query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
DELETE /movers/1 DELETE /movers/1.json
def destroy @mover.destroy head :no_content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @verb.destroy\n respond_to do |format|\n format.html { redirect_to verbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verb.destroy\n\n head :no_content\n end", "def destroy\n @ver.destroy\n respond_to do |format|\n format.html { redirect_to vers_url, notice: 'Ver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @verbo = Verbo.find(params[:id])\n @verbo.destroy\n\n respond_to do |format|\n format.html { redirect_to verbos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @jm_verse = JmVerse.find(params[:id])\n @jm_verse.destroy\n\n respond_to do |format|\n format.html { redirect_to jm_verses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url, flash: {success: t('app.msgs.success_deleted', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @m1.destroy\n respond_to do |format|\n format.html { redirect_to m1s_url, notice: 'M1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end", "def destroy\n @mou.destroy\n respond_to do |format|\n format.html { redirect_to mous_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @serv = Serv.find(params[:id])\n if @serv.mngbl\n #Remueve el MR a través de una llamada al webservice del núcleo\n http = Net::HTTP.new(\"192.168.119.163\",9999)\n post_params = {'ip' => @serv.conn.ip, 'port' => @serv.conn.port}\n request = Net::HTTP::Delete.new(\"/mbs/#{@serv.domain}/#{@serv.name}\")\n request.set_form_data(post_params)\n begin\n response = http.request(request)\n rescue Errno::ECONNREFUSED\n end\n end\n @serv.destroy\n\n respond_to do |format|\n format.html { redirect_to servs_url, notice: t('servs.delete.notice') }\n format.json { head :no_content }\n end\n end", "def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verse = Verse.find(params[:id])\n @verse.destroy\n\n respond_to do |format|\n format.html { redirect_to verses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verse = Verse.find(params[:id])\n @verse.destroy\n\n respond_to do |format|\n format.html { redirect_to verses_url }\n format.json { head :no_content }\n end\n end", "def delete(vmname)\n uri = @uri + \"/#{vmname}?api-version=#{api_version}\"\n uri\n end", "def destroy\n @mrv.destroy\n respond_to do |format|\n format.html { redirect_to mrvs_url, notice: 'Mrv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @verma.destroy\n respond_to do |format|\n format.html { redirect_to vermas_url, notice: 'Verma was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mote = Mote.find(params[:id])\n @mote.destroy\n\n respond_to do |format|\n format.html { redirect_to motes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mob.destroy\n respond_to do |format|\n format.html { redirect_to mobs_url }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n @instrument_version.destroy\n\n respond_to do |format|\n format.html { redirect_to(instrument_versions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @momsg = Momsg.find(params[:id])\n @momsg.destroy\n\n respond_to do |format|\n format.html { redirect_to momsgs_url }\n format.json { head :ok }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def delete\n request(:delete)\n end", "def destroy\n @mobs_nano = MobsNano.find(params[:id])\n @mobs_nano.destroy\n\n respond_to do |format|\n format.html { redirect_to mobs_nanos_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @demot = Demot.find(params[:id])\n @demot.destroy\n\n respond_to do |format|\n format.html { redirect_to demots_url }\n format.json { head :no_content }\n end\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @mot_m.destroy\n respond_to do |format|\n format.html { redirect_to matches_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @vano = Vano.find(params[:id])\n @vano.destroy\n\n respond_to do |format|\n format.html { redirect_to vanos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @v1_order = V1::Order.find(params[:id])\n @v1_order.destroy\n\n head :no_content\n end", "def destroy\n @moresmalltrial = Moresmalltrial.find(params[:id])\n @moresmalltrial.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmalltrials_url }\n format.json { head :no_content }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @mensagem = Mensagem.find(params[:id])\n api_client.delete_object(@mensagem.post_id)\n @mensagem.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.js { head :ok }\n end\n end", "def destroy\n @moretinymobtrail = Moretinymobtrail.find(params[:id])\n @moretinymobtrail.destroy\n\n respond_to do |format|\n format.html { redirect_to moretinymobtrails_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @file_version = FileVersion.find(params[:id])\n @file_version.destroy\n\n respond_to do |format|\n format.html { redirect_to file_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @monit = Monit.find(params[:id])\n @monit.destroy\n\n respond_to do |format|\n format.html { redirect_to monits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @observ.destroy\n respond_to do |format|\n format.html { redirect_to observs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @votaciones_hist.destroy\n respond_to do |format|\n format.html { redirect_to votaciones_hists_url, notice: 'Votaciones hist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @voc = Voc.find(params[:id])\n @voc.destroy\n\n respond_to do |format|\n format.html { redirect_to vocs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @version = Version.find(params[:id])\n @version.destroy\n\n respond_to do |format|\n format.html { redirect_to versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @promos = Promos.find(params[:id])\n @promos.destroy\n\n respond_to do |format|\n format.html { redirect_to(promos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @revision = Revision.find(params[:id])\n @revision.destroy\n\n respond_to do |format|\n format.html { redirect_to @revision.page }\n format.json { head :no_content }\n end\n end", "def destroy\n @fileversion = Fileversion.find(params[:id])\n @fileversion.destroy\n\n respond_to do |format|\n format.html { redirect_to fileversions_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @metum = Metum.find(params[:id])\n @metum.destroy\n\n respond_to do |format|\n format.html { redirect_to meta_url }\n format.json { head :ok }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pinglun = Pinglun.find(params[:id])\n @pinglun.destroy\n\n respond_to do |format|\n format.html { redirect_to pingluns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verbindung = Verbindung.find(params[:id])\n @verbindung.destroy\n\n respond_to do |format|\n format.html { redirect_to verbindungs_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @serving = Serving.find(params[:id])\n @serving.destroy\n\n respond_to do |format|\n format.html { redirect_to servings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @version.destroy\n respond_to do |format|\n format.html { redirect_to alfred_module_url(@a_module), notice: 'Version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n @v1_message = V1::Message.find(params[:id])\n @v1_message.destroy\n\n head :no_content\n end", "def destroy\n @promo = Promo.find(params[:id])\n @promo.destroy\n\n respond_to do |format|\n format.html { redirect_to promos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @promo = Promo.find(params[:id])\n @promo.destroy\n\n respond_to do |format|\n format.html { redirect_to promos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mi = Mi.find(params[:id])\n @mi.destroy\n\n respond_to do |format|\n format.html { redirect_to mis_url }\n format.json { head :ok }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def delete\n delete_from_server single_url\n end", "def destroy\n @mill = Mill.find(params[:id])\n @mill.destroy\n\n respond_to do |format|\n format.html { redirect_to mills_url }\n format.json { head :no_content }\n end\n end", "def DeleteView id\n \n APICall(path: \"views/#{id}.json\",method: 'DELETE')\n \n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @metodo = Metodo.find(params[:id])\n @metodo.destroy\n\n respond_to do |format|\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @moment = Moment.find(params[:id])\n @moment.destroy\n\n respond_to do |format|\n format.html { redirect_to moments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @moonwalk.destroy\n respond_to do |format|\n format.html { redirect_to moonwalks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @version.destroy\n respond_to do |format|\n format.html { redirect_to user_app_path(@user, @app), notice: 'Version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @razmer_go = RazmerGo.find(params[:id])\n @razmer_go.destroy\n\n respond_to do |format|\n format.html { redirect_to razmer_gos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vano.destroy\n respond_to do |format|\n format.html { redirect_to vanos_url, notice: 'Vano was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def destroy\n @nvs_mig_status = NvsMigStatus.find(params[:id])\n @nvs_mig_status.destroy\n\n respond_to do |format|\n format.html { redirect_to nvs_mig_statuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @turbo_memoid = TurboMemoid.find(params[:id])\n @turbo_memoid.destroy\n\n respond_to do |format|\n format.html { redirect_to turbo_memoids_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @version = Version.find(params[:id])\n @versionconfig = @version.version_configurations.destroy_all\n @version.destroy\n\n respond_to do |format|\n format.html { redirect_to [@application, @version] }\n format.json { head :no_content }\n end\n end", "def destroy\n @mate = Mate.find(params[:id])\n @mate.destroy\n\n respond_to do |format|\n format.html { redirect_to mates_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n request 'DELETE', path\n end", "def delete(*rest) end", "def destroy\n if @short_url.destroy\n render json: { status: \"Deleted\" }\n else\n render json: { head: \"no content\" }\n end \n end", "def destroy\n @monel = Monel.find(params[:id])\n @monel.destroy\n\n respond_to do |format|\n format.html { redirect_to monels_url }\n format.json { head :ok }\n end\n end", "def delete(path)\n request(:delete, path)\n end", "def delete_story_version(id)\n @client.raw('delete', \"/content/story-versions/#{id}\")\n end", "def destroy\n @sinh_vien = SinhVien.find(params[:id])\n @sinh_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def delete\n object.delete(:version_id => @version_id)\n end", "def destroy\n @vod.destroy\n respond_to do |format|\n format.html { redirect_to vods_url, notice: 'Vod was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @venta = Venta.find(params[:id])\n @venta.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end" ]
[ "0.73285717", "0.6927342", "0.6804239", "0.6769565", "0.67591625", "0.67119193", "0.67022914", "0.668431", "0.667599", "0.66255075", "0.66076225", "0.65931666", "0.65872884", "0.6570591", "0.6567346", "0.6560736", "0.65507025", "0.65507025", "0.6540325", "0.6532836", "0.6521344", "0.65114224", "0.65008765", "0.6494923", "0.64917207", "0.6469816", "0.6449768", "0.6449233", "0.64446396", "0.6438936", "0.6438019", "0.6436325", "0.6428332", "0.6413471", "0.6412193", "0.6411812", "0.64085513", "0.6402903", "0.6400881", "0.6381647", "0.6379424", "0.63735825", "0.6367031", "0.6365077", "0.6362183", "0.6361966", "0.6361248", "0.63488203", "0.6345853", "0.63412195", "0.63364005", "0.6336313", "0.6336313", "0.6336313", "0.6336313", "0.63360155", "0.6333696", "0.6333374", "0.63329107", "0.633042", "0.632882", "0.632882", "0.63267356", "0.6323962", "0.63221884", "0.6319316", "0.6309071", "0.6305046", "0.63006353", "0.63006353", "0.6297346", "0.6294516", "0.6293316", "0.6292445", "0.6291533", "0.629049", "0.62898743", "0.62857103", "0.6285288", "0.62846935", "0.62844545", "0.62844545", "0.6283319", "0.628204", "0.62812793", "0.6277612", "0.627757", "0.6275851", "0.62741405", "0.6272335", "0.6270404", "0.62687814", "0.6267022", "0.62658745", "0.62623495", "0.62610114", "0.6256965", "0.62534654", "0.62520707", "0.6252004", "0.6251651" ]
0.0
-1
before_filter :authenticate , :except => [:get_dealers, :get_zones]
def index @users = get_model.paginate :page => params[:page] @countries = get_countries.all @roles = get_roles.all respond_to do |format| format.html format.js { render :partial => 'list', :object => [ @roles, @users ] } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_filter; end", "def authorize\n redirect_to '/' unless current_user || current_dealer\n end", "def before_each(req)\n if dealership(req).nil? then not_found\n elsif !authenticated?(req) then unauthenticated\n elsif !authorized?(role(req), session_user(req)) then unauthorized\n else super\n end\n end", "def show\n skip_authorization\n end", "def before_filter\n if current_user\n true\n end\n end", "def run_filters\n set_user\n authorize\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def skip_authorization; end", "def whitelist\n if cannot_access_api?\n render json: [], status: :unauthorized\n end\n end", "def index\n\n if current_user.admin?\n @dealers = Dealer.all\n else\n redirect_to root_path\n end\n\n end", "def authorized\n redirect_to \"/login\" unless logged_in? \n end", "def authorization_filter\n unless controller_name == 'dashboard' || authorized?\n respond_to do |wants|\n wants.html { redirect_to '/' }\n wants.js { render :nothing => true}\n end\n return false\n end\n end", "def authorization_filter\n unless controller_name == 'dashboard' || authorized?\n respond_to do |wants|\n wants.html { redirect_to '/' }\n wants.js { render :nothing => true}\n end\n return false\n end\n end", "def reset_filter!\n skip_before_action(:filter_access_filter) if method_defined?(:filter_access_filter)\n before_action :filter_access_filter\n end", "def not_authenticated\n redirect_to root_landing_url\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def login_filter\n\t\tif not protect?( action_name )\n\t\t\treturn true \n\t\tend\n\n\t\tif not session[:user_id]\n\t\t\t# user isn't logged in\n\t\t\tstore_location\n\t\t\tredirect_to :controller=>\"account\", :action=>\"login\"\n\t\t\treturn false\n\t\tend\n\n\t\t# initialize the @user variable\n\t\t@user = User.find( session[:user_id] )\n\t\t\n\t\tif not @user.validated?\n\t\t\t# user is logged in, but they haven't been validated\n\t\t\tredirect_to :controller=>\"account\", :action=>\"not_activated\"\n\t\t\treturn false\n\t\telsif not authorized?( @user, action_name )\n\t\t\t# user is logged in and validated, but not authorized\n\t\t\tredirect_to :controller=>\"account\", :action =>\"denied\"\n\t\t\treturn false\n\t\telse\n\t\t\t# user is logged in AND validated AND authorized! let 'em in!\n\t\t\treturn true\t\n\t\tend\n\n\t\t# we shouldn't get here\n\t\traise \"Serious malfunction in 'login_filter' -- please contact manufacturer ([email protected])...\"\n\tend", "def castle_filter\n return unless resource_class.castle_hooks[:before_registration]\n\n response = CastleDevise.sdk_facade.filter(\n event: \"$registration\",\n context: CastleDevise::Context.from_rack_env(request.env, resource_name)\n )\n\n return if CastleDevise.monitoring_mode?\n\n case response.dig(:policy, :action)\n when \"deny\"\n set_flash_message!(:alert, \"blocked_by_castle\")\n flash.alert = \"Account cannot be created at this moment. Please try again later.\"\n redirect_to new_session_path(resource_name)\n false\n else\n # everything fine, continue\n end\n rescue Castle::InvalidParametersError\n # TODO: We should act differently if the error is about missing/invalid request token\n # compared to any other validation errors. However, we can't do this with the\n # current Castle SDK as it doesn't give us any way to differentiate these two cases.\n CastleDevise.logger.warn(\n \"[CastleDevise] /v1/filter request contained invalid parameters.\" \\\n \" This might mean that either you didn't configure Castle's Javascript properly, or\" \\\n \" a request has been made without Javascript (eg. cURL/bot).\" \\\n \" Such a request is treated as if Castle responded with a 'deny' action in\" \\\n \" non-monitoring mode.\"\n )\n\n unless CastleDevise.monitoring_mode?\n set_flash_message!(:alert, \"blocked_by_castle\")\n redirect_to new_session_path(resource_name)\n false\n end\n rescue Castle::Error => e\n # log API errors and allow\n CastleDevise.logger.error(\"[CastleDevise] filter($registration): #{e}\")\n end", "def filter_self\n if @user && !current_user.can_edit?(@user)\n respond_to do |format|\n format.html {\n render :nothing => true, :status => 403\n }\n format.json {\n render :json => {:status => 'failure'}, :status => 403\n }\n end\n end\n end", "def filter_redirect; end", "def filter_redirect; end", "def index\n redirect_to(:action => 'login') unless logged_in? \n end", "def authenticate\n deny_access unless signed_in? \n end", "def authenticate\n CASClient::Frameworks::Rails::Filter.before(self)\n update_current_user(User.eager_load(*eager_loads).find_by(cas_directory_id: session[:cas_user]))\n\n return unless session[:cas_user] && !allow_access\n render(file: File.join(Rails.root, 'public/403.html'), status: :forbidden, layout: false)\n end", "def authenticate_request\n render :json => { :error => :unauthorized }, :status => :unauthorized unless current_user\n end", "def filter_request(request)\n @token.authenticate(request)\n end", "def authorize\n redirect_to :login unless user_signed_in?\n end", "def authenticate\n\n redirect_to_login if current_user.nil?\n \n end", "def index\n # Handle bookmarked or otherwise incorrect GETs to the login action\n if request.method == :get\n redirect_to login_path\n else\n redirect_to member_home_path\n end\n end", "def authorize\n redirect_to('/login') unless @current_user\n end", "def show_lawyer_list\n authorize!(:show_lawyer_list,current_user) unless current_user.role?:secretary\n #session[:verified_secretary_id1] = params[:service_provider_id]\n if params[:search].nil?\n @employees = Employee.paginate :page => params[:page], :order => 'employees.created_at DESC', :per_page=>20, :include=>[:user=>[:role,:service_provider_employee_mappings]]\n else\n @employees = Employee.get_employees(params)\n end\n end", "def login_required\n # Skip this filter if the requested action is not protected\n return true unless protect?(action_name)\n\n # Check if user is logged in and authorized\n return true if logged_in? and authorized?(current_user)\n\n # Store current location so that we can redirect back after login\n store_location\n\n # Call access_denied for an appropriate redirect and stop the filter\n # chain here\n access_denied and return false\n end", "def login_required\n not_authorized unless current_user\n end", "def authenticate_user\n\t\trender_unauthorized unless current_user\n\tend", "def authenticate_user\n render_403 'Invalid user.' if @user.blank? || [email protected]?\n end", "def restrict_access\n head :unauthorized and return false unless current_user\n end", "def needs_authenticate_user?\n except_actions = %w[index show]\n !except_actions.include?(action_name)\n end", "def signed_in_user_filter\n if signed_in?\n redirect_to root_path, notice: \"Already logged in\"\n end\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authenticate\n logged_in? || access_denied\n end", "def restrict_access\n render :\"/home/http_404\" unless @profile && @profile.user == current_user\n end", "def no_authentication_required(*options)\n skip_before_filter :require_authentication, options\n end", "def users_only\n redirect_to band_path(current_user.accountable) if is_band\n end", "def check_authentication\n case self.controller_name\n when /^clients/i, /^ingredients/i, /^orders/i, /^pages/i, /^productpresentations/i, /^products/i, /^companies/i\n authenticate\n end\n end", "def authenticate\n \t\tlogged_in? || access_denied\n \tend", "def require_login\n\t\tauthorize_request || render_unauthorized(\"Access Denied\")\n\tend", "def skip_authorization_check(*args)\n before_action(*args) do |controller|\n controller.instance_variable_set(:@_authorized, true)\n end\n end", "def restrictToAdmin! ; redirect to('/login'),303 unless admin? ; end", "def protected\n auth = request.headers['HTTP_AUTHORIZATION']\n\n if auth =~ /sekret/\n render json: {success: \"You're in!\"}\n else\n render json: {error: 'Unauthorized'}, status: 401\n end\n end", "def authenticate_owner!\n category = Category.find(params[:id])\n render \"errors/404\" unless category.order != 0 && category.setup.venture.user_id == current_user.id\n end", "def authorized\n redirect_to :controller => 'home', :action => 'index' unless logged_in?\n end", "def authenticate\n unless logged_in?\n redirect_to login_url\n end\n end", "def authenticate\n respond_to do |format|\n format.js { render nothing: true, status: 401 if current_user.nil? }\n format.html { redirect_to root_url if current_user.nil? }\n end\n end", "def authenticate!\n unless current_user\n redirect \"/login\"\n end\nend", "def logged_in_user_or_customer\n unless user_logged_in? || customer_logged_in?\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end\n end", "def auth_controller?\n false\n end", "def authorize\n unless current_user\n respond_to do |format|\n format.html { redirect_to \"http://localhost:3000/signin\" , notice: 'Please sign in!.' }\n end\n end\nend", "def authenticate\n redirect_to :login unless user_signed_in?\n end", "def authenticate_user!\n \tunless current_user?\n \trender status: :unauthorized\n \tend\n end", "def authenticate\n\tdeny_access unless signed_in?\n end", "def authenticate\n\n # This suppresses the log in suggestion on subsequent\n # request if the user clicks \"No\"\n if params[:stay_anonymous]\n cookies[:shunt_hint] = 'anonymous'\n logger.info \"Suppressing log in suggestion\"\n redirect_to url_for(params.except!(:stay_anonymous))\n end\n\n if params[:public]\n cookies[:shunt_hint] = 'public'\n redirect_to url_for(params.except!(:public))\n end\n\n if should_force_authentication\n force_authentication\n end\n end", "def authenticate\n\t\tdeny_access unless signed_in?\n\tend", "def index\n render json: filter(@current_user), status: :ok if @current_user\n render json: { message: 'expired' }, status: :not_found if !@current_user\n end", "def require_no_user(options = {})\n self.before_filter options do |controller|\n controller.send(:require_no_user)\n end\n end", "def unauthenticated\n end", "def restrict_access\n render :\"/home/http_404\" unless @pet && @pet.user == current_user\n end", "def authenticate\n render json: { error: 'Access Denied' }, status: 401 unless current_user\n end", "def authorize\n return if current_user\n\n redirect_to login_url\n end", "def authenticate_admin!\n render_404 unless current_user.try(:admin?) && current_user\n end", "def authenticate\n logged_in? ? true : access_denied\nend", "def correct_initiative_only\n unless current_user.admin?\n if current_user.service_user? || current_user.initiatives.exclude?(Initiative.find(params[:id]))\n flash[:danger] = 'You are not allowed to access that page.'\n redirect_to current_user\n end\n end\n end", "def check_flickr_auth\n return unless current_user\n exempt_controllers = ['sessions','users']\n unless current_user.flickr_token && current_user.flickr_user_id\n redirect_to edit_user_path(current_user) unless exempt_controllers.include?(params[:controller])\n end\n end", "def require_auth\n\n # When no user is logged in, redirect the visitor to the login page\n if @user.nil?\n respond_to do |format|\n format.html { redirect_to :controller => :auth, :action => :login }\n end\n end\n\n end", "def correct_initiative_only\n unless current_user.admin?\n if current_user.service_user? || current_user.initiatives.exclude?(Initiative.find(params[:initiative_id]))\n flash[:danger] = 'You are not allowed to access that page.'\n redirect_to current_user\n end\n end\n end", "def authenticate\n\tlogged_in? ? true : access_denied \n end", "def authenticate\n deny_access unless signed_in?\n end", "def authenticate\n deny_access unless signed_in?\n end", "def index\n if current_user.role == 'Party'\n @customers = current_user.customers\n else\n @customers = Customer.all\n end\n end", "def authenticate\n deny_access unless loged_in?\n end", "def unauthorized_request user:current_user,filter:nil\n\t\t\tputs \"\\n\\nNo filter matches the given http method, controller, or controller method, rerouting...\" if filter.blank?\n\t\t\tputs \"\\n\\nUser #{user.email} is not authorized to #{filter.http_method.upcase}::>#{filter.controller || 'all'}.#{filter.action_name || 'all'}, rerouting...\\n\\n\" unless filter.blank?\n\t\t\trender json: \"Unauthorized Request\"\n\t\tend", "def index\n redirect_to(:action => 'login') #unless logged_in? || User.count > 0\n end", "def index\n #before_action :authenticate_user\n #if current_user.admin?\n @users = User.all\n render json: @users, status: :ok\n #else\n # render json: [], status: :unauthorized\n #end\n end", "def authenticate!\n\t\t# :authenticate_user!\n\n\t\t# if u are trying to access any pages other than the sign in page and you are not a user, you are redirected to the login page\n\t\tif current_user.nil? && protected_routes\n\t\t\tredirect_to new_user_session_path, alert: \"Must sign in to proceed\" and return\n\t\tend\n\t\tif params[:controller] == 'posts' && params[:id] && !params[:commit] == 'Search'\n\t\t\tcurrent_post = Post.find(params[:id])\n\t\t\tif (params[:action] == 'edit' || params[:action] == 'update' || params[:action] == 'destroy')\n\t\t\t if current_post.user == current_user\n\t\t\t # when you return from authentication!, the program continues to requested page\n\t\t\t return\n\t\t\t else\n\t\t\t # by redirecting here, we are preventing the user from visiting the requested page\n\t\t\t redirect_to root_url, notice: \"Record not found\" and return\n\t\t\t end\n\t\t\tend\n\t\tend\n\t\tif params[:controller] == 'answers' && params[:id] \n\t\t\tcurrent_answer = Answer.find(params[:id])\n\t\t\tif (params[:action] == 'edit' || params[:action] == 'update' || params[:action] == 'destroy')\n\t\t\t if current_answer.user == current_user\n\t\t\t # when you return from authentication!, the program continues to requested page\n\t\t\t return\n\t\t\t else\n\t\t\t # by redirecting here, we are preventing the user from visiting the requested page\n\t\t\t redirect_to root_url, notice: \"Record not found\" and return\n\t\t\t end\n\t\t\tend\n\t\tend\n\tend", "def index\n if current_user.role == 'Party'\n @customers = current_user.party.customers\n else\n @customers = Customer.all\n end\n end", "def authenticate_conditionally\n authenticate unless can? :be_anonymous, User\n end", "def authenticate_user\n redirect_to \"/login\" unless logged_in?\n end", "def index\n if(current_user.customer_id?)\n @resturants = Resturant.where(\"region_id = ?\", current_user.customer.region_id)\n else\n @resturants = Resturant.where(\"region_id = ?\", current_user.driver.region_id)\n end\n \n render json: @resturants, status: 200\n end", "def authorize\n redirect_to login_url, alert: \"Not authorized\" if current_user.nil?\n end", "def authorize\n redirect_to login_url, alert: \"Not authorized\" if current_user.nil?\n end", "def authorize\n redirect_to login_url, alert: \"Not authorized\" if current_user.nil?\n end", "def authorized\n redirect_to '/signin' unless current_driver\n end", "def require_login\n unless current_account\n if request.xhr?\n return respond_to do |format|\n format.js { render 'shared/login', layout: false, status: 401}\n end\n else\n if ['collect', 'uncollect'].include? action_name\n session[:redirect_to] = request.referer\n end\n authenticate_account!\n end\n end\n end", "def show\n #authorize! :read, Transport\n @passengers = @transport.passengers\n end", "def authenticate\n logged_in? || access_denied\n end" ]
[ "0.68926954", "0.67334634", "0.6531955", "0.64141935", "0.62292796", "0.6224203", "0.61926466", "0.61796427", "0.6172221", "0.6140805", "0.61108935", "0.61011034", "0.61011034", "0.6080525", "0.6064698", "0.60575485", "0.60575485", "0.60575485", "0.60575485", "0.60575485", "0.60575485", "0.60575485", "0.60575485", "0.60572606", "0.6053617", "0.60313714", "0.60243106", "0.60243106", "0.6011295", "0.6007968", "0.60065174", "0.5998178", "0.59903145", "0.59893924", "0.5975714", "0.59738404", "0.59675914", "0.5951054", "0.59430957", "0.5941123", "0.5935914", "0.5932793", "0.59292054", "0.5926574", "0.5924259", "0.59215516", "0.59097785", "0.59063303", "0.58953685", "0.58935624", "0.58760977", "0.58684427", "0.5865203", "0.5859912", "0.58589274", "0.5849787", "0.58429927", "0.58412427", "0.5833595", "0.5832778", "0.5825441", "0.58190954", "0.5817444", "0.5816063", "0.58112603", "0.58100545", "0.5807532", "0.58036846", "0.58036697", "0.57930404", "0.57846266", "0.57816607", "0.5772828", "0.57710665", "0.5764582", "0.5760231", "0.5759006", "0.57582444", "0.5756527", "0.5742636", "0.5742631", "0.57378167", "0.5736608", "0.5736608", "0.5735446", "0.573506", "0.5734518", "0.57344526", "0.57329386", "0.57327014", "0.5729982", "0.572488", "0.57242036", "0.5722878", "0.5722554", "0.5722554", "0.5722554", "0.57224995", "0.57209784", "0.57169515", "0.5709963" ]
0.0
-1
pirates_say_arrrrrrrrr("are you really learning Ruby?") => "eenu" pirates_say_arrrrrrrrr("Katy Perry is on the radio!") => "rya" pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") => "arrrrrrrr"
def pirates_say_arrrrrrrrr(string) new_string = [] string.split(//).each_with_index do |l, i| if l == "r" || l == "R" new_string << string[i + 1] end end new_string.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pirates_say_arrrrrrrrr(string)\n\nend", "def offer_rose (string)\r\n \"Would you take this rose, #{string}, in exchange for giving an old beggar woman shelter from the bitter cold?\" \r\nend", "def pirates_say_arrrrrrrrr(string)\n\nstring.downcase!\nsplitsplat = string.split(//)\nresult = \"\"\n\nsplitsplat.each_with_index do |l, index|\n if l == \"r\"\n result << splitsplat[index + 1].to_s\n end\nend\nreturn result\nend", "def pirates_say_arrrrrrrrr(string)\n new_string = ''\n string.downcase.chars.map.with_index{ |char, idx| new_string += string[idx+1].to_s if char == 'r' }\n new_string\nend", "def pirates_say_arrrrrrrrr(string)\nto_return = \"\"\nr_last = false\n\nstring.downcase.each_char do |c|\n\tto_return << c if r_last\n\tr_last = (c == \"r\")\n\tend\n\nto_return\nend", "def pirates_say_arrrrrrrrr(string)\n\tresult = ''\n\tstring_array = string.downcase.split('')\n\tstring_array.each.with_index{|x,i| result += string_array[i+1] if x == 'r' && i != string.length - 1}\n\treturn result\nend", "def pirates_say_arrrrrrrrr(string)\n\n ans = \"\"\n\n a = string.split(//)\n # Splits each letter into an array and assigns it to variable \"a\".\n\n a.each_with_index do | x, i |\n\n # Calls a block (everything after pipes) with two arguments \"x\" and \"i\".\n\n # \"x\" represents the current letter in the array and \"i\" represents the index of the current letter in the array.\n\n # So in the below the current character and its index is passed into the block.\n\n if x.downcase == \"r\"\n\n # This block asks \"is the current character (i.e. \"x\") a letter \"r\"? The .downcase adds to this, meaning we're actually asking if x was lower case would it match lower case \"r\". If it does then ruby executes the below.\n\n ans << a[i+1].to_s\n\n # This selects the next character after the current character using its index (\"[i+1]\"), converts it to a string and adds it to the current stored value of ans.\n\n end\n\n end\n\n ans\n\nend", "def pirates_say_arrrrrrrrr(string)\n other_word = \"\"\n string.length.times do | index |\n if ((string[index].downcase.include? \"r\") && (string[index + 1] != nil))\n other_word << string[index + 1]\n end\n end\n\n return other_word\nend", "def pirates_say_arrrrrrrrr(string)\n\tstring.split('').select.with_index { |item, i|\n\t\tstring.split('')[i-1].downcase == 'r' if i > 0\n\t}.join\nend", "def pirates_say_arrrrrrrrr(string)\n new_array = []\n array = string.downcase.split(\"\")\n i = 0\n while i < array.length\n new_array.push(array[i+1]) if array[i] == \"r\"\n i += 1\n end\n return new_array.join.to_s\nend", "def pirates_say_arrrrrrrrr(string)\n output = \"\"\n string.length.times do |index|\n output << string[index+1] if string[index].downcase == \"r\" && index < (string.length - 1)\n \n end\n return output\nend", "def pirates_say_arrrrrrrrr(string)\n newstring = ''\n string.downcase!\n string.length.times do |index|\n newstring += string[index + 1] if char_is_r(string, index) && next_char_not_nil(string, index)\n end\n newstring\nend", "def pirates_say_arrrrrrrrr(string)\n\tnew_string = \"\"\n\tstring_array = string.split('')\n\tfor i in 0..string_array.length-1\n\t\tif string_array[i] == \"r\" || string_array[i] == \"R\"\n\t\t\tnew_string << string_array[i+1].to_s\n\t\tend\n\tend\n\tnew_string\nend", "def pirates_say_arrrrrrrrr(string)\n\tcounter = 0\n\tpirate_string = \"\"\n\twhile counter < string.length - 1 do \n\n\t\tif string[counter] == \"r\" || string[counter] == \"R\"\n\t\t\tpirate_string += string[counter + 1]\n\t\tend\t\n\n\t\tcounter += 1\n\tend\n\t return pirate_string \nend", "def pirates_say_arrrrrrrrr(string)\n return \"\" if string == \"\"\n string.downcase!\n result = \"\"\n (0..string.length-2).each do |i|\n if string[i] == 'r'\n result += string[i + 1]\n end\n end\n result\nend", "def pirates_say_arrrrrrrrr(string)\n result = \"\"\n string.each_char.with_index() do |char, i|\n if char.downcase == \"r\" and i < string.length - 1\n result += string[i + 1]\n end\n end\n result\nend", "def pirates_say_arrrrrrrrr(string)\n\tletters = string.split(\"\")\n\n\tword = []\n\ti = 1\n\tletters.each do |element|\n\t\tif element == \"r\" || element == \"R\"\n\t\t\tword.push(letters[i])\t\n\t\tend\n\ti +=1\n\tend\n\treturn word.join(\"\")\nend", "def friendly_parrot (name, age)\n \"You are called #{name} and you are #{age}\"\nend", "def pirates_say_arrrrrrrrr(string)\n string.each_char.each_cons(2)\n .with_object(\"\") do |(a,b), to_return|\n next unless a.downcase == \"r\"\n to_return << b\n end\nend", "def pirates_say_arrrrrrrrr(string)\n\tcharacters = string.split('')\n\tchar_index = []\n\toutput = \"\"\n\tcharacters.each_with_index {|char,index| char.downcase == \"r\" ? char_index.push(index += 1) : ''}\n \tcharacters.map.with_index {|char,index| char_index.include?(index) ? output << char : nil }.compact\n return output\nend", "def sayHello( name=\"Stranger\", adjective=\"stinky\" )\n puts \"Hello #{ adjective } #{ name }\"\n \"hotdogs hotdogs hotdogs\"\nend", "def pirates_say_arrrrrrrrr(string)\n s = \"\"\n ((0 ... string.length).find_all { |i| string.downcase[i,1] == 'r' }).each do |c|\n if c < (string.length-1) then s += string[c+1] end\n end\n return s\nend", "def pirates_say_arrrrrrrrr(string)\n string\n .each_char\n .each_with_index\n .map { |char, index| string[index + 1] if char.downcase == 'r' }\n .compact\n .join\nend", "def favourite_language(fav_language)\n return \"I love #{fav_language}\"\nend", "def pirates_say_arrrrrrrrr(string)\n return_string = \"\"\n\n string_length = string.length\n\n for x in 0...string_length\n if string[x] == \"r\" || string[x] == \"R\"\n return_string << string[x+1] unless (x+1) == string_length\n end\n end\n return_string\nend", "def pirates_say_arrrrrrrrr(string)\n\tto_array = string.downcase.split(\"\")\n\tnew_arr = []\n\tcount = 0\n\tto_array.length.times do\n\t\tif to_array[count] == \"r\"\n\t\t\tnew_arr << to_array[count+1]\n\t\tend\n\tcount += 1\n\tend\n\tnew_arr.join\nend", "def pirates_say_arrrrrrrrr(string)\n a = \"\"\n (string.length - 1).times do |x|\n a.concat(string[x+1]) if string[x].downcase == \"r\"\n end\n a\nend", "def friendly_parrot(name, age)\n \"Hi, Are you #{name}? You're #{age} years old.\"\nend", "def pirates_say_arrrrrrrrr(string)\n\n string_array = string.chars\n indexes = string_array.each_with_index.map {|char, index| char.downcase == 'r' ? index : nil}.compact # gives an array of the indexes we want\n indexes.map {|x| string_array[x+1]}.join # iterates through each index for string_array \n\nend", "def pirates_say_arrrrrrrrr(string)\nz = \"\"\nstring.split(\"\").each_index{|x| z << string[x+1] if string.downcase[x] == \"r\" && string[x+1] != nil }\nz\nend", "def pirates_say_arrrrrrrrr(string)\n #sort through letters in a string, return next letter\n array = string.split('')\n array.select.each_with_index do |item, index|\n if item == \"r\" \n array[index + 1].join\n else\n nil\n end\n end\nend", "def sayGoodnight(name)\n result = \"Goodnight, #{name}\" \n # return result\nend", "def pirates_say_arrrrrrrrr(string)\n counter = 0\n result = ''\n while counter <= string.length\n if (string[counter] == \"r\" || string[counter] == \"R\") && counter < (string.length - 1)\n result += string[counter + 1]\n end\n counter += 1\n end\n result\nend", "def pirates_say_arrrrrrrrr(string)\nresult = \"\"\n string.size.times { |i| result << string[i+1] if string[i] == \"r\" || string[i] == \"R\"}\nreturn result\nend", "def pirates_say_arrrrrrrrr(string)\n result = \"\"\n string.each_char.with_index do |letter, index|\n unless string.size-1 == index\n if (letter == \"r\" || letter == \"R\")\n next_letter = string[index + 1]\n result = result + next_letter\n end\n end\n end\n return result\nend", "def pirates_say_arrrrrrrrr(string)\n holder = String.new\n i = 0\n until i+1 == string.length\n holder << string[i+1] if string[i] == \"r\" || string[i] == \"R\"\n i +=1\n end\n holder\nend", "def pirates_say_arrrrrrrrr(string)\n arr = string.downcase.split(\"\")\n r_array = []\n arr.each_with_index do |elem, index|\n if elem == \"r\"\n r_array << index + 1\n end\n end\n final = []\n r_array.each {|x| final << arr[x]}\n return final.join(\"\")\nend", "def pirates_say_arrrrrrrrr(string)\n\tstring.chars.each_with_index.map { |c, i|\n\t\tif c.downcase == 'r' then string[i + 1] else \"\" end\n\t}.join(\"\")\nend", "def pirates_say_arrrrrrrrr(string)\n output = \"\"\n string.chars.each_with_index do |n, index|\n if string[index] == \"r\" || string[index] == \"R\"\n output << string[index+1,1]\n else\n end\n end\n return output\nend", "def polly_wanna(word)\n return word*3\nend", "def friendly_parrot(name, age)\n \"Hello #{name} you are #{age}\"\nend", "def friendly_parrot(name, age)\n \"Hi #{name}, you're #{age} years old.\"\nend", "def shout(word)\n# irb(main):012:1> \nreturn \"HOLA\"\n# irb(main):013:1> \nend", "def pirates_say_arrrrrrrrr(string)\n r_indexes = []\n string.split(\"\").each_with_index{|letter, index| r_indexes << index if letter.downcase == \"r\"}\n plusoneindex = r_indexes.map{|index| index + 1}\n answer = \"\"\n plusoneindex.map{|index| string.split(\"\")[index]}.join\n\nend", "def pirates_say_arrrrrrrrr(string)\n a = string.split(\"\")\n return_string = Array.new\n\n a.length.times { |x| return_string.push(a[x + 1]) if a[x] == \"r\" || a[x] == \"R\" }\n\n return_string.join(\"\")\nend", "def pirates_say_arrrrrrrrr(string)\n resultArr = []\n\n string.split(\"\").each_index do |x|\n if (string[x].downcase === \"r\" && string[x+1] != nil)\n resultArr.push(string[x+1])\n end\n end\n\n return resultArr.join(\"\")\n\n\nend", "def pirates_say_arrrrrrrrr(string)\n to_return = \"\"\n next_letter = false\n string.size.times do |letter|\n current_letter = string[letter]\n to_return << current_letter if next_letter\n next_letter = (current_letter == \"r\" or current_letter == \"R\")\n end\n to_return\n \nend", "def whisper(phrase)\n return \"#{phrase.downcase}...shhhhhhh\"\nend", "def pirates_say_arrrrrrrrr(string)\n\tchars = string.split(//)\n\treturnString = ''\n\tchars.each_with_index do |c,i|\n\t\treturnString << chars[i+1].to_s if c == 'r' || c == 'R'\n\tend\n\treturnString\nend", "def sayGoodnightTo(name)\n result = \"Goodnight, #{name}!\"\nend", "def pirate_speech(sentence)\n sentence.gsub('Hello', 'Ahoy').\n gsub('hello', 'ahoy').\n gsub('Friend', 'Matey').\n gsub('friend','matey').\n gsub('Yes', 'Aye').\n gsub('yes', 'aye') + \" Arrrrr\"\nend", "def pirates_say_arrrrrrrrr(string)\n\tnewstr = \"\"\n\tlength = string.length - 1\n\tlength.times do |x|\n\t\tif string[x] == \"r\" || string[x] == \"R\"\n\t\t\tpos = x + 1\n\t\t\tnewstr << string[pos]\n\t\tend\n\tend\n\tnewstr\nend", "def pirates_say_arrrrrrrrr(string)\n to_return = \"\"\n add_next = false\n string.size.times do |index|\n current_char = string[index, 1] # kindly enough, Josh Cheek put in a comment\n# explainging the above line, that the second param tells Ruby to get a string of\n# length 1, which is only necessary on version 1.8 and if you're on 1.9 and above\n# that you should just go with string[index]. This makes me wonder about the \n# value this tutorial offers, just saying.\n to_return << current_char if add_next\n add_next = (current_char == \"r\" || current_char == \"R\")\n end\n to_return\nend", "def pirates_say_arrrrrrrrr(string)\n out_string = \"\"\n prev_char = \"\"\n string.each_char do |char|\n if prev_char == \"r\" || prev_char == \"R\"\n out_string << char\n end\n prev_char = char\n end\n out_string\nend", "def greeter(name)\n return \"hello \" + name + \" its nice to see you.\"\nend", "def pirates_say_arrrrrrrrr(string)\n pirate = \"\"\n # Add a blank index at the end of string in case it ends in 'r'\n string << \" \"\n string.each_char.with_index { |chr, ind|\n pirate << string[ind+1] if [\"r\",\"R\"].include?(chr)\n }\n # strip to remove that extra space at the end\n pirate.strip\nend", "def pirates_say_arrrrrrrrr(string)\n output = ''\n string.each_char.with_index do |letter, i|\n unless string[i + 1].nil?\n output += string[i + 1] if letter == 'r' || letter == 'R'\n end\n end\n output\nend", "def friendly_parrot(name, age)\n age\n \"Hello! Your name is #{name} and you are #{age} years old.\"\nend", "def rubyify(sentence)\r\n\r\nend", "def dance_to_music \n \"Feel the rhythm\"\n end", "def pirates_say_arrrrrrrrr(string) #defines a method with 1 parameter\n answer = \"\" #sets up a blank variable for the answer\n add_next_letter = false #sets up a variable with false\n string.length.times do |count| #finds length of string and creates a loop to work that many times\n the_character = string[count] #puts the count character into the the_character\n answer << the_character if add_next_letter #appends the answer if\n add_next_letter = (the_character == \"r\" || the_character == \"R\") #adds in next letter if the next character is R or R.\n end #ends the loop\n answer #returns the answer\nend", "def polly_wanna(word)\n word*3\nend", "def polly_wanna(word)\n word*3\nend", "def pirates_say_arrrrrrrrr(string)\n # find index of r's but ignore when r is the last letter\n indices_of_r = (0..string.length - 2).select{|n| string[n] == \"r\" || string[n] == \"R\"}\n letters = \"\"\n # extract letters at indices of r + 1\n indices_of_r.each {|n|\n letters += string[n + 1]}\n letters\nend", "def pirates_say_arrrrrrrrr(string) \n to_return = \"\" # return a string\n add_next = false \n string.size.times do |index| #iterate upwards adding to the index for each look\n current_char = string[index,1] # the present character is index 1 ont he string\n to_return << current_char if add_next #move to the next character\n add_next = (current_char == \"r\" || current_char == \"R\") # only add if the current character is an upper or lower case \n end\n to_return\nend", "def shout(phrase)\n return \"#{phrase.upcase} !!!!\"\n #return \"#{phrase}!!!!\".upcase\nend", "def polly_wanna (word)\n word*3\nend", "def student_favourite_programming_language(language)\n return \"I love #{language}\"\n end", "def bear_roars()\n return \"RROOOAAAAARRRRR\"\nend", "def pirates_say_arrrrrrrrr(string)\n final_result = \"\"\n looking_for_r = false\n string.length.times do |x|\n if looking_for_r == true\n final_result << string[x]\n end\n looking_for_r = string[x].include?(\"r\") || string[x].include?(\"R\")\n end\n final_result\nend", "def speak_to_grandma(phrase)\n if phrase == \"I LOVE YOU GRANDMA!\"\n return \"I LOVE YOU TOO PUMPKIN!\"\n elsif phrase==phrase.upcase\n return \"NO, NOT SINCE 1938!\"\n else\n return \"HUH?! SPEAK UP, SONNY!\"\n end\nend", "def say_goodnight(name)\n result = \"Good night, \" + name.capitalize\n return result\nend", "def say_hi(name)\n result = \"Hey Hi, #{name}\"\n return result\nend", "def pirates_say_arrrrrrrrr(string)\n\t#string_array = string.split(\"\")\n\t#string_array.each { |string| \"r\" +1}\n\t#puts string_array \n\n\tstring_array = string.split(\"\")\n\tnew_array = []\n\tstring_array.each_index do |x| \n\t\tunless x - 1 < 0\n\t\tif string_array.fetch(x - 1) == 'r'\n\t\t\tnew_array << string_array.fetch(x) \n\t\telsif string_array.fetch(x - 1) == 'R' \n\t\t\tnew_array << string_array.fetch(x) \n\t\tend\n\tend\n\tend\n\tnew_array.join\nend", "def speak\n \"#{name} says arf!\"\nend", "def speak\n \"#{name} says arf!\"\nend", "def speak\n \"#{name} says arf!\"\nend", "def pirates_say_arrrrrrrrr(string)\n\n\tarr = string.split(//)\n\n output = []\n arr.each_cons(2) { |a,b| output << b if a == \"r\" || a == \"R\" }\n output.join\n\nend", "def sentence(book, opinion)\n p \"I want you to know that #{book} is an amazing book series. #{opinion}\"\nend", "def two_strings(man, woman)\n p \"When \" + man + \" Met \" + woman\nend", "def generate_lyric word1 , word2\n # Store the lyric sentence as variable\n lyric = \"This place is a #{word1}. And these people aren't your #{word2}.\"\n\n # return the variable so it can be used later\n return lyric\nend", "def introduce_yourself\n \"Hi, my name is #{name} and I am the boss. YAY!\"\n end", "def greet(name)\n result = \"Good night #{name}\"\n return result\nend", "def pirates_say_arrrrrrrrr(string)\n answer = []\n array = string.split(\"\")\n array.each_with_index do |v,i|\n unless array[i+1].nil?\n \tif v == \"R\" || v == \"r\"\n \t\tanswer << array[i+1]\n \tend\n end\n end\n\n answer.join\nend", "def pirates_say_arrrrrrrrr(string)\n text = \"\"\n r_exist = false\n string.split('').each do |chr|\n if r_exist == true\n text << chr\n r_exist = false\n elsif chr.downcase == \"r\"\n r_exist = true\n end\n end\n text\nend", "def pirates_say_arrrrrrrrr(string)\n last_letter_r = false\n array = []\n string.size.times { |x|\n string_letter = string[x]\n array << string_letter if last_letter_r\n last_letter_r = (string_letter == \"r\" || string_letter == \"R\") }\n array.join(\"\")\nend", "def pirates_say_arrrrrrrrr(string)\n\nreturn_string = \"\" # !> assigned but unused variable - return_string\n\nr_character = false\n\nstring.chars.each do |char| \n\nreturn_string << char if r_character == true\n\nr_character = (char.upcase == \"R\")\n\nend\n\nreturn_string\n\nend", "def speak_to_grandma(takes_string_arguement)\n\n if takes_string_arguement == takes_string_arguement.upcase\n return \"NO, NOT SINCE 1938!\"\n else\n return \"HUH?! SPEAK UP, SONNY!\"\n end\n \nend", "def polly_wanna word2\n word2*3\nend", "def say_hello(name)\n return \"Hi, #{name}. Have a good day.\"\nend", "def parrot(phrase =\"Squawk!\")\n puts phrase\n return phrase\nend", "def strings(team1, team2)\n p \"I think the #{team1} are better than the #{team2}.\"\nend", "def speak_to_grandma(question)\n if question != question.upcase\n return \"HUH?! SPEAK UP, SONNY!\"\n elsif question == \"I LOVE YOU GRANDMA!\"\n return \"I LOVE YOU TOO PUMKIN!\"\n else\n return \"NO, NOT SINCE 1938!\"\n end\nend", "def say_goodnight(name)\r\n \"Dobranoc #{ name.capitalize }\"\r\nend", "def pirates_say_arrrrrrrrr(string)\n to_return = \"\"\n add_next = false\n string.size.times do |index|\n current_char = string[index,1] # the second param here tells it to get a str of length 1. This is only necessary on 1.8. If you are on 1.9, just go with string[index]\n to_return << current_char if add_next\n add_next = (current_char == \"r\" || current_char == \"R\")\n end\n to_return\nend", "def my_name\n return \"Bagus Wachyu Nuralam\" # Pengembalian secara eksplisit pada return\nend", "def pirates_say_arrrrrrrrr(string)\n characters = \"\"\n add_letter = false\n string.length.times do |index|\n current = string[index]\n characters << current if add_letter\n add_letter = (current == 'r' || current == 'R')\n end\n characters\nend", "def hipsterfy(word)\n\nend", "def hello_world (str)\n return 'hola mundo' if str == \"es\"\n return 'hallo welt' if str == \"de\"\n return 'hello world'\nend", "def a_turn_of_phrase(sentence)\n # code goes here\nend" ]
[ "0.7582853", "0.7221111", "0.7166108", "0.7000308", "0.6918801", "0.6901277", "0.6896448", "0.68805456", "0.68634295", "0.6854863", "0.6852092", "0.6848121", "0.68022496", "0.6780184", "0.672969", "0.6727635", "0.67212564", "0.66923374", "0.66913617", "0.6689932", "0.66816777", "0.6670735", "0.66466105", "0.664242", "0.66419876", "0.6641514", "0.6618842", "0.66163445", "0.6605234", "0.6598846", "0.6598765", "0.6588383", "0.6584346", "0.6578521", "0.65631866", "0.6560435", "0.6558273", "0.6545443", "0.65416384", "0.65407985", "0.6536517", "0.65280277", "0.6527301", "0.65192884", "0.65075654", "0.6506345", "0.6504555", "0.6492493", "0.64893514", "0.64743686", "0.64734465", "0.6465125", "0.6462163", "0.64621574", "0.64574134", "0.6453645", "0.6451271", "0.64477587", "0.6447281", "0.6443552", "0.6438693", "0.64360464", "0.64360464", "0.6423303", "0.6414344", "0.6410607", "0.64080024", "0.6403526", "0.63976866", "0.6396529", "0.63940334", "0.6391715", "0.6390388", "0.6388099", "0.6386311", "0.6386311", "0.6386311", "0.6382974", "0.6378414", "0.6356926", "0.63555455", "0.63387907", "0.63385856", "0.63336855", "0.63330877", "0.6332897", "0.6330878", "0.6322619", "0.63166535", "0.6314897", "0.6312488", "0.63123685", "0.63064104", "0.6304836", "0.6302746", "0.62963194", "0.62960035", "0.6296001", "0.6292186", "0.6280758" ]
0.6280563
100
Search User with given search string. Param : +search_string+:: the search string Returns : json format of search result.
def search_user search = Sunspot.search User do fulltext search_params end r = Hash.new search.results.each do |u| r.store(u.id,u) end render :json => r.to_json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_by_name\n query = params[:query]\n users = User.search_users(query)\n render :json => users.to_json(:check_user => current_user)\n end", "def search(query_string, page = 1)\n oauth_response = access_token.get(\"/api/v1/search.json\", :search => query_string, :page => page)\n JSON.parse(oauth_response)\n end", "def search\n\t\tif params[:term]\n\t\t\tto_match = '%' + params[:term] + '%'\n\t\t\t@users = User.where(\"(name ILIKE :search OR surname ILIKE :search OR nickname ILIKE :search) AND id != :current_id\", search: to_match, current_id: current_user.id)\n\t\telse\n\t\t\t@users = User.all\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json {render :json => @users.to_json}\n\t\tend\n\tend", "def suggestion_search\n keywords = params[:q]\n keywords = Utils.nomalize_string(keywords)\n\n if keywords.include? '-'\n keywords = keywords.gsub! '-', \" \"\n end\n\n pattern = /#{Regexp.escape(keywords)}/i\n\n users = User.or({:name => pattern}, {:email => pattern}).map { |user|\n UserSerializer.new(user).suggestion_search_hash\n }\n\n render json: users, root: false\n return\n end", "def search(search_string)\n GoogleAjax::Search.web(search_string)[:results]\n end", "def user_search(search, options = {})\n options[:search] = search\n get('/users', query: options)\n end", "def user_search username\n url = API + \"users/search?q=#{username}&access_token=\" + @access_token\n get(url)['data']\n end", "def search\n @term = params[:term]\n if @term.blank?\n @users = []\n else\n @users = User.where(\"username like ? or name like ?\", '%' + @term + '%', '%' + @term +'%')\n end\n\n respond_to do |format|\n format.html { render action: \"index\" }\n format.json { render json: @users, :except => [:encrypted_password, :salt] }\n end\n end", "def index\n @users = User.search_user(params[:search_user])\n end", "def search_by_email\n @user = User.find_by(email: params[:email])\n # @user = User.find_by_email(params[:email])\n\n # render json: @user.as_json(only: [:id, :first_name, :last_name, :email])\n render json: @user\n end", "def search\n render json: User.first(10)\n end", "def search_user(query, &block)\n if not query.nil?\n query = query.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)\n get(\"#{@base_url}/users/search/json?q=#{query}\", user_mapping, -> results do\n block.call(results)\n end\n )\n end\n end", "def search_for_user(params) # :yields: JSON\n uri=URI.parse(@uri_builder.get_user_contents(Api_options::USER::SEARCH, params))\n http=HttpHandler.initiate_http(uri)\n begin\n response=HttpHandler.get_response(http,uri)\n rescue ArgumentError\n puts \"Request failed with code: #{response.code}\"\n else\n @response_status=true\n return response\n end\n end", "def check\n @user = User.find_by_email(params[:search])\n render json: @user.as_json\n end", "def autocomplete\n\t\t\tusers = User.search(params[:keyword]).limit(10)\n\t\t\t\n\t\t\tusers = users.where.not(id: params[:except]) if params[:except].present?\n\n\t\t\trender json: { \n\t\t\t\tstatus: 0,\n\t\t\t\tresult: users.all.map do |user|\n\t\t\t\t\t[user.id, \"#{user.full_name} &lt;#{user.email}&gt;\"]\n\t\t\t\tend.to_h\n\t\t\t}\n\t\tend", "def search\n\t\tusers = []\n\t\tif !params.has_key?(\"term\") or params[:term].empty?\n\t\t\trespond({ status: 1, error: \"You must provide a term to search for\" })\n\t\telse\n\t\t\tUser.contains(params[:term]).each do |u|\n\t\t\t\thash = u.attributes \n\t\t\t\thash[:client] = u.client ? u.client.name : nil\n\t\t\t\tusers.push(hash)\n\t\t\tend\n\t\t\trespond({ status: 0, users: users })\n\t\tend\n\tend", "def search_prof\n # Search for email or name of professor\n term = \"%#{params[:term]}%\"\n @users = User.all(:conditions => [\"(LOWER(first_name) LIKE LOWER(?) OR LOWER(last_name) LIKE LOWER(?) OR LOWER(email) LIKE LOWER(?)) AND role = ?\", term, term, term, \"Professor\"])\n\n # Return a JSON with \"label\" and \"value\" as key required by JQUeryUI autocomplete\n result = Array.new\n @users.each do |user| \n label = user.first_name + \" \" + user.last_name + \" - \" + user.email\n item = Hash[ \"label\" => label, \"value\" => user.email ]\n result.push item\n end\n\n render :json => result\n end", "def search\n search_param = params[:term]\n matching_keys = UserKey.submitted.search(search_param).collect { |u| { value: \"#{u.name}\", data: u.id } }\n render json: { suggestions: matching_keys }\n end", "def search_results\n @results = User.search(params[:search])\n end", "def search(search)\n query = if Rails.env.development?\n 'name like ?'\n else\n 'name ilike ?'\n end\n User.where(query, \"%#{search}%\")\n end", "def get_user_vidm_search_result(search_string, opts = {})\n data, _status_code, _headers = get_user_vidm_search_result_with_http_info(search_string, opts)\n data\n end", "def get_user_vidm_search_result(search_string, opts = {})\n data, _status_code, _headers = get_user_vidm_search_result_with_http_info(search_string, opts)\n data\n end", "def search\n\n=begin\n :: Expected Params ::\n \n Constants::REQUEST_PARAM_TEXT => User name\n\n=end \n\n begin \n\n users = User.where(\"name LIKE (?)\", \"%#{param_text}%\").all.map{ |user| {:id => user.id, :name => user.name, :is_verified => user.is_verified, :photo_url => user.photo}}\n\n if users.present?\n render json: {status: status_code(:ok), message: '', data: users}\n else\n render json: {status: status_code(:not_found), message: Constants::NO_MATCHING_RECORD_FOUND}\n end \n\n rescue =>e\n \n render json: {status: status_code(:unprocessable_entity), message: Constants::SOMETHING_WENT_WRONG, data: {errors: e.message}}\n\n end \n\n end", "def search\n # params[:query] populated by query text input field\n # here we search for users that match input email\n @users = User.where(email: params[:query])\n end", "def search(one_or_all, search_str, escape_char=nil, *paths)\n json_op(:search, self, one_or_all.to_s, search_str, escape_char, *paths)\n end", "def search_results(user_params)\n search_service(user_params).search_results\n end", "def find\n users = User.where(\"email ILIKE ?\", \"#{params[:term]}%\").order(:email).pluck(:email)\n\n render :json => users\n end", "def usernamesearch(field_hash)\n usersearch(field_hash)\n end", "def search_new\n\n @searching = true\n results = Profile.joins(:user).includes(:user => [:photos]).user_readable(current_user).search_for(params['search-string'])\n @profiles = results.page(params[:page]).per(@@results_per_page)\n\n respond_to do |format|\n format.html { render action: \"index\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n\n end", "def search_result\n query = search_params.presence && search_params\n results = query.present? ? helpers.search_query(query) :helpers.create_query(current_user)\n render json: {:data => results, :total => results.results.total}\n end", "def search_by_user(user, additional_filters={})\n additional_filters[:user] = user\n return search(additional_filters)\n end", "def users\n puts \"SEARCH USERS\"\n @users = User.search(params[:q])\n puts \"SEARCH USERS COUNT:#{@users.count}\"\n render :json => @users.as_json(:current_user => current_user)\n end", "def search\n @users ||= User.search_user(params[:search])\n authorize! :read, @user\n end", "def user_search(options = {})\n get('users/search', options)\n end", "def index\n @users = User.search(params[:search], params[:search_type])\n end", "def index\n return render json: { error: 'bad_request' }, status: :bad_request unless params_present?\n\n @users = User.where('name LIKE(?)', \"%#{params[:keyword]}%\")\n\n if @users.present?\n render json: @users, each_serializer: Rest::UserSerializer\n else\n render json: { error: 'not_found' }, status: :not_found\n end\n end", "def usersearch(struct)\n struct.remapkeys!\n if struct.has_key? :user and struct.has_key? :pass\n rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])\n struct.delete(:user)\n struct.delete(:pass)\n else\n rt = RT_Client.new\n end\n val = rt.usersearch(struct)\n rt = nil\n val\n end", "def search_user\n @users = UserService.searchUser(params)\n render :index\n end", "def search\n @users = User.search_by_name(params[:search_name]).paginates_per(page: params[:page])\n end", "def search(query=nil)\n get \"/users/search\", auth_params.merge(:q => query)\n end", "def search\n token = current_user.twitter_access_token\n client = Twitter::Client.new oauth_token: token.token, oauth_token_secret: token.secret\n\n @users = client.user_search params['q'], {\n count: params['count']\n }\n\n respond_with @users\n end", "def user_search(query)\n get(\"/user/search/#{query}\")['users'].map { |u| User.new(self, u) }\n end", "def search(search_string)\n\n # Convert to a get-paramenter\n search_string = CGI.escapeHTML search_string\n search_string.gsub!(\" \", \"&nbsp;\")\n\n results = []\n \n return results\n end", "def index\n if params[:search]\n @user = Sunspot.search(User) do\n fulltext params[:search]\n end.results\n else\n @user = User.all.order(\"created_at DESC\")\n end\n render :json => @user\n end", "def search\n\tsearch_term = \"%#{params[:query].downcase}%\"\n\t# if using search engine\n\t# musicians = User.search search_term, :conditions => { :local_player_flag => 1 }, :order => :last_name\n\n\t# SQL Search (to be replaced by search engine, depends on hosting situation)\n\tmusicians = User.where(\"local_player_flag=1 and status_id<>1 and (cell_phone is not null or home_phone is not null) and (lower(username) like ? or lower(first_name) like ? or lower(last_name) like ? )\", search_term, search_term, search_term).order(\"last_name\").select(\"username, first_name, last_name, user_id, cell_phone, url, home_phone, image, image_url\")\n\n\t# JSON output\n\trender :json => musicians\n end", "def filterUsers\n if(params[:search] && params[:search].length >= 1)\n @users = User.where('nickname LIKE ? OR email LIKE ?', \"%#{params[:search]}%\", \"%#{params[:search]}%\")\n else\n @users = {}\n end\n respond_to do |format|\n format.html {render :partial => 'users/userList'}\n format.js\n end\n end", "def search_results\n @query = params[:user]\n processed_query = sanitize(@query)\n @source = params[:source]\n @results = ApiHelper.user_search(processed_query, USER_COUNT, @source)\n if @results.count == 0\n flash[:notice] = \"No users matching '#{@query}'.\"\n end\n render 'search'\n end", "def search_by_email(email)\n begin\n JSON.parse(RestClient.get construct_url(\"user/search/by_email/#{email}\"))\n rescue RestClient::BadRequest => e \n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end", "def index\n @usersearch = Usersearch.all\n \n\n respond_to do |format|\n format.html { return @usersearch}\n format.json { render json: @usersearch.to_json }\n end\n\n end", "def users\n items = B1Admin::User.where([\"name LIKE :term OR email LIKE :term\",term: \"#{params[:term].to_s}%\"]).all\n render json: {success: true, users: items}\n end", "def json_index\n\t\tquery = begin\n\t\t\tparams.permit(:query).fetch(:query)\n\t\trescue\n\t\t\t''\n\t\tend\n\t\tusers = User.where('LOWER(nickname) LIKE LOWER(:query)', query: \"%#{query}%\")\n\t\trender json: users.map(&:name)\n\tend", "def search\n users = Api.users.find(params)\n\n select2_format=(params[:f]=='s2')\n if select2_format\n hash = {\n :more => false,\n :results => users.map { |user| {:id => user.login, :text => \"#{user.name} (#{user.login})\"} }\n }\n else\n hash = {:users => users.map { |user| User.to_hash(user) }}\n end\n\n respond_to do |format|\n format.json { render :json => jsonp(hash) }\n format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'users') }\n end\n end", "def search(string, options = {})\n if (string.is_a?(Hash))\n options = string\n else\n options.merge!(:search => string)\n end\n\n options = merge_defaults(options)\n\n if options[:search].nil? || options[:search].empty?\n raise Lolbase::Exceptions::NoSearchString.new\n end\n\n if !valid_search_type?(options[:type])\n raise Lolbase::Exceptions::InvalidSearchType.new(options[:type])\n end\n\n options.merge!(:caching => false)\n\n data = post_html(@@search_url, options)\n\n results = []\n\n if (data)\n case options[:type]\n\n when 'characters'\n data.xpath('//div[@class=\"table\"]/table/tbody/tr').each do |char|\n results << Lolbase::Classes::SearchCharacter.new(char, self)\n end\n end\n end\n\n return results\n end", "def search_user\n \t@users = UsersService.searchUser(params)\n render :index\n end", "def user_search(params = {})\n last_name.set params[:last_name] unless nil_or_empty? params[:last_name]\n login_id.set params[:login] unless nil_or_empty? params[:login]\n site_name.set params[:site] unless nil_or_empty? params[:site]\n site_group_select.select unless nil_or_empty? params[:site_group]\n role_select.set params[:role] unless nil_or_empty? params[:role]\n study_select.select params[:study] unless nil_or_empty? params[:study]\n unless nil_or_empty? params[:environment]\n if params[:environment].downcase == 'prod'\n env = 'Live: Prod'\n else\n env = 'Aux: ' + params[:environment].gsub(/[\\W]/, '') # sanitize study string\n end\n environment_select.select env\n end\n auth_select.select params[:authenticator] unless nil_or_empty? params[:authenticator]\n search_button.click\n sleep 5 #TODO: Figure out a way to remove this ~MD\n end", "def search\n @users = User.where('full_name ilike ?', \"%#{params[:query].strip}%\")\n if @users.length.zero?\n flash[:notice] = \"#{params[:query]} not found\"\n redirect_to users_path\n else\n render 'index'\n end\n end", "def autocomplete_user_email\n term = params[:term]\n users = User.where(:role_id => current_user.can_mail_to).where(\"lower(email) ILIKE '%#{term}%' OR lower(user_id) ILIKE '%#{term}%'\").order(:email)\n render :json => users.map { |user| {:id => user.id, :label => \"#{user.name} - #{user.email}\", :value => user.name} }\n end", "def photo_search\n user_id = username_to_userid(params[:username])\n plain_response = Flickr::Client.get('photos.search', {\n :text=>((params[:q].blank? and user_id.blank?) ? DEFAULT_TERM : params[:q]),\n :per_page=>20,\n :page => params[:page],\n :user_id => user_id,\n :privacy_filter => 1,\n #:has_geo => true,\n :sort => 'relevance'\n })\n # remove the callback method wrapper:\n hash_response = js_to_ruby plain_response\n raise hash_response.inspect unless hash_response['stat']=='ok'\n hash_response\n end", "def search (search_url, options = {})\n # HttParty encapsulate Net::Http library to make it more developer friendly. \n # It is making a get request to the search_url. \n # Sets options to the query and merges the default params. Example the access_token.\n http_response = HTTParty.get(search_url, query: options.merge(Underbelly::DEFAULT_PARAMS))\n # HttParty has methods like .parsed_response, .body, .code, .message, .headers.inspect\n # Set @status equal to the code that is returning we can uses this to make sure that the response was successful.\n @status = http_response.code\n # Message is set to get more detail of the status. It is more useful when the response is not successful.\n @message = http_response.message\n # Before set the response to the User object, it makes sure that the response is successful. \n if status == 200\n # Set a local variable equal to the parsed response. \n # The parsed_response method calls JSON parse without explicitly using the JSON library.\n # Return a ruby hash instead of a Json response.\n response = http_response.parsed_response\n # Transform the response into an object in this case a User object.\n # This way it calls the attributes like normal attributes \".name\" instead of \"['name']\".\n # Also allows us to be able to create addition methods for the User object to manipulate the data. \n @user = Underbelly::User.new(response) \n end \n end", "def user_search\n @users = User.admin_search(params[:query])\n end", "def index\n @users= User.where(\"email like '%#{params[:search]}%'\").all\n respond_to do |format|\n format.html # index.html.erb\n format.js { render :layout=>false }\n format.json { render json: @users }\n end\n end", "def user_search(query, options = {})\n response = get(\"users/search\", options.merge(q: query))\n response\n end", "def return_exact_results\n\t# make empty array that will contain all users whose first_name, last_name, or email exactly matches a given string\n\texact_search_results = []\n\n\tUser.all.each do |user|\n\t\tif user.first_name == user.search_term || user.last_name == search_term || user.email == search_term\n\t\t\texact_search_results.push user.id\n\t\telse\n\t\t\t# do nothing if search term is not exactly\n\t\tend\n\tend\n\texact_search_results\nend", "def find(search_value)\r\n cases = [search_value.downcase, search_value.capitalize, search_value.upcase]\r\n users = Array.new\r\n\r\n cases.each do |value|\r\n users.concat(Array.new(User.all(:login.like => \"%#{value}%\") |\r\n User.all(:firstname.like => \"%#{value}%\") |\r\n User.all(:lastname.like => \"%#{value}%\")))\r\n end\r\n\r\n # Delete user which searching for other users\r\n users.delete(self)\r\n\r\n return false if users.empty?\r\n\r\n users.map! { |user| { login: user.login,\r\n firstname: user.firstname,\r\n lastname: user.lastname }}\r\n users = users.uniq\r\n end", "def set_usersearch\n @usersearch = Usersearch.find(params[:id])\n end", "def index\n if params[:search]\n @user = User.all.includes(:user).where(\"user.first_name\" => params[:search]).all\n end\n end", "def suggest\n if !params.has_key? :q then\n head :ok\n return\n end\n\n search_stmt = params[:q].upcase\n current_user_id = current_user.id\n\n results = UrContact.where.has{\n (user_id == current_user_id) &\n (upper(name).like \"%#{search_stmt}%\") |\n (upper(email).like \"%#{search_stmt}%\") |\n (upper(telephone).like \"%#{search_stmt}%\")\n }\n\n if params[:format] == \"search\" then\n formattedResults = results\n else\n formattedResults = {query:params[:q], suggestions:results.map{|x| {value:x.name, data:x}} }\n end\n\n #render json: {query:params[:q], suggestions:results}\n render json: formattedResults\n end", "def search\n\n @accounts = []\n \n PgSearch.multisearch(params['search-string']).where(:searchable_type => \"Account\").find_each do |document|\n @accounts << document.searchable if Account.user_readable(current_user).include?(document.searchable)\n end\n\n respond_to do |format|\n format.html { render action: \"index\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n \n end", "def search_user_names_for_message\n @users = (session[:from_follower_following] ? @login_user.from_follower_following(params[:term]) : @login_user.all_message_users(params[:term]))\n @usernames = []\n @users.collect{|u| @usernames << u.username}\n respond_to do |format|\n format.json { render :json => @usernames }\n end\n end", "def index\n @search = UserSearch.new(search_params)\n @users = search_params.present? ? @search.results : User.where(:banned => false)\n @users = @users.order(:name)\n\n respond_to do |format|\n format.html { render :index}\n format.json { render json: @users }\n end\n end", "def search\n @users = User.search(@search_term)\n @tweets = Tweet.search(@search_term)\n @tags = Tag.search(@search_term)\n end", "def search\n messages = Message.search search_params.merge!(messager_id: current_user.id)\n\n render json: MessageSerializer.new(messages).serialize\n end", "def index\n #search method will search model based on the params\n respond_to do |format|\n format.html {}\n format.json {\n @users = User.search_get_json(@current_page, @rows_per_page,params)\n render json: @users\n }\n end\n end", "def search\n\t\tbegin\n\t\t # Need a variable to avoid duplicate record insertion while applying filters\t\n\t if params[:is_new].to_s.downcase == \"true\"\n\t history = UserSearchHistory.new(params[:location])\n\t history.save!\n\t mongo_user_search = MongoUserSearch.add_search_records(current_user,params[:location]) unless current_user.blank?\n\t end\n\t @records = MongoUserSearch.records_in_miles(current_user,params[:location][:latitude],params[:location][:longitude])\n\t render :json => {:success => true, :message => \"search successful\" ,:results => @records}, :status => 200\n\t rescue Exception => e\n\t \tp e\n\t render :json => {:success => false, :message => \"Error\", :results => @records}, :status => 200\n\t end\n\tend", "def index\n query = ''\n searchparam = \"\"\n if params[:search] && params[:search] != ''\n query += ' lower(name) LIKE ?'\n searchparam = \"%#{params[:search].downcase}%\"\n end\n\n @users = User.where(query, searchparam).paginate(page: params[:page])\n @searched = query != ''\n end", "def search\n @user = current_user\n @query = params[:query]\n @resulted_users = Admin.search_user(@query.downcase)\n @resulted_users.delete @user\n @resulted_users.sort! {|a,b| a.email <=> b.email}\n render layout: 'mobile_template'\n end", "def search_contacts\n\t\tif params[:term]\n\t\t\tto_match = '%' + params[:term] + '%'\n\t\t\tuser = current_user\n\t\t\tusers_not_to_find = user.contacts.all.ids\n\t\t\tusers_not_to_find.push current_user.id\n\t\t\t@users = User.where(\"(name ILIKE :search OR surname ILIKE :search OR nickname ILIKE :search) AND\n\t\t\t\t\tid NOT IN (:ids)\", search: to_match, ids: users_not_to_find)\n\t\telse\n\t\t\t@users = User.all\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json {render :json => @users.to_json}\n\t\tend\n\tend", "def search\n add_breadcrumb :search\n @start = Time.now\n @search = User.search(:include => [:tags]) do\n fulltext params[:q] do\n fields(:bio, :name => 2.0)\n end\n order_by sort_column, sort_direction\n paginate :page => params[:page], :per_page => 21\n end\n\n respond_to do |format|\n format.html { render :action => \"index\" }\n format.xml { render :xml => @search }\n format.xml { render :json => @search }\n end\n end", "def search(query)\n response = twitter_user.request(:get, configatron.api_call_url + \"users/search.json?q=#{URI.escape(query)}\")\n \n #\"#{configatron.api_call_url}users/search.json?q=#{URI.escape(query)}&page=#{page}&per_page=#{configatron.page_size}\"\n if response.is_a?(Net::HTTPSuccess)\n get_nicknames_and_names(JSON.parse(response.body))\n end\n end", "def search_for_group\n @groups = @login_user.all_groups(params[:term])\n @usernames = []\n @groups.collect{|group| @usernames << group.name}\n respond_to do |format|\n format.json { render :json => @usernames }\n end\n end", "def set_user_search\n @user_search = UserSearch.find(params[:id])\n end", "def index\n @users = User.nonadmin.order('users.created_at desc')\n if params[:search].present?\n if params[:search][:name].blank?\n @users = User.nonadmin.order(\"users.id desc\").order('users.created_at desc')\n elsif params[:search][:name].present?\n search_terms = params[:search][:name].split(' ').join('%')\n @users = User.nonadmin.where(\"concat(LOWER(first_name), ' ', LOWER(last_name)) like ?\",\"%#{search_terms}%\").order('users.created_at desc')\n end\n\n if params[:search][:ic].present?\n @users = @users.where(ic_number: params[:search][:ic])\n end\n end\n if params[:filter].present?\n @users = @users.send(params[:filter])\n end\n @klass = Class\n @users = Kaminari.paginate_array(@users).page(params[:page]).per(6)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def search\n @users = User.all.order(:user_id)\n if params[:search][:annual].present?\n @users = @users.where(\"annual like '%\" + params[:search][:annual] + \"%' \").order(:user_id) \n end\n if params[:search][:name].present?\n @users = @users.where(\"name like '%\" + params[:search][:name] + \"%' \").order(:user_id)\n end\n @name = params[:search][:name]\n @annual = params[:search][:annual]\n render :index\n end", "def user_search(params = {})\n request = Ohmage::Request.new(self, :post, 'user/search', params)\n # TODO: make a utility to abstract creation of array of base objects\n t = []\n request.perform[:data].each do |k, v|\n t << Ohmage::User.new(k => v)\n end\n t\n end", "def search\n if id = search_params[:room_id]\n students = Student.roomFilter(id)\n else\n students = Student.all\n end\n query = search_params[:query_string] || \"\"\n students = students.search(query)\n render json: students, root: false\n end", "def search_user(q)\n uri = \"https://api.twitter.com/1/users/search.json\"\n req = Typhoeus::Request.new(uri,\n :method =>\"get\",\n :params =>{:q=>q, :include_entities=>\"true\"})\n oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))\n sign_request(req,uri)\n hydra = Typhoeus::Hydra.new\n hydra.queue(req)\n hydra.run \n \n profile_list = Array.new\n\n JSON.parse(req.response.body).each do |raw|\n profile_list.push([\n raw[\"id\"].to_s,\n raw[\"profile_image_url\"].to_s,\n raw[\"name\"].to_s,\n raw[\"screen_name\"].to_s]\n )# prepare to cash into database, not sure\n end\n profile_list.sort!{|x,y| x[0]<=>y[0]} \n end", "def index\n if params[:search].nil?\n @users = User.paginate(page: params[:page]).where.not(id: current_user.id)\n else\n @users = User.where(\"lower(first_name) like ? or lower(last_name) like ?\", \"%#{params[:search][:q].downcase}%\", \"%#{params[:search][:q].downcase}%\").paginate(page: params[:page]).where.not(id: current_user.id)\n end\n end", "def parse_user search\n Hash[*search.split(',').map{|pair| pair.split('=').values_at(0..1)}.flatten]['uid']\n end", "def search\n\n @matches = []\n\n unless params[:search_str] and params[:search_str] != \"\"\n render :text => @matches.to_json\n return\n end\n\n pattern = Regexp.new(Regexp.quote(params[:search_str].downcase))\n\n Photo.all.each do |p|\n\n comment_matches = false\n\n p.comments.each do |c|\n if c.comment.downcase =~ pattern\n comment_matches = true\n @matches << [p.user.id, p.id, \"/images/#{p.file_name}\"]\n break\n end\n end\n\n if !comment_matches\n p.tags.each do |t|\n if t.user.full_name.downcase =~ pattern\n @matches << [p.user.id, p.id, \"/images/#{p.file_name}\"]\n break\n end\n end\n end\n\n end\n\n render :text => @matches.to_json\n\n end", "def search\n @user = User.find(params[:id])\n @users = User.where('email LIKE ?', \"%#{params[:email]}%\")\n authorize @users\n @departments = @user.org.departments.order(:name)\n @plans = Plan.active(@user).page(1)\n # WHAT TO RETURN!?!?!\n if @users.present? # found a user, or Users, submit for merge\n render json: {\n form: render_to_string(partial: 'super_admin/users/confirm_merge.html.erb')\n }\n else # NO USER, re-render w/error?\n flash.now[:alert] = 'Unable to find user'\n render :edit # re-do as responding w/ json\n end\n end", "def search_result\n # user specified that they want to search questions?\n # user specified that they want to search courses ?\n \n if params[:search_for] == \"question\"\n if !search_params[\"question_keyword\"].nil? and search_params[\"question_keyword\"].include?(',')\n search_params[\"question_keyword\"] = search_params[\"question_keyword\"].tr(',', '').strip #scrub any commas in our search\n end\n\n db = Search.search_questions(search_params.to_h)\n @results = JSON.parse(db.to_json)\n elsif params[:search_for] == \"course\"\n db = Search.search_courses(search_params.to_h)\n @results = JSON.parse(db.to_json)\n end\n\n end", "def search_users_by_username\n @check=0\n @username=updated_user_params[:username]\n if @username.empty?\n flash.now[:error]=\"Please, enter an username \"\n @all_searched_users=Array.new\n render 'search_users'\n else\n @all_searched_users=User.where(\"username like ?\", \"%\"+@username+\"%\").paginate(:page => params[:page], :per_page => 9)\n if @all_searched_users && !@all_searched_users.empty?\n @searched_user=User.new\n render 'search_users'\n else\n @searched_user=User.new\n @all_searched_users=Array.new\n render 'search_users'\n end\n end\n end", "def search_patients\n\t\t# Searching for patients as per user entered term\n\t\tpatients = current_user.patients.search_by_name(params[:term]).collect{|patient| {label: patient_search_meta(patient),name: \"#{patient.firstname} #{patient.lastname}\",value: patient.id.to_s} }.to_json\n\t\trespond_to do |format|\n\t\t format.json { render :json => patients }\n\t\tend\n\tend", "def user_search(search_criteria)\n found_user = nil\n as_manager do | conn |\n conn.search(user_root_dn,\n LDAP::LDAP_SCOPE_SUBTREE,\n ldap_user_search_criteria(search_criteria),\n SEARCH_RETURN_ATTRS) do | entry |\n found_user = entry.to_hash\n end\n end\n found_user\n end", "def search_by_username(search_username)\n #will return all values except the current user\n User.find(:all, :conditions => [\"username LIKE ? AND username <> ?\", \"%#{search_username}%\", \"#{self.username}\"])\n end", "def user\n user_name = User.where(:id => params[:id]).first.try(:name)\n \n user_data = {\n id: params[:id],\n name: user_name\n }\n \n respond_to do |format|\n format.html { redirect_to root_path } # search.html.erb\n format.json { render json: user_data }\n end\n end", "def search(string, options = {})\n \n\t\t\tif (string.is_a?(Hash))\n\t\t\t\toptions = string\n\t\t\telse\n\t\t\t\toptions.merge!(:search => string)\n\t\t\tend\n\n options = merge_defaults(options)\n\n\t\t\tif options[:search].nil? || options[:search].empty?\n\t\t\t\traise \"no search string\"\n\t\t\tend\n\n\t\t\tif !@@search_types.has_value?(options[:type])\n\t\t\t\traise \"invalid search type\"\n\t\t\tend\n\n results = []\n\n case options[:type]\n when @@search_types[:character]\n url = self.base_url + @@requester_file\n character_names = Net::HTTP.post_form(URI.parse(url), {\"f\"=>\"autocompleteNicks\", \"nickname\"=>\"#{options[:search]}\"})\n character_names = character_names.body.split('\"')\n character_names.each_index do |d|\n if character_names[d].include?(\";\")\n character_names.delete_at(d)\n end\n end\n character_names.delete_at(0)\n\n character_names.each do |character|\n sheet = self.get_character(character)\n if sheet.account.id > 0\n results << self.get_character(character)\n end\n end\n end\n\n return results\n \n end", "def search (query_string)\n\n OpenWFE::Extras::Workitem.search(query_string, store_names).find_all do |wi|\n\n @user.admin? or (\n wi.store_name != 'users' || wi.participant_name == @user.name)\n end\n end", "def search_all\n users = User.where([\"name LIKE ?\", \"%#{keywords}%\"])\n end", "def search\n results = @test.search(test_params)\n return render json: {results: results, total: results.total_entries}\n end" ]
[ "0.6749811", "0.6660052", "0.66419387", "0.6637043", "0.6519637", "0.6513587", "0.6498677", "0.6483692", "0.63838154", "0.6362096", "0.63606346", "0.6356656", "0.63477385", "0.6344594", "0.627396", "0.62249964", "0.6224557", "0.6208137", "0.6202906", "0.62022847", "0.6193012", "0.6193012", "0.61600614", "0.61535007", "0.6150683", "0.6139271", "0.61288166", "0.61232775", "0.60937124", "0.60699797", "0.60680485", "0.6061345", "0.6030723", "0.60018224", "0.5989761", "0.5982824", "0.5974825", "0.5954128", "0.59518194", "0.59419185", "0.59351814", "0.5921636", "0.59190965", "0.58970577", "0.58965755", "0.58866316", "0.58860993", "0.58753204", "0.5872966", "0.5866148", "0.5859637", "0.585702", "0.5852892", "0.5849872", "0.5839194", "0.583775", "0.5835948", "0.5831347", "0.5823122", "0.5819698", "0.58187056", "0.58107316", "0.5805092", "0.5795185", "0.5786382", "0.5774346", "0.5773748", "0.5767022", "0.57623285", "0.5747847", "0.5739558", "0.57308", "0.57253385", "0.5718815", "0.5712838", "0.57102805", "0.5708217", "0.5706246", "0.57037634", "0.569831", "0.56979614", "0.5695093", "0.5694389", "0.5687949", "0.5685434", "0.56741893", "0.56628036", "0.5659818", "0.5647715", "0.5643391", "0.564258", "0.56320816", "0.5632063", "0.56196016", "0.5619334", "0.5599073", "0.55983037", "0.5591004", "0.5587627", "0.5582125" ]
0.67567044
0
Whitelist the required fields in params hash
def search_params params.require(:search_string) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def required_attributes!(keys)\n keys.each do |key|\n bad_request!(key) unless params[key].present?\n end\n end", "def required_attributes!(keys)\n keys.each do |key|\n bad_request!(key) unless params[key].present?\n end\n end", "def validate_params!\n self.params ||= Hash.new\n self.class.instance_variable_get(:@__required_params).each do |e|\n raise ArgumentError, \"Insufficient parameters set (#{e} not supplied)\" if self.params[e].nil?\n end\n end", "def require_params *keys\n filter_strong_params :require, [:create, :update], keys\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def check_params; true; end", "def mandatory_params\n return {}\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def valid_params_request?; end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def ensure_params(*req)\n missing = []\n req.flatten.each do |param|\n if params[param].blank?\n missing << param.to_s\n end\n end\n if missing.empty?\n return false\n else\n msg = \"Following params are required but missing: \" + missing.join(\", \")\n render_api_error(11 , 400, 'params', msg)\n return true\n end\n end", "def requires!\n @required_params.each do |param| \n key = (param.is_a?(Array) ? param.first : param)\n verify_required_param(key)\n end\n end", "def allowed_params\n ALLOWED_PARAMS\n end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def parameters(params)\n allowed = [:start,:num,:type,:id,:filter,:tagged,:search,:state,:email,:password]\n params.merge! defaults if defaults\n params.reject {|key,value| !allowed.include? key }\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def required_custom_params\n custom.select{|param| param[\"required\"]}.map{|param| param[\"name\"]}\n end", "def anonymous_filter_params\n p = params.required('payload')\n # p.permit!('controls_params')\n # p.permit!('columns_params')\n # p.permit!('sorting')\n # p.permit!('global_config')\n p.permit(\n 'name',\n 'controls_list' => [],\n 'controls_hl_mode' => [],\n 'controls_params' => {},\n 'columns_list' => [],\n 'columns_params' => {},\n 'sorting' => {},\n 'global_config' => {}\n ).merge(permit_hashes(p, [\n 'controls_params',\n 'columns_params',\n 'sorting',\n 'global_config'\n ]))\n end", "def valid_params?; end", "def check_required_params\n errors = required_params.map { |param, value| raise param_errors[param] if value.nil? }.compact\n raise errors.joins('; ') unless errors.empty?\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def missing_params\n required_params = manifest.keys.select { |name| manifest.required?(name) }\n required_params - @params.keys\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def check_params\n true\n end", "def required_state(opts)\n opts = check_params(opts,[:field_names])\n super(opts)\n end", "def required_params?\n @unincluded_params = []\n\n required_params.each do |param|\n unless params.include?(param)\n unincluded_params << param\n end\n end\n\n unincluded_params.empty?\n end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def validate_params_present!\n raise ArgumentError, \"Please provide one or more of: #{ACCEPTED_PARAMS}\" if params.blank?\n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def registration_params\n hash = params.permit(:object_type, :admin_policy, :metadata_source, :rights,\n :collection, :other_id, tag: [])\n hash[:source_id] = params.require(:source_id)\n hash[:label] = params.require(:label)\n hash\n end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def validate_params\n if process_object && process_object[\"required_params\"]\n process_object[\"required_params\"].each do |param|\n if !params_hash.has_key?(param)\n errors.add(:params, \"Step: #{step} - Missing mandatory param #{param}\")\n end\n end\n end\n end", "def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end", "def param_whitelist\n [:rating, :review]\n end", "def filtered_parameters; end", "def require_params_on_create *keys\n filter_strong_params :require, [:create], keys\n end", "def required\n { must_exclude_attrs: %i[] }\n end", "def required_fields\n # \"cid\" is not required\n [\n \"byr\",\n \"ecl\",\n \"eyr\",\n \"hcl\",\n \"hgt\",\n \"iyr\",\n \"pid\",\n ]\nend", "def param_whitelist\n [\n :school_name,\n :school_id,\n :degree,\n :started_at,\n :finished_at,\n majors: [],\n minors: []\n ]\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end", "def requires!(hash, *params)\n params.each { |param| raise RateError, \"Missing Required Parameter #{param}\" if hash[param].nil? }\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def validate\n missing_parameters = []\n required_fields.each do |param|\n missing_parameters << param.to_s unless self.send(param)\n end\n raise RTurk::MissingParameters, \"Parameters: '#{missing_parameters.join(', ')}'\" unless missing_parameters.empty?\n end", "def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end", "def required_params(*param_names)\n param_names.each do |param_name|\n param_name = param_name.to_sym\n if empty_param?(param_name)\n raise \"Configuration Error in #{self.class.name}: No value for #{param_name}.\"\n else\n self.class.define_method(param_name.to_s) { params[param_name].strip }\n end\n end\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def allow_only_whitelisted_fields(record)\n return record unless @config['fields_whitelist'] \n puts({connection_id: @config['connection_id'], whitelisted_fields: @config['fields_whitelist'], flow: @config['flow'], record: record.inspect})\n\n params_list = @config['fields_whitelist'].split(\",\").map(&:strip).map(&:to_sym)\n\n # so id is not forgotten\n params_list = (params_list << :id).uniq\n\n new_record = {}\n\n params_list.each do |param|\n new_record[param] = record[param]\n end\n\n new_record\n end", "def required_fields\n required_fields = []\n ignore_fields = [:id, :date_entered, :date_modified]\n self.fields.each_value do |field|\n next if ignore_fields.include? field[\"name\"].to_sym\n required_fields << field[\"name\"].to_sym if field[\"required\"] == 1\n end \n required_fields\n end", "def required_fields\n required_fields = []\n ignore_fields = [:id, :date_entered, :date_modified]\n self.fields.each_value do |field|\n next if ignore_fields.include? field[\"name\"].to_sym\n required_fields << field[\"name\"].to_sym if field[\"required\"] == 1\n end \n required_fields\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def required_args\n doodle.attributes.select{ |k, v| v.required?}.map{ |k,v| v}\n end", "def param_whitelist\n [:role, :title]\n end", "def permit_all_params options = {}\n prepend_before_filter do\n self.params.deep_permit!\n end\n end", "def filter_params(params)\n attributes = self.class._attributes\n params.keep_if {|name, value|\n attributes.key?(name)\n }\n end", "def filter_params(params)\n attributes = self.class._attributes\n params.keep_if {|name, value|\n attributes.key?(name)\n }\n end", "def required(*params)\n @required = params unless params.empty?\n @required ||= []\n end", "def junk_params\n params.fetch(:junk, {})\n end", "def _validate_presence_of(*params)\n\t\tparams.each do |param|\n\t\t\traise ArgumentError, PRESENCE_REQUESTED if param.nil?\n\t\tend\n\tend", "def guard_required!\n required.each do |key|\n raise ArgumentError, \"Missing required attribute #{key}\" if self[key].nil?\n end\n end", "def trim_params(params)\n Hash[*(params.select { |k,v| new.attributes.keys.include? k.to_s}.flatten)] \n end", "def check_for_required_params!(attributes_hash)\n return if (\n missing_attributes = required_params - attributes_hash.keys\n ).empty?\n\n raise(\n UserEngage::CreateNotSuccessfulException,\n \"Missing attributes {#{missing_attributes.inspect}}\"\n )\n end", "def validate_params(hash)\n hash.include?('title') and hash.include?('body') and hash.include?('category')\n end", "def validate_required(*required_parameters)\n if self[:ensure] == :present\n required_parameters.each do |req_param|\n raise ArgumentError, \"parameter '#{req_param}' is required\" if self[req_param].nil?\n end\n end\n end", "def validate_required(*required_parameters)\n if self[:ensure] == :present\n required_parameters.each do |req_param|\n raise ArgumentError, \"parameter '#{req_param}' is required\" if self[req_param].nil?\n end\n end\n end", "def validate_required(*required_parameters)\n if self[:ensure] == :present\n required_parameters.each do |req_param|\n raise ArgumentError, \"parameter '#{req_param}' is required\" if self[req_param].nil?\n end\n end\n end", "def permit(*permitted)\n hardened_params = params.dup\n\n hardened_params.keep_if { |k, _v| permitted.flatten.include?(k.to_sym) }\n\n hardened_params.symbolize_keys\n end", "def obj_params\n params.require(:data).require(:attributes)\n end", "def required_fields\n []\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def expected_permitted_parameter_names; end", "def blacklisted_params\n params.keys.each_with_object({}) do |param, hash|\n param = param.to_sym\n hash[param] = nil unless WHITELIST_PAGINATION_PARAMS.include?(param)\n end\n end", "def named_args_required(obj_hash)\n keys_with_nil_values = obj_hash.select{|k,v| v.nil?}.collect{|e| e[0]}\n raise ArgumentError, \"Nil argument not allowed in #{keys_with_nil_values.join(', ')}\" unless keys_with_nil_values.empty?\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def exclusion_guard(arr)\n arr | required_fields\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def unsolved_params\n \n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def permitted_params\n res = attribute_names.map(&:to_sym) - %i[disabled user_id created_at updated_at tracker_id tracker_history_id\n admin_id]\n refine_permitted_params res\n end", "def required_parameters\n definition_lambda.parameters.select { |key,_value| key == :req }.map { |_key,value| value }\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def validate_required_params required_params\n @find_by_ext_id = false\n missing_params = []\n \n required_params.each { |k| \n if k.to_s == \"id\" and !params[:external_id].blank?\n @find_by_ext_id = true\n params[:id] = params[:external_id]\n next\n end\n\n unless params[:criteria].has_key?(k)\n missing_params << k\n end\n }\n \n missing_params\n end", "def require_valid_params\n params\n .require(:share)\n .require(%i[document_id document_type recipient_id])\n end", "def required_fields\n if self.controller_name == \"registrations\"\n param_name = \"user\"\n elsif self.controller_name == \"merchants\"\n param_name = \"merchant\"\n else\n return\n end\n empty_fields = Array.new\n empty = false\n params[param_name].each_pair do |k, v|\n if v == \"\"\n empty_fields << k.gsub(\"_\", \" \")\n empty = true\n end\n end\n if empty == true\n (0..empty_fields.length - 3).each do |i|\n empty_fields[i] << \",\"\n end\n empty_fields.insert(-2, \"and\") unless empty_fields.length < 2\n field_list = empty_fields.join(\" \")\n message = \"You cannot leave empty fields. The field\" \n if empty_fields.length > 1\n message << \"s \"\n else\n message << \" \"\n end\n message << field_list \n if empty_fields.length > 1\n message << \" were left blank.\"\n else\n message << \" was left blank.\"\n end\n flash[:notice] = message\n redirect_to request.referrer\n else\n return\n end\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def required_parameters\n @required_parameters ||= ((self.parameter_descriptions.select do |k, v|\n v['required']\n end).inject({}) { |h,(k,v)| h[k]=v; h }).keys\n end", "def filter_params(_sub_object_attribute = nil)\n required = :returns_lbtt_tax\n attribute_list = Lbtt::Tax.attribute_list\n params.require(required).permit(attribute_list) if params[required]\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def sanitize_params\n if valid_lease?\n sanitize_lease_params\n elsif valid_embargo?\n sanitize_embargo_params\n elsif !wants_lease? && !wants_embargo?\n sanitize_unrestricted_params\n else\n @attributes\n end\n end", "def require_params_on_update *keys\n filter_strong_params :require, [:update], keys\n end", "def user_params_without_password\n params.required(:user).permit(:first_name, :last_name, :email)\n end", "def sanitize_params(params = params)\n params = walk_hash(params) if params\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def valid_for_params_auth?; end" ]
[ "0.7635751", "0.7635751", "0.7295643", "0.71705216", "0.712372", "0.71105945", "0.7103987", "0.7066571", "0.6986981", "0.6957311", "0.6943916", "0.6938119", "0.6931988", "0.69087815", "0.69083166", "0.6882444", "0.6875311", "0.68642014", "0.684964", "0.6845869", "0.68415564", "0.68154633", "0.6814315", "0.68110436", "0.6809892", "0.6809892", "0.6807704", "0.6762884", "0.675034", "0.6726199", "0.6706909", "0.6668483", "0.6667656", "0.66659623", "0.664691", "0.6646398", "0.6631167", "0.66295004", "0.6625191", "0.6622402", "0.6611467", "0.6601631", "0.6593909", "0.65882266", "0.6587217", "0.65859604", "0.6575643", "0.6574666", "0.6548378", "0.6546079", "0.6545781", "0.6543083", "0.6543083", "0.6539727", "0.6537905", "0.6534054", "0.6510349", "0.6502972", "0.6502048", "0.65001607", "0.65001607", "0.6491333", "0.6490881", "0.6487813", "0.64874965", "0.6476925", "0.64652926", "0.6451206", "0.64475334", "0.6446645", "0.6446645", "0.6439149", "0.64383954", "0.64352727", "0.64326155", "0.6428708", "0.6427692", "0.64268476", "0.6421375", "0.64152807", "0.6415035", "0.64147866", "0.640746", "0.6401147", "0.64005643", "0.6391365", "0.63892233", "0.63891757", "0.6373206", "0.6370567", "0.63663644", "0.63657266", "0.6362533", "0.6361724", "0.63555425", "0.6355537", "0.6339573", "0.6337058", "0.6331833", "0.6325821", "0.63190544" ]
0.0
-1
for locale sensitive transliteration with friendly_id
def normalize_friendly_id(input) input.to_s.to_slug.normalize.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_friendly_id(text)\n text.to_slug.normalize! transliterations: :russian\n end", "def normalize_friendly_id(text)\n text.to_slug.normalize! transliterations: :russian\n end", "def normalize_friendly_id(text)\n text.to_slug.normalize! transliterations: :russian\n end", "def normalize_friendly_id(input)\n input.to_s.to_slug.transliterate(:russian).normalize.to_s\n end", "def normalize_friendly_id(slug_string)\n return super if self.language_code ? self.language_code == \"en\" : I18n.locale_language == :en\n options = friendly_id_config.babosa_options\n language = Utility.english_language_name(self.language_code || I18n.locale_language) || :english\n slug_string.normalize! options.merge(:transliterations => \"#{language}\".underscore.to_sym)\n end", "def normalize_friendly_id(input)\n if self.website.primary_language\n language = self.website.primary_language.language\n if language.code == \"russian\"\n return input.to_s.to_slug.normalize(transliterations: :russian).to_s\n elsif language.code == \"ukrainian\"\n return input.to_s.to_slug.normalize(transliterations: :ukrainian).to_s\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n end", "def normalize_friendly_id(input)\n if self.website.primary_language\n language = self.website.primary_language.language\n if language.code == \"russian\"\n return input.to_s.to_slug.normalize(transliterations: :russian).to_s\n elsif language.code == \"ukrainian\"\n return input.to_s.to_slug.normalize(transliterations: :ukrainian).to_s\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n end", "def normalize_friendly_id(input)\n if self.website.primary_language\n language = self.website.primary_language.language\n if language.code == \"russian\"\n return input.to_s.to_slug.normalize(transliterations: :russian).to_s\n elsif language.code == \"ukrainian\"\n return input.to_s.to_slug.normalize(transliterations: :ukrainian).to_s\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n end", "def normalize_friendly_id(input)\n input.to_s.to_slug.normalize(transliterations: :greek).to_s\n end", "def normalize_friendly_id(string); string.upcase.gsub(\"-\", \".\") end", "def normalize_friendly_id(text)\n text.to_s.to_slug.normalize.to_s\n end", "def normalize_friendly_id(text)\n text.to_s.to_slug.normalize.to_s\n end", "def friendly_id\n slug(true).to_friendly_id\n end", "def normalize_friendly_id(string)\n name\n end", "def unfriendly_id?; end", "def normalize_friendly_id(string)\n super.gsub(\"-\", \".\")\n end", "def friendly_id; end", "def to_param\n slug ? slug.to_friendly_id : id.to_s\n end", "def normalize_friendly_id(string)\n super[0..59]\n end", "def normalize_friendly_id(slug_str)\n super.gsub(\"-\", \"\")\n end", "def normalize_friendly_id(input)\n input\n end", "def normalize_friendly_id(name)\n name_as_slug = name.to_s.to_slug.normalize(transliterations: :russian).to_s\n add_parent_slug(name_as_slug)\n end", "def normalize_friendly_id(input)\n input.to_s.to_url\n end", "def normalize_friendly_id(input)\n input.to_s.to_url\n end", "def normalize_friendly_id(input)\n input.to_s.to_url\n end", "def normalize_friendly_id(input)\n input.to_s.to_url\n end", "def mission_id_to_locale_id(id)\n \"m_#{id}\"\nend", "def friendly_id_config; end", "def friendly_id\n send friendly_id_config.query_field\n end", "def find_by_friendly_id(id); end", "def to_param_from_slug\n slug? ? slug.to_friendly_id : id.to_s\n end", "def to_param_from_slug\n slug? ? slug.to_friendly_id : id.to_s\n end", "def to_param_from_slug\n slug? ? slug.to_friendly_id : id.to_s\n end", "def to_param\n (friendly_id || id).to_s\n end", "def to_param\n (friendly_id || id).to_s\n end", "def to_param\n (friendly_id || id).to_s\n end", "def to_param\n (friendly_id || id).to_s\n end", "def normalize_friendly_id(string)\n super.delete(\"-\")\n end", "def slug_base_string\n self.id || sluggify\n end", "def normalize_friendly_id(string)\n\t super[0..20]\n\tend", "def slug_text\n base = send friendly_id_options[:column]\n if self.friendly_id_options[:strip_diacritics]\n base = Slug::strip_diacritics(base)\n end\n if self.friendly_id_options[:strip_non_ascii]\n base = Slug::strip_non_ascii(base)\n end\n base = Slug::normalize(base)\n \n if base.length > friendly_id_options[:max_length]\n base = base[0...friendly_id_options[:max_length]]\n end\n if friendly_id_options[:reserved].include?(base)\n raise FriendlyId::SlugGenerationError.new(\"The slug text is a reserved value\")\n end\n return base\n end", "def generate_custom_slug\n\t\t# \"#{convert_to_lowercase_to} #{convert_to_lowercase_from}\"\n\t\t\"#{self.id}\"\n\tend", "def normalize_friendly_id(string)\n if slug.blank?\n super\n else\n super(slug)\n end\n end", "def transliterate_slug(input)\n transliteration = case ::Globalize.locale.to_sym\n #when :bg then :bulgarian\n #when :da then :danish\n when :de then :german\n #when :gr then :greek\n #when :mk then :macedonian\n #when :no then :norwegian\n #when :ro then :romanian\n when :ru then :russian\n #when :bg then :serbian\n when :pt then :spanish\n when :br then :spanish\n when :es then :spanish\n #when :se then :swedish\n end\n if transliteration.presence\n input.to_s.to_slug.normalize(:transliterate => true, :transliterations => transliteration).to_s\n else\n input.to_s.to_slug.normalize.to_s\n end\n end", "def to_param\n slug # or \"#{id}-#{name}\".parameterize\n end", "def parameterize(id=nil)\n # Prepare the ID portion or blank it\n id = id.blank? ? \"\" : \"#{id}-\"\n\n # Remove HTML\n slug = self.downcase.strip.gsub(/<(.|\\n)*?>/,'')\n \n # Decode HTML Entities\n # &ldquo; => “ (smart quotes)\n slug = HTMLEntities.new.decode(slug)\n \n # Clean weird characters, and weird win1252 character set conversions\n slug = slug.gsub(\"\\342\\200\\230\",'') # single quote\n slug = slug.gsub(\"\\342\\200\\231\",'') # single quote\n slug = slug.gsub(\"\\342\\200\\234\",'') # double quote\n slug = slug.gsub(\"\\342\\200\\235\",'') # double quote\n slug = slug.gsub(\"\\342\\200\\224\",'') # mdash\n slug = slug.gsub(/[\\240]/,'-') \n slug = slug.gsub(/[\\…\\–\\/]/,'-') # Convert some characters into dashes\n \n # Remove some common weird characters\n slug = slug.gsub(/[\\©\\®\\!\\@\\#\\$\\%\\^\\&\\*\\?\\+\\=\\:\\;\\<\\>\\[\\]\\{\\}\\~\\|\\\\\\_\\,\\`\\'\\\"\\.\\(\\)]/,'')\n \n # Remove leading dashes\n slug = slug[0..0].eql?(\"-\") ? slug[1..-1] : slug\n\n # Join the portions, and replace non-word (+i18n) characters with dashes\n # Squeeze runs of dashes, chomp off trailing dashes, and present\n (id+slug).gsub(/[^\\w]/, '-').squeeze('-').chomp('-')\n end", "def normalize_friendly_id(slug_string)\n FriendlyIdPath.normalize_friendly_id(slug_string)\n end", "def to_param\n \"#{id}-#{canonical_title.parameterize}\"\n end", "def to_param\n \"#{self.id}-#{self.friendly_id}\"\n end", "def id_safe(text)\n\t\ttext.gsub(/[ .?!]/, ' ' => '-', '.' => '', '?' => '', '!' => '').gsub(/-{2,}/, '-').downcase.to_s\n\tend", "def should_generate_new_friendly_id?; end", "def to_friendly_param\n to_param\n end", "def to_param\n friendly_id_config.cache_column ? to_param_from_cache : to_param_from_slug\n end", "def as_slug\n Swift::Transliteration.slugize self\n end", "def cached_slug\n id.to_s\n end", "def to_param\n id.to_s + \"-\" + slug\n end", "def to_param\n id.to_s + \"-\" + slug\n end", "def to_param\n \"#{id}-#{self.title}\".parameterize\n end", "def to_param\n \"#{id}-#{self.title}\".parameterize\n end", "def short_code\n id.to_s 36\n end", "def to_param\n if friendly_id_config.routes == :friendly\n friendly_id.presence.to_param || super\n else\n super\n end\n end", "def should_generate_new_friendly_id?\n true\n end", "def to_param\n \"#{id}-#{title.to_s.gsub(/\\p{^Alnum}/u, \" \").gsub(/\\s+/, \"-\").downcase}\"\n end", "def to_param\n \"#{id} #{title}\".parameterize\n end", "def to_param\n \"#{id} #{title}\".parameterize\n end", "def to_param\n \"#{id}-#{title.parameterize}\"\n end", "def to_param\n \"#{id}-#{title.parameterize}\"\n end", "def canonical_slug\n Globalize.with_locale(::Refinery::I18n.default_frontend_locale) { slug }\n end", "def slugfy\n# self.slug = title.gsub(/\\W/, '-').downcase\n self.slug = title.parameterize.to_s\n end", "def locale\n (self.country.blank? or self.country.indonesia?) ? :id : :en\n end", "def secure_id\n @secure_id_without_dashes ||= super&.gsub(\"-\", \"\")\n end", "def canonical_slug\n Mobility.with_locale(::Refinery::I18n.current_frontend_locale) { slug }\n end", "def has_better_id?\n slug and found_using_numeric_id? || found_using_outdated_friendly_id?\n end", "def sanitize_for_id(unsanitized_string)\n unsanitized_string.gsub(\" \", \"_\").downcase\n end", "def localised_string table, key\n plugin.localised_string(table, key)\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n slug\n end", "def to_param\n \"#{id}-#{title.to_s.gsub(/\\W/, '_').downcase}\"\n end", "def to_param\n \"#{id}-#{title.parameterize[0..32]}\"\n end", "def to_param\n \"#{id}-#{title.parameterize[0..32]}\"\n end", "def to_param\n \"#{ slug }\"\n end", "def hecho_en\n 'china'\n end", "def loser_code()\n \"L\"+self.id.to_s\n end", "def to_param\n \"#{id}-#{title.gsub(/\\W/, '-').downcase}\"\n end" ]
[ "0.784157", "0.784157", "0.784157", "0.76804805", "0.74155873", "0.7400233", "0.7400233", "0.7400233", "0.7226008", "0.71514297", "0.70323867", "0.6992389", "0.6964565", "0.6912709", "0.6861595", "0.6850003", "0.682335", "0.6747979", "0.66526747", "0.66428006", "0.6642008", "0.66270465", "0.66060877", "0.66060877", "0.66060877", "0.66060877", "0.6598831", "0.65819734", "0.6457259", "0.6438106", "0.6415143", "0.6415143", "0.6415143", "0.6396189", "0.6396189", "0.6396189", "0.6396189", "0.6369362", "0.636843", "0.63664967", "0.63338333", "0.63091254", "0.62999946", "0.627395", "0.6201041", "0.61342007", "0.6131376", "0.6121343", "0.6066417", "0.60523564", "0.6043538", "0.6015661", "0.5981338", "0.59311163", "0.58823293", "0.5868082", "0.5868082", "0.5836559", "0.5836559", "0.58318627", "0.5759066", "0.5729419", "0.5721305", "0.57174075", "0.57174075", "0.5717379", "0.5717379", "0.5697983", "0.56959975", "0.5683135", "0.56787026", "0.56709784", "0.5651868", "0.5621904", "0.56211674", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.56161565", "0.560876", "0.5606456", "0.5606456", "0.560498", "0.5599699", "0.5594974", "0.5594699" ]
0.668178
20
convert parameters with hyphen to parameters with underscore. deep_transform_keys has been removed in Rails 5.1
def transform_params params.transform_keys! { |key| key.underscore } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transform\n params.transform_keys! { |key| key.tr('-', '_') }\n end", "def transform_params\n params.transform_keys! { |key| key.tr(\"-\", \"_\") }\n end", "def transform_param_keys_casing\n params.transform_keys!(&:underscore)\n end", "def normalize_keys(hash)\n hash.inject(HashWithIndifferentAccess.new) do |new_hash, (key, value)|\n new_hash[key.parameterize(separator: \"_\")] = value\n new_hash\n end\n end", "def normalize_key(k)\n k.to_s.gsub('-', '_').gsub(INVALID_PATTERN, '').to_sym\n end", "def deep_underscore_keys\n deep_transform_keys { |key| key.to_s.underscore }\n end", "def normalize(key)\n key.tr(\"-\", \"_\")\n end", "def convert_underscores(hash)\n hash.each_with_object({}) do |(k ,v), obj|\n key = k.to_s.gsub(/_/, '-').to_sym\n obj[key] = v\n\n end\n end", "def normalize\n @parameters.inject({}) do |hash, (k, v)|\n v = v.is_a?(Array) ? v.join(',') : v.to_s\n k = k.to_s.split('_').map {|w| w[0, 1] = w[0, 1].upcase; w }.join\n hash[k] = v\n\n hash\n end\n end", "def rubyize_keys\n transform_keys do |key|\n key\n .to_s\n .gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2')\n .gsub(/([a-z\\d])([A-Z])/, '\\1_\\2')\n .downcase\n .to_sym\n end\n end", "def convert_underscores(hash)\n hash.each_with_object({}) do |(k ,v), obj|\n key = k.to_s.gsub(/_/, '-').to_sym\n obj[key] = v\n end\nend", "def normalize_keys\n transform_keys { |key| key.downcase.to_sym rescue key }\n end", "def normalized_key key\n key.downcase.parameterize.underscore.to_sym\n end", "def recursively_normalize_keys\n recursively_transform_keys { |key| key.downcase.to_sym rescue key }\n end", "def underscore_keys input\n case input\n when Hash\n input.to_h { |key, value| [ActiveSupport::Inflector.underscore(key), underscore_keys(value)] }\n when Array\n input.map { |elem| underscore_keys elem }\n else\n input\n end\n end", "def deep_camelize_keys\n deep_transform_keys { |key| key.to_s.camelize(:lower) }\n end", "def dasherize_keys(hash)\n hash.deep_transform_keys do |key|\n key.to_s.dasherize\n end\n end", "def normalize_key(key)\n case key\n when Numeric, nil\n # nils never happen here in Ruby >= 2.3 since nils\n # skip the normalizer.\n key\n else\n key.to_s.downcase.strip\n .gsub(/(?:\\s+|-)/, '_')\n .gsub(/[^a-zA-Z0-9_]+/, '')\n .squeeze('_')\n .gsub(/_$/, '')\n .to_sym\n end\n end", "def deep_transform_keys(&block); end", "def normalize_abbreviation_key(key); end", "def format_key(key)\n key.to_s.gsub(\"-\",\"_\")\n end", "def deep_camelize_keys!(first_letter = :upper)\n deep_transform_keys! { |key| key.to_s.camelize(first_letter) rescue key }\n end", "def clean_fields(fields)\n fields.map { |k, v| [k.to_s.downcase.gsub(/ |-/, '_'), v] }.to_h\n end", "def deep_transform_keys!(&block); end", "def normalize_flat_keys(locale, key, scope, separator); end", "def normalize_flat_keys(locale, key, scope, separator); end", "def underscore_fix_for_related_urls(key)\n if key == 'RelatedURLs'\n 'related_urls'\n else\n key.underscore\n end\n end", "def normalize_keys(hash)\n hash.each{|k, v|\n hash.delete(k) unless @@valid_types.include?(v.class)\n if k.is_a?(String)\n hash.delete(k)\n hash[k.gsub(/\\-/, \"_\").to_sym] = v\n elsif !k.is_a?(Symbol) # elsunless\n hash.delete(k)\n end\n }\n return hash\nend", "def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end", "def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end", "def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end", "def deep_transform_keys!(&block)\n @parameters.deep_transform_keys!(&block)\n self\n end", "def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end", "def normalize\n inject({}) do |hash, kv|\n k, v = kv\n v = v.is_a?(Array) ? v.join(',') : v.to_s\n hash[k.to_s.split('_').map {|w| w[0, 1] = w[0, 1].upcase; w }.join] = v\n hash\n end\n end", "def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end", "def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end", "def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end", "def load_param\n to_hash.select { |_key, value| value }\n .map { |key, value| [key.to_s.split('_').map(&:capitalize).join.sub!(/\\D/, &:downcase), value] }\n .to_h\n end", "def sanitize_key key\n key.gsub! '-', '_'\n key.gsub! ' ', ''\n key.gsub! ',', ''\n key.downcase!\n return key\n end", "def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end", "def convert_key(key); end", "def convert_key(key); end", "def convert_key(key); end", "def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end", "def transformed_argname=(_); end", "def deep_stringify_keys!\n deep_transform_keys! { |key| key.to_s }\n end", "def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end", "def normalize_key(key)\n KEY_NORMALIZER.call(key)\n end", "def camelcase_params!(params)\n params.keys.select {|key| key.is_a?(Symbol) && key.to_s.include?(?_) }.each do |key|\n camelcase_key = camelize(key)\n camelcase_key[0] = camelcase_key[0].chr.downcase\n params[camelcase_key] = params.delete(key)\n end\n end", "def params_key(k)\n key = k.to_s.camelize\n key.gsub('Id', 'ID')\n end", "def transform_keys!(&block); end", "def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end", "def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end", "def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end", "def javaize_key(key)\n key = key.to_s\n case key\n when 'acquirer_transaction_request'\n 'AcquirerTrxReq'\n when 'acquirer_status_request'\n 'AcquirerStatusReq'\n when 'directory_request'\n 'DirectoryReq'\n when 'issuer', 'merchant', 'transaction'\n key.capitalize\n when 'created_at'\n 'createDateTimeStamp'\n when 'merchant_return_url'\n 'merchantReturnURL'\n when 'token_code', 'expiration_period', 'entrance_code'\n key[0,1] + key.camelize[1..-1]\n when /^(\\w+)_id$/\n \"#{$1}ID\"\n else\n key\n end\n end", "def transform_keys(&block); end", "def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end", "def normalize_keys(locale, key, scope, separator = nil)\n keys = [locale] + Array(scope) + Array(key)\n keys = keys.map {|k| I18n.translation_key_escaped?(k) ? I18n.unescape_translation_key(k) : k.to_s.split(separator || I18n.default_separator)}\n keys = (keys.flatten - ['']).reject {|k| !k}\n keys.map {|k| k.to_sym if k}\n end", "def expanded_key(key)\n return key.cache_key.to_s if key.respond_to?(:cache_key)\n\n case key\n when Array\n if key.size > 1\n key.collect { |element| expanded_key(element) }\n else\n expanded_key(key.first)\n end\n when Hash\n key.collect { |k, v| \"#{k}=#{v}\" }.sort!\n else\n key\n end.to_param\n end", "def deep_symbolize_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_sym rescue key }\n end", "def attributize_keys\n keys.each do |key|\n self[key.parameterize.underscore.to_sym] = delete(key)\n end\n self\n end", "def dasherize_keys(data)\n return nil if data.nil?\n return data.map { |obj| dasherize_keys obj } if data.is_a? Array\n if data.is_a? Hash\n return Hash[data.map {|k, v| [k.to_s.dasherize, dasherize_keys(v)] }]\n end\n return data\n end", "def deep_stringify_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_s }\n end", "def format_key(key)\n key.tr(\"_\", \"-\")\n .gsub(\"enabled\", \"enable\")\n .gsub(\"user-name\", \"username\")\n .gsub(/^registry-jwt-expiration-time-value$/, \"jwt-expiration-time\")\n .gsub(/^registry-catalog-page-value$/, \"catalog-page\")\n .gsub(/^check-ssl-usage-enable$/, \"secure\")\n .gsub(/^user-permission-change-visibility-enable$/, \"change-visibility-enable\")\n .gsub(/^user-permission-manage-namespace-enable$/, \"manage-namespace-enable\")\n .gsub(/^user-permission-create-namespace-enable$/, \"create-namespace-enable\")\n .gsub(/^user-permission-manage-team-enable$/, \"manage-team-enable\")\n .gsub(/^user-permission-create-team-enable$/, \"create-team-enable\")\nend", "def underscore(value)\n case value\n when Hash then value.deep_transform_keys! { |key| underscore(key) }\n when Symbol then underscore(value.to_s).to_sym\n when String then StringSupport.underscore(value)\n else value\n end\n end", "def convert_key dbkey\n arr = dbkey.split('_')\n arr.each {|s|s[0]=s[0].upcase}\n newkey = arr.join('')\n newkey[0]=newkey[0].downcase\n newkey\n end", "def recursively_stringify_key\n recursively_transform_keys { |key| key.to_s rescue key }\n end", "def stringify_keys!\n replace stringify_keys\n end", "def decode_parameter(key)\n key.to_s.sub(/^_/, '').to_sym\n end", "def underscore\n gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').gsub(/([a-z\\d])([A-Z])/, '\\1_\\2').tr('-', '_').downcase\n end", "def convert_key(key)\n case key\n when '$'\n 'text'\n when 'D', 'Dm', 'F', 'FDm', 'FNm', 'G', 'Gm', 'Gn', 'H', 'Hm', 'Hn', 'Nm', 'P', 'Pp', 'PPd', 'PPn', 'S', 'T', 'U', 'V', 'W'\n key\n else\n key.to_s.strip.\n gsub('@', '').\n gsub(' ', '_').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n squeeze(\"_\").\n downcase\n end\n end", "def prepare_key prefix, key\n \"oaf_#{prefix}_#{key.gsub('-', '_').downcase}\"\n end", "def to_underscore(string)\n string.to_s.gsub(/([A-Z][A-Z0-9]?)/) { '_' + $1.downcase }.gsub(/^_|\\s_/, ' ').gsub(/^\\s/, '')\nend", "def stringify_keys!\n transform_keys!{ |key| key.to_s }\n end", "def format\n Hash[params.map {|k, v| [k.to_s.dasherize, v]}]\n end", "def underscore!\n gsub!('::', '_')\n gsub!(/([A-Z\\d]+)([A-Z][a-z])/, '\\1_\\2')\n gsub!(/([a-z\\d])([A-Z])/, '\\1_\\2')\n downcase!\n end", "def underscore\n gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').\n gsub(/([a-z\\d])(A-Z)/, '\\1_\\2').\n tr('-', '_').downcase\n end", "def transform_params(params)\n case @case\n when 'snake', 'as_is'\n params\n when 'camel'\n snakecase_keys(params)\n else\n raise Blacksheep::Error, \"unknown_case #{@case}\"\n end\n end", "def fill_key_name\n self.key_name = key_name&.parameterize(separator: '_')\n end", "def dehyphenate_keys=(bool)\n self[:dehyphenate_keys] = bool\n if bool == true\n Hashugar.class_eval(%q[\n def stringify_key(key)\n (key.is_a?(Symbol) ? key.to_s : key).gsub(/-/, '_')\n end\n ])\n elsif bool == false\n Hashugar.class_eval(%q[\n def stringify_key(key)\n key.is_a?(Symbol) ? key.to_s : key\n end\n ])\n else\n raise ArgumentError\n end\n end", "def expand_keys(key)\n key.to_s.split(FLATTEN_SEPARATOR).inject([]) do |keys, k|\n keys << [keys.last, k].compact.join(FLATTEN_SEPARATOR)\n end\n end", "def stringify_keys\n transform_keys { |key| key.to_s rescue key }\n end", "def stringify_keys!\n transform_keys!(&:to_s)\n end", "def stringify_keys!\n transform_keys!(&:to_s)\n end", "def stringify_keys!\n transform_keys!(&:to_s)\n end", "def sanitize(p, keys)\n new_params = {}\n keys.each { |k| new_params[k] = p[k] if p.include?(k) }\n return new_params.symbolize_keys\n end", "def transform_parameters(params)\n Smash.new.tap do |new_hash|\n (params || []).each do |key, value|\n new_hash[snakecase(key)] = value\n end\n end\n end", "def stringified_keys; end", "def to_underscore(s)\n s.gsub(/\\.|\\-/, '__')\n end", "def underscore\n self.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end", "def unescape_keys(attrs)\n h=Hash.new\n attrs.each do |k,v|\n h[k.gsub(/ /, '_')]=v\n\n end\n h\n end", "def unescape_keys(attrs)\n h=Hash.new\n attrs.each do |k,v|\n h[k.gsub(/ /, '_')]=v\n\n end\n h\n end", "def _squish(hash)\n hash = _flatten(hash)\n hash.each_with_object({}) do |(k, v), ret|\n k = k.gsub(/extensions|com|instructure|canvas/, '').gsub(/_+/, '_').gsub(/^_/, '').downcase\n ret[k] = v\n end\nend", "def transform_keys!(&block)\n return to_enum(:transform_keys!) unless block_given?\n @parameters.transform_keys!(&block)\n self\n end", "def transformed_argname; end", "def underscore(value)\n case value\n when Array then value.map { |item| underscore(item) }\n when Hash then value.deep_transform_keys! { |key| underscore(key) }\n when Symbol then underscore(value.to_s).to_sym\n when String then value.underscore\n else value\n end\n end", "def underscore(camel_cased_word)\n word = camel_cased_word.to_s.gsub('::', '/')\n word.gsub!(/([A-Z\\d]+)([A-Z][a-z])/,'\\1_\\2')\n word.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n word.tr!(\"-\", \"_\")\n word.downcase!\n word\n end", "def normalize(name)\n name.to_s.gsub('-', '_')\n end", "def camelize_and_normalize_name(snake_cased_name)\n result = Client.camelize_name(snake_cased_name.to_s)\n PARAM_NORMALIZATION.each {|k, v| result.gsub!(/#{k}/, v) }\n result\n end", "def symbolize_keys!\n transform_keys!{ |key| key.to_sym rescue key }\n end" ]
[ "0.83179075", "0.80978477", "0.7838634", "0.69487405", "0.6860742", "0.6818881", "0.68116105", "0.67156476", "0.66917235", "0.6674035", "0.66411376", "0.6572811", "0.65596545", "0.65286756", "0.6525203", "0.6471799", "0.6468641", "0.64488655", "0.62814033", "0.62770873", "0.6273019", "0.62708586", "0.62692", "0.62403184", "0.6222452", "0.6222452", "0.61822796", "0.6166042", "0.6164228", "0.61611545", "0.61611545", "0.6139419", "0.6136219", "0.6122904", "0.6114764", "0.6114764", "0.6114764", "0.61144304", "0.6103092", "0.6099341", "0.6068063", "0.6068063", "0.6068063", "0.6036181", "0.6030904", "0.60291046", "0.6026741", "0.602292", "0.6013991", "0.60128623", "0.6012365", "0.5965632", "0.5962212", "0.5962212", "0.595567", "0.5947276", "0.5945177", "0.59241617", "0.59236777", "0.591337", "0.59115046", "0.59109986", "0.5910268", "0.59083337", "0.58980715", "0.5893928", "0.5889002", "0.58800644", "0.586825", "0.58499295", "0.5845936", "0.5844248", "0.58435667", "0.58365554", "0.58313566", "0.5828491", "0.58284056", "0.5823865", "0.5811078", "0.5799345", "0.5794736", "0.5791643", "0.5780714", "0.5780714", "0.5780714", "0.5780294", "0.57780886", "0.5777123", "0.57734996", "0.5761009", "0.575523", "0.575523", "0.57538646", "0.57504016", "0.5745457", "0.5744365", "0.5731605", "0.5730584", "0.5729408", "0.5727961" ]
0.79714274
2
Building an mxmlc line
def get_compile_line(input, output) libs_path = LIBRARY_PATH.map{ |lib| "-library-path+='#{File.join(current_path, lib)}'"}.join(" ") sources_path = SOURCE_PATH.map{ |lib| "-sp+='#{File.join(current_path, lib)}'"}.join(" ") line = "mxmlc #{File.join(current_path(), input)} -o=#{File.join(current_path(), output)} -debug=#{DEBUG} #{libs_path} #{sources_path} #{EXTRA}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comp_line\n @xml += \"<#{@tokens[@i].type}> #{@tokens[@i].val} </#{@tokens[@i].type}> \"\n @i += 1\n end", "def build_line_content_tag(line_content, container_attributes)\n result = Nokogiri::XML::Element.new('td', doc)\n result['class'] = 'line-content'\n\n line_pre = Nokogiri::XML::Element.new('pre', doc)\n result.add_child(line_pre)\n container_attributes.each { |key, value| line_pre.set_attribute(key, value) }\n\n line_code = Nokogiri::XML::Element.new('code', doc)\n line_pre.add_child(line_code)\n line_code.inner_html = line_content\n\n result\n end", "def project_to_line\n end", "def build_line_tag(line_number, line_content, container_attributes)\n tr = Nokogiri::XML::Element.new('tr', doc)\n\n tr.add_child(build_line_number_tag(line_number))\n tr.add_child(build_line_content_tag(line_content, container_attributes))\n\n tr\n end", "def element_line(element); end", "def build_line_number_tag(line_number)\n result = Nokogiri::XML::Element.new('td', doc)\n result['class'] = 'line-number'\n result['data-line-number'] = line_number\n\n result\n end", "def build_line(multiplier, products)\n multiplier.to_s + \": \" + products.to_s + \"\\n\"\n end", "def svg\n '<line x1= \"' + @head.x.to_s + '\" ' + \n 'y1= \"' + @head.y.to_s + '\" ' +\n 'x2= \"' + @tail.x.to_s + '\" ' +\n 'y2= \"' + @tail.y.to_s + '\" ' +\n \"\\n\\t\" +\n 'style=\"stroke:rgb(0,0,0);stroke-width:2\"/>'\n end", "def line_item_xml_data(line_item, xml)\n\n end", "def compile(xml)\n XML.default_line_numbers = true\n\n doc = nil\n\n if xml.is_a?(String)\n doc = LibXML::XML::Document.string xml\n doc = doc.root\n elsif xml.is_a?(LibXML::XML::Document)\n doc = xml.root\n else\n doc = xml\n end\n\n @context.compile_structural(doc)\n end", "def line_on_column(xmlparams)\n\n xml = xmlparams[:xml]\n min = xmlparams[:min] ? xmlparams[:min] : 400\n max = xmlparams[:max] ? xmlparams[:max] : 1000\n explode = xmlparams[:explode] ? xmlparams[:explode] : false\n\n explode_str=''\n if explode\n explode_str=%Q(\n <series_explode>\n <number>200</number>\n </series_explode>\n )\n end\n \n\n # data string for the chart\n data=%Q(\n <chart>\n \n <axis_value min='#{min}' max='#{max}' font='arial' bold='true' size='10' \n color='000000' alpha='50' steps='4' prefix='' suffix='' decimals='0' separator='' show_min='true' />\n \n <chart_border color='000000' top_thickness='1' bottom_thickness='2' left_thickness='0' right_thickness='0' />\n \n #{xml}\n \n <chart_grid_h alpha='20' color='000000' thickness='1' type='dashed' />\n <chart_rect x='55' y='70' width='300' height='200' positive_color='ffffff' negative_color='000000' \n positive_alpha='10' negative_alpha='30' />\n <!--chart_transition type='scale' delay='.5' duration='0.5' order='series' /-->\n <chart_value color='ffffff' alpha='85' font='arial' bold='true' size='10' \n position='middle' prefix='' suffix='' decimals='0' separator='' as_percentage='false' />\n \n <legend_label layout='horizontal' font='arial' bold='true' size='12' color='333355' alpha='90' />\n <legend_rect x='55' y='5' width='300' height='15' margin='5' fill_color='000066' fill_alpha='8' \n line_color='000000' line_alpha='0' line_thickness='0' />\n \n <chart_type>\n <string>column</string>\n <string>line</string>\n <string>line</string>\n <string>line</string>\n </chart_type>\n \n <series_color>\n <color>050222</color>\n <color>41A317</color>\n <color>FFF380</color>\n <color>F660AB</color>\n </series_color>\n <series_gap set_gap='40' bar_gap='-5' />\n \n #{explode_str}\n \n </chart>\n ) #'\n \n data\n end", "def line\n\t\tl = @name\n\t\t(1..25).each do |i|\n\t\t\tl += \" &\"\n\t\t\tif i <= @number then\n\t\t\t\tl += \" \\\\!$\\\\times$\"\n\t\t\tend\n\t\tend\n\t\tl += \" \\\\\\\\\\n\"\n\t\treturn l\n\tend", "def cpline_to(x, y, w = nil)\n return line_to(x, y) unless w\n command = absolute? ? 'C' : 'c'\n args = [@last.x + w, @last.y, x - w, y, x, y]\n @path_builder << \"#{command}#{to_path(args)}\"\n @last.x = (absolute? ? 0 : @last.x) + x\n @last.y = (absolute? ? 0 : @last.y) + y\n @last.bx = x - w\n @last.by = y\n end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line_template(ul = 'unmarked', ur = 'unmarked', ll = 'unmarked', lr = 'unmarked')\n html = <<-eol\n <div class=\"fam-tree-line-container\">\n <div class=\"fam-tree-line-level\">\n <div class=\"fam-tree-#{ul}\"></div>\n <div class=\"fam-tree-#{ur}\"></div>\n #{clear}\n </div>\n <div class=\"fam-tree-line-level\">\n <div class=\"fam-tree-#{ll}\"></div>\n <div class=\"fam-tree-#{lr}\"></div>\n #{clear}\n </div>\n </div>\n eol\n html.html_safe\n end", "def initialize(path, line_number, line)\r\n @path = path\r\n @line_number = line_number\r\n @line = line\r\n @colorize_line = @line.gsub('<', '&lt;')\r\n @colorize_line = @colorize_line.gsub('>', '&gt;')\r\n end", "def mxmlc *args, &block\n mxmlc_tool = Sprout::MXMLC.new\n mxmlc_tool.to_rake(*args, &block)\n mxmlc_tool\nend", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if [email protected]? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def begin_line kind\n if style = @span_for_kinds[@last_opened ? [kind, *@opened] : kind]\n if style['class=\"']\n @out << style.sub('class=\"', 'class=\"line ')\n else\n @out << style.sub('>', ' class=\"line\">')\n end\n else\n @out << '<span class=\"line\">'\n end\n @opened << kind\n @last_opened = kind if @options[:css] == :style\n end", "def build_first_line\n @number = Qt::Label.new\n add_widget(@number)\n end", "def rb_mvwvline row, col, char, width\n mvwvline row, col, char, width\n end", "def how_to_render_lines args\n # Render a horizontal line at the bottom\n args.nokia.lines << { x: 0, y: 0, x2: 83, y2: 0 }\n\n # Render a vertical line at the left\n args.nokia.lines << { x: 0, y: 0, x2: 0, y2: 47 }\n\n # Render a diagonal line starting from the bottom left and going to the top right\n args.nokia.lines << { x: 0, y: 0, x2: 83, y2: 47 }\nend", "def line\n end", "def line\n end", "def child *a; CssString.new a.flatten.unshift(self).join ' > ' end", "def putc(*line)\n raise unless @state == :asm\n @outp.puts(formatDump(\" \" + line.join(''), lastComment))\n end", "def line(&block)\n attributes[:lines] << Line.build(&block)\n end", "def normal_line(text)\n end", "def build\n\n\t\t\tFlexMate::SDK.add_flex_bin_to_path\n\t\t\tTextMate.require_cmd('mxmlc')\n\n\t\t\tcmd = MxmlcCommand.new\n\t\t\tcmd.file_specs = get_file_specs\n\t\t\tcmd.o = get_flex_output(cmd.file_specs)\n\n\t\t\tputs html_head( :window_title => \"ActionScript 3 Build Command\",\n\t\t\t\t\t\t\t\t\t\t\t:page_title => \"Build (mxmlc)\",\n\t\t\t\t\t\t\t\t\t\t\t:sub_title => cmd.file_specs_name )\n\n\t\t\tputs \"<h2>Building...</h2>\"\n\t\t\tputs \"<p><pre>-file-specs=#{cmd.file_specs}\"\n\t\t\tputs \"-o=#{cmd.o}</pre></p>\"\n\n\t\t\texhaust = get_exhaust\n\t\t\t\n\t\t\tTextMate::Process.run(cmd.line) do |str|\n\t\t\t\tSTDOUT << exhaust.line(str)\n\t\t\tend\n\n\t\t\texhaust.complete\n\n\t\t\thtml_footer\n\n\t\tend", "def generate_content_ncx(content,path)\n @builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n class_types_map = {\"Subject\" => \"course\", \"ContentYear\" => \"academic-class\", \"Subject\" => \"subject\", \"Chapter\" => \"chapter\", \"Topic\" => \"topic\", \"SubTopic\" => \"subtopic\"}\n xml.navMap do\n xml.navPoint(:id=>\"Curriculum\", :class=>\"curriculum\") do\n xml.content(:src=>\"curriculum\")\n xml.navPoint(:id=>\"Content\",:class=>\"content\")do\n xml.content(:src=>\"content\")\n\n ## The code for generating the inside xml string\n content_xml_string = ''\n parents = content.parents.reverse\n ## Generating the content node\n parents.each do |parent|\n content_data = Content.find(parent[\"ancestor\"])\n ## Getting the class for the current node\n node_class = class_types_map[content_data.type]\n ## Getting the src for the current node\n node_src = ''\n if content_data.type == 'Board'\n node_src = content_data.code+'_'+content.assets.first.publisher_id.to_s\n elsif content_data.type == 'ContentYear' or content_data.type == 'Subject'\n node_src = content_data.code\n else\n node_src = content.assets.first.src\n end\n # Reset the nav node and the content node\n nav_node = ''\n content_node = ''\n\n # Generating the nav node\n nav_node = nav_node+\"<navPoint id='#{content_data.name}' class='#{node_class}' >\"\n\n # Generating the content node\n content_node = content_node+\"<content src='#{node_src}' />\"\n\n ## Appending the nav node and the content node to the main xml\n content_xml_string = content_xml_string+nav_node+content_node\n end\n ## Appending the navpoint end tags to the string\n parents.length.times do\n content_xml_string = content_xml_string + \"</navPoint>\"\n end\n\n ## End of code for generating the xml string\n xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse(content_xml_string)\n end\n end\n end\n end\n xml_string = @builder.to_xml.to_s\n file = File.new(path+\"/\"+\"index.ncx\", \"w+\")\n File.open(file,'w') do |f|\n f.write(xml_string.to_s.gsub( \"\\n\", \"\" ).gsub(/>[ ]*</,'><'))\n end\n create_zip(\"content_#{content.id}\",path)\n end", "def line(number); end", "def reduce_new_line(_production, _range, _tokens, _children)\n # TODO: control portability\n Regex::Character.new('\\n')\n end", "def build_node\n \"\"\n end", "def rb_mvwvline row, col, char, width\n super(row-@top, col-@left, char, width)\n end", "def addTimelineElement(template, line, current, index)\n\ttime_point = Nokogiri::XML::Node.new(\"when\", template)\n\ttime_point['id'] = 'timepoint_' + (index + 1).to_s \n\ttime_point['since'] = 'timepoint_begin'\n\t\t\t\n\ttime_point['interval'] = srt_time_to_milliseconds(line.start_time)\n\n\tcurrent.add_next_sibling(time_point)\n\tcurrent.add_next_sibling(\"\\n\")\n\n\treturn time_point\nend", "def build_xml(target, type, value)\n <<-EOF.gsub(/^ {8}/, '')\n <?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\n <entry\n xml:base=\"/p/p.svc/\"\n xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\"\n xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"\n xmlns=\"http://www.w3.org/2005/Atom\">\n <id></id>\n <title type=\"text\"></title>\n <updated>#{@time}</updated>\n <author><name /></author>\n <category term=\"pomegranateModel.Asset\" scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\" />\n <content type=\"application/xml\">\n <m:properties>\n <d:AssetID>--</d:AssetID>\n <d:AssetData>#{type === \"TEXT\" ? escape_xml(value) : value}</d:AssetData>\n <d:AssetType>#{type}</d:AssetType>\n <d:AssetMeta></d:AssetMeta>\n <d:AssetRecordID>#{@record_id}</d:AssetRecordID>\n <d:Target>#{target}</d:Target>\n <d:Client>#{@client_id}</d:Client>\n <d:Status>#{@client_id == \"P0\" ? \"UPLOADED\" : \"APPROVED\"}</d:Status>\n </m:properties>\n </content>\n </entry>\n EOF\n end", "def line\n @line ||= Line.get(@attrs['LineCode'])\n end", "def process_next_line\n @line_starts_with_tick = false\n @self_closing = false\n @inner_text = nil\n \n line = \"\"\n \n if @text[\"\\n\"] != nil\n line_break_index = @text.index \"\\n\"\n line = @text[0..line_break_index].strip\n @text = @text[line_break_index+1..-1]\n else\n line = @text.strip()\n @text = \"\"\n end\n \n @line_number += 1\n if line.length == 0\n return self\n end\n \n # Whole line embedded HTML, starting with back ticks:\n if line[0] == @embedding_token\n self.process_embedded_line line\n \n else\n # Support multiple tags on one line via \"\\-\\\" delimiter\n while true do\n line_split_list = line.split '\\\\-\\\\'\n lines = [line_split_list[0]]\n \n if line_split_list.length == 1\n line = line_split_list[0].strip\n break\n else\n lines << line_split_list[1..-1].join('\\\\-\\\\')\n end\n \n lines[0] = lines[0].strip\n selector = self.class.get_selector_from_line lines[0]\n self.process_selector((selector*1))\n rest_of_line = lines[0][selector.length..-1].strip\n rest_of_line = self.process_attributes rest_of_line\n self.add_html_to_output\n \n @tag = nil\n @tag_id = nil\n @tag_classes = []\n @tag_attributes = []\n @previous_level = @current_level * 1\n @current_level += 1\n line = lines[1..-1].join '\\\\-\\\\'\n end\n \n selector = self.class.get_selector_from_line line\n self.process_selector((selector*1))\n rest_of_line = line[selector.length..-1].strip\n rest_of_line = self.process_attributes rest_of_line\n \n if rest_of_line.index('<') == 0\n @inner_text = rest_of_line\n if self.class.get_tag_nest_level(@inner_text) < 0\n raise CompilerException, \"Too many '>' found on line #{@line_number}\"\n end\n \n while self.class.get_tag_nest_level(@inner_text) > 0 do\n if @text == \"\"\n raise CompilerException, \"Unmatched '<' found on line #{@line_number}\"\n \n elsif @text[\"\\n\"] != nil\n line_break_index = @text.index \"\\n\"\n # Guarantee only one space between text between lines.\n @inner_text << ' ' + @text[0..line_break_index].strip\n if @text.length == line_break_index + 1\n @text = \"\"\n else\n @text = @text[line_break_index+1..-1]\n end\n \n else\n @inner_text << @text\n @text = \"\"\n end\n end\n \n @inner_text = @inner_text.strip()[1..-2]\n \n elsif rest_of_line.index('/') == 0\n if rest_of_line.length > 0 and rest_of_line[-1] == '/'\n @self_closing = true\n end\n end\n \n self.add_html_to_output\n end\n \n self\n end", "def element_lines(elements); end", "def make_vm_line(vm)\n \"${color2} #{vm}\\n\"\nend", "def generate_ncx(content,path)\n @builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.navMap{\n xml.navPoint(:id=>\"Curriculum\", :class=>\"curriculum\"){\n xml.content(:src=>\"curriculum\")\n\n # TODO: Currently if Publishing the Assessment as Home Work then storing \"Home Work\" in the extras\n # The code for generating the NCX for the Assessments of type Practice Test, Insti Test or Quiz\n if content.type.eql?\"Assessment\" and (content.extras.nil? or !content.extras.index(\"homework\")) and (content.assessment_type.eql?\"practice-tests\" or content.assessment_type.eql?\"insti-tests\" or content.assessment_type.eql?\"quiz\" or content.assessment_type.eql?\"olympiad\" or content.assessment_type.eql?\"iit\" or content.assessment_type.eql?\"inclass\")\n xml.navPoint(:id=>\"Assessment\",:class=>\"assessment\"){\n xml.content(:src=>\"assessments\")\n xml.navPoint(:id=>content.subject.board.name,:class=>\"course\"){\n xml.content(:src=>content.subject.board.code+\"_\"+content.asset.publisher_id.to_s)\n xml.navPoint(:id=>content.subject.content_year.name,:class=>\"academic-class\"){\n xml.content(:src=>content.subject.content_year.code)\n xml.navPoint(:id=>content.assessment_type,:class=>\"assessment-category\"){\n xml.content(:src=>\"practice\")\n\n # The code for handling the data if the subject has a subject as a parent\n if !content.subject.subject_id.nil?\n xml.navPoint(:id=>content.subject.parent_subject.name,:class=>\"subject\")\n xml.content(:src=>content.subject.parent_subject.code)\n end\n # End of code for handling the data if the subject has a subject as a parent\n\n xml.navPoint(:id=>content.subject.name,:class=>\"subject\"){\n xml.content(:src=>content.subject.code)\n if !content.subject_id.nil? and content.chapter_id.nil? and content.topic_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type, :passwd=>content.passwd ){\n xml.content(:src=>content_url(content))\n }\n end\n if !content.chapter_id.nil? and content.topic_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.chapter.name, :class=>\"chapter\"){\n xml.content(:src=>content.chapter.assets.first.src)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type ,:passwd=>content.passwd){\n xml.content(:src=>content_url(content))\n }\n }\n end\n if !content.topic_id.nil? and !content.chapter_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.topic.chapter.name, :class=>\"chapter\"){\n xml.content(:src=>content.topic.chapter.assets.first.src)\n xml.navPoint(:id=>content.topic.name, :class=>\"topic\"){\n xml.content(:src=>content.topic.assets.first.src)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type,:passwd=>content.passwd){\n xml.content(:src=>content_url(content))\n }\n }\n }\n end\n if !content.sub_topic_id.nil? and !content.chapter_id.nil? and !content.topic_id.nil?\n xml.navPoint(:id=>content.sub_topic.chapter.name, :class=>\"chapter\"){\n xml.content(:src=>content.sub_topic.chapter.assets.first.src)\n xml.navPoint(:id=>content.sub_topic.topic.name, :class=>\"topic\"){\n xml.content(:src=>content.sub_topic.topic.assets.first.src)\n xml.navPoint(:id=>content.sub_topic.name, :class=>\"subtopic\"){\n xml.content(:src=>content.sub_topic.assets.first.src)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type,:passwd=>content.passwd){\n xml.content(:src=>content_url(content))\n }\n }\n }\n }\n end\n }\n }\n }\n }\n }\n\n # The code for generating the NCX for publishing Assessment Practice Test, Insti Test or Quiz as Home Work\n elsif content.type.eql?\"Assessment\" and (!content.extras.nil? and content.extras.index(\"homework\")) and (content.assessment_type.eql?\"practice-tests\" or content.assessment_type.eql?\"insti-tests\" or content.assessment_type.eql?\"Quiz\")\n\n # Generating the Content Node\n xml.navPoint(:id=>\"Content\",:class=>\"content\"){\n xml.content(:src=>\"content\")\n xml.navPoint(:id=>content.subject.board.name,:class=>\"course\"){\n xml.content(:src=>content.subject.board.code+\"_\"+content.asset.publisher_id.to_s, :params=>content.subject.board.params)\n xml.navPoint(:id=>content.subject.content_year.name,:class=>\"academic-class\"){\n xml.content(:src=>content.subject.content_year.code,:params=>content.subject.content_year.params)\n\n # The code for handling the data if the subject has a subject as a parent\n if !content.subject.subject_id.nil?\n xml.navPoint(:id=>content.subject.parent_subject.name,:class=>\"subject\")\n xml.content(:src=>content.subject.parent_subject.code)\n end\n # End of code for handling the data if the subject has a subject as a parent\n\n xml.navPoint(:id=>content.subject.name,:class=>\"subject\"){\n xml.content(:src=>content.subject.code, :params=>content.subject.params)\n time = content.test_configurations.first.end_time.to_i*1000 rescue nil\n # Handling the case if chapter, topic and sub topic are NULL\n if !content.subject_id.nil? and content.chapter_id.nil? and content.topic_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type,:container_type => content.extras,:submitTime=>time,:passwd=>content.passwd){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name, :params=>content.subject.params)\n else\n xml.content(:src=>content_url(content), :params=>content.subject.params)\n end\n }\n end\n\n # Handling the case if topic and sub topic are NULL\n if !content.chapter_id.nil? and content.topic_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.chapter.name, :class=>\"chapter\", :playOrder=>content.chapter.play_order){\n xml.content(:src=>content.chapter.assets.first.src, :params=>content.chapter.params)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type, :container_type => content.extras, :playOrder=>content.chapter.play_order,:submitTime=>time,:passwd=>content.passwd){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name, :params=>content.chapter.params)\n else\n xml.content(:src=>content_url(content), :params=>content.chapter.params)\n end\n }\n }\n\n end\n\n # Handling the case if sub topic is NULL\n if !content.topic_id.nil? and !content.chapter_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.topic.chapter.name, :class=>\"chapter\", :playOrder=>content.chapter.play_order){\n xml.content(:src=>content.topic.chapter.assets.first.src, :params=>content.chapter.params)\n xml.navPoint(:id=>content.topic.name, :class=>\"topic\", :playOrder=>content.topic.play_order){\n xml.content(:src=>content.topic.assets.first.src, :params=>content.topic.params)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type, :container_type => content.extras, :playOrder=>content.topic.play_order,:submitTime=>time,:passwd=>content.passwd){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name, :params=>content.topic.params)\n else\n xml.content(:src=>content_url(content), :params=>content.topic.params)\n end\n }\n }\n }\n\n end\n\n # Handling the case if all are present\n if !content.sub_topic_id.nil? and !content.chapter_id.nil? and !content.topic_id.nil?\n xml.navPoint(:id=>content.sub_topic.chapter.name, :class=>\"chapter\", :playOrder=>content.chapter.play_order){\n xml.content(:src=>content.sub_topic.chapter.assets.first.src, :params=>content.chapter.params)\n xml.navPoint(:id=>content.sub_topic.topic.name, :class=>\"topic\", :playOrder=>content.topic.play_order){\n xml.content(:src=>content.sub_topic.topic.assets.first.src, :params=>content.topic.params)\n xml.navPoint(:id=>content.sub_topic.name, :class=>\"subtopic\", :playOrder=>content.sub_topic.play_order){\n xml.content(:src=>content.sub_topic.assets.first.src, :params=>content.sub_topic.params)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type, :container_type => content.extras, :playOrder=>content.sub_topic.play_order,:submitTime=>time,:passwd=>content.passwd){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name, :params=>content.sub_topic.params)\n else\n xml.content(:src=>content_url(content), :params=>content.sub_topic.params)\n end\n }\n\n\n }\n }\n }\n end\n }\n }\n }\n }\n\n # Generating the Homework Node\n xml.navPoint(:id=>\"HomeWork\",:class=>\"home-work\"){\n xml.content(:src=>\"homework\")\n xml.navPoint(:id=>content.subject.board.name,:class=>\"course\"){\n xml.content(:src=>content.subject.board.code+\"_\"+content.asset.publisher_id.to_s, :params=>content.subject.board.params)\n xml.navPoint(:id=>content.subject.content_year.name,:class=>\"academic-class\"){\n xml.content(:src=>content.subject.content_year.code, :params=>content.subject.content_year.params)\n\n # The code for handling the data if the subject has a subject as a parent\n if !content.subject.subject_id.nil?\n xml.navPoint(:id=>content.subject.parent_subject.name,:class=>\"subject\")\n xml.content(:src=>content.subject.parent_subject.code, :params=>content.subject.parent_subject.params)\n end\n # End of code for handling the data if the subject has a subject as a parent\n\n xml.navPoint(:id=>content.subject.name,:class=>\"subject\"){\n xml.content(:src=>content.subject.code,:params=>content.subject.params)\n time = content.test_configurations.first.end_time.to_i*1000 rescue nil\n\n # Handling the case if chapter, topic and sub topic are NULL\n if !content.subject_id.nil? and content.chapter_id.nil? and content.topic_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type, :prerequiste=>content.subject.uri,:submitTime=>time,:passwd=>content.passwd){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name, :params=>content.subject.params)\n else\n xml.content(:src=>content_url(content), :params=>content.subject.params)\n end\n }\n end\n\n # Handling the case if topic and sub topic are NULL\n if !content.chapter_id.nil? and content.topic_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.chapter.name, :class=>\"chapter\", :playOrder=>content.chapter.play_order){\n xml.content(:src=>content.chapter.assets.first.src,:params=>content.chapter.params)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type, :prerequiste=>content.chapter.uri,:playOrder=>content.chapter.play_order,:submitTime=>time,:passwd=>content.passwd){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name, :params=>content.chapter.params)\n else\n xml.content(:src=>content_url(content), :params=>content.chapter.params)\n end\n }\n }\n end\n\n # Handling the case if sub topic is NULL\n if !content.topic_id.nil? and !content.chapter_id.nil? and content.sub_topic_id.nil?\n xml.navPoint(:id=>content.topic.chapter.name, :class=>\"chapter\", :playOrder=>content.chapter.play_order){\n xml.content(:src=>content.topic.chapter.assets.first.src,:params=>content.chapter.params)\n xml.navPoint(:id=>content.topic.name, :class=>\"topic\", :playOrder=>content.topic.play_order){\n xml.content(:src=>content.topic.assets.first.src, :params=>content.topic.params)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type, :prerequiste=>content.topic.uri, :playOrder=>content.topic.play_order,:submitTime=>time,:passwd=>content.passwd){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name, :params=>content.topic.params)\n else\n xml.content(:src=>content_url(content), :params=>content.topic.params)\n end\n }\n }\n }\n end\n\n # Handling the case if all are present\n if !content.sub_topic_id.nil? and !content.chapter_id.nil? and !content.topic_id.nil?\n xml.navPoint(:id=>content.sub_topic.chapter.name, :class=>\"chapter\", :playOrder=>content.chapter.play_order){\n xml.content(:src=>content.sub_topic.chapter.assets.first.src,:params=>content.chapter.params)\n xml.navPoint(:id=>content.sub_topic.topic.name, :class=>\"topic\", :playOrder=>content.topic.play_order){\n xml.content(:src=>content.sub_topic.topic.assets.first.src, :params=>content.topic.params)\n xml.navPoint(:id=>content.sub_topic.name, :class=>\"subtopic\", :playOrder=>content.sub_topic.play_order){\n xml.content(:src=>content.sub_topic.assets.first.src, :params=>content.sub_topic.params)\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>\"assessment-\"+content.assessment_type, :prerequiste=>content.sub_topic.uri, :playOrder=>content.sub_topic.play_order,:submitTime=>time,:passwd=>content.passwd){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name, :params=>content.sub_topic.params)\n else\n xml.content(:src=>content_url(content), :params=>content.sub_topic.params)\n end\n }\n }\n }\n }\n end\n\n\n }\n }\n }\n }\n\n # End of code for generating the NCX for publishing Assessment Practice Test, Insti Test or Quiz as Home Work\n\n elsif content.type.eql?(\"AssessmentHomeWork\") or (content.type.eql?\"Assessment\" and content.assessment_type.eql?\"home-work\")\n xml.navPoint(:id=>\"HomeWork\",:class=>\"home-work\"){\n xml.content(:src=>\"homework\")\n xml.navPoint(:id=>content.subject.board.name,:class=>\"course\"){\n xml.content(:src=>content.subject.board.code+\"_\"+content.asset.publisher_id.to_s)\n xml.navPoint(:id=>content.subject.content_year.name,:class=>\"academic-class\"){\n xml.content(:src=>content.subject.content_year.code)\n\n # The code for handling the data if the subject has a subject as a parent\n if !content.subject.subject_id.nil?\n xml.navPoint(:id=>content.subject.parent_subject.name,:class=>\"subject\")\n xml.content(:src=>content.subject.parent_subject.code)\n end\n # End of code for handling the data if the subject has a subject as a parent\n\n xml.navPoint(:id=>content.subject.name,:class=>\"subject\"){\n xml.content(:src=>content.subject.code)\n #if !content.subject_id.nil? and content.chapter_id.nil? and content.topic_id.nil? and content.sub_topic_id.nil?\n time = (content.type.eql?(\"AssessmentHomeWork\")? content.content_profile.expiry_date.to_i*1000 : content.test_configurations.first.end_time.to_i*1000) rescue nil\n xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>((File.extname(content.asset.attachment_file_name) == \".zip\" or content.assessment_type == \"home-work\" ) ? \"assessment-practice-tests\" :\"assessment-home-work\") ,:submitTime=>time){\n if File.extname(content.asset.attachment_file_name) == \".zip\"\n Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n if File.extname(d) =='.etx'\n @name = d\n break\n end\n end\n xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name)\n else\n xml.content(:src=>content_url(content))\n end\n }\n #end\n #if !content.chapter_id.nil? and content.topic_id.nil? and content.sub_topic_id.nil?\n # xml.navPoint(:id=>content.chapter.name, :class=>\"chapter\"){\n # xml.content(:src=>content.chapter.assets.first.src)\n # xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>File.extname(content.asset.attachment_file_name) == \".zip\" ? \"assessment-practice-tests\" :\"assessment-home-work\"){\n # if File.extname(content.asset.attachment_file_name) == \".zip\"\n # Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n # if File.extname(d) =='.etx'\n # @name = d\n # break\n # end\n # end\n # xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name)\n # else\n # xml.content(:src=>content.asset.src)\n # end\n # }\n # }\n #end\n #if !content.topic_id.nil? and !content.chapter_id.nil? and content.sub_topic_id.nil?\n # xml.navPoint(:id=>content.topic.chapter.name, :class=>\"chapter\"){\n # xml.content(:src=>content.topic.chapter.assets.first.src)\n # xml.navPoint(:id=>content.topic.name, :class=>\"topic\"){\n # xml.content(:src=>content.topic.assets.first.src)\n # xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>File.extname(content.asset.attachment_file_name) == \".zip\" ? \"assessment-practice-tests\" :\"assessment-home-work\"){\n # if File.extname(content.asset.attachment_file_name) == \".zip\"\n # Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n # if File.extname(d) =='.etx'\n # @name = d\n # break\n # end\n # end\n # xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name)\n # else\n # xml.content(:src=>content.asset.src)\n # end\n # }\n # }\n # }\n #end\n #if !content.sub_topic_id.nil? and !content.chapter_id.nil? and !content.topic_id.nil?\n # xml.navPoint(:id=>content.sub_topic.chapter.name, :class=>\"chapter\"){\n # xml.content(:src=>content.sub_topic.chapter.assets.first.src)\n # xml.navPoint(:id=>content.sub_topic.topic.name, :class=>\"topic\"){\n # xml.content(:src=>content.sub_topic.topic.assets.first.src)\n # xml.navPoint(:id=>content.sub_topic.name, :class=>\"subtopic\"){\n # xml.content(:src=>content.sub_topic.assets.first.src)\n # xml.navPoint(:id=>content.uri.split('/').last, :displayName => content.name, :class=>File.extname(content.asset.attachment_file_name) == \".zip\" ? \"assessment-practice-tests\" :\"assessment-home-work\"){\n # if File.extname(content.asset.attachment_file_name) == \".zip\"\n # Dir.entries(Rails.root.to_s+\"/public\"+content.asset.src.gsub(content.asset.attachment_file_name,\"\")).sort.each do |d|\n # if File.extname(d) =='.etx'\n # @name = d\n # break\n # end\n # end\n # xml.content(:src=>content.asset.src.gsub(content.asset.attachment_file_name,\"\")+@name)\n # else\n # xml.content(:src=>content.asset.src)\n # end\n # }\n #\n #\n # }\n # }\n # }\n #end\n }\n }\n }\n }\n else\n xml.navPoint(:id=>\"Content\",:class=>\"content\"){\n xml.content(:src=>\"content\")\n xml.navPoint(:id=>content.subject.board.name,:class=>\"course\"){\n xml.content(:src=>content.subject.board.code+\"_\"+content.assets.first.publisher_id.to_s)\n xml.navPoint(:id=>content.subject.content_year.name,:class=>\"academic-class\"){\n xml.content(:src=>content.subject.content_year.code)\n\n # The code for handling the data if the subject has a subject as a parent\n if !content.subject.subject_id.nil?\n xml.navPoint(:id=>content.subject.parent_subject.name,:class=>\"subject\")\n xml.content(:src=>content.subject.parent_subject.code)\n end\n # End of code for handling the data if the subject has a subject as a parent\n\n xml.navPoint(:id=>content.subject.name,:class=>\"subject\"){\n xml.content(:src=>content.subject.code)\n case content.type when \"Chapter\"\n xml.navPoint(:id=>content.name,:class=>\"chapter\",:playOrder=>content.play_order.nil? ? 0 :content.play_order){\n xml.content(:src=>content.assets.first.src)\n }\n when \"Topic\"\n xml.navPoint(:id=>content.chapter.name,:class=>\"chapter\",:playOrder=>content.play_order.nil? ? 0 :content.play_order){\n xml.content(:src=>content.chapter.assets.first.src,:params=>content.chapter.params)\n xml.navPoint(:id=>content.name, :class=>\"topic\",:playOrder=>content.play_order.nil? ? 0 :content.play_order){\n xml.content(:src=>content.assets.first.src)\n }\n }\n when \"SubTopic\"\n xml.navPoint(:id=>content.chapter.name,:class=>\"chapter\",:playOrder=>content.play_order.nil? ? 0 :content.play_order){\n xml.content(:src=>content.chapter.assets.first.src,:params=>content.chapter.params)\n xml.navPoint(:id=>content.topic.name, :class=>\"topic\",:playOrder=>content.play_order.nil? ? 0 :content.play_order){\n xml.content(:src=>content.topic.assets.first.src,:params=>content.chapter.params)\n xml.navPoint(:id=>content.name, :class=>\"subtopic\",:playOrder=>content.play_order.nil? ? 0 :content.play_order){\n xml.content(:src=>content.assets.first.src)\n }\n }\n }\n end\n }\n }\n }\n }\n end\n }\n }\n end\n xml_string = @builder.to_xml.to_s\n file = File.new(path+\"/\"+\"index.ncx\", \"w+\")\n File.open(file,'w') do |f|\n f.write(xml_string.to_s.gsub( \"\\n\", \"\" ).gsub(/>[ ]*</,'><'))\n end\n create_zip(\"assessment_#{content.id}\",path)\n end", "def line=(_arg0); end", "def line\n @line ||= Line.get(@attrs['Line'])\n end", "def compiled_string_at(line_no)\n line_str = \"\"\n\n value_arr.each do |num|\n if dash_lines.keys.include?(line_no)\n line_str << dash_or_blank_fill(line_no, num)\n else\n line_str << bars(line_no, num)\n end\n\n line_str << \" \"\n end\n\n line_str\n end", "def assemble_xml_file # :nodoc:\n write_xml_declaration do\n # Write the c:chartSpace element.\n write_chart_space do\n # Write the c:lang element.\n write_lang\n # Write the c:style element.\n write_style\n # Write the c:protection element.\n write_protection\n # Write the c:chart element.\n write_chart\n # Write the c:spPr element for the chartarea formatting.\n write_sp_pr(@chartarea)\n # Write the c:printSettings element.\n write_print_settings if @embedded && @embedded != 0\n end\n end\n end", "def write_attribute_text(prefix, line)\n print prefix\n line.each do |achar|\n print achar.char\n end\n puts\n end", "def node_at(line, column); end", "def lex_en_line_comment; end", "def lex_en_line_comment; end", "def lex_en_line_comment; end", "def tagline; end", "def add_line_details(line_doc)\n id = parse_xml(line_doc/'id') if (line_doc/'id').first\n line = bank_transaction_lines.find_or_build(id) if line_doc.name == 'bank_transaction_line'\n if line\n line.apply_attributes(line_doc) \n line.fill_default_detail_values\n self.max_serial_no = line.serial_no = (self.max_serial_no.to_i + 1).to_s if line.new_record?\n end\n line\n end", "def to_xml_string(str = +'')\n str << <<~XML\n <xml xmlns:v=\"urn:schemas-microsoft-com:vml\"\n xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n xmlns:x=\"urn:schemas-microsoft-com:office:excel\">\n <o:shapelayout v:ext=\"edit\">\n <o:idmap v:ext=\"edit\" data=\"#{@comments.worksheet.index + 1}\"/>\n </o:shapelayout>\n <v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\"\n path=\"m0,0l0,21600,21600,21600,21600,0xe\">\n <v:stroke joinstyle=\"miter\"/>\n <v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/>\n </v:shapetype>\n XML\n @comments.each { |comment| comment.vml_shape.to_xml_string str }\n str << \"</xml>\"\n end", "def print_line\n @pdf.stroke_horizontal_line @pdf.bounds.left, @pdf.bounds.right\n end", "def build_xml(p_item)\r\n xml = \"<#{ELE_ITEM}>\\n\"\r\n unless p_item.id.nil?\r\n xml += \"\\t<#{ELE_ID}>#{p_item.id}</#{ELE_ID}>\\n\"\r\n end\r\n xml += \"\\t<#{ELE_TITLE}>#{p_item.title}</#{ELE_TITLE}>\\n\"\r\n xml += \"\\t<#{ELE_CREATED_ON}><![CDATA[#{format_date(p_item.created_on)}]]></#{ELE_CREATED_ON}>\\n\"\r\n xml += \"\\t<#{ELE_LAST_UPDATED_ON}><![CDATA[#{format_date(p_item.last_updated_on)}]]></#{ELE_LAST_UPDATED_ON}>\\n\"\r\n xml += \"\\t<#{ELE_FIELDS}>\\n\"\r\n p_item.get_fields.each do |name, value|\r\n xml += \"\\t\\t<#{ELE_FIELD} #{ATTR_NAME}='#{name}'><![CDATA[#{value}]]></#{ELE_FIELD}>\\n\"\r\n end\r\n xml += \"\\t</#{ELE_FIELDS}>\\n\"\r\n\r\n # add related items\r\n related_items = p_item.get_related_items\r\n unless related_items.nil? and related_items.empty?\r\n xml += \"<#{ELE_RELATED_ITEMS}>\\n\"\r\n related_items.each do |key, item_ids|\r\n xml += \"<#{key}>\\n\"\r\n item_ids.each do |item_id|\r\n xml += \"<#{ELE_ITEM}>\"\r\n xml += item_id.to_s\r\n xml += \"</#{ELE_ITEM}>\\n\"\r\n end\r\n xml += \"</#{key.to_s.downcase}>\\n\"\r\n end\r\n xml += \"</#{ELE_RELATED_ITEMS}>\\n\"\r\n end\r\n\r\n # set target class\r\n unless p_item.target_class.nil?\r\n xml += \"<#{ELE_TARGET_CLASS}>\"\r\n xml += p_item.target_class\r\n xml += \"</#{ELE_TARGET_CLASS}>\"\r\n end\r\n\r\n xml += \"</#{ELE_ITEM}>\\n\"\r\n end", "def parse_line_break; end", "def start_line\n attributes.fetch(:startLine)\n end", "def generate()\n\t\t\t@out = []\n\t\t\t@context = []\n\n\t\t\ttrim_nil_lines\n\n\t\t\[email protected]_with_index do |line, i|\n\t\t\t\twrite_with_context(line.line, line.context, next_context(i))\n\t\t\tend\n\t\t\twrite_with_context(nil, [], [])\n\t\t\treturn @out.join\n\t\tend", "def parse(header_file, to_file)\n includes = @includes.flatten.uniq.map {|i| \"-I#{i.chomp}\"}.join(\" \").chomp\n flags = @flags.flatten.join(\" \").chomp\n cmd = \"#{@exe} #{includes} #{flags} #{header_file} -fxml=#{to_file}\"\n raise \"Error executing gccxml command line: #{cmd}\" unless system(cmd)\n end", "def build_line(id)\n mailaddr = encode_mail(id)\n status = @stats[id]\n \"#{id},#{@names[id]},#{@passwords[id]},#{mailaddr},\" \\\n \"#{build_winlose(**status)}\"\n end", "def osmxml (ios)\n ios.write(\"<osm version=\\\"0.6\\\" >\\n\")\n @properties.each { |x| \n x.osmxml(ios) \n }\n ios.write(\"</osm>\\n\")\n end", "def create_line(num)\n '-' * num\nend", "def transaction_set_line_number(index)\n ['LX', index.to_s.rjust(4, '0')].join(@element_seperator)\n end", "def xml; end", "def add_line(line)\n @tip.string_content += line.slice(@offset, line.length) + '\\n'\n end", "def decoration(number, line_length)\n (\"=\" * number * (line_length+1)) << \"\\n\"\nend", "def source_line; end", "def line(number)\n end", "def line\n\t\t\[email protected](buffer.line.start, buffer.line.end)\n\t\tend", "def render(xm=Builder::XmlMarkup.new(:indent => 2))\n [:name, :visibility, :address].each do |a|\n xm.__send__(a, self.__send__(a)) unless self.__send__(a).nil?\n end\n \n xm.description { xm.cdata!(description) } unless description.nil?\n xm.open(self.open) unless open.nil?\n \n xm.phoneNumber(phone_number) unless phone_number.nil?\n xm.styleUrl(style_url) unless style_url.nil?\n \n unless address_details.nil?\n xm.AddressDetails(:xmlns => \"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\") { address_details.render(xm) } \n end\n \n xm.Snippet(snippet.text, snippet.max_lines) unless snippet.nil?\n \n xm.LookAt { look_at.render(xm) } unless look_at.nil?\n xm.TimePrimitive { time_primitive.render(xm) } unless time_primitive.nil?\n xm.StyleSelector { style_selector.render(xm) } unless style_selector.nil?\n end", "def line_code\n @attrs['Line']\n end", "def short_vertical_line\n html = <<-eol\n <div class=\"short-line-container\">\n <div class=\"fam-tree-marked-right\"></div>\n <div class=\"fam-tree-unmarked\"></div>\n </div>\n eol\n html.html_safe\n end", "def start_line_number=(_); end", "def gen_raw_line\n return nil unless self.valid?\n line = ''\n data = []\n SUB_STR_ATTRIBUTES.each do |field,field_regex|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n line = \"#{data.join ' ,'}\"\n end\n\n data = []\n BOOL_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \",#{data.join ','} \"\n end\n end\n\n data = []\n ARR_STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \", #{data.join ','} \"\n end\n end\n\n data = []\n STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n line += data.join ' '\n return line\n end", "def source_line=(_); end", "def render_line(range, ellipsis = T.unsafe(nil), range_end = T.unsafe(nil)); end", "def render_line(range, ellipsis = T.unsafe(nil), range_end = T.unsafe(nil)); end", "def render_line(range, ellipsis = T.unsafe(nil), range_end = T.unsafe(nil)); end", "def parse_line_break\n @tree.children << Element.new(:br, nil, nil, location: @src.current_line_number)\n @src.pos += @src.matched_size\n end", "def line=(_); end", "def line=(_); end", "def create_pathdrawelement(line_width: 16.0, stroke_color: nil)\n strokeColor = stroke_color unless stroke_color.nil?\n strokeColor = MIColor.make_rgbacolor(0.2, 0.2, 0.2) if stroke_color.nil?\n arcBox = MIShapes.make_rectangle(width: $theWidth, height: $theHeight)\n startX = $theWidth * 0.5 + $radius * Math.sin(-0.75 * Math::PI)\n startY = $theHeight * 0.5 + $radius * Math.cos(-0.75 * Math::PI)\n startPoint = MIShapes.make_point(startX, startY)\n arcBBox = MIShapes.make_rectangle(width: $theWidth, height: $theHeight)\n thePath = make_arcpath(inBox: arcBBox, radius: $radius)\n pathDrawElement = MIDrawElement.new(:strokepath)\n pathDrawElement.arrayofpathelements = thePath\n pathDrawElement.startpoint = startPoint\n pathDrawElement.linewidth = line_width\n pathDrawElement.linecap = :kCGLineCapRound\n pathDrawElement.strokecolor = strokeColor\n pathDrawElement\nend", "def print_placemark\n #Links are not processed\n# if @@last_type == Link then return end\n #An icon showing the start point and description\n ret = \"<Placemark>\"\n ret << \"<name>#{@@step.to_s.rjust(2,'0')}</name>\"\n ret << \"<description>\"\n #Different rendering for Streets and Triphops\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"#{@@init_time.strftime(\"%H:%M\")}. \"\n else\n ret << \"Departure: #{@@init_time.strftime(\"%H:%M\")}. \"\n ret << \"Arrival: #{@@end_time.strftime(\"%H:%M\")}. \"\n end\n# ret << payload.to_kml\n ret << @@last_name\n ret << \"</description>\"\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"<styleUrl>#walkIcon</styleUrl>\"\n else\n ret << \"<styleUrl>#busIcon</styleUrl>\"\n end\n ret << \"<Point>\"\n ret << \"<coordinates>\"\n ret << \"#{@@coords[0]}\"\n ret << \"</coordinates>\"\n ret << \"</Point>\"\n ret << \"</Placemark>\"\n\n #A polyline showing the path\n ret << \"<Placemark>\"\n ret << \"<name>\"\n# ret << payload.to_kml\n ret << @@last_name\n ret << \"</name>\"\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"<styleUrl>#walkPath</styleUrl>\"\n else\n ret << \"<styleUrl>#busPath</styleUrl>\"\n end\n ret << \"<LineString>\"\n ret << \"<coordinates>\"\n ret << \"#{@@coords.join(' ')}\"\n ret << \"</coordinates>\"\n ret << \"</LineString>\"\n ret << \"</Placemark>\"\n end", "def initialize\n\t@xml = '<?xml version=\"1.0\"?>\n<?misc:processingInstruction \"with arguments\"?>\n<?other:piNoArgs ?>\n<!DOCTYPE outer PUBLIC \"public id\" \"foobar\" [\n <!ENTITY foo \"bletch\">\n <!ELEMENT el>\n <!ATTLIST el EMPTY>\n <!NOTATION notation ignored>\n]>\n<!-- comment -->\n<outer>\n data&amp;&foo;\nmore on next line<simpleTag>text</simpleTag>\n<inner:tag a=\"tabs\tto\tspaces&foo;\"/><![CDATA[xx<z&xx</\nnewline in cdata\n]]>\n<p>text <b>bold café coffee</b> more text</p>\n</outer>'\n\n\temptyAttrs = Hash.new()\n\t@newlineTok = NQXML::Text.new(\"\\n\")\n\n\tattrs = Hash.new()\n\tattrs['version'] = '1.0'\n\t@xmlDecl = NQXML::XMLDecl.new('xml', attrs, '<?xml version=\"1.0\"?>')\n\n\tsrc = '<?misc:processingInstruction \"with arguments\"?>'\n\t@piWithArgs =\n\t NQXML::ProcessingInstruction.new('misc:processingInstruction',\n\t\t\t\t\t '\"with arguments\"', src)\n\n\t@piNoArgs = NQXML::ProcessingInstruction.new('other:piNoArgs', '',\n\t\t\t\t\t\t '<?other:piNoArgs ?>')\n\n\t@entityTag =\n\t NQXML::GeneralEntityTag.new('foo', 'bletch', nil, nil,\n\t\t\t\t\t'<!ENTITY foo \"bletch\">')\n\t@element = NQXML::Element.new('el', '', '<!ELEMENT el>')\n\t@attlist = NQXML::Attlist.new('el', 'EMPTY', '<!ATTLIST el EMPTY>')\n\t@notation = NQXML::Notation.new('notation', 'ignored',\n\t\t\t\t\t'<!NOTATION notation ignored>')\n\t@doctypePubid =\n\t NQXML::PublicExternalID.new('\"public id\"', '\"foobar\"',\n\t\t\t\t\t'PUBLIC \"public id\" \"foobar\"')\n\t@doctype =\n\t NQXML::Doctype.new('outer', @doctypePubid,\n\t\t\t [@entityTag, @element, @attlist, @notation],\n\t\t\t \"<!DOCTYPE outer PUBLIC \\\"public id\\\" \\\"foobar\\\" [\\n\" +\n\t\t\t \" <!ENTITY foo \\\"bletch\\\">\\n\" +\n\t\t\t \" <!ELEMENT el>\\n\" +\n\t\t\t \" <!ATTLIST el EMPTY>\\n\" +\n\t\t\t \" <!NOTATION notation ignored>\\n\" +\n\t\t\t \"]>\")\n\n\t@comment = NQXML::Comment.new('<!-- comment -->')\n\t@outerStart = NQXML::Tag.new('outer', emptyAttrs, false, '<outer>')\n\t@textDataWithSub = NQXML::Text.new(\"\\n data&bletch\\nmore on next line\")\n\t@simpleTagStart = NQXML::Tag.new('simpleTag', emptyAttrs, false,\n\t\t\t\t\t '<simpleTag>')\n\t@simpleTextData = NQXML::Text.new('text')\n\t@simpleTagEnd = NQXML::Tag.new('simpleTag', nil, true, '</simpleTag>')\n\n\tattrs = Hash.new()\n\tattrs['a'] = 'tabs to spacesbletch'\n\t@innerTagStart = NQXML::Tag.new('inner:tag', attrs, false,\n\t\t\t\t\t'<inner:tag a=\"tabs\tto\tspaces&foo;\"/>')\n\n\t@innerTagEnd = NQXML::Tag.new('inner:tag', nil, true,\n\t\t\t\t\t'<inner:tag a=\"tabs\tto\tspaces&foo;\"/>')\n\t@pTagStart = NQXML::Tag.new('p', emptyAttrs, false, '<p>')\n\t@pTagEnd = NQXML::Tag.new('p', nil, true, '</p>')\n\t@bTagStart = NQXML::Tag.new('b', emptyAttrs, false, '<b>')\n\t@bTagEnd = NQXML::Tag.new('b', nil, true, '</b>')\n\t@textText = NQXML::Text.new('text ')\n\t@boldText = NQXML::Text.new('bold café coffee')\n\t@moreTextText = NQXML::Text.new(' more text')\n\n\t@cdata = NQXML::Text.new(\"xx<z&xx</\\nnewline in cdata\\n\",\n\t\t\t\t \"<![CDATA[xx<z&xx</\\nnewline in cdata\\n]]>\")\n\t@outerEnd = NQXML::Tag.new('outer', nil, true, '</outer>')\n\n\t@sub1_xml = '<?xml version=\"1.0\"?>\n<!DOCTYPE outer SYSTEM \"foobar\" [\n <!ENTITY example \"<p>An ampersand (&#38;#38;) may be escaped numerically (&#38;#38;#38;) or with a general entity (&amp;amp;).</p>\" >\n]>\n'\n\tsrc = '<!ENTITY example \"<p>An ampersand (&#38;#38;) may be' +\n\t ' escaped numerically (&#38;#38;#38;) or with a general entity' +\n\t ' (&amp;amp;).</p> >'\n\tval = \"<p>An ampersand (&#38;) may be escaped numerically\" +\n\t \" (&#38;#38;) or with a general entity (&amp;amp;).</p>\"\n\t@sub1Entity = NQXML::GeneralEntityTag.new('example', val, nil, nil,\n\t\t\t\t\t\t src)\n\t\t\t\t\t\t\n\t@sub2_xml = '<?xml version=\"1.0\"?>\n<!DOCTYPE test [\n<!ELEMENT test (#PCDATA) >\n<!ENTITY % xx \\'&#37;zz;\\'>\n<!ENTITY % zz \\'&#60;!ENTITY tricky \"error-prone\" >\\' >\n%xx;\n]>\n<test>This sample shows a &tricky; method.</test>\n'\n\t@xxEntity =\n\t NQXML::ParameterEntityTag.new('xx', '%zz;', nil,\n\t\t\t\t\t '<!ENTITY % zz \\'&#37;zz;\\'>')\n\n\tsrc = '<!ENTITY % zz \\'&#60;!ENTITY tricky \"error-prone\" >\\' >'\n\tval = '<!ENTITY tricky \"error-prone\" >'\n\t@zzEntity = NQXML::ParameterEntityTag.new('zz', val, nil, src)\n end", "def compile_line(aRawLine)\n line_rep = aRawLine.map { |couple| compile_couple(couple) }\n \n # Apply the rule: when a line just consist of spaces \n # and a section element, then remove all the spaces from that line.\n line_to_squeeze = line_rep.all? do |item|\n if item.kind_of?(StaticText)\n item.source =~ /\\s+/\n else\n false\n end\n end\n line_rep_ending(line_rep) unless line_to_squeeze\n \n return line_rep\n end", "def line_for_position(position); end" ]
[ "0.6535489", "0.6103469", "0.5983788", "0.5969462", "0.5962474", "0.5828589", "0.55920625", "0.5582747", "0.54876465", "0.54665154", "0.54589987", "0.54263324", "0.5389798", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.5347669", "0.53423715", "0.5320288", "0.52944493", "0.52899575", "0.5266427", "0.5241157", "0.5227907", "0.52077895", "0.5194317", "0.5194317", "0.51772714", "0.51649547", "0.5155718", "0.513614", "0.51267666", "0.5124097", "0.5111904", "0.51006556", "0.5098884", "0.50784516", "0.5071944", "0.5067463", "0.505511", "0.5028344", "0.5027553", "0.50121784", "0.50010073", "0.5000365", "0.4988131", "0.4978435", "0.49759623", "0.49686575", "0.49609393", "0.49569455", "0.49569455", "0.49569455", "0.49490246", "0.49437723", "0.49330434", "0.49205565", "0.49179426", "0.4916007", "0.49008107", "0.48767608", "0.48723587", "0.4871113", "0.48700935", "0.48691383", "0.4863622", "0.48624438", "0.48582876", "0.4852604", "0.4850829", "0.48480546", "0.48453254", "0.4835751", "0.4831477", "0.48313332", "0.4826816", "0.4825971", "0.48240408", "0.4821348", "0.4821348", "0.4821348", "0.48173845", "0.4810344", "0.4810344", "0.48100325", "0.48067343", "0.4805036", "0.48032135", "0.48023242" ]
0.6235582
1
Get the current path
def current_path File.expand_path(File.join(__FILE__,"../")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_path\n current_folder.path\n end", "def get_current_path\n decompress_value(session['app.current_path']).tap do |path|\n session.delete('app.current_path') if path.blank?\n end\n end", "def current\n\t\t\t\t\treturn Pathname.new(\".\")\n\t\t\t\tend", "def current path=nil\n current = `pwd`.strip + \"/\"\n if path\n current + path \n else\n current\n end\nend", "def current_file_path\n current_file.to_path\n end", "def current_path\n @current_path ||= @deploy_to + '/current'\n end", "def current_dir; end", "def current_directory\n File.expand_path @current_directory\n end", "def current_dir\n File.dirname(file_path)\n end", "def current_path\n current_url = page.current_url\n url_match = URL_REGEX.match(current_url)\n return url_match[4] if url_match\n\n # Special case: prepend a slash to the path to force a valid URL for things like\n # \"about:srcdoc\" iframe srcdoc pages.\n current_url = \"/#{current_url}\" if current_url[0] != '/'\n\n current_url\n end", "def current_path\n file.try(:path)\n end", "def current_path\n URI.parse(current_url).path\nend", "def base_path\n Dir.pwd + \"/\"\n end", "def current_file\n @path || @parent.current_file rescue nil\n end", "def current_path\n ::File.join(install_path, artifact_name, 'current')\n end", "def path\n `window.location.pathname`\n end", "def path\n application? ? application_path : local_path\n end", "def current_path\n return nil if current_url.nil?\n return current_url.gsub(\"http://www.example.com\",\"\")\n end", "def base_path\n @base_path ||= Dir.pwd\n end", "def path\n @base\n end", "def set_current_path; end", "def cwd\n return cd(\"\").to_s\n end", "def working_dir\n ENV['PWD'] || Dir.pwd\n end", "def current_file_path\n clurl = AssetSettings[:local_assets][@file_id].last\n clurl.sub(/\\A#{AssetSettings[:local_assets].assets_url_prefix}/,\n '') if clurl\n end", "def root\n Dir.pwd\n end", "def current_working_directory; @rye_current_working_directory; end", "def root; Pathname(__dir__).parent; end", "def path\n location.path\n end", "def path\n real_path = Pathname.new(root).realpath.to_s\n full_path.sub(%r{^#{real_path}/}, '')\n end", "def this_dir\n File.expand_path(File.dirname(caller_file(caller)))\n end", "def this_file_path\n Pathname.new( __FILE__ ).expand_path\n end", "def integration_cwd\n root.to_s\n end", "def path\n current_localization.path\n end", "def getwd\n Dir.getwd\n end", "def path\n return @path\n end", "def path\n return @path\n end", "def path\n return @path\n end", "def base_path\n @base_path ||= server_path(File.expand_path(Dir.pwd))\n end", "def dir\n @working_directory\n end", "def curr_srcdir\n \"#{srcdir_root()}/#{relpath()}\"\n end", "def pwd\n Dir.pwd\n end", "def path\n return @path\n end", "def current_folder\n tree.terminal\n end", "def path\n @pathname.to_s\n end", "def linked_path\n File.readlink current_directory\n end", "def curr_srcdir\n \"#{srcdir_root()}/#{relpath()}\"\n end", "def curr_srcdir\n \"#{srcdir_root()}/#{relpath()}\"\n end", "def current_texte_path\n config = File.open('./.config.msh','rb'){|f|Marshal.load(f)}\n config[:last_file_path]\n end", "def current_path\n url_for(params)\n end", "def path\n @global_page.path\n end", "def get_path(path)\n return '' if path.blank?\n return path if path[0] == '/'\n Rails.root.to_s + '/' + path\n end", "def root\n Pathname.new(File.dirname(__dir__))\n end", "def root\n File.dirname __dir__\n end", "def get_base_path()\n return TembooSession.get_base_path + \"/choreos\"\n end", "def path\r\n @pathname.to_s\r\n end", "def active_path\n if script = script_object()\n if path = script.path\n return path.dup\n end\n end\n\n # If for some reason that didn't work, return the compile time filename.\n method.file.to_s\n end", "def current_url\n evaluate(\"window.top.location.href\")\n end", "def root\n File.dirname __dir__\n end", "def root\n File.dirname __dir__\n end", "def cwd\n Dir.getwd\n end", "def load_path\n paths, file = [\"\"], current_file\n paths << File.dirname(file) if file\n paths + LOAD_PATH\n end", "def path\n\t\trequest.original_fullpath\n\tend", "def path\n request.path\n end", "def path\n @path ||= @project.dir.path\n end", "def current_url\n request.env['REQUEST_URI']\n end", "def path()\n return ::File.join(@root, @name)\n end", "def base_path\n @base_path || self.class.base_path\n end", "def path()\n\t\t\t\t@basePath + \"/\" + hierarchy().join( \"/\" )\n\t\t\tend", "def my_path\n File.expand_path(File.dirname(__FILE__))\n end", "def base_path\n self.class.base_path\n end", "def path\n parse_request! if @path.nil?\n @path\n end", "def local_path\n @io.local_path\n end", "def path\n env[PATH] ||= (env.has_key?(GIT) ? env[GIT].path : Dir.pwd)\n end", "def set_current_path(path)\n @current_path = path\nend", "def workspace_folder\n @pwd\n end", "def root_path\n @root_path ||= `git rev-parse --show-toplevel`.chomp\n end", "def path\n # FIXME: Do this without exception!\n #\"#{ @parent.path unless @parent == self }##{ ident }\"\n # rescue base path\n \"#{@parent.path rescue ''}##{ident}\"\n end", "def dir\n File.dirname(__FILE__)\n end", "def get_current_url\n remove_context_path(@current_url)\n end", "def path(ident=:default)\n tail = identifying_path_part(ident)\n if tail.empty?\n base_path\n else\n File.join base_path, tail\n end\n end", "def root\n File.dirname(__FILE__)\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n return get_path self\n end", "def work\n '/' + File.dirname(file)\n end", "def current_pstore_path\n return nil if current_pstore.nil?\n @current_pstore_path ||= begin\n current_pstore.nil? ? nil : File.join(app.folder_pstore, current_pstore)\n end\n end", "def pwd\n @local\n end", "def locate\r\n File.dirname(__FILE__)\r\n end", "def locate\r\n File.dirname(__FILE__)\r\n end", "def getRoot\n @path[0]\n end", "def getPath()\n return @uri.path\n end", "def get_path_root\n return self if @path.nil?\n @path.get_path_root\n end", "def path\n location.nil? ? nil : location.path\n end", "def get_root\n return File.join('/root/path', SETTINGS[:project])\n end", "def path\n @path ||= \n (@path_proc && @path_proc.call(self)) || \n default_path\n end", "def path\n File.join(@base, @name)\n end", "def cwd\n @cwd ||= begin\n exec! 'pwd'\n rescue => e\n raise e\n '/'\n end\n end", "def parent_dir path\r\n\t(File.basename File.dirname path).gsub(/\\s+/, ' ').strip\r\nend" ]
[ "0.8477773", "0.8474798", "0.8282554", "0.8233582", "0.8005608", "0.8002216", "0.7988916", "0.7974565", "0.7925812", "0.78865093", "0.7722694", "0.7659557", "0.7651106", "0.7559208", "0.7547554", "0.75152457", "0.7393415", "0.7378526", "0.7376576", "0.726565", "0.7188195", "0.7183612", "0.71565396", "0.7154114", "0.7131079", "0.71247774", "0.7023885", "0.69904804", "0.69901025", "0.6972751", "0.69665384", "0.69639575", "0.6953221", "0.6918639", "0.6900477", "0.6900477", "0.6900477", "0.6895881", "0.68843186", "0.6868859", "0.6866514", "0.686383", "0.68634653", "0.68548596", "0.6850842", "0.68255985", "0.68255985", "0.68242896", "0.68182075", "0.6811816", "0.68007034", "0.6794534", "0.6783509", "0.6782969", "0.67811984", "0.67750984", "0.6767559", "0.675196", "0.675196", "0.675142", "0.6748656", "0.67434293", "0.67327535", "0.6732343", "0.6730045", "0.67258966", "0.6717662", "0.6712996", "0.67004406", "0.66941386", "0.6665027", "0.6663032", "0.66544026", "0.6652315", "0.6651412", "0.66297895", "0.6627276", "0.66179854", "0.65967834", "0.659284", "0.65870714", "0.65851843", "0.65851843", "0.65851843", "0.65851843", "0.6579447", "0.6562085", "0.65584415", "0.65563536", "0.65526897", "0.65526897", "0.6543492", "0.6539122", "0.6538279", "0.6530672", "0.65275055", "0.65257657", "0.6513252", "0.65099025", "0.6504879" ]
0.79835343
7
rerender and cache this template/key combination for each language
def refresh(template_name,key,args={},&prerender_block) # @logger.debug("\trender_base.refresh(#{template_name},#{key})") if @logger result={} @languages.each do |language| result[language] = refresh_one_language(template_name,language,key,args,&prerender_block) end return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh_one_language(template_name,language,key,args={},&prerender_block)\n # @logger.debug(\"\\t\\trender_base.refresh_one_language(#{template_name},#{language},#{key})\") if @logger\n\n renderer=get_renderer(template_name)\n key ||= renderer.get_key(args)\n rendered=renderer.render(language,args,{:render_mode => :refresh},&prerender_block)\n put_page_into_s3(language,key,rendered)\n return rendered\n end", "def _template_cache\n @cache ||= {}\n end", "def template_cache_key\n context[:template_cache_key]\n end", "def reload\n @@languages.each do |lang_code, lang_file|\n lang_file.reload\n end\n end", "def update_template(key, value)\n t = { key => value }\n raw = read_attribute(\"template\") \n d = raw.nil? ? {} : JSON.parse(raw) \n merged = d.deep_merge(t)\n self.template = JSON.generate(merged)\n self.save!\n end", "def load_cache(language)\n\n\t\t\t\t\t\t# Initialize cache structures\n\t\t\t\t\t\tif @o2t.nil?\n\t\t\t\t\t\t\t@o2t = {}\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif @t2o.nil?\n\t\t\t\t\t\t\t@t2o = {}\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Fill cache if empty\n\t\t\t\t\t\tif @o2t[language.to_sym].nil? || @t2o[language.to_sym].nil?\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t@o2t[language.to_sym] = {}\n\t\t\t\t\t\t\t@t2o[language.to_sym] = {}\n\n\t\t\t\t\t\t\tdata = where(slug_language: language.to_s)\n\t\t\t\t\t\t\tdata.each do |item|\n\t\t\t\t\t\t\t\t@o2t[language.to_sym][item.original] = item.translation\n\t\t\t\t\t\t\t\t@t2o[language.to_sym][item.translation] = item.original\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend", "def prep_template(language,frame_binding)\n\n template=@localized_templates[language]\n @language=language\n eval(\"@language='#{language}'\",frame_binding)\n \n unless template\n local_template_text=@raw_template.result(frame_binding)\n local_template_text=local_template_text.gsub(@ltag,\"<%\")\n local_template_text=local_template_text.gsub(@rtag,\"%>\")\n\n template=compile(local_template_text)\n @localized_templates[language]=template unless is_development?\n end\n template\n \n end", "def raw_template=(content)\n @source ||= {}\n @source[Locomotive::Mounter.locale] = content\n end", "def clear_cache_i18n\n Rails.cache.delete_matched 'views/i18n/*'\n end", "def source\n @source ||= {}\n @source[Locomotive::Mounter.locale] ||= self.template.need_for_prerendering? ? self.template.render : self.template.data\n end", "def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\n end", "def generate_with_cache(checksums)\n changed_files = []\n Registry.checksums.each do |file, hash|\n changed_files << file if checksums[file] != hash\n end\n Registry.load_all\n all_objects.each do |object|\n if object.files.any? {|f, line| changed_files.include?(f) }\n log.info \"Re-generating object #{object.path}...\"\n opts = options.merge(:object => object, :type => :layout)\n Templates::Engine.render(opts)\n end\n end\n end", "def expire_caches_for(record)\n key = \"/ajax/tags/#{record.class.name.downcase.pluralize}\"\n\n I18n.available_locales.each do |locale|\n expire_fragment(\"#{locale}#{key}\")\n expire_fragment(\"#{locale}#{key}.json\")\n end\n end", "def read_or_render(template_name,language,key,render_args={},&prerender_block)\n # @logger.debug(\"render_base.read_or_render(#{template_name},#{language},#{key})\") if @logger\n #check cache\n\n renderer=nil\n unless key\n #try to generate the key\n renderer ||= get_renderer(template_name)\n\n key=renderer.get_key( render_args)\n end\n if key\n result=peek(language,key)\n end\n unless result\n\n template_name,key,render_args = process_prerender_block(\n template_name,\n key,\n render_args,\n &prerender_block)\n \n renderer ||= get_renderer(template_name)\n result=renderer.render(language,render_args,{})\n put_page_into_s3(language,key,result)\n else\n # @logger.debug(\"got it from cache\") if @logger\n\n end\n return result\n end", "def expire_cache_for(list)\n key = \"/ajax/lists/#{list.id}\"\n\n I18n.available_locales.each do |locale|\n expire_fragment(\"#{locale}#{key}/edit\")\n expire_fragment(\"#{locale}#{key}/copy\")\n end\n end", "def for path, namespaces = nil\n @semaphore.synchronize do\n if @cache.has_key?(path)\n @cache[path]\n else\n @cache[path] = if namespaces\n for_node @template.at(canonicalize(path), namespaces)\n else\n for_node @template.at(canonicalize(path))\n end\n end\n end\n end", "def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end", "def redis_key\n return \"rlt:#{@template_name}\"\n end", "def cache_removal_key\n study_name = self.study.url_safe_name\n case self.file_type\n when 'Cluster'\n name_key = self.cluster_groups.first.name.split.join('-')\n @cache_key = \"#{study_name}.*render_cluster.*#{name_key}\"\n when 'Coordinate Labels'\n name_key = self.coordinate_labels_target.name.split.join('-')\n @cache_key = \"#{study_name}.*render_cluster.*#{name_key}\"\n when 'Expression Matrix'\n @cache_key = \"#{study_name}.*expression\"\n when 'MM Coordinate Matrix'\n @cache_key = \"#{study_name}.*expression\"\n when /10X.*File/\n @cache_key = \"#{study_name}.*expression\"\n when 'Gene List'\n name_key = self.precomputed_scores.first.name.split.join('-')\n @cache_key = \"#{study_name}.*#{name_key}\"\n when 'Metadata'\n # when reparsing metadata, almost all caches now become invalid so we just clear all matching the study\n @cache_key = \"#{study_name}\"\n else\n @cache_key = nil\n end\n @cache_key\n end", "def templates\n GitWiki.template_cache ||= Dir[\"#{ settings.views[0] }/*.liquid\"].map do |f|\n name = File.basename(f, '.liquid')\n {\n \"name\" => name,\n \"examples\" => Page.get_template(name).examples\n }\n end\n end", "def cached_translations_for_language(language)\n translations = Tr8n::Config.current_source.valid_translations_for_key_and_language(self.key, language)\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end", "def reload_dictionary\n if @short_refresh\n load_dictionary if needs_refresh?\n else\n load_dictionary\n end\n end", "def cached_translations_for_language(language)\n if Tr8n::RequestContext.current_source\n translations = Tr8n::RequestContext.current_source.valid_translations_for_key_and_language(self.key, language)\n end\n\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end", "def operate_switch_language(code)\n #callback(:before_switch_language)\n @translation_cache = {} if @translation_cache.nil?\n facet_names = self.class.globalize_facets\n @translation_cache[language_code] = @attributes.dup.delete_if {|key, value| !facet_names.include? key.to_sym}\n Locale.switch(code) do\n set_original_language\n if @translation_cache.include? code\n @attributes.update @translation_cache[code]\n elsif @original_language == Locale.base_language and !@new_record\n reload\n elsif !@new_record\n trs = ModelTranslation.find(:all, \n :conditions => [ \"table_name = ? AND item_id = ? AND language_id = ? AND \" +\n \"facet IN (#{[ '?' ] * facet_names.size * ', '})\", self.class.table_name,\n self.id, @original_language.id ] + facet_names.map {|facet| facet.to_s} )\n trs ||= []\n trs.each do |tr|\n attr = tr.text || base[tr.facet.to_s]\n write_attribute( tr.facet, attr )\n end\n end\n \n operate_switch_language_on_associations(code)\n \n #callback(:after_switch_language)\n end\n end", "def build_model_i18n_js_cache(user)\n set_app_def() unless Cache[:app]\n\n model_i18n = {}\n Cache[:app][:model_list].each do |model|\n model_i18n[model] = get_model_i18n(model, user)\n end\n\n cache_str = 'R8.Model.i18n=' + JSON.pretty_generate(model_i18n) + ';'\n cache_file_name = \"#{R8::Config[:js_file_write_path]}/model.i18n.cache.js\"\n File.open(cache_file_name, 'w') { |fhandle| fhandle.write(cache_str) }\n end", "def initialize(template_text,options={})\n @renderer_extension_modules=[]\n\n @name=options[:template_name]\n @templates_root_dir= options[:templates_directory]# || \"#{::Rails.root.to_s}/app/views\"\n\n @output_buffer=\"\"\n #unique tag for escaping post and pre processing tags\n @ltag=\"!@@@##$$1212\"\n @rtag=\"!723465hjf3!@#\"\n\n @default_language=options[:default_language] || \"en\"\n\n\n @escape_tags= options[:tags_to_escape] || []\n @runtime_tags= options[:runtime_tags] || []\n\n\n #escape blocks that will be run at view time\n @template_text=template_text.clone\n @escape_tags.each do |etag|\n escape_tag_content( etag,@template_text)\n\n \n end\n\n# raise \"need templates directory\" unless options[:templates_directory]\n\n #escape all normal dynamic blocks for preprocessing\n @template_text=@template_text.gsub(\"<%\",@ltag).gsub(\"%>\",@rtag).gsub(\"<$\",\"<%\").gsub(\"$>\",\"%>\")\n \n #turn the setup block into a proc <## ##> into executable blocks\n @template_text=@template_text.gsub(\"<##\",\"<% set_setup_proc{ \").gsub(\"##>\",\"} %>\")\n\n #turn the key block into a proc <## ##> into executable blocks\n @template_text=@template_text.gsub(\"<!!KEY\",\"<% set_key_proc{ \").gsub(\"!!KEY>\",\"} %>\")\n\n\n @raw_template=compile(@template_text)\n #this hold variations of the template after it has been localized\n #into different languages, but before rendering\n @localized_templates={}\n @setup_proc=nil\n @key_proc=nil\n @render_base=options[:render_base]\n @template_name=options[:template_name]\n #this tag will be used to create non cachable dynamic blocks\n\n\n if options.has_key?(:helpers) && options[:helpers]!=nil\n options[:helpers].each do |helper|\n include helper\n end\n end\n \n end", "def caching_compile(action, template)\n if Global.compile && action.template\n Cache.compiled[action.relaxed_hash] ||= compile(action, template)\n else\n compile(action, template)\n end\n end", "def clear_cached_vars\n @_rendered , @_versions = false , false\n end", "def add_key i18n_prj, input, select_from_translations\n v, quote = input.unquote\n\n if select_from_translations\n items = i18n_prj.potential_i18n_keys v\n if items.empty?\n TextMate::UI.tool_tip \"Can not find tranlation key\"\n else\n k = TextMate::UI.request_item \\\n :title => \"Select Translation Key\",\n :prompt => 'Select Translation Key',\n :items => items\n if !k\n TextMate::UI.tool_tip \"Canceled\"\n end\n end\n return input if !k\n else # new translation if needed\n v.gsub! '.', ''\n k = v[0..0].downcase + v[1..-1].underscore\n full_k = \"#{i18n_prj.key_prefix}.#{k}\"\n if i18n_prj.no_translation(full_k)\n new_k = TextMate::UI.request_string \\\n :default => full_k,\n :title => \"New Translation Key\"\n return input if new_k.nil? or new_k.empty?\n if new_k != full_k\n full_k = new_k\n k = new_k\n else\n k = '.' + k\n end\n insert_translation i18n_prj.en_yml_path, full_k, v\n else\n TextMate::UI.tool_tip \"Translation key '#{full_k}' exists\"\n k = '.' + k\n end\n end\n\n # snippet\n file_type = i18n_prj.file_type\n if quote or file_type == 'rb'\n %Q|t(#{k.inspect})|\n else\n case file_type\n when 'slim'; quote ? %Q|t(#{k.inspect})| : %Q|= t(#{k.inspect})|\n when 'haml'; quote ? %Q|t(#{k.inspect})| : %Q|= t(#{k.inspect})|\n else %Q|<%= t #{k.inspect} %>|\n end\n end\nend", "def update_translation( key, value, locale )\n \n # lock file\n filename = File::join RAILS_ROOT, \"config/locales\", File::basename( locale + \".yml\" )\n if( File.exists? filename )\n file = File.new( filename, \"r+\")\n else\n file = File.new( filename, \"w+\" ) \n end\n \n file.flock( File::LOCK_EX )\n \n begin \n # read project locale file\n data = YAML.load( file )\n unless data.is_a? Hash \n I18n.load_path << filename\n data = { locale => {} } unless data \n end\n \n tmp = data\n \n # create middle hash keys as needed\n key = locale + \".\" + key\n keys = key.split(/\\./)\n base_key = keys.pop\n \n while tmpkey = keys.shift\n unless tmp[tmpkey].class == Hash\n tmp[tmpkey] = {}\n end\n tmp = tmp[tmpkey]\n end\n \n # update or create value\n tmp[base_key] = value\n \n # save file\n file.truncate( 0 )\n file.rewind\n file.write( data.to_yaml )\n ensure\n # unlock and close file\n file.flock( File::LOCK_UN )\n file.close\n end\n \n I18n.reload!\n \n end", "def store_template_to_local_cache( template_body, ttl = self.local_cache_ttl )\n @@cache ||= {}\n \n expiration = Time.now.to_i + ttl\n Rails.logger.debug( \"Caching template locally for #{ttl.inspect} seconds; will expire at #{expiration}\" )\n @@cache[@template_name] = { :template => template_body,\n :expiration => expiration }\n\n return template_body\n end", "def key_template\n @key_template ||= [*name.downcase.split(\"::\"), \"%<id>d\"].join(\":\")\n end", "def resource_cache(resource_key)\n data[resource_key] ||= Dictionary.new\n end", "def template_map\n \n end", "def _cache_key(*keys)\n # monkey patch to avoid SystemStackError: stack level too deep \n if keys.to_s.include?(\"i18n_transliterate_rule\")\n keys.to_s\n else\n keys.map(&:to_s).join(\" \").parameterize.underscore \n end \n end", "def prepare_translations!\r\n stash.each do |locale, attrs|\r\n if attrs.any?\r\n translation = record.translations.find_by_locale(locale)\r\n translation ||= record.translations.build(:locale => locale)\r\n attrs.each{ |name, value| translation[name] = value }\r\n end\r\n end\r\n reset\r\n end", "def perform_template_load\n memoize(:template) do\n self.data[:template] = api.stack_template_load(self)\n true\n end\n end", "def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end", "def t_hash(key)\n translations = {}\n %i[en fr].each do |locale|\n translations[locale] = I18n.t(key, locale: locale, default: key.to_s.titleize)\n end\n translations\n end", "def fill_defaults\n self.suid = Dictionary.next_suid\n dictionary_descriptions.destroy_all\n Language.all.each do |language|\n dictionary_descriptions.build(lang: language.code3)\n end\n end", "def ct(key, language = nil)\n language = language || I18n.locale\n r = {flag: false, key: key, translation: \"\", locale: language.to_sym}\n hooks_run(\"on_translation\", r)\n return r[:translation] if r[:flag]\n translate(\"common.#{key}\", locale: language)\n end", "def combined_fragment_cache_key(key); end", "def write_to_file keys\n init_translations_and_ignore_app_mode_file_dump if self.class.mode == :origin\n # Hash to capture the files updated on origin mode and the keys for each one\n result = {}\n keys.each do |key, value|\n #\n # Search the files where the translation will be applied to\n decide_filenames(key).each do |filename| \n (result[filename] ||= []) << key\n # Apply the current translation to the filenames\n #\n # It will save a key 'ubiquo.categories.index.title' with a value 'Title'\n # mergin the content of $filename with it\n #\n # Load the file\n hash = YAML.load_file(filename)\n # Morph the translation key\n # from: 'ubiquo.categories.index.title'\n # to: { :ubiquo => {\n # :categories => {\n # :index => {\n # :title => 'Title'\n # }\n # }\n # }\n # }\n # }\n branch_hash = Translate::Keys.to_deep_hash({key => value})\n #\n # Cast all the hash keys to String\n #\n branch_hash = Translate::File.deep_stringify_keys({self.locale => branch_hash})\n #\n # Merge the translation with the content of the file\n #\n #\n hash.deep_merge!(branch_hash)\n #\n # Save to file updated to disk\n Translate::File.new(filename).write(hash)\n end \n end\n result\n end", "def reload\n self.class.get(key)\n end", "def reload\n self.class.get(key)\n end", "def update_cache\r\n Rails.cache.delete(\"All#{self.class.name.to_s}\")\r\n end", "def set_stale\n return unless locale == I18n.default_locale.to_s\n\n Translation.where(:key => key).where(Translation.arel_table[:locale].not_eq(locale)).update_all({:stale => true})\n end", "def reload!\n @initialized = false\n @translations = nil\n super\n end", "def translator_for(t_key, template = nil, parameters = nil)\n o_translator = translators[t_key]\n if template\n translator = Translator.new(template,\n :parameters => parameters)\n if o_translator\n o_translator.flagged.each do |i|\n translator.flag_ref(i)\n end\n end\n translators[t_key] = translator\n o_translator = translator\n else\n unless o_translator\n o_translator = Translator.new({},\n :parameters => {})\n end\n end\n o_translator\n end", "def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end", "def translate_pattern(key, language = :en)\n case key\n when :search\n language.eql?(:sv) ? 'Du sökte efter %%searchphrase%% %%page%% %%sep%% %%sitename%%' : 'You searched for %%searchphrase%% %%page%% %%sep%% %%sitename%%'\n when :not_found\n language.eql?(:sv) ? 'Sidan kunde inte hittas %%sep%% %%sitename%%' : 'Page Not Found %%sep%% %%sitename%%'\n when :author\n language.eql?(:sv) ? '%%name%%, Författare %%sitename%% %%page%%' : '%%name%%, Author at %%sitename%% %%page%%'\n when :term\n language.eql?(:sv) ? '%%term_title%% Arkiv %%page%% %%sep%% %%sitename%%' : '%%term_title%% Archives %%page%% %%sep%% %%sitename%%'\n end\n end", "def cache_collect\n\t\tRepository.repo.get_from_cache(@template)\n\tend", "def render_batch(languages,argsx={},callback_options={})\n clear\n result={}\n \n frame_binding= create_binding(argsx,callback_options)\n languages.each do |language|\n template=prep_template(language,frame_binding)\n apply_view_setup(frame_binding)\n result[language]= render_impl(template,language,frame_binding)\n end\n result\n end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache(key)\n @lock.synchronize do\n @contents[key] ||= yield\n end\n end", "def cache_key(package)\n stock_location = package.stock_location.nil? ? \"\" : \"#{package.stock_location.id}\"\n ship_address = package.order.ship_address\n contents_hash = Digest::MD5.hexdigest(package.contents.map {|content_item| content_item.variant.id.to_s + \"_\" + content_item.quantity.to_s }.join(\"|\"))\n @cache_key = \"Spree::Calculator::Shipping::PerVariant-#{stock_location}-#{package.order.number}-#{ship_address.country.iso}-#{ship_address.state_text}-#{ship_address.city}-#{ship_address.zipcode}-#{contents_hash}-#{I18n.locale}\".gsub(\" \",\"\")\n end", "def fetch_or_cache_partial(cached_partials, template, order_by:); end", "def cache\n yield\n end", "def reformat_languages(languages)\nnew_hash = Hash.new\n# another_hash = Hash.new\nlanguages.each do |hash_key, hash_data|\n hash_data.each do |language_name, types|\n new_hash[language_name] = types\n new_hash[language_name][:style] = [hash_key]\n end\n new_hash[:javascript][:style] << :oo\n end\n new_hash\nend", "def uncached_render\n before_process\n\n content = engine.transform(self)\n\n if path and tlayout = layout\n [instance, tlayout.instance].each do |i|\n i.instance_variable_set(\"@content\", content)\n end\n\n content = tlayout.render\n end\n\n content\n\n ensure\n after_process unless $!\n end", "def fix_related_data_for_copied_theme(new_theme, new_nodes, new_template_files, original_theme, original_nodes, original_template_files, created_at)\n # # update param_values\n original_theme_id = original_theme['id']\n new_theme_id = new_theme.id\n\n original_nodes.each_with_index{|node,index|\n new_node = new_nodes[index]\n ParamValue.where( :theme_id=>original_theme_id, :page_layout_id=>node.id, :created_at=>created_at ).\n update_all( :page_layout_id=> new_node.id, :page_layout_root_id=>new_theme.page_layout_root_id, :theme_id=>new_theme_id )\n obsolete_template_resources = new_theme.template_resources.select{|template_resource| template_resource.page_layout_id== node.id }\n if obsolete_template_resources.present?\n #change page_layout_key, update one of them is done.\n obsolete_template_resources.first.update_attribute!(:page_layout_id, new_node.id )\n end\n }\n # after page_layout_key updated, confirm template_resource existing.\n new_theme.template_resources.select{|template_resource| template_resource.source.nil? }.each(&:destroy!)\n\n if created_at.present?\n Spree::TemplateFile.where(:created_at=>created_at, :theme_id=>original_theme_id).update_all( :theme_id=>new_theme_id )\n Spree::TemplateRelease.where(:created_at=>created_at, :theme_id=>original_theme_id).update_all( :theme_id=>new_theme_id )\n end\n new_theme.save!\n end", "def find_template(views, name, engine, &block)\n I18n.fallbacks[I18n.locale].each { |locale|\n super(views, \"#{name}.#{locale}\", engine, &block) }\n super(views, name, engine, &block)\n end", "def duplicate\n @selected_locale = params[:locale]\n @selected_language = @languages[@selected_locale]\n common_duplicate_behavior @process_lt, 'process_lt', @selected_locale\n end", "def each_template\n if @processed.nil?\n @processed, @rest = templates.keys.partition { |k| k.to_s.include? \".\" }\n end\n\n @processed.each do |k|\n yield k, templates[k]\n end\n\n @rest.each do |k|\n yield k, templates[k]\n end\n end", "def save_translations\n return true unless translation_cache\n \n translation_cache.each do |code, attrs|\n switch_language(code) do\n @attributes.update attrs\n update_translation\n end\n end\n true\n end", "def templates; end", "def set_locale\n set_I18n_locale(params[:locale]) # Merken in Client_Info_Cache\n\n respond_to do |format|\n format.js {render :js => \"window.location.reload();\" } # Reload der Sganzen Seite\n end\n end", "def index\n \n if params[:main_language_id] != nil && params[:main_language_id] != ''\n session[:main_language_id] = params[:main_language_id]\n end\n \n @locales = Locale.all\n \n if session[:main_language_id] == nil || session[:main_language_id] == ''\n session[:main_language_id] = @locales.first.id\n end\n \n @locales_array = Array.new\n @locales.each{ |locale| @locales_array << [locale.name, locale.id]}\n \n @keys = Key.find_key_without_parent\n # params[:namespace_id] ? @namespace = Key.find(params[:namespace_id].to_i) : nil\n @namespaces = Key.find_root_namespaces\n @sequences = Key.find_sequences\n \n respond_to do |format|\n format.html\n end\n end", "def set_template\n end", "def template_map\n return TEMPLATE_MAP\n end", "def reload_rh_texts\n langs = Dir[\"Data/Text/Dialogs/#{CSV_BASE}.*.dat\"].collect { |i| i.match(/[0-9]+\\.([a-z]+)\\.dat$/).captures[0] }\n if langs.empty? ||\n File.mtime(\"Data/Text/Dialogs/#{CSV_BASE}.#{langs.first}.dat\") < File.mtime(\"Data/Text/#{langs.first}.dat\")\n langs << GamePlay::Load::DEFAULT_GAME_LANGUAGE if langs.empty?\n log_debug('Updating Text files')\n filename = 'plugins/text2csv' # Just to avoid the warning\n require filename\n Available_Langs.clear\n Available_Langs.concat(langs)\n log_debug('Compiling Text files')\n compile\n end\n end", "def cache_key\n case\n when !persisted?\n \"#{self.class.model_name.cache_key}/new\"\n else\n \"#{self.class.model_name.cache_key}/#{id}-#{self.cache_version_key}\"\n end\n end", "def templates=(_arg0); end", "def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end", "def cache_key_base\n \"georeferencer/#{Georeferencer::VERSION}/#{self.to_s.underscore}\"\n end", "def sync(source_template)\n [ :template_name, :template_type, :template_outfile, :template_rebuild_me, :template_text,\n :template_linked_file, :template_linked_file_mtime, :template_linked_file_size,\n :template_created_on, :template_modified_on, :template_created_by, :template_modified_by,\n :template_build_dynamic ].each do |attribute|\n self[attribute] = source_template[attribute]\n end\n \n # Linked files must be placed in the filesystem appropriately.\n unless self.linked_file.blank?\n blog_root_regex = Regexp.new('(/var/domain/.*/(beta|www))')\n source_blog_root = blog_root_regex.match(source_template.blog.blog_site_path)[1]\n target_blog_root = blog_root_regex.match(self.blog.blog_site_path)[1]\n self[:template_linked_file].gsub!(source_blog_root, target_blog_root)\n end\n \n # Copy templatemaps ONLY if this template has been previously saved.\n unless self.new_record?\n # Delete existing templatemaps.\n self.templatemaps.destroy_all\n \n # Copy templatemaps.\n source_template.templatemaps.each do |source_templatemap|\n self.templatemaps << MovableType::AR::Templatemap.create(self, source_templatemap)\n end\n end\n end", "def translations_hash; end", "def rekey_as_needed; end", "def store_cached_name\n self.cached_name = \"\"\n self.cached_name << \"#{reference} - \" if reference.present?\n self.cached_name << \"#{resource.title} - \"\n self.cached_name << \"#{criterion.name}\"\n end", "def reload\n clear_memoizations!\n remove = data.keys.find_all do |k|\n ![:id, :name].include?(k.to_sym)\n end\n remove.each do |k|\n data.delete(k)\n end\n super\n end", "def build_text(dict_id,entry_data,key_lang,num)\n\t\tprimary_lang=primary_lang(dict_id)\n\t\tif primary_lang!=@src_lang and primary_lang!=\"\"\n\t\t\[email protected](true)\n\t\telse\n\t\t\[email protected](false)\n\t\tend\n\t\tif entry_data[\"#HTML\"]!=nil\n\t\t\t### this guy already has HTML text .. dont need to build\n\t\t\treturn @hili.hilite(entry_data[\"#HTML\"],is_html=true)\n\t\tend\n\t\tmulti_lingual= is_multilingual(dict_id)\n\n\t\ti = 1\n\t\thtml_txt = \"\"\n\n\t\t####### For tag TERM:LANG\n\t\tnum_text=\"\"\n\t\tif num != \"0\" \n\t\t\tnum_text=sprintf(\"<b>%s. </b>\",num)\n\t\tend\n\t\tentry_data.each{|tag,value|\n\t\t\tnext if tag[0,5]!=\"#TERM\"\n\t\t\tnext if tag[6,2]==primary_lang ## dont show key if it is in source language\n\t\t\thtml_txt << '<p class=\"dict_text\">'\n\t\t\tif num_text != \"\"\n\t\t\t\thtml_txt << num_text\n\t\t\t\tnum_text = \"\"\n\t\t\tend\n\t\t\thtml_txt << \"[\" + tag[6,2] + \"] \" if multi_lingual\n\t\t\thtml_txt << @hili.hilite(value) \n\t\t\thtml_txt << '</p>'\n\t\t}\n\t\t####### For tag EXPLAIN:LANG\n\t\tentry_data.each{|tag,value|\n\t\t\tnext if tag[0,8]!=\"#EXPLAIN\"\n\t\t\thtml_txt << '<p class=\"dict_text\">'\n\t\t\thtml_txt << \"[\" + tag[9,2] + \"] \" if multi_lingual\n\t\t\thtml_txt << @hili.hilite(value) \n\t\t\thtml_txt << '</p>'\n\t\t}\n\t\t####### For tag EXAMPLES:LANG\n\t\tentry_data.each{|tag,value|\n\t\t\tnext if tag[0,9]!=\"#EXAMPLES\"\n\t\t\thtml_txt << render_examples(value)\n\t\t}\n\t\treturn html_txt\n\tend", "def translate(language_code)\n \n template = nil\n \n if template_translation = ::ContentManagerSystem::Translation::TemplateTranslation.get(id)\n \n translated_attributes = {}\n \n template_translation.get_translated_attributes(language_code).each do |term| \n translated_attributes.store(term.concept.to_sym, term.translated_text)\n end\n\n template = Template.new(attributes.merge(translated_attributes){ |key, old_value, new_value| new_value.to_s.strip.length > 0?new_value:old_value }) \n else\n template = self \n end\n \n template.language_code = language_code\n \n template\n \n end", "def set_content_for key\n @view_flow.content.delete key\n content_for key do\n yield\n end\n end", "def composite_keys \n Hash.new.tap do |hash|\n SPREE_MODULES.each do |mod|\n hash.merge! get_translation_keys(\"spree_#{mod}\")\n end\n end\n end", "def get_not_translated\n language = \"en\"\n language = params[:language] if params[:language]\n lang = []\n @files = {}\n @new_lang = []\n File.read(\"#{Rails.root}/lang/#{language}.rb\").scan(/l.store\\s?[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st|\n st.scan(/[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st2|\n lang << st2.gsub(/[\\'\\\"]/, \"\")\n end\n end\n\n @files_list = Dir.glob(\"#{Rails.root}/app/controllers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/views/**/*.rhtml\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/models/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/helpers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/lib/**/*.rb\").collect\n for file in @files_list\n File.read(file).scan(/[^\\w\\d]\\_\\([\\'\\\"][^\\'\\\"]+[\\'\\\"]\\)/) do |st|\n st = st.gsub(/.?\\_\\(/, \"\").gsub(/[\\s\\'\\\"\\)\\(]/, \"\")\n @new_lang << st\n @files[st] = file\n end\n end\n\n @new_lang -= lang\n @new_lang = @new_lang.uniq.flatten\n end", "def templateForComponent(name)\n template = nil\n pfn = pathForName(name)\n if @templateCache.has_key? pfn\n if @templateCache[pfn].respond_to? :weakref_alive?\n rtc = 0\n begin\n template = @templateCache[pfn].self\n rescue Exception => e\n Logger[Ciowa_log].info \"Error: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n #reload(File.new(pathForName(name)))\n reload(File.new(pfn))\n rtc += 1\n if rtc < 3\n retry\n else\n raise e\n end\n end\n else\n template = @templateCache[pfn]\n end\n else\n \n #reload(File.new(pathForName(name)))\n reload(File.new(pfn)) if pfn\n template = @templateCache[pfn]\n end\n template\n end", "def clean_cache_and_translations\n $redis.srem(\"otwtranslation_rules_for_#{language_short}\", display_type)\n\n Otwtranslation::Translation.for_language(language_short)\n .where(\"rules != '#{[].to_yaml}'\").each do |translation|\n if translation.rules.include?(id)\n translation.approved = false\n translation.rules = []\n translation.save!\n end\n end\n end", "def all_templates\n @templates = super.merge(TEMPLATES)\n end", "def all_templates\n @templates = super.merge(TEMPLATES)\n end", "def all_templates\n @templates = super.merge(TEMPLATES)\n end", "def all_templates\n @templates = super.merge(TEMPLATES)\n end", "def all_templates\n @templates = super.merge(TEMPLATES)\n end", "def store_resource_template\n add_pod_disruption_budget\n counter = Hash.new(-1)\n self.resource_template = raw_template.map do |resource|\n index = (counter[resource.fetch(:kind)] += 1)\n TemplateFiller.new(self, resource, index: index).to_hash\n end\n end", "def store_translation(locale, key, text, count=nil)\n if count.nil?\n data = text\n else\n pluralization_index = pluralizer(locale).call(count)\n data = { pluralization_index => text }\n end\n Translation.create_or_update(locale, key, data)\n # merge the stored translation back to the memory collection\n reload!\n end" ]
[ "0.7255774", "0.63926667", "0.60329664", "0.60078907", "0.57929796", "0.5736165", "0.5713645", "0.56191", "0.5592546", "0.55683136", "0.55079514", "0.5491279", "0.5478338", "0.5453145", "0.54496485", "0.54337054", "0.53969634", "0.5385297", "0.535207", "0.5342463", "0.5330953", "0.53000146", "0.5296106", "0.5283712", "0.5260608", "0.52557576", "0.52550083", "0.5239055", "0.5238632", "0.5220654", "0.5218783", "0.5204079", "0.51892704", "0.51856214", "0.5174279", "0.5160968", "0.5152688", "0.51524806", "0.51467377", "0.5145659", "0.51398075", "0.5136328", "0.51106715", "0.51006734", "0.51006734", "0.5085819", "0.5080522", "0.5079562", "0.5078144", "0.50729215", "0.5065116", "0.50597185", "0.5056463", "0.50536466", "0.50536466", "0.50536466", "0.50536466", "0.50536466", "0.50536466", "0.50536466", "0.5041212", "0.50385267", "0.5036339", "0.50356275", "0.50263375", "0.50257", "0.5021802", "0.5016829", "0.5016177", "0.5015069", "0.5012337", "0.50034475", "0.50000185", "0.49889696", "0.4969655", "0.4966459", "0.49603575", "0.49564764", "0.49534225", "0.49529222", "0.49498877", "0.49458852", "0.4933674", "0.49329063", "0.493161", "0.4931392", "0.49296966", "0.4926072", "0.4923266", "0.4920122", "0.491497", "0.49135694", "0.49088222", "0.489278", "0.489278", "0.489278", "0.489278", "0.489278", "0.4886575", "0.4882857" ]
0.75529647
0
rerender and cache this template/key combination for ONE language
def refresh_one_language(template_name,language,key,args={},&prerender_block) # @logger.debug("\t\trender_base.refresh_one_language(#{template_name},#{language},#{key})") if @logger renderer=get_renderer(template_name) key ||= renderer.get_key(args) rendered=renderer.render(language,args,{:render_mode => :refresh},&prerender_block) put_page_into_s3(language,key,rendered) return rendered end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh(template_name,key,args={},&prerender_block)\n # @logger.debug(\"\\trender_base.refresh(#{template_name},#{key})\") if @logger\n result={}\n @languages.each do |language|\n result[language] = refresh_one_language(template_name,language,key,args,&prerender_block)\n end\n return result\n end", "def _template_cache\n @cache ||= {}\n end", "def template_cache_key\n context[:template_cache_key]\n end", "def update_template(key, value)\n t = { key => value }\n raw = read_attribute(\"template\") \n d = raw.nil? ? {} : JSON.parse(raw) \n merged = d.deep_merge(t)\n self.template = JSON.generate(merged)\n self.save!\n end", "def read_or_render(template_name,language,key,render_args={},&prerender_block)\n # @logger.debug(\"render_base.read_or_render(#{template_name},#{language},#{key})\") if @logger\n #check cache\n\n renderer=nil\n unless key\n #try to generate the key\n renderer ||= get_renderer(template_name)\n\n key=renderer.get_key( render_args)\n end\n if key\n result=peek(language,key)\n end\n unless result\n\n template_name,key,render_args = process_prerender_block(\n template_name,\n key,\n render_args,\n &prerender_block)\n \n renderer ||= get_renderer(template_name)\n result=renderer.render(language,render_args,{})\n put_page_into_s3(language,key,result)\n else\n # @logger.debug(\"got it from cache\") if @logger\n\n end\n return result\n end", "def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\n end", "def prep_template(language,frame_binding)\n\n template=@localized_templates[language]\n @language=language\n eval(\"@language='#{language}'\",frame_binding)\n \n unless template\n local_template_text=@raw_template.result(frame_binding)\n local_template_text=local_template_text.gsub(@ltag,\"<%\")\n local_template_text=local_template_text.gsub(@rtag,\"%>\")\n\n template=compile(local_template_text)\n @localized_templates[language]=template unless is_development?\n end\n template\n \n end", "def load_cache(language)\n\n\t\t\t\t\t\t# Initialize cache structures\n\t\t\t\t\t\tif @o2t.nil?\n\t\t\t\t\t\t\t@o2t = {}\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif @t2o.nil?\n\t\t\t\t\t\t\t@t2o = {}\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Fill cache if empty\n\t\t\t\t\t\tif @o2t[language.to_sym].nil? || @t2o[language.to_sym].nil?\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t@o2t[language.to_sym] = {}\n\t\t\t\t\t\t\t@t2o[language.to_sym] = {}\n\n\t\t\t\t\t\t\tdata = where(slug_language: language.to_s)\n\t\t\t\t\t\t\tdata.each do |item|\n\t\t\t\t\t\t\t\t@o2t[language.to_sym][item.original] = item.translation\n\t\t\t\t\t\t\t\t@t2o[language.to_sym][item.translation] = item.original\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend", "def redis_key\n return \"rlt:#{@template_name}\"\n end", "def source\n @source ||= {}\n @source[Locomotive::Mounter.locale] ||= self.template.need_for_prerendering? ? self.template.render : self.template.data\n end", "def raw_template=(content)\n @source ||= {}\n @source[Locomotive::Mounter.locale] = content\n end", "def caching_compile(action, template)\n if Global.compile && action.template\n Cache.compiled[action.relaxed_hash] ||= compile(action, template)\n else\n compile(action, template)\n end\n end", "def reload\n @@languages.each do |lang_code, lang_file|\n lang_file.reload\n end\n end", "def cache_removal_key\n study_name = self.study.url_safe_name\n case self.file_type\n when 'Cluster'\n name_key = self.cluster_groups.first.name.split.join('-')\n @cache_key = \"#{study_name}.*render_cluster.*#{name_key}\"\n when 'Coordinate Labels'\n name_key = self.coordinate_labels_target.name.split.join('-')\n @cache_key = \"#{study_name}.*render_cluster.*#{name_key}\"\n when 'Expression Matrix'\n @cache_key = \"#{study_name}.*expression\"\n when 'MM Coordinate Matrix'\n @cache_key = \"#{study_name}.*expression\"\n when /10X.*File/\n @cache_key = \"#{study_name}.*expression\"\n when 'Gene List'\n name_key = self.precomputed_scores.first.name.split.join('-')\n @cache_key = \"#{study_name}.*#{name_key}\"\n when 'Metadata'\n # when reparsing metadata, almost all caches now become invalid so we just clear all matching the study\n @cache_key = \"#{study_name}\"\n else\n @cache_key = nil\n end\n @cache_key\n end", "def clear_cache_i18n\n Rails.cache.delete_matched 'views/i18n/*'\n end", "def store_template_to_local_cache( template_body, ttl = self.local_cache_ttl )\n @@cache ||= {}\n \n expiration = Time.now.to_i + ttl\n Rails.logger.debug( \"Caching template locally for #{ttl.inspect} seconds; will expire at #{expiration}\" )\n @@cache[@template_name] = { :template => template_body,\n :expiration => expiration }\n\n return template_body\n end", "def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end", "def reload\n self.class.get(key)\n end", "def reload\n self.class.get(key)\n end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def expire_cache_for(list)\n key = \"/ajax/lists/#{list.id}\"\n\n I18n.available_locales.each do |locale|\n expire_fragment(\"#{locale}#{key}/edit\")\n expire_fragment(\"#{locale}#{key}/copy\")\n end\n end", "def reload_dictionary\n if @short_refresh\n load_dictionary if needs_refresh?\n else\n load_dictionary\n end\n end", "def clear_cached_vars\n @_rendered , @_versions = false , false\n end", "def expire_caches_for(record)\n key = \"/ajax/tags/#{record.class.name.downcase.pluralize}\"\n\n I18n.available_locales.each do |locale|\n expire_fragment(\"#{locale}#{key}\")\n expire_fragment(\"#{locale}#{key}.json\")\n end\n end", "def resource_cache(resource_key)\n data[resource_key] ||= Dictionary.new\n end", "def combined_fragment_cache_key(key); end", "def uncached_render\n before_process\n\n content = engine.transform(self)\n\n if path and tlayout = layout\n [instance, tlayout.instance].each do |i|\n i.instance_variable_set(\"@content\", content)\n end\n\n content = tlayout.render\n end\n\n content\n\n ensure\n after_process unless $!\n end", "def for path, namespaces = nil\n @semaphore.synchronize do\n if @cache.has_key?(path)\n @cache[path]\n else\n @cache[path] = if namespaces\n for_node @template.at(canonicalize(path), namespaces)\n else\n for_node @template.at(canonicalize(path))\n end\n end\n end\n end", "def add_key i18n_prj, input, select_from_translations\n v, quote = input.unquote\n\n if select_from_translations\n items = i18n_prj.potential_i18n_keys v\n if items.empty?\n TextMate::UI.tool_tip \"Can not find tranlation key\"\n else\n k = TextMate::UI.request_item \\\n :title => \"Select Translation Key\",\n :prompt => 'Select Translation Key',\n :items => items\n if !k\n TextMate::UI.tool_tip \"Canceled\"\n end\n end\n return input if !k\n else # new translation if needed\n v.gsub! '.', ''\n k = v[0..0].downcase + v[1..-1].underscore\n full_k = \"#{i18n_prj.key_prefix}.#{k}\"\n if i18n_prj.no_translation(full_k)\n new_k = TextMate::UI.request_string \\\n :default => full_k,\n :title => \"New Translation Key\"\n return input if new_k.nil? or new_k.empty?\n if new_k != full_k\n full_k = new_k\n k = new_k\n else\n k = '.' + k\n end\n insert_translation i18n_prj.en_yml_path, full_k, v\n else\n TextMate::UI.tool_tip \"Translation key '#{full_k}' exists\"\n k = '.' + k\n end\n end\n\n # snippet\n file_type = i18n_prj.file_type\n if quote or file_type == 'rb'\n %Q|t(#{k.inspect})|\n else\n case file_type\n when 'slim'; quote ? %Q|t(#{k.inspect})| : %Q|= t(#{k.inspect})|\n when 'haml'; quote ? %Q|t(#{k.inspect})| : %Q|= t(#{k.inspect})|\n else %Q|<%= t #{k.inspect} %>|\n end\n end\nend", "def perform_template_load\n memoize(:template) do\n self.data[:template] = api.stack_template_load(self)\n true\n end\n end", "def key\n :cache\n end", "def cache(key)\n @lock.synchronize do\n @contents[key] ||= yield\n end\n end", "def cache_key\n case\n when !persisted?\n \"#{self.class.model_name.cache_key}/new\"\n else\n \"#{self.class.model_name.cache_key}/#{id}-#{self.cache_version_key}\"\n end\n end", "def fetch_template_from_local_cache\n @@cache ||= {}\n \n return nil unless @@cache[@template_name]\n\n expiration = @@cache[@template_name][:expiration].to_i\n\n if expiration <= Time.now.to_i\n Rails.logger.debug( \"Local cache entry is too old, removing!\" )\n @@cache.delete( @template_name )\n return nil\n end\n\n Rails.logger.debug( \"Local cache still valid, expiring in #{expiration.inspect}\" )\n\n return @@cache[@template_name][:template]\n end", "def generate_with_cache(checksums)\n changed_files = []\n Registry.checksums.each do |file, hash|\n changed_files << file if checksums[file] != hash\n end\n Registry.load_all\n all_objects.each do |object|\n if object.files.any? {|f, line| changed_files.include?(f) }\n log.info \"Re-generating object #{object.path}...\"\n opts = options.merge(:object => object, :type => :layout)\n Templates::Engine.render(opts)\n end\n end\n end", "def rekey_as_needed; end", "def fetch_or_cache_partial(cached_partials, template, order_by:); end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def expire(bibl)\n Rails.cache.delete(\"views/tracksys.lib.virginia.edu\" + \"#{admin_bibl_path(bibl.id)}\")\n Rails.cache.delete(\"views/tracksys.lib.virginia.edu\" + \"#{admin_bibls_path}\")\n end", "def cache(data); end", "def set_template\n end", "def update_cache\r\n Rails.cache.delete(\"All#{self.class.name.to_s}\")\r\n end", "def cache\n yield\n end", "def ct(key, language = nil)\n language = language || I18n.locale\n r = {flag: false, key: key, translation: \"\", locale: language.to_sym}\n hooks_run(\"on_translation\", r)\n return r[:translation] if r[:flag]\n translate(\"common.#{key}\", locale: language)\n end", "def cache!( new_file )\n super\n @old_tmp_file = new_file\n end", "def cache_collect\n\t\tRepository.repo.get_from_cache(@template)\n\tend", "def cache_key(package)\n stock_location = package.stock_location.nil? ? \"\" : \"#{package.stock_location.id}\"\n ship_address = package.order.ship_address\n contents_hash = Digest::MD5.hexdigest(package.contents.map {|content_item| content_item.variant.id.to_s + \"_\" + content_item.quantity.to_s }.join(\"|\"))\n @cache_key = \"Spree::Calculator::Shipping::PerVariant-#{stock_location}-#{package.order.number}-#{ship_address.country.iso}-#{ship_address.state_text}-#{ship_address.city}-#{ship_address.zipcode}-#{contents_hash}-#{I18n.locale}\".gsub(\" \",\"\")\n end", "def update_translation( key, value, locale )\n \n # lock file\n filename = File::join RAILS_ROOT, \"config/locales\", File::basename( locale + \".yml\" )\n if( File.exists? filename )\n file = File.new( filename, \"r+\")\n else\n file = File.new( filename, \"w+\" ) \n end\n \n file.flock( File::LOCK_EX )\n \n begin \n # read project locale file\n data = YAML.load( file )\n unless data.is_a? Hash \n I18n.load_path << filename\n data = { locale => {} } unless data \n end\n \n tmp = data\n \n # create middle hash keys as needed\n key = locale + \".\" + key\n keys = key.split(/\\./)\n base_key = keys.pop\n \n while tmpkey = keys.shift\n unless tmp[tmpkey].class == Hash\n tmp[tmpkey] = {}\n end\n tmp = tmp[tmpkey]\n end\n \n # update or create value\n tmp[base_key] = value\n \n # save file\n file.truncate( 0 )\n file.rewind\n file.write( data.to_yaml )\n ensure\n # unlock and close file\n file.flock( File::LOCK_UN )\n file.close\n end\n \n I18n.reload!\n \n end", "def regenerate( how = nil )\n retouch nil, how\n end", "def cached_translations_for_language(language)\n translations = Tr8n::Config.current_source.valid_translations_for_key_and_language(self.key, language)\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end", "def operate_switch_language(code)\n #callback(:before_switch_language)\n @translation_cache = {} if @translation_cache.nil?\n facet_names = self.class.globalize_facets\n @translation_cache[language_code] = @attributes.dup.delete_if {|key, value| !facet_names.include? key.to_sym}\n Locale.switch(code) do\n set_original_language\n if @translation_cache.include? code\n @attributes.update @translation_cache[code]\n elsif @original_language == Locale.base_language and !@new_record\n reload\n elsif !@new_record\n trs = ModelTranslation.find(:all, \n :conditions => [ \"table_name = ? AND item_id = ? AND language_id = ? AND \" +\n \"facet IN (#{[ '?' ] * facet_names.size * ', '})\", self.class.table_name,\n self.id, @original_language.id ] + facet_names.map {|facet| facet.to_s} )\n trs ||= []\n trs.each do |tr|\n attr = tr.text || base[tr.facet.to_s]\n write_attribute( tr.facet, attr )\n end\n end\n \n operate_switch_language_on_associations(code)\n \n #callback(:after_switch_language)\n end\n end", "def wrap_compile(action, template = nil)\n template ||= reaction_or_file(action).to_s\n caching_compile(action, template)\n end", "def updateKey; @key = getKey; self end", "def template_map\n \n end", "def cache_key\n end", "def render(cache: true, &block)\n\t\t\t@cache = cache\n\t\t\t## Compile Tilt to instance hash\n\t\t\treturn unless @filename\n\n\t\t\ttilt = compile_file\n\t\t\t## Render Tilt from instance hash with new options\n\t\t\tlayout_render tilt.render(@scope, @locals, &block)\n\t\tend", "def templateForComponent(name)\n template = nil\n pfn = pathForName(name)\n if @templateCache.has_key? pfn\n if @templateCache[pfn].respond_to? :weakref_alive?\n rtc = 0\n begin\n template = @templateCache[pfn].self\n rescue Exception => e\n Logger[Ciowa_log].info \"Error: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n #reload(File.new(pathForName(name)))\n reload(File.new(pfn))\n rtc += 1\n if rtc < 3\n retry\n else\n raise e\n end\n end\n else\n template = @templateCache[pfn]\n end\n else\n \n #reload(File.new(pathForName(name)))\n reload(File.new(pfn)) if pfn\n template = @templateCache[pfn]\n end\n template\n end", "def get( wrapped_page_layout )\n key = wrapped_page_layout.to_key \n unless resources_cache.key? key\n target_resource = nil\n resource_id = wrapped_page_layout.assigned_text_id\n if resource_id > 0 \n target_resource = Spree::TemplateText.find(resource_id)\n end\n resources_cache[key] = target_resource \n end\n if resources_cache[key].present?\n resources_cache[key]\n else\n nil \n end\n end", "def revert!\n ::ActionView::Template.class_eval do\n alias_method :compile!, :cb_original_compile! # rubocop:disable Lint/DuplicateMethods\n undef_method :cb_patched_compile!\n end\n end", "def set_key(key, text)\n return if key == self.key and text == self.text\n @key = key\n @text = text\n refresh\n end", "def update_cache\n # Does nothing...up to subclasses to implement.\n end", "def cached_translations_for_language(language)\n if Tr8n::RequestContext.current_source\n translations = Tr8n::RequestContext.current_source.valid_translations_for_key_and_language(self.key, language)\n end\n\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end", "def cache_erb_fragment(block, name = {}, options = nil)\n unless AppConfig[:perform_caching] then block.call; return end\n buffer = eval(\"_erbout\", block.binding)\n if cache = Cache.get(name)\n buffer.concat(cache)\n else\n pos = buffer.length\n block.call\n Cache.put(name, buffer[pos..-1], 600)\n end\n end", "def translator_for(t_key, template = nil, parameters = nil)\n o_translator = translators[t_key]\n if template\n translator = Translator.new(template,\n :parameters => parameters)\n if o_translator\n o_translator.flagged.each do |i|\n translator.flag_ref(i)\n end\n end\n translators[t_key] = translator\n o_translator = translator\n else\n unless o_translator\n o_translator = Translator.new({},\n :parameters => {})\n end\n end\n o_translator\n end", "def menu\n Rails.cache.fetch('menu') { render :partial => 'all/menu' }\n end", "def set_content_for key\n @view_flow.content.delete key\n content_for key do\n yield\n end\n end", "def main= page\n @cache[:main] = page\n end", "def stack_template_load(stack)\n if(stack.persisted?)\n result = request(\n :endpoint => stack.custom.fetch(:manifest, stack.custom.get(:update, :manifest))\n )\n cache_template = stack.template = template_data_format(result[:body])\n stack.custom = stack.custom.merge(result[:body])\n if(stack.custom['expandedConfig'])\n stack.custom['expandedConfig'] = YAML.load(stack.custom['expandedConfig']).to_smash\n end\n if(stack.custom['layout'])\n stack.custom['layout'] = YAML.load(stack.custom['layout']).to_smash\n end\n stack.valid_state\n cache_template\n else\n Smash.new\n end\n end", "def set_stale\n return unless locale == I18n.default_locale.to_s\n\n Translation.where(:key => key).where(Translation.arel_table[:locale].not_eq(locale)).update_all({:stale => true})\n end", "def reload!\n @initialized = false\n @translations = nil\n super\n end", "def refresh_cache\n @cache = build_cache\n end", "def key_template\n @key_template ||= [*name.downcase.split(\"::\"), \"%<id>d\"].join(\":\")\n end", "def update(key, ctx); end", "def set_locale\n set_I18n_locale(params[:locale]) # Merken in Client_Info_Cache\n\n respond_to do |format|\n format.js {render :js => \"window.location.reload();\" } # Reload der Sganzen Seite\n end\n end", "def __ag_render_a_template(key, template, options, other, &block)\n _ag_render_without_silverlight(key, template, options, other, &block)\n end", "def initialize(template_text,options={})\n @renderer_extension_modules=[]\n\n @name=options[:template_name]\n @templates_root_dir= options[:templates_directory]# || \"#{::Rails.root.to_s}/app/views\"\n\n @output_buffer=\"\"\n #unique tag for escaping post and pre processing tags\n @ltag=\"!@@@##$$1212\"\n @rtag=\"!723465hjf3!@#\"\n\n @default_language=options[:default_language] || \"en\"\n\n\n @escape_tags= options[:tags_to_escape] || []\n @runtime_tags= options[:runtime_tags] || []\n\n\n #escape blocks that will be run at view time\n @template_text=template_text.clone\n @escape_tags.each do |etag|\n escape_tag_content( etag,@template_text)\n\n \n end\n\n# raise \"need templates directory\" unless options[:templates_directory]\n\n #escape all normal dynamic blocks for preprocessing\n @template_text=@template_text.gsub(\"<%\",@ltag).gsub(\"%>\",@rtag).gsub(\"<$\",\"<%\").gsub(\"$>\",\"%>\")\n \n #turn the setup block into a proc <## ##> into executable blocks\n @template_text=@template_text.gsub(\"<##\",\"<% set_setup_proc{ \").gsub(\"##>\",\"} %>\")\n\n #turn the key block into a proc <## ##> into executable blocks\n @template_text=@template_text.gsub(\"<!!KEY\",\"<% set_key_proc{ \").gsub(\"!!KEY>\",\"} %>\")\n\n\n @raw_template=compile(@template_text)\n #this hold variations of the template after it has been localized\n #into different languages, but before rendering\n @localized_templates={}\n @setup_proc=nil\n @key_proc=nil\n @render_base=options[:render_base]\n @template_name=options[:template_name]\n #this tag will be used to create non cachable dynamic blocks\n\n\n if options.has_key?(:helpers) && options[:helpers]!=nil\n options[:helpers].each do |helper|\n include helper\n end\n end\n \n end", "def cache!(key=nil, options={})\n if @context.controller.perform_caching\n value = _cache_fragment_for(key, options) do\n _scope { yield self }\n end\n\n merge! value\n else\n yield\n end\n end", "def store_template_to_redis( template_body )\n return self.redis_connector.set( redis_key, template_body )\n end", "def set_cache\n Rails.cache.write(Service.cache_key,JSON.parse(params[:newest]))\n render :text => 'New cache!'\n end", "def load_template( key )\n\t\ttname = @signature.templates[key] or\n\t\t\traise Arrow::AppletError, \n\t\t\t\t\"No such template %p defined in the signature for %s (%s)\" %\n\t\t\t\t[ key, self.signature.name, self.class.filename ]\n\n\t\ttname.untaint\n\n\t\treturn @template_factory.get_template( tname )\n\tend", "def cache(key, options = {}, &block)\n name = cache_name(key)\n tags = options.delete(:tags) || []\n check_tags_existance(name, tags)\n if ActionController::Base.perform_caching\n cache = read(name, options)\n if cache && cache.is_a?(Hash) && cache[:data] && is_cache_actual?(cache) \n # Overwriting the cache with the same data for avoiding its expiration\n # when 'freeze cache' option is enabled.\n write(name, cache, options) if AstroConfig.freeze_cache?\n data = modify_cache_by_personalized_data(cache[:data], options)\n data.is_a?(String) ? data.html_safe : data\n else\n self.class.do_not_cache_block = false\n output = execute_block(&block)\n unless self.class.do_not_cache_block\n tags_hash = generate_tags_hash(tags)\n write(name, { :data => output, :tags => tags_hash }, options)\n end\n self.class.do_not_cache_block = false\n output.is_a?(String) ? output.html_safe : output\n end\n else\n execute_block(&block)\n end\n end", "def cache_key_base\n \"georeferencer/#{Georeferencer::VERSION}/#{self.to_s.underscore}\"\n end", "def cache=(_arg0); end", "def cache=(_arg0); end", "def cache=(_arg0); end", "def cache=(_arg0); end", "def current_template=(t)\n @ran_templates ||= []\n @ran_templates << t unless t.nil?\n @current_template = t\n end", "def duplicate\n @selected_locale = params[:locale]\n @selected_language = @languages[@selected_locale]\n common_duplicate_behavior @process_lt, 'process_lt', @selected_locale\n end", "def cache!(new_file)\n super\n @old_tmp_file = new_file\n end", "def cache!(new_file)\n super\n @old_tmp_file = new_file\n end", "def move_to_cache\n true\n end" ]
[ "0.73324925", "0.6522461", "0.6261616", "0.5951001", "0.5816642", "0.5722953", "0.5720778", "0.56825167", "0.5602317", "0.55857486", "0.5581559", "0.5577895", "0.5548715", "0.54909766", "0.54816586", "0.54650223", "0.53913945", "0.5382071", "0.5382071", "0.5376518", "0.5376518", "0.5376518", "0.5376518", "0.5376518", "0.5376518", "0.5376518", "0.53581184", "0.5355162", "0.53225476", "0.53010774", "0.52914196", "0.5286953", "0.52736396", "0.52547467", "0.5252089", "0.52516514", "0.5231577", "0.5223764", "0.521752", "0.5217158", "0.5210529", "0.5180072", "0.51743144", "0.5171617", "0.5171617", "0.5171617", "0.5171617", "0.5155014", "0.51481354", "0.5147627", "0.5144953", "0.5130707", "0.51281303", "0.5118049", "0.5116742", "0.51109135", "0.5103318", "0.5102399", "0.51005703", "0.50962967", "0.5090944", "0.5090078", "0.5088789", "0.5078203", "0.50781316", "0.5075388", "0.50660765", "0.5065724", "0.5064101", "0.50560766", "0.50544685", "0.50500405", "0.5043342", "0.5037144", "0.5036656", "0.50364465", "0.5026514", "0.5018502", "0.5013207", "0.5010661", "0.50099105", "0.5001076", "0.50005496", "0.4997017", "0.49951914", "0.4991729", "0.49875852", "0.49817058", "0.4978314", "0.49721494", "0.49721408", "0.49701977", "0.49701977", "0.49701977", "0.49701977", "0.49663836", "0.4963162", "0.49596134", "0.49596134", "0.49591097" ]
0.75145096
0
try the cache first. if not in cache render and put in cache
def read_or_render(template_name,language,key,render_args={},&prerender_block) # @logger.debug("render_base.read_or_render(#{template_name},#{language},#{key})") if @logger #check cache renderer=nil unless key #try to generate the key renderer ||= get_renderer(template_name) key=renderer.get_key( render_args) end if key result=peek(language,key) end unless result template_name,key,render_args = process_prerender_block( template_name, key, render_args, &prerender_block) renderer ||= get_renderer(template_name) result=renderer.render(language,render_args,{}) put_page_into_s3(language,key,result) else # @logger.debug("got it from cache") if @logger end return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cached?; end", "def cached_render\n if Global.file_cache\n cached_render_file\n else\n cached_render_memory\n end\n end", "def move_to_cache\r\n true\r\n end", "def move_to_cache\n true\n end", "def move_to_cache\n true\n end", "def move_to_cache\n true\n end", "def move_to_cache\n true\n end", "def update_cache\n # Does nothing...up to subclasses to implement.\n end", "def cache\n yield\n end", "def cache_on?; end", "def cache_on?; end", "def pictures_nocache\r\n plan_id = params[:id]\r\n str = pictures_helper(plan_id)\r\n\r\n #MES- Is there a cache entry?\r\n cache_entry = @@pictures_cache[plan_id]\r\n if !cache_entry.nil?\r\n #MES- Is it stale?\r\n if cache_entry != str\r\n #MES- It's stale, reset it\r\n @@pictures_cache[plan_id] = str\r\n end\r\n end\r\n render :text => str\r\n end", "def cache?\n false\n end", "def cache!\n @@cache\n end", "def flush_cache; end", "def render_page_from_cache\n if cached_page.live_exists?\n render :file => cached_page.live_path\n return true\n else\n render :text => 'Currently not in cache', :status => 503\n return false\n end\n end", "def render_or_cache(key, options = {}, cache_options = {}, &block)\n if options[:ignore_roles].present? and logged_in? and current_user.has_role?(options[:ignore_roles])\n yield\n else\n cache(\"#{Rails.env}_#{key}\", cache_options, &block)\n end\n end", "def cache(data); end", "def cache?\n caching && true\n end", "def update\n download_page if cache_expired?\n read_cache\n end", "def cache_value?; end", "def cache_store; end", "def cache_store; end", "def should_cache?\n false\n end", "def call_with_cache(key)\n cache.key?(key) ? cache[key] : cache[key] = fetch(key).call\n end", "def configure_cache; end", "def _template_cache\n @cache ||= {}\n end", "def cache_collect\n\t\tRepository.repo.get_from_cache(@template)\n\tend", "def set_cache(value); end", "def set_cache(value); end", "def set_cache\n Rails.cache.write(Service.cache_key,JSON.parse(params[:newest]))\n render :text => 'New cache!'\n end", "def write_cache?\n if site.front_page_cached and c = cache_url\n #Rails.logger.info(\"request.path:::: #{request.path}\")\n cache_page(response.body, File.join(site.cache_path, c).to_s)\n end\n end", "def use_cache?\n super && !against_head?\n end", "def use_cache?\n super && !against_head?\n end", "def cache_request\n cache\n end", "def move_to_cache\n false\n end", "def cache!(key=nil, options={})\n if @context.controller.perform_caching\n value = _cache_fragment_for(key, options) do\n _scope { yield self }\n end\n\n merge! value\n else\n yield\n end\n end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def caching\n @caching = \"data_update[#{data_path}]\"\n end", "def clear_cache; end", "def _cache_control; end", "def without_cache(&block); end", "def without_cache(&block); end", "def disable_caching; end", "def refresh_cache\n @cache = build_cache\n end", "def cache\n old = @cache_enabled\n @cache_enabled = true\n yield\n ensure\n @cache_enabled = old\n clear_cache unless @cache_enabled\n end", "def cached_render_memory\n cache = Cache.actions\n options = cache_options\n store_options = {}\n key = full_path\n\n if options.respond_to?(:values_at)\n block, ttl = options.values_at(:key, :ttl)\n\n key = [full_path, block.call] if block\n store_options[:ttl] = ttl if ttl\n end\n\n cached_memory_process(cache, key, store_options)\n end", "def fetch_or_cache_partial(cached_partials, template, order_by:); end", "def cache\n @cache ||= build_cache\n end", "def use_cache(cache)\n @cache = cache\n end", "def pictures_cached\r\n plan_id = params[:id]\r\n #MES- Can we find the pictures sidebar text in the cache?\r\n cache_entry = @@pictures_cache[plan_id]\r\n str = ''\r\n if cache_entry.nil?\r\n #MES- The pictures sidebar is NOT in the cache, get the string and\r\n # put it in the cache\r\n str = pictures_helper(plan_id)\r\n @@pictures_cache[plan_id] = str\r\n else\r\n #MES- The pictures sidebar IS in the cache- get the string\r\n str = cache_entry\r\n #MES- The cache entry MAY be stale, so append some JavaScript that'll update the\r\n # HTML\r\n str += render_to_string(:partial => 'pictures_cached_javascript')\r\n end\r\n render :text => str\r\n end", "def cacheable?\n true\n end", "def disable_caching=(_arg0); end", "def filter_cache; end", "def disable_cache; end", "def add_cache_control; end", "def cache(key, options = {}, &block)\n name = cache_name(key)\n tags = options.delete(:tags) || []\n check_tags_existance(name, tags)\n if ActionController::Base.perform_caching\n cache = read(name, options)\n if cache && cache.is_a?(Hash) && cache[:data] && is_cache_actual?(cache) \n # Overwriting the cache with the same data for avoiding its expiration\n # when 'freeze cache' option is enabled.\n write(name, cache, options) if AstroConfig.freeze_cache?\n data = modify_cache_by_personalized_data(cache[:data], options)\n data.is_a?(String) ? data.html_safe : data\n else\n self.class.do_not_cache_block = false\n output = execute_block(&block)\n unless self.class.do_not_cache_block\n tags_hash = generate_tags_hash(tags)\n write(name, { :data => output, :tags => tags_hash }, options)\n end\n self.class.do_not_cache_block = false\n output.is_a?(String) ? output.html_safe : output\n end\n else\n execute_block(&block)\n end\n end", "def uncached_render\n before_process\n\n content = engine.transform(self)\n\n if path and tlayout = layout\n [instance, tlayout.instance].each do |i|\n i.instance_variable_set(\"@content\", content)\n end\n\n content = tlayout.render\n end\n\n content\n\n ensure\n after_process unless $!\n end", "def cache=(_arg0); end", "def cache=(_arg0); end", "def cache=(_arg0); end", "def cache=(_arg0); end", "def cached\n raise NotImplementedError\n end", "def cache time: 3600, &block\n return yield if 'development' == ENV['RACK_ENV']\n\n key = \"url:#{I18n.locale}:#{request.path}\"\n cached = $redis.get(key)\n page = cached || yield\n etag Digest::SHA1.hexdigest(page)\n\n if cached\n ttl = $redis.ttl(key)\n response.header['redis-ttl'] = ttl.to_s\n response.header['redis'] = 'HIT'\n else\n response.header['redis'] = 'MISS'\n $redis.setex(key, time, page)\n end\n page\n end", "def clear_cache() @cache = {}; end", "def do_cached( key, &block )\n \n # have a look in the cache\n value = fetch( key )\n\n # Cache HIT?\n return value unless value.nil?\n\n # Cache MISS : execute the block\n value = block.call( key )\n\n # Store value in the cache\n return store( key, value )\n end", "def refresh_cache\n return unless @p.user.is_admin\n return unless request.delete?\n expire_fragment('app_flickr_pics')\n flash[:notice] = \"Cache Cleared!\"\n redirect_back_or_default('/admin')\n end", "def load_cache\n @load_cache\n end", "def cache\n @cache ||= {}\n end", "def cache\n @cache ||= {}\n end", "def serve_from_cache!\n puts \"\\nServed from cache '#{request.uri}'\\n\\n\" if ::SETTINGS['debug']\n TinyProxy::Cache.get(request.uri)\n end", "def cache(key)\n @cache ||= {}\n timestamp, data = @cache[key]\n if timestamp && data && Time.now - timestamp < 1\n puts 'CACHE HIT'\n data\n else\n data = yield\n @cache[key] = [Time.now, data]\n data\n end\n end", "def cache(new_cache = nil)\n @cache = new_cache if new_cache\n @cache\n end", "def cache_erb_fragment(block, name = {}, options = nil)\n unless AppConfig[:perform_caching] then block.call; return end\n buffer = eval(\"_erbout\", block.binding)\n if cache = Cache.get(name)\n buffer.concat(cache)\n else\n pos = buffer.length\n block.call\n Cache.put(name, buffer[pos..-1], 600)\n end\n end", "def cache\n DataCache\n end", "def cache(key)\n return @cache[key] if cached?(key)\n\n @cache[key] = yield\n end", "def set_cache_buster\n \n response.headers[\"Cache-Control\"] = \"no-cache, no-store, max-age=0, must-revalidate\"\n response.headers[\"Pragma\"] = \"no-cache\"\n response.headers[\"Expires\"] = \"Fri, 01 Jan 1990 00:00:00 GMT\"\n\n end", "def cached\n self\n end", "def using_cache\n\t\t(@modcache_invalidated != true)\n\tend", "def cache(key, action, cache_store)\n binding.pry\n cache_key = key.to_s + \"_\" + action.to_s\n if cache_store[cache_key]\n return cache_store[cache_key]\n else\n result = yield # run the block\n cache_store[cache_key] = result # store it in our cache\n return result\n end\nend", "def cache( object = nil )\n return @cache unless object\n @cache[ object.id ] = object\n end", "def cached?(key)\n false\n end", "def cache\n the_current_time = current_time\n cache_loaded_at = @cache.loaded_at if @cache\n\n if @cache && cache_expiration_policy_object.stale?(cache_loaded_at, the_current_time)\n flush!(:stale, :loaded => cache_loaded_at, :now => the_current_time)\n end\n\n unless @cache\n instrument('cache_load') do\n @cache = LowCardTables::LowCardTable::Cache.new(@low_card_model, @low_card_model.low_card_options)\n end\n end\n\n @cache\n end", "def cache\n @cache ||= {}\n end", "def cached(cache_key)\n begin\n result = yield\n $memcache.set(cache_key, result, 7200)\n warn \"Component #{cache_key} Set Successfully\" \n result\n rescue\n {}\n end\n end", "def assign_cached(value)\n uploaded_file = uploaded_file(value)\n set(uploaded_file) if cache.uploaded?(uploaded_file)\n end", "def render_once(view, *args, &block)\n @_render_once ||= {}\n if @_render_once[view]\n nil\n else\n @_render_once[view] = true\n render(view, *args, &block)\n end\n end", "def render_once(view, *args, &block)\n @_render_once ||= {}\n if @_render_once[view]\n nil\n else\n @_render_once[view] = true\n render(view, *args, &block)\n end\n end", "def cache_resource( path )\n resource_hash = compute_hash(path)\n return true if find_resource(resource_hash)\n\n copy_resource(resource_hash, path)\n end", "def cache(key)\n @lock.synchronize do\n @contents[key] ||= yield\n end\n end", "def update_cache_chain\n logger.debug \"DB ********** Touching Element #{id} ********** \"\n self.touch\n self.dynamic_page.try(:update_cache_chain)\n end" ]
[ "0.7420183", "0.7420183", "0.7420183", "0.7420183", "0.7420183", "0.7420183", "0.7420183", "0.7379275", "0.7371972", "0.7242854", "0.7154603", "0.70867604", "0.70867604", "0.70867604", "0.70719224", "0.70075667", "0.6972006", "0.6972006", "0.6861038", "0.68379897", "0.6828975", "0.6826198", "0.67928463", "0.67833525", "0.67720276", "0.6759492", "0.6731351", "0.67275554", "0.66789657", "0.66789657", "0.66712964", "0.6653066", "0.6639435", "0.6633202", "0.6609531", "0.6605714", "0.6605714", "0.66007704", "0.65928996", "0.6582091", "0.6582091", "0.6569164", "0.65318865", "0.6491352", "0.64745003", "0.64745003", "0.64745003", "0.64745003", "0.64735883", "0.6467206", "0.64520097", "0.64520097", "0.6450021", "0.644422", "0.64355725", "0.64076126", "0.6395872", "0.6392969", "0.6357849", "0.6342085", "0.6338452", "0.63214415", "0.6318279", "0.63127166", "0.62990415", "0.62827003", "0.6282564", "0.62816447", "0.62816447", "0.62816447", "0.62816447", "0.62802255", "0.6260188", "0.61888", "0.6178292", "0.61777323", "0.61760986", "0.61750984", "0.61750984", "0.6160886", "0.6159349", "0.61518306", "0.6147935", "0.61356646", "0.61022776", "0.6075998", "0.6071909", "0.6068686", "0.606516", "0.60575485", "0.60559547", "0.6049075", "0.6048363", "0.60395396", "0.6036896", "0.6014286", "0.6014286", "0.60097885", "0.6004364", "0.6002051" ]
0.6242836
73
to test room paths
def test_room_paths() # the parameter is the (name, description) in initialize in class Room # to create new room of center/north/south center = Room.new("Center", "Test room in the center.") north = Room.new("North", "Test room in the north.") south = Room.new("South", "Test room in the south.") # to add path of center room center.add_paths({:north => north, :south => south}) # check if center.go(:north) really goes to north assert_equal(center.go(:north), north) # check if center.go(:south) really goes to south assert_equal(center.go(:south), south) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_simple_path_for\n path_finder = Amazeingly::PathFinder.new(rooms_collection: @rooms_collection)\n expected = Amazeingly::Path.new([\n { room: Amazeingly::Room.new(@rooms[2]), collected_objects: ['Knife'] }\n ])\n\n assert_equal expected, path_finder.path_for(objects: ['Knife'], starting_room_id: 3)\n end", "def test_shortest_path\n expected = Amazeingly::Path.new([\n { step_number: 1, room: @rooms_collection.find(6), collected_objects: [] },\n { step_number: 2, room: @rooms_collection.find(5), collected_objects: [] },\n { step_number: 3, room: @rooms_collection.find(7), collected_objects: [] },\n { step_number: 4, room: @rooms_collection.find(4), collected_objects: [] }\n ])\n\n assert_equal expected, @path_finder.shortest_path(from_room: @rooms_collection.find(6), to_room: @rooms_collection.find(4))\n end", "def test_enter_the_room\n enter_the_room(\"test_name\")\n end", "def test_full_room()\n @room2.guest_enter(@guest)\n @room2.guest_enter(@guest)\n assert_equal(true, @room2.full_room)\n end", "def test_create_all_paths\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.create_all_locations(test_graph)\n\t\ttest_main.create_all_paths(test_graph)\n\t\tassert_equal test_graph.get_loc(\"Matzburg\").paths.length, 4\n\tend", "def test_listedpath\n server = nil\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n\n # create a deep dir\n basedir = tempfile\n testdir = \"#{basedir}/with/some/sub/directories/for/testing\"\n oldfile = File.join(testdir, \"oldfile\")\n assert_nothing_raised {\n system(\"mkdir -p #{testdir}\")\n File.open(oldfile, \"w\") { |f|\n 3.times { f.puts rand(100) }\n }\n @@tmpfiles << basedir\n }\n\n # mounty mounty\n assert_nothing_raised {\n server.mount(basedir, \"localhost\")\n }\n\n list = nil\n # and then check a few dirs\n assert_nothing_raised {\n list = server.list(\"/localhost/with\", :manage, false, false)\n }\n\n assert(list !~ /with/)\n\n assert_nothing_raised {\n list = server.list(\"/localhost/with/some/sub\", :manage, true, false)\n }\n\n assert(list !~ /sub/)\n end", "def test_room_name\n assert_equal(\"Pop\", @room2.room_name)\n end", "def test_fun_forward_path\n\t@city = GoldRush::new\n\tassert_equal nil, @city.angels.forward_path4\n\tassert_equal nil, @city.sutter.forward_path3\n\tassert_equal nil, @city.nevada.forward_path2\n end", "def test_path\n assert_equal(1, categories(:category1).full_path.size)\n assert_equal(categories(:category1), categories(:category1).full_path[0])\n assert_equal(2, categories(:category2).full_path.size)\n assert_equal(categories(:category1), categories(:category2).full_path[0])\n assert_equal(categories(:category2), categories(:category2).full_path[1])\n assert_equal(2, categories(:category3).full_path.size)\n assert_equal(categories(:category1), categories(:category3).full_path[0])\n assert_equal(categories(:category3), categories(:category3).full_path[1])\n end", "def test1\n Cases.each do |c|\n a = ZML::pathsplit(c[0])\n assert_equal(c[1], a)\n b = ZML::pathjoin(a)\n assert_equal(c[0], b)\n end\n end", "def room; end", "def paths; end", "def paths; end", "def paths; end", "def paths; end", "def paths; end", "def room\n end", "def path() end", "def path() end", "def path() end", "def test_find_route_success\n @south_america = Init.set_up_map('../JSON/test_data.json')\n santiago = @south_america.vertices[@south_america.metros['santiago']]\n lima = @south_america.vertices[@south_america.metros['lima']]\n route = santiago.find_route(@south_america.metros['lima'])\n assert_equal(1, route.length)\n assert_instance_of(Array, route)\n assert_equal(route[0].vertex, lima)\n end", "def test_mates\n enter_the_room \"Not me\"\n #change test room\n @room_name=\"zz\"\n # add dude that will left by timeout\n enter_the_room \"a\"\n sleep Active_session::WAIT_TIMEOUT*4\n # enter and the leave\n session=enter_the_room(\"leaver\")[\"session\"]\n leave session\n # add couple of dudes\n enter_the_room \"b\"\n session=enter_the_room(\"c\")[\"session\"]\n # check that everything ok\n result=get_mates(session)[\"mates\"]\n assert result == [\"b\",\"c\"] || result == [\"c\",\"b\"], \"result:\"+\n result.join(\",\")\n end", "def test_room_has_name()\n assert_equal(\"The Diamond Room\", @room1.name())\n end", "def checkroom(r)\n case r.status\n when :plan\n # moot\n when :dig\n # designation cancelled: damp stone etc\n r.dig\n when :dug, :finished\n # cavein / tree\n r.dig\n # tantrumed furniture\n r.layout.each { |f|\n next if f[:ignore]\n t = df.map_tile_at(r.x1+f[:x].to_i, r.y1+f[:y].to_i, r.z1+f[:z].to_i)\n if (f[:bld_id] and not df.building_find(f[:bld_id]))\n df.add_announcement(\"AI: fix furniture #{f[:item]} in #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = t }\n f.delete :bld_id\n @tasks << [:furnish, r, f]\n end\n if f[:construction]\n try_furnish_construction(r, f, t)\n end\n }\n # tantrumed building\n if r.misc[:bld_id] and not r.dfbuilding\n df.add_announcement(\"AI: rebuild #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = r }\n r.misc.delete :bld_id\n construct_room(r)\n end\n end\n end", "def robot_path(grid)\n Robot.new(grid).find_unobstructed_path\nend", "def smooth_room_access(r)\n smooth_room(r)\n r.accesspath.each { |a| smooth_room_access(a) }\n end", "def smooth_room_access(r)\n smooth_room(r)\n r.accesspath.each { |a| smooth_room_access(a) }\n end", "def test_can_create_karaoke_room()\n assert_equal(KaraokeRoom, @karaoke_room1.class())\n end", "def test_type_of_room \n assert_equal(@room.type_of_room, \"Emperor Suite\")\n end", "def checkroom(r)\n case r.status\n when :plan\n # moot\n when :dig\n # designation cancelled: damp stone etc\n r.dig\n when :dug, :finished\n # cavein / tree\n r.dig\n # tantrumed furniture\n r.layout.each { |f|\n next if f[:ignore]\n if f[:bld_id] and not df.building_find(f[:bld_id])\n df.add_announcement(\"AI: fix furniture #{f[:item]} in #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = [r.x1+f[:x].to_i, r.y1+f[:y].to_i, r.z1+f[:z].to_i] }\n f.delete :bld_id\n @tasks << [:furnish, r, f]\n end\n }\n # tantrumed building\n if r.misc[:bld_id] and not r.dfbuilding\n df.add_announcement(\"AI: rebuild #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = r }\n r.misc.delete :bld_id\n construct_room(r)\n end\n end\n end", "def test_connection\n open_session.folders\n end", "def test_locations_of_fourth_ave\n\t\tassert_equal \"Cathedral\", @road2.locations[0]\n\tend", "def test_application_session_as_directory\n assert_pattern_match [ \"/\", \"index.vwf\", \"0000000000000000\", nil ], \"/0000000000000000/\"\n assert_pattern_match [ \"/\", \"component.vwf\", \"0000000000000000\", nil ], \"/component.vwf/0000000000000000/\"\n assert_pattern_match [ \"/directory\", \"index.vwf\", \"0000000000000000\", nil ], \"/directory/0000000000000000/\"\n assert_pattern_match [ \"/directory\", \"component.vwf\", \"0000000000000000\", nil ], \"/directory/component.vwf/0000000000000000/\"\n end", "def player_can_path_through? player, x,y\n can_path_through(x,y) && \n !(units.reject{|v| v.player ==player}.find{|v| v.location == [x,y]})\n end", "def path\n Especie.where(id: path_ids)\n end", "def test_folders\n assert_equal(['folder1'], cmk.folders)\n end", "def test_movement_check_one_way\r\n\t\tdriver = Driver::new(\"Driver 1\")\r\n\t\thospital = Location::new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location::new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location::new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\r\n\t\thospital.new_one_way cathedral\r\n\t\thospital.new_two_way museum\r\n\r\n\t\tdriver.current_location(hospital)\r\n\t\tdriver_move(driver, 0)\r\n\t\tassert_equal cathedral, driver.location\r\n\tend", "def test_room_starts_empty_of_guests()\n assert_equal(0, @room1.guest_count())\n end", "def find_path(goal) \n \n end", "def valid_path?(x,y)\n puts \"This method needs to be defined in the piece's Unique Class;\\ne.g. for the Queen piece, edit the Queen Class in queen.rb\"\n end", "def test_add_guest__exist_in_room()\n @room1.add_guest(@guest1)\n @room1.add_guest(@guest1)\n assert_equal(1,@room1.guests.count())\n end", "def spawn(player_room)\n # get all possible paths and create a hash indexed by size\n paths_to_player = self.rooms.inject({}) do |hsh, room|\n path = self.class.grue_path(room, player_room, self.edges)\n hsh[path.size] = path\n hsh\n end\n\n # get the longest of the shortest paths\n # (this is as far away as we can get)\n longest_path = paths_to_player[paths_to_player.keys.max]\n\n # get the first element of the first edge\n self.current_room = longest_path.first.first\n end", "def test_check_in_group_to_room()\n @room.check_in(@group2)\n assert_equal(1, @room.karaoke_room_occupied())\n end", "def test_all\n coords = all_combos\n coords.each do |c|\n find_route(c[0], c[1])\n end\nend", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def test_get_guests\n @room.add_guest(@guest1)\n @room.add_guest(@guest2)\n assert_equal([\"Kylie\",\"Janis\"],@room.get_guests)\n end", "def path(*) end", "def test_room_at_capacity__return_false_you_may_enter\n @room.add_guest_to_room(@guest1)\n assert_equal(\"Come on in\", @room.room_at_capacity())\n end", "def test_application_session_with_public_path\n assert_pattern_match [ \"/\", \"index.vwf\", \"0000000000000000\", \"file.ext\" ], \"/0000000000000000/file.ext\"\n assert_pattern_match [ \"/\", \"component.vwf\", \"0000000000000000\", \"file.ext\" ], \"/component.vwf/0000000000000000/file.ext\"\n assert_pattern_match [ \"/directory\", \"index.vwf\", \"0000000000000000\", \"file.ext\" ], \"/directory/0000000000000000/file.ext\"\n assert_pattern_match [ \"/directory\", \"component.vwf\", \"0000000000000000\", \"file.ext\" ], \"/directory/component.vwf/0000000000000000/file.ext\"\n end", "def testBuildSingleDeliverableHierarchicalID_ObjectPath\n setRepository('UniqueDeliverableHierarchicalID') do |iRepoDir|\n runFSCMS(['Build', '--', '--target', 'TestType/TestID/SubTestID/SubSubTestID'])\n lBuiltFileName = \"#{iRepoDir}/TestType/TestID/SubTestID/SubSubTestID/0.1/Deliverables/TestDeliverable/BuiltFile\"\n assert(File.exists?(lBuiltFileName))\n File.open(lBuiltFileName, 'r') do |iFile|\n assert_equal($FSCMSTest_RepositoryToolsDir, iFile.read)\n end\n end\n end", "def test_find_path_to_goal_1\n w = 6\n h = 6\n walls = [Position.new(1, 3), Position.new(2, 3), Position.new(3, 3), Position.new(3, 2),\n Position.new(3, 5), Position.new(4, 5), Position.new(5, 5), Position.new(5, 3),\n Position.new(6, 5), Position.new(6, 3)]\n start = Position.new(1, 1)\n goal = Position.new(5, 6)\n maze = Maze.new(w, h, walls, start, goal)\n path_to_goal = maze.find_path_to_goal\n outcome = [Position.new(1, 1), Position.new(1, 2), Position.new(2, 2), Position.new(2, 1),\n Position.new(3, 1), Position.new(4, 1), Position.new(4, 2), Position.new(4, 3),\n Position.new(4, 4), Position.new(3, 4),\n Position.new(2, 4), Position.new(2, 5), Position.new(2, 6), Position.new(3, 6),\n Position.new(4, 6), Position.new(5, 6)]\n assert_equal outcome.size, path_to_goal.size\n\n assert_equal outcome, path_to_goal\n end", "def test_add_playlist_to_rooms_karaoke_machine\n @room.add_playlist(@playlist)\n assert_equal(1, @room.room_playlist())\n end", "def test_room_has_room_number()\n assert_equal(1, @room.room_number())\n end", "def grue_path(grue_room, player_room, edges)\n shortest_path = []\n\n edges_to_check = edges.select do |arr|\n arr.first == grue_room\n end\n\n unchecked_edges = edges - edges_to_check\n\n edges_to_check.each do |e|\n path = [e]\n if e[1] != player_room\n\n next_node = (e - [grue_room]).first\n\n remaining_path = grue_path(next_node, player_room, unchecked_edges)\n\n if remaining_path.empty?\n path.clear\n else\n path += remaining_path\n end\n else\n path\n end\n\n if path_distance(path) < path_distance(shortest_path)\n shortest_path = path\n end\n end\n\n shortest_path\n end", "def by_path(path); end", "def test_guest_song_on_playlist\n assert_equal(true, @room1.check_song_on_playlist(@playlist,@guest2))\n end", "def test_try_add_guest_to_room\n @room1.add_guest_to_room(@guest1)\n assert_equal(1,@room1.guest_count)\n end", "def test_movement_check_two_way\r\n\t\tdriver = Driver::new(\"Driver 1\")\r\n\t\thospital = Location::new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location::new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location::new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\r\n\t\thospital.new_one_way cathedral\r\n\t\thospital.new_two_way museum\r\n\r\n\t\tdriver.current_location(hospital)\r\n\t\tdriver_move(driver, 1)\r\n\t\tassert_equal museum, driver.location\r\n\tend", "def initialize\n \t@grid_w = 50\n \t@grid_h = 40\n \t@grid = []\n\t\n\t\t@player_x = 0\n\t\t@player_y = 0\n\t\t@has_enviroment_rendered=false\n\t\t#setup and fill grid with walls\n \t@grid_w.times.with_index do |x|\n \t\t@grid[x] = []\n\t\t\t@grid_h.times.with_index do |y|\n \t\t\t@grid[x][y]= 1\n \t \tend\n \tend\n\t\tmin_rooms = 2\n\t\tmax_rooms = 10\n\t\t#setup number of rooms that will exist\n\t\t@n_rooms = rand(max_rooms - min_rooms) + min_rooms\n\t\tputs \"n rooms #{@n_rooms}\"\n\t\trooms = []\n\t\t#define the size of each room\n\t\t@n_rooms.times.with_index do |room|\n\t\t\trooms[room] = make_room 8,10\n\t\tend\n\t\n\t\t#clears the walls from where rooms will be \n\t\trooms.each_with_index do |r,i| \n\t\t\t(r[:x]..r[:x] + r[:w]).each do |x|\n\t\t\t\t(r[:y]..r[:y] + r[:h]).each do |y|\n\t\t\t\t\t@grid[x][y]= 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#create pathways towards the next room\n\t\trooms.each_cons(2) do |(cur_room, next_room)|\n\t\t\t#find the center of each room \n\t\t\tcenter_x = cur_room[:x] + cur_room[:w].idiv(2)\n\t\t\tcenter_y = cur_room[:y] + cur_room[:h].idiv(2)\n\n\t\t\tnext_center_x = next_room[:x] + next_room[:w].idiv(2)\n\t\t\tnext_center_y = next_room[:y] + next_room[:h].idiv(2)\n\n\t\t\t#loops between each rooms X and Y positions \n\t\t\t#this can be approached differently\n\t\t\t(min(center_x,next_center_x)..max(center_x,next_center_x)).each do |x|\n\t\t\t\t(min(center_y,next_center_y)..max(center_y,next_center_y)).each do |y|\n\t\t\t\t\t#checking if this position is in-line with either rooms x or y centres\n\t\t\t\t\t@grid[x][y] = 0 if y == center_y || y == next_center_y || x == center_x || x == next_center_x\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@new_grid = []\n\t\t#set new grid to prune unneeded walls to improve performance\n\t\t@grid_w.times.with_index do |x|\n\t \t@new_grid[x] = []\n\t \t@grid_h.times.with_index do |y|\n \t\t\t@new_grid[x][y]= @grid[x][y]\n\t\t\tend\n\t end\n\t\t#set up values\n\t\t@grid_w.times.with_index do |x|\n \t\t@grid_h.times.with_index do |y|\n\t\t\t\t#if surrounded it should not be filled in\n\t\t\t\tif check_surrounding_tiles x,y\n\t\t\t\t\t@grid[x][y] = 0\n\t\t\t\tend\n \t\tend\n \tend\n\t\t#this will set the players starting position to a known safe area\n\t\t@player_x = rooms[0][:x] + rooms[0][:w].idiv(2)\n\t\t@player_y = rooms[0][:y] + rooms[0][:h].idiv(2)\n\t\t@grid[@player_x][@player_y] = 2\n\tend", "def test_new_location\n\t\t@new_driver.location 'Cathedral'\n\t\tassert_equal 'Hillman', @new_driver.location('Hillman')\n\tend", "def test_location_2\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 2, locations)\r\n\t\tassert_equal cathedral, driver.location\r\n\tend", "def path\n @game_info['path']\n end", "def spec_dirs; end", "def test_driver_checkLocation_mid\n\t\td = Driver::new(\"Driver 1\",1)\n\t\td.checkLocation\n\t\t# assert_equal d.classes, 2\n\t\td.setLocation 1 #from cathedral go to museum\n\t\td.checkLocation\n\t\tassert_equal [2,1], [d.classes,d.dinotoys]\n\t\t#assert_equal d.dinotoys, 1\n\tend", "def test_folder\n assert_not_nil(cmk.folder('folder1'))\n end", "def path\n end", "def path\n end" ]
[ "0.712498", "0.6654616", "0.60118854", "0.60033345", "0.58961827", "0.5893172", "0.58754987", "0.5729186", "0.5726042", "0.5669198", "0.5629313", "0.56133276", "0.56133276", "0.56133276", "0.56133276", "0.56133276", "0.5610616", "0.55882484", "0.55882484", "0.55882484", "0.5577218", "0.5575446", "0.5561461", "0.5518583", "0.5509536", "0.5494109", "0.5494109", "0.5490661", "0.5488149", "0.5486172", "0.5424139", "0.54239655", "0.5404281", "0.53964305", "0.5391715", "0.5367292", "0.5356119", "0.5355996", "0.5354284", "0.53527486", "0.5344837", "0.53278285", "0.53267723", "0.5323013", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.53112394", "0.5305538", "0.5297009", "0.5296453", "0.5276778", "0.5270216", "0.5262096", "0.5261817", "0.52611756", "0.5258291", "0.5254251", "0.5254177", "0.5249788", "0.52379197", "0.5226845", "0.5226263", "0.52241117", "0.52211565", "0.5220638", "0.5218998", "0.52136636", "0.5209773", "0.5209773" ]
0.80948585
0
Returns the name of the company
def employee_name @employee_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def company_name\t\t\t# Getter method - return nil if name is not found\n\t\tcompany.try(:name)\n\tend", "def company_name\n @company_name\n end", "def name\n company.blank? ? full_name : \"#{company} (#{full_name})\"\n end", "def company_name\n element_with_value('CompanyName', opts[:company_name])\n end", "def company_name\n element_with_value('CompanyName', opts[:company_name][0..34])\n end", "def company_name\n @company_name\n end", "def company_name\n object.company.name\n end", "def name\n company.blank? ? full_name : \"#{company} (#{full_name})\"\n end", "def company_name\n self.companies.count > 0 ? self.companies.first.title : ''\n end", "def company_name\n account.name if account\n end", "def name\n self.company.name unless company.nil?\n end", "def company_name\n self.dig_for_string(\"agentSummary\", \"office\", \"companyName\")\n end", "def user_company\n if Client.find_by_id(current_user.client_id)\n Client.find_by_id(current_user.client_id).client_name\n end\n end", "def company_name\n quote.name\n end", "def customer_name\n company.blank? ? full_name : \"#{company} (#{full_name})\"\n end", "def customer_name\n company.blank? ? full_name : \"#{company} (#{full_name})\"\n end", "def name\n \"#{id}-#{company_name}\"\n end", "def current_company_name\n begin\n Client.find(current_subdomain).webname\n rescue\n \"\"\n end\n end", "def name\n latest_ccla_signature.company\n end", "def company_name\n self.well_info.company_name\n end", "def company_name\n Faker::Company.name\n end", "def company_name\n Faker::Company.name\n end", "def account_name\n return company.company_name unless company.nil? || company.company_name.nil?\n\n [forename, surname].join(' ')\n end", "def get_Company(name=nil)\n\n getElement_text(\"cust_vendors\").click\n\n getElement_text(\"Customers\").click\n\n if(name!=nil)\n getElement_text_direct(name).click\n else\n getElement_text(\"company_name_data\").click\n end\n end", "def name\n if person?\n \"#{lastname}, #{firstname}\"\n else\n company_name\n end\n end", "def billing_name\n company.blank? ? full_name : \"#{full_name} (#{company})\"\n end", "def company\n @attributes[:company]\n end", "def company_name(company_name, direction = :push)\n if direction == :push\n company_name[0..82]\n else\n company_name\n end\n end", "def shipper_name\n element_with_value('Name', opts[:company_name])\n end", "def company\n @company ||= research_param(:company) || company_list.first\n end", "def company_name\n name.left_name\nend", "def current_company\n Company.find(1)\n end", "def competitor_name(competitor_id)\n comp = Competitor.find_by_id(competitor_id)\n name = comp.name\n return name\n end", "def describe_company(company)\n signed_get(COMPANIES_PATH, escape(company))\n end", "def getcompany\n Company.company_than(need_calc_company)\n end", "def to_s\n company\n end", "def list_portfolio_companies\n self.companies.map do |company_instance|\n company_instance.name\n end\n end", "def company\n alliance_company\n end", "def company_code\n if self.yard.present? && self.yard.facility.present? && self.yard.facility.country.present?\n country = self.yard.facility.country\n \"COPART#{country.code}\".upcase\n else\n \"\"\n end\n end", "def comp_2_name\n comp = Competitor.find_by_id(self.comp_id_2)\n name = comp.name\n return name\n end", "def company\n response = JSON.parse(@client.get(\"users/#{send(:id)}/companies\").body)\n Promisepay::Company.new(@client, response['companies'])\n rescue Promisepay::NotFound\n nil\n end", "def service_company\n self.well_info.service_company\n end", "def task_name_company\n [executor.try(:profile).try(:first_name), executor.try(:profile).try(:last_name), executor.try(:profile).try(:company)].join(' ')\n end", "def task_name_company\n [executor.try(:profile).try(:first_name), executor.try(:profile).try(:last_name), executor.try(:profile).try(:company)].join(' ')\n end", "def getorganizationname()\r\n return getvalue(SVTags::ORGANIZATION_NAME)\r\n end", "def get_name(org_guid)\n org = @client.organization(org_guid)\n org.name\n end", "def org_name\n (org = self.organization) && org.name\n end", "def get_company\n @company ||= current_company\n end", "def set_company_name\n @company_name = CompanyName.find(params[:id])\n end", "def set_CompanyName(value)\n set_input(\"CompanyName\", value)\n end", "def current_company\n Company.find(:first)\nend", "def con_name\n @data_object.con_first_name.to_s +\n \" \" +\n @data_object.con_last_name.to_s\n end", "def name\n return @person_name if @person_name\n\n if @key_names\n if @names_before_key\n return \"#{@names_before_key} #{@key_names}\"\n else\n return @key_names\n end\n end\n\n @corporate_name\n end", "def get_campus_name(doc)\n admin_set = doc.admin_set.title.first.to_s\n Hyrax::CampusService.get_campus_from_admin_set(admin_set)\n end", "def name\n name_business\n end", "def current_company\n current_user ? current_user.company : nil\n end", "def company_id\n if @company.respond_to?(:to_hash)\n @company.fetch(:company_id) { @company }\n elsif @company.respond_to?(:company_id)\n @company.company_id\n else\n @company\n end\n end", "def get_contact_name(page)\n page.css(WebScraper::JOB_DETAILS_SELECTOR)[WebScraper::JOB_CONTACT_NAME_POS].content.strip\n end", "def identificacion_company\n \"#{type_identification}-#{rif}\"\n end", "def org_name\n raw_info['org_name']\n end", "def lookup(company)\n cfpb_name = fuzzy_cfpb_lookup(company).first || {}\n iex_name = match_cfpb_to_iex(cfpb_name) || {}\n\n { cfpb: cfpb_name['name'], iex: iex_name['name'] }\n end", "def org_name\n self.org.try(:name).to_s\n end", "def organisation_name_fetch\n @organisation.try(:organisation_name)\n end", "def name_with_locations\n \"#{self.location_one} - #{self.location_two} - #{self.priority} - \" + Company.find(self.company_id).company_name\n end", "def contract_term_name\n unless self.contract_term_id and self.contract_term\n return 'Unknown term'\n end\n return self.contract_term.name\n end", "def company\n @company ||= Company.find(params[:id])\n end", "def comune_name(comune_metadata)\n # Italian name takes precedence for multi-language names\n comune_metadata['name:it'] || comune_metadata['name']\n end", "def update_company company_name\n if self.valid?\n unless company_name.nil?\n company_name = company_name.strip\n if company_name.blank?\n self.company_id = 0\n self.company_name = ''\n else\n company = Company.find_or_create_by_name company_name\n unless company.id == self.company_id\n self.company_id = company.id\n self.company_name = company.name\n end\n end\n end\n end\n end", "def name\n self.compra.name\n end", "def search_company(name = \"\", limit = 50)\n\t\[email protected]_company(name, limit)\n\tend", "def current_company() # :doc:\n current_user.full?(&:company)\n end", "def company; end", "def company; end", "def org_name(item:)\n return '' unless item.present? && item['name'].present?\n\n country = item.fetch('country', {}).fetch('country_name', '')\n website = org_website(item: item)\n # If no website or country then just return the name\n return item['name'] unless website.present? || country.present?\n\n # Otherwise return the contextualized name\n \"#{item['name']} (#{website || country})\"\n end", "def company_information(params)\n get('company-information',params)\n end", "def company_name_beta(companies)\n companies.find do |company|\n if company.name == 'Beta'\n company\n end\n end \nend", "def company_info(company_id, *fields)\n get(\"/organizations/#{company_id}#{field_selector(fields)}\")\n end", "def current_company\n @current_company = current_user.company\n end", "def company\n if teacher? || !self.group\n return nil\n else\n self.group.company\n end\n end", "def full_name\n return \"\" if self.curriculum_core.blank?\n \"#{self.curriculum_core.name}, #{self.name}\"\n end", "def guess_company_domain\n if self.company_domain.blank?\n string = self.company_name.to_s.downcase.gsub(' ', '') + \".fr\"\n self.company_domain = string\n end\n end", "def company_name=(company_name)\n if !company_name.nil? && company_name.to_s.length < 0\n fail ArgumentError, 'invalid value for \"company_name\", the character length must be great than or equal to 0.'\n end\n\n @company_name = company_name\n end", "def suffix\n fetch('company.suffix')\n end", "def company\n @company ||= Harvest::API::Company.new(credentials)\n end", "def name\n fetch('bank.name')\n end", "def company_info\n company_info ||= CompanyLeave.for_company(company).first\n end", "def company_name=(company_name)\n if company_name.nil?\n fail ArgumentError, 'company_name cannot be nil'\n end\n\n if company_name.to_s.length < 1\n fail ArgumentError, 'invalid value for \"company_name\", the character length must be great than or equal to 1.'\n end\n\n @company_name = company_name\n end", "def name\n if self[:name].blank?\n (self[:email] || \"\").split('@')[0].split('.').map(&:capitalize).join(' ')\n else\n self[:name]\n end\n end", "def display_name\n @name.capitalize.freeze\n end", "def acct_name\n @name\n end", "def app_company\n 'BarkerEST'\n end", "def organisation_name\n return if partnership?\n\n organisation.name\n end", "def company_number\n 1\n end", "def name\n return @poco_data[:name] unless @poco_data == nil\n pick_first_node(@poco.xpath('./poco:name'))\n end", "def display_name\n name\n end", "def get_name()\n return @me.uname if @me.brother.nil?\n return @me.brother.full_name\n end", "def name\n @trading_name || @other_trading_name || @main_name || @legal_name || @legal_name2 || 'Name unknown'\n end", "def carwash_city_name\n\t\t\tobject.city.name\n\t\tend", "def company=(v)\n Axlsx.validate_string v\n @company = v\n end", "def org_name\n test_org.name\n end", "def find_company_id(name)\n @company = Company.find_or_create_by(name: name)\n @company.id\n end" ]
[ "0.86295986", "0.8539934", "0.8473931", "0.8299938", "0.8276819", "0.8212174", "0.8108807", "0.8044838", "0.79729766", "0.7822352", "0.77791184", "0.7730765", "0.7670152", "0.7627004", "0.7617805", "0.7617805", "0.7617035", "0.76146644", "0.75624", "0.75319386", "0.7505568", "0.7505568", "0.739196", "0.739059", "0.7333141", "0.72738785", "0.7164921", "0.7145008", "0.6950085", "0.6937891", "0.68836397", "0.68093264", "0.67910683", "0.6766147", "0.6755382", "0.666864", "0.66144836", "0.66031176", "0.6597247", "0.65896106", "0.65886545", "0.65390235", "0.6535043", "0.6535043", "0.6514398", "0.6460883", "0.6458541", "0.64322877", "0.64307326", "0.6423092", "0.6416154", "0.64138687", "0.63534755", "0.6338864", "0.6334975", "0.63222086", "0.62894", "0.62817395", "0.62698096", "0.6265759", "0.6258977", "0.6255006", "0.6245106", "0.6237154", "0.6234018", "0.6227723", "0.62265056", "0.6220723", "0.6220648", "0.6218893", "0.6214137", "0.6205403", "0.6205403", "0.61953354", "0.61911243", "0.6178485", "0.6164854", "0.6159888", "0.6151731", "0.61475796", "0.6147358", "0.6146866", "0.61381906", "0.61339855", "0.6110162", "0.61082435", "0.61022204", "0.6080084", "0.6077117", "0.6076651", "0.6070602", "0.6068541", "0.6048187", "0.6046496", "0.60455793", "0.6035699", "0.6027085", "0.6016064", "0.60149586", "0.6011088", "0.6004618" ]
0.0
-1
Try writing the above program without using the sort method. A large part of programming is solving problems, so get all the practice you can!
def sort_array2 arr = [] begin puts "Please give me a word." ans = gets.chomp arr << ans end while ans != '' new_arr = [] n = arr.length for i in 1..n new_arr << arr.min arr.delete(arr.min) end puts new_arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sorting(arr)\n#display orig array\n p arr \n p \"**************************************************\"\n # do something to the array\n # compare each value of an array to the value on its left\n # if the value is less than the value on its left, switch places\n # do this by placing the lesser value in a holder and then moving the greater\n # value to the lesser value's former position in the array, then rewrite the\n # greater value's former position, with the holder value.\n # do this until the value is greater than the value on its left for \n # the entire array \n#Here is our brute force attempt at making our own .sort! method\n#we used the .sort! method from the Array class.\narr.length.times do\n |x|\n holder = \"\"\n if arr[x] > arr[x-1]\n holder = arr[x-1]\n arr[x-1] = arr[x]\n arr[x] = holder\n end \n end\nputs \"this is the one we made #{arr} \"\n # if arr[1] > arr[0]\n p arr.sort!\n p \"above is the sorting method\"\n#rerturn the changed array\nend", "def bigSorting(unsorted)\n\nend", "def sorting(numbers)\n numbers.sort\nend", "def sean_sort(numbers)\n\n\nend", "def solution(nums)\n nums.to_a.sort\nend", "def print_funny_sort(arr)\r\n\tprint \"\\nOriginal: \"\r\n\tprint arr\r\n\tprint \"\\nSorted: \"\r\n\tprint funny_sort(arr)\r\n\tprint \"\\n\"\r\nend", "def sort1(array)\n\nend", "def array_sort(arr)\nx = arr.length\nif x == 1\nelsif x == 2\n if arr[0] > arr[1]\n arr[0], arr[1] = arr[1], arr[0]\n end\nelse\n loop do\n modified = FALSE\n (x-2).times do |x|\n if (arr[x] < arr[x + 1]) && (arr[x] < arr[x + 2])\n if arr[x + 2] < arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x], arr [x + 2], arr[x + 1]\n modified = TRUE\n end\n elsif (arr[x + 1] < arr[x]) && (arr[x + 1] < arr[x + 2])\n if arr[x] < arr[x + 2]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr[x], arr[x + 2]\n modified = TRUE\n elsif arr[x + 2] < arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr [x + 2], arr[x]\n modified = TRUE\n elsif arr[x + 2] == arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr[x], arr[x + 2]\n modified = TRUE\n end\n elsif (arr[x + 2] < arr[x]) && (arr[x + 2] < arr[x + 1])\n if arr[x] < arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x], arr[x + 1]\n modified = TRUE\n elsif arr[x + 1] < arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x + 1], arr[x]\n modified = TRUE\n elsif arr[x] == arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x], arr[x + 1]\n modified = TRUE\n end\n end\n end\n break if modified == FALSE\n end\nend\n arr\nend", "def rec_sort unsorted, sorted \n\tif unsorted.length <= 0\n\n# sorted is an array\n\treturn sorted \n\tend\n\n# So if we got here, then it means we still have work to do.\n# take last one out of unsorted, call it smallest\nsmallest = unsorted.pop\n#create en empty 'still unsorted' array \nstill_unsorted = []\n\n#testing if each object in unsorted is smaller than 'smallest' \n\tunsorted.each do |tested_object| \n\t#if tested object is smaller than smallest then push them in still unsorted\n\t\tif tested_object.downcase < smallest.downcase\n\t\t\tstill_unsorted.push smallest\n\t\t\tsmallest = tested_object\n\t\telse\n\t\t\tstill_unsorted.push tested_object\n\t\tend \n\tend\n# Now \"smallest\" really does point to the\n# smallest element that \"unsorted\" contained,\n# and all the rest of it is in \"still_unsorted\". \nsorted.push smallest\n\nrec_sort still_unsorted, sorted\nend", "def mothrah_sort (an_array)\n\tdef move_to_end (value, array)\n\t\tarray.delete(value)\n\t\tarray.push(value)\n\tend\n\tpos = 0\n\twhile pos < an_array.length \n\t\tif an_array[pos] > an_array[pos + 1]\n\t\t\tmove_to_end(an_array[pos], an_array)\n\t\telse\n\t\t\tpos += 1\n\t\tend\n\tend\n\tan_array\nend", "def sort(array)\nfor j in 1..(array.length-1) #Sets loop parameter to count between 1 and length instead of starting at zero\n compare = array[j]\n i = j - 1\n while i >= 0 and array[i] > compare\n array[i+1] = array[i]\n i = i - 1\n end\n array[i+1] = compare\nend \nputs array\nend", "def test_funny_sort(arr)\n\tputs \"The initial array is: #{arr.to_s}\"\n\tsortedtest = funny_sort(arr)\n\tputs \"The funny sorted array is: #{sortedtest.to_s}\\n\\n\"\nend", "def sort(num_array)\n # Your code goes here\n (num_array.length).times do |i|\n while i > 0\n if num_array[i-1] > num_array[i] \n num_array[i-1], num_array[i] = num_array[i], num_array[i-1]\n else\n break\n end\n i-=1\n end\n \n end\n return num_array\n \nend", "def puzzle_5\n arr = 10.times.map{ 55 + Random.rand(46) }\n puts arr.sort!\n puts arr.first\n puts arr.last\nend", "def using_sort(array)\narray.sort\nend", "def using_sort(array)\narray.sort\nend", "def buuble_sort(arr)\n\tloop do\n\t\tloop_break = true\n\t\t(arr.length-1).times do |i|\n\t\tif arr[i]>arr[i+1]\n\t\t\tarr[i], arr[i+1] = arr[i+1], arr[i]\n\t\t\tloop_break = false\n\t\tend\n\t\tend\n\tbreak if loop_break\n\tend\n\tputs arr\nend", "def five_sort(nums)\n i = 0\n sorted = false\n while !sorted\n sorted = true\n while i < nums.length - 1\n if nums[i] == 5 && nums[i + 1] != 5\n # p \"SWAPPING i: #{i}, nums[i]: #{nums[i]}, nums[i + 1]: #{nums[i + 1]}\"\n nums[i], nums[i + 1] = nums[i + 1], nums[i]\n sorted = false\n end\n i += 1\n end\n i = 0\n end\n nums\nend", "def gnomesort(a)\n a.start_logging\n\n i = 0\n while i < a.length\n if i == 0 || a[i] > a[i - 1]\n i += 1\n else\n a[i], a[i - 1] = a[i - 1], a[i]\n a.log\n i -= 1\n end\n end\n\n a\nend", "def sort3(collection)\n # p \"sort 3\"\n # p collection\n collection[1..-1].each_with_index do |el, i|\n k = i + 1\n # p \"*********** i is: #{i} ************\"\n while collection[k] < collection[k-1]\n # p \"k is: #{k}\"\n # p \"swapping #{collection[k]} with #{collection[k-1]}\"\n collection[k], collection[k-1] = collection[k-1], collection[k]\n # p collection\n # p \"subtracting 1 from k\"\n k -= 1\n break if k == 0\n end\n end\n collection\nend", "def sort(numbers)\n n = numbers.length\n for j in 1..(n - 1)\n highest = numbers[j]\n i = j - 1\n while i >= 0 and numbers[i] > highest\n numbers[i+1] = numbers[i]\n i = i - 1\n end\n numbers[i+1] = highest\n end\n numbers = numbers.uniq\n numbers = numbers.reverse\n if numbers.length < 2\n puts \"First highest number is #{numbers[0]}!\"\n else\n puts \"Second highest number is #{numbers[1]}\"\n end\nend", "def rec_sort(unsorted, sorted)\n if unsorted.length <= 0\n return sorted\n end\n\n=begin\nif the arr passed through the rec_sort method has a length of 0 or negative,\nreturn the empty array\n=end\n\n smallest = unsorted.pop\n still_unsorted = []\n\n#smallest variable pops the last object of the unsorted array\n#storing an empty array to the variable still_unsorted\n\n unsorted.each do |tested_object|\n if tested_object.downcase < smallest.downcase\n# this will ignore if the word is capitalized or not when sorting\n still_unsorted.push(smallest)\n smallest = tested_object\n else\n still_unsorted.push(tested_object)\n end\n end\n\n=begin\nwe are passing each element of the array to the each method. If the first element\nof the array comes before the last element of the array, we push that last element\ninto the still_unsorted array. Else we push the first element into the\nstill_unsorted array. The last element has been popped out of the array.\nthis is to find the smallest element which will be stored into the smallest\nvariable\n=end\n\n sorted.push(smallest)\n\n#once we find the smallest word, we push it in to the sorted array\n\n rec_sort(still_unsorted, sorted)\n\n=begin\nthen we recursively repeat the process with the still_unsorted array and push\nthe smallest word into the sorted array, until we pushed them all in the sorted\narray\n=end\nend", "def dub_sort(arr)\nend", "def sort_array(source_array)\n odd=[]\n nArr=[]\n for x in source_array do\n if x != 0 && x % 2 != 0\n odd.push(x)\n end\n end\n odd.sort!\n i=0\n for x in source_array do\n if x != 0 && x %2 != 0\n nArr.push(odd[i])\n i += 1\n else\n nArr.push(x)\n end\n end\n p nArr\nend", "def funny_sort(array)\n\tputs array.sort{ |a, b| findEarliestDigits(a) <=> findEarliestDigits(b) }\nend", "def sort(q)\n person = 0\n for i in 0...(q.length - 1)\n temp = q[i]\n if q[i] > q[i+1]\n q[i] = q[i+1]\n q[i+1] = temp\n person = temp\n break\n end\n end\n\n return person, q\nend", "def sort!\n\t\tquick!(self, 1, length)\n\tend", "def shell_sort(a)\n i = 0\n j = 0\n size = a.length\n increment = size / 2\n temp = 0\n \n while increment > 0\n i = increment\n while i<size\n j = i\n temp = a[i]\n while j>=increment and a[j-increment]>temp\n a[j] = a[j-increment]\n j = j-increment\n end\n a[j] = temp\n i+=1\n end\n if increment == 2\n increment = 1\n else\n increment = (increment/2).to_i\n end\n end\n return a\nend", "def non_comparison_sort(arr)\n result = []\n i = 1 \n while i <= arr.length \n result << i \n i+=1\n end \n p result \nend", "def sort2(num_array)\n n = num_array.length - 1\n for i in 0..n\n for j in 0..(n-i-1)\n if num_array[j] >= num_array[j+1]\n num_array[j], num_array[j+1] = num_array[j+1], num_array[j]\n end\n end\n end\n return num_array\nend", "def sort2(collection)\n # p \"sort 2\"\n # p collection\n collection[1..-1].each_with_index do |el, i|\n k = i + 1\n # p \"******/***** i is: #{i} ************\"\n until collection[k] > collection[k-1] or k == 0\n # p \"k is: #{k}\"\n # p \"swapping #{collection[k]} with #{collection[k-1]}\"\n collection[k], collection[k-1] = collection[k-1], collection[k]\n # p collection\n # p \"subtracting 1 from k\"\n k -= 1\n end\n end\n collection\nend", "def poorly_written_ruby(*arrays)\n combined_array = []\n\n arrays.each do |array|\n combined_array.concat(array)\n end\n \n def quick_sort(collection)\n return collection if collection.length <= 1\n pivot = collection.sample\n\n left = Array.new\n right = Array.new\n\n collection.each do |x|\n if x <= pivot\n left << x\n else\n right << x\n end\n end\n\n quick_sort(left) + quick_sort(right)\n\n end\n\n def buckethash_sort(collection)\n\n buckets = Hash.new\n\n (\"A\"..\"Z\").each do |x|\n buckets[x] = Array.new\n end\n\n collection.each do |x|\n if buckets.key?(x[0])\n buckets[x[0]] << x\n end\n end\n\n buckets.each_key do |key|\n buckets[key] = quick_sort(buckets[key])\n end\n\n buckets.values.flatten\n\n end\n\n buckethash_sort(combined_array)\n\nend", "def sort(arr)\n\tnew_arr = arr.sort\n\tp new_arr\nend", "def sort(a)\n\t\n\tfor i in 1...a.length\n\n\ttemp=a[i]\n\tj=i-1\n\tx=bsearch(a,temp,0,j)\n\n\twhile j>=x do\n\ta[j+1]=a[j]\n\tj-=1\n\tend #This is for the while loop\n\ta[j+1]=temp\n\tend\n\n\tend", "def grand_sorting_machine(array)\n\n\n\nend", "def sorting(array)\n\t#start with an empty array where newly sorted elements from the input will go\n\tsorted_array = []\n\n\t#while there is at least one element in the passed in array execute the loop\n\twhile array.length > 0\n\t\t#start with these initial values\n\t\tcount = 1\n\t\tminIndex = 0\n\t\t#this ensures that count will never exceed the number of elements in the inputted array\n\t\twhile count < array.length\n\t\t\t#compare using index values of the array elements starting with array[0] and array[1]\n\t\t\t#compares words in their lowercase form, otherwise capitalized letters would come before lowercase ones, despite alphabetical order\n\t\t\t#the downcase method just temporarily changes the value of the element during comparison, then they retain their capitalized form in the output\n\t\t\tif array[minIndex].downcase > array[count].downcase\n\t\t\t\t#if the preceding element of the inputted array is a word that comes after the following element\n\t\t\t\t#set minIndex (the smallest index value of the array) equal to the count value\n\t\t\t\tminIndex = count\n\t\t\tend\n\t\t\t#add 1 to count so that the while loop will eventually finish\n\t\t\tcount += 1\n\t\tend\n\t\t#now, the array element with minIndex is the smallest value so it is safe to push it to our sorted_array\n\t\tsorted_array.push(array[minIndex])\n\t\t#then delete the smallest element from the inputted array so that the next iteration will be the next smallest element\n\t\tarray.delete_at(minIndex)\n\tend\n\tputs sorted_array\nend", "def using_sort(array)\n array.sort\nend", "def using_sort(array)\n array.sort\nend", "def using_sort(array)\n array.sort\nend", "def sorter(arr)\n\nreturn arr if arr.length <= 1\n\nnot_sorted = true\n\n while not_sorted\n not_sorted = false\n (arr.length-1).times do |i|\n if arr[i] > arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n not_sorted = true\n p arr\n p \"swap occurred\"\n end\n end\n end\n arr\nend", "def sorter(arr)\n\nreturn arr if arr.length <= 1\n\nnot_sorted = true\n\n while not_sorted\n not_sorted = false\n (arr.length-1).times do |i|\n if arr[i] > arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n not_sorted = true\n p arr\n p \"swap occurred\"\n end\n end\n end\n arr\nend", "def orderly(array)\n p array.sort\nend", "def sort(array)\n array.each_index do |i|\n (array.length - i - 1).times do |job|\n if array[cownt] > list[cownt + 1]\n array[cownt], array[cownt + 1] = array[cownt + 1], array[cownt]\n end\n end\n end\nend", "def rec_sort unsorted, sorted\n if unsorted.length <= 0\n return sorted\n end\n#\n#start smallest using 'pop' word and move to sorted list\nsmallest = unsorted.pop\nstill_unsorted = []\n#if tested word from unsorted is less then put\n#smallest into still_unsorted and move tested to smallest\nunsorted.each do |tested_object|\n if tested_object < smallest\n still_unsorted.push smallest\n smallest = tested_object\n#otherwise put tested_object into still_unsorted\n else\n still_unsorted.push tested_object\n end\n#push smallest into sorted\n sorted.push smallest\n #calls method recursively again\n rec_sort still_unsorted, sorted\nend\nend", "def two(array)\n array.sort\nend", "def sortarray (sort_me)\n counter = sort_me.length\n a = 0\n b = 1\n while a < (counter-1)\n b = a+1\n while b < (counter)\n if sort_me[a] > sort_me[b]\n temp = sort_me[a]\n sort_me[a] = sort_me[b]\n sort_me[b] = temp\n end\n b += 1\n end\n a += 1\n end\n return sort_me\nend", "def integer_pigeonhole_sort(numbers)\n sorted = []\n\n numbers.length.times do |i|\n sorted << i\n end\n\n sorted\nend", "def sort_entries; end", "def sort(input)\n # If the length of the array is < or = 1, then we already\n # know it's sorted, so exit\n return input if input.length <= 1\n\n # Now we want to run this algorithm in a loop for forever\n # until we know that the entire array is sorted. That\n # will be our \"break\" condition - the condition to\n # break out of the loop.\n\n swapped = true\n while swapped do\n # We set swapped equal to false here, because we\n # basically want to set it only to true when we've\n # actually swapped something. If we never swap anything\n # in this iteration of the loop, it means that the\n # array is sorted and we're done.\n swapped = false\n\n # We use upto, which is a function from Enumerators\n # https://ruby-doc.org/core-2.2.0/Integer.html#method-i-upto\n # We basically are saying we are going to access through the\n # array we're given, up until the length of it -2. Why?\n # We're accessing each of the array elements by index.\n # Example: [1,2,3,4]\n # If we want to get 1 from the array, we access element 0.\n # In this example, we want to access the current index and the\n # index ahead of it. So, in this loop, we only want to try\n # and access the length of the array minus 2, because otherwise\n # we'll run out of the bounds of the array.\n 0.upto(input.length - 2) do |index|\n # If the number at our current index is greater than the one\n # in front of it... swap!\n if input[index] > input[index+1]\n # Here's a neat trick you can do so you don't have to assign\n # any variables to hold onto a value.\n input[index], input[index+1] = input[index+1], input[index]\n swapped = true\n end\n end\n end\n\n input\nend", "def sort_array array\n sorted=[]\n a=0\n b=0\n until a==(array.length-1)||b==(array.length)\n if array[a] <= array[b]\n b+=1\n else\n a+=1\n b=0\n end\n end\n sorted.push array[a]\n array.delete(array[a])\n \n while true\n if array.length==1\n sorted.push array[0]\n break\n else\n a=0\n b=0\n until a==(array.length-1)||b==(array.length)\n if array[a]<=array[b]\n b+=1\n else\n a+=1\n b=0\n end\n end\n sorted.push array[a]\n array.delete_at(a)\n end\n end\n sorted\nend", "def using_sort(array)\n sorted_array=array.sort\nend", "def sort_zombies\n index = 0\n while index < @zombie_apocalypse_supplies.length\n index2 = index + 1\n while index2 < @zombie_apocalypse_supplies.length\n if @zombie_apocalypse_supplies[index2] < @zombie_apocalypse_supplies[index]\n @zombie_apocalypse_supplies[index], @zombie_apocalypse_supplies[index2] = @zombie_apocalypse_supplies[index2], @zombie_apocalypse_supplies[index]\n end\n index2 += 1\nend\nindex += 1\nend\nputs\nputs @zombie_apocalypse_supplies\nputs\nend", "def test_sort\n\n a_plus = Grade.new(\"A+\")\n a = Grade.new(\"A\")\n b_minus = Grade.new(\"B-\")\n\n ordered = [a_plus,b_minus, a].sort # should return [a, a_plus]\n\n assert(ordered[0] == b_minus)\n assert(ordered[1] == a)\n assert(ordered[2] == a_plus)\n\n end", "def bubble_sorting array\r\n#assign length of the array = variable(z)\r\n z = array.length\r\n# like a while loop\r\n loop do\r\n#boolean variable called \"sorted\" = false is when algorithm should exit\r\n# if true keeps looping\r\n sorted = false\r\n#Inside loop check the value of each element and compare it w/ the next one\r\n# how many times it runs = z-1\r\n (z-1).times do |i|\r\n if array[i] > array[i+1]\r\n array[i], array[i+1]=array[i+1], array[i]\r\n#ends loop once sorting = true \r\n sorted = true\r\n end\r\n end\r\n\r\n break if not sorted\r\n end\r\n\r\n array\r\nend", "def test_runtime(size,bound,iterations)\n\n # table header\n puts(\" Arraygröße | ins_sort! | max_sort! | min_sort! \");\n puts(\"------------------------------------------------\");\n\n # measure runtime for the three sorting algorithms\n for i in 0..iterations-1 do\n\n array_size = (2**i) * size;\n # generate random array\n test_array = random_array(array_size,bound);\n # since all sorting functions are mutable\n # functions, we have to copy the generated\n # array in order to use the same array_size\n # for all sorting functions; otherwise\n # the second sorting function will work\n # on an already sorted array.\n\n # measure runtime for `ins_sort!`\n ins_sort_array = test_array.clone;\n ins_sort_time = Time.now;\n ins_sort!(test_array);\n ins_sort_time = Time.now - ins_sort_time;\n\n # measure runtime for `max_sort!`\n max_sort_array = test_array.clone;\n max_sort_time = Time.now;\n max_sort!(test_array);\n max_sort_time = Time.now - max_sort_time;\n\n # measure runtime for `min_sort!`\n min_sort_array = test_array.clone;\n min_sort_time = Time.now;\n min_sort!(test_array);\n min_sort_time = Time.now - min_sort_time;\n\n # pretty print table output\n tab1 = \" \" * 3;\n tab2 = \" \" * 4;\n print(tab1);\n print_array_size(array_size);\n print(tab2);\n print_float(ins_sort_time);\n print(tab2);\n print_float(max_sort_time);\n print(tab2);\n print_float(min_sort_time);\n print(\"\\n\");\n end;\nend", "def poorly_written_ruby(*arrays)\n\n combined_array = arrays.flatten # use built in ruby method\n\n index_count = combined_array.size - 1 # assign a variable so that array does not need to be accessed in while loop check\n sorted_array = [combined_array.delete_at(combined_array.length-1)]\n\n for val in combined_array\n i = 0\n while i <= index_count # use variable to avoid array access\n\n if val <= sorted_array[i]\n sorted_array.insert(i, val)\n break\n elsif i == sorted_array.length - 1\n sorted_array << val\n break\n end\n i+=1\n end\n end\n\n # Return the sorted array\n sorted_array\nend", "def my_array_sorting_method(source)\n puts source.map{|x| x.to_s}.sort \n\n #return source.sort_by{|x| x.to_s} => see comment A below regarding this line\nend", "def sort(array)\n final = [array[0]]\n array.delete_at(0)\n # main code\n for i in array\n final_index = 0\n while final_index < final.length\n if i <= final[final_index]\n final.insert(final_index,i)\n break\n elsif final_index == final.length-1\n final.insert(final_index+1,i)\n break\n end\n final_index+=1\n end\n end\n # output\n final\nend", "def sort1(num_array)\n sorted_array = []\n while num_array.length > 0\n sorted_array.push(num_array.min)\n num_array.delete(num_array.min)\n end\n return sorted_array\nend", "def bubble_sort(array)\r\n #Create a do loop to iterate through the loop\r\n loop do\r\n \t#Make a variable called switch that will switch the numbers as you sort\r\n \t#Set it to false, it will become true if the numbers are not in the right place\r\n switch = false\r\n #MAke a loop inside the other loop\r\n #The length of the array - 1 (To catch last two values as you go through), iterate this many times \r\n (array.length-1).times do |i|\r\n #If the array at the first index is greater value than the one on front of it\r\n if array[i] > array[i+1]\r\n \t#Then it equals one placeholder/index in front/next index spot\r\n \t#It's a larger number and needs to swap\r\n array[i], array[i+1] = array[i+1], array[i]\r\n #Set switch to true\r\n switch = true\r\n #End if statement\r\n end\r\n end\r\n #Break this iteration and go back in line, iterating through if not - switch is false\r\n break if not switch\r\n end\r\n #Return the sorted array\r\n array\r\n #End method\r\nend", "def count_sort(a)\n\t\nend", "def qsort(arr)\nend", "def recursive_sort listA, listB, sorted, nums\n\t# local variables\n\tx = 0\n\ty = 0\n\tz = 0\n\t# cycle I\n\twhile x <= nums\n\t\tif listA[x].downcase <= listA[y].downcase\n\t\t\ty = y + 1\n\t\t\tif y == nums + 1\n\t\t\tsorted.push listA[x]\n\t\t\tx = x + 1\n\t\t\ty = 0\n\t\t\tz = z + 1\n\t\t\tend \n\t\telse\n\t\tlistB.push listA[x]\n\t\tx = x + 1\n\t\ty = 0 \n\t\tend\n\tend\n\t# cycle II\n\tnums = nums - z\n\tlistA = [ ]\n\tx = 0\n\ty = 0\n\tz = 0\n\tif nums < 0\n\t\tx = nums + 5\n\tend\n\twhile x <= nums\n\t\tif listB[x].downcase <= listB[y].downcase\n\t\t\ty = y + 1\n\t\t\tif y == nums + 1\n\t\t\t\tsorted.push listB[x]\n\t\t\t\tx = x + 1\n\t\t\t\ty = 0\n\t\t\t\tz = z + 1 \n\t\t\tend\n\t\telse\n\t\t\tlistA.push listB[x]\n\t\t\tx = x + 1\n\t\t\ty = 0\n\t\tend\n\tend\n\tnums = nums - z\n\tx = 0\n\ty = 0\n\tz = 0\n\tif nums < 0\n\t\tputs 'sorted list: '\n\t\tputs sorted\n\telse\n\t\trecursive_sort(listA, [ ], sorted, nums)\n\tend\nend", "def sort_method unsorted, sorted\n# end the programme when the unsorted array is empty\n if unsorted.length == 0\n return sorted\n end\n\nsmallest = unsorted.pop\nstill_unsorted = []\n\nunsorted.each do |testedword|\n if testedword > smallest\n still_unsorted.push testedword # testedword is bigger than the reference word so will need to be sorted\n else\n still_unsorted.push smallest # 'smallest' goes in the unsorted array as turns out was not the smallest\n smallest = testedword # sets the tested word as smallest found so far in the array\n end\nend\n\nsorted.push smallest\n\nsort_method still_unsorted, sorted\n\nend", "def selection_sort\n for i in [email protected]\n min_index = i\n for j in [email protected]\n min_index = j if (@array[j] < @array[min_index])\n end\n swap(@array, i, min_index)\n end\n print\n end", "def sort arr\r\n\treturn arr if arr.length <= 1\r\n\r\n\tmiddle = arr.pop\r\n\tless = arr.select{|x| x < middle}\r\n\tmore = arr.select{|x| x >= middle}\r\n\r\n\tsort(less) + [middle] + sort(more)\r\nend", "def selection_sort(numbers)\n length = numbers.length\n index = 0\n while index < length\n minimum = index\n j = index + 1\n while j < length\n if numbers[j] < numbers[minimum]\n minimum = j\n end\n j += 1\n end\n temp = numbers[index]\n numbers[index] = numbers[minimum]\n numbers[minimum] = temp\n index += 1\n end\n # numbers.each_with_index do |number, index|\n # minimum = number\n # j = index + 1\n # while j < numbers.length\n # if numbers[j] < minimum\n # minimum = numbers[j]\n # end\n # j += 1\n # end\n # temp = minimum\n # numbers[index] = numbers[minimum]\n # numbers[minimum] = temp\n # end\nend", "def sort\n # Find a cycle in the move graph and pick a register to spill to break it.\n spillee = nil\n each_strongly_connected_component do |component|\n if component.size > 1\n fail if spillee # There is one cycle with 3 registers.\n spillee = component.first.src\n end\n end\n\n # Break the cycle.\n spill(spillee) if spillee\n\n tsort\n end", "def selection_sort(n,a)\n for i in 0..n-2\n minimum_index = i\n key = a[i]\n for j in i+1..n-1\n if a[j] < a[minimum_index]\n minimum_index = j\n end\n end\n a[i] = a[minimum_index]\n a[minimum_index] = key\n end\n for i in 0..n-1\n print a[i]\n end\n print \"\\n\"\nend", "def quick_sort(array)\nend", "def wiggle_sort(nums)\n nums = nums.sort!\n\n greater_num_idx = nums.length / 2\n lesser_num_idx = 1\n\n until lesser_num_idx >= greater_num_idx\n nums[lesser_num_idx], nums[greater_num_idx] = nums[greater_num_idx], nums[lesser_num_idx]\n lesser_num_idx += 2\n greater_num_idx += 1\n end\n nums\nend", "def sort_array_plus_one(array)\r\n\r\n\tarray.sort! {|x, y| x <=> y}\r\n\tputs \"Input array :\"\r\n\tprint array\r\n\tprint \"\\n\"\r\n\tputs \"Result :\"\r\n\tfor i in array do \r\n\t\tprint i.to_i+1\r\n\t\tprint \", \"\r\n\r\n\tend\r\n\r\nend", "def take_array(array)\r\n array.sort\r\nend", "def comp(array1, array2)\n p array1\n p array2\n if array1.nil? || array2.nil?\n return false\n else\n array2 = array2.map { |num| Math.sqrt(num) }\n p array1.sort\n p array2.sort\n array1.sort == array2.sort\n end\nend", "def quicksort(a)\n\n\tdo_quick_sort(a, 0, a.length-1)\n\tputs a.to_s\nend", "def sort_problem (arr1, arr2)\n\n i1 = arr1.length - 1\n i2 = arr2.length - 1\n i2_non0 = arr1.length - 1\n\n while i1 >= 0 && i2 >= 0 do \n if arr1[i1] > arr2[i2_non0]\n arr2[i2] = arr1[i1]\n i2 -=1\n i1 -= 1\n else \n arr2[i2] = arr2[i2_non0]\n i2_non0 -= 1\n i2 -= 1\n end\n end\n\n return arr2\n \nend", "def sort arr\n return arr if arr.length <= 1\n \n middle = arr.pop\n less = arr.select{|x| x < middle}\n more = arr.select{|x| x >= middle}\n\n sort(less) + [middle] + sort(more)\nend", "def sort arr\n return arr if arr.length <= 1\n \n middle = arr.pop\n less = arr.select{|x| x < middle}\n more = arr.select{|x| x >= middle}\n\n sort(less) + [middle] + sort(more)\nend", "def shell_sort(a)\n n = a.length # Size of input\n h = 1\n h = h * 3 + 1 while h < n / 3\n\n while h >= 1\n i = h\n while i < n\n j = i\n while j >= h && a[j] < a[j - h]\n temp = a[j - h]\n a[j - h] = a[j]\n a[j] = temp\n\n j -= h\n end\n i += 1\n end\n h = (h / 3).to_i\n end\n a\nend", "def custom_sort (unsorted, sorted = [])\n return sorted.uniq if unsorted.length == 0\n smallest = unsorted[0]\n unsorted.each {|x| smallest = x if x <= smallest}\n\n unsorted.each {|x| sorted << x if x <= smallest }\n\n unsorted.delete(smallest)\n custom_sort(unsorted, sorted)\nend", "def poorly_written_sort(*arrays)\n combined_array = []\n arrays.each do |array|\n array.each do |value|\n combined_array << value\n end\n end\n\n sorted_array = [combined_array.delete_at(combined_array.length-1)]\n\n for val in combined_array\n i = 0\n while i < sorted_array.length\n if val <= sorted_array[i]\n sorted_array.insert(i, val)\n break\n elsif i == sorted_array.length - 1\n sorted_array.insert(i, val)\n break\n end\n i+=1\n end\n end\n\n # Return the sorted array\n sorted_array\nend", "def sort(to_sort)\n # if the array is of length 0 or 1, consider it is already sorted\n if to_sort.length <= 1\n then return to_sort\n end\n\n # otherwise split the remaining elements in two\n # I had to look this line on the web (sourcerefactormycode.com)\n second_array = to_sort.slice!((to_sort.length / 2.0).round..to_sort.length)\n\n # recursive method call on both arrays\n first_sorted_array = sort(to_sort)\n second_sorted_array = sort(second_array)\n\n # merge the two sorted arrays together\n return merge(first_sorted_array, second_sorted_array)\nend", "def shell_sort(a)\n n=a.length\n h=1\n \n while (h<n/3) #for computing increment factor \"h\"\n h= (3*h)+1\n end\n \n while h>=1\n # Logic of insertion sort with inrement steps of \"h\"\n for i in h...n\n j=i\n while j>=h\n if a[j-h]>a[j]\n temp=a[j]\n a[j]=a[j-h]\n a[j-h]=temp\n end\n j-=h\n end\n end\n h/=3\n end\n \n return a\n \nend", "def sort(unsorted_array)\n @sorted_array << unsorted_array.delete_at(unsorted_array.min)\n sort(unsorted_array) until unsorted_array.length == 0\n# This is the RECURSION - latest value of unsorted_array after each iteration\n# is then re-run through the sort method until everything is sorted.\n @sorted_array\nend", "def sort arr\n return arr if arr.length <= 1\n middle = arr.pop\n less = arr.select{|x| x < middle}\n more = arr.select{|x| x >= middle}\n sort(less) + [middle] + sort(more)\nend", "def shell_sort(a)\n array = a\n \n m = 1\n while (gap = array.length / (2 ** m)) >= 1\n puts \"gap: #{gap}\"\n 0.step(array.length-1, gap) do |i|\n #puts \"#{i}\"\n # insertion sort\n #puts \" ###{i+gap}\"\n (i+1).upto(i+gap-1) do |j|\n #puts \" #{j}\"\n if array[j] < array[j-1]\n # need to shift everything over until it isn't\n j.downto(i+1) do |k|\n if array[k] < array[k-1]\n array[k], array[k-1] = array[k-1], array[k]\n end\n end\n end\n end\n p a\n end\n \n m += 1\n end\nend", "def gnome_sort(array)\n count = 0\n\n while count < array.length - 1\n if array[count] > array[count + 1]\n array[count + 1], array[count] = array[count], array[count + 1]\n count -= 2 if count.positive?\n end\n count += 1\n end\n\n array\nend", "def non_recursive_sort unsorted_array\n\nsorted_array = []\n\nsmallest = unsorted_array[0]\n\n while unsorted_array != []\n \n unsorted_array.each {|word|\n if smallest >= word\n smallest = word\n end\n }\n sorted_array.push smallest\n unsorted_array.delete_at(unsorted_array.find_index(smallest))\n smallest = unsorted_array[0]\n end\n puts sorted_array.join(\", \")\nend", "def bar arr\n arr.sort!\nend", "def sorting(teamsarrayswins)\n rec_sorting(teamsarrayswins, [])\nend", "def flash_sort(arr) \n max = 0;\n min = arr[0];\n n = arr.length;\n m = (0.45 * n).floor;\n l = Array.new(m);\n i = 1;\n while (i < n)\n if (arr[i] < min) \n min = arr[i];\n end\n if (arr[i] > arr[max]) \n max = i;\n end\n i += 1;\n end\n \n if (min == arr[max]) \n return arr;\n end\n \n c1 = (m - 1) / (arr[max] - min);\n \n k = 0;\n while (k < m)\n l[k] = 0;\n k+=1;\n end\n j = 0;\n while (j < n) \n k = (c1 * (arr[j] - min)).floor;\n l[k]+=1;\n j+=1;\n end\n \n d = 1;\n while (d < m) \n l[d] += l[d - 1];\n d+=1;\n end\n \n hold = arr[max];\n arr[max] = arr[0];\n arr[0] = hold;\n \n #permutation\n move = 0;\n j = 0; \n k = m - 1;\n \n while (move < (n - 1)) \n while (j > (l[k] - 1))\n j+=1;\n k = (c1 * (arr[j] - min)).floor;\n end\n if (k < 0) then end;\n flash = arr[j];\n while (j != l[k]) \n k = (c1 * (flash - min)).floor;\n hold = arr[t = l[k]-=1];\n arr[t] = flash;\n flash = hold;\n move+=1;\n end\n end\n \n #insertion\n j = 1;\n while (j < n)\n hold = arr[j];\n i = j - 1;\n while (i >= 0 && arr[i] > hold)\n arr[i + 1] = arr[i-=1];\n end\n arr[i + 1] = hold;\n j+=1;\n end\n return arr;\nend", "def solve(nums)\n squared = nums.map {|num| num * num}\n return squared.sort\nend", "def sort arr\n return arr if arr.length <= 1\n middle = arr.pop\n lesss = arr.select{|x| x < middle}\n more = arr.select{|x| x>= middle}\n\n sort(less) + [middle] + sort(more)\nend", "def selection_sort(arr)\n# set a variable called mark to 0\nmark = 0\n# make sure that we check every number\nwhile mark <= arr.length\n\t# set an index marker to 0\n\ti = 0\n\t# go through every item in the array\n\tarr.each do |num|\n\t# set the variable var to the value of the array at index position i\n\tvar = arr[i]\n\t\t# when the value of var is greater than the value of num\n\t\tif var > num\n\t\t\t# set the variable low to the value of num\n\t\t\tlow = num\n\t\t\t# set the variable var to the value of num\n\t\t\tvar = num\n\t\tend\n\t\t# increment the value of the variable i by 1\n\t\ti += 1\n\tend\n\tswap = arr[i]\n\tarr[i] = low\nend\n\treturn arr\nend", "def better_written_ruby(*arrays)\n combined_array = []\n # remove one loop and simply concatenate the arrays.\n arrays.each do |array|\n combined_array += array\n end\n \n sorted_array = [combined_array.delete_at(combined_array.length-1)]\n \n for val in combined_array\n i = 0\n while i < sorted_array.length\n if val < sorted_array[i]\n sorted_array.insert(i, val)\n break\n elsif i == sorted_array.length - 1\n sorted_array << val\n break\n end\n i+=1\n end\n end\n sorted_array\nend", "def sort_nums_ascending(arr)\n return arr.sort\nend", "def sort_method(unsorted_array, sorted_array)\n if unsorted_array.length <= 0 #checking if there is any words left to sort\n return sorted_array #if no words then output is the complete sorted array\n end\n \nsmallest = unsorted_array.pop #select a word from the end of the unsorted array\nstill_unsorted = [] #create a new array to put the unsorted words in\n\nunsorted_array.each do |test_word|\n if test_word < smallest #word is tested if it should come before the selected word\n still_unsorted.push smallest #if it does come before the selected word, then move the selected word into unsorted array\n smallest = test_word #then set \n else\n still_unsorted.push test_word #if no words found then the \n end\nend\n\nsorted_array.push smallest #pushes the \n \nsort_method still_unsorted, sorted_array #recursive method\n\nend", "def solution(a)\n sorted_array = a.sort\n\n index = 0\n while index < sorted_array.length do\n break unless sorted_array[index] == sorted_array[index+1]\n index += 2\n end\n\n sorted_array[index]\nend", "def merge_sort numbers, si=0, ei=nil\n\n # TODO: your cool code goes here\n\nend", "def selectionSort(array)\n array.each_index do |index|\n \tputs \"element\"\n \tcurrent = index\n \tstart = index\n \tleast = array[current]\n \tleast_index=index\n while (start < array.length - 1)\n\n\t \tif array[start + 1] < least\n\t \t\tleast = array[start + 1]\n\t \t least_index = start + 1\n\t \tend\t\n\t \tstart += 1\n\t end\n\n\t array[least_index] = array[current]\n array[current] = least\n \n end \n return array \nend" ]
[ "0.7074742", "0.7071043", "0.6968346", "0.69415516", "0.68486744", "0.67531735", "0.67439705", "0.6732928", "0.67306083", "0.6674136", "0.6660055", "0.6657538", "0.66439736", "0.6637575", "0.66282403", "0.66282403", "0.66164404", "0.65989476", "0.6590009", "0.65879804", "0.65788186", "0.65497655", "0.65350246", "0.65346766", "0.6518885", "0.65035146", "0.6502225", "0.64884275", "0.6475288", "0.64666826", "0.64640105", "0.64388865", "0.64246583", "0.6418272", "0.64001215", "0.6399118", "0.6380504", "0.6380504", "0.6380504", "0.6376463", "0.6376463", "0.6375214", "0.6371057", "0.6369763", "0.63677335", "0.6358209", "0.63562477", "0.6354617", "0.63527006", "0.6350799", "0.6349071", "0.6347242", "0.6341772", "0.6341719", "0.63302845", "0.63290465", "0.63215053", "0.631555", "0.6313267", "0.630449", "0.6301102", "0.63004816", "0.62975997", "0.62895465", "0.6289541", "0.62876874", "0.62833226", "0.62798476", "0.627404", "0.6265502", "0.62648726", "0.62634456", "0.6261804", "0.6261183", "0.6258854", "0.6256332", "0.62544966", "0.62544966", "0.62519", "0.62517035", "0.62492317", "0.6248996", "0.6241127", "0.6236249", "0.62346876", "0.623366", "0.62303936", "0.6229711", "0.62233657", "0.6218073", "0.6217359", "0.6215119", "0.62057245", "0.62042695", "0.62012607", "0.6201031", "0.61950225", "0.61900413", "0.6190018", "0.6181447" ]
0.6340105
54
Rewrite your Table of Contents program (from the chapter on methods). Start the program with an array holding all of the information for your Table of Contents (chapter names, page numbers, etc.). Then print out the information from the array in a beautifully formatted Table of Contents.
def justify_again content = ['Table of Contents', 'Chapter 1: Numbers', 'page 1', 'Chapter 2: Letters', 'page 72', 'Chapter 3: Variables', 'page 118'] lineWidth = 40 puts (content[0].center(lineWidth)) puts (content[1].ljust(lineWidth/2) + content[2].rjust(lineWidth/2)) puts (content[3].ljust(lineWidth/2) + content[4].rjust(lineWidth/2)) puts (content[5].ljust(lineWidth/2) + content[6].rjust(lineWidth/2)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def table_of_contents\n puts(\"Table of Contents\".center(50))\n puts(\"Chapter 1\".ljust(15) + \"Getting Started\".ljust(20) + \"page \".ljust(1) + \"1\".rjust(3))\n puts(\"Chapter 2\".ljust(15) + \"Numbers\".ljust(20) + \"page \".ljust(1) + \"9\".rjust(3))\n puts(\"Chapter 3\".ljust(15) + \"Letters\".ljust(20) + \"page \".ljust(1) + \"13\".rjust(3))\nend", "def table_of_contents\n lineWidth = 50\n table_name = \"Table of Contents\"\n colume1_label = \"Chapter\"\n colume2_label = \"\"\n colume3_label = \"page\"\n spacer = \"\"\n puts table_name.center(lineWidth)\n puts spacer\n puts (colume1_label + \" 1:\").ljust(lineWidth/4) + \"Numbers\".ljust(lineWidth/4) + (colume3_label+\" 1\").rjust(lineWidth/2)\n puts (colume1_label + \" 2:\").ljust(lineWidth/4) + \"Letters\".ljust(lineWidth/4) + (colume3_label+\" 72\").rjust(lineWidth/2)\n puts (colume1_label + \" 3:\").ljust(lineWidth/4) + \"Variables\".ljust(lineWidth/4) + (colume3_label+\" 118\").rjust(lineWidth/2)\n\nend", "def print_out(print_info)\n line_width = 40\n \n puts print_info[0][0].center(line_width) #we print the title first\n \n print_info[1].each_with_index do |v,i| #we use each_with_index so that we can loop through each element in the sub-arrays\n print \"Chapter #{i + 1}: #{print_info[1][i].ljust(line_width/2)}\" #prints out the prefix \"Chapter#:\" and the names\n print \"Page #{print_info[2][i]}\".rjust(line_width/2) #prints out the \n print \"\\n\"\n end\n \n\nend", "def display_toc(cgi)\n index = Index.new\n if index.size == 0\n res = \"<p>Be the first supporter!\"\n elsif index.size == 1\n res = display_messages(cgi, index[0])\n else\n res = \"Click on a date below to see the supporters \" +\n \"who signed up then.<p>\"\n\n index.each_message_dir do |md|\n res += \"<a href=\\\"display.cgi?ms=#{md.base_name}\\\">#{md.date_range}</a><br> \"\n end\n\n res += \"<p><a href=\\\"display.cgi?ms=all\\\">See all supporters</a>\"\n end\n res\nend", "def toc\n \"* \\n{:toc}\\n\"\n end", "def toc\n \"* \\n{:toc}\\n\"\n end", "def print_table\n $table_page.puts \"<tr> <td>\" + @fed_no.to_s + \"</td> <td>\"+ @fed_author.join(' ') + \"</td><td> <a href=docs.html#\" + @fed_number[2] + \">\" + @fed_title.join(' ') + \"</td> <td>\" + @fed_place.join(' ') + \"</td> </tr>\"\n end", "def table_of_contents\n toc = '<ul>'\n prevDepth = 0\n prevIndex = ''\n\n html = gsub %r{<h(\\d)(.*?)>(.*?)</h\\1>$}m do\n depth, atts, title = $1.to_i, $2, $3.strip\n\n # generate a LaTeX-style index (section number) for the heading\n depthDiff = (depth - prevDepth).abs\n\n index =\n if depth > prevDepth\n toc << '<li><ul>' * depthDiff\n\n s = prevIndex + ('.1' * depthDiff)\n s.sub(/^\\./, '')\n\n elsif depth < prevDepth\n toc << '</ul></li>' * depthDiff\n\n s = prevIndex.sub(/(\\.\\d+){#{depthDiff}}$/, '')\n s.next\n\n else\n prevIndex.next\n\n end\n\n prevDepth = depth\n prevIndex = index\n\n # generate a unique anchor for the heading\n frag = CGI.unescape(\n if atts =~ /id=('|\")(.*?)\\1/\n atts = $` + $'\n $2\n else\n title\n end\n ).to_uri_fragment\n\n frag << frag.object_id.to_s while @@uriFrags.include? frag\n @@uriFrags << frag\n\n # provide hyperlinks for traveling between TOC and heading\n dst = frag\n src = dst.object_id.to_s.to_uri_fragment\n\n dstUrl = '#' + dst\n srcUrl = '#' + src\n\n # forward link from TOC to heading\n toc << %{<li>#{index} <a id=\"#{src}\" href=\"#{dstUrl}\">#{title}</a></li>}\n\n # reverse link from heading to TOC\n %{<h#{depth}#{atts}><a id=\"#{dst}\" href=\"#{srcUrl}\" class=\"list\" title=\"#{LANG['Return to %s', LANG['Contents']]}\">#{index}</a>&nbsp;&nbsp;<a href=\"##{dst}\" class=\"here\" title=\"#{LANG['Permanent hyperlink to this section']}\">#{title}</a></h#{depth}>}\n end\n\n if prevIndex.empty?\n toc = nil # there were no headings\n else\n toc << '</ul></li>' * prevDepth\n toc << '</ul>'\n\n # collapse redundant list elements\n while toc.gsub! %r{(<li>.*?)</li><li>(<ul>)}, '\\1\\2'\n end\n\n # collapse unnecessary levels\n while toc.gsub! %r{(<ul>)<li><ul>(.*)</ul></li>(</ul>)}, '\\1\\2\\3'\n end\n end\n\n [toc, html]\n end", "def print\n puts \"Multiplication Table of Prime Numbers\"\n table = Terminal::Table.new :title => \"#{(grid.length - 1).to_s} prime numbers\" do |t|\n \n # For each prime number, create a row\n for x in 0..(grid.length - 1) do\n\n # Start each row with the prime number\n row = [nil]\n \n for y in 0..(grid.length - 1) do\n row << grid[x][y]\n end\n \n # Add the row as well as a seperator for every row, except the last\n t << row\n t << :separator unless x == (grid.length)\n end\n \n end\n puts table\n end", "def table_of_contents\n accept RDoc::Markup::ToTableOfContents.to_toc\n end", "def print_table\n\t$table.each do |row|\n\t\trow.each_with_index do |c, index|\n\t\t\tif index != 0\n\t\t\t\tprint ' '\n\t\t\tend\n\t\t\tprint c\n\t\tend\n\t\tprint \"\\n\"\n\tend\nend", "def print\n table_header = \"Last Name | First Name | Gender | Date of Birth | Favorite Color\"\n puts table_header\n puts \"-\" * 50\n @people_array.each do |p|\n puts \"#{p['LastName']} | #{p['FirstName']} | #{p['Gender']} | #{p['DateOfBirth']} | #{p['FavoriteColor']}\"\n end\n end", "def print_header # sets the 'header' display format\n puts \"The students of my cohort at Makers Academy\"\n puts \"-------------\\n\"\nend", "def print_header # print intial text\n puts \"The students of Villians Academy\"\n puts \"-------------\"\nend", "def display_toc(cgi)\n res = \"\"\n index = Index.new\n index.each_message_dir do |md|\n res += %{<a href=\"display.cgi?ms=#{md.base_name}\">#{md.date_range}</a> }\n end\n res\nend", "def show_doc(retval_arr)\n message = retval_arr[0]\n table = retval_arr[1]\n \n table.each do |row|\n puts row\n end\n puts\n end", "def history_report(rows)\n table = Terminal::Table.new :headings => ['Date','Exercise', 'Set', 'Weight', 'Reps'], \n :title => \"Exercise Log History\",\n :rows => rows \n puts table\nend", "def print_contents\n\t\tputs \"Artist: %s\" % [@artist]\n\t\tputs \"Album: %s\" % [@title]\n\t\tputs \"Released: %s\" % [@year]\n\n\t\tif @cd_count > 0\n\t\tputs \"CD(%d): %s\" % [@cd_count, @cd_id]\n\t\tend\n\n\t\tif @tape_count > 0\n\t\tputs \"Tape(%d): %s\" % [@tape_count, @tape_id]\n\t\tend\n\n\t\tif @vinyl_count > 0\n\t\tputs \"Vinyl(%d): %s\" % [@vinyl_count, @vinyl_id]\n\t\tend\n\n\tend", "def display_contents(everything)\n\t# Open database connection\n\tdb = open_connection\n\tif (everything == true)\n\t\tif (ARGV[1] == nil) # if no file was specified, output to screen\n\t\t\tbegin\n\t\t\t\t# Set results equal to the result of the MySQL query\n\t\t\t\tresults = db.query \"SELECT * FROM #{$db_name}.#{$db_table_name}\"\n\t\t\t\tputs \"\\nNumber of items: #{results.num_rows}\"\n\n\t\t\t\tputs \"+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+\"\n\t\t\t\tputs \"| Barcode\".ljust(17) + \"| Item Name:\".ljust(34) + \n\t\t\t\t\t\"| Item Category\".ljust(18) + \"| Quantity\".ljust(11) + \n\t\t\t\t\t\"| Price\".ljust(10) + \"| Description\".ljust(29) + \" |\"\n\t\t\t\tputs \"+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+\"\n\t\t\t\t# Loop through the results and output the data\n\t\t\t\tresults.each_hash do |item|\n\t\t\t\t\tprint \"| #{item['Barcode']}\".ljust(17)\n\t\t\t\t\tprint \"| #{item['ItemName']}\".ljust(34)\n\t\t\t\t\tprint \"| #{item['ItemCategory']}\".ljust(18)\n\t\t\t\t\tprint \"| #{item['Quantity']}\".ljust(11)\n\t\t\t\t\tprint \"| #{item['Price']}\".ljust(10)\n\t\t\t\t\tprint \"| #{item['Description']}\".ljust(29) + \" |\"\n\t\t\t\t\tprint \"\\n\"\n\t\t\t\tend\n\t\t\t\tputs \"+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+\"\n\t\t\t\tprint \"\\n\"\n\t\t\t\tresults.free\n\t\t\trescue\n\t\t\t\tabort \"Could not retrieve information from database. Ensure that table name has been entered properly.\"\n\t\t\tensure\n\t\t\t\tdb.close\n\t\t\tend\n\t\telse # output to a file\n\t\t\t# set the filename and check if it is a TSV file\n\t\t\tnew_filename = ARGV[1].to_s\n\t\t\tif (new_filename.end_with?(\".tsv\"))\n\t\t\t\t# query the database\n\t\t\t\tdatabase_contents = db.query \"SELECT * FROM #{$db_name}.#{$db_table_name}\"\n\t\t\t\t# create/open the file for writing and add the database contents to it\n\t\t\t\tCSV.open(new_filename, \"w\", {:col_sep => \"\\t\"}) do |csv|\n\t\t\t\t\tdatabase_contents.each_hash do |a|\n\t\t\t\t\t csv << [a['Barcode'], a['ItemName'], a['ItemCategory'], a['Quantity'], a['Price'], a['Description']]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tputs \"File was successfully created!\"\n\t\t\telse # give an error\n\t\t\t\tabort \"Invalid file format – unable to proceed.\"\n\t\t\tend\n\t\tend\n\telsif (everything == false)\n\t\tif (ARGV[1] == nil) # if no file specified output to screen\n\t\t\tbegin\n\t\t\t\t# Set results equal to the result of the MySQL query\n\t\t\t\tresults = db.query \"SELECT * FROM #{$db_name}.#{$db_table_name} WHERE Quantity=0\"\n\t\t\t\tputs \"\\nNumber of items: #{results.num_rows}\"\n\n\t\t\t\tputs \"+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+\"\n\t\t\t\tputs \"| Barcode\".ljust(17) + \"| Item Name:\".ljust(34) + \n\t\t\t\t\t\"| Item Category\".ljust(18) + \"| Quantity\".ljust(11) + \n\t\t\t\t\t\"| Price\".ljust(10) + \"| Description\".ljust(29) + \" |\"\n\t\t\t\tputs \"+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+\"\n\t\t\t\t# Loop through the results and output the data\n\t\t\t\tresults.each_hash do |item|\n\t\t\t\t\tprint \"| #{item['Barcode']}\".ljust(17)\n\t\t\t\t\tprint \"| #{item['ItemName']}\".ljust(34)\n\t\t\t\t\tprint \"| #{item['ItemCategory']}\".ljust(18)\n\t\t\t\t\tprint \"| #{item['Quantity']}\".ljust(11)\n\t\t\t\t\tprint \"| #{item['Price']}\".ljust(10)\n\t\t\t\t\tprint \"| #{item['Description']}\".ljust(29) + \" |\"\n\t\t\t\t\tprint \"\\n\"\n\t\t\t\tend\n\t\t\t\tputs \"+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+\"\n\t\t\t\tprint \"\\n\"\n\t\t\t\tresults.free\n\t\t\trescue\n\t\t\t\tabort \"Could not retrieve information from database. Ensure that table name has been entered properly.\"\n\t\t\tensure\n\t\t\t\tdb.close\n\t\t\tend\n\t\telse # output to a file\n\t\t\t# set the filename and check if it is a TSV file\n\t\t\tnew_filename = ARGV[1].to_s\n\t\t\tif (new_filename.end_with?(\".tsv\"))\n\t\t\t\t# create/open the file for writing and append it with the\n\t\t\t\t# contents of the array\n\t\t\t\tdatabase_contents = db.query \"SELECT * FROM #{$db_name}.#{$db_table_name} WHERE Quantity=0\"\n\t\t\t\tCSV.open(new_filename, \"w\", {:col_sep => \"\\t\"}) do |csv|\n\t\t\t\t\tdatabase_contents.each_hash do |a|\n\t\t\t\t\t csv << [a['Barcode'], a['ItemName'], a['ItemCategory'], a['Quantity'], a['Price'], a['Description']]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tputs \"File was successfully created!\"\n\t\t\telse # give an error\n\t\t\t\tabort \"Invalid file format – unable to proceed.\"\n\t\t\tend\n\t\tend\n\tend\nend", "def print_header\nputs \"The students of my cohort at Makers Academy\"\nputs \"-------------\"\nend", "def print_header\n\tputs \"The students of my cohort at Makers Academy\"\n\tputs \"-------------------------\"\nend", "def print_header\n puts \"The students of Villains Academy\"\n puts \"------------\"\nend", "def show_books(found_list)\r\n\tputs \"\"\r\n\tputs \"\"\r\n\tputs (\"Author Title Section ID On Shelf\")\r\n\tputs (\"--------------------------------------------------------------------------------------------\")\r\n\tfor i in 0...found_list.size\r\n\t\tputs (\"#{(found_list[i][6]+', '+found_list[i][7]).truncate(25).ljust(25, \" \")} #{found_list[i][1].truncate(40).ljust(40,\" \")} #{found_list[i][3].truncate(15).ljust(15,\" \")} #{found_list[i][0].to_s.truncate(5).ljust(5,\" \")} #{found_list[i][4]}\")\r\n\tend\r\nend", "def print_header\n puts \"The students of my cohort at Makers Academy\"\n puts \"------------\"\nend", "def print_header\n puts \"\\nThe students of Villains Academy\"\n puts \"-------------\"\nend", "def print_header\n puts \"The students of Villains Academy\"\n puts \"--------------\"\nend", "def print_header\n puts \"The students of Villains Academy\"\n puts \"--------------\"\nend", "def generate_toc matches\n matches.inject(\"<toc>\\n\") do |memo, match|\n memo += \"#{tab * (match[:level].to_i - 1)}#{anchor(match)}<br />\\n\"\n end + '</toc>'\nend", "def print_header\n puts \"The students of my cohort at Makers Academy\"\n puts \"-------------\"\nend", "def print_header\n puts\n puts \"The students of Villains Academy\"\n puts \"-------------\"\nend", "def print_header\n puts \"\\nThe students of Villains Academy\"\n puts \"---------------\\n \"\nend", "def print_header\n puts \"The students of Villains Academy\"\n puts \"-------------\"\nend", "def print_header\n puts \"The students of Villains Academy\"\n puts \"-------------\"\nend", "def print_header\n puts \"The students of Villains Academy\"\n puts \"-------------\"\nend", "def print_header\n puts \"The students of Villains Academy\"\n puts \"-------------\"\nend", "def print_header\n\tputs \"The students of Villians Academy\"\n\tputs \"-------------\"\nend", "def generate_toc(filename = nil)\n filename ||= @template_path\n data = read_file(filename)\n base = 2 # Minimum indentation depth\n indent = [0] # Indentation Level tracker\n last = base\n result = ''\n data.each_line do |line|\n next if line.include?('## Table of Contents')\n next unless (hash_count = count_hashes(line))\n\n indent.push(indent.last + 1) if hash_count > last # Add a level\n indent.pop if hash_count < last # Remove a level\n indent = [0] if hash_count == base # Reset\n last = hash_count # Level check\n text = line.delete('#').delete('+').strip\n link = text.downcase.tr(' ', '-').delete(',')\n\n # Format table entry with indentation and hyperlink\n result += \"\\t\" * indent.last + \"+ [#{text}](##{link})\\n\"\n end\n result\n end", "def alpha_toc\n attributes = SECTIONS.collect { |s| s['attributes'] }.flatten\n # -> ['author', 'autorequire', ...]\n attr_map = attributes.partition_by { |a| a[0,1] }\n # -> { 'a' => ['author', ...], 'b' => ... }\n attributes = attr_map.collect { |letter, attrs|\n [letter.upcase, attrs.sort]\n }.sort_by { |l, _| l }\n # -> [ ['A', ['author', ...], ...]\n attributes = attributes.collect { |letter, attrs|\n \"* *#{letter}* \" << attrs.collect { |a| _link(a) }.join(SEPSTRING)\n } # -> [ 'A author | autorequire', 'B bindir', ...]\n puts attributes.join(\"\\n\")\nend", "def print_header \n puts \"The students of Villains Academy\"\n puts \"--------------------------------\"\nend", "def print_header\n puts \"The students of my cohort at Makers Academy\"\n puts \"-----------------\"\nend", "def print_header\n\n puts \"The students of Villains Academy\"\n puts \"%s %s %s %s %s %s %s\" % [\n \"ID\".ljust(2),\n \"Name\".ljust(@width),\n \"Cohort\".ljust(@width),\n \"D.O.B\".ljust(@width),\n \"Height(cm)\".ljust(@width),\n \"C.O.B\".ljust(@width),\n \"hobby\"\n ]\n puts \"-------------\"\nend", "def print_header\n\tputs \"The students of my cohort at Makers Academy are:\"\n\tputs \"---------\"\nend", "def print_header\n puts \"The students of Villains Academy\"\nputs \"------------\"\nend", "def layout_toc doc, num_levels = 2, toc_page_number = 2, start_y = nil, num_front_matter_pages = 0\n go_to_page toc_page_number unless (page_number == toc_page_number) || scratch?\n if scratch?\n colophon = doc.find_by(context: :section) {|sect| sect.sectname == 'colophon' }\n if (colophon = colophon.first)\n doc.instance_variable_set :@colophon, colophon\n colophon.parent.blocks.delete colophon\n end\n else\n if (colophon = doc.instance_variable_get :@colophon)\n # if prepress book, consume blank page before table of contents\n go_to_page(page_number - 1) if @ppbook\n convert_section colophon\n go_to_page(page_number + 1)\n end\n end\n offset = colophon && !@ppbook ? 1 : 0\n toc_page_numbers = super doc, num_levels, (toc_page_number + offset), start_y, num_front_matter_pages\n scratch? ? ((toc_page_numbers.begin - offset)..toc_page_numbers.end) : toc_page_numbers\n end", "def table(array_table)\n\t\tputs \" _____1___________2____________3_____ \".colorize(:green)\n\t\tputs \" | | | |\".colorize(:green)\n\t\tputs \" | #{array_table[0]*3} | #{array_table[1]*3} | #{array_table[2]*3} |\".colorize(:green)\n\t\tputs \"A | #{array_table[0]*3} | #{array_table[1]*3} | #{array_table[2]*3} |\".colorize(:green)\n\t\tputs \" | #{array_table[0]*3} | #{array_table[1]*3} | #{array_table[2]*3} |\".colorize(:green)\n\t\tputs \" |___________|___________|____________|\".colorize(:green)\n\t\tputs \" | | | |\".colorize(:green)\n\t\tputs \"B | #{array_table[3]*3} | #{array_table[4]*3} | #{array_table[5]*3} |\".colorize(:green)\n\t\tputs \" | #{array_table[3]*3} | #{array_table[4]*3} | #{array_table[5]*3} |\".colorize(:green)\n\t\tputs \" | #{array_table[3]*3} | #{array_table[4]*3} | #{array_table[5]*3} |\".colorize(:green)\n\t\tputs \" |___________|___________|____________|\".colorize(:green)\n\t\tputs \" | | | |\".colorize(:green) \n\t\tputs \" | #{array_table[6]*3} | #{array_table[7]*3} | #{array_table[8]*3} |\".colorize(:green) \n\t\tputs \"C | #{array_table[6]*3} | #{array_table[7]*3} | #{array_table[8]*3} |\".colorize(:green)\n\t\tputs \" | #{array_table[6]*3} | #{array_table[7]*3} | #{array_table[8]*3} |\".colorize(:green)\n\t\tputs \" |___________|___________|____________|\".colorize(:green)\n\tend", "def output_table(title = '', headings, rows)\n table = Terminal::Table.new\n table.title = title unless title.empty?\n table.rows = rows\n table.headings = headings\n table.style = {\n :padding_left => 1,\n :padding_right => 1\n }\n\n puts table\n end", "def list_course_info\n puts \"There are #{@student_array.length} students in this course\"\n puts \"The Course roster is listed below\"\n # the code below neatly prints the contents of @student_array, making use of ruby's .ljust method\n puts @console_headers\n @student_array.each do |student|\n puts student[:first_name].ljust(20) + student[:last_name].ljust(20) +\n student[:email].ljust(35) + student[:section].to_s.ljust(10) +\n student[:major1].ljust(35) + student[:major2].to_s.ljust(35) +\n student[:minor1].to_s.ljust(35) + student[:minor2].to_s.ljust(35)\n end\n # in case of extremely large file, prints course information at bottom of file so need not scroll up\n if @student_array.length > 40\n puts \"The Course roster is listed above\"\n puts \"There are #{@student_array.length} students in this course\"\n end\n # Prompts the user to return to menu\n puts \"Press 'enter' to return to menu\"\n temp = gets.chomp\n user_menu\n end", "def print_catalog\n puts @name + \" Catalog\"\n puts Time.now.to_s\n\n # print all books as a table\n format = '%-15s %-15s %-30s %-20s %s'\n puts format % ['Book Number', 'ISBN', 'Title', 'Author', 'Available']\n self.each_with_index do |book, i|\n puts format % [ i+1, book.isbn, book.title, book.author, book.available ]\n end\n end", "def generate_table_of_contents(table_of_contents, file_names)\n\n contents_hash = Hash.new\n file_names.each_with_index do |val,index|\n contents_hash[index+1] = val[0..-5]\n end\n\n table_of_contents.table(contents_hash) do |table|\n table.rows(file_names.length)\n end\n\n table_of_contents.render_file \"table_of_contents.pdf\"\n\n # contents_hash = Hash.new\n\n # # add anchor tag to each element\n # file_names.each_with_index do |val,index|\n # contents_hash[index+1] = table_of_contents.add_dest(val, 6)\n # end\n\n # p contents_hash[1].class\n\n # # table_of_contents.table(contents_hash) do |table|\n # # table.rows(contents_hash.length)\n # # end\n\n # table_of_contents.render_file \"table_of_contents.pdf\"\n\nend", "def each_chapter\n @table_of_contents.each_with_index do |name, index|\n number = index + 1\n contents = File.read(\"data/chp#{number}.txt\")\n yield number, name, contents\n end\nend", "def header\r\n\tputs \"The students of Villains Academy starting with the letter \\\"R\\\".\"\r\n\tputs \"~~~~~~~~~~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~\"\t\r\nend", "def terminal_table\n rows = @moods.map do |mood|\n mood.to_arr\n end\n table = Terminal::Table.new({ headings: HEADINGS, rows: rows })\n puts table\n end", "def display_header\n puts \" 1 2 3 4 5 6 7 8 9 10\"\n puts \" -----------------------------------------\"\n end", "def justify\n lineWidth = 40\n puts (\"Table of Contents\".center(lineWidth))\n puts (\"Chapter 1: Numbers\".ljust(lineWidth/2) + \"page 1\".rjust(lineWidth/2))\n puts (\"Chapter 2: Letters\".ljust(lineWidth/2) + \"page 72\".rjust(lineWidth/2))\n puts (\"Chapter 3: Variables\".ljust(lineWidth/2) + \"page 118\".rjust(lineWidth/2))\nend", "def display_table(rows, columns)\n\tputs \"\\nYour Multiplication table:\"\n\tputs_labels(columns)\n puts_divider(columns)\n 1.upto(rows) do |row|\n \tputs_row(row, columns)\n end\nend", "def prt\n puts \"Federalist #@fedno\\n\"\n puts \"\\n#@title\\n\"\n puts \"\\n#@author\\n\"\n puts \"\\n#@content\\n\"\n end", "def overview( *settings )\r\n txt = []\r\n txt << \"List of ToDos/FixMes:\"\r\n @codelines.each do |key, todo|\r\n txt << todo.infoline(settings)\r\n end\r\n txt.join(\"\\n\")\r\n end", "def print_table(heading, data, length = 20, *options)\n table_width = (length + 2) * data[0].size\n # show header\n header_footer(options[1], table_width) if options[1]\n #show table body\n puts \"\".rjust(table_width, '#')\n heading.each {|title| print \"|\", \"\\e[31m\", title.center(length), \"\\e[0m\" }\n puts\n data.each do |data_row|\n data_row.each { |value| print \"|\",value.to_s.center(length) }\n puts \n end\n puts \"\".rjust(table_width, '#')\n #show footer\n header_footer(options[0], table_width) if options[0]\n end", "def printMultiplicationTable(numArray)\n puts \"\\nPrime numbers multiplication table\"\n \n # Printing beautified first row with initial margin\n firstRow = \" \"\n numArray.each do |i|\n firstRow += alignTabularValue(i.to_s) + \" | \"\n end\n \n puts firstRow\n \n numArray.each do |i|\n printString = alignTabularValue(i.to_s) + ' | '\n numArray.each do |ii|\n result = (i * ii).to_s\n \n printString += alignTabularValue(result) + ' | '\n end\n puts printString\n end\n \n puts \"\\n\"\n end", "def print_header\n\tprint \"\\nThe students of the September 2014 cohort at Makers Academy\\n\"\n\tprint \"-----------------------------------------------------------\\n\"\nend", "def print_table(n)\n prime_number = PrimeNumber.new(@path)\n prime_and_flag = prime_number.get_prime_numbers(n)\n table = Table.new(prime_and_flag[0])\n puts table.make_products_table\n if prime_and_flag[1]\n diff = prime_and_flag[2]\n File.open(File.expand_path(@path), \"a\") do |f|\n f.puts(prime_and_flag[0][diff..-1])\n end\n end\n end", "def print_prime_table\n out = ''\n prime_array = print_prime\n top_line = \"\\t#{prime_array.join(\"\\t\")}\"\n out += top_line + \"\\n\"\n for prime_row in prime_array\n line = \"\"\n line += \"#{prime_row}\\t\"\n for prime_col in prime_array\n line += \"#{prime_row * prime_col}\\t\"\n end\n out += line + \"\\n\"\n end\n out\n end", "def print_header\n\tputs \"The students of my cohort at Makers Academy\".center(77)\n\tputs \"-------------------------------------------\".center(77)\nend", "def print_menu\n puts \"1. Input the students\"\n puts \"2. Show the students\"\n puts \"3. Save the list to a csv file\"\n puts \"4. Load the list from a csv file\"\n puts \"5. Print the source code for this programme\"\n puts \"9. Exit\" # 9 because we'll be adding more items\nend", "def print_header\n\tputs \"----------------------------------------\"\n\tputs \"Makers Academy - January Cohort Students\"\n\tputs \"----------------------------------------\"\nend", "def print_board\n @tablero.row_vectors().each_with_index { |row, i|\n print \"#{row.component(i)}\\n\"\n }\n #Imprime los numeros de las columnas\n ([email protected]_vectors.size).each { |n|\n print \" #{n} \"\n }\n puts\n #Imprime las letras de las filas\n letras = (\"A\"..\"Z\").to_a\n ([email protected]_vectors.size).each do |i|\n print \"#{letras[i]} \"\n @tablero.row_vectors()[i].each do |fila|\n print \" #{fila} | \"\n end\n puts\n print \" ----\" * @tablero.row_count\n puts\n end\n end", "def report\n table = Terminal::Table.new(headings: ['Basic', 'Result']) do |t|\n t << [\"Number of paragraphs\", number_of_paragraphs]\n t << [\"Number of sentences\", number_of_sentences]\n t << [\"Number of words\", number_of_words]\n t << [\"Number of characters\", number_of_characters]\n t << [\"Number of syllables\", number_of_syllables]\n\n t << :separator\n t << [\"Average words per sentence\", mean_of_words_per_sentence]\n t << [\"Average syllables per word\", mean_of_syllables_per_word]\n t << [\"Average syllables per content word\", syllables_per_content_word]\n\n t << :separator\n t << [\"Verbs Ocurrencies\", verb_incidence]\n t << [\"Nouns Ocurrencies\", noun_incidence]\n t << [\"Adjective Ocurrencies\", adjective_incidence]\n t << [\"Adverb Ocurrencies\", adverb_incidence]\n t << [\"Pronoun Ocurrencies\", pronoun_incidence]\n t << [\"Content Word Ocurrencies\", content_word_incidence]\n t << [\"Function Word Ocurrencies\", function_word_incidence]\n\n t << :separator\n t << [\"Flesch score\", flesch]\n end\n puts table\n end", "def tabulate content, options\n data = []\n content.each {|line| data << line.join(\"\\t\"); }\n puts \"Rows: #{data.size}\" if $opt_verbose\n require 'tempfile'\n tmpfile = Tempfile.new('SQL.XXXXXX')\n filename = tmpfile.path\n #filename = Shellwords.escape(filename)\n #puts \"Writing to #{filename}\"\n tmpfile.write(data.join(\"\\n\"))\n tmpfile.close # need to flush, otherwise write is buffered\n if options[:formatting]\n system(\"term-table.rb < #{filename} | sponge #{filename}\")\n end\n return filename\nend", "def print_prime_table(n_primes)\n out = ''\n prime_array = is_prime_new(n_primes)\n top_line = \"\\t#{prime_array.join(\"\\t\")}\"\n out += top_line + \"\\n\"\n for prime_row in prime_array\n line = \"\"\n line += \"#{prime_row}\\t\"\n for prime_col in prime_array\n line += \"#{prime_row * prime_col}\\t\"\n end\n out += line + \"\\n\"\n end\n out\nend", "def printHeader\n puts \"!_TAG_FILE_FORMAT\\t2\\t/extended format/\\n\" \n puts \"!_TAG_FILE_SORTED\\t0\\t/0=unsorted, 1=sorted, 2=foldcase/\\n\"\n puts \"!_TAG_PROGRAM_AUTHOR\\tScott Shattuck\\t/[email protected]/\\n\"\n puts \"!_TAG_PROGRAM_URL\\t//\\n\"\n puts \"!_TAG_PROGRAM_NAME\\tjstags.rb\\t//\\n\"\n puts \"!_TAG_PROGRAM_VERSION\\t1.0\\t//\\n\"\n return\nend", "def prt(outputFile)\n # puts \"\\nFederalist #@fedno\" + \" Title: #@title\" #used for verification before \n puts \"#@fedno Title: #@title\\nPublication: #@pub\\n\\n\" #exporting to HTML doc\n # puts \"Written by: #@auth\"\n outputFile.puts \"<tr><th>#@fedno</th><th>#@auth</th><th>#@title</th><th>#@pub</th></tr>\"\n end", "def mostrar_tabla(array_anterior)\n tabla = Terminal::Table.new do |a|\n a.title= 'ORDENAR LISTA'\n a.headings = [{value:array_anterior, alignment: :center}]\n a.add_row([{value:mostrar_lista(), alignment: :center}])\n end\n puts tabla\n end", "def print_table(n)\n printer = Printer.new(first n)\n printer.print\n end", "def tab\n write(9)\n end", "def print_coin_names\n coin_names_arrays.each do |coin|\n coin.each do |name|\n index = name.slice!(/\\d+\\s/).strip\n table = terminal_table do |t|\n t.add_row [index, name]\n t.style = { all_separators: true, width: 60 }\n end\n puts table\n end\n yield\n end\n end", "def show_board\n \n puts \" 1 2 3\"\n puts \" a #{@A1.content} | #{@A2.content} | #{@A3.content}\"\n puts \" ---------\"\n puts \" b #{@B1.content} | #{@B2.content} | #{@B3.content}\"\n puts \" ---------\"\n puts \" c #{@C1.content} | #{@C2.content} | #{@C3.content}\"\n\n end", "def print_header\n\t\t\"The students of Makers Academy\\n=======================================\"\nend", "def generate_codepage_table(cp)\n puts \"Generating codepage table for #{cp}\"\n ranges = codepage_table(cp)\n open(cp.downcase+\".go\", \"w\") do |f|\n f.puts \"package codepage\", \"\"\n f.puts \"var #{cp.gsub('-', '_')} = Codepage{\"\n ranges.each do |range|\n f.puts \"\\t{0x%04X, 0x%04X, %d, %d},\" % [range.first, range.first + range.count - 1, range.count, range.delta]\n end\n f.puts \"}\"\n end\nend", "def pp_table(headers, rows)\n if headers.empty? || rows.empty?\n return\n end\n puts headers.map { |h| \"%20s\" % h.upcase }.join\n rows.map { |cols| puts cols.map { |c| \"%20s\" % c }.join }\n #puts \"=\" * 80\nend", "def readme\n puts\n puts \"Usage of machine_age.rb\"\n puts \"=======================\"\n puts\n puts \"1. Machine analysis\"\n puts \"-------------------\"\n puts \"1.0 clean_ib_source (INFILE EUNA download)\"\n puts \"1.1 copy_column\"\n puts \"1.2 abc_analysis (INFILE: EUNA download)\"\n puts \"1.3 machine_age (INFILE: EUNA downlaod\"\n puts \"1.4 machine_count_top (INFILE: see note)\"\n puts \" Note: use the resulting file from 'machine_age'\"\n puts\n puts \"2. Spares and Repairs analysis\"\n puts \"------------------------------\"\n puts \"2.1 extract_regional_data (INFILE: DWH download)\"\n puts \" Note: Only if you want to analyze a specific country and extract \"\n puts \" it from a world file\"\n puts \"2.2 insert_customer_data (INFILE: result from 2.1 or DWH download\"\n puts \"2.3 region_revenue (INFILE: result from 2.2 or DWH download)\"\n puts \"2.4 customer_revenue (INFILE: result from 2.2)\" \n puts\n puts \"3. Conduct complete analysis in one swoop\"\n puts \"-----------------------------------------\"\n puts \"3.1 machine_analysis (includes 1.1 - 1.3, INFILE: EUNA downlaod)\"\n puts \"3.2 spares_and_repairs_analysis_complete (includes 2.1 - 2.4,\"\n puts \" INFILE: DWH download)\"\n puts \"3.3 spares_and_repairs_analysis (includes 2.3 - 2.4,\"\n puts \" INFILE: DWH downlaod)\"\nend", "def display_branch_list\n table = build_table_view\n\n puts \"\\n\\n\"\n puts table\n end", "def build_table(patients)\n rows = []\n patients.each do | person |\n rows << [person[:bed_no], person[:hospital_no], person[:first_name], person[:last_name], person [:dob], person[:age], person[:current_diagnosis] ]\n x = person[:medications]\n puts x[:name]\n end\n\n\n table = Terminal::Table.new :rows => rows\n table.title = \"Your Patients for the Day!\"\n table.headings = ['Bed Number', 'Hospital Number', 'First Name', 'Last Name', 'D.O.B', 'Age', 'Current Diagnosis', 'Medications']\n puts table\nend", "def display_stats\n #Table of dragon stats\n table = Terminal::Table.new do |t|\n t.headings = ['Type','Dragon']\n t.add_row ['HP', '100']\n end\n puts table #print table \n end", "def output_terminal(doc_info)\n\n # Header\n puts\n puts \"File: #{doc_info[:file]}\"\n puts \"Modified: #{doc_info[:modified]}\"\n\n # Goal section\n unless doc_info[:goals].nil?\n gdend = doc_info[:goals][:end]\n gwtotal = doc_info[:goals][:goal_total]\n gwdaily = doc_info[:goals][:goal_daily]\n unless gwtotal == 0\n tactual = doc_info[:sections][0][:words]\n (tactuals, tactperc) = meter(tactual, gwtotal)\n end\n unless gwdaily == 0\n # Coloring the actuals\n dactual = doc_info[:today][:end] - doc_info[:today][:start]\n (dactuals, dactperc) = meter(dactual, gwdaily)\n end\n unless gdend.nil?\n dstart = doc_info[:goals][:start]\n ddur = (gdend - dstart).round\n ddiff = (gdend - Date.today).round\n dsleft = case\n when ddiff == 0 then 'today'\n when ddiff > 0 then \"#{ddiff} day(s) left\"\n else \"#{ddiff} day(s) behind schedule\"\n end\n end\n unless (gdend.nil? && gwtotal == 0 && gwdaily == 0)\n puts \"Goals\".bold\n puts \"Delivery: #{dsleft}, #{gdend}\" unless gdend.nil?\n puts \"Words, total: #{tactperc} #{tactuals}/#{gwtotal}\" unless gwtotal == 0\n puts \"Words, daily: #{dactperc} #{dactuals}/#{gwdaily}\" unless gwdaily == 0\n end\n end\n # Structure\n puts\n puts \"Document structure\".bold\n puts format(\"%-57.57s %-16s %5s\", 'Title', 'Tag', 'Words')\n puts \"-\"*80\n doc_info[:sections].each do |s|\n puts format(\"%-57.57s %-16s %5d\", (' ' * s[:level])+s[:title], s[:tag], s[:words])\n end\n #Remarks\n if doc_info[:remarks]\n puts\n puts \"Remarks\".bold\n puts format(\"%-10.10s %20.20s %5s %-52s\", Type, File, Line, Content)\n puts \"-\"*80\n doc_info[:remarks].each do |r|\n puts format(\"%-10.10s %20.20s %5d %-42.42s\", \"#{r[:keyword]}\", r[:file], r[:line], r[:text])\n puts format(\"%s %-42.42s\", ' '*37, r[:text][42..84]) if r[:text].length > 42\n end\n end\nend", "def print_table(columns, data, print_headings = true)\n\n # Fill base lengths\n columns.each do |col|\n col[:length] = (print_headings ? col[:title].length : 0)\n end\n\n # Compute maximum length of each field\n data.each do |datum|\n\n columns.each do |col|\n if (col[:func] != nil)\n str = col[:func].call(datum).to_s\n else\n str = datum[col[:key]].to_s\n end\n str = str.gsub(/\\e\\[[0-9;]*m/, '') # eliminate \"colors\"\n col[:length] = [ col[:length], str.length ].max\n end\n\n end\n\n # Create the format string\n table_format_row = '|'\n columns.each do |col|\n if (col[:type] == :int)\n table_format_row << sprintf(\" %%%dd |\", col[:length])\n else\n table_format_row << sprintf(\" %%-%ds |\", col[:length])\n end\n end\n table_format_row << \"\\n\"\n\n # Special line: title\n table_format_title = \"\\e[1m\\e[4m\" +\n table_format_row.gsub(/%-?([0-9]+)[a-z]/, '%-\\1s').gsub(/\\|/, ' ') + \"\\e[m\"\n\n # Create the horizontal line\n table_horizontal = '+'\n columns.each do |col|\n table_horizontal << '-' * (col[:length]+2) << '+'\n end\n\n # Print table\n if (print_headings)\n titles = []\n columns.each do |col|\n titles << col[:title]\n end\n #puts table_horizontal\n printf(table_format_title, *titles);\n else\n puts table_horizontal\n end\n\n data.each do |datum|\n cols_ary = []\n columns.each do |col|\n if (col[:func])\n cols_ary << col[:func].call(datum)\n else\n cols_ary << datum[col[:key]]\n end\n end\n printf(table_format_row, *cols_ary)\n #puts table_horizontal\n end\n puts table_horizontal\n\nend", "def print_table_t(objects, *method_names)\n terminal_width = `tput cols`.to_i\n cols = objects.count + 1 # Label column\n col_width = (terminal_width / cols) - 1 # Column spacing\n\n Array(method_names).map do |method_name|\n cells = objects.map { |o| o.send(method_name).inspect }\n cells.unshift(method_name)\n\n puts cells.map { |cell| cell.to_s.ljust(col_width) }.join \" \"\n end\n nil\nend", "def display_table\n loc = 1\n for card in @cards_showing\n print (\"\\e[0m#{loc}\".ljust(8, \" \") + \"#{card.display_card}\" + \" \".ljust(20, \" \"))\n loc += 1\n puts \"\" if (loc % 2 != 0) || (loc == (@table_size + 1) && @table_size != @table_max)\n end\n\n print \"\\e[0m\"\n end", "def print_prime_multiples\n \ttabs = \"\\t\" * (no_of_primes/2 - 3) rescue \"\\t\"\n print \"\\n #{tabs} Multiplication Table for first #{no_of_primes} Prime numbers \\n\\n\"\n\n prime_array.length.times do |i|\n \t\tprint \" _ _ _\"\n \tend\n \tprint \"\\n\"\n\n \tprime_array.length.times do |i|\n \t\tif(i == 0)\n \t\t\tprint \"| \\t\"\n \t\telse\n \t\t\tprint \"| #{ordinal(i)} \\t\"\n \t\tend\n \tend\n \tprint \"|\\n\"\n \t\n \tprime_array.length.times do |i|\n \t\tprint \" _ _ _\"\n \tend\n \tprint \"\\n\"\n \t\n \toutput_array.each do |i|\n print \"\\n\"\n \t\ti.each do |j|\n \t\t\tprint \"| #{j} \\t\"\n \t\tend\n \t\tprint \"|\\n\"\n \t\ti.each do |j|\n \t\t\tprint \" _ _ _\"\n \t\tend\n \t\tprint \"\\n\"\n \tend\n \treturn\n end", "def display_book\n\t\tputs \"Author: #@author, Title: #@title, Publisher: #@publisher, Year: #@year, Location: Shelf: #@shelf_num\"\n\tend", "def show_primer_table primer_tab, primers_over_60, primers_over_90\n data = show do\n title \"Create an IDT DNA oligos order\"\n \n warning \"Oligo concentration for primer(s) #{primers_over_60} will have to be set to \\\"100 nmole DNA oligo.\\\"\" if primers_over_60 != \"\"\n warning \"Oligo concentration for primer(s) #{primers_over_90} will have to be set to \\\"250 nmole DNA oligo.\\\"\" if primers_over_90 != \"\"\n \n #check \"Click Custom DNA Oligos, click Bulk Input. Copy paste the following table and then click the Update button.\"\n \n check \"Under \\\"Custom DNA Oligos\\\", click \\\"DNA Oligos\\\", then under \\\"Single-stranded DNA\\\" click \\\"Order now\\\", and click \\\"Bulk input\\\". Copy and paste the following table there.\"\n table primer_tab\n \n check \"Click Add to Order, review the shopping cart to double check that you entered correctly. There should be #{operations.length} primers in the cart.\"\n check \"Click Checkout, then click Continue.\"\n check \"Enter the payment information, click the oligo card tab, select the Card1 in Choose Payment and then click Submit Order.\"\n check \"Go back to the main page, let it sit for 5-10 minutes, return and refresh, and find the order number for the order you just placed.\"\n \n get \"text\", var: \"order_number\", label: \"Enter the IDT order number below\", default: 100\n end\n\n operations.each { |op| op.set_output_data(\"Primer\", :order_number, data[:order_number]) }\n end", "def with_toc(src)\n toc = \"<div class=\\\"toc\\\">\\n\"\n last_level = 1\n src = src.gsub(/<h(\\d)>(.*)<\\/h\\d>/) do |line|\n level, heading = $1.to_i, $2.strip\n aname = URI.escape(heading)\n toc << \"\\t\"*last_level << \"<ol class='level-#{level-1}'>\\n\" if level > last_level\n toc << \"\\t\"*level << \"</ol>\"*(last_level - level) << \"\\n\" if level < last_level\n toc << \"\\t\"*level << \"<li><a href='##{aname}'>#{heading}</a></li>\\n\"\n last_level = level\n \"<a name=\\\"#{aname}\\\"></a>\\n\" << line\n end\n toc << \"\\t\" << \"</ol>\"*(last_level-1) << \"\\n</div>\\n\"\n toc + src\nend", "def table(opts = { print: true })\n require \"inspec/ui_table_helper\"\n\n the_table = TableHelper.new\n yield(the_table)\n\n colorizer = proc do |data, row, _col|\n if color? && row == 0\n ANSI_CODES[:bold] + ANSI_CODES[:color][:white] + data.to_s + ANSI_CODES[:reset]\n else\n data\n end\n end\n render_mode = color? ? :unicode : :ascii\n padding = [0, 1, 0, 1] # T R B L\n result = the_table.render(render_mode, filter: colorizer, padding: padding) + \"\\n\"\n print_or_return(result, opts[:print])\n end", "def printTabla(nivel)\n\t\tprintNivel(nivel)\n\t\tputs \"SYMBOL TABLE\"\n\n\t\[email protected] do |identificador, valor|\n\t\t\tprintNivel(nivel+1)\n\t\t\tputs \"Name: #{identificador}, Type: #{valor.str}\"\n\t\tend\n\tend", "def important_toc(*attributes)\n puts attributes.collect { |a| _link(a) }.join(SEPSTRING)\nend", "def with_toc(src)\n toc = \"<div class='toc'>\\n\"\n last_level = 1\n src = src.gsub(/<h(\\d)>(.*)<\\/h\\d>/) do |line|\n level, heading = $1.to_i, $2.strip\n aname = URI.escape(heading)\n toc << \"\\t\"*last_level << \"<ol class='level-#{level-1}'>\\n\" if level > last_level\n toc << \"\\t\"*level << \"</ol>\"*(last_level - level) << \"\\n\" if level < last_level\n toc << \"\\t\"*level << \"<li><a href='##{aname}'>#{heading}</a></li>\\n\"\n last_level = level\n \"<a name='#{aname}'></a>\\n\" << line\n end\n toc << \"\\t\" << \"</ol>\"*(last_level-1) << \"\\n</div>\\n\"\n toc + src\nend", "def print_header()\n printf(\"%18sBATNUM\\n\", \"\")\n puts(\"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\")\n 2.times { puts }\n print <<EOM\nTHIS PROGRAM IS A 'BATTLE OF NUMBERS'\nGAME, WHERE THE COMPUTER IS YOUR OPPONENT\n\nTHE GAME STARTS WITH AN ASSUMED PILE OF OBJECTS.\nYOU AND YOUR OPPONENT ALTERNATELY REMOVE OBJECTS FROM\nTHE PILE. WINNING IS DEFINED IN ADVANCE AS TAKING THE\nLAST OBJECT OR NOT. YOU CAN ALSO SPECIFY SOME OTHER\nBEGINNING CONDITIONS. DON'T USE ZERO, HOWEVER, IN\nPLAYING THE GAME.\n\nEOM\nend", "def print_table_names\r\n get_tables.each do |name| \r\n print \"#{name} \"\r\n end\r\n puts \"\"\r\n end", "def list_header(title)\n 2.times do\n puts (\"\")\n end\n puts (\"Details of your todo list #{title}\")\n puts (\"\")\n end", "def display_text\n system(\"clear\")\n text_font = TTY::Font.new(:doom)\n text_title = Pastel.new\n puts text_title.cyan.bold(text_font.write(\"TEXT\", letter_spacing: 2))\n text = []\n CSV.foreach(\"text_manipulation.csv\", headers: true).select { |row| \n text << [row[\"title\"], row[\"description\"], row[\"code snippet\"]]\n }\n text_table = TTY::Table.new([\"Title\",\"Description\",\"Code Snippet\"], text)\n puts text_table.render(:unicode, multiline: true, alignments: [:left, :left], padding:[1,1])\nend", "def print_header\n puts \"The students of Villains Academy\".center(80)\n puts \"--------------\".center(80)\nend", "def output\n # adds header to beginning of main array then joins all elements with a blank space\n (@main.unshift(@header)).join(' ')\n end" ]
[ "0.75025827", "0.721961", "0.678244", "0.6566309", "0.633035", "0.633035", "0.6299628", "0.6262416", "0.62353283", "0.62247926", "0.6187457", "0.61871845", "0.6183919", "0.61698544", "0.61524606", "0.61438", "0.6131542", "0.6130732", "0.6089386", "0.60757464", "0.60741955", "0.60516703", "0.60508716", "0.60452724", "0.60396975", "0.60392964", "0.60392964", "0.60379094", "0.6037064", "0.60341454", "0.6029474", "0.6029316", "0.6029316", "0.6029316", "0.6029142", "0.6028638", "0.6012972", "0.6011495", "0.60080314", "0.60072654", "0.5998123", "0.59916437", "0.59880245", "0.5962262", "0.59465367", "0.5939651", "0.5916987", "0.590442", "0.59040403", "0.589915", "0.58869356", "0.5858935", "0.5858085", "0.5855469", "0.58428806", "0.58425903", "0.5839155", "0.5818596", "0.5799339", "0.57953507", "0.57877505", "0.57873046", "0.57733065", "0.57618237", "0.5761068", "0.5757527", "0.5734411", "0.5721184", "0.5713658", "0.57045954", "0.5692599", "0.56920266", "0.5690035", "0.5680923", "0.56634516", "0.5654332", "0.56532943", "0.5650875", "0.564394", "0.5641652", "0.5639038", "0.56363904", "0.56361157", "0.5633572", "0.5632452", "0.5622506", "0.5614979", "0.56111926", "0.5605769", "0.55985653", "0.55871004", "0.5578654", "0.5578637", "0.5572395", "0.5572371", "0.5568891", "0.55610055", "0.5559726", "0.5556532", "0.55540204", "0.55531514" ]
0.0
-1
Connects to the Stomp middleware TODO: write to use logic from super class
def connect(connector = ::Stomp::Connection) if @connection Log.debug("Already connection, not re-initializing connection") return end begin host = nil port = nil user = nil password = nil @@base64 = false @@base64 = get_bool_option("stomp.base64", false) @@msgpriority = get_option("stomp.priority", 0).to_i # Maintain backward compat for older stomps host = get_env_or_option("STOMP_SERVER", "stomp.host") port = get_env_or_option("STOMP_PORT", "stomp.port", 6163).to_i user = get_env_or_option("STOMP_USER", "stomp.user") password = get_env_or_option("STOMP_PASSWORD", "stomp.password") #TODO: assume reactor is running already @connection = EM.connect host, port, StompClient, :login => user, :passcode => password Log.debug("Connecting to #{host}:#{port}") rescue Exception => e pp e.backtrace[0..5] raise("Could not connect to Stomp Server: #{e}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect\n if @connection\n Log.debug(\"Already connection, not re-initializing connection\")\n return\n end\n\n begin\n host = nil\n port = nil\n user = nil\n password = nil\n @base64 = get_bool_option(\"stomp.base64\", false)\n @msgpriority = get_option(\"stomp.priority\", 0).to_i\n\n # Maintain backward compat for older stomps\n unless @config.pluginconf.include?(\"stomp.pool.size\")\n host = get_env_or_option(\"STOMP_SERVER\", \"stomp.host\")\n port = get_env_or_option(\"STOMP_PORT\", \"stomp.port\", 6163).to_i\n user = get_env_or_option(\"STOMP_USER\", \"stomp.user\")\n password = get_env_or_option(\"STOMP_PASSWORD\", \"stomp.password\")\n\n Log.debug(\"Connecting to #{host}:#{port}\")\n @connection = ::Stomp::Connection.new(user, password, host, port, true)\n else\n pools = @config.pluginconf[\"stomp.pool.size\"].to_i\n hosts = []\n\n 1.upto(pools) do |poolnum|\n host = {}\n\n host[:host] = get_option(\"stomp.pool.host#{poolnum}\")\n host[:port] = get_option(\"stomp.pool.port#{poolnum}\", 6163).to_i\n host[:login] = get_env_or_option(\"STOMP_USER\", \"stomp.pool.user#{poolnum}\")\n host[:passcode] = get_env_or_option(\"STOMP_PASSWORD\", \"stomp.pool.password#{poolnum}\")\n host[:ssl] = get_bool_option(\"stomp.pool.ssl#{poolnum}\", false)\n\n Log.debug(\"Adding #{host[:host]}:#{host[:port]} to the connection pool\")\n hosts << host\n end\n\n raise \"No hosts found for the STOMP connection pool\" if hosts.size == 0\n\n connection = {:hosts => hosts}\n\n # Various STOMP gem options, defaults here matches defaults for 1.1.6 the meaning of\n # these can be guessed, the documentation isn't clear\n connection[:initial_reconnect_delay] = get_option(\"stomp.pool.initial_reconnect_delay\", 0.01).to_f\n connection[:max_reconnect_delay] = get_option(\"stomp.pool.max_reconnect_delay\", 30.0).to_f\n connection[:use_exponential_back_off] = get_bool_option(\"stomp.pool.use_exponential_back_off\", true)\n connection[:back_off_multiplier] = get_bool_option(\"stomp.pool.back_off_multiplier\", 2).to_i\n connection[:max_reconnect_attempts] = get_option(\"stomp.pool.max_reconnect_attempts\", 0)\n connection[:randomize] = get_bool_option(\"stomp.pool.randomize\", false)\n connection[:backup] = get_bool_option(\"stomp.pool.backup\", false)\n connection[:timeout] = get_option(\"stomp.pool.timeout\", -1).to_i\n\n @connection = ::Stomp::Connection.new(connection)\n end\n rescue Exception => e\n raise(\"Could not connect to Stomp Server: #{e}\")\n end\n end", "def connect!\n sessions\n self\n end", "def client_class\n Stomp::Client\n end", "def connect!; end", "def connect!; end", "def connect(*) end", "def connect!\n request! :connect\n end", "def initialize(options)\n host = {:host => options[:host], :port => options[:port]}\n host[:passcode] = options[:password] if options[:password]\n host[:login] = options[:username] if options[:username]\n headers = {}\n headers.merge!(:host => options[:host], :\"accept-version\" => \"1.2\", :\"heart-beat\" => \"2000,0\") unless options[:heartbeat] == false\n headers.merge!(:\"client-id\" => options[:client_id]) if options[:client_id]\n\n @stomp_client = Stomp::Client.new(:hosts => [host], :connect_headers => headers)\n end", "def start\n self.connect\n self.login if @connected\n end", "def middleware; end", "def connect; end", "def initialize(connection) \n @SocketHandle = connection \n connection.puts \"Admin session\"\n\n handleRequest\n end", "def connect\n force_connect unless @handler\n end", "def middleware\n connection.builder\n end", "def connect\n end", "def connect(used_socket)\n @connect_headers = {} unless @connect_headers # Caller said nil/false\n headers = @connect_headers.clone\n headers[:login] = @login unless @login.to_s.empty?\n headers[:passcode] = @passcode unless @login.to_s.empty?\n _pre_connect\n if !@hhas10 && @stompconn\n _transmit(used_socket, Stomp::CMD_STOMP, headers)\n else\n _transmit(used_socket, Stomp::CMD_CONNECT, headers)\n end\n @connection_frame = _receive(used_socket, true)\n _post_connect\n @disconnect_receipt = nil\n @session = @connection_frame.headers[\"session\"] if @connection_frame\n # replay any subscriptions.\n @subscriptions.each {|k,v|\n _transmit(used_socket, Stomp::CMD_SUBSCRIBE, v)\n }\n end", "def connect_through_proxy; end", "def connect\n require 'osc-ruby' unless defined?(::OSC)\n port = additional_params[:port] || 3333\n @client = OSC::Server.new(port)\n super\n end", "def initialize(options)\n host = { :host => options[:host], :port => options[:port] }\n host[:passcode] = options[:password] if options[:password]\n host[:login] = options[:username] if options[:username]\n\n headers = {}\n unless options[:heartbeat] == false\n headers.merge!(\n :host => options[:host],\n :\"accept-version\" => \"1.2\",\n :\"heart-beat\" => \"2000,0\")\n end\n headers[:\"client-id\"] = options[:client_ref] if options[:client_ref]\n\n @stomp_client = ::Stomp::Client.new(:hosts => [host], :connect_headers => headers)\n end", "def start\n return if active?\n begin\n @subject.start\n rescue Errno::ECONNRESET\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Connection failed. network error to: #{connection_params}\"\n rescue Bunny::TCPConnectionFailed\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Connection failed to: #{connection_params}\"\n rescue Bunny::PossibleAuthenticationFailureError\n raise EventSource::Protocols::Amqp::Error::AuthenticationError,\n \"Likely athentication failure for account: #{@subject.user}\"\n rescue StandardError\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Unable to connect to: #{connection_params}\"\n else\n sleep 1.0\n logger.info \"Connection #{connection_uri} started.\" if active?\n active?\n end\n end", "def spawn_connection\n connect\n end", "def connect!\n end", "def middleware(&block); end", "def receive\n Log.debug(\"Waiting for a message from Stomp\")\n msg = @connection.receive\n\n # STOMP puts the payload in the body variable, pass that\n # into the payload of MCollective::Request and discard all the\n # other headers etc that stomp provides\n if @base64\n Request.new(SSL.base64_decode(msg.body))\n else\n Request.new(msg.body)\n end\n end", "def connect\n super\n end", "def connect\n super\n end", "def websocket; end", "def websocket; end", "def middleware\n connection.builder\n end", "def connect\n rabbit.transaction_short do\n @publisher = Rabbit::Publisher::Admin.new(rabbit.channel)\n yield\n end\n end", "def connect\n\t\[email protected]\n\n\t\t# Set up our input and output exchange/queue\n\t\t@output = @client.exchange( @playername, :passive => false )\n\t\t@queue = @client.queue\n\n\t\t@exchange = @client.exchange( @playername, :passive => false )\n\t\t@queue = @client.queue( \"#{@playername}_output\", :exclusive => true )\n\n\t\tlogin_exchange = @client.exchange( 'login', :type => :direct, :auto_delete => true )\n\n\t\t# Set up the queue to handle incoming connections\n\t\tself.log.debug \" setting up the connections queue...\"\n\t\t@connect_queue = @playersbus.queue( 'connections', :exclusive => true )\n\t\t@connect_queue.bind( @login_exch, :key => :character_name )\n\t\t@connect_queue.subscribe(\n\t\t\t:header => true,\n\t\t\t:consumer_tag => 'engine',\n\t\t\t:exclusive => true,\n\t\t\t:no_ack => false,\n\t\t\t&self.method(:handle_connect_event)\n\t\t )\n\tend", "def start_session(endpoint); end", "def handshake\n end", "def connect\n connection.tap do |c|\n c.start\n end\n end", "def connect\n rabbit.transaction_short do\n choose_queue\n yield\n end\n end", "def setup\n\n\tsb = ServerBroker.new\n\tcb = ClientBroker.new(sb)\n\tcp = ClientProxy.new(cb)\n\n\tClient.new(cp)\n\nend", "def initialize\n\t\tsuper\n\n\t\t@socket = UDPSocket.new\n\t\t@amqp_session = nil\n\t\t@amqp_channel = Concurrent::ThreadLocalVar.new { @amqp_session.create_channel }\n\t\t@amqp_exchange = Concurrent::ThreadLocalVar.new do\n\t\t\t@amqp_channel.value.headers( self.class.exchange, passive: true )\n\t\tend\n\t\t@processing = false\n\tend", "def initialize(exchange_name = nil, routing_key: nil, connection: nil, context: nil, ident: nil, expiration: nil, persistent: true, durable: true, timeout: nil)\n super(connection: connection, context: context, ident: ident)\n\n @routing_key = routing_key\n @timeout = timeout\n\n @rpc_exchange = self.channel.direct(\n exchange_name || EXCHANGE_NAME_DEFAULT,\n durable: durable\n )\n\n @response_queue = self.channel.queue(\n @ident,\n durable: false,\n header: true,\n auto_delete: true\n )\n @expiration = expiration\n @persistent = !!persistent\n\n @callback = { }\n\n @consumer = Skein::Adapter.subscribe(@response_queue, block: false) do |payload, delivery_tag, reply_to|\n self.context.trap do\n if (ENV['SKEIN_DEBUG_JSON'])\n $stdout.puts(payload)\n end\n\n response = JSON.load(payload)\n\n if (callback = @callback.delete(response['id']))\n if (response['error'])\n exception =\n case (response['error'] and response['error']['code'])\n when -32601\n NoMethodError.new(\n \"%s from `%s' RPC call\" % [\n response.dig('error', 'message'),\n response.dig('error', 'data', 'method')\n ]\n )\n when -32602\n ArgumentError.new(\n response.dig('error', 'data', 'message') || 'wrong number of arguments'\n )\n else\n RPCException.new(\n response.dig('error', 'data', 'message') || response.dig('error', 'message')\n )\n end\n\n case (callback)\n when Skein::TimeoutQueue\n callback << exception\n when Proc\n callback.call(exception)\n end\n else\n case (callback)\n when Skein::TimeoutQueue\n callback << response['result']\n when Proc\n callback.call(response['result'])\n end\n end\n end\n\n self.channel.acknowledge(delivery_tag)\n end\n end\n end", "def connect\n # Implement in subclass\n end", "def connect\n self.send({\n msg: :connect,\n version: @version,\n support: @support\n })\n\n #handle incoming response form the server\n self.onmessage = lambda do |event|\n\n res = JSON.parse(event.data)\n\n if res.has_key? 'session'\n #connection is successful - update session and record version\n @session = res['session'].to_s\n @@last_suc_version = @version\n\n else #there was a failed connection\n @version = res['version']\n #retry the send request with the version specified by the server\n self.send({\n msg: :connect\n version: @version,\n support: @support\n })\n end\n\n end\n end", "def pre_connect(request); end", "def initialize(app = nil, options = {})\n @app = app\n @options = {\n path: '/stream',\n namespace: '',\n keepalive_timeout: 20\n }.merge(options)\n @subscription_map = {}\n EventMachine::next_tick { setup_redis }\n EventMachine::next_tick { setup_keepalive }\n end", "def open_ssl_socket()\n require 'openssl' unless defined?(OpenSSL)\n begin # Any raised SSL exceptions\n ctx = @sslctx_newparm ? OpenSSL::SSL::SSLContext.new(@sslctx_newparm) : OpenSSL::SSL::SSLContext.new\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Assume for now\n #\n # Note: if a client uses :ssl => true this would result in the gem using\n # the _default_ Ruby ciphers list. This is _known_ to fail in later\n # Ruby releases. The gem now detects :ssl => true, and replaces that\n # with:\n # * :ssl => Stomp::SSLParams.new\n #\n # The above results in the use of Stomp default parameters.\n #\n # To specifically request Stomp default parameters, use:\n # * :ssl => Stomp::SSLParams.new(..., :ciphers => Stomp::DEFAULT_CIPHERS)\n #\n # If connecting with an SSLParams instance, and the _default_ Ruby\n # ciphers list is actually required, use:\n # * :ssl => Stomp::SSLParams.new(..., :use_ruby_ciphers => true)\n #\n # If a custom ciphers list is required, connect with:\n # * :ssl => Stomp::SSLParams.new(..., :ciphers => custom_ciphers_list)\n #\n if @ssl != true\n #\n # Here @ssl is:\n # * an instance of Stomp::SSLParams\n # Control would not be here if @ssl == false or @ssl.nil?.\n #\n\n # Back reference the SSLContext\n @ssl.ctx = ctx\n\n # Server authentication parameters if required\n if @ssl.ts_files\n ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER\n truststores = OpenSSL::X509::Store.new\n fl = @ssl.ts_files.split(\",\")\n fl.each do |fn|\n # Add next cert file listed\n raise Stomp::Error::SSLNoTruststoreFileError if !File::exists?(fn)\n raise Stomp::Error::SSLUnreadableTruststoreFileError if !File::readable?(fn)\n truststores.add_file(fn)\n end\n ctx.cert_store = truststores\n end\n\n # Client authentication parameters.\n # Both cert file and key file must be present or not, it can not be a mix.\n raise Stomp::Error::SSLClientParamsError if @ssl.cert_file.nil? && [email protected]_file.nil?\n raise Stomp::Error::SSLClientParamsError if [email protected]_file.nil? && @ssl.key_file.nil?\n if @ssl.cert_file # Any check will do here\n raise Stomp::Error::SSLNoCertFileError if !File::exists?(@ssl.cert_file)\n raise Stomp::Error::SSLUnreadableCertFileError if !File::readable?(@ssl.cert_file)\n ctx.cert = OpenSSL::X509::Certificate.new(File.read(@ssl.cert_file))\n raise Stomp::Error::SSLNoKeyFileError if !File::exists?(@ssl.key_file)\n raise Stomp::Error::SSLUnreadableKeyFileError if !File::readable?(@ssl.key_file)\n ctx.key = OpenSSL::PKey::RSA.new(File.read(@ssl.key_file), @ssl.key_password)\n end\n\n # Cipher list\n # As of this writing, there are numerous problems with supplying\n # cipher lists to jruby. So we do not attempt to do that here.\n if [email protected]_ruby_ciphers # No Ruby ciphers (the default)\n if @ssl.ciphers # User ciphers list?\n ctx.ciphers = @ssl.ciphers # Accept user supplied ciphers\n else\n ctx.ciphers = Stomp::DEFAULT_CIPHERS # Just use Stomp defaults\n end\n end unless @jruby\n\n # Set SSLContext Options if user asks for it in Stomp::SSLParams\n # and SSL supports it.\n if @ssl.ssl_ctxopts && ctx.respond_to?(:options=)\n ctx.options = @ssl.ssl_ctxopts\n end\n\n end\n\n #\n ssl = nil\n slog(:on_ssl_connecting, log_params)\n # _dump_ctx(ctx)\n Timeout::timeout(@connect_timeout, Stomp::Error::SocketOpenTimeout) do\n tcp_socket = TCPSocket.open(@host, @port)\n ssl = OpenSSL::SSL::SSLSocket.new(tcp_socket, ctx)\n ssl.hostname = @host if ssl.respond_to? :hostname=\n ssl.sync_close = true # Sync ssl close with underlying TCP socket\n ssl.connect\n if (ssl.context.verify_mode != OpenSSL::SSL::VERIFY_NONE) && @ssl_post_conn_check\n ssl.post_connection_check(@host)\n end\n end\n def ssl.ready?\n ! @rbuffer.empty? || @io.ready?\n end\n if @ssl != true\n # Pass back results if possible\n if RUBY_VERSION =~ /1\\.8\\.[56]/\n @ssl.verify_result = \"N/A for Ruby #{RUBY_VERSION}\"\n else\n @ssl.verify_result = ssl.verify_result\n end\n @ssl.peer_cert = ssl.peer_cert\n end\n slog(:on_ssl_connected, log_params)\n ssl\n rescue Exception => ex\n lp = log_params.clone\n lp[:ssl_exception] = ex\n slog(:on_ssl_connectfail, lp)\n if ssl\n # shut down the TCP socket - we just failed to do the SSL handshake in time\n ssl.close\n end\n #\n puts ex.backtrace\n $stdout.flush\n raise # Reraise\n end\n end", "def setup\n open_session\n end", "def start\n EM.run do\n @__conn = EventMachine::WebSocketClient.connect(@__socket_url)\n\n @__callbacks[:connection_established] &&\n @__conn.callback do\n instance_exec(&@__callbacks[:connection_established])\n end\n\n @__callbacks[:error] &&\n @__conn.errback do |e|\n instance_exec(e, &@__callbacks[:error])\n end\n\n @__conn.stream do |msg|\n @__conn.close_connection if msg.data == \"done\"\n\n event = JSON.parse(msg.data)[1]\n case event['type']\n when 'paired'\n @__event_pool[:paired] = event\n\n when 'connected'\n break unless @__callbacks[:connected]\n instance_exec(&@__callbacks[:connected])\n @__event_pool[:connected] = event\n\n when 'arm_synced'\n @__event_pool[:arm_synced] = event\n\n when 'unlocked'\n puts(\"unlocked!\")\n @__event_pool[:unlocked] ||= false\n @__event_pool[:unlocked] = true\n\n when 'pose'\n\n break unless @__callbacks[:pose]\n pose = event['pose']\n puts \"this is pose: \" + pose\n #instance_exec(@__event_pool[:pose][:pose], :off, &@__callbacks[:pose]) if @__event_pool[:pose][:pose]\n instance_exec(pose, :on, &@__callbacks[:pose])\n @__event_pool[:pose] = event\n\n when 'orientation'\n break unless @__callbacks[:periodic]\n e = OpenStruct.new({\n :accel => OpenStruct.new({\n :x => event['accelerometer'][0],\n :y => event['accelerometer'][1],\n :z => event['accelerometer'][2]\n }),\n :gyro => OpenStruct.new({\n :x => event['gyroscope'][0],\n :y => event['gyroscope'][1],\n :z => event['gyroscope'][2]\n }),\n :orientation => OpenStruct.new(event['orientation'])\n })\n @__event_pool[:orientation] = e\n instance_exec(e, &@__callbacks[:periodic])\n\n end\n end\n\n @__conn.disconnect do\n EM::stop_event_loop\n end\n end\n end", "def initialize(options = {})\n @ws_server = options[:host] || \"ws://localhost:9000\"\n @protocols = options[:protocols]\n @headers = options[:headers]\n @id = nil\n @socket = nil\n @wamp_protocol = nil\n @server_ident = nil\n\n @prefixes = {}\n @topics = []\n @callbacks = {}\n end", "def test_conn_1p_0020\n @conn.disconnect\n #\n cha = {:host => \"localhost\", \"accept-version\" => \"1.0\"}\n cha[:host] = \"/\" if ENV['STOMP_RABBIT']\n conn = nil\n assert_nothing_raised do\n conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)\n conn.disconnect\n end\n assert_equal conn.protocol, Stomp::SPL_10\n end", "def connect\n s = service\n yield s if s\n end", "def on_connect(*)\n @storage = TickingAway::JSONFileStorage.new\n @ta_bot = config[:time_api] ? TickingAway::Bot.new(storage: @storage, time_api: config[:time_api]) : TickingAway::Bot.new(storage: @storage)\n end", "def play socket\n end", "def setup\n super do |server_app, binder|\n binder.forward :concurrency\n\n yield(server_app, binder) if block_given?\n end\n end", "def connect\n\tend", "def setup\n\n @server = ItemServer.new :auth => :basic\n @server.start\n end", "def run\n connect\n end", "def on_connect(*)\n @mplayer_cmd = \"#{config[:mplayer]} -nosound #{config[:url]}\"\n @twitter_client = Twitter::REST::Client.new do |twitter_config|\n twitter_config.consumer_key = config[:twitter_consumer_key]\n twitter_config.consumer_secret = config[:twitter_consumer_secret]\n twitter_config.access_token = config[:twitter_access_token]\n twitter_config.access_token_secret = config[:twitter_access_token_secret]\n end\n end", "def on_create\n RMQ.debugging = true\n RMQ.caching_enabled = true\n\n mp \"BluePotionApplication on_create\", debugging_only: true\n\n VW::SessionClient.debug = true # Debug network calls\n end", "def prepare_connection(env)\n env.trace 'init connection'\n @env = env\n init_queue\n initialize_connection env # Defined in each endpoint\n @application.stat_connection_open\n @channel = env.params['channel']\n logger.debug \"Connected to channel #{@channel}\"\n subscribe @channel\n end", "def initialize(url, cookies, logs: false, &handler)\n @super_logger = Logger.new(logs ? 'ws_super_logger.log' : '/dev/null')\n\n @uri = URI.parse(url)\n @url = \"ws#{@uri.scheme.split(\"\")[4]}://#{@uri.host}\"\n\n if @uri.scheme.split(\"\")[4] == 's'\n @socket = TCPSocket.new(@uri.host, 443)\n @super_logger.info \"Opened TCP socket for (port 443) #{@uri} (#{@socket})\"\n @socket = OpenSSL::SSL::SSLSocket.new(@socket)\n @socket.connect\n @super_logger.info \"Upgrade TCP socket to SSL socket socket for #{@uri} (#{@socket})\"\n else\n @socket = TCPSocket.new(@uri.host, 80)\n @super_logger.info \"Opened TCP socket for (port 80) #{@uri} (#{@socket})\"\n end\n\n @handler = handler\n @logger = Logger.new(logs ? \"realtime.log\" : '/dev/null')\n @restart = true\n @super_logger.info \"Set @restart to #{@restart}\"\n\n @driver = WebSocket::Driver.client(self)\n @driver.add_extension PermessageDeflate\n @driver.set_header \"Cookies\", cookies if cookies\n @driver.set_header \"Origin\", \"#{@uri.scheme}://#{@uri.host.split('.')[-2..-1].join('.')}\"\n\n @driver.on :connect, ->(_e) {}\n\n @driver.on :open, ->(_e) do\n send \"155-questions-active\"\n @super_logger.info \"Socket open. Subscribed to 155-questions-active\"\n @logger.info \"WebSocket is open!\"\n end\n\n @driver.on :message do |e|\n @logger.info(\"Read: #{e.data}\")\n data = JSON.parse(e.data)\n if data[\"action\"] == \"hb\"\n send \"hb\"\n else\n @handler.call(data)\n end\n end\n\n @driver.on :close, ->(_e) do\n @logger.info \"Realtime WebSocket is closing.\"\n @super_logger.info \"Socket was closed. @restart == #{@restart}\"\n if @restart\n @logger.info \"Attempting to reopen websocket...\"\n @super_logger.info \"Attempting to reopen socket\"\n @driver.start\n end\n end\n\n @driver.on :error, ->(e) { @logger.error e }\n\n @driver.start\n\n @dead = false\n @thread = Thread.new do\n trap(\"SIGINT\") do\n @restart = false\n @dead = true\n @super_logger.info \"Got SIGINT. Dying.\"\n close\n Thread.exit\n end\n begin\n @driver.parse(@socket.is_a?(TCPSocket) ? @socket.recv(1) : @socket.sysread(1)) until @dead\n rescue IOError, SystemCallError => e\n @super_logger.warn \"Got some kind of interrupt in the thread. Panic.\"\n @logger.warn \"Recieved #{e} closing TCP socket. You shouldn't be worried :)\"\n end\n @super_logger.warn \"Left TCPSocket.recv loop. If you're reading this, panic.\"\n end\n\n at_exit { @thread.join }\n end", "def connect!\n EventMachine.run do\n EventMachine::MQTT::ClientConnection.connect(@server) do |c|\n c.subscribe(@topic)\n c.receive_callback do |message|\n handle_incoming_message(message)\n end\n end\n end\n end", "def connection\n # Establish connection (if not established yet).\n if not @conn then\n # Connect.\n @conn =\n if use_secure_connection? then Socket_IO.open(\"https://socketio.mtgox.com/socket.io\")\n else Socket_IO.open(\"http://socketio.mtgox.com/socket.io\"); end\n # Subscribe to ticker.\n @conn.send Socket_IO::JSONMsg[\n \"op\" => \"mtgox.subscribe\",\n \"type\" => \"ticker\"\n ]\n end\n #\n return @conn\n end", "def transport; end", "def transport; end", "def transport; end", "def start\n @state = STARTED\n logger.info \"Starting producer with host_params:#{@host_params}\"\n @connection_start_time = Time.new\n @stomp = start_server(@host_params, @options.user, @options.passwd)\n rescue => e\n logger.error \"Error occurred while starting a connection: #{e}\\n #{e.backtrace.join(\"\\n\")}\"\n end", "def start\n\t\tself.socket.connect( self.class.host, self.class.port )\n\n\t\tsuper\n\tend", "def start\n\t\t\t\t@endpoint ||= self.endpoint\n\t\t\t\t\n\t\t\t\t@bound_endpoint = Async do\n\t\t\t\t\tAsync::IO::SharedEndpoint.bound(@endpoint)\n\t\t\t\tend.wait\n\t\t\t\t\n\t\t\t\tConsole.logger.info(self) { \"Starting #{name} on #{@endpoint.to_url}\" }\n\t\t\t\t\n\t\t\t\t@debug_trap.ignore!\n\t\t\t\t\n\t\t\t\tsuper\n\t\t\tend", "def start\n self.assign_handler(Puerto::Handlers::Setup.new, self)\n end", "def start\n\n logger.info('Starting the WebSocket Client...')\n\n EventMachine.run do\n\n puts '='*80, \"Connecting to websockets server at ws://#{Settings.websocket.host}:#{Settings.websocket.port}\", '='*80\n\n http = EventMachine::HttpRequest.new(\"ws://#{Settings.websocket.host}:#{Settings.websocket.port}/websocket\").get :timeout => 0\n\n http.errback do\n logger.error \"something was wrong in the websocket_client\"\n end\n\n http.callback do\n puts \"#{Time.now.strftime('%H:%M:%S')} : Connected to server\"\n end\n\n http.stream do |msg|\n puts msg\n end\n\n end\n \n end", "def establish_connection\n end", "def connect(*args, &block)\n self.connection = RStomp::Connection.open(configuration.to_hash)\n # If the connection has swapped hosts, then swap out primary and secondary\n if connection.current_host != configuration.host\n configuration.secondary_host = configuration.host\n configuration.host = connection.current_host\n end\n\n # If the connection has swapped ports, then swap out primary and secondary\n if connection.current_port != configuration.port\n configuration.secondary_port = configuration.port\n configuration.port = connection.current_port\n end\n end", "def initialize\n\n logger.info(\"Starting WebSocketServer...\")\n \n end", "def pre_connect_hooks; end", "def pre_connect_hooks; end", "def post_init\n self.dispatch_event(:on_connect, [self])\n self.send_data(SyncMessage.new($listen_port, $uuid).to_sendable)\n end", "def start\n _connect\n sleep 1\n end", "def connect\n\n # Initialize the gem\n ShopifyAPI::Session.setup({api_key: @api_key, secret: @shared_secret})\n\n # Instantiate the session\n session = ShopifyAPI::Session.new(@url, @password)\n\n # Activate the Session so that requests can be made\n return ShopifyAPI::Base.activate_session(session)\n\n end", "def connect\n start_listener!\n end", "def middleware=(_arg0); end", "def connection(env); end", "def connect\n service\n end", "def connect\n connection.connect\n nil\n end", "def start\n puts 'launching server'\n EM::run do\n EM::WebSocket.run(:host => \"0.0.0.0\", :port => 6262) do |ws|\n sigHandler\n SparrowWSHandler.new ws\n end\n end\n end", "def initialize\n require 'zmq'\n super\n end", "def connect\n connection = Bunny.new(connection_attributes.\n merge(:pass => connection_attributes[:password]))\n connection.start\n \n # NOTE: This is a super undocumented feature that you will probably know\n # about only from reading AMQP specs. If we want to subscribe, but abort\n # subscription before all messages are read, we need to turn this on,\n # otherwise the server will go on and deliver all remaining messages in\n # turn. See also the :ack => true flag in ServerTransport... 23Dez09, ksc\n connection.qos\n\n connection\n end", "def connection_action\n @sslsocket.connect_nonblock\n end", "def test_conn_1p_0040\n @conn.disconnect\n #\n cha = get_conn_headers() \n cha[\"heart-beat\"] = \"0,0\" # No heartbeats\n conn = nil\n assert_nothing_raised do\n conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)\n conn.disconnect\n end\n assert conn.protocol >= Stomp::SPL_11\n end", "def example_one(amqsleep = nil)\n #\n conn = Stomp::Connection.open(@runparms.userid, @runparms.password,\n @runparms.host, @runparms.port, true)\n #\n @log.debug(\"Connection is: #{conn.inspect}\")\n #\n # -----------------------------------------------------------------------------------\n # Connection 1:\n conn = Stomp::Connection.open(\"usera\", \"pwa\", @runparms.host, @runparms.port, @reliable)\n # Do issue a subscribe\n conn.subscribe(@qname, @headers)\n # Send a message\n conn.publish(@qname, Time.now.to_s)\n if amqsleep\n sleep amqsleep\n end\n # Do not call 'receive' here, just issue a disconnect.\n conn.disconnect\n # -----------------------------------------------------------------------------------\n # Connection 2:\n conn = Stomp::Connection.open(\"userb\", \"pwb\", @runparms.host, @runparms.port, @reliable)\n # Subscribe on this connection\n conn.subscribe(@qname, @headers)\n @log.debug \"calling receive, which should never complete ......\"\n #\n # This should hang forever because of the subscribe issued first on \n # connection 1.\n #\n msg = conn.receive\n @log.debug \"Received: #{msg.inspect}\"\n conn.disconnect\nend", "def start\n # subscribe is like a callback\n @server_queue.subscribe(block: @block) do |delivery_info, properties, payload|\n consume(delivery_info, properties, payload)\n end\n end", "def spoof()\n\t\tlisten()\n\n\t\tlisten()\n\tend", "def connect!\n start_em\n @client.ensure_connect\n end", "def setup\n alert_user\n\n # Reset the session counts to zero.\n reset_session_counts\n\n return if not payload_instance\n return if not handler_enabled?\n\n # Configure the payload handler\n payload_instance.exploit_config = {\n 'active_timeout' => self.active_timeout\n }\n\n # Set up the payload handlers\n payload_instance.setup_handler\n\n # Defer starting bind handlers until after exploit completion\n return if handler_bind?\n\n # Start the payload handler\n payload_instance.start_handler\n end", "def initialize(options)\n\n # Initialize the parameters\n self.connected = false\n self.uri = options[:uri]\n self.headers = options[:headers] || {}\n self.protocol = options[:protocol] || 'wamp.2.json'\n self.serializer = options[:serializer] || WampClient::Serializer::JSONSerializer.new\n\n # Add the wamp.2.json protocol header\n self.headers['Sec-WebSocket-Protocol'] = self.protocol\n\n # Initialize callbacks\n @on_open = nil\n @on_close = nil\n @on_message = nil\n @on_error = nil\n\n end", "def start()\n #start listening\n @transport.monitor do |rmsg,header,payload|\n consume(rmsg,header,payload)\n end\n end", "def log_connect(stream_obj)\n puts \"STREAM: connect for #{stream_obj.request_path} from #{request.ip}\" if VERBOSE\n # REDIS.PUBLISH 'stream.admin.connect', stream_obj.to_json\nend", "def server\n self.next\n end", "def run\n EventMachine::run do\n @tcp = EventMachine::connect(config.server.host, config.server.port, TCPConnection)\n @tcp.client = self\n spectator_join\n end\n end", "def connect\n raise NotImplementedError, \"#connect should be overriden by adapters\"\n end", "def setup\n @client.clear(self.signals_redis_key)\n @worker_pool.start\n end", "def initialize( host, port = 8888, path = \"websocket\",\n version = self.version, support )\n super(\"http://#{host}:#{port}/#{path}\") #setup websocket connection\n\n self.init_event_handlers()\n\n @callbacks = {}\n @collections = {}\n @subs = {}\n @version = version\n @session = nil\n @curr_id = 0\n @support = support\n\n end", "def initialize( host, port = 8888, path = \"websocket\",\n version = 1, support )\n super(\"http://#{host}:#{port}/#{path}\") #setup websocket connection\n\n self.init_event_handlers()\n @callbacks = {}\n @collections = {}\n @subs = {}\n @sub_ids = {}\n @version = version\n #setup database info\n @mongo = self.get_db_conn\n\n end" ]
[ "0.62556803", "0.620251", "0.61694086", "0.5979476", "0.5979476", "0.5977518", "0.5883973", "0.58221793", "0.5811948", "0.5789673", "0.5780501", "0.57481563", "0.5724082", "0.5723438", "0.5721184", "0.57173914", "0.5714341", "0.5689558", "0.5686748", "0.5668475", "0.5652576", "0.564743", "0.5619597", "0.561134", "0.5590871", "0.5590871", "0.5576106", "0.5576106", "0.5571408", "0.55637103", "0.5561383", "0.5554437", "0.5542598", "0.55374193", "0.553566", "0.55236125", "0.5518267", "0.5512058", "0.5507704", "0.5507615", "0.55026937", "0.5481494", "0.54761744", "0.54659545", "0.54627955", "0.5455337", "0.5454793", "0.5447219", "0.54404867", "0.54335773", "0.54320633", "0.5419031", "0.5415713", "0.53936917", "0.5392495", "0.5390599", "0.53865373", "0.53863513", "0.53820086", "0.5381029", "0.5375197", "0.5375197", "0.5375197", "0.53670174", "0.53628343", "0.5355707", "0.53440446", "0.5341915", "0.5330751", "0.5328813", "0.53203493", "0.53196126", "0.53196126", "0.5306944", "0.53058404", "0.530513", "0.53046054", "0.53013355", "0.5297135", "0.5292267", "0.5289978", "0.528488", "0.52745974", "0.52745205", "0.5272752", "0.5271756", "0.5267105", "0.526434", "0.5263562", "0.5259186", "0.52551776", "0.52511287", "0.5247921", "0.5243575", "0.52298576", "0.522534", "0.5221067", "0.5220525", "0.52193856", "0.5209907" ]
0.60536295
3
TODO: make automic subscribe_and_send because need subscribe to happen before send does Subscribe to a topic or queue
def subscribe(source) unless @subscriptions.include?(source) EM::defer do Log.debug("Subscribing to #{source}") wait_until_connected? @connection.subscribe(source) @subscriptions << source end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribe_to_channel; end", "def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end", "def subscribe\n @broker.subscribe(*self.class.subscriptions) do |channel, data|\n begin\n perform(channel, data)\n rescue => e\n puts \"Exception #{e}\"\n end\n end\n end", "def subscribe(_topic, **)\n raise 'not implemented'\n end", "def subscribe!\n # TODO: Implement\n end", "def subscribe\n \nend", "def subscribe\n @conn.subscribe(@queue_name, @headers)\n @@log.debug(\"subscribe to: #{@queue_name}\")\n @@log.debug(\"headers: #{@headers.inspect}\")\n end", "def test_queued_sendmsg\n t = 'foo'\n m1 = MessageMock.new('foo', 'foomsg')\n @t.sendmsg(m1)\n \n u = UserMock.new\n @t.subscribe(t, u)\n \n assert_equal(m1.data, u.data)\n assert_equal('MESSAGE', m1.command)\n \n u2 = UserMock.new\n @t.subscribe(t, u2) \n assert_equal('', u2.data)\n end", "def subscribe\n conn = @cluster.connect\n conn.subscribe(ALL)\n conn.subscribe(SHARE)\n conn.subscribe(@channel)\n conn.on(:message) do |channel, message|\n @messages.push([channel, message])\n end\n end", "def subscribe(data)\n # @channels (local tracker)\n # push channel name into subscribe list, if and only if not already in subscribe list\n end", "def subscribe(connection)\n channel = connection.create_channel\n q = channel.queue DESTINATION_QUEUE, durable: true\n q.subscribe do |delivery, headers, body|\n puts \"#{Time.now}: Got the message\"\n end\nend", "def example_one(amqsleep = nil)\n #\n conn = Stomp::Connection.open(@runparms.userid, @runparms.password,\n @runparms.host, @runparms.port, true)\n #\n @log.debug(\"Connection is: #{conn.inspect}\")\n #\n # -----------------------------------------------------------------------------------\n # Connection 1:\n conn = Stomp::Connection.open(\"usera\", \"pwa\", @runparms.host, @runparms.port, @reliable)\n # Do issue a subscribe\n conn.subscribe(@qname, @headers)\n # Send a message\n conn.publish(@qname, Time.now.to_s)\n if amqsleep\n sleep amqsleep\n end\n # Do not call 'receive' here, just issue a disconnect.\n conn.disconnect\n # -----------------------------------------------------------------------------------\n # Connection 2:\n conn = Stomp::Connection.open(\"userb\", \"pwb\", @runparms.host, @runparms.port, @reliable)\n # Subscribe on this connection\n conn.subscribe(@qname, @headers)\n @log.debug \"calling receive, which should never complete ......\"\n #\n # This should hang forever because of the subscribe issued first on \n # connection 1.\n #\n msg = conn.receive\n @log.debug \"Received: #{msg.inspect}\"\n conn.disconnect\nend", "def auto_subscribe_topic\n fail NotImplementedError, 'To be implemented by the concrete topic posts controller.'\n end", "def subscribe\n return unless self.hub.nil?\n\n # Discover hubs if none exist\n @hubs = discover_hubs_for_topic(self.topic_url) if self.hubs.empty?\n @hub = self.hubs.first\n change_subscription(:subscribe, token)\n\n # TODO: Check response, if failed, try a different hub\n end", "def test_subscribe2\n t = 'sub2'\n m1 = MessageMock.new(t, 'sub2msg')\n @t.sendmsg(m1)\n \n u = UserMock.new\n @t.subscribe(t, u)\n \n assert_equal(m1.data, u.data)\n end", "def test_multiple_publish_multiple_subjects_subscribed\n signal = Queue.new\n subscriber_count = 100\n subscription_count = 10\n\n all_subjects = (1..subscriber_count).collect { | i | \"/#{i}\" }\n\n [ (1..subscriber_count).collect do | index | \n Thread.new( index ) do | index |\n subjects = all_subjects.rotate( index ).take( subscription_count )\n \n Bayeux::Session.start do | session |\n subjects.each { | subject | session.subscribe_and_wait subject }\n \n signal << 42\n\n until subjects.empty?\n session.connect.each do | update |\n data = update[ 'data' ]\n subject = update[ 'channel' ]\n raise RuntimeError, \"Not an update #{update}\" unless data && subject\n raise RuntimeError, \"Invalid update #{update}\" unless data == { 'subject' => subject }\n raise RuntimeError, \"Update not expected #{update}\" unless subjects.delete subject\n end\n end\n end\n end\n end,\n Thread.new do\n subscriber_count.times { signal.pop }\n\n Bayeux::Session.start do | session |\n all_subjects.each do | subject |\n result = session.publish subject, { 'subject' => subject }\n assert_equal( 1, result.length )\n assert( successful result )\n end \n end\n end ].flatten.each { | t | t.join }\n end", "def subscribe(&b)\n @publisher.subscribe(&b)\n end", "def request!\n self.type = :subscribe\n reply_if_needed!\n end", "def subscribe(channel, *channels, &block); end", "def subscribe\n subscribee = connection.jid.bare\n\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscribe','node' => node_id, 'jid'=>subscribee)\n )\n )\n\n send_iq_stanza_fibered iq\n end", "def subscribed; end", "def subscribe \n @subscription = MQ.new\n @subscription.queue(@uuid).bind(@subscription.fanout('global_history')).subscribe do |result|\n x = Mash.new(JSON::parse(result))\n puts \"received: #{x[:uuid]} #{x[:user]}@#{x[:host]}$ #{x[:message]}\"\n if x[:uuid] != @uuid\n @pause = true\n File.open(path, \"a\") {|f| f.puts(x[:message])}\n skip_ahead\n @pause = false\n schedule_next_read\n end\n end\n end", "def subscribe\n self.subscribed = true\n end", "def run_subscribe(conn, dest)\n return if not @need_subscribe\n @log.debug \"run_subscribe starts\"\n conn.subscribe(dest) # call hook\n @log.debug \"run_subscribe done\"\n @need_subscribe = false\n @need_gets = true\nend", "def subscribe_to_channel\n run_callbacks :subscribe do\n subscribed\n end\n\n reject_subscription if subscription_rejected?\n ensure_confirmation_sent\n end", "def subscribe!(topic)\n subscriptions.create!( :topic_id => topic.id )\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def subscribe(name, config = {})\n return if subscriptions.has_key? name\n\n queue = @channel.queue(ns(name), {:auto_delete => true}.merge!(config))\n queue.bind(@exchange, :routing_key => ns(name)) \n\n queue.subscribe do |headers, payload|\n decoded = MP.unpack(payload)\n subscriptions[name].handlers.each do |h|\n h.receive(decoded[\"uuid\"], headers.type, decoded[\"msg\"])\n end\n end\n\n subscriptions[name] = HandlerCollection.new(queue, [])\n end", "def subscribe(&blk)\n pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribe')\n connection.send_stanza pres, &blk\n end", "def sendMsg(msg)\r\n @pubNub.publish(:message => msg, :channel => @channel, :http_sync => true)\r\n end", "def connect_topic\n # scott old ack auot\n # see http://activemq.apache.org/stomp.html for activemq.dispathAsync settig\n self.conn.subscribe( self.topic, { :ack =>\"client\" , 'activemq.dispatchAsync' => 'false'}) { |msg| \n \n self.msg_count+=1\n \t begin\t\n \t self.conn.acknowledge(msg,msg.headers) \n \t self.queue << msg \n \t \n rescue Exception => e\n self.exception_count+=1\n puts \" Thread: :exception found #{e.backtrace}\" \n puts \"Thread: :exception messag #{e.message}\"\n end\n \n }\n end", "def subscribe_to_newsletter\n SubscribeToNewsletterService.new(self).call\n end", "def testSubscribe1()\n topic = \"_Subscribe1_\"\n conn = Scalaris::PubSub.new()\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n conn.subscribe(@testTime.to_s + topic + i.to_s, $_TEST_DATA[i])\n end\n \n # check if the subscribers were successfully saved:\n (0..($_TEST_DATA.length - 1)).each do |i|\n topic1 = topic + i.to_s\n subscribers = conn.get_subscribers(@testTime.to_s + topic1)\n assert(subscribers.include?($_TEST_DATA[i]),\n \"Subscriber \\\"\" + $_TEST_DATA[i] + \"\\\" does not exist for topic \\\"\" + topic1 + \"\\\"\")\n assert_equal(1, subscribers.length,\n \"Subscribers of topic (\" + topic1 + \") should only be [\" + $_TEST_DATA[i] + \"], but is: \" + subscribers.to_s)\n end\n \n conn.close_connection()\n end", "def subscribe(*channels, &block); end", "def subscribe_to_topic(tokens, topic)\n make_topic_mgmt_request(tokens, topic, \"batchAdd\")\n end", "def subscribe(*args, &blk)\n (@client ||= connect).subscribe(*args, &blk)\n end", "def setup_shared_queue\n @amq.queue(@shared_queue).subscribe(:ack => true) do |info, msg|\n begin\n info.ack\n receive_request(@serializer.load(msg))\n rescue Exception => e\n RightLinkLog.error(\"RECV #{e.message}\")\n @callbacks[:exception].call(e, msg, self) rescue nil if @callbacks && @callbacks[:exception]\n end\n end\n true\n end", "def subscribe(*topics)\n # Defer subscribing until we are connected\n callback do\n send_packet(\n MQTT::Packet::Subscribe.new(\n :topics => topics,\n :message_id => @message_id.next\n )\n )\n end\n end", "def subscribed\n \t#stream_from 'demo_chan'\n end", "def notfiy_subscribers(params)\n subject = params[:subscribable]\n\n subject.subscribers.each do |subscriber|\n subscriber.notify(subject, params[:message])\n end\n\n continue(params)\n end", "def subscribe(*topics)\n # FIXME: make sure @connection isn't nil\n @connection.subscribe(*topics)\n end", "def start\n channel.prefetch(10)\n queue.subscribe(manual_ack: true, exclusive: false) do |delivery_info, metadata, payload|\n begin\n body = JSON.parse(payload).with_indifferent_access\n status = run(body)\n rescue => e\n status = :error\n end\n\n if status == :ok\n channel.ack(delivery_info.delivery_tag)\n elsif status == :retry\n channel.reject(delivery_info.delivery_tag, true)\n else # :error, nil etc\n channel.reject(delivery_info.delivery_tag, false)\n end\n end\n\n wait_for_threads\n end", "def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end", "def subscribe_and_configure(form)\n subscribee = connection.jid.bare\n\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscribe','node' => node_id, 'jid'=>subscribee),\n x('options',\n connection.build_submit_form(form)\n )\n )\n )\n\n send_iq_stanza_fibered iq\n end", "def subscribe(queue_name = nil, size = 1, &block)\n callback = block || method(:call)\n client.subscribe(\"/queue/#{queue_name || queue}\", { :ack => 'client', 'activemq.prefetchSize' => size }, &callback)\n end", "def subscribe_and_monitor(topic_id, context_obj = nil, &block)\n topic = OmfCommon::Comm::Topic[topic_id]\n if topic.nil?\n OmfCommon.comm.subscribe(topic_id, routing_key: \"o.info\") do |topic|\n if topic.error?\n error \"Failed to subscribe #{topic_id}\"\n else\n debug \"Subscribed to #{topic_id}\"\n context_obj.associate_topic(topic) if context_obj\n block.call(context_obj || topic) if block\n register_default_callback(topic)\n end\n end\n else\n context_obj.associate_topic(topic) if context_obj\n block.call(context_obj || topic) if block\n end\n end", "def subscribe(channels_string)\n channels = channels_string.split.map{|c| c.gsub('#','')}\n\n channels.each do |my_channel|\n next if @subscriptions.has_key? my_channel\n\n channel = @session.create_channel\n exchange = channel.topic(my_channel)\n queue = channel.queue(\"#{channel}_queue\")\n\n queue.bind(exchange, routing_key: \"#{my_channel}.*\")\n\n @subscriptions[my_channel] = {\n exchange: exchange,\n queue: queue\n }\n\n Thread.new do \n queue.subscribe do\n process_message( next_message_from(queue) )\n end\n end\n end\n end", "def subscribe(params = {})\n @connection ||= stub_connection\n @subscription = self.class.channel_class.new(connection, CHANNEL_IDENTIFIER, params.with_indifferent_access)\n @subscription.singleton_class.include(ChannelStub)\n @subscription.subscribe_to_channel\n @subscription\n end", "def batch_subscribe(email)\n # Raise an error to warn it isn't implemented.\n raise NotImplementedError.new\n end", "def subscribe_frame d, h\n h[:ack] = 'auto' unless ['client', 'client-individual'].include?(h[:ack])\n create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}]\n end", "def handle_subscribe(client, data)\n topic = @engine.subscribe_client_to_topic client, data[0]\n\n trigger(:subscribe, client, topic.uri)\n end", "def subscribe(agent, type, collective)\n source = make_target(agent, type, collective)\n unless @subscriptions.include?(source)\n Log.debug(\"Subscribing to #{source}\")\n queue = @channel.queue(source)\n queue.subscribe(:block => false) do |delivery_info, properties, payload|\n msg = { :delivery_info => delivery_info, :properties => properties, :payload => payload }\n @buf.synchronize do\n @buf.push(msg)\n @empty_cond.signal\n end\n end\n @subscriptions << source\n end\n end", "def testSubscribe2()\n topic = \"_Subscribe2\"\n conn = Scalaris::PubSub.new()\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n conn.subscribe(@testTime.to_s + topic, $_TEST_DATA[i])\n end\n \n # check if the subscribers were successfully saved:\n subscribers = conn.get_subscribers(@testTime.to_s + topic)\n (0..($_TEST_DATA.length - 1)).each do |i|\n assert(subscribers.include?($_TEST_DATA[i]),\n \"Subscriber \\\"\" + $_TEST_DATA[i] + \"\\\" does not exist for topic \\\"\" + topic + \"\\\"\")\n end\n assert_equal(nil, self.class._getDiffElement(subscribers, $_TEST_DATA),\n \"unexpected subscriber of topic \\\"\" + topic + \"\\\"\")\n \n conn.close_connection()\n end", "def subscribe\n Socky.send( {:action => \"subscribe\",\n :channel => params[:channel],\n :client => (params[:client_id] || '')}.to_json)\n render :text => \"ok\"\n end", "def do_subscribe(params)\n mode = params['hub.mode']\n callback = params['hub.callback']\n topic = params['hub.topic']\n verify = params['hub.verify']\n vtoken = params['hub.verify_token']\n \n content_type 'text/plain', :charset => 'utf-8'\n unless callback and topic and verify\n throw :halt, [400, \"Bad request: Expected 'hub.callback', 'hub.topic', and 'hub.verify'\"]\n end\n throw :halt, [400, \"Bad request: Empty 'hub.callback' or 'hub.topic'\"] if (callback.empty? or topic.empty?)\n # anchor part in the url not allowed by the spec\n throw :halt, [400, \"Bad request: Invalid URL\"] if (callback.include?('#') or topic.include?('#'))\n \n throw :halt, [400, \"Bad request: Unrecognized mode\"] unless ['subscribe', 'unsubscribe'].include?(mode)\n\n # Processing optional secret\n secret = params['hub.secret'] ? params['hub.secret'] : ''\n \n # remove invalid verify modes \n verify = Array(verify.split(',')).delete_if { |x| not ['sync','async'].include?(x) }\n throw :halt, [400, \"Bad request: Unrecognized verification mode\"] if verify.empty?\n # For now, only using the first preference of verify mode\n verify = verify[0]\n #throw :halt, [400, \"Bad request: Unrecognized verification mode\"] unless ['sync', 'async'].include?(verify)\n begin\n hash = Topic.to_hash(topic)\n tp = DB[:topics].filter(:url => hash).first\n throw :halt, [404, \"Not Found\"] unless tp[:id]\n \n state = (verify == 'async') ? 1 : 0\n query = { 'hub.mode' => mode,\n 'hub.topic' => topic,\n 'hub.lease_seconds' => 0, # still no subscription refreshing support\n 'hub.challenge' => gen_id}\n query['hub.verify_token'] = vtoken if vtoken\n if verify == 'sync'\n MyTimer.timeout(Config::GIVEUP) do\n res = HTTPClient.get_content(callback, query)\n opts = \"m=#{mode} c=#{callback} t=#{topic} v=#{verify} -> res=#{res.inspect}\"\n raise \"do_verify(#{opts})\" unless res and res == query['hub.challenge']\n end\n state = 0\n end\n \n # Add subscription\n # subscribe/unsubscribe to/from ALL channels with that topic\n cb = DB[:subscriptions].filter(:topic_id => tp[:id], :callback => Topic.to_hash(callback))\n cb.delete if (mode == 'unsubscribe' or cb.first)\n if mode == 'subscribe'\n raise \"DB insert failed\" unless DB[:subscriptions] << {\n :topic_id => tp[:id], :callback => Topic.to_hash(callback), \n :vtoken => vtoken, :vmode => verify, :secret => secret, :state => state }\n end\n throw :halt, verify == 'async' ? [202, \"202 Scheduled for verification\"] : \n [204, \"204 No Content\"]\n rescue Exception => e\n throw :halt, [409, \"Subscription verification failed: #{e.to_s}\"]\n end\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def send_topic_acknowledge(msg, headers, timeout=60)\n #m=StompMessage::Message.new('stomp_BILLING', msg)\n open_connection\n s=rand*30 # scott - used to be 1000 but seem to create connections on activemq\n # open new topic to listen to reply...\n # was this but jms seems to blow up receipt_topic=\"/topic/receipt/client#{s.to_i}\"\n receipt_topic=\"/topic/rcpt_client#{s.to_i}\"\n receipt_flag = false\n # internal_conn = Stomp::Connection.open '', '', self.host, self.port, false \n self.conn.subscribe( receipt_topic, { :ack =>\"client\" }) {|msg|\n begin\n Timeout::timeout(timeout) {\n self.conn.acknowledge(msg,msg.headers)\n \t msg2= msg.body\n \t yield msg2\n }\n rescue Exception => e\n puts \"exception #{e.message}\"\n # raise \"timeout\" \n ensure\n receipt_flag=true\n self.conn.unsubscribe receipt_topic \n end \n }\n \n \n more_headers= {'persistent'=>'false', 'reply-to' => \"#{receipt_topic}\" }\n more_headers.merge headers\n self.conn.send(self.topic, msg.to_xml, more_headers ) \n Thread.new { sleep(timeout+1)\n puts \"calling unsubscribe on #{receipt_topic}\" if !receipt_flag\n self.conn.unsubscribe receipt_topic if !receipt_flag\n } \n end", "def subscribed\n @course_queue = CourseQueue.find(params[:id])\n stream_for @course_queue\n end", "def after_subscribe(subscribed)\n # not required\n end", "def test_publish_two_messages\n conn_subscribe make_destination\n @conn.publish make_destination, \"a\\0\"\n @conn.publish make_destination, \"b\\0\"\n msg_a = @conn.receive\n msg_b = @conn.receive\n\n assert_equal \"a\\0\", msg_a.body\n assert_equal \"b\\0\", msg_b.body\n checkEmsg(@conn)\n end", "def listen_for_messages\n @queue.subscribe do |_delivery_info, _metad5ata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end", "def subscribe(subscribes = [], queue_name = nil, subscribe_interval=10)\n return nil if subscribes.empty?\n\n # start listening on our queue\n queue = sqs.queue(queue_name)\n listener = QueueListener.new(queue)\n avail_proc = AvailabilityProcessor.new\n avail_proc.availability_changed = Proc.new do |availability_processor|\n info { \"Availability Changed! New list is:\\n #{availability_processor.all_available(false, true).inspect}\" }\n debug { \"received availability message #{availability_processor}\" }\n actions.each do |action|\n begin\n action.invoke(availability_processor)\n rescue Exception => ex\n error \"Error calling action #{action.inspect} with #{availability_processor.inspect}\", ex\n end\n end\n end\n listener.add_processor(avail_proc)\n listener_thread = listener.listen\n \n subscribe_thread = Thread.new do\n while true \n # subscribe to all the services we're interested in\n begin\n sub_msg = SubscriptionMessage.new(subscribes, queue_name, true)\n debug{ \"sending subscription message #{sub_msg.inspect}\" }\n send_message(monitor_queue, sub_msg)\n debug{ \"sleeping for #{subscribe_interval}s\" }\n sleep subscribe_interval\n rescue Exception => ex\n error \"Error sending subscription message: #{sub_msg.inspect}\", ex\n end\n end\n end\n \n return subscribe_thread\n end", "def subscribe_channels\n @channels.each { |channel| subscribe(channel) }\n end", "def subscribe(channel, data = {})\n log_to_file(\"#{self.class} tries to subscribe to channel #{channel} with #{data.inspect}\")\n send_action('subscribe', channel, data)\n end", "def push_subscription(object)\n local_server.subscribe(object)\n synchro_point\n end", "def subscribe(client_id, channel, &callback)\n super\n publish_awaiting_messages(channel)\n end", "def subscribed\n id = params.fetch(:id)\n return unless execution = JobQueue.find_by_id(id)\n\n execution.viewers.push current_user\n\n Thread.new do\n ActiveRecord::Base.connection_pool.with_connection do\n builder = EventBuilder.new(execution.job)\n execution.output.each do |event, data|\n transmit event: event, data: builder.payload(event, data)\n end\n # TODO: disconnect all listeners so they close their sockets ?\n # then replace the reloaded/finished/waitUntilEnabled stuff with that\n end\n end\n end", "def subscribe(name, params, &blk)\n id = self.next_id()\n self.send({msg: 'sub', id: id, name: name, params: params})\n\n @subs[name] = id\n @callbacks[id] = blk\n end", "def subscribe(subject, opts={}, &callback)\n return unless subject and not draining?\n sid = (@ssid += 1)\n sub = @subs[sid] = { :subject => subject, :callback => callback, :received => 0 }\n sub[:queue] = opts[:queue] if opts[:queue]\n sub[:max] = opts[:max] if opts[:max]\n send_command(\"SUB #{subject} #{opts[:queue]} #{sid}#{CR_LF}\")\n # Setup server support for auto-unsubscribe\n unsubscribe(sid, opts[:max]) if opts[:max]\n sid\n end", "def pubsub_adapter; end", "def put_messages()\n #\n for i in 1..@max_msgs do\n message = \"Go Sox #{i}!\"\n @@log.debug \"#{message}\"\n @client.publish(@queue_name, message, \n {\"persistent\" => true, \"client-id\" => @client_id, \n \"reply-to\" => @queue_name} )\n end\n @client.close\n @@log.debug(\"queue_put completes\")\n end", "def subscribed\n stream_from channel_name\n end", "def do_publish(params)\n content_type 'text/plain', :charset => 'utf-8'\n unless params['hub.url'] and not params['hub.url'].empty?\n throw :halt, [400, \"Bad request: Empty or missing 'hub.url' parameter\"]\n end\n begin\n # TODO: move the subscribers notifications to some background job (worker?)\n hash = Topic.to_hash(params['hub.url'])\n topic = DB[:topics].filter(:url => hash)\n if topic.first # already registered\n # minimum 5 min interval between pings\n #time_diff = (Time.now - topic.first[:updated]).to_i\n #throw :halt, [204, \"204 Try after #{(300-time_diff)/60 +1} min\"] if time_diff < 300\n topic.update(:updated => Time.now, :dirty => 1)\n # only verified subscribers, subscribed to that topic\n subscribers = DB[:subscriptions].filter(:topic_id => topic.first[:id], :state => 0)\n atom_diff = Topic.diff(params['hub.url'], true)\n postman(subscribers, atom_diff) if (subscribers.count > 0 and atom_diff)\n topic.update(:dirty => 0)\n else \n DB[:topics] << { :url => hash, :created => Time.now, :updated => Time.now }\n end\n throw :halt, [204, \"204 No Content\"]\n rescue Exception => e\n throw :halt, [404, e.to_s]\n end\n end", "def subscribe!\n raise StandardError, \"Consumer already exists\" unless @consumer.nil?\n @consumer ||= @main_exchange.subscribe(@consumer_tag) do |delivery_info, metadata, payload|\n process(delivery_info, metadata, payload)\n end\n end", "def listen\n @queue.subscribe(block: true) do |delivery_info, properties, body|\n puts(body)\n end\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def send_a_message(conn, dest, message, headers={})\n return if not @need_sends \n @log.debug \"send_s_message starts\"\n return if not conn.connected?\n 1.upto(@max_msgs) do |mnum|\n outmsg = \"#{message} |:| #{mnum}\"\n conn.send(dest, outmsg, headers) # EM supplied Stomp method\n end\n @need_sends = false\n @need_subscribe = true\n @log.debug \"send_s_message done\"\nend", "def subscribe_to_channel(*)\n synchronize_entrypoint! { super }\n end", "def update_newsletter_subscription!\n return unless self.user.present?\n\n if self.receives_newsletter?\n NewsletterSubscriptionsWorker.perform_async(:subscribe, self.user.email)\n else\n NewsletterSubscriptionsWorker.perform_async(:unsubscribe, self.user.email)\n end\n end", "def test1 #fails\n\n EventMachine::WebSocket.start(:host => \"0.0.0.0\", :port => 8567) do |ws|\n ws.onopen do\n puts \"WebSocket opened\"\n conn = Bunny.new\n conn.start\n#ch = conn.default_channel\n q = $ch.queue(\"tweets\")\n q.subscribe(:block => true) do |delivery_info, properties, body|\n puts \"Received tweet\\n\"\n ws.send \"test\"\n end\n end\n ws.onclose do\n ws.close(code = nil, body = nil)\n puts \"WebSocket closed\"\n# exit\n end\n end\nend", "def subscribe(*a, &b)\n name = gen_id\n EM.schedule { @subs[name] = EM::Callback(*a, &b) }\n\n name\n end", "def subscribe(args = {})\n :no_response\n end", "def subscribe(subscribable, subscription_level = Subscription::Levels[:reader])\n subscribable.subscribe(self, subscription_level)\n end", "def subscribe_all\n @config.subscriptions.size.times do\n current\n select_next_consumer\n end\n end", "def subscribe(&onMessage) # block\n end", "def setup\n EM.kqueue\n #AMQP.logging = true\n @mq = MQ.new\n @requests = @mq.queue('jesus_nut',:auto_delete => true)\n @setup = true\n @mq.queue(@reply_to).subscribe { |info, response|\n resp = Marshal.load response\n callback = @pending.delete info.message_id\n callback.call resp\n }\n @id = 1\n end", "def send_other_kafka_message\n Rimless.message(data: { 'id' => 'id' }, topic: :test, schema: :include)\nend", "def subscribe(args)\n ## Capture User Input\n channel = args['channel']\n callback = args['callback']\n\n ## Fail if missing channel\n if !channel\n puts \"Missing Channel.\"\n return false\n end\n\n ## Fail if missing callback\n if !callback\n puts \"Missing Callback.\"\n return false\n end\n\n ## Begin Subscribe\n loop do\n begin\n timetoken = args['timetoken'] ? args['timetoken'] : 0\n\n ## Wait for Message\n response = _request([\n 'subscribe',\n @subscribe_key,\n channel,\n '0',\n timetoken.to_s\n ])\n\n messages = response[0]\n args['timetoken'] = response[1]\n\n ## If it was a timeout\n next if !messages.length\n\n ## Run user Callback and Reconnect if user permits.\n ## Capture the message and encrypt it\n if @cipher_key.length > 0\n pc = PubnubCrypto.new(@cipher_key)\n messages.each do |message|\n if message.is_a? Array\n message=pc.decryptArray(message)\n else\n message=pc.decryptObject(message)\n end\n if !callback.call(message)\n return\n end\n end\n else\n messages.each do |message|\n if !callback.call(message)\n return\n end\n end\n end\n rescue Timeout::Error\n rescue\n sleep(1)\n end\n end\n end", "def subscribe(routing_key, options = {}, &block)\n q = bind_queue(routing_key)\n options = options.merge(manual_ack: true)\n\n q.subscribe(options) do |delivery_info, metadata, payload|\n block.call(delivery_info, metadata, payload)\n @channel.ack(delivery_info.delivery_tag)\n end\n end", "def subscribe(channel)\n @env.trace 'subscribing'\n @subscription_id = @application.subscribe(self, channel) do |msg|\n @queue.push msg\n end\n @subscription_id\n end", "def populate_topic(lst)\n # puts \"list is #{lst}\"\n self.arg_hash = {:host => 'localhost'}\n #self.mms_sender=MmscManager::MmsSendTopic.new(arg_hash) \n lst.each {|key| \n \n dst = key\n send_it(dst) #if SmscManager::Sms.check_destination(dst)\n \n }\n \n sleep(2) # should we wait till we get receipts for all?\n puts \"populate topic sent #{self.sent}\"\n sleep(self.attempts*0.5+1) if self.sent!=self.attempts\n puts \"populate topic sent after sleep #{self.sent}\"\n # self.mms_sender.disconnect_stomp\n end", "def subscribe(last_sequence)\n @subscribed = true\n @channel = Server::Channel.new @req.path\n @deferrable = @channel.next_message last_sequence\n @deferrable.callback do |message, sequence|\n Firehose.logger.debug \"WS sent `#{message}` to `#{@req.path}` with sequence `#{sequence}`\"\n @ws.send self.class.wrap_frame(message, last_sequence)\n subscribe sequence\n end\n @deferrable.errback do |e|\n EM.next_tick { raise e.inspect } unless e == :disconnect\n end\n end", "def _publish\n puts(\"pushing message: #{self.to_json} to queue #{@queue}\")\n AMQPCli.instance.push(self.to_json, @queue)\n end", "def subscribe_queue(name, opts = {})\n # TBD: here and analogously; only push in self and dynamically call native_client?(:mq)\n R8QueueMQ.new(self, name, opts)\n end", "def subscribe!\n @repository.callback_url = pubsubhubbub_callback_url\n\n if @repository.valid?\n begin\n client.subscribe(\n topic,\n @repository.callback_url,\n ENV['PUBSUBHUBBUB_SECRET']\n )\n\n @repository.save\n rescue Octokit::Error => e\n @repository.errors.add(:base, e.message)\n\n false\n end\n end\n end", "def start\n # subscribe is like a callback\n @server_queue.subscribe(block: @block) do |delivery_info, properties, payload|\n consume(delivery_info, properties, payload)\n end\n end", "def publish(subject, msg=EMPTY_MSG, opt_reply=nil, &blk)\n return unless subject and not @drained_subs\n msg = msg.to_s\n\n # Accounting\n @msgs_sent += 1\n @bytes_sent += msg.bytesize if msg\n\n send_command(\"PUB #{subject} #{opt_reply} #{msg.bytesize}#{CR_LF}#{msg}#{CR_LF}\")\n queue_server_rt(&blk) if blk\n end", "def subscribe(params = T.unsafe(nil)); end", "def pubsub; end", "def publish( message )\n subscribers.each do |name, subscriber|\n subscriber.produce( message )\n end\n end", "def deliver!\n if pending_no_aggregation? and not user_has_unsubscribed?\n self.mark_as_sent!\n self.class.deliver_channels(self.id)\n end\n end" ]
[ "0.6843848", "0.6802487", "0.67838216", "0.6758646", "0.6711873", "0.6419873", "0.6419273", "0.6394999", "0.63465226", "0.63434416", "0.6327666", "0.63045335", "0.62975055", "0.6293828", "0.6293258", "0.620208", "0.6188301", "0.61713296", "0.61614805", "0.6138595", "0.61328614", "0.6130362", "0.6127427", "0.6120859", "0.6108724", "0.61048466", "0.60963815", "0.6075933", "0.6074087", "0.6068341", "0.60588115", "0.60578036", "0.6050208", "0.60213846", "0.602024", "0.6016787", "0.6005892", "0.6005066", "0.6004402", "0.59888655", "0.59801626", "0.59762233", "0.59737515", "0.59701896", "0.5957612", "0.5953888", "0.5943023", "0.5937596", "0.5937107", "0.5936876", "0.593365", "0.5925279", "0.5918382", "0.59167254", "0.59084386", "0.5866532", "0.5863671", "0.58535916", "0.5833696", "0.58322495", "0.5825658", "0.58236897", "0.58212805", "0.5818719", "0.5794807", "0.5785412", "0.57800555", "0.5771634", "0.57683045", "0.5766981", "0.5766105", "0.57611287", "0.57534635", "0.57421774", "0.57413745", "0.57322365", "0.57296747", "0.5726352", "0.5720454", "0.57187617", "0.5710995", "0.5699218", "0.5688315", "0.5682538", "0.56718206", "0.56653255", "0.56521857", "0.56516117", "0.5648408", "0.5643003", "0.56411314", "0.563727", "0.56354356", "0.5631912", "0.5622232", "0.56196517", "0.56146294", "0.56035393", "0.5602689", "0.55898577", "0.55890536" ]
0.0
-1
Subscribe to a topic or queue
def unsubscribe(source) #TODO end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribe(_topic, **)\n raise 'not implemented'\n end", "def subscribe(connection)\n channel = connection.create_channel\n q = channel.queue DESTINATION_QUEUE, durable: true\n q.subscribe do |delivery, headers, body|\n puts \"#{Time.now}: Got the message\"\n end\nend", "def subscribe\n @broker.subscribe(*self.class.subscriptions) do |channel, data|\n begin\n perform(channel, data)\n rescue => e\n puts \"Exception #{e}\"\n end\n end\n end", "def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end", "def subscribe\n @conn.subscribe(@queue_name, @headers)\n @@log.debug(\"subscribe to: #{@queue_name}\")\n @@log.debug(\"headers: #{@headers.inspect}\")\n end", "def subscribe(*topics)\n # FIXME: make sure @connection isn't nil\n @connection.subscribe(*topics)\n end", "def subscribe!(topic)\n subscriptions.create!( :topic_id => topic.id )\n end", "def subscribe\n conn = @cluster.connect\n conn.subscribe(ALL)\n conn.subscribe(SHARE)\n conn.subscribe(@channel)\n conn.on(:message) do |channel, message|\n @messages.push([channel, message])\n end\n end", "def subscribe(*args, &blk)\n (@client ||= connect).subscribe(*args, &blk)\n end", "def subscribe!\n # TODO: Implement\n end", "def subscribe(*topics)\n # Defer subscribing until we are connected\n callback do\n send_packet(\n MQTT::Packet::Subscribe.new(\n :topics => topics,\n :message_id => @message_id.next\n )\n )\n end\n end", "def subscribe(queue_name = nil, size = 1, &block)\n callback = block || method(:call)\n client.subscribe(\"/queue/#{queue_name || queue}\", { :ack => 'client', 'activemq.prefetchSize' => size }, &callback)\n end", "def subscribe\n return unless self.hub.nil?\n\n # Discover hubs if none exist\n @hubs = discover_hubs_for_topic(self.topic_url) if self.hubs.empty?\n @hub = self.hubs.first\n change_subscription(:subscribe, token)\n\n # TODO: Check response, if failed, try a different hub\n end", "def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end", "def subscribe\n subscribee = connection.jid.bare\n\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscribe','node' => node_id, 'jid'=>subscribee)\n )\n )\n\n send_iq_stanza_fibered iq\n end", "def subscribe(channel, &block)\n faye.subscribe \"/topic/#{channel}\", &block\n end", "def subscribe(&blk)\n pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribe')\n connection.send_stanza pres, &blk\n end", "def subscribe(domain, node, jid)\n jid = JID.new(jid)\n redis.multi\n redis.sadd(\"pubsub:#{domain}:subscribers_#{node}\", jid.to_s)\n redis.sadd(\"pubsub:#{domain}:subscriptions_#{jid}\", node)\n redis.exec\n end", "def subscribe_to_channel; end", "def subscribe \n @subscription = MQ.new\n @subscription.queue(@uuid).bind(@subscription.fanout('global_history')).subscribe do |result|\n x = Mash.new(JSON::parse(result))\n puts \"received: #{x[:uuid]} #{x[:user]}@#{x[:host]}$ #{x[:message]}\"\n if x[:uuid] != @uuid\n @pause = true\n File.open(path, \"a\") {|f| f.puts(x[:message])}\n skip_ahead\n @pause = false\n schedule_next_read\n end\n end\n end", "def subscribe!\n raise StandardError, \"Consumer already exists\" unless @consumer.nil?\n @consumer ||= @main_exchange.subscribe(@consumer_tag) do |delivery_info, metadata, payload|\n process(delivery_info, metadata, payload)\n end\n end", "def subscribe(subject, opts={}, &callback)\n return unless subject and not draining?\n sid = (@ssid += 1)\n sub = @subs[sid] = { :subject => subject, :callback => callback, :received => 0 }\n sub[:queue] = opts[:queue] if opts[:queue]\n sub[:max] = opts[:max] if opts[:max]\n send_command(\"SUB #{subject} #{opts[:queue]} #{sid}#{CR_LF}\")\n # Setup server support for auto-unsubscribe\n unsubscribe(sid, opts[:max]) if opts[:max]\n sid\n end", "def subscribe\n \nend", "def subscribe(prefix)\n setsockopt :subscribe, prefix\n end", "def subscribe(topic, channel, options={}, &block)\n Util.assert_topic_and_channel_valid(topic, channel)\n subscriber = nil\n name = \"#{topic}:#{channel}\"\n @subscriber_mutex.synchronize do\n raise \"Already subscribed to #{name}\" if @subscribers[name]\n subscriber_class = block_given? ? Subscriber : QueueSubscriber\n subscriber = @subscribers[name] = subscriber_class.new(self, topic, channel, options, &block)\n end\n\n @nsqd_tcp_addresses.each do |addr|\n address, port = addr.split(':')\n subscriber.add_connection(address, port.to_i)\n end\n subscriber\n end", "def subscribe(&b)\n @publisher.subscribe(&b)\n end", "def run_subscribe(conn, dest)\n return if not @need_subscribe\n @log.debug \"run_subscribe starts\"\n conn.subscribe(dest) # call hook\n @log.debug \"run_subscribe done\"\n @need_subscribe = false\n @need_gets = true\nend", "def subscribe(subscribable, subscription_level = Subscription::Levels[:reader])\n subscribable.subscribe(self, subscription_level)\n end", "def subscribe(name, config = {})\n return if subscriptions.has_key? name\n\n queue = @channel.queue(ns(name), {:auto_delete => true}.merge!(config))\n queue.bind(@exchange, :routing_key => ns(name)) \n\n queue.subscribe do |headers, payload|\n decoded = MP.unpack(payload)\n subscriptions[name].handlers.each do |h|\n h.receive(decoded[\"uuid\"], headers.type, decoded[\"msg\"])\n end\n end\n\n subscriptions[name] = HandlerCollection.new(queue, [])\n end", "def subscribe(key)\n @amq.queue(key).subscribe do |value|\n yield value\n end\n end", "def subscribe(subscription)\n queue = connection.queue \"#{subscription.consumer.id}@#{subscription.channel}\",\n :auto_delete => true,\n :arguments => {'x-expires' => Push.config.amqp.queue_ttl * 1000}\n fanout = connection.exchange(subscription.channel, :auto_delete => true, :type => :fanout)\n queue.bind(fanout)\n\n # Cleanup is handled automatically for us by the timeout that we set on the \n # client connection queue. There's also no channel clean-up since we're not \n # running this inside of a concurrent run-time environment.\n\n # Try popping a message off the queue, deal with Bunny idiosyncracies, and \n # pass the message into the subscription object for further processing.\n subscription.process_message(self.class.process_message(queue.pop))\n end", "def subscribe(subscribes = [], queue_name = nil, subscribe_interval=10)\n return nil if subscribes.empty?\n\n # start listening on our queue\n queue = sqs.queue(queue_name)\n listener = QueueListener.new(queue)\n avail_proc = AvailabilityProcessor.new\n avail_proc.availability_changed = Proc.new do |availability_processor|\n info { \"Availability Changed! New list is:\\n #{availability_processor.all_available(false, true).inspect}\" }\n debug { \"received availability message #{availability_processor}\" }\n actions.each do |action|\n begin\n action.invoke(availability_processor)\n rescue Exception => ex\n error \"Error calling action #{action.inspect} with #{availability_processor.inspect}\", ex\n end\n end\n end\n listener.add_processor(avail_proc)\n listener_thread = listener.listen\n \n subscribe_thread = Thread.new do\n while true \n # subscribe to all the services we're interested in\n begin\n sub_msg = SubscriptionMessage.new(subscribes, queue_name, true)\n debug{ \"sending subscription message #{sub_msg.inspect}\" }\n send_message(monitor_queue, sub_msg)\n debug{ \"sleeping for #{subscribe_interval}s\" }\n sleep subscribe_interval\n rescue Exception => ex\n error \"Error sending subscription message: #{sub_msg.inspect}\", ex\n end\n end\n end\n \n return subscribe_thread\n end", "def auto_subscribe_topic\n fail NotImplementedError, 'To be implemented by the concrete topic posts controller.'\n end", "def subscribe(&callback)\n redis.subscribe(channel) do |on|\n on.message do |channel, payload|\n data = JSON.parse(payload) rescue payload\n callback.call channel, data, self\n end\n end\n end", "def subscribe dest, ack=false\n send_frame \"SUBSCRIBE\", {:destination=>dest, :ack=>(ack ? \"client\" : \"auto\")}\n end", "def subscribe!\n @repository.callback_url = pubsubhubbub_callback_url\n\n if @repository.valid?\n begin\n client.subscribe(\n topic,\n @repository.callback_url,\n ENV['PUBSUBHUBBUB_SECRET']\n )\n\n @repository.save\n rescue Octokit::Error => e\n @repository.errors.add(:base, e.message)\n\n false\n end\n end\n end", "def subscribe(channel)\n @env.trace 'subscribing'\n @subscription_id = @application.subscribe(self, channel) do |msg|\n @queue.push msg\n end\n @subscription_id\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def subscribe_to_topic(tokens, topic)\n make_topic_mgmt_request(tokens, topic, \"batchAdd\")\n end", "def subscriber(name)\n subscriber_name = \"#{@name}.#{name}\"\n @client.sadd @name, subscriber_name\n queue = ::Qup::Adapter::Redis::Queue.new(@uri, subscriber_name, @name)\n ::Qup::Subscriber.new( self, queue )\n end", "def subscribe(subject, opts={}, &callback)\n sid = nil\n sub = nil\n synchronize do\n sid = (@ssid += 1)\n sub = @subs[sid] = Subscription.new\n end\n sub.subject = subject\n sub.callback = callback\n sub.received = 0\n sub.queue = opts[:queue] if opts[:queue]\n sub.max = opts[:max] if opts[:max]\n\n send_command(\"SUB #{subject} #{opts[:queue]} #{sid}#{CR_LF}\")\n @flush_queue << :sub\n\n # Setup server support for auto-unsubscribe when receiving enough messages\n unsubscribe(sid, opts[:max]) if opts[:max]\n\n sid\n end", "def subscribe(args)\n ## Capture User Input\n channel = args['channel']\n callback = args['callback']\n\n ## Fail if missing channel\n if !channel\n puts \"Missing Channel.\"\n return false\n end\n\n ## Fail if missing callback\n if !callback\n puts \"Missing Callback.\"\n return false\n end\n\n ## Begin Subscribe\n loop do\n begin\n timetoken = args['timetoken'] ? args['timetoken'] : 0\n\n ## Wait for Message\n response = _request([\n 'subscribe',\n @subscribe_key,\n channel,\n '0',\n timetoken.to_s\n ])\n\n messages = response[0]\n args['timetoken'] = response[1]\n\n ## If it was a timeout\n next if !messages.length\n\n ## Run user Callback and Reconnect if user permits.\n ## Capture the message and encrypt it\n if @cipher_key.length > 0\n pc = PubnubCrypto.new(@cipher_key)\n messages.each do |message|\n if message.is_a? Array\n message=pc.decryptArray(message)\n else\n message=pc.decryptObject(message)\n end\n if !callback.call(message)\n return\n end\n end\n else\n messages.each do |message|\n if !callback.call(message)\n return\n end\n end\n end\n rescue Timeout::Error\n rescue\n sleep(1)\n end\n end\n end", "def subscribe_and_monitor(topic_id, context_obj = nil, &block)\n topic = OmfCommon::Comm::Topic[topic_id]\n if topic.nil?\n OmfCommon.comm.subscribe(topic_id, routing_key: \"o.info\") do |topic|\n if topic.error?\n error \"Failed to subscribe #{topic_id}\"\n else\n debug \"Subscribed to #{topic_id}\"\n context_obj.associate_topic(topic) if context_obj\n block.call(context_obj || topic) if block\n register_default_callback(topic)\n end\n end\n else\n context_obj.associate_topic(topic) if context_obj\n block.call(context_obj || topic) if block\n end\n end", "def handle_subscribe(client, data)\n topic = @engine.subscribe_client_to_topic client, data[0]\n\n trigger(:subscribe, client, topic.uri)\n end", "def subscribe(routing_key, options = {}, &block)\n q = bind_queue(routing_key)\n options = options.merge(manual_ack: true)\n\n q.subscribe(options) do |delivery_info, metadata, payload|\n block.call(delivery_info, metadata, payload)\n @channel.ack(delivery_info.delivery_tag)\n end\n end", "def subscribe_pubsub(domain, node, jid)\n @pubsub.subscribe(domain, node, jid)\n end", "def subscribed\n stream_from channel_name\n end", "def subscribe(name, params, &blk)\n id = self.next_id()\n self.send({msg: 'sub', id: id, name: name, params: params})\n\n @subs[name] = id\n @callbacks[id] = blk\n end", "def subscribe(subscription)\n @pipe.send_strings [\"subscribe\", subscription]\n end", "def subscribe(source)\n unless @subscriptions.include?(source)\n Log.debug(\"Subscribing to #{source}\")\n @connection.subscribe(source)\n @subscriptions << source\n end\n end", "def subscribe_to_topic(topic_arn, protocol, end_point)\n # TODO handle different SubscriptionArn results? Let's\n # just return the raw subscription arn for now\n req_hash = generate_request('Subscribe', 'TopicArn' => topic_arn, 'Protocol' => protocol, 'Endpoint' => end_point)\n request_info(req_hash, SnsSubscribeParser.new(:logger => @logger))\n end", "def subscribe(subscription)\n raise \"subscribe is only valid on ZMQ::SUB sockets\" unless @socktype == ZMQ::SUB\n @data_socket.setsockopt ZMQ::SUBSCRIBE, subscription\n end", "def subscribe(subscription)\n raise \"subscribe is only valid on ZMQ::SUB sockets\" unless @socktype == ZMQ::SUB\n @data_socket.setsockopt ZMQ::SUBSCRIBE, subscription\n end", "def subscribe_to_topic(topic, device)\n raise NotImplementedError.new\n end", "def subscribe(subscription)\n consumer_queue = \"#{subscription.consumer.id}@#{subscription.channel}\"\n queue = subscription_channel.queue(consumer_queue, :arguments => {'x-expires' => Push.config.amqp.queue_ttl * 1000})\n fanout = subscription_channel.fanout(subscription.channel, :auto_delete => true)\n\n subscription.on_delete {\n logger.debug \"AMQP unbinding `#{consumer_queue}`\"\n # The AMQP server automatically deletes and unbinds this queue after the\n # number of seconds specified in the 'x-expires' argument above.\n }\n\n logger.debug \"AMQP binding `#{consumer_queue}` to exchange `#{subscription.channel}`\"\n queue.bind(fanout).subscribe(:ack => true) do |metadata, payload|\n logger.debug \"AMQP acking payload `#{payload}`\"\n metadata.ack\n subscription.process_message(payload)\n end\n\n # Install signal handlers to deal with cleaning up potentially long running\n # connections when we kill the server for reboots, etc.\n Signal.trap('TERM'){ subscription.delete }\n end", "def subscribe(channel, *channels, &block); end", "def subscribe(params = {})\n @connection ||= stub_connection\n @subscription = self.class.channel_class.new(connection, CHANNEL_IDENTIFIER, params.with_indifferent_access)\n @subscription.singleton_class.include(ChannelStub)\n @subscription.subscribe_to_channel\n @subscription\n end", "def subscribe_to(topic)\n StreamUser.create(:user => self, :stream_message => topic.stream_messages.last, :source => 'followed') if topic.stream_messages.last\n subscriptions << Subscription.new(:topic => topic)\n end", "def subscribed\n @course_queue = CourseQueue.find(params[:id])\n stream_for @course_queue\n end", "def listen\n @queue.subscribe(block: true) do |delivery_info, properties, body|\n puts(body)\n end\n end", "def subscribe_to_channel\n run_callbacks :subscribe do\n subscribed\n end\n\n reject_subscription if subscription_rejected?\n ensure_confirmation_sent\n end", "def subscribe(node, host, &block)\n pubsub.subscribe(node, nil, host, &callback_logging(__method__, node, &block))\n end", "def subscribe(source)\n unless @subscriptions.include?(source)\n EM::defer do \n Log.debug(\"Subscribing to #{source}\")\n wait_until_connected?\n @connection.subscribe(source)\n @subscriptions << source\n end\n end\n end", "def subscribe_to(channel, &block)\n subscriptions[channel].subscribe(&block)\n end", "def connect_topic\n # scott old ack auot\n # see http://activemq.apache.org/stomp.html for activemq.dispathAsync settig\n self.conn.subscribe( self.topic, { :ack =>\"client\" , 'activemq.dispatchAsync' => 'false'}) { |msg| \n \n self.msg_count+=1\n \t begin\t\n \t self.conn.acknowledge(msg,msg.headers) \n \t self.queue << msg \n \t \n rescue Exception => e\n self.exception_count+=1\n puts \" Thread: :exception found #{e.backtrace}\" \n puts \"Thread: :exception messag #{e.message}\"\n end\n \n }\n end", "def subscribe(mailbox)\n tagged_response(\"SUBSCRIBE\", to_utf7(mailbox))\n end", "def subscribe_queue(name, opts = {})\n # TBD: here and analogously; only push in self and dynamically call native_client?(:mq)\n R8QueueMQ.new(self, name, opts)\n end", "def subscribed\n \t#stream_from 'demo_chan'\n end", "def enqueue_subscribe_job(url)\n UrlSubscriber.enqueue_subscribe_job url, self\n end", "def subscribe(*args, &block)\n listener = Listener.new(*args)\n listener.on_delivery(&block)\n @listeners << listener\n end", "def testSubscribe1()\n topic = \"_Subscribe1_\"\n conn = Scalaris::PubSub.new()\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n conn.subscribe(@testTime.to_s + topic + i.to_s, $_TEST_DATA[i])\n end\n \n # check if the subscribers were successfully saved:\n (0..($_TEST_DATA.length - 1)).each do |i|\n topic1 = topic + i.to_s\n subscribers = conn.get_subscribers(@testTime.to_s + topic1)\n assert(subscribers.include?($_TEST_DATA[i]),\n \"Subscriber \\\"\" + $_TEST_DATA[i] + \"\\\" does not exist for topic \\\"\" + topic1 + \"\\\"\")\n assert_equal(1, subscribers.length,\n \"Subscribers of topic (\" + topic1 + \") should only be [\" + $_TEST_DATA[i] + \"], but is: \" + subscribers.to_s)\n end\n \n conn.close_connection()\n end", "def subscribe(event, *args, &block)\n event(event).subscribe(*args, &block)\n end", "def subscribe( channel, &callback )\n fail NotImplementedError\n end", "def testSubscribe2()\n topic = \"_Subscribe2\"\n conn = Scalaris::PubSub.new()\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n conn.subscribe(@testTime.to_s + topic, $_TEST_DATA[i])\n end\n \n # check if the subscribers were successfully saved:\n subscribers = conn.get_subscribers(@testTime.to_s + topic)\n (0..($_TEST_DATA.length - 1)).each do |i|\n assert(subscribers.include?($_TEST_DATA[i]),\n \"Subscriber \\\"\" + $_TEST_DATA[i] + \"\\\" does not exist for topic \\\"\" + topic + \"\\\"\")\n end\n assert_equal(nil, self.class._getDiffElement(subscribers, $_TEST_DATA),\n \"unexpected subscriber of topic \\\"\" + topic + \"\\\"\")\n \n conn.close_connection()\n end", "def subscribe(public_ip, public_port = 80)\n fetch if @hub_url.nil?\n hub = PubSubHubbub.new(@hub_url, public_ip, public_port)\n hub.subscribe(self)\n hub.client_thread.join\n end", "def listen_for_messages\n @queue.subscribe do |_delivery_info, _metad5ata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end", "def subscribe(key)\n @queue = @rabbit.channel.queue(\"\", :exclusive => true)\n @queue.bind(@exchange, :routing_key => key)\n begin\n @queue.subscribe(:block => true) do |delivery_info, metadata, payload|\n message = JSON.parse(payload, symbolize_names: true)\n yield message\n end\n rescue Interrupt => _\n @rabbit.close\n end\n end", "def subscribe(args = {})\n :no_response\n end", "def subscribe(*a, &b)\n name = gen_id\n EM.schedule { @subs[name] = EM::Callback(*a, &b) }\n\n name\n end", "def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end", "def subscribe\n Socky.send( {:action => \"subscribe\",\n :channel => params[:channel],\n :client => (params[:client_id] || '')}.to_json)\n render :text => \"ok\"\n end", "def subscribe_to_newsletter\n SubscribeToNewsletterService.new(self).call\n end", "def subscribe(client_id, channel, &callback)\n super\n publish_awaiting_messages(channel)\n end", "def subscribe(data)\n # @channels (local tracker)\n # push channel name into subscribe list, if and only if not already in subscribe list\n end", "def request!\n self.type = :subscribe\n reply_if_needed!\n end", "def subscribe(aSubscriber)\n subscribers << aSubscriber\n end", "def subscribe(key)\n @amq.queue(key).subscribe do |header, body|\n value = YAML.load(body)\n yield value\n end\n end", "def subscribe(channel, data = {})\n log_to_file(\"#{self.class} tries to subscribe to channel #{channel} with #{data.inspect}\")\n send_action('subscribe', channel, data)\n end", "def subscribe\n self.subscribed = true\n end", "def push_subscription(object)\n local_server.subscribe(object)\n synchro_point\n end", "def subscribe(args)\n ## Capture User Input\n channel = args['channel']\n callback = args['callback']\n timetoken = args['timetoken'] ? args['timetoken'] : 0\n\n ## Fail if missing channel\n if !channel\n puts \"Missing Channel.\\n\"\n return false\n end\n\n ## Fail if missing callback\n if !callback\n puts \"Missing Callback.\\n\"\n return false\n end\n\n ## Begin Recusive Subscribe\n begin\n ## Wait for Message\n response = self._request([\n 'subscribe',\n @subscribe_key,\n channel,\n '0',\n timetoken.to_s\n ])\n\n messages = response[0]\n args['timetoken'] = response[1]\n\n \n ## If it was a timeout\n if !messages.length\n return self.subscribe(args)\n end\n\n ## Run user Callback and Reconnect if user permits.\n messages.each do |message|\n if !callback.call(message)\n return\n end\n end\n\n ## Keep Listening.\n return self.subscribe(args)\n rescue Timeout::Error\n return self.subscribe(args)\n rescue\n sleep(1)\n return self.subscribe(args)\n end\n end", "def subscribe(&onMessage) # block\n end", "def subscribe(node, jid = nil, host = nil)\n jid ||= client.jid.stripped\n stanza = Stanza::PubSub::Subscribe.new(:set, send_to(host), node, jid)\n request(stanza) { |n| yield n if block_given? }\n end", "def subscribe(queue_resource_name:, topic_resource_name:)\n topic = topics[topic_resource_name]\n queue = queues[queue_resource_name]\n queue_arn = queue.attributes[\"QueueArn\"]\n\n resp = sns_client.subscribe(\n topic_arn: topic.arn,\n protocol: \"sqs\",\n endpoint: queue_arn,\n attributes: { \"RawMessageDelivery\" => \"true\" }\n )\n\n subscriptions[resp.subscription_arn] =\n Aws::SNS::Subscription.new(resp.subscription_arn, client: sns_client)\n\n queue.set_attributes(\n attributes: {\n \"Policy\" => sqs_policy(\n queue_arn: queue_arn,\n topic_arn: topic.arn\n )\n }\n )\n end", "def start\n # subscribe is like a callback\n @server_queue.subscribe(block: @block) do |delivery_info, properties, payload|\n consume(delivery_info, properties, payload)\n end\n end", "def subscribe(channels_string)\n channels = channels_string.split.map{|c| c.gsub('#','')}\n\n channels.each do |my_channel|\n next if @subscriptions.has_key? my_channel\n\n channel = @session.create_channel\n exchange = channel.topic(my_channel)\n queue = channel.queue(\"#{channel}_queue\")\n\n queue.bind(exchange, routing_key: \"#{my_channel}.*\")\n\n @subscriptions[my_channel] = {\n exchange: exchange,\n queue: queue\n }\n\n Thread.new do \n queue.subscribe do\n process_message( next_message_from(queue) )\n end\n end\n end\n end", "def subscribe(worker)\n subscriber = listen(worker)\n subscriber.on_error { |e| on_error(e) }\n subscriber.start\n end", "def subscribe(*channels, &block); end", "def publish(topic, payload, retain=false, qos=0)\n # FIXME: make sure @connection isn't nil\n @connection.publish(topic, payload, retain, qos=0)\n end", "def subscribe(url)\n subscribed_feed = UrlSubscriber.subscribe url, self\n end", "def listen_for_messages\n queue = @channel.queue(\"\")\n\n queue.bind(@exchange).subscribe do |delivery_info, metadata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end" ]
[ "0.8279137", "0.7770299", "0.76997524", "0.75924224", "0.75877917", "0.7525232", "0.75030375", "0.74784464", "0.7423347", "0.73976284", "0.73969394", "0.73961616", "0.7369467", "0.7362734", "0.73212713", "0.7195823", "0.71849406", "0.71793324", "0.7140507", "0.7122031", "0.7053036", "0.7006983", "0.7000131", "0.69757503", "0.6969131", "0.6959343", "0.6930874", "0.6886652", "0.6870409", "0.6856082", "0.68547", "0.6849615", "0.6845094", "0.6842344", "0.68374634", "0.68336827", "0.68327636", "0.682318", "0.68201065", "0.6816795", "0.6802923", "0.67968637", "0.6787725", "0.6780783", "0.67747736", "0.67683935", "0.676149", "0.6760183", "0.6756123", "0.6749612", "0.6743978", "0.6738483", "0.6738483", "0.6734326", "0.67337227", "0.67144066", "0.6706524", "0.6694584", "0.66927326", "0.6692385", "0.6691523", "0.6682819", "0.6672771", "0.6668669", "0.6641542", "0.66364396", "0.66318476", "0.6627132", "0.6600627", "0.65693563", "0.65559834", "0.6538248", "0.65373665", "0.6536342", "0.65319633", "0.6521527", "0.6512071", "0.6508164", "0.6506932", "0.65039027", "0.6502012", "0.64909536", "0.64755505", "0.6473732", "0.6471583", "0.64676285", "0.64536756", "0.64478374", "0.6428642", "0.6412801", "0.6410162", "0.6406456", "0.6397673", "0.6395036", "0.63857806", "0.6379064", "0.6371325", "0.6363706", "0.6348261", "0.6343943", "0.6336692" ]
0.0
-1
looks for a config option, accepts an optional default raises an exception when it cant find a value anywhere
def get_option(opt, default=nil) return @config.pluginconf[opt] if @config.pluginconf.include?(opt) return default if default raise("No plugin.#{opt} configuration option given") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conf name, args = {}\n required = args[:required] ||= false\n default = args[:default] ||= nil\n if CONFIG[name]\n CONFIG[name]\n else\n if required && !default\n $stderr.puts \"#{name} not found - exiting\"\n exit\n else\n default\n end\n end\nend", "def find_option(name)\n @entries[name] || fail(\n ArgumentError,\n \"Unsupported option: '#{name}'; \" \\\n \"#{@entries.keys.any? ? \"registered options: #{@entries.keys.join(', ')}\" : 'no registered options'}\",\n )\n end", "def option_from(config, option, default = nil)\n config.respond_to?(option) ? config.send(option) : default\n end", "def get name, default: nil\n name_str = name.to_s\n name_sym = name.to_sym\n\n value = nil\n found = false\n @config.each do |configfile|\n if value = configfile[:config][name_str] or value = configfile[:config][name_sym]\n found = true\n break\n end\n end\n value = default if value.nil? and not found\n value\n end", "def get_option(opt, default=nil, allow_nil=true)\n return @config.pluginconf[opt] if @config.pluginconf.include?(opt)\n return default if (default or allow_nil)\n raise(\"No plugin.#{opt} configuration option given\")\n end", "def get_option(opt, default=nil, allow_nil=true)\n return @config.pluginconf[opt] if @config.pluginconf.include?(opt)\n return default if (default or allow_nil)\n raise(\"No plugin.#{opt} configuration option given\")\n end", "def get_option(opt, default=nil)\n return @config.pluginconf[opt] if @config.pluginconf.include?(opt)\n return default if default\n\n raise(\"No plugin.#{opt} configuration option given\")\n end", "def config_or_default(config,key,default)\n (config && config[key] ? config[key] : default)\n end", "def option_or_default(key, default)\n options? ? options.fetch(key, default) : default\n end", "def get_option(options, key, default_value = \"\")\n result = options.has_key?(key) ? options[key] : nil\n result = default_value if result.nil? || result == \"\"\n result \n end", "def try_opt(opt)\n if system\n options.fetch(opt, system.try_opt(opt))\n else\n options.fetch(opt, Souffle::Config[opt])\n end\n rescue\n nil\n end", "def default_option\n if configuration_options.count == 1\n configuration_options.first\n else\n configuration_options.find { |option| option.free? }\n end\n end", "def find_option(target_opt)\n match_data = nil\n if $opts_arr.find{ |opt| match_data = opt.match(/^--?#{target_opt}=(\\S+)$/) }\n return match_data[1]\n elsif $opts_arr.find { |opt| opt =~ /^--?#{target_opt}$/ }\n return true\n else\n return nil\n end\nend", "def _get_option(name)\n\n # Start with nothing\n value = nil\n\n # First, get the default value by cycling through the allowed options\n method = self.class.metadata[:allowed_options].each do |allowed_option|\n value = allowed_option[:default] if allowed_option[:name] == name\n end\n\n # Then, cycle through the user-provided options\n @user_options.each do |user_option|\n value = user_option[name] if user_option.key?(name)\n end\n\n value\n end", "def get_config key, default = nil\n name_key = my_short_name.to_sym\n\n if Bot::Conf.has_key? name_key\n if Bot::Conf[name_key].has_key? key\n return Bot::Conf[name_key][key]\n end\n end\n\n default\n end", "def get(key, default=nil)\n raise(ArgumentError, \"Argument 'key' must be a String or Symbol.\") unless key.is_a?(String) || key.is_a?(Symbol)\n # Alternative ways can be implemented here. (reading individual registry keys etc.)\n key = key.to_sym unless key.is_a?(Symbol)\n return (@options.include?(key)) ? @options[key] : default\nend", "def get_env_or_option(env, opt, default=nil)\n return ENV[env] if ENV.include?(env)\n return @config.pluginconf[opt] if @config.pluginconf.include?(opt)\n return default if default\n\n raise(\"No #{env} environment or plugin.#{opt} configuration option given\")\n end", "def get_config_value(label, default)\n if Config.include?(:ldap) && Config[:ldap].include?(label)\n Config[:ldap][label]\n else\n default\n end\n end", "def get_opt(opt)\n @options[opt] || nil\n end", "def [](name)\n by_name(name).full?(&:value) || APP_CONFIG_DEFAULTS[name.to_s]\n end", "def option(name, default = nil)\n value = self.class.options[name.to_sym]\n value = default if default and !value\n\n if value.respond_to? :call then value.call else value end\n end", "def locate_config_value(key)\n key = key.to_sym\n config[key] || Chef::Config[:knife][key]\n end", "def handle_config\n if @opts[:file].nil?\n default = true\n components = [File.dirname(__FILE__), '..', '..', Pull::DEFAULT_CONFIG_NAME]\n file = File.absolute_path(File.join(components))\n else\n default = false\n file = @opts[:file]\n end\n\n if not File.exists? file\n if default\n msg = \"Missing default config file, expected to be at #{file}\"\n else\n msg = \"Missing config file, expected to be at #{file}\"\n end\n Trollop::die msg\n else\n file\n end\n end", "def configuration_for?(key)\n key = resolver.resolve(key) unless key == :default\n configurations.key?(key)\n end", "def get_option(key = nil, default = nil, meta_key = \"_default\")\n values = cama_options(meta_key)\n key = key.to_sym\n values.has_key?(key) && values[key] != \"\" ? values[key] : default\n end", "def get_option(hash, key)\n hash[key.to_sym] || hash[key] || nil\n end", "def get_option(option, default = (default_not_passed = true; false))\n option = option.strip\n return false if option.blank?\n # Filters the value of an existing option before it is retrieved.\n pre = apply_filters(\"pre_option_#{option}\", false, option, default)\n\n return pre if pre != false\n # return false if defined? WP_SETUP_CONFIG\n passed_default = !default_not_passed\n if true #! wp_installing()\n # prevent non-existent options from triggering multiple queries\n notoptions = Rails.cache.read 'Railspress::' + 'options' + '/' + 'notoptions'\n if !notoptions.blank? && notoptions[option]\n # Filters the default value for an option.\n return apply_filters( \"default_option_#{option}\", default, option, passed_default)\n end\n\n alloptions = wp_load_alloptions\n\n if alloptions[option]\n value = alloptions[option]\n else\n value = Rails.cache.fetch('Railspress::' + 'options' + '/' + option) {\n Railspress::Option.where(option_name: option).pluck(:option_value).first\n }\n if value.nil? # option does not exist, so we must cache its non-existence\n notoptions = {} unless notoptions.kind_of? Hash\n notoptions[ option ] = true\n Rails.cache.write 'Railspress::' + 'options' + '/' + 'notoptions', notoptions\n # This filter is documented in wp-includes/option.php */\n return apply_filters(\"default_option_#{option}\", default, option, passed_default)\n end\n end\n else\n # not implementing this case\n end\n # If home is not set use siteurl.\n if 'home' == option && '' == value\n return get_option('siteurl')\n end\n\n if %w(siteurl home category_base tag_base).include? option\n value = Railspress::FormattingHelper.untrailingslashit(value)\n end\n\n # Filters the value of an existing option.\n apply_filters( \"option_#{option}\", Railspress::Functions.maybe_unserialize(value), option).freeze\n end", "def get(setting, _site_name, _environment_name, default = nil)\n @config.dig(*setting) || default\n end", "def method_missing(name, *_args)\n fail \"Unknown option #{name.to_s.gsub!('=', '')}\"\n end", "def config_opt(*env_vars, default: nil)\n ENV.values_at(*env_vars).compact.fetch(0, default)\n end", "def get(key, default=nil)\n rv = nil\n\n [*key].each do |k|\n # Lets check for this key\n rv = @config.get(k.to_s)\n break unless rv.nil?\n\n # If it doesn't exist, check with env\n rv = @config.get(KnoxBoxWeb::Application.environment.to_s << '.' << k.to_s)\n break unless rv.nil?\n end\n\n return default if rv.nil?\n return rv\n end", "def setting(key)\n keys = [key]\n case key\n when String\n keys << key.to_sym\n when Symbol\n keys << key.to_s\n end\n\n # Scan all possible keys to see if the config has a matching value\n keys.inject(nil) do |rv, k|\n v = @config[k]\n break v unless v.nil?\n end\n end", "def setting(key)\n keys = [key]\n case key\n when String\n keys << key.to_sym\n when Symbol\n keys << key.to_s\n end\n\n # Scan all possible keys to see if the config has a matching value\n keys.inject(nil) do |rv, k|\n v = @config[k]\n break v unless v.nil?\n end\n end", "def default_if_not_specified(opt,default_opt)\n opt ? opt : default_opt\nend", "def get_config(name, default)\n return ENV[name].nil? ? default : ENV[name]\nend", "def accepts_optional_argument?\n config[:optional_argument] || config[:argument] == :optional\n end", "def configuration_exists(conf_line,find_str)\n\n #Check that the configuration attribute exists\n conf_exists = conf_line.include?(find_str)\n conf_value = false\n\n #Ensure there is a value for the configuration line\n if conf_exists && conf_line.split('=')[1].chomp.strip.length > 0\n conf_value = true\n end\n\n return conf_value\n\nend", "def option_missing(opt, argv)\n raise NoOptionError, opt\n end", "def configured_default\n @options[:default] || default_entry\n end", "def get(name, default = nil)\n\t\t\t\tname = name.to_sym\n\n\t\t\t\tif @options[name][:value] != nil then\n\t\t\t\t\t@options[name][:value]\n\t\t\t\telsif default != nil then\n\t\t\t\t\tdefault\n\t\t\t\telse\n\t\t\t\t\t@options[name][:default]\n\t\t\t\tend\n\t\t\tend", "def assert_option(opt)\n if [email protected]_key?(opt)\n puts \"Option #{opt} was not found! Check config files and add #{opt} to continue\".red\n raise \"Missing configuration options\"\n end\n end", "def option_type_config_for(name, result_if_empty: :default)\n return unless option_configs\n\n res = option_configs.find { |s| s.name == name.to_s.underscore.to_sym }\n\n if !res && self.class.allow_empty_options\n res = if result_if_empty == :first_config\n option_configs.first\n else\n self.class.options_provider.new(result_if_empty, {}, self)\n end\n\n end\n res\n end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def missing_option; end", "def getConf(key, defaultValue = DefaultValue, conf = @conf)\n if (conf.key?(key)) then\n return conf[key] ;\n elsif(conf != @conf && @conf.key?(key)) then\n return @conf[key] ;\n else\n return defaultValue ;\n end\n end", "def default?\n options.key?(:default)\n end", "def determine_requested\n # param is usually set from the convention. when set from convention stack name takes higher precedence\n config_key = @config.singularize.to_sym # param or variable\n @options[config_key] || @options[:config] || @options[:stack]\n end", "def default\r\n @opts[:default]\r\n end", "def optional_config_file\n if ::File.exists?(@options.to_s)\n @options = @global.load_ruby_config(::File.expand_path(@options))\n end\n end", "def get_param(key, default_value = \"\")\n result = get_option(@params, key, default_value)\n result\n end", "def get_option(opt)\n @optlist.each do |o|\n return o if (opt.is_a?(Symbol) && o.name == opt) || (opt.is_a?(Fixnum) && o.opt == opt)\n end\n nil\n end", "def default?\n @options.key?(:default)\n end", "def get_option(key)\n o = @grammar.get_locally_defined_option(key)\n if (!(o).nil?)\n return o\n end\n if (!(@parent).nil?)\n return @parent.get_option(key)\n end\n return nil # not found\n end", "def get!(key, default=nil, &block)\n value = get key, default, &block\n raise \"Nil value found for option: #{key}, #{default}\" if value.nil?\n return value\n end", "def config_matches?(option, value)\n pattern = /^#{option}: *?#{value}.*?/i\n !(@path_content =~ pattern).nil?\n end", "def lookup_in_options(value)\n if options.include?(value)\n return value\n elsif options_are_labeled? && pair = options.detect {|option| option.include?(value.to_s) }\n return pair.last\n else\n raise \"Value '#{value}' isn't one of the options for #{self.name}.\"\n end\n end", "def method_missing(meth, *args, &block)\n return 'Unknown config value: ' + meth.to_s\n end", "def lookup_config(name)\n\t\tend", "def validate(option)\n unless Config.settings.keys.include?(option.to_sym)\n raise Errors::InvalidConfigOption.new(option)\n end\n end", "def validate(option)\n unless Config.settings.keys.include?(option.to_sym)\n raise Errors::InvalidConfigOption.new(option)\n end\n end", "def set_opt(opt, default)\n if opt\n opt\n else\n default\n end\n end", "def option\n return @manager.configurable.class.configuration.options[key]\n end", "def provided?(name)\n\t\t\t\tname = name.to_sym\n\t\t\t\t(@options[name] || {})[:value] != nil\n\t\t\tend", "def get_option_config(name, arg)\n unless @config.option?(name)\n raise Cliqr::Error::UnknownCommandOption,\n \"unknown option \\\"#{arg}\\\"\"\n end\n @config.option(name)\n end", "def default_value\n config[:default]\n end", "def has_option?(arg)\n !!find_option(arg)\n end", "def lookup_or_default(arg)\n instance = detect { |property| property.name.to_sym == arg.to_sym }\n instance ||= new(:value => default(arg))\n end", "def find_setting(name, **opts)\n log.debug \".find_setting(#{name}) called\"\n return opts[name.to_sym] if opts.key? name.to_sym\n\n string_name = \"#{lex_name}_#{name.to_s.downcase}\"\n if Legion::Settings[:crypt][:vault][:connected] && Legion::Crypt.exist?(lex_name)\n log.debug \"looking for #{string_name} in Legion::Crypt\"\n crypt_result = Legion::Crypt.get(lex_name)\n return crypt_result[name.to_sym] if crypt_result.is_a?(Hash) && crypt_result.key?(name.to_sym)\n end\n return settings[name.to_sym] if settings.key? name.to_sym\n\n if Legion::Settings[:cache][:connected]\n log.debug \"looking for #{string_name} in Legion::Cache\"\n cache_result = Legion::Cache.get(string_name)\n return cache_result unless cache_result.nil?\n end\n\n ENV[string_name] if ENV.key? string_name\n nil\n end", "def option(opt)\n @options[opt]\n end", "def default_option(option, value)\n default_options[option.to_sym] = value\n end", "def default?\n optarg_type? || kwoptarg_type?\n end", "def has_default?\n options.key?(:default) || name_property?\n end", "def get_setting(key, default)\r\n setting = Setting.where(key: key).first\r\n setting && !setting.value.blank? ? setting.value : default\r\n end", "def valid_config_value(retrieved_value)\n VALID_CONFIG_VALUES.include?(retrieved_value) ? retrieved_value : AUTO_CONFIG_VALUE\n end", "def has_option(opt, value)\n options[opt] = value\n end", "def unrecognized_option(err); end", "def option_type_config\n res = versioned_definition.option_type_config_for option_type,\n result_if_empty: :first_config\n unless res || option_type.blank? || option_type == :blank || option_type == :blank_log\n unless option_type.start_with?('ignore_missing_')\n if Rails.env.test?\n puts \"No extra log type configuration exists for #{option_type || 'primary'} in #{self.class.name}\"\n end\n logger.warn \"No extra log type configuration exists for #{option_type || 'primary'} in #{self.class.name}\"\n end\n res = current_definition.option_type_config_for option_type,\n result_if_empty: :first_config\n end\n res\n end", "def get_default( default, *args )\n if args.empty?\n return @config\n end\n\n r = get_sub_tree( @config, *args )\n r.nil? ? default : r\n end", "def fetch_plugin_setting(setting_name, default = nil)\n env_var_name = \"INSPEC_CHEF_#{setting_name.upcase}\"\n config_name = \"chef_api_#{setting_name.downcase}\"\n ENV[env_var_name] || plugin_conf[config_name] || default\n end", "def setup_config(*args)\n args.first.is_a?(Hash) ? args.first : { default: args }\n end", "def param_with_flag flag\n params_with(:flag).each do |param|\n return param if param_definitions[param][:flag].to_s == flag.to_s\n end\n raise Configliere::Error.new(\"Unknown option: -#{flag}\") if complain_about_bad_flags?\n end", "def config(value,options)\n\n end", "def config(value,options)\n\n end", "def exception_unless_configured\n required = @config.find_all {|key, val| val == :required }\n raise ConfigOptionRequired, \"Required settings: \" +\n required.map {|key, val| key }.join(', ') unless required.empty?\n end", "def get( from: '', type: String, required: false, default_value: false, comment: '')\n # from: contain the key used for the current option\n # test errors\n step_options = @options['step_options']\n error = ''\n # a required option is missing ?\n error = \"#{from} declaration is missing\" if step_options[from].nil? and required == true\n # a option is with a wrong type ?\n # Note: With Ruby version < 2.4.0 there is problem Integer from yaml are detected as Fixnum, that can be fixed in the yaml by replacing Integer by Fixnum type\n error = \"#{from} should be a #{type}, a #{step_options[from].class} is provided\" if not step_options[from].nil? and step_options[from].class != type\n # Auto documentation of this option\n @doc.push \"Option from: #{from},\\ttype: #{type},\\trequired: #{required},\\tdefault_value :#{default_value},\\tcomment :#{comment}\"\n # use a default value ?\n step_options[from] ||= default_value if default_value # the ||= operator affect a variable only if this variable is nil or false\n # Add quotes for empty string and nil\n step_options[from] = \"\\\"#{step_options[from]}\\\"\" if step_options[from].class == String # return String with quotes\n step_options[from] = \"\\\"\\\"\" if step_options[from].nil? # return \"\" if nil\n # If no error found return the value else return an empty string and add the error in the @errors list\n if error == ''\n step_options[from]\n else\n @errors.push error\n return ''\n end\n end", "def check_option(opt, opts, msg = \"#{opt.to_s} option must be specified\")\n raise msg if opts[opt] == nil\n end", "def value_of_or_default(option_1, default_value)\n if option_1.nil? || option_1.empty?\n value_name = default_value\n else\n value_name = option_1.strip\n end\n read_value_from_body(value_name)\n end", "def auto_config? name\n return auto_config[name] if !auto_config[name].nil?\n end", "def search_option(parameter, options = {})\n self.search_options << parameter.to_s\n self.default_search_options[parameter] = options[:default] if options.has_key?(:default)\n end", "def fetch(key, default)\n @configuration.fetch(key, default)\n end", "def fetch(key, default)\n @configuration.fetch(key, default)\n end", "def missing_option=(_arg0); end", "def missing_option=(_arg0); end" ]
[ "0.72180235", "0.7143899", "0.70763266", "0.7036564", "0.6899398", "0.6899398", "0.68198174", "0.67460746", "0.6729968", "0.6623835", "0.6613081", "0.660622", "0.6602791", "0.6581234", "0.64198565", "0.63926655", "0.63518363", "0.6329506", "0.62800413", "0.6279581", "0.62718153", "0.6265935", "0.62138474", "0.62000316", "0.6188819", "0.6135861", "0.60991627", "0.6098569", "0.60963017", "0.60896105", "0.6078781", "0.60757494", "0.60757494", "0.6063624", "0.6057203", "0.6052971", "0.6050766", "0.6043003", "0.6039872", "0.603784", "0.6034446", "0.6033699", "0.6026884", "0.6026884", "0.6026884", "0.6026884", "0.6026884", "0.6026884", "0.6026884", "0.6026884", "0.6026884", "0.60045475", "0.60037655", "0.60030895", "0.6000473", "0.59942096", "0.5985571", "0.5982027", "0.59672827", "0.5956723", "0.594196", "0.59364617", "0.59308183", "0.5928461", "0.59209776", "0.5904321", "0.5904321", "0.59014803", "0.5897075", "0.5873633", "0.5856692", "0.58481663", "0.5846054", "0.58108634", "0.5808919", "0.57789236", "0.5758339", "0.57473344", "0.5732386", "0.5726646", "0.5711399", "0.57079685", "0.57008874", "0.5694474", "0.5692736", "0.5691712", "0.5691234", "0.5688599", "0.56865054", "0.56865054", "0.5686365", "0.56852037", "0.5683802", "0.5680252", "0.56764734", "0.5672802", "0.56711584", "0.56711584", "0.56598026", "0.56598026" ]
0.67625976
7
gets a boolean option from the config, supports y/n/true/false/1/0
def get_bool_option(opt, default) return default unless @config.pluginconf.include?(opt) val = @config.pluginconf[opt] if val =~ /^1|yes|true/ return true elsif val =~ /^0|no|false/ return false else return default end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bool_option(opt, default)\n return default unless @config.pluginconf.include?(opt)\n\n val = @config.pluginconf[opt]\n\n if val =~ /^1|yes|true/\n return true\n elsif val =~ /^0|no|false/\n return false\n else\n return default\n end\n end", "def get_bool_option(opt, default)\n return default unless @config.pluginconf.include?(opt)\n\n val = @config.pluginconf[opt]\n if val =~ /^1|yes|true/\n return true\n elsif val =~ /^0|no|false/\n return false\n else\n return default\n end\n end", "def typus_boolean(attribute = :default)\n options = read_model_config['fields']['options']\n\n boolean = if options && options['booleans'] && boolean = options['booleans'][attribute.to_s]\n boolean.is_a?(String) ? boolean.extract_settings : boolean\n else\n [\"True\", \"False\"]\n end\n\n [[boolean.first, \"true\"], [boolean.last, \"false\"]]\n end", "def boolean_option? opt_sym\n val = default_value opt_sym\n !!val == val\n end", "def boolean(*args, &block)\n args = [{ :using => Option, :default => false, :arity => 0}, *args]\n da = option(*args, &block)\n da.instance_eval do\n kind FalseClass, TrueClass\n from NilClass do\n false\n end\n from Numeric do |n|\n n == 0 ? false : true\n end\n from String do |s|\n case s\n when \"on\", \"true\", \"yes\", \"1\"\n true\n when \"off\", \"false\", \"no\", \"0\"\n false\n else\n raise Doodle::ValidationError, \"unknown value for boolean: #{s}\"\n end\n end\n end\n end", "def boolean(key, default=false)\n\t\tvalue = self.fetch(key.downcase, nil)\n\t\tif value\n\t\t\tif value.strip =~ /^(true|t|yes|y|on|1|enable|enabled|positive|pro|allow|active|activate|accept|trust)$/i\n\t\t\t\treturn true\n\t\t\tend\n\t\t\tif value.strip =~ /^(false|f|no|n|off|0|disable|disabled|negative|con|deny|inactive|deactivate|reject|distrust|mistrust)$/i\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn default\n\tend", "def config_boolean_true?(boolean_field)\n data[boolean_field].to_i == 1\n end", "def config_to_value(v)\n case v\n when 'true'\n true\n when 'false'\n false\n else\n v\n end\n end", "def to_boolean(default = nil)\n return true if ['true', '1', 'yes', 'on', 't'].include? self\n return false if ['false', '0', 'no', 'off', 'f'].include? self\n return default\n end", "def config?\n options[:config]\n end", "def rs_cassandra_bool_config(config_val)\n if config_val.is_a?(String) then\n return config_val\n elsif config_val then\n return \"true\"\n else\n return \"false\"\n end\nend", "def bool(val)\n case val.to_s.downcase\n when 'y', 'yes', 'on', 't', 'true'\n true\n when 'n', 'no', 'off', 'f', 'false'\n false\n else\n nil\n end\nend", "def parse_enabled_bool\n bool_string = @params[:enabled]\n return true if bool_string == true || bool_string =~ /(true|t|yes|y|1|True)$/i\n return false if bool_string == false ||\n bool_string.blank? ||\n bool_string =~ /(false|f|no|n|0|False)$/i\n end", "def typus_boolean(attribute = 'default')\n boolean = Typus::Configuration.config[self.name]['fields']['options']['booleans'][attribute] rescue nil\n boolean = \"true, false\" if boolean.nil?\n return { :true => boolean.split(', ').first.humanize, \n :false => boolean.split(', ').last.humanize }\n end", "def to_bool\n return true if ['true', '1', 'yes', 'on', 't'].include? self\n return false if ['false', '0', 'no', 'off', 'f'].include? self\n return false\n end", "def load_boolean(env_name, default)\r\n raw = load_var(env_name, default, 2)\r\n return raw if raw == true || raw == false\r\n return raw =~ /true|yes/i\r\n end", "def boolean(name, options={})\n param(:boolean, name, options)\n end", "def parse_bool(bool_param)\n bool_param.try(:to_bool) || (bool_param.try(:to_i) == 1)\n end", "def get_boolean_value\n\t\tend", "def typus_boolean(attribute = :default)\n\n begin\n boolean = Typus::Configuration.config[name]['fields']['options']['booleans'][attribute.to_s]\n rescue\n boolean = 'true, false'\n end\n\n return nil if boolean.nil?\n\n hash = ActiveSupport::OrderedHash.new\n\n mapping = boolean.kind_of?(Array) ? boolean : boolean.extract_settings\n hash[:true], hash[:false] = mapping.first, mapping.last\n hash.map { |k, v| hash[k] = v.humanize }\n\n return hash\n\n end", "def convert_opt_in_to_true_false (opt_in_value_num)\n if opt_in_value_num == 0\n opt_in_boolean = false\n elsif opt_in_value_num == 1\n opt_in_boolean = true\n end\n end", "def convert_opt_in_to_true_false (opt_in_value_num)\n if opt_in_value_num == 0\n opt_in_boolean = false\n elsif opt_in_value_num == 1\n opt_in_boolean = true\n end\n end", "def get_bool\n skip_tkspace\n tk = get_tk\n if :on_kw == tk[:kind] && 'true' == tk[:text]\n true\n elsif :on_kw == tk[:kind] && ('false' == tk[:text] || 'nil' == tk[:text])\n false\n else\n unget_tk tk\n true\n end\n end", "def check_boolean(param, default, options = {})\n true_values = (options[:true] ? options[:true] : [\"1\", \"true\"])\n false_values = (options[:false] ? options[:false] : [\"0\", \"false\"])\n if (true_values.include?(param))\n true\n elsif (false_values.include?(param))\n false\n else\n default\n end\n end", "def parse_bool() true end", "def bool(var_name, default = nil)\n return default unless ENV.key?(var_name)\n\n return true if true_value?(ENV[var_name])\n return false if false_value?(ENV[var_name])\n\n default\n end", "def to_bool\n is_a?(::TrueClass) || self == :true || self == :yes || self == :on\n end", "def bool_property(name)\n val = property(name)\n (val && val == 'true')\n end", "def _boolinze(val)\n return true if ['true', '1'].include?(val)\n return false if ['false', '0'].include?(val)\n val\n end", "def is_bool(value) #method\n if value == 'verdadero' || value == 'falso'\n true\n else\n false\n end\n end", "def to_bool(str)\n str = str.to_s.downcase\n return true if str == 'yes' or str == 'true' or str == 'on'\n return true if str.to_i > 0\n return false\n end", "def boolean(value)\n value.strip =~ /^(y|t)$/i ? true : false\n end", "def test_bool_returns_true\n assert_equal(false, Config.bool?('VAULT_BOOLEAN_VAR'))\n set_env 'VAULT_BOOLEAN_VAR', 'true'\n assert_equal(true, Config.bool?('VAULT_BOOLEAN_VAR'))\n\n Config.default(:foo, true)\n assert_equal(true, Config.bool?(:foo))\n end", "def apphelp_boolean( bool )\n apphelp_generic( bool ? :yes : :no )\n end", "def to_boolean(val)\n val && (val.to_s.match(/(true|t|yes|y|1)$/i) != nil)\n end", "def booleanish_to_boolean(arguments, ddl)\n arguments.keys.each do |key|\n if ddl[:input].keys.include?(key)\n if ddl[:input][key][:type] == :boolean\n arguments[key] = true if arguments[key] == \"true\"\n arguments[key] = true if arguments[key] == \"yes\"\n arguments[key] = true if arguments[key] == \"1\"\n arguments[key] = false if arguments[key] == \"false\"\n arguments[key] = false if arguments[key] == \"no\"\n arguments[key] = false if arguments[key] == \"0\"\n end\n end\n end\n rescue\n true\n end", "def to_bool(value, default = false)\n return default if value.nil?\n return value if value.is_a?(TrueClass) || value.is_a?(FalseClass)\n !!(value =~ /^(true|t|yes|y|1)$/i)\n end", "def get_option(option_name)\n\t\toption = nil\n\t\t# Could use ternary conditional expressions here (bool ? true_value : false_value) but chose not to for readability\n\t\tif use_short_option?(option_name)\n\t\t\tdebug_log \"Short version has been flagged for option: #{option}\"\n\t\t\tcase option_name\n\t\t\twhen 'badge'\n\t\t\t\toption = \"-b\"\n\t\t\telse\n\t\t\t\traise \"Option not supported: #{option_name}\"\n\t\t\tend\n\t\telse\n\t\t\tdebug_log \"Short version not flagged for option: #{option}. Using long version.\"\n\t\t\tcase option_name\n\t\t\twhen 'badge'\n\t\t\t\toption = \"--badge\"\n\t\t\telse\n\t\t\t\traise \"Option not supported: #{option_name}\"\n\t\t\tend\n\t\tend\n\n\t\treturn option\n\n\tend", "def boolean(name, option={})\n option[:is_a] = :boolean\n register_attribute_member(name, option)\n define_attribute_accessor(name, option)\n method = <<-EOS\n def #{name}?\n get_attribute(:#{name})\n end\nEOS\n class_eval(method, __FILE__, __LINE__)\n define_validations(name, option)\n end", "def boolean(arg)\n case arg\n when 'true'\n 1\n when 'false'\n 0\n when nil\n 0\n end\n end", "def options?\n false\n end", "def options?\n false\n end", "def optional?\n return config[:optional]\n end", "def boolean?\n !@arg[:boolValue].nil?\n end", "def env_to_bool(var_name, default)\n value = ENV[var_name] || \"\"\n if value.downcase == \"true\"\n true\n elsif value.downcase == \"false\"\n false\n else\n default\n end\nend", "def to_cli_boolean(value)\n case value\n when true\n :true\n else\n :false\n end\n end", "def boolean\n Util.from_bytes :boolean, value\n end", "def test_bool_returns_false\n set_env 'VAULT_BOOLEAN_VAR', 'false'\n assert_equal(false, Config.bool?('VAULT_BOOLEAN_VAR'))\n set_env 'VAULT_BOOLEAN_VAR', 'foo'\n assert_equal(false, Config.bool?('VAULT_BOOLEAN_VAR'))\n set_env 'VAULT_BOOLEAN_VAR', '1'\n assert_equal(false, Config.bool?('VAULT_BOOLEAN_VAR'))\n\n Config.default(:foo, false)\n assert_equal(false, Config.bool?(:foo))\n end", "def display_boolean(value)\n value == \"true\" ? \"Yes\" : \"No\"\n end", "def configuration?\n get_mode.to_s.include?('config')\n end", "def boolean(tag, default_value = false)\n choice(tag){|inst, val|\n if val.nil?\n default_value\n else\n STDERR.puts \"used to be #{val}, norikae #{not val}\"\n not val\n end\n }\n end", "def convert(value)\n case value.to_s\n when /^(yes|y|t(rue)?|1)$/i\n return true\n when /^(no|n|f(alse)?|0)$/i\n return false\n else\n fail TypeError, \"Expected boolean type, got #{value}\"\n end\n end", "def to_boolean(value)\n [\"true\", \"1\", \"yes\"].include?(value.to_s) ? true : false\n end", "def typecast_value_boolean(opts={});true;end", "def convert_to_boolean(value)\n if value == \"yes\"\n true\n else\n false\n end\nend", "def read_bool\n read_word == \"true\"\n end", "def parse_bool() false end", "def parse_bool() false end", "def default_X__PROPERTY_BOOL__X\n config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X')\n end", "def to_boolean(value)\n [\"true\", \"1\", \"yes\"].include?(value.to_s) ? true : false\n end", "def get_boolean\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/boolean'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n _response.raw_body.downcase! == 'true'\n end", "def read_bool; end", "def to_bool(questionable_string)\n\tbool = true\n\tunless questionable_string == \"true\"\n\t\tbool = false\n\tend\n\tbool\nend", "def option_enabled?(app_setting_option)\n AppSettings::DependencyValue.new(app_setting_option, user: @user).on?\n end", "def enabled?(opt, who)\n option(opt)\n e = @state[opt].send(who)\n e == :yes ? true : false\n end", "def display_boolean( value, format = :yesno )\n I18n.t( 'general.boolean.' + format.to_s )[ value ? 0 : 1 ]\n end", "def boolean_type\n 'Boolean'\n end", "def parse_boolean_value(value)\n value.to_s.downcase == 'true'\n end", "def true?(param)\n params[param] == 'on'\n end", "def boolean?\n @kind == :true_kw || @kind == :false_kw\n end", "def str_to_bool(str)\n if str.size > 0 and str[0].chr == '!'\n command = str[1, str.length]\n value = `#{command}`\n else\n value = str\n end\n\n case value.downcase.strip\n when \"false\", \"0\", \"nil\", \"\", \"no\", \"off\"\n nil\n when \"true\", \"1\", \"yes\", \"on\"\n true\n else\n value\n end\n end", "def param_check_bool(param, value)\n if value != 'true' && value != 'false'\n write_output 'Error'.red + \" : argument must be 'true' or 'false' when setting param #{param[:string]}\\n\"\n return false\n end\n param_exec_value_change(param, value)\n end", "def yes_no(bool)\n case bool\n when 1\n \"yes\"\n when 0\n \"no\"\n end\n end", "def supports_options?\n return true\n end", "def options?\n non_empty?(@config.options)\n end", "def desired?(opt)\n st = @wopts[opt]\n st = false if st.nil?\n st\n end", "def run_set_bool(args, default=true)\n set_val = args.size < 2 ? 'on' : args[1]\n setting = @name.gsub(/^(set|show)/,'')\n begin\n settings[setting.to_sym] = @proc.get_onoff(set_val)\n run_show_bool(string_in_show)\n rescue NameError, TypeError\n end\n end", "def boolean?\n @type == :boolean\n end", "def boolean?\n type == \"BOOLEAN\" || type == \"BOOL\"\n end", "def method_missing(sym, *args)\n if sym.to_s =~ /\\A(.*)\\?\\z/ && options.include?($1.to_sym) && (options[$1.to_sym].is_a?(TrueClass) || options[$1.to_sym].is_a?(FalseClass))\n options[$1.to_sym]\n elsif sym.to_s =~ /\\A(.*)\\z/ && options.include?($1.to_sym) \n options[$1.to_sym]\n else\n false\n end\n end", "def configured?\n @config = load_config\n unless @config.nil?\n return unless priviledge_check\n @@options.each do |k,v|\n case resource[v]\n when true, :true, :enable, :enabled\n value = true\n when false, :false, :disable, :disabled, nil\n value = false\n else\n value = resource[v]\n end\n\t config = @config.to_ruby\n return false unless config[k].eql?(value) \n end\n else\n # Create a new configuration\n @config = NSMutableDictionary.new\n return unless priviledge_check\n end\n true\n end", "def option\n return @manager.configurable.class.configuration.options[key]\n end", "def value_is_boolean?(string)\n return %w[true false yes no y n].include?(string.downcase)\n end", "def boolean(sym, options={})\n element(sym, {:type => BooleanConverter, :single => true, :reader => false}.merge(options))\n end", "def str_to_bool(str)\n if str.size > 0 and str[0].chr == '!'\n command = str[1, str.length]\n value = `#{command}`\n else\n value = str\n end\n\n case value.downcase.strip\n when \"false\", \"0\", \"nil\", \"\", \"no\", \"off\"\n nil\n when \"true\", \"1\", \"yes\", \"on\"\n true\n when /\\n/\n value.strip.split(/\\n+/)\n else\n value\n end\n end", "def to_bool(value)\n value.to_s.downcase == 'true' ? true : false\n end", "def options?\n @supports_options\n end", "def flag?(the_flag)\n assit_not_nil(the_flag)\n ENV[the_flag].yes?\n end", "def get_boolean(value_name)\r\n puts \"please input a value for #{value_name} (true/false)\"\r\n answer = gets.chomp\r\n until answer == 'true' || answer == 'false'\r\n puts \"please input either true or false for this value\"\r\n answer = gets.chomp\r\n end\r\n answer\r\n end", "def default?\n options.key?(:default)\n end", "def bool()\n val = _int32(\"bool\")\n\n case val\n when 0\n false\n when 1\n true\n else\n raise ArgumentError, \"Invalid value for bool: #{val}\"\n end\n end", "def parse_boolean(switch)\n if current_is_value?\n if [\"true\", \"TRUE\", \"t\", \"T\", true].include?(peek)\n shift\n true\n elsif [\"false\", \"FALSE\", \"f\", \"F\", false].include?(peek)\n shift\n false\n else\n !no_or_skip?(switch)\n end\n else\n @switches.key?(switch) || !no_or_skip?(switch)\n end\n end", "def automatic?\r\n\t\t\t@automatic ||= json['auto'] == 'Y'\r\n\t\tend", "def to_boolean\r\n\t !!(self.to_s =~ /^(true|t|yes|y|1)$/i)\r\n\tend", "def yesno(bool)\n return 'N/A' if bool.nil?\n bool ? 'YES' : 'NO'\n end", "def boolean_attribute?(name) \n BOOLEAN_ATTRIBUTES.include?(name.to_s)\n end", "def string_to_bool(value)\n return false if value.nil? || value.casecmp('no').zero?\n return true if value.casecmp('yes').zero?\n value # if it doesn't match anything\n end", "def bool_to_word bool\n if bool == \"true\"\n \"Yes\"\n else\n \"No\"\n end\nend", "def bool_to_string(value)\n return 'yes' if value == true\n return 'no' if value == false\n value # if it doesn't match anything\n end" ]
[ "0.8172083", "0.8158482", "0.74252176", "0.7221383", "0.7102384", "0.7072118", "0.6993416", "0.6939167", "0.684158", "0.6835384", "0.6732325", "0.67090964", "0.66438526", "0.6631929", "0.66208476", "0.6613772", "0.66091496", "0.6604708", "0.6571556", "0.6539367", "0.6489771", "0.6489771", "0.6457463", "0.64261895", "0.64259267", "0.6414422", "0.6368007", "0.6352186", "0.6334309", "0.63102883", "0.6292145", "0.6288911", "0.6269111", "0.62670034", "0.6252087", "0.62417424", "0.62348026", "0.62340873", "0.62301004", "0.6226003", "0.62217325", "0.62217325", "0.621293", "0.6210015", "0.6209925", "0.6196026", "0.6192853", "0.618751", "0.61496025", "0.61470836", "0.61432457", "0.61381245", "0.61371875", "0.613214", "0.613026", "0.6129606", "0.61132115", "0.61132115", "0.61018604", "0.6100064", "0.6097189", "0.60852766", "0.60743475", "0.6070265", "0.6058747", "0.6056528", "0.60524875", "0.6044444", "0.60250133", "0.6016545", "0.6012688", "0.60106647", "0.5990394", "0.5988657", "0.5985082", "0.5984724", "0.5984104", "0.5982877", "0.5981144", "0.59758383", "0.5971636", "0.5964626", "0.5964023", "0.59612674", "0.596121", "0.5954812", "0.59509623", "0.5948137", "0.5938253", "0.5936923", "0.59157115", "0.5914862", "0.59125984", "0.59096533", "0.5900926", "0.5897041", "0.5890893", "0.58875746", "0.5884248" ]
0.8155399
3
MES Mark that this user/planner viewed the indicated plan
def viewed_plan(pln) #MES- Is the plan on the planner? if plans.include?(pln) plans.update_attributes(pln, :viewed_at => Time.now_utc) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plan=(new_plan)\n reset\n @plan = new_plan\n end", "def has_contributor_plan?\n (current_user.plan.id == 5)\n end", "def set_plan\n\t\t@plan = Plan.find(params[:id])\n\tend", "def show\n set_client_profile(@plan)\n @goals = @plan.goals\n @tasks = @plan.tasks\n end", "def set_plan\n return unless json_request?\n @plan = current_user.plans.find_by_ident(params[:id])\n return render json: { status: 'failed', alert: '此计划不存在' } unless @plan\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def visibility\n plan = Plan.find(params[:id])\n if plan.present?\n authorize plan\n if plan.visibility_allowed?\n plan.visibility = plan_params[:visibility]\n if plan.save\n deliver_if(recipients: plan.owner_and_coowners,\n key: 'owners_and_coowners.visibility_changed') do |r|\n UserMailer.plan_visibility(r, plan).deliver_now\n end\n redirect_to publish_plan_path(plan), notice: success_message(plan, _('updated'))\n else\n redirect_to publish_plan_path(plan), alert: failure_message(plan, _('update'))\n end\n else\n # rubocop:disable Layout/LineLength\n render status: :forbidden, json: {\n msg: format(_(\"Unable to change the plan's status since it is needed at least %{percentage} percentage responded\"), percentage: Rails.configuration.x.plans.default_percentage_answered)\n }\n # rubocop:enable Layout/LineLength\n end\n else\n render status: :not_found,\n json: { msg: format(_('Unable to find plan id %{plan_id}'),\n plan_id: params[:id]) }\n end\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n puts '==================================='\n puts params \n puts '==================================='\n @plan = Plan.find(params[:id])\n end", "def answer?\n @plan.readable_by?(@user.id)\n end", "def plan\n unless planned?\n @plan_id = Gremlin.world.plan(template.to_class, args).id if validated\n self.save\n end\n end", "def set_plan\r\n @plan = Plan.find(params[:id])\r\n end", "def set_trip_plan\n @trip_plan = TripPlan.where(user_id: current_user.try(:id)).find(params[:id])\n end", "def plan_only\n unless current_user\n redirect_to \"/\", :alert => \"Access denied. You must be a member to suggest a charity. Explore with us as a member now for free.\"\n end\n end", "def assign_plan\n self.plan_id = Plan.find_by_name('Free').id\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def plan\n plan_rebuilder.plan\n end", "def plan\n data['plans'][me]\n end", "def visible_plans(viewing_user_id)\r\n #MES- If the viewing user is the owner of this planner, then\r\n # they can see all the plans\r\n return plans if !viewing_user_id.nil? && viewing_user_id == self.user_id\r\n\r\n #MES- Other users can see all plans that are public\r\n return plans.find_all { |pln| pln.security_level == Plan::SECURITY_LEVEL_PUBLIC }\r\n end", "def change_plan!(new_plan)\n changed = change_plan_internal(new_plan) do\n self.save!\n end\n\n changed && self.plan\n end", "def set_account_plan\r\n @account_plan = AccountPlan.find(params[:id])\r\n end", "def set_plan\n case params[:id]\n when \"course\"\n else \n @plan = Plan.find(params[:id])\n end\n end", "def update_self_and_plan(user, plan)\n if plan[:level].to_i == 1\n self.plan.attributes = plan\n self.plan.save(false)\n self.update_attributes(user)\n else\n self.plan.update_attributes(plan) && self.update_attributes(user) && self.plan.process_transaction\n end\n end", "def display_plan_information(result)\n ui.info ui.color(\"Pre-update resource planning report:\", :bold)\n unless print_plan_result(result, [result.name])\n ui.info \"No resources life cycle changes detected in this update!\"\n end\n if config[:plan_apply]\n return ui.info \"Realizing this stack plan...\"\n elsif config[:plan_only]\n return\n end\n ui.confirm \"Realize this stack plan?\"\n end", "def set_role_from_plan\n if PlannedRole.exists?(employee_id: self.employee_id)\n self.update_attribute :role_id, (PlannedRole.find_by employee_id: self.employee_id).role_id\n end\n end", "def set_user_notenplan\n @user_notenplan = UserNotenplan.find(params[:id])\n end", "def set_user_plan_month\n @user_plan_month = UserPlanMonth.find(params[:id])\n end", "def request_feedback(user)\n Plan.transaction do\n begin\n val = Role.access_values_for(:reviewer, :commenter).min\n self.feedback_requested = true\n \n # Share the plan with each org admin as the reviewer role\n admins = user.org.org_admins\n admins.each do |admin|\n self.roles << Role.new(user: admin, access: val)\n end \n\n if self.save!\n # Send an email confirmation to the owners and co-owners\n owners = User.joins(:roles).where('roles.plan_id =? AND roles.access IN (?)', self.id, Role.access_values_for(:administrator))\n deliver_if(recipients: owners, key: 'users.feedback_requested') do |r|\n UserMailer.feedback_confirmation(r, self, user).deliver_now\n end\n # Send an email to all of the org admins as well as the Org's administrator email\n if user.org.contact_email.present? && !admins.collect{ |u| u.email }.include?(user.org.contact_email)\n admins << User.new(email: user.org.contact_email, firstname: user.org.contact_name)\n end\n deliver_if(recipients: admins, key: 'admins.feedback_requested') do |r|\n UserMailer.feedback_notification(r, self, user).deliver_now\n end\n true\n else\n false\n end\n rescue Exception => e\n Rails.logger.error e\n false\n end\n end\n end", "def set_planer\n @planer = Planer.find(params[:id])\n end", "def plan plan\n plan.myself if respond_to?(:run)\n end", "def plans=(value)\n @plans = value\n end", "def update\n\t\t@plan = Plan.find(params[:id])\n authorize @plan\n\t\tif user_signed_in? && @plan.editable_by(current_user.id) then\n\t\t\trespond_to do |format|\n\t\t\tif @plan.update_attributes(params[:plan])\n\t\t\t\tformat.html { redirect_to @plan, notice: I18n.t('helpers.project.success_update') }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\tend\n\t\tend\n \telse\n\t\t\trender(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)\n \tend\n \tend", "def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end", "def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end", "def set_meeting_plan\n @meeting_plan = MeetingPlan.find(params[:id])\n end", "def plan=(plan)\n @plan = plan\n @relation_graphs =\n if plan then plan.event_relation_graphs\n end\n @execution_engine =\n if plan && plan.executable? then plan.execution_engine\n end\n end", "def edit_plan\n if instructor_signed_in? && current_instructor.merchant.present?\n @instructor = current_instructor\n\n Stripe.api_key = \"sk_test_ECd3gjeIEDsGkySmF8FQOC5i\"\n\n unless @instructor.plan_id == @instructor.id.to_s\n account = Stripe::Account.retrieve(@instructor.merchant.stripe_id)\n @plan = Stripe::Plan.retrieve(@instructor.plan_id, stripe_account: @instructor.merchant.stripe_id)\n @amount = BigDecimal(@plan.amount) / 100\n end\n elsif instructor_signed_in? && current_instructor.merchant.nil?\n redirect_to new_instructor_merchant_path(current_instructor)\n flash[:alert] = \"You need to set up a merchant account first.\"\n else\n redirect_to root_url\n end\n end", "def plan(&block)\n @plan = block\n end", "def publish\n @plan = Plan.find(params[:id])\n if @plan.present?\n authorize @plan\n @plan_roles = @plan.roles.where(active: true)\n @orcid_access_token = ExternalApiAccessToken.for_user_and_service(user: current_user, service: 'orcid')\n else\n redirect_to(plans_path)\n end\n end", "def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @plans = Plan.where(user_id: current_user.id)\n end", "def show\n set_client_profile(@goal)\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n\n @needs = @goal.needs\n end", "def create_plan(plan:, params:)\n plan.visibility = if params['visibility'].blank?\n Rails.configuration.x.plans.default_visibility\n else\n plan_params[:visibility]\n end\n\n plan.template = ::Template.find(params[:template_id])\n\n plan.title = if params[:title].blank?\n if current_user.firstname.blank?\n format(_('My Plan (%{title})'), title: plan.template.title)\n else\n format(_('%{user_name} Plan'), user_name: \"#{current_user.firstname}'s\")\n end\n else\n params[:title]\n end\n\n plan.org = process_org!(user: current_user)\n # If the user said there was no research org, use their org since Plan requires one\n plan.org = current_user.org if plan.org.blank?\n plan.funder = process_org!(user: current_user, namespace: 'funder')\n\n plan.title = plan.title.strip\n\n return unless plan.save\n\n # pre-select org's guidance and the default org's guidance\n ids = (::Org.default_orgs.pluck(:id) << plan.org_id).flatten.uniq\n ggs = ::GuidanceGroup.where(org_id: ids, optional_subset: false, published: true)\n\n plan.guidance_groups << ggs unless ggs.empty?\n plan.add_user!(current_user.id, :creator)\n\n # Set new identifier to plan id by default on create.\n # (This may be changed by user.)\n # ================================================\n # Start DMPTool customization\n # We are using this field as a Funding Opportunity Number\n # ================================================\n # @plan.identifier = @plan.id.to_s\n # ================================================\n # End DMPTool customization\n # ================================================\n plan.save\n plan\n end", "def show\n unless current_user.viewed(@survey)\n add_viewer(user_id=current_user.id, project_id=0, idea_id=0, [email protected], call_for_idea_id=0, actuality_id=0)\n end\n end", "def mark_as_viewed(recipient_user_id)\n if self.recipient_user_id == recipient_user_id && self.viewed_date.nil?\n self.viewed_date = Time.now \n self.save\n end\n end", "def approve(user)\n if !self.approved?\n self.approved = true\n self.manager = user\n self.approved_at = Time.now\n end\n end", "def plan\n @courses = Course.all\n @semesters = Semester.all\n @p_planners = PastPlanner.find_all_semester_groups(current_user)\n @f_planners = FuturePlanner.find_all_semester_groups(current_user)\n end", "def set_test\n plan = Plan.find(params[:id])\n authorize plan\n plan.visibility = (params[:is_test] == '1' ? :is_test : :privately_visible)\n\n if plan.save\n render json: {\n code: 1,\n msg: (plan.is_test? ? _('Your project is now a test.') : _('Your project is no longer a test.'))\n }\n else\n render status: :bad_request, json: {\n code: 0, msg: _(\"Unable to change the plan's test status\")\n }\n end\n end", "def set_location_from_plan\n if PlannedRole.exists?(employee_id: self.employee_id)\n self.update_attribute :location_id, (PlannedRole.find_by employee_id: self.employee_id).location_id\n end\n end", "def plan=(plan)\n @plan = plan\n @relation_graphs = plan&.event_relation_graphs\n @execution_engine = plan.execution_engine if plan&.executable?\n end", "def plan\n AcceptOn::Plan.new(@plan)\n end", "def set_testplan\n @testplan = Testplan.find(params[:id])\n end", "def show\n id = @call.plan_id\n @plan = Plan.find(id)\n @plan = @plan.name\n end", "def plans?\n true\n end", "def create\n @plan = Plan.new(plan_params)\n @plan.user = current_user\n respond_to do |format|\n if @plan.save\n format.html { redirect_to profile_path, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_plan_comment\n @plan_comment = PlanComment.find(params[:id])\n end", "def select_plan\n unless params[:plan] && (params[:plan] == '1' || params[:plan] == '2')\n redirect_to root_url\n end\n end", "def approved_by\n if approved?\n I18n::t(:dean, :scope => [:model, :plan])\n elsif approval\n approval.approved_by\n end\n end", "def plans_templates_show\n @user = User.find_by_id(session[:user_id])\n \n # If an institutional user, return the template \n if user_role_in?(:dmp_admin)\n @plan = Plan.find_by_id(params[:id])\n \n @plan\n elsif user_role_in?(:institutional_admin, :institutional_reviewer, :resource_editor, :template_editor)\n\n @plan = Plan.joins(:users).where(\"users.institution_id IN (?)\", @user.institution.id).find_by_id(params[:id])\n\n # User does not have access to the requested plan\n if @plan.nil?\n render_not_found\n else\n @plan\n end\n else\n render_unauthorized\n end\n end", "def show\n @plan = Plan.find(params[:id])\n end", "def set_article_plan\n @article_plan = ArticlePlan.find(params[:id])\n end", "def plan_params\n params.require(:plan).permit(:name, :user_id)\n end", "def change_plan_internal(new_plan)\n if result = super\n user_account.push_web_hooks_later(:event => \"plan_changed\")\n result\n end\n end", "def set_employee_plan\n @employee_plan = EmployeePlan.find(params[:id])\n end", "def create\n @plan = Plan.new(plan_params)\n respond_to do |format|\n if @plan.save\n PlanUser.create(plan_id: @plan.id, user_id: current_user.id)\n format.html { redirect_to ({action: 'member', id: @plan.id , flg: 'new'}) }\n # format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_on?(peer)\n plan&.update_on?(peer) || super\n end", "def select_plan\n unless (params[:plan] == '1' || params[:plan] == '2')\n flash[:notice] = \"Please select a membership plan to sign up.\"\n redirect_to root_url\n end\n end", "def set_art_plan\n @art_plan = ArtPlan.find(params[:id])\n #byebug\n if @art_plan.nil?\n flash[:danger] = \"ART PROJECT Plan not Found!\"\n redirect_to art_plans_path\n end\n end", "def set_page_plan\n @page_plan = PagePlan.find(params[:id])\n end", "def set_test_plan\n @test_plan = TestPlan.where(project_id: @project.id).find(params[:id])\n end", "def set_check_plan\n @check_plan = CheckPlan.find(params[:id])\n end", "def plan_ids_with_unviewed\r\n\r\n #MES- Select plan IDs for plans that are on our calendar,\r\n # that are taking place in the future, that we've accepted,\r\n # and that have relevant changes that took place AFTER we\r\n # viewed the plan\r\n sql = <<-END_OF_STRING\r\n SELECT\r\n plans.id AS id, count(*) as count\r\n FROM\r\n plans, planners_plans, plan_changes\r\n WHERE\r\n plans.id = planners_plans.plan_id AND\r\n planners_plans.planner_id = ? AND\r\n planners_plans.cal_pln_status IN (?) AND\r\n plans.fuzzy_start > UTC_TIMESTAMP() AND\r\n plan_changes.plan_id = planners_plans.plan_id AND\r\n (\r\n plan_changes.change_type IN (?) OR\r\n (plan_changes.change_type = ? AND plan_changes.comment IS NOT NULL)\r\n ) AND\r\n ((plan_changes.updated_at > planners_plans.viewed_at) OR planners_plans.viewed_at IS NULL) AND\r\n plan_changes.owner_id != ?\r\n GROUP BY plans.id\r\n END_OF_STRING\r\n\r\n res = {}\r\n rows = perform_select_all_sql([sql, self.id, Plan::STATUSES_ACCEPTED, PlanChange::CHANGE_TYPES_COMMENTS_AND_CHANGES, PlanChange::CHANGE_TYPE_RSVP, self.user_id])\r\n rows.each do | row |\r\n res[row['id'].to_i] = row['count'].to_i\r\n end\r\n return res\r\n end", "def set_ad_plan\n @ad_plan = AdPlan.find(params[:id])\n end", "def show\n @plan = SemesterPlan.find(params[:id])\n @users = []\n @users = User.users_of_plan_pure @plan\n @slots = []\n @options = {0 => \"manuellen Plan erstellen\", 1 => \"gültige Lösungen berechnen lassen\", 2 => \"hinreichend optimale Lösung berechnen lassen\"}\n @users.each do |user|\n found = !SemesterPlanConnection.are_build?(user, @plan)\n @plan.time_slots.each do |slot|\n type = slot_type slot\n if found\n @slots << SemesterPlanConnection.create(user: user, time_slot: slot, typus: type, availability: 0)\n else\n @slots << SemesterPlanConnection.find_it(user, slot)\n end\n end\n end\n end", "def go_to_plan(partner)\n localization_text = localized_click(partner, 'plan_link')\n main_section_head.eql?(localization_text)\n end", "def change_plan(vid, plan)\n perform_request(action: 'vserver-change', vserverid: vid, plan: plan)\n end", "def plan; end", "def set_operative_plan\n @operative_plan = OperativePlan.find(params[:id])\n end", "def plan=(plan)\r\n if plan.amount > 0\r\n # Discount the plan with the existing discount (if any)\r\n # if the plan doesn't already have a better discount\r\n plan.discount = discount if discount && discount > plan.discount\r\n # If the assigned plan has a better discount, though, then\r\n # assign the discount to the subscription so it will stick\r\n # through future plan changes\r\n self.discount = plan.discount if plan.discount && plan.discount > discount\r\n else\r\n # Free account from the get-go? No point in having a trial\r\n self.state = 'active' if new_record?\r\n end\r\n\r\n #\r\n # Find any attributes that exist in both the Subscription and SubscriptionPlan\r\n # and that match the pattern of \"something_limit\"\r\n #\r\n limits = self.attributes.keys.select { |k| k =~ /^.+_limit$/ } &\r\n plan.attributes.keys.select { |k| k =~ /^.+_limit$/ }\r\n\r\n (limits + [:amount, :renewal_period]).each do |f|\r\n self.send(\"#{f}=\", plan.send(f))\r\n end\r\n \r\n self.subscription_plan = plan\r\n end", "def join_plan \n\t\trequire 'fcm'\n\t\tactivities = [\"grab food\", \"hang out\", \"group study\", \"party\"]\n\t\tplan_member = PlanMember.new(\n \tplan_id: params[:plan_id],\n \tuser_id: current_user.id\n )\n\t\tplan = Plan.find_by(id: params[:plan_id])\n\n\t\tif plan_member.save\n\t\t\tPlanMessage.create(\n \tplan_id: params[:plan_id],\n \tuser_id: current_user.id, \n \tcontent: \"#{current_user.fullname} is in!\",\n \tsystem_message: true\n )\t\n\n member_count = PlanMember.where(plan_id: params[:plan_id]).count\n\t\t\tis_happening = false\n\t if member_count > 2 && plan.is_happening == false\n\t \tis_happening = true\n\t \tplan.is_happening = true\n\t \tplan.save \n\n\t \tPlanMessage.create(\n\t \tplan_id: params[:plan_id],\n\t \tuser_id: current_user.id, \n\t \tcontent: \"Woohoo this plan to #{activities[plan.activity]} is happening! 3 or more people are in.\",\n\t \tsystem_message: true\n\t )\t\n\t end\n\t render json: { is_success: true, is_happening: is_happening, name_of_joiner: current_user.fullname}, status: :ok\n\t\t\n\t\telse\n\t\t\trender json: { is_success: false }, status: :ok\n\t\tend\n\tend", "def update\n @plan = Plan.find(params[:id])\n authorize @plan\n attrs = plan_params\n # rubocop:disable Metrics/BlockLength\n respond_to do |format|\n # TODO: See notes below on the pan_params definition. We should refactor\n # this once the UI pages have been reworked\n # Save the guidance group selections\n guidance_group_ids = if params[:guidance_group_ids].blank?\n []\n else\n params[:guidance_group_ids].map(&:to_i).uniq\n end\n @plan.guidance_groups = GuidanceGroup.where(id: guidance_group_ids)\n @research_domains = ResearchDomain.all.order(:label)\n\n @plan.funder = process_org!(user: current_user, namespace: 'funder')\n @plan.grant = plan_params[:grant]\n attrs.delete(:funder)\n attrs.delete(:grant)\n\n @plan.title = @plan.title.strip\n\n if @plan.update(attrs)\n format.html do\n redirect_to plan_path(@plan),\n notice: success_message(@plan, _('saved'))\n end\n format.json do\n render json: { code: 1, msg: success_message(@plan, _('saved')) }\n end\n else\n format.html do\n # TODO: Should do a `render :show` here instead but show defines too many\n # instance variables in the controller\n redirect_to plan_path(@plan).to_s, alert: failure_message(@plan, _('save'))\n end\n format.json do\n render json: { code: 0, msg: failure_message(@plan, _('save')) }\n end\n end\n rescue StandardError => e\n flash[:alert] = failure_message(@plan, _('save'))\n format.html do\n Rails.logger.error \"Unable to save plan #{@plan&.id} - #{e.message}\"\n redirect_to plan_path(@plan).to_s, alert: failure_message(@plan, _('save'))\n end\n format.json do\n render json: { code: 0, msg: flash[:alert] }\n end\n end\n # rubocop:enable Metrics/AbcSize, Metrics/BlockLength\n end", "def set_meal_plan\n @meal_plan = MealPlan.find(params[:id])\n end", "def updated_by?(peer)\n plan&.updated_by?(peer) || super\n end", "def set_viewing_group\n @viewing_group = @pcp_subject.viewing_group_map( current_user )\n render_no_permission if @viewing_group == 0 \n end" ]
[ "0.61313593", "0.604793", "0.6032117", "0.6024883", "0.60174525", "0.6013894", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60137343", "0.60071886", "0.5994118", "0.5966878", "0.5942828", "0.5927175", "0.5922982", "0.5915622", "0.59115726", "0.5904379", "0.58912677", "0.58912677", "0.58912677", "0.5889696", "0.5821677", "0.58157116", "0.5802538", "0.57711", "0.57661223", "0.5764854", "0.57580316", "0.57536787", "0.57327205", "0.57306063", "0.5680407", "0.5664525", "0.5662381", "0.5661892", "0.5660929", "0.56528413", "0.56528413", "0.56377983", "0.5633284", "0.56267595", "0.56242985", "0.5619754", "0.5608422", "0.55959654", "0.5593481", "0.5587467", "0.5584923", "0.5576158", "0.5556019", "0.5552844", "0.55384", "0.5535918", "0.55123377", "0.55099523", "0.5501251", "0.54881835", "0.54510266", "0.54481363", "0.54468626", "0.54089016", "0.5408314", "0.54033214", "0.54029024", "0.53967303", "0.5382402", "0.5373973", "0.53716713", "0.53669757", "0.53656155", "0.5361506", "0.5358643", "0.5354039", "0.53471226", "0.5344877", "0.5344604", "0.5342523", "0.5337927", "0.53379005", "0.5334495", "0.5332142", "0.5327281", "0.5320518", "0.5318966", "0.53186107", "0.5309093", "0.5304899", "0.5303484" ]
0.73103297
0
MES Of the plans associated with this planner, which are visible to the indicated user? NOTE: This does NOT check the visiblity of the PLANNER, only of the PLANS
def visible_plans(viewing_user_id) #MES- If the viewing user is the owner of this planner, then # they can see all the plans return plans if !viewing_user_id.nil? && viewing_user_id == self.user_id #MES- Other users can see all plans that are public return plans.find_all { |pln| pln.security_level == Plan::SECURITY_LEVEL_PUBLIC } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plans\n return @plans\n end", "def all_plans\n if current_user.typeofuser == \"admin\" then\n @tenant = current_user.tenant\n @current_plan = @tenant.pricing_plan\n @selected_plan = PricingPlan.find(@tenant.selected_plan_id)\n @pricing_plans = PricingPlan.where(:plan_type => 'public')\n end\n end", "def plans?\n true\n end", "def index\n if current_user.is_admin?\n @plans = Plan.all\n else\n @plans = Plan.where(user_id: current_user.id)\n end\n end", "def index\n @plans = Plan.all\n if not (current_user.role? :faculty) || (current_user.role? :admin)\n @plans = Plan.where(user_id: current_user.id)\n end\n end", "def index\n @plans = Plan.where(user_id: current_user.id)\n end", "def show\n @plan = SemesterPlan.find(params[:id])\n @users = []\n @users = User.users_of_plan_pure @plan\n @slots = []\n @options = {0 => \"manuellen Plan erstellen\", 1 => \"gültige Lösungen berechnen lassen\", 2 => \"hinreichend optimale Lösung berechnen lassen\"}\n @users.each do |user|\n found = !SemesterPlanConnection.are_build?(user, @plan)\n @plan.time_slots.each do |slot|\n type = slot_type slot\n if found\n @slots << SemesterPlanConnection.create(user: user, time_slot: slot, typus: type, availability: 0)\n else\n @slots << SemesterPlanConnection.find_it(user, slot)\n end\n end\n end\n end", "def answer?\n @plan.readable_by?(@user.id)\n end", "def list_plans(filter: nil)\n {\n plans: filter_content(pal.list_plans_with_cache(filter_content: true), filter),\n modulepath: pal.user_modulepath\n }\n end", "def plan\n @courses = Course.all\n @semesters = Semester.all\n @p_planners = PastPlanner.find_all_semester_groups(current_user)\n @f_planners = FuturePlanner.find_all_semester_groups(current_user)\n end", "def plans\n [Free, FreePlus, Pro, Growth, ProSpecial, ProComped, ProManaged, EliteSpecial, Elite, Custom0, Custom1, Custom2, Custom3].map(&:name)\n end", "def plan_ids_with_unviewed\r\n\r\n #MES- Select plan IDs for plans that are on our calendar,\r\n # that are taking place in the future, that we've accepted,\r\n # and that have relevant changes that took place AFTER we\r\n # viewed the plan\r\n sql = <<-END_OF_STRING\r\n SELECT\r\n plans.id AS id, count(*) as count\r\n FROM\r\n plans, planners_plans, plan_changes\r\n WHERE\r\n plans.id = planners_plans.plan_id AND\r\n planners_plans.planner_id = ? AND\r\n planners_plans.cal_pln_status IN (?) AND\r\n plans.fuzzy_start > UTC_TIMESTAMP() AND\r\n plan_changes.plan_id = planners_plans.plan_id AND\r\n (\r\n plan_changes.change_type IN (?) OR\r\n (plan_changes.change_type = ? AND plan_changes.comment IS NOT NULL)\r\n ) AND\r\n ((plan_changes.updated_at > planners_plans.viewed_at) OR planners_plans.viewed_at IS NULL) AND\r\n plan_changes.owner_id != ?\r\n GROUP BY plans.id\r\n END_OF_STRING\r\n\r\n res = {}\r\n rows = perform_select_all_sql([sql, self.id, Plan::STATUSES_ACCEPTED, PlanChange::CHANGE_TYPES_COMMENTS_AND_CHANGES, PlanChange::CHANGE_TYPE_RSVP, self.user_id])\r\n rows.each do | row |\r\n res[row['id'].to_i] = row['count'].to_i\r\n end\r\n return res\r\n end", "def plan\n data['plans'][me]\n end", "def account_plans\n @account_plans_manager\n end", "def index\n if user_signed_in?\n @plans = Plan.where(user_id: current_user.id)\n else\n @plans = []\n end\n end", "def show\n set_client_profile(@goal)\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n\n @needs = @goal.needs\n end", "def readable_by?(user_id)\n user = user_id.is_a?(User) ? user_id : User.find(user_id)\n owner_orgs = self.owner_and_coowners.collect(&:org)\n \n # Super Admins can view plans read-only, Org Admins can view their Org's plans \n # otherwise the user must have the commenter role\n (user.can_super_admin? ||\n user.can_org_admin? && owner_orgs.include?(user.org) ||\n has_role(user.id, :commenter))\n end", "def show\n @lesson_plans = LessonPlan.where(educator_id: current_educator.id).all\n end", "def plans_available_bam(country)\n plan = Plan.select('id, name, detail, price').where('country= ? AND item= ?',\n country, 'bam')\n # Format to show in view\n plans = plan.map { |m| [m.name, m.id] }\n # Format to display details of plans\n details = plan.map {|m| [m.id, m.detail]}\n return [plans, details]\n end", "def plans\n\t @plans = Plan.all\n\t current_user.clean_subscriptions if current_user\n\tend", "def index\n authorize Plan\n @plans = Plan.includes(:roles).active(current_user).page(1)\n @organisationally_or_publicly_visible = if current_user.org.is_other?\n []\n else\n Plan.organisationally_or_publicly_visible(current_user).page(1)\n end\n # TODO: Is this still used? We cannot switch this to use the :plan_params\n # strong params because any calls that do not include `plan` in the\n # query string will fail\n @template = Template.find(params[:plan][:template_id]) if params[:plan].present?\n end", "def plans\n @plans ||= spinner('Loading plans') { Loader.load_all configuration.plan_files }\n end", "def show\n set_client_profile(@plan)\n @goals = @plan.goals\n @tasks = @plan.tasks\n end", "def form_plans\n return @_plans if @_plans.present?\n @_plans = all_plans\n unless current_user.admin?\n @_plans.delete_if {|p| p.disabled? && [email protected]_plan?(p)}\n end\n @_plans\n end", "def get_visible_assistants(viewer_user)\n user_list = if viewer_user.eql?(creator)\n users.select(:id, :name)\n elsif (viewer_user.public_or_following_creator?(self))\n # TODO: ORDER THIS\n users.select(:id, :name, :is_private).collect { |user| \n user if (user.is_public? || viewer_user.following?(user))\n }.compact\n end\n\n return user_list\n end", "def plans\n subscriptions.map(&:plan)\n end", "def index\n @art_plans = current_user.art_plans\n end", "def user_group_project_visibilities\n visibilities = Set.new\n User.current.groups.each do |g|\n g.custom_field_value(group_conditional_custom_field).each do |gcfv|\n visibilities.add gcfv.to_s\n end\n end\n visibilities\n end", "def build_plan_accessible?\n build_plan || is_admin\n end", "def active_plans\n self.plans.includes(:template).where(\"roles.active\": true).where(Role.not_reviewer_condition)\n end", "def visible?(usr=nil)\n (usr || User.current).allowed_to?(:view_cm_qrs, self.project)\n end", "def plan\n plan_rebuilder.plan\n end", "def plans=(value)\n @plans = value\n end", "def visibility\n plan = Plan.find(params[:id])\n if plan.present?\n authorize plan\n if plan.visibility_allowed?\n plan.visibility = plan_params[:visibility]\n if plan.save\n deliver_if(recipients: plan.owner_and_coowners,\n key: 'owners_and_coowners.visibility_changed') do |r|\n UserMailer.plan_visibility(r, plan).deliver_now\n end\n redirect_to publish_plan_path(plan), notice: success_message(plan, _('updated'))\n else\n redirect_to publish_plan_path(plan), alert: failure_message(plan, _('update'))\n end\n else\n # rubocop:disable Layout/LineLength\n render status: :forbidden, json: {\n msg: format(_(\"Unable to change the plan's status since it is needed at least %{percentage} percentage responded\"), percentage: Rails.configuration.x.plans.default_percentage_answered)\n }\n # rubocop:enable Layout/LineLength\n end\n else\n render status: :not_found,\n json: { msg: format(_('Unable to find plan id %{plan_id}'),\n plan_id: params[:id]) }\n end\n end", "def memberships\n @basic_plan = Plan.find(1)\n @pro_plan = Plan.find(2)\n end", "def viewed_plan(pln)\r\n #MES- Is the plan on the planner?\r\n if plans.include?(pln)\r\n plans.update_attributes(pln, :viewed_at => Time.now_utc)\r\n end\r\n end", "def available_invites\n self.user_admin? ? 1 : self[:available_invites]\n end", "def plans(within_product=nil)\n product_id = within_product ? within_product.enabled_products.map(&:id) + [within_product.id] : nil\n Plan.where(:id => plan_ids, :product_id => product_id).all\n end", "def visible?(user=User.current)\n (project.nil? || user.allowed_to?(:view_invoices, project))\n end", "def visible?(usr=nil)\n (usr || User.current).allowed_to?(:view_cm_ncs, self.project)\n end", "def authorized_to_view_records\n visible_records\n end", "def form_plans\n return @_plans if @_plans.present?\n @_plans = all_plans.to_a\n unless admin?\n @_plans.delete_if { |p| p.disabled? && [email protected]_plan?(p) && !p.show_disabled? }\n end\n @_plans\n end", "def has_contributor_plan?\n (current_user.plan.id == 5)\n end", "def visible?(user)\n\n return true if self.for_all?\n\n return false if user.nil?\n\n return true if (user.admin?(User::AUTH_ADDRESSBOOK) or self.owner_id == user.id)\n\n groups = self.get_groups_a\n teams = self.get_teams_a\n\n user.get_groups_a(true).each do |group_id|\n return true if groups.include?(group_id)\n end\n\n user.get_teams_a.each do |team_id|\n return true if teams.include?(team_id)\n end\n\n return false\n end", "def index\n if current_user.role == \"admin\" or current_user.role == \"faculty\" then\n @plans = Plan.all.order('user_id')\n\t \n\t if current_user.role == \"faculty\" then\n\t\t@users = User.where(:role=>'student').order('name')\n\t else\n\t\t@users = User.all.order('name')\n\t end\n else\n @plans = Plan.where(user_id: current_user.id)\n end \n end", "def all_p_bam\n plan = Plan.select('id, name').where('plan_type = ? AND item= ?', 'plan', 'bam')\n # Format to show in view\n plans = plan.map { |m| [m.name, m.name] }\n return plans\n end", "def expose_selections\n params[:attendee] ||= {} # TODO: not sure we need this\n params[:activity_ids] ||= []\n @activity_selections = params[:activity_ids].map(&:to_i)\n @plan_selections = Registration::PlanSelection.parse_params(params['plans'], all_plans)\n end", "def plan_index\n selected_facets = process_facets\n search_term = process_search\n sort_by = process_sort_by\n\n # Fetch the plan ids that match the user's search criteria\n # NOTE: changing the order of columns in `pluck` will impact drop_unused_facets()\n plan_ids = ::Plan.joins(roles: [user: [:org]])\n .publicly_visible\n .search(search_term)\n .faceted_search(facets: selected_facets, sort_by: sort_by)\n .distinct\n .pluck(%w[plans.id plans.funder_id plans.org_id plans.featured plans.created_at\n plans.language_id plans.research_domain_id].join(', '))\n\n # If the user clicked 'View All', set the per_page to match the record count\n per_page = plan_ids.length if public_plans_params[:all]\n per_page = public_plans_params.fetch(:per_page, 10) if per_page.blank?\n\n @viewing_all = public_plans_params[:all].present?\n\n # Handle pagination unless the user clicked 'View All' (Always do this last!)\n @paginated_plan_ids = Kaminari.paginate_array(plan_ids.map { |plan| plan[0] })\n .page(public_plans_params.fetch(:page, 1))\n .per(per_page)\n\n # Only do a full fetch of the plans that are on the current page!\n @plans = ::Plan.includes(:org, :funder, :language, :template, :research_domain, identifiers: [:identifier_scheme],\n roles: [user: [:org]])\n .joins(roles: [user: [:org]])\n .publicly_visible\n .where(::Role.creator_condition)\n .where('roles.active = true')\n .where('plans.id IN (?)', @paginated_plan_ids)\n .order(sort_by)\n\n # Build the facets list and retain the user's current search, sort and faceting selections\n @facets = cached_facet_options\n build_facet(facet: :funders, ids: selected_facets[:funder_ids], plans: plan_ids, facet_pos_in_plans: 1)\n build_facet(facet: :institutions, ids: selected_facets[:org_ids], plans: plan_ids, facet_pos_in_plans: 2)\n build_facet(facet: :languages, ids: selected_facets[:lang_ids], plans: plan_ids, facet_pos_in_plans: 3)\n build_facet(facet: :subjects, ids: selected_facets[:sub_ids], plans: plan_ids, facet_pos_in_plans: 4)\n @facets = @facets.merge({ search: public_plans_params[:search], sort_by: public_plans_params[:sort_by] })\n end", "def show\n @plan = Plan.includes(\n template: [:phases], guidance_groups: [:guidances]\n ).find_by(id: params[:id])\n raise ActiveRecord::RecordNotFound if @plan.blank?\n\n authorize @plan\n @visibility = if @plan.visibility.present?\n @plan.visibility.to_s\n else\n Rails.configuration.x.plans.default_visibility\n end\n # Get all of the available funders\n @funders = Org.funder\n .joins(:templates)\n .where(templates: { published: true }).uniq.sort_by(&:name)\n # TODO: Seems strange to do this. Why are we just not using an `edit` route?\n @editing = (!params[:editing].nil? && @plan.administerable_by?(current_user.id))\n\n # Get all Guidance Groups applicable for the plan and group them by org\n @all_guidance_groups = @plan.guidance_group_options\n @all_ggs_grouped_by_org = @all_guidance_groups.sort.group_by(&:org)\n @selected_guidance_groups = @plan.guidance_groups\n\n # Important ones come first on the page - we grab the user's org's GGs and\n # \"Organisation\" org type GGs\n @important_ggs = []\n\n if @all_ggs_grouped_by_org.include?(current_user.org)\n @important_ggs << [current_user.org, @all_ggs_grouped_by_org[current_user.org]]\n end\n\n @default_orgs = Org.default_orgs\n @all_ggs_grouped_by_org.each do |org, ggs|\n @important_ggs << [org, ggs] if @default_orgs.include?(org)\n\n # If this is one of the already selected guidance groups its important!\n @important_ggs << [org, ggs] if !(ggs & @selected_guidance_groups).empty? && @important_ggs.exclude?([org, ggs])\n end\n\n # Sort the rest by org name for the accordion\n @important_ggs = @important_ggs.sort_by { |org, _gg| (org.nil? ? '' : org.name) }\n @all_ggs_grouped_by_org = @all_ggs_grouped_by_org.sort_by do |org, _gg|\n (org.nil? ? '' : org.name)\n end\n @selected_guidance_groups = @selected_guidance_groups.ids\n\n @based_on = if @plan.template.customization_of.nil?\n @plan.template\n else\n Template.where(family_id: @plan.template.customization_of).first\n end\n\n @research_domains = ResearchDomain.all.order(:label)\n\n respond_to :html\n end", "def visible_corporations\n if @par_rag\n @game.sorted_corporations.select { |c| c == @game.rag }\n else\n @game.sorted_corporations.reject(&:closed?)\n end\n end", "def plans_templates_show\n @user = User.find_by_id(session[:user_id])\n \n # If an institutional user, return the template \n if user_role_in?(:dmp_admin)\n @plan = Plan.find_by_id(params[:id])\n \n @plan\n elsif user_role_in?(:institutional_admin, :institutional_reviewer, :resource_editor, :template_editor)\n\n @plan = Plan.joins(:users).where(\"users.institution_id IN (?)\", @user.institution.id).find_by_id(params[:id])\n\n # User does not have access to the requested plan\n if @plan.nil?\n render_not_found\n else\n @plan\n end\n else\n render_unauthorized\n end\n end", "def view_authorized(current_user)\n return self.goal.public? || self.edit_authorized(current_user)\n end", "def plans\r\n @plans ||= PlansController.new(configuration: @configuration)\r\n end", "def visible?(user=User.current)\n (project.nil? || user.allowed_to?(:view_contacts, project)) && (self.is_public? || self.user_id == user.id)\n end", "def visible_to? a_user\n a_user.participating_programs.include? program\n end", "def index\n @planif_records = current_user.planif_records.all\n end", "def check_read_access_helper(ven, plan_id, usr)\r\n #MES- Is the place public?\r\n return ven if ven.public_venue\r\n \r\n #MES- If the usr is nil, they can't see private places.\r\n raise \"You must log in to view this place\" if usr.nil?\r\n \r\n #MES- We should be able to view public places,\r\n # places that we own, and places that are associated\r\n # with plans that we're attending.\r\n return ven if usr.administrator?\r\n\r\n\r\n #MES- Does the current user own the place?\r\n return ven if ven.owner == usr\r\n\r\n #MES- Is the place associated with the given plan, and is the current\r\n # user associated with the given plan?\r\n raise \"Current user doesn't have read rights on place #{ven.id} and plan_id is nil\" if plan_id.nil?\r\n\r\n pln = Plan.find(plan_id)\r\n raise \"Current user doesn't have read rights on place #{ven.id} and plan #{plan_id} not found\" if pln.nil?\r\n raise \"Place #{ven.id} is not associated with plan #{plan_id}\" if ven != pln.place\r\n if !pln.invitees.include? usr\r\n #MES- The user has to EITHER be on the plan OR be able to see a planner on which the plan is\r\n if params[:cal_id]\r\n planner = Planner.find(params[:cal_id])\r\n if !pln.planners.include?(planner)\r\n raise \"Planner #{planner.id} does not include plan #{plan_id}\"\r\n elsif planner.visibility_level(usr) < Planner::USER_VISIBILITY_LEVEL_DETAILS\r\n raise \"Planner #{planner.id} not visible to current user\"\r\n end\r\n return ven\r\n else\r\n #MGS- no planner passed on querystring\r\n raise \"Current user is not associated with plan #{plan_id}\"\r\n end\r\n end\r\n return ven\r\n end", "def viewable?(user=:false)\n (user != :false && is_visible_to_id <= user.user_level.position) || (user == :false && is_visible_to == UserLevel.find_by_name(\"Anonymous\"))\n end", "def my_peer_results(user)\n results = []\n (self.my_roles(user) - self.my_assigned_roles(user)).each do |role|\n results << self.design_review_results.detect { |drr| drr.role == role }\n end\n results\n end", "def completed_plans\n raise Pundit::NotAuthorizedError unless Api::V0::StatisticsPolicy.new(@user, :statistics).completed_plans?\n\n roles = Role.where(\"#{Role.creator_condition} OR #{Role.administrator_condition}\")\n\n users = User.unscoped\n if @user.can_super_admin? && params[:org_id].present?\n users = users.where(org_id: params[:org_id])\n else\n users = users.where(org_id: @user.org_id)\n end\n\n plans = Plan.where(complete: true)\n if params[:range_dates].present?\n r = {}\n params[:range_dates].each_pair do |k, v|\n range_date_plans = plans\n .where('plans.updated_at >=?', v['start_date'])\n .where('plans.updated_at <=?', v['end_date'])\n r[k] = roles.joins(:user, :plan).merge(users).merge(range_date_plans).select(:plan_id).distinct.count\n end\n respond_to do |format|\n format.json { render(json: r.to_json) }\n format.csv {\n send_data(CSV.generate do |csv|\n csv << [_('Month'), _('No. Completed Plans')]\n total = 0\n r.each_pair{ |k,v| csv << [k,v]; total+=v }\n csv << [_('Total'), total]\n end, filename: \"#{_('completed_plans')}.csv\") }\n end\n else\n plans = plans.where('plans.updated_at >= ?', Date.parse(params[:start_date])) if params[:start_date].present?\n plans = plans.where('plans.updated_at <= ?', Date.parse(params[:end_date])) if params[:end_date].present?\n count = roles.joins(:user, :plan).merge(users).merge(plans).select(:plan_id).distinct.count\n render(json: { completed_plans: count }) \n end\n end", "def roby_plan\n roby_app.plan\n end", "def to_a\n @plans\n end", "def visible?(user=User.current)\n user.allowed_to?(:view_pulls, self.project)\n end", "def do_filtered_plan_display\n filter_plans @arguments.pattern\n\n unless plans.empty?\n frame('Plans') do\n puts build_display_string\n end\n else\n puts stylize(\"{{x}} No plans match #{@arguments.pattern.source}\")\n end\n end", "def index\n @supported_users = current_user.inverse_accountability_partners\n end", "def roaming_plans(country)\n plan = Plan.select('id, name, detail, price').where('country= ? AND plan_type = ? AND item= ?',\n country, 'plan', 'roaming')\n # Format to show in view\n plans = plan.map { |m| [m.name, m.id] }\n # Format to display details of plans\n details = plan.map {|m| [m.id, m.detail]}\n return [plans, details]\n end", "def gr_is_visible?\n eval_policy(:read_access)\n end", "def improvisors\n find_related_frbr_objects( :is_improvised_by, :which_roles?) \n end", "def improvisors\n find_related_frbr_objects( :is_improvised_by, :which_roles?) \n end", "def jmeter_plans\n jmeter_plan_ids = self.client_stats.collect(&:jmeter_plan_id).uniq\n Hailstorm::Model::JmeterPlan.where(id: jmeter_plan_ids)\n end", "def status\n \t\t@plan = Plan.find(params[:id])\n authorize @plan\n \t\tif user_signed_in? && @plan.readable_by(current_user.id) then\n\t\t\trespond_to do |format|\n\t\t\t\tformat.json { render json: @plan.status }\n\t\t\tend\n\t\telse\n\t\t\trender(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)\n\t\tend\n\tend", "def interviewers\n if interview_committee.nil?\n offering_interviewers\n else\n interview_committee.members.active_for(quarter_offered)\n end\n end", "def plans_templates_index\n @user = User.find_by_id(session[:user_id])\n \n # If an institutional user, return the templates that the instition has used to make plans\n if user_role_in?(:dmp_admin)\n @plans = Plan.includes(:requirements_template).order(id: :asc)\n \n @plans\n \n elsif user_role_in?(:institutional_admin, :institutional_reviewer, :resource_editor, :template_editor)\n @plans = Plan.joins(:users).where(\"users.institution_id IN (?)\", @user.institution.id).\n includes(:requirements_template).order(id: :asc)\n @plans\n else\n render_unauthorized\n end\n end", "def show_online_access_facet?(_field_config, facets)\n facets.items.map(&:value).include? current_user.access_type\n end", "def show\n\n # Get base API Connection\n @graph = Koala::Facebook::API.new(session[:access_token])\n\n # Get public details of current application\n #@app = @graph.get_object(ENV[\"FACEBOOK_APP_ID\"])\n\n\n @user = User.find(params[:id])\n @plans = @user.plans.all\n\n @upcoming_plans = @user.plans.find(:all, :conditions => [\"plandate >= ?\", Date.today]).sort_by { |obj| obj.plandate }\n #@past_plans = @user.plans.find(:all, :conditions => [\"plandate < ?\", Date.today]).sort_by { |obj| obj.plandate }\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def visible?(user=User.current)\n true\n end", "def plan\n AcceptOn::Plan.new(@plan)\n end", "def plan_only\n unless current_user\n redirect_to \"/\", :alert => \"Access denied. You must be a member to suggest a charity. Explore with us as a member now for free.\"\n end\n end", "def show\n @lesson_plan = LessonPlan.find(params[:id])\n current_roles = Role.find(:all, :joins=>:logins, :conditions=>['logins.id=?', Login.current_login.id]).map(&:authname)\n @is_admin=true if current_roles.include?(\"administration\") || current_roles.include?(\"lesson_plans_module_admin\")|| current_roles.include?(\"lesson_plans_module_viewer\")|| current_roles.include?(\"lesson_plans_module_user\")\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lesson_plan }\n end\n end", "def visible?(user=User.current)\n user.allowed_to?(:view_issues, self.project)\n end", "def activeVisitable\n activatedVisitable\n end", "def query_plan\n return nil unless @gapi.statistics.query.query_plan\n Array(@gapi.statistics.query.query_plan).map do |stage|\n Stage.from_gapi stage\n end\n end", "def visible?\n if ta_visible || peer_visible\n true\n else\n errors.add(:base, I18n.t('activerecord.errors.models.criterion.visibility_error'))\n false\n end\n end", "def users\n # TODO use SQL\n results = self.approvers + self.observers + [self.requester]\n results.compact\n end", "def viewable_users\n @viewable_users ||= (controllable_users + request_applicants + controllable_users.map{|uu|uu.request_applicants}).flatten.uniq\n end", "def viewers\n self.queue_items.map {|item| item.viewer}\n end", "def show_assets?(participant, user)\n show_restricted_info(participant, user)\n end", "def can_be_accessed_by?(user)\n if visibility == 'public'\n return true\n elsif visibility == 'buddies' && organization.battle_buddy_list.include?(user.organization_id)\n return true\n elsif visibility == 'shared' && buddy_list.split(',').include?(user.organization_id.to_s)\n return true\n elsif visibility == 'executive' && user.is_executive? && organization.users.include?(user)\n return true\n elsif ['private','buddies','shared'].include?(visibility) && organization.users.include?(user)\n return true\n else\n return false\n end\n end", "def index\n @goals = Goal.select{|goal| goal.resolution.user_id == current_user.id}\n end", "def lesson_plan_item_actable_names\n []\n end", "def created_plans\n raise Pundit::NotAuthorizedError unless Api::V0::StatisticsPolicy.new(@user, :statistics).plans?\n \n roles = Role.where(\"#{Role.creator_condition} OR #{Role.administrator_condition}\")\n\n users = User.unscoped\n if @user.can_super_admin? && params[:org_id].present?\n users = users.where(org_id: params[:org_id])\n else\n users = users.where(org_id: @user.org_id)\n end\n\n plans = Plan.all\n if params[:range_dates].present?\n r = {}\n params[:range_dates].each_pair do |k, v|\n range_date_plans = plans\n .where('plans.created_at >=?', v['start_date'])\n .where('plans.created_at <=?', v['end_date'])\n r[k] = roles.joins(:user, :plan).merge(users).merge(range_date_plans).select(:plan_id).distinct.count\n end\n respond_to do |format|\n format.json { render(json: r.to_json) }\n format.csv {\n send_data(CSV.generate do |csv|\n csv << [_('Month'), _('No. Plans')]\n total = 0\n r.each_pair{ |k,v| csv << [k,v]; total+=v }\n csv << [_('Total'), total]\n end, filename: \"#{_('plans')}.csv\") }\n end\n else\n plans = plans.where('plans.created_at >= ?', Date.parse(params[:start_date])) if params[:start_date].present?\n plans = plans.where('plans.created_at <= ?', Date.parse(params[:end_date])) if params[:end_date].present?\n count = roles.joins(:user, :plan).merge(users).merge(plans).select(:plan_id).distinct.count\n render(json: { created_plans: count })\n end\n end", "def collaborators\n self.users.where(\"project_memberships.active = ?\", true)\n end", "def show \n available_users\n end", "def projects_visible_to_current_user\n ::Project\n .in_namespace(group.self_and_descendants.select(:id))\n .public_or_visible_to_user(current_user)\n end", "def index\n @operative_plans = OperativePlan.all\n end", "def visible_users\n is_superadmin? ? User.all : title.users\n end", "def ops_airports\n Airport.ops_user_is(self)\n end", "def viewable_by?(user)\n Sugar.public_browsing? || user ? true : false\n end", "def planwatch_entries\n if User.current_user && User.current_user.watch_order == \"alph\"\n planwatch_entries_sorted_by_username\n else\n planwatch_entries_sorted_by_last_update\n end\n end", "def presenters\n find_related_frbr_objects( :is_presented_by, :which_roles?) \n end" ]
[ "0.6818674", "0.658455", "0.64472157", "0.6380544", "0.6378029", "0.6353371", "0.62980527", "0.62788904", "0.62707305", "0.625661", "0.62412214", "0.6212541", "0.61753654", "0.610983", "0.6104827", "0.609371", "0.60398334", "0.6039682", "0.5999258", "0.5998156", "0.59873533", "0.5985885", "0.59699756", "0.59643406", "0.59534276", "0.5933258", "0.58911514", "0.5890904", "0.58790034", "0.58789897", "0.58727", "0.5868106", "0.58624274", "0.5831374", "0.58291215", "0.5818285", "0.5808353", "0.5804109", "0.57903117", "0.5783388", "0.57833534", "0.5781878", "0.5776511", "0.5772046", "0.5767057", "0.5766934", "0.57664096", "0.57417923", "0.5738094", "0.5726675", "0.5724509", "0.57032925", "0.5699747", "0.5686167", "0.56839246", "0.5664139", "0.56574976", "0.56471634", "0.56422746", "0.5628598", "0.56198657", "0.56179464", "0.5609844", "0.56087273", "0.5603593", "0.55895346", "0.5586859", "0.5576692", "0.5576692", "0.5567941", "0.55672514", "0.5561895", "0.55561525", "0.5549033", "0.5547142", "0.55462784", "0.5539924", "0.55393803", "0.5533755", "0.553035", "0.55211484", "0.55187815", "0.5511459", "0.54974705", "0.5491724", "0.54832226", "0.54826236", "0.54825485", "0.5472905", "0.54724723", "0.5452783", "0.5452578", "0.54525113", "0.5451882", "0.5449574", "0.5441291", "0.5437169", "0.54339", "0.54318756", "0.5427191" ]
0.83265644
0
MES Returns a hash where the keys are the IDs of plans on this planner that have unviewed changes (e.g. plans that have a new comment since the user last viewed the plan.) Viewing time is controlled by the viewed_plan function.
def plan_ids_with_unviewed #MES- Select plan IDs for plans that are on our calendar, # that are taking place in the future, that we've accepted, # and that have relevant changes that took place AFTER we # viewed the plan sql = <<-END_OF_STRING SELECT plans.id AS id, count(*) as count FROM plans, planners_plans, plan_changes WHERE plans.id = planners_plans.plan_id AND planners_plans.planner_id = ? AND planners_plans.cal_pln_status IN (?) AND plans.fuzzy_start > UTC_TIMESTAMP() AND plan_changes.plan_id = planners_plans.plan_id AND ( plan_changes.change_type IN (?) OR (plan_changes.change_type = ? AND plan_changes.comment IS NOT NULL) ) AND ((plan_changes.updated_at > planners_plans.viewed_at) OR planners_plans.viewed_at IS NULL) AND plan_changes.owner_id != ? GROUP BY plans.id END_OF_STRING res = {} rows = perform_select_all_sql([sql, self.id, Plan::STATUSES_ACCEPTED, PlanChange::CHANGE_TYPES_COMMENTS_AND_CHANGES, PlanChange::CHANGE_TYPE_RSVP, self.user_id]) rows.each do | row | res[row['id'].to_i] = row['count'].to_i end return res end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def viewed_plan(pln)\r\n #MES- Is the plan on the planner?\r\n if plans.include?(pln)\r\n plans.update_attributes(pln, :viewed_at => Time.now_utc)\r\n end\r\n end", "def visible_plans(viewing_user_id)\r\n #MES- If the viewing user is the owner of this planner, then\r\n # they can see all the plans\r\n return plans if !viewing_user_id.nil? && viewing_user_id == self.user_id\r\n\r\n #MES- Other users can see all plans that are public\r\n return plans.find_all { |pln| pln.security_level == Plan::SECURITY_LEVEL_PUBLIC }\r\n end", "def plans\n return @plans\n end", "def list_plans(filter: nil)\n {\n plans: filter_content(pal.list_plans_with_cache(filter_content: true), filter),\n modulepath: pal.user_modulepath\n }\n end", "def view\n {\n 'canceled_at' => canceled_at,\n 'plan' => plan,\n 'status' => status,\n }\n end", "def jmeter_plans\n jmeter_plan_ids = self.client_stats.collect(&:jmeter_plan_id).uniq\n Hailstorm::Model::JmeterPlan.where(id: jmeter_plan_ids)\n end", "def hash\n [timing, plan, amount, quantity, billing, amount_incl_vat, compensation_method, partial_period_handling, start_date, cancel_change, add_ons, remove_add_ons].hash\n end", "def plans=(value)\n @plans = value\n end", "def plan\n data['plans'][me]\n end", "def plans\n\t @plans = Plan.all\n\t current_user.clean_subscriptions if current_user\n\tend", "def expose_selections\n params[:attendee] ||= {} # TODO: not sure we need this\n params[:activity_ids] ||= []\n @activity_selections = params[:activity_ids].map(&:to_i)\n @plan_selections = Registration::PlanSelection.parse_params(params['plans'], all_plans)\n end", "def hash\n [account_id_guid, account_name, account_settings, allow_transaction_rooms, billing_period_days_remaining, billing_period_end_date, billing_period_envelopes_allowed, billing_period_envelopes_sent, billing_period_start_date, billing_profile, can_upgrade, connect_permission, created_date, currency_code, current_plan_id, distributor_code, docu_sign_landing_url, dss_values, envelope_sending_blocked, envelope_unit_price, external_account_id, forgotten_password_questions_count, is_downgrade, payment_method, plan_classification, plan_end_date, plan_name, plan_start_date, recipient_domains, seats_allowed, seats_in_use, status21_cfr_part11, suspension_date, suspension_status].hash\n end", "def all_plans\n if current_user.typeofuser == \"admin\" then\n @tenant = current_user.tenant\n @current_plan = @tenant.pricing_plan\n @selected_plan = PricingPlan.find(@tenant.selected_plan_id)\n @pricing_plans = PricingPlan.where(:plan_type => 'public')\n end\n end", "def plan\n plan_rebuilder.plan\n end", "def hash\n [handle, customer, plan, state, test, amount, quantity, expires, reactivated, timezone, created, activated, renewing, plan_version, amount_incl_vat, start_date, end_date, grace_duration, current_period_start, next_period_start, first_period_start, last_period_start, trial_start, trial_end, is_cancelled, in_trial, has_started, renewal_count, cancelled_date, expired_date, expire_reason, on_hold_date, on_hold_reason, payment_method_added, scheduled_plan_change, reminder_email_sent, failed_invoices, failed_amount, cancelled_invoices, cancelled_amount, pending_invoices, pending_amount, dunning_invoices, dunning_amount, settled_invoices, settled_amount, refunded_amount, pending_additional_costs, pending_additional_cost_amount, transferred_additional_costs, transferred_additional_cost_amount, pending_credits, pending_credit_amount, transferred_credits, transferred_credit_amount, hosted_page_links, subscription_discounts, pending_change, subscription_changes, subscription_add_ons].hash\n end", "def hash\n [created, changed_by, updated, metadata, id, version_id, crm_id, account_id, organization_id, product_id, product_rate_plan_id, parent_id, name, description, type, state, current_period_start, current_period_end, contract_start, subscription_end, current_period_end_explicit, initial_period_start, successful_periods, total_periods, trial_end, dunning, locked, managed_by, version_start, version_end, version_number, credit_enabled, aggregate_all_subscriptions_on_account, pricing_component_values, payment_method_subscription_links, fixed_terms, current_time, time_offset, payment_terms, purchase_order, failed_payment_behaviour].hash\n end", "def hash\n [id, _info, actual_end, actual_hours, actual_start, agreement, bill_expenses, billing_amount, billing_attention, billing_method, billing_rate_type, billing_terms, bill_products, bill_project_after_closed_flag, bill_time, bill_to_company, bill_to_contact, bill_to_site, bill_unapproved_time_and_expense, board, budget_analysis, budget_flag, budget_hours, business_unit_id, company, contact, customer_po, description, downpayment, estimated_end, estimated_expense_revenue, estimated_hours, estimated_product_revenue, estimated_start, estimated_time_revenue, expense_approver, include_dependencies_flag, include_estimates_flag, location_id, manager, name, opportunity, project_template_id, restrict_down_payment_flag, scheduled_end, scheduled_hours, scheduled_start, ship_to_company, ship_to_contact, ship_to_site, site, status, time_approver, type].hash\n end", "def plan_index\n selected_facets = process_facets\n search_term = process_search\n sort_by = process_sort_by\n\n # Fetch the plan ids that match the user's search criteria\n # NOTE: changing the order of columns in `pluck` will impact drop_unused_facets()\n plan_ids = ::Plan.joins(roles: [user: [:org]])\n .publicly_visible\n .search(search_term)\n .faceted_search(facets: selected_facets, sort_by: sort_by)\n .distinct\n .pluck(%w[plans.id plans.funder_id plans.org_id plans.featured plans.created_at\n plans.language_id plans.research_domain_id].join(', '))\n\n # If the user clicked 'View All', set the per_page to match the record count\n per_page = plan_ids.length if public_plans_params[:all]\n per_page = public_plans_params.fetch(:per_page, 10) if per_page.blank?\n\n @viewing_all = public_plans_params[:all].present?\n\n # Handle pagination unless the user clicked 'View All' (Always do this last!)\n @paginated_plan_ids = Kaminari.paginate_array(plan_ids.map { |plan| plan[0] })\n .page(public_plans_params.fetch(:page, 1))\n .per(per_page)\n\n # Only do a full fetch of the plans that are on the current page!\n @plans = ::Plan.includes(:org, :funder, :language, :template, :research_domain, identifiers: [:identifier_scheme],\n roles: [user: [:org]])\n .joins(roles: [user: [:org]])\n .publicly_visible\n .where(::Role.creator_condition)\n .where('roles.active = true')\n .where('plans.id IN (?)', @paginated_plan_ids)\n .order(sort_by)\n\n # Build the facets list and retain the user's current search, sort and faceting selections\n @facets = cached_facet_options\n build_facet(facet: :funders, ids: selected_facets[:funder_ids], plans: plan_ids, facet_pos_in_plans: 1)\n build_facet(facet: :institutions, ids: selected_facets[:org_ids], plans: plan_ids, facet_pos_in_plans: 2)\n build_facet(facet: :languages, ids: selected_facets[:lang_ids], plans: plan_ids, facet_pos_in_plans: 3)\n build_facet(facet: :subjects, ids: selected_facets[:sub_ids], plans: plan_ids, facet_pos_in_plans: 4)\n @facets = @facets.merge({ search: public_plans_params[:search], sort_by: public_plans_params[:sort_by] })\n end", "def hash\n [id, project_id, description, board, status, agreement, opportunity, parent_phase, wbs_code, bill_time, bill_expenses, bill_products, mark_as_milestone_flag, notes, deadline_date, bill_separately_flag, billing_method, scheduled_hours, scheduled_start, scheduled_end, actual_hours, actual_start, actual_end, budget_hours, location_id, business_unit_id, hourly_rate, billing_start_date, bill_phase_closed_flag, bill_project_closed_flag, downpayment, po_number, po_amount, estimated_time_cost, estimated_expense_cost, estimated_product_cost, estimated_time_revenue, estimated_expense_revenue, estimated_product_revenue, currency, bill_to_company, bill_to_contact, bill_to_site, ship_to_company, ship_to_contact, ship_to_site, _info].hash\n end", "def plans\r\n @plans ||= PlansController.new(configuration: @configuration)\r\n end", "def form_plans\n return @_plans if @_plans.present?\n @_plans = all_plans.to_a\n unless admin?\n @_plans.delete_if { |p| p.disabled? && [email protected]_plan?(p) && !p.show_disabled? }\n end\n @_plans\n end", "def form_plans\n return @_plans if @_plans.present?\n @_plans = all_plans\n unless current_user.admin?\n @_plans.delete_if {|p| p.disabled? && [email protected]_plan?(p)}\n end\n @_plans\n end", "def plans\n subscriptions.map(&:plan)\n end", "def fetch\n plans = @pgsql.exec(\n [\n 'SELECT plan.id, plan.completed, plan.schedule,',\n 'SUM(risk.probability * effect.impact) / COUNT(triple.id) AS rank',\n 'FROM plan',\n 'JOIN part ON part.id = plan.part',\n 'JOIN project ON part.project = project.id',\n 'JOIN triple ON cause = plan.part OR risk = plan.part OR effect = plan.part',\n 'JOIN risk ON triple.risk = risk.id',\n 'JOIN effect ON triple.effect = effect.id',\n 'LEFT JOIN task ON task.plan = plan.id',\n 'WHERE project.login = $1 AND task.id IS NULL',\n 'GROUP BY plan.id, plan.completed, plan.schedule'\n ],\n [@login]\n )\n plans.select { |p| deadline(Time.parse(p['completed']), p['schedule'].strip.downcase) < Time.now }\n .map { |p| p['id'].to_i }\n end", "def plan_information(plan, options = {})\n apps = get_option(options, \"apps\", [])\n stages = get_option(options, \"stages\", [])\n report = []\n plan.plan_stages.each do |stage|\n if stages.empty? || stages.include?(stage.name)\n report << {\"stage\" => stage.name}\n components = []\n requests = stage.requests.include(:apps_requests).where(\"aasm_state IN ('complete, planned')\").order(\"apps_requests.app_id, aasm_state, requests.id DESC\")\n cur_app = \"\"; cur_env = \"\"\n request.each do |request|\n if request.app_name.first != cur_app\n report += components.sort{|a,b| a[\"component\"] <=> b[\"component\"] }\n report << {\"app\" => request.app_name.first, \"environment\" => request.environment.name }\n components = []\n cur_app = request.app_name.first\n end\n request_component_versions(request).each do |comp, ver|\n components << {\"component\" => comp, \"version\" => ver, \"request\" => request.number, \"environment\" => request.environment.name }\n end\n end\n end\n end\n report\nend", "def index\n @plans = Plan.where(user_id: current_user.id)\n end", "def planwatch_entries\n if User.current_user && User.current_user.watch_order == \"alph\"\n planwatch_entries_sorted_by_username\n else\n planwatch_entries_sorted_by_last_update\n end\n end", "def index\n if user_signed_in?\n @plans = Plan.where(user_id: current_user.id)\n else\n @plans = []\n end\n end", "def roby_plan\n roby_app.plan\n end", "def plan_status(plan)\r\n cur_stat = Plan::STATUS_NO_RELATION\r\n existing_plan = self.plans.detect { | item | item.id == plan.id }\r\n cur_stat = existing_plan.cal_pln_status if !existing_plan.nil?\r\n return cur_stat\r\n end", "def to_a\n @plans\n end", "def roaming_plans(country)\n plan = Plan.select('id, name, detail, price').where('country= ? AND plan_type = ? AND item= ?',\n country, 'plan', 'roaming')\n # Format to show in view\n plans = plan.map { |m| [m.name, m.id] }\n # Format to display details of plans\n details = plan.map {|m| [m.id, m.detail]}\n return [plans, details]\n end", "def account_plans\n @account_plans_manager\n end", "def plan_object\n Plan.new plan\n end", "def active_plans\n self.plans.includes(:template).where(\"roles.active\": true).where(Role.not_reviewer_condition)\n end", "def created_plans\n raise Pundit::NotAuthorizedError unless Api::V0::StatisticsPolicy.new(@user, :statistics).plans?\n \n roles = Role.where(\"#{Role.creator_condition} OR #{Role.administrator_condition}\")\n\n users = User.unscoped\n if @user.can_super_admin? && params[:org_id].present?\n users = users.where(org_id: params[:org_id])\n else\n users = users.where(org_id: @user.org_id)\n end\n\n plans = Plan.all\n if params[:range_dates].present?\n r = {}\n params[:range_dates].each_pair do |k, v|\n range_date_plans = plans\n .where('plans.created_at >=?', v['start_date'])\n .where('plans.created_at <=?', v['end_date'])\n r[k] = roles.joins(:user, :plan).merge(users).merge(range_date_plans).select(:plan_id).distinct.count\n end\n respond_to do |format|\n format.json { render(json: r.to_json) }\n format.csv {\n send_data(CSV.generate do |csv|\n csv << [_('Month'), _('No. Plans')]\n total = 0\n r.each_pair{ |k,v| csv << [k,v]; total+=v }\n csv << [_('Total'), total]\n end, filename: \"#{_('plans')}.csv\") }\n end\n else\n plans = plans.where('plans.created_at >= ?', Date.parse(params[:start_date])) if params[:start_date].present?\n plans = plans.where('plans.created_at <= ?', Date.parse(params[:end_date])) if params[:end_date].present?\n count = roles.joins(:user, :plan).merge(users).merge(plans).select(:plan_id).distinct.count\n render(json: { created_plans: count })\n end\n end", "def get_semesters_courses\n\t\t@plans_courses = PlansCourse.where(plan_id: @plan.id)\n\t\t@plans_courses_hash = Hash.new\n\t\[email protected] do |semester|\n\t\t\t@plans_courses_hash[\"#{semester}\"] = Array.new\n\t\tend\n\t\t@plans_courses.each do |course|\n\t\t\tif(@plans_courses_hash.has_key?(course.taken_planned))\n\t\t\t\t@plans_courses_hash[\"#{course.taken_planned}\"] << Course.find(course.course_id)\n\t\t\tend\n\t\tend\n\t\treturn @plans_courses_hash\n\tend", "def hash\n [id, created, modified, company_name, domain_name, state, billing_email, plan_name, plan_expires, application_limit, user_limit, campaign_limit, api_limit, application_count, user_count, campaigns_active_count, campaigns_inactive_count, attributes].hash\n end", "def plan_id\r\n subscription_plan_id\r\n end", "def hash\n [id, portal_config, project_name_flag, project_type_flag, status_flag, project_manager_flag, billing_method_flag, contact_flag, estimated_start_flag, estimated_end_flag, description_flag, last_updated_flag, only_display, time_material_budget_hrs_flag, time_material_scheduled_start_flag, time_material_scheduled_finish_flag, time_material_scheduled_hrs_flag, time_material_actual_start_flag, time_material_actual_finish_flag, time_material_actual_hrs_flag, time_material_bill_flag, time_material_status_flag, time_material_assigned_flag, fixed_fee_budget_hrs_flag, fixed_fee_scheduled_start_flag, fixed_fee_scheduled_finish_flag, fixed_fee_scheduled_hrs_flag, fixed_fee_actual_start_flag, fixed_fee_actual_finish_flag, fixed_fee_actual_hrs_flag, fixed_fee_bill_flag, fixed_fee_status_flag, fixed_fee_assigned_flag, project_issue_budget_hrs_flag, project_issue_scheduled_start_flag, project_issue_scheduled_finish_flag, project_issue_scheduled_hrs_flag, project_issue_actual_start_flag, project_issue_actual_finish_flag, project_issue_actual_hrs_flag, project_issue_bill_flag, project_issue_status_flag, project_issue_assigned_flag, project_detail_total_hours_flag, _info].hash\n end", "def index\n if current_user.is_admin?\n @plans = Plan.all\n else\n @plans = Plan.where(user_id: current_user.id)\n end\n end", "def stats_to_hash\n {\n views_count: views,\n views_till_end_count: views_till_end,\n sum_view_time_sec: sum_view_time_sec,\n comments_count: comments,\n }\n end", "def hash\n [activity_id, blueprint_id, blueprint_location_id, blueprint_type_id, completed_character_id, completed_date, cost, duration, end_date, facility_id, installer_id, job_id, licensed_runs, output_location_id, pause_date, probability, product_type_id, runs, start_date, station_id, status, successful_runs].hash\n end", "def hash\n [class_schedule_id, visits, clients, location, resource, max_capacity, web_capacity, total_booked, total_booked_waitlist, web_booked, semester_id, is_canceled, substitute, active, is_waitlist_available, is_enrolled, hide_cancel, id, is_available, start_date_time, end_date_time, last_modified_date_time, class_description, staff, booking_window, booking_status].hash\n end", "def show\n set_client_profile(@plan)\n @goals = @plan.goals\n @tasks = @plan.tasks\n end", "def plans\n @plans ||= spinner('Loading plans') { Loader.load_all configuration.plan_files }\n end", "def completed_plans\n raise Pundit::NotAuthorizedError unless Api::V0::StatisticsPolicy.new(@user, :statistics).completed_plans?\n\n roles = Role.where(\"#{Role.creator_condition} OR #{Role.administrator_condition}\")\n\n users = User.unscoped\n if @user.can_super_admin? && params[:org_id].present?\n users = users.where(org_id: params[:org_id])\n else\n users = users.where(org_id: @user.org_id)\n end\n\n plans = Plan.where(complete: true)\n if params[:range_dates].present?\n r = {}\n params[:range_dates].each_pair do |k, v|\n range_date_plans = plans\n .where('plans.updated_at >=?', v['start_date'])\n .where('plans.updated_at <=?', v['end_date'])\n r[k] = roles.joins(:user, :plan).merge(users).merge(range_date_plans).select(:plan_id).distinct.count\n end\n respond_to do |format|\n format.json { render(json: r.to_json) }\n format.csv {\n send_data(CSV.generate do |csv|\n csv << [_('Month'), _('No. Completed Plans')]\n total = 0\n r.each_pair{ |k,v| csv << [k,v]; total+=v }\n csv << [_('Total'), total]\n end, filename: \"#{_('completed_plans')}.csv\") }\n end\n else\n plans = plans.where('plans.updated_at >= ?', Date.parse(params[:start_date])) if params[:start_date].present?\n plans = plans.where('plans.updated_at <= ?', Date.parse(params[:end_date])) if params[:end_date].present?\n count = roles.joins(:user, :plan).merge(users).merge(plans).select(:plan_id).distinct.count\n render(json: { completed_plans: count }) \n end\n end", "def application_plans\n manager_instance(ApplicationPlanManager)\n end", "def plan=(new_plan)\n reset\n @plan = new_plan\n end", "def payer_plans\n payerplan_type = \"http://hl7.org/fhir/us/davinci-pdex-plan-net/CodeSystem/InsuranceProductTypeCS|\"\n reply = @client.search(FHIR::InsurancePlan, search: { parameters: { type: payerplan_type } }).resource\n @payersbyid = build_payer_plans(reply)\n session[:payersbyid] = compress_hash(@payersbyid.to_json)\n\n # Prepare the query string for display on the page\n @search = URI.decode(reply.link.select { |l| l.relation === \"self\" }.first.url) if reply.link.first\n session[:payersplan_query] = @search\n rescue => exception\n puts \"payer plans fails: #{exception}\"\n @payersbyid ||= {}\n end", "def hash\n [id, name, based_on, custom_calendar, default_flag, application_order, hi_impact_hi_urgency, hi_impact_med_urgency, hi_impact_low_urgency, med_impact_hi_urgency, med_impact_med_urgency, med_impact_low_urgency, low_impact_hi_urgency, low_impact_med_urgency, low_impact_low_urgency, respond_hours, respond_percent, plan_within, plan_within_percent, resolution_hours, resolution_percent, _info].hash\n end", "def index\n @plans = Plan.all\n if not (current_user.role? :faculty) || (current_user.role? :admin)\n @plans = Plan.where(user_id: current_user.id)\n end\n end", "def plans(within_product=nil)\n product_id = within_product ? within_product.enabled_products.map(&:id) + [within_product.id] : nil\n Plan.where(:id => plan_ids, :product_id => product_id).all\n end", "def show\n @plan = SemesterPlan.find(params[:id])\n @users = []\n @users = User.users_of_plan_pure @plan\n @slots = []\n @options = {0 => \"manuellen Plan erstellen\", 1 => \"gültige Lösungen berechnen lassen\", 2 => \"hinreichend optimale Lösung berechnen lassen\"}\n @users.each do |user|\n found = !SemesterPlanConnection.are_build?(user, @plan)\n @plan.time_slots.each do |slot|\n type = slot_type slot\n if found\n @slots << SemesterPlanConnection.create(user: user, time_slot: slot, typus: type, availability: 0)\n else\n @slots << SemesterPlanConnection.find_it(user, slot)\n end\n end\n end\n end", "def all_plans\n file = File.read('./data/bundle.json')\n plan_hash = JSON.parse(file)\n plans = plan_hash['plans']\n end", "def plan_params plan\n {\n name: plan.name,\n plan_id: plan.id,\n status: plan.status,\n chargebee_data: {\n price: plan.price,\n period: plan.period,\n period_unit: plan.period_unit,\n trial_period: plan.trial_period,\n trial_period_unit: plan.trial_period_unit,\n charge_model: plan.charge_model,\n free_quantity: plan.free_quantity\n }\n }\n end", "def hash\n [additional_query_filters, global_time_target, show_error_budget, slo_id, time_windows, title, title_align, title_size, type, view_mode, view_type].hash\n end", "def get_plansbyid\n if session[:plansbyid]\n @plansbyid = JSON.parse(decompress_hash(session[:plansbyid])).deep_symbolize_keys\n @locationsbyid = JSON.parse(decompress_hash(session[:locationsbyid])).deep_symbolize_keys\n @cp_options = decompress_hash(session[:cp_options])\n @search = session[:query]\n else\n puts \"get_plansbyid: session[:plansbyid] is #{session[:plansbyid]}, calling coverage_plans \"\n coverage_plans\n end\n end", "def plan\n AcceptOn::Plan.new(@plan)\n end", "def snapshot(reused_relation_graphs = nil)\n plan = self.plan.dup\n plan.extend ReplayPlan\n\n if reused_relation_graphs\n relations = reused_relation_graphs\n else\n relations = Hash.new\n all_relations.each do |rel|\n relations[rel] = rel.dup\n end\n end\n\n return PlanRebuilderSnapshot.new(stats, state, plan, relations)\n end", "def new_plan\n plan.clear\n plan\n end", "def plan\n @courses = Course.all\n @semesters = Semester.all\n @p_planners = PastPlanner.find_all_semester_groups(current_user)\n @f_planners = FuturePlanner.find_all_semester_groups(current_user)\n end", "def plan?\n now = Time.zone.now\n\n have_discounts = clients_plans.with_discounts\n !have_discounts.empty? && have_discounts.any? do |plan|\n now < plan.expired_date\n end\n end", "def hash\n [task_id, name, rate, charge_type, estimate_minutes, project_id, total_minutes, total_amount, minutes_invoiced, minutes_to_be_invoiced, fixed_minutes, non_chargeable_minutes, amount_to_be_invoiced, amount_invoiced, status].hash\n end", "def index\n @plans = Plan.all\n end", "def index\n @plans = Plan.all\n end", "def index\n authorize Plan\n @plans = Plan.includes(:roles).active(current_user).page(1)\n @organisationally_or_publicly_visible = if current_user.org.is_other?\n []\n else\n Plan.organisationally_or_publicly_visible(current_user).page(1)\n end\n # TODO: Is this still used? We cannot switch this to use the :plan_params\n # strong params because any calls that do not include `plan` in the\n # query string will fail\n @template = Template.find(params[:plan][:template_id]) if params[:plan].present?\n end", "def tasks_info_of_snapshot(cycle)\n _, snapshot, * = history[cycle]\n tasks = snapshot.plan.tasks.to_set\n job_info = {}\n tasks.each do |t|\n if t.kind_of?(Roby::Interface::Job)\n planned_by_graph = snapshot.plan.task_relation_graph_for(Roby::TaskStructure::PlannedBy)\n placeholder_task = planned_by_graph.enum_for(:each_out_neighbour, t).first\n if placeholder_task\n job_info[placeholder_task] = t\n end\n end\n end\n [tasks, job_info]\n end", "def query_plan\n return nil unless @gapi.statistics.query.query_plan\n Array(@gapi.statistics.query.query_plan).map do |stage|\n Stage.from_gapi stage\n end\n end", "def hash\n [created, next_subscription_name, next_subscription_description, product, product_rate_plan, invoicing_type, mappings, pricing_behaviour, dry_run].hash\n end", "def hash\n [id, name, description, start, _end, state, parent_id, aggregate_all_subscriptions_on_account, failed_payment_behaviour].hash\n end", "def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end", "def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end", "def updatable_subscription_plans\n subscription_plans = SubscriptionPlan.where(disabled: false).order(:name)\n\n if current_subscription_plan.present?\n subscription_plans.where('id != ?', current_subscription_plan.id)\n else\n subscription_plans\n end\n end", "def hash\n [id, user_profile_id, pattern_id, created_at, updated_at, activated_at, alert_daily, alert_weekly, alert_monthly, alert_method, alert_single_amount, allow_mccs_atm, allow_mccs_fuel, allow_mccs_public_transport, allow_mccs_car_park, allow_mccs_taxi, allow_mccs_medical, allow_mccs_airplane, allow_mccs_car_rental, allow_mccs_travel, allow_mccs_food, allow_mccs_courier, allow_mccs_car_pound, allow_mccs_car_repairs, allow_mccs_hardware, allow_mccs_advertising, allow_mccs_online_subscription, allow_mccs_misc, allow_mccs_financial, allow_on_monday, allow_on_tuesday, allow_on_wednesday, allow_on_thursday, allow_on_friday, allow_on_saturday, allow_on_sunday, allow_timeframe_from, allow_timeframe_to, assigned_at, color, countries, deprecated_at, disable_at, enabled, expiration_date, free_use, name, online_payment, status, temporary_threshold, temporary_expiration_date, threshold_daily, threshold_weekly, threshold_monthly, token].hash\n end", "def plan_params\n params.require(:plan).permit(:date, :user_id, :situation, :incident_id, :weather, \n :general_safety, :prepared_by, :org_list, :assignment_list, \n :comm_plan, :med_plan, :incident_map, :comm_plan, \n :travel_plan, :date_prepare, :time_prepared, :ops_period,\n :approved_by)\n end", "def status\n \t\t@plan = Plan.find(params[:id])\n authorize @plan\n \t\tif user_signed_in? && @plan.readable_by(current_user.id) then\n\t\t\trespond_to do |format|\n\t\t\t\tformat.json { render json: @plan.status }\n\t\t\tend\n\t\telse\n\t\t\trender(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)\n\t\tend\n\tend", "def cached_facet_options\n # Stash all of the available faceting options into the cache so that its not using up valuable memory each time\n # {\n # :funders=>\n # [:\"170\", {:label=>\"United States Department of Agriculture (usda.gov)\", :nbr_plans=>18, :selected=>false}]\n # ]\n # :institutions=> [\n # [:\"4497\", {:label=>\"São Paulo Research Foundation (fapesp.br)\", :nbr_plans=>313, :selected=>false}]\n # ]\n # :languages=> [\n # [:\"2\", {:label=>\"English (US)\", :nbr_plans=>707, :selected=>false}\n # ],\n # :subjects=> [\n # [:\"6\", {:label=>\"Earth and related environmental sciences\", :nbr_plans=>70, :selected=>false}\n # ]\n # }\n # faceting_options = Rails.cache.fetch('public_plans/faceting_options', expires_in: 24.hours) do\n Rails.cache.fetch('public_plans/faceting_options', expires_in: 12.hours) do\n languages = ::Language.joins('INNER JOIN plans on plans.language_id = languages.id')\n .where('plans.visibility = ?', ::Plan.visibilities[:publicly_visible])\n .order('count(plans.id) DESC, languages.name')\n .group('languages.id, languages.name')\n .pluck('languages.id, languages.name, count(plans.id) as nbr_plans')\n\n funders = ::Org.joins(:funded_plans).includes(:funded_plans)\n .where('plans.visibility = ?', ::Plan.visibilities[:publicly_visible])\n .order('count(plans.id) DESC, orgs.name')\n .group('orgs.id, orgs.name')\n .pluck('orgs.id, orgs.name, count(plans.id) as nbr_plans')\n\n institutions = ::Org.joins(:plans).includes(:plans)\n .where('plans.visibility = ?', ::Plan.visibilities[:publicly_visible])\n .order('count(plans.id) DESC, orgs.name')\n .group('orgs.id, orgs.name')\n .pluck('orgs.id, orgs.name, count(plans.id) as nbr_plans')\n\n subjects = ::ResearchDomain.joins('INNER JOIN plans on plans.research_domain_id = research_domains.id')\n .where('plans.visibility = ?', ::Plan.visibilities[:publicly_visible])\n .order('count(plans.id) DESC, research_domains.label')\n .group('research_domains.id, research_domains.label')\n .pluck('research_domains.id, research_domains.label, count(plans.id) as nbr_plans')\n\n {\n funders: result_to_hash(array: funders),\n institutions: result_to_hash(array: institutions),\n languages: result_to_hash(array: languages),\n subjects: result_to_hash(array: subjects)\n }\n end\n end", "def service_plans\n manager_instance(ServicePlanManager)\n end", "def plans\n [Free, FreePlus, Pro, Growth, ProSpecial, ProComped, ProManaged, EliteSpecial, Elite, Custom0, Custom1, Custom2, Custom3].map(&:name)\n end", "def show\n set_client_profile(@goal)\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n\n @needs = @goal.needs\n end", "def new_plan\n\t plan.clear\n\t plan\n\tend", "def hash\n [router_mode, matrix_id, router_dimension, speed_multiplier, area, speed_multiplier_area, traffic, departure, track, motorway, toll, trailers, weight, weight_per_axle, height, width, length, hazardous_goods, max_walk_distance, approach, snap, strict_restriction, cost_fixed, cost_distance_multiplier, cost_time_multiplier, cost_value_multiplier, cost_waiting_time_multiplier, cost_late_multiplier, start_point_id, end_point_id, capacities, sequence_timewindows, timewindow_id, timewindow, rest_ids, id, coef_setup, additional_setup, coef_service, additional_service, shift_preference, trips, value_matrix_id, duration, distance, maximum_ride_time, maximum_ride_distance, skills, unavailable_work_day_indices, unavailable_work_date, unavailable_index_ranges, unavailable_date_ranges, free_approach, free_return].hash\n end", "def optimal_plan=(plans)\n @plans = plans\n @cost = 0.00\n @plans_name = \"\"\n @features_count = 0\n @plans.each do |plan|\n @cost += plan['cost']\n @plans_name += plan['name'] + \" \"\n @features_count += plan['features'].size\n end\n end", "def plan_params\n params.require(:plan).permit(:title, :body, :is_pending, :team_ids, :plan_status, :user_id, team_ids: [])\n end", "def equality_fields\n [:status, :plan]\n end", "def visibility\n plan = Plan.find(params[:id])\n if plan.present?\n authorize plan\n if plan.visibility_allowed?\n plan.visibility = plan_params[:visibility]\n if plan.save\n deliver_if(recipients: plan.owner_and_coowners,\n key: 'owners_and_coowners.visibility_changed') do |r|\n UserMailer.plan_visibility(r, plan).deliver_now\n end\n redirect_to publish_plan_path(plan), notice: success_message(plan, _('updated'))\n else\n redirect_to publish_plan_path(plan), alert: failure_message(plan, _('update'))\n end\n else\n # rubocop:disable Layout/LineLength\n render status: :forbidden, json: {\n msg: format(_(\"Unable to change the plan's status since it is needed at least %{percentage} percentage responded\"), percentage: Rails.configuration.x.plans.default_percentage_answered)\n }\n # rubocop:enable Layout/LineLength\n end\n else\n render status: :not_found,\n json: { msg: format(_('Unable to find plan id %{plan_id}'),\n plan_id: params[:id]) }\n end\n end", "def plan_params\r\n params.require(:plan).permit(\r\n :title,\r\n :started_at,\r\n :ended_at,\r\n :state,\r\n :remarks,\r\n :project_ids => [],\r\n )\r\n end", "def reset_plan_id\n if (self.program_id == Program.find_by_name('IDPs').id)\n self.hrd_id = nil\n self.fscd_annual_plan_id = nil\n elsif (self.program_id == Program.find_by_name('Relief').id)\n self.fscd_annual_plan_id = nil\n elsif (self.program_id == Program.find_by_name('PSNP').id)\n self.hrd_id = nil\n end\n end", "def state\n {\n current_video_state: {\n start_time: (current_video_poll and current_video_poll.start_time),\n end_time: (current_video_poll and current_video_poll.end_time),\n video_uid: current_video_uid,\n title: current_video.title\n },\n pool_playlist_uid: playlist.playlist_uid,\n standings: (current_video_poll and current_video_poll.standings),\n num_of_users: current_user_sessions.length,\n poll_id: (current_video_poll and current_video_poll.id),\n room_name: self[:name],\n }\n end", "def hash\n [ad_mode_begin, ad_mode_complete, bytes_delivered, engagement_score, play_rate, play_request, video, duration, video_engagement_1, video_engagement_25, video_engagement_50, video_engagement_75, video_engagement_100, video_impression, name, video_percent_viewed, video_seconds_viewed, video_view].hash\n end", "def get_plan\n\t\t\t@account_plan.map{|k, v| \"#{k}['#{v}']\"}.join(' ')\n\t\tend", "def plan_params\n params.require(:plan).permit(:name, :user_id, :description, :id, :starting_year)\n end", "def hash\n [ir, loi, approval_id, calculated_max_price, completes, event_id, id, new_estimated_cost, original_cpi, original_estimated_cost, project_id, quota_group_id, reason, request_new_price, required_completes].hash\n end", "def plan_description\n end", "def hash\n [customer, plan, amount, quantity, test, handle, source, create_customer, plan_version, amount_incl_vat, generate_handle, start_date, end_date, grace_duration, no_trial, no_setup_fee, subscription_discounts, coupon_codes, add_ons, additional_costs, signup_method, conditional_create].hash\n end", "def all_p_bam\n plan = Plan.select('id, name').where('plan_type = ? AND item= ?', 'plan', 'bam')\n # Format to show in view\n plans = plan.map { |m| [m.name, m.name] }\n return plans\n end", "def plan\n 0\n end", "def show_stats\n # Using MeetingStat\n @meeting_stat_calculator = MeetingStatCalculator.new(@meeting)\n @meeting_stats = @meeting_stat_calculator.calculate\n\n @preselected_team_id = params[:team_id]\n\n # Get a timestamp for the cache key:\n @max_updated_at = get_timestamp_from_relation_chain() # default: MIR\n end", "def index\n @session_plans = @session_plan_category.session_plans\n end" ]
[ "0.68991256", "0.6014877", "0.59783185", "0.58419055", "0.573575", "0.5673647", "0.5646351", "0.5623643", "0.56008315", "0.5585867", "0.5571968", "0.55279857", "0.54809815", "0.5456194", "0.5420065", "0.54191834", "0.5374252", "0.5368421", "0.53627574", "0.53460735", "0.5338163", "0.53329057", "0.53167593", "0.5313735", "0.5309567", "0.53006023", "0.5262471", "0.5258046", "0.52139693", "0.51913947", "0.5182191", "0.51789737", "0.5178648", "0.5169899", "0.51594263", "0.5137789", "0.5137684", "0.5132618", "0.51205873", "0.51204777", "0.5114729", "0.5112434", "0.51042354", "0.508077", "0.5062843", "0.5049508", "0.50301456", "0.50260514", "0.5016833", "0.49671152", "0.49668476", "0.4958129", "0.49575552", "0.49548587", "0.49497807", "0.4941413", "0.493542", "0.4928723", "0.49203992", "0.4916606", "0.49159992", "0.49145156", "0.49133748", "0.49127635", "0.4908834", "0.4908834", "0.48992512", "0.4896436", "0.48918352", "0.48899058", "0.4885859", "0.4882565", "0.4882565", "0.48761848", "0.48614883", "0.48604846", "0.48509687", "0.4845372", "0.4842143", "0.48409975", "0.4830893", "0.4820245", "0.48200095", "0.48084643", "0.4803107", "0.47929165", "0.47898322", "0.47868913", "0.4781282", "0.47762164", "0.47633845", "0.47606912", "0.47567332", "0.47566214", "0.4752413", "0.47508878", "0.47402638", "0.47402537", "0.47386265", "0.47318992" ]
0.7733827
0
MES A helper to get the current plan status for the indicated plan for this planner.
def plan_status(plan) cur_stat = Plan::STATUS_NO_RELATION existing_plan = self.plans.detect { | item | item.id == plan.id } cur_stat = existing_plan.cal_pln_status if !existing_plan.nil? return cur_stat end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n if (!plan_results || plan_results == [])\n return 'no_tests'\n end\n if (plan_results['state'] == \"Successful\")\n return 'pass'\n end\n if (plan_results['state'] != \"Successful\")\n return 'fail'\n end\n return 'no_tests'\n end", "def plan\n plan_rebuilder.plan\n end", "def status\n @plan = Plan.find(params[:id])\n authorize @plan\n respond_to do |format|\n format.json { render json: @plan.status }\n end\n end", "def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end", "def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end", "def plan\n AcceptOn::Plan.new(@plan)\n end", "def calculate_and_change_status\n return @status.not_a_plan! if !task.basis_plan?\n return @status.singular! if task.singular_basis_matrix?\n return @status.optimal! if task.sufficient_for_optimal?\n return @status.unlimited! if task.positive_z_index == nil # if z <= 0, target function is unlimited\n @status.step_completed!\n end", "def plan\n data['plans'][me]\n end", "def fulfillment_status\n self.current_state\n end", "def status\n \t\t@plan = Plan.find(params[:id])\n authorize @plan\n \t\tif user_signed_in? && @plan.readable_by(current_user.id) then\n\t\t\trespond_to do |format|\n\t\t\t\tformat.json { render json: @plan.status }\n\t\t\tend\n\t\telse\n\t\t\trender(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)\n\t\tend\n\tend", "def display_plan_information(result)\n ui.info ui.color(\"Pre-update resource planning report:\", :bold)\n unless print_plan_result(result, [result.name])\n ui.info \"No resources life cycle changes detected in this update!\"\n end\n if config[:plan_apply]\n return ui.info \"Realizing this stack plan...\"\n elsif config[:plan_only]\n return\n end\n ui.confirm \"Realize this stack plan?\"\n end", "def get_plan_type(plan)\n plan_type_id = plan.plan_type_id\n PlanType.find(plan_type_id).type_name rescue nil\n end", "def plan plan\n plan.myself if respond_to?(:run)\n end", "def status\n if self.started_at.nil? and self.stopped_at.nil?\n 'Pending'\n elsif self.started_at.present? and self.stopped_at.nil?\n 'Active'\n elsif self.started_at.present? and self.stopped_at.present?\n 'Completed'\n end\n end", "def plan_object\n Plan.new plan\n end", "def plan_type\n return 'supporter' if owner.values[:paypal_active] == true\n return 'free' if owner.values[:plan_type].nil?\n return 'supporter' if owner.values[:plan_type].match /^plan_/\n return 'supporter' if owner.values[:plan_type] == 'special'\n owner.values[:plan_type]\n end", "def scheduler_state\n plan.consolidated_scheduler_state\n end", "def plan_information(plan, options = {})\n apps = get_option(options, \"apps\", [])\n stages = get_option(options, \"stages\", [])\n report = []\n plan.plan_stages.each do |stage|\n if stages.empty? || stages.include?(stage.name)\n report << {\"stage\" => stage.name}\n components = []\n requests = stage.requests.include(:apps_requests).where(\"aasm_state IN ('complete, planned')\").order(\"apps_requests.app_id, aasm_state, requests.id DESC\")\n cur_app = \"\"; cur_env = \"\"\n request.each do |request|\n if request.app_name.first != cur_app\n report += components.sort{|a,b| a[\"component\"] <=> b[\"component\"] }\n report << {\"app\" => request.app_name.first, \"environment\" => request.environment.name }\n components = []\n cur_app = request.app_name.first\n end\n request_component_versions(request).each do |comp, ver|\n components << {\"component\" => comp, \"version\" => ver, \"request\" => request.number, \"environment\" => request.environment.name }\n end\n end\n end\n end\n report\nend", "def status\n if index.disert_theme\n @status ||= if index.disert_theme.defense_passed? || index.final_exam_passed?\n ''\n elsif all_subjects_finished?\n I18n::t(:study_plan_completed, :scope => [:model, :plan])\n elsif canceled?\n I18n::t(:study_plan_not_approved, :scope => [:model, :plan])\n elsif approved?\n I18n::t(:study_plan_approved, :scope => [:model, :plan])\n elsif admited?\n I18n::t(:study_plan_admited, :scope => [:model, :plan])\n end\n else\n I18n::t(:missing_disert_theme_title, :scope => [:model, :plan])\n end\n end", "def plan\n 0\n end", "def current_state\n if self.steps.where(state: 'reproved').exists?\n 'reproved'\n elsif self.steps.pluck(:state).uniq == ['approved']\n 'approved'\n else\n 'waiting'\n end\n end", "def plans\n return @plans\n end", "def current_status\n if done?\n failed? ? 'Error' : 'Completed'\n else\n 'Running'\n end\n end", "def plan?(plan)\n return items.any? { |item| item.stripe_plan == plan } if multiple_plans?\n\n stripe_plan == plan\n end", "def status\n\t\treturn \"Pending\" if !completed\n\t\t\"Completed\"\n\tend", "def plan?\n now = Time.zone.now\n\n have_discounts = clients_plans.with_discounts\n !have_discounts.empty? && have_discounts.any? do |plan|\n now < plan.expired_date\n end\n end", "def status\n STATUSES[self.status_id]\n end", "def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end", "def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end", "def current_status\n return status if [:finished, :failed].include? status\n if address&.start_with?(\"0x\")\n state = HacksContract::Hackathon.new(address).state\n s = case state\n when 0\n :preparation\n when 1\n :crow_funding\n when 2\n :apply_participation\n when 3\n :gaming\n when 4\n :voting\n when 5\n :finished\n else\n :failed\n end\n else\n current = Time.now\n s = if current < crow_funding_start_at\n :preparation\n elsif current < apply_start_at\n :crow_funding\n elsif current < game_start_at\n :apply_participation\n elsif current < vote_start_at\n :gaming\n elsif current < finished_at\n :voting\n else\n :finished\n end\n end\n\n if s != status\n update_column(:status, s)\n end\n s\n end", "def plans?\n true\n end", "def roby_plan\n roby_app.plan\n end", "def service_plan_name\n return @service_plan_name\n end", "def query_plan\n return nil unless @gapi.statistics.query.query_plan\n Array(@gapi.statistics.query.query_plan).map do |stage|\n Stage.from_gapi stage\n end\n end", "def plan_name\n if @plan_name.nil?\n jmeter_document do |doc|\n test_plan = doc.xpath('//TestPlan').first\n @plan_name = test_plan['testname']\n end\n if @plan_name.blank? || (@plan_name == 'Test Plan')\n @plan_name = self.test_plan_name\n end\n end\n\n @plan_name\n end", "def activity_name\n plan.activity.name\n end", "def get_status\n if criteria_type == Constants::CRITERIA_TYPE_PASS_FAIL\n temp_status = status\n else\n temp_status = point.zero? ? Constants::CRITERIA_STATUS_FAILED : Constants::CRITERIA_STATUS_PASSED\n end\n temp_status\n end", "def as_plan\n self\n end", "def get_status\n fetch_status unless status == :completed\n status\n end", "def get_status\n fetch_status unless status == :completed\n status\n end", "def planned?\n return false unless @plan_id != 'none'\n return true\n end", "def current_subscription_plan\n return @current_subscription_plan if @current_subscription_plan\n\n if @current_subscription_plan = current_subscription.try(:subscription_plan)\n @current_subscription_plan = SubscriptionPlanDecorator.decorate(@current_subscription_plan)\n end\n end", "def status\n STATUSES[self.status_id || 0]\n end", "def status\n unless source.nil? or source.empty?\n refresh_status\n else\n self.description = \"Status is currently unavailable\"\n end\n self.description.first\n end", "def get_merchant_status\n\t\tstatus = 'Pending'\n\t\tif self.paid?\n\t\t\tstatus = \"Paid\"\n\t\telsif self.fullfilled?\n\t\t\tstatus = \"Fullfilled\"\n\t\telsif self.cancelled?\n\t\t\tstatus = \"Cancelled\"\n\t\tend\n\t\tstatus\n\tend", "def status\n return :completed if completed?\n return :failed if failed?\n :pending\n end", "def status\n @status\n end", "def status\n @status\n end", "def current_time\n plan_rebuilder.current_time\n end", "def status\r\n if @status == \"paid\"\r\n :completed\r\n elsif @tatus == \"refused\"\r\n :refused\r\n else\r\n :pending_payment\r\n end\r\n end", "def current_art_plan\n @current_art_plan ||= ArtPlan.find_by_id(params[:art_plan_id]) if params[:art_plan_id]\n end", "def tst_plan_name\n defined?(@@test_plan) ? @@test_plan : nil\n end", "def get_status\n return @m_status\n end", "def visibility\n plan = Plan.find(params[:id])\n if plan.present?\n authorize plan\n if plan.visibility_allowed?\n plan.visibility = plan_params[:visibility]\n if plan.save\n deliver_if(recipients: plan.owner_and_coowners,\n key: 'owners_and_coowners.visibility_changed') do |r|\n UserMailer.plan_visibility(r, plan).deliver_now\n end\n redirect_to publish_plan_path(plan), notice: success_message(plan, _('updated'))\n else\n redirect_to publish_plan_path(plan), alert: failure_message(plan, _('update'))\n end\n else\n # rubocop:disable Layout/LineLength\n render status: :forbidden, json: {\n msg: format(_(\"Unable to change the plan's status since it is needed at least %{percentage} percentage responded\"), percentage: Rails.configuration.x.plans.default_percentage_answered)\n }\n # rubocop:enable Layout/LineLength\n end\n else\n render status: :not_found,\n json: { msg: format(_('Unable to find plan id %{plan_id}'),\n plan_id: params[:id]) }\n end\n end", "def plan\n @plan ||= Plan.new(stripe_plan_id: stripe_plan_id)\n end", "def equality_fields\n [:status, :plan]\n end", "def status\n return :cancelled if cancelled?\n return :closed if closed?\n return :active if active?\n\n # If the establishment is not active, closed, or cancelled it is pending\n :pending\n end", "def account_plans\n @account_plans_manager\n end", "def current_status\n status ? 'Active' : 'Inactive'\n end", "def viewed_plan(pln)\r\n #MES- Is the plan on the planner?\r\n if plans.include?(pln)\r\n plans.update_attributes(pln, :viewed_at => Time.now_utc)\r\n end\r\n end", "def plan_type\n plan_type_config = facility.plan_type.to_s.downcase.gsub(' ', '_')\n if plan_type_config == 'payer_specific_only'\n output_plan_type = payer.plan_type.to_s if payer\n output_plan_type = 'ZZ' if output_plan_type.blank?\n else\n if eob.claim_information && !eob.claim_information.claim_type.blank?\n output_plan_type = eob.claim_information.plan_type\n elsif eob.claim_information.blank? && eob.claim_type == \"Secondary\"\n output_plan_type = \"CI\"\n else\n output_plan_type = eob.plan_type\n end\n end\n output_plan_type\n end", "def get_plan(id)\n plan = {name: \"Información no se encuentra en la Base de Datos\"}\n plan = Plan.find(id) unless id.empty?\n return plan\n end", "def status\n instance_get(:status)\n end", "def status\n if @object.deadpooled_on\n 'deadpooled'\n elsif @object.acquired_by.any?\n 'acquired'\n elsif @object.initial_public_offering.present?\n 'IPOed'\n else\n 'alive'\n end\n end", "def get_current_state\n execute(:get_vm_status, VmId: vm_id)\n end", "def plan; connection_space.plan end", "def plan( &block )\n nested_class( 'Plan', Yacl::Define::Plan, &block )\n end", "def getStatus\n @status\n end", "def status\n @status\n end", "def status\n @status\n end", "def read_service_plans()\n @client.service_plans\n end", "def get_status\n\t\tstatus\n\tend", "def getStatus\r\n\t\t\t\t\treturn @status\r\n\t\t\t\tend", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status\n return @status\n end", "def status(user)\n if rest_day # Rest day if flag is set\n :rest\n else \n cw = CompletedWorkout.get(user, self)\n if cw\n if cw.mgr_override # Excused if there is a manager override\n :excused \n else\n :completed # Completed normally without mgr override\n end\n else\n if active?(user)\n :open\n else\n :expired\n end\n end\n end\n \n end", "def status\n if waiting?\n :waiting\n elsif running?\n :running\n elsif done?\n :done\n end\n end", "def plans\n @plans ||= spinner('Loading plans') { Loader.load_all configuration.plan_files }\n end" ]
[ "0.67702335", "0.6701635", "0.65720326", "0.65377736", "0.65377736", "0.64744776", "0.6295177", "0.62819177", "0.6191641", "0.61736345", "0.61341655", "0.6117844", "0.60947067", "0.6046385", "0.6028999", "0.6019969", "0.6000083", "0.5995394", "0.5987751", "0.5960768", "0.5947026", "0.59369767", "0.591333", "0.5893746", "0.588742", "0.58860046", "0.5881643", "0.58783096", "0.58783096", "0.5877161", "0.58726674", "0.5860885", "0.5846032", "0.5825709", "0.5823715", "0.5818598", "0.58157384", "0.57886636", "0.5769438", "0.5769438", "0.5748323", "0.5734418", "0.57264215", "0.5726217", "0.57261497", "0.57248926", "0.57088196", "0.57088196", "0.5704382", "0.5694675", "0.5689045", "0.568518", "0.56802857", "0.5679911", "0.56685495", "0.5665118", "0.565917", "0.5654649", "0.5647715", "0.56445074", "0.5619703", "0.5608128", "0.56000054", "0.5597468", "0.5595867", "0.55942863", "0.55921453", "0.5591271", "0.55852205", "0.55852205", "0.5578442", "0.5578189", "0.55683666", "0.5562244", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5562215", "0.5561152", "0.5555595", "0.5551921" ]
0.84197336
0
MES A helper that creates a PlanChange object for a change in RSVP status
def create_plan_change_helper(user, plan, initial_status, final_status, comment = nil) #MES- Record a PlanChange object pc = PlanChange.new #MGS- set the comment on the plan change, unless the comment is blank pc.comment = comment unless comment.blank? pc.rsvp_changed(user, initial_status, final_status) pc.save plan.plan_changes << pc return pc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_plan(plan)\n PsegRecurring::Plan.new(@credentials).send_plan(plan)\n end", "def plan_object\n Plan.new plan\n end", "def test_change_plan\n response=@root_key_api.change_plan(\"[email protected]\",\"password\",@account_id, \"Bronze\")\n \n response=@root_key_api.describe_plan(\"[email protected]\",\"password\",@account_id)\n assert_include response, 'type'\n assert_equal 'Bronze', response['type']\n\n response=@root_key_api.change_plan(\"[email protected]\",\"password\",@account_id, \"Free\")\n end", "def create\n @user = @current_user\n @title = 'Home ('+ Time.now.to_date.to_s + ')'\n @current_event, @events = Event.find_todays_events(@user)\n @plans = @user.plans\n\n\n unless params[:plan]['deadline(3i)'].blank? and\n params[:plan]['deadline(2i)'].blank? \n\n if params[:plan]['deadline(2i)'].blank? \n params[:plan]['deadline(2i)'] = Time.now.month.to_s\n end\n\n if params[:plan]['deadline(3i)'].blank? \n params[:plan]['deadline(3i)'] = '1'\n end\n\n if params[:plan]['deadline(2i)'].to_i < Time.now.month or \n (params[:plan]['deadline(2i)'].to_i == Time.now.month and \n params[:plan]['deadline(3i)'].to_i < Time.now.day)\n params[:plan]['deadline(1i)'] = Time.now.year.next.to_s\n else\n params[:plan]['deadline(1i)'] = Time.now.year.to_s\n end\n end\n\n @new_plan = Plan.new(params[:plan])\n @new_plan.user = @user\n\n unless params[:plan][:recurs] == 'recurs' \n if params[:plan][:recurs] == 'daily' \n @new_plan.recurs = Plan::RECURS[:daily] \n elsif params[:plan][:recurs] == 'weekly' \n @new_plan.recurs = Plan::RECURS[:weekly] \n elsif params[:plan][:recurs] == 'monthly' \n @new_plan.recurs = Plan::RECURS[:monthly] \n end\n else \n @new_plan.recurs = Plan::RECURS[:none] \n end \n\n unless params[:plan].blank? or params[:plan][:parent].blank?\n @new_plan.parent = @current_user.plans.find(params[:plan][:parent])\n end\n\n respond_to do |format|\n if @new_plan.save\n flash[:notice] = 'Plan was successfully created.'\n format.html { redirect_to(events_path()) }\n format.xml { render :xml => @new_plan, :status => :created,\n :location => @new_plan }\n else\n format.html { render :template=>\"events/index\" }\n format.xml { render :xml => @new_plan.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n @plan = Plan.new(params[:plan])\n @plan['name'] = params[:name]\n if (params[:plandate].blank?)\n @plan['plandate'] = Date.today\n else\n @plan['plandate'] = params[:plandate]\n end\n\n @plan.save\n\n @invite = Invite.new\n @invite.plan = @plan\n @invite['user_id'] = params[:userid]\n\n @invite.save\n\n UserMailer.plan_created(@plan, @user).deliver\n\n end", "def test_change_plan_with_latest_policy\n upload_catalog('Catalog-v1.xml', false, @user, @options)\n\n # basic-bimestrial has a trial period\n bp = create_basic_entitlement(1, 'BIMESTRIAL', '2013-08-01', nil, 0)\n\n # Move clock to 2013-08-31\n add_days_and_check_invoice_item(30, 2, 'basic-bimestrial', '2013-08-31', '2013-10-31', 1000.0)\n\n # Move clock to 2013-10-01\n kb_clock_add_days(31, nil, @options)\n\n # Effective date of the second catalog is 2013-10-01\n # Because of limitations of how effectiveDateForExistingSubscriptions is used, we need to upload this intermediate catalog:\n # if we were to upload v4 right away, the change plan would fail (unable to find basic-annual)\n upload_catalog('Catalog-v3.xml', false, @user, @options)\n\n # Move clock to 2013-10-31\n add_days_and_check_invoice_item(30, 3, 'basic-bimestrial', '2013-10-31', '2013-12-31', 1000.0)\n\n # Move clock to 2013-11-01\n kb_clock_add_days(1, nil, @options)\n\n # Effective date of the fourth catalog is 2013-11-01\n upload_catalog('Catalog-v4.xml', false, @user, @options)\n\n add_days(1)\n\n # Verify new CHANGE_OF_PLAN change alignment\n # Because the basic-annual has a 30 days trial, and because of the policy (CHANGE_PLAN) we invoice for a $0 trial\n # and therefore create a pro-ration credit for the part 2013-11-02 -> 2013-12-31\n change_base_entitlement(bp, 4, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-02', nil, 0, -967.21)\n end", "def create_invoice\n invoice_data = {\n payplan_id: self.payplan.id, \n payertype: \"fiz\", \n paymenttype: \"creditcard\", \n service_handle: self.payplan.service_handle \n }\n if self.status\n if self.payplan_id == Payplan.favorite_free_id\n invoice = Invoice.create(invoice_data.merge!(status: \"Оплачен\"))\n payment = invoice.get_payment.update(paymentdate: Date.today, status: \"Оплачен\")\n else\n invoice = Invoice.create(invoice_data)\n end\n end\nend", "def purchase(plan)\n # the purchased plan is going to expire depending on the plan specifications\n # so for example:\n # DateTime.now => Thu, 12 Mar 2015 21:17:33 -0500\n # plan => {\n # :currency => \"COP\",\n # :deleted_at => nil,\n # :description => \"15% de ahorro\",\n # :expired_rate => 1,\n # :expired_time => \"month\",\n # :name => \"Hurry Up!\",\n # :num_of_discounts => 15,\n # :price => 127500,\n # :status => true\n # }\n # the purchased_plan.expired_date = Thu, 12 Apr 2015 21:17:33 -0500\n # 1 month after today\n ClientsPlan.new(\n plan_id: plan.id,\n client_id: id, # self.id\n expired_date: Time.zone.now + plan.expired_rate.send(plan.expired_time),\n num_of_discounts_left: plan.num_of_discounts\n ).tap do |clients_plan|\n yield clients_plan if block_given?\n clients_plan.save\n end\n end", "def change_plan\n if @account.active == 1\n # Find a plan,\n old_plan = PlanCC.find_by_i_plan(@account.i_plan)\n new_plan = PlanCC.find_by_i_plan(params[:plan])\n\n if !params[:type].blank?\n type = params[:type].to_s\n\n if !params[:year].blank?\n year = params[:year].to_i\n else\n flash[:error_card] = 'Incorrect parameters when changing the plan'\n redirect_to :controller => 'subs'\n end\n\n if type == \"new\"\n year = year == 1 ? true : false\n elsif type == \"change\"\n year = @account.i_bilcircle == 0 ? true : false\n else\n flash[:error_card] = 'Incorrect parameters when changing the plan'\n redirect_to :controller => 'subs' and return false\n end\n else\n flash[:error_card] = 'Incorrect parameters when changing the plan'\n redirect_to :controller => 'subs' and return false\n end\n\n # Calculate price of new plan\n @new_price = year ? calculate_discount_plan_cost(new_plan.i_plan) : new_plan.price\n @old_price = @account.i_bilcircle == 0 ? old_plan.price : calculate_discount_plan_cost(old_plan.i_plan)\n\n # Find a credit card\n @credit_card = CreditCard.find_by_i_cc(@account.i_cc)\n\n # Change plan\n #if @new_price > @old_price\n if year\n sum = @new_price - @account.credit\n\n if sum > 0\n # Make a payment\n payment_result = authorize_net_purchase(sum)\n\n # Generate user message\n if @response_code.to_i == 1 && @response_reason_code.to_i == 1\n user_message = \"Plan changed\"\n else\n user_message = get_user_message(@response_code, @response_reason_code)\n end\n\n if payment_result\n # Update account\n @account.endtime = (12.months).since(Time.now)\n @account.credit = 0\n @account.i_plan = new_plan.i_plan\n @account.i_bilcircle = BillingCircle.find(:first, :conditions => \"bilcircle = 12\").i_bilcircle\n @account.save\n\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :amount => sum,\n :type => \"payment_received\",\n :plan => old_plan.i_plan,\n :new_plan => new_plan.i_plan,\n :transaction_id => @authorize_transaction_id,\n :user_message => user_message,\n :gw_string => @authorize_gateway,\n :ip => request.remote_ip.to_s,\n :authorization_code => @authorize_code)\n\n flash[:notice] = 'Plan changed'\n else\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :amount => sum,\n :type => \"payment_failed\",\n :plan => old_plan.i_plan,\n :new_plan => new_plan.i_plan,\n :user_message => user_message,\n :transaction_id => @authorize_transaction_id,\n :gw_string => @authorize_gateway,\n :ip => request.remote_ip.to_s,\n :authorization_code => @authorize_code)\n\n flash[:error_card] = 'Payment failed'\n\n redirect_to :controller => 'subs' and return false\n end\n else\n @account.credit = @account.credit - @new_price\n @account.i_bilcircle = BillingCircle.find(:first, :conditions => \"bilcircle = 12\").i_bilcircle\n @account.i_plan = new_plan.i_plan\n @account.save\n\n # Add transaction\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :type => \"plan_changed\",\n :amount => @new_price,\n :plan => old_plan.i_plan,\n :new_plan => new_plan.i_plan,\n :user_message => \"Plan changed\",\n :new_plan => new_plan.i_plan,\n :ip => request.remote_ip.to_s)\n end\n else\n # Add credit\n credit = 0 - ((@new_price-@old_price).to_f/30*(30-Time.now.day).abs)\n credit = 0 if credit > 0\n\n @account.credit = @account.credit + credit\n @account.endtime = (1.months).since(Time.now)\n @account.i_bilcircle = 0\n @account.i_plan = new_plan.i_plan\n @account.save\n\n # Add transaction\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :type => \"plan_changed\",\n :amount => credit,\n :plan => old_plan.i_plan,\n :new_plan => new_plan.i_plan,\n :user_message => \"Plan changed\",\n :new_plan => new_plan.i_plan,\n :ip => request.remote_ip.to_s)\n end\n\n # Send Email\n Mailer.deliver_payment_success\n\n flash[:notice] = \"Plan changed\"\n #end\n end\n\n redirect_to :controller => 'subs'\n end", "def check_status_change\n if self.status_id != @current_status\n sc = StatusChange.new\n sc.submission_id = self.id\n sc.status_id = self.status_id\n sc.changed_at = @current_time\n sc.comments = status_comments\n sc.save\n #give sub a global id if approved\n if self.status.eq?('approved')\n self.guid = generate_guid(@current_time)\n end\n end\n end", "def test_add_plan\n upload_catalog('Catalog-v1.xml', false, @user, @options)\n\n # basic-monthly has no trial period\n bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-09-01', 1000.0)\n\n # Move clock to 2013-09-01\n add_days_and_check_invoice_item(31, 2, 'basic-monthly', '2013-09-01', '2013-10-01', 1000.0)\n\n # Effective date of the second catalog is 2013-10-01\n upload_catalog('Catalog-v3.xml', false, @user, @options)\n\n # Move clock to 2013-10-01\n # Original subscription is grandfathered (no effectiveDateForExistingSubscriptions specified)\n add_days_and_check_invoice_item(30, 3, 'basic-monthly', '2013-10-01', '2013-11-01', 1000.0)\n\n # The annual plan is only present in the v3 catalog\n create_basic_entitlement(4, 'ANNUAL', '2013-10-01', nil, 0)\n\n # Move clock to 2013-10-31 (BCD = 1)\n add_days_and_check_invoice_item(30, 5, 'basic-annual', '2013-10-31', '2014-10-01', 12_849.32)\n\n # Move clock to 2013-11-01\n # Verify original subscription is still grandfathered\n add_days_and_check_invoice_item(1, 6, 'basic-monthly', '2013-11-01', '2013-12-01', 1000.0)\n\n # Verify we can change to the new plan\n change_base_entitlement(bp, 7, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-01', '2014-11-01', 14_000, 13_000)\n end", "def create\n @plan = Plan.new(plan_params)\n @case = @plan.case\n respond_to do |format|\n if @plan.save\n set_link_to_appointment(@plan)\n format.html { redirect_to back_index_case_url, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan\n @plan ||= Plan.new(stripe_plan_id: stripe_plan_id)\n end", "def create\n @plan = Plan.new(params[:plan])\n @plan.transaction_fee_percent = TRANSACTION_FEE_PERCENT\n @plan.transaction_fee_flat = TRANSACTION_FEE_FLAT\n @plan.artist_id = session[:artist_id] \n\n respond_to do |format|\n if @plan.save\n\n Stripe::Plan.create( :amount => \"#{(@plan.price * 100).to_i}\", :interval => 'month', :name => \"#{@plan.artist.name} - #{@plan.name}\", :currency => 'usd', :id => \"#{@plan.id}\" )\n \n format.html { redirect_to(artist_profile_url(@plan.artist), :notice => 'Pledge level was successfully created.') }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def business_plan\n end", "def bill_plan_change(contract, period)\n if contract.never_billed?\n bill_plan_change_for_unbilled_contract(contract, period)\n else\n bill_plan_change_for_billed_contract(contract, period)\n end\n end", "def upgrade_plan_from_admin(plan_id, renewal_date, fin_year)\n new_plan = Plan.find_by_id(plan_id.to_i)\n transaction do\n subscription_history = SubscriptionHistory.create!(\n :company_id => self.company_id,\n :plan_id => self.plan_id,\n :start_date => self.start_date,\n :end_date => self.end_date,\n :renewal_date => self.renewal_date,\n :first_subscription_date => self.first_subscription_date,\n :ip_address => self.ip_address,\n :amount => self.amount,\n :allocated_storage_mb => self.allocated_storage_mb,\n :allocated_user_count => self.allocated_user_count\n )\n\n user_count = self.allocated_user_count - self.plan.user_count + new_plan.user_count\n self.update_attributes!(\n :plan_id => new_plan.id,\n :renewal_date => renewal_date,\n :end_date => renewal_date,\n :allocated_user_count => user_count\n )\n\n if Subscription.find(self.id).plan.is_inventoriable? && self.company.warehouses.blank?\n Warehouse.create_default_warehouse(self.company_id, self.company.users.first.id)\n end\n if Subscription.find(self.id).plan.payroll_enabled? && self.company.leave_types.blank?\n LeaveType.create_default_leave_types(self.company_id, self.company.users.first.id)\n end\n\n if Subscription.find(self.id).plan.payroll_enabled? && self.company.holidays.blank?\n year = (Time.zone.now.to_date.month.to_i < fin_year.start_date.month ? fin_year.end_date.year : fin_year.start_date.year )\n holiday_date1 = Date.new(year.to_i, 1, 26)\n holiday_date2 = Date.new(year.to_i, 8, 15)\n holiday_date3 = Date.new(year.to_i, 10, 02)\n holiday = Holiday.create(:company_id => self.company_id, :created_by => self.company.users.first.id, :holiday=> \"Republic day\", :holiday_date => holiday_date1, :description =>\"Republic day of India\")\n holiday = Holiday.create(:company_id => self.company_id, :created_by => self.company.users.first.id, :holiday=> \"Independance Day\", :holiday_date => holiday_date2, :description =>\"Independance day of India\")\n holiday = Holiday.create(:company_id => self.company_id, :created_by => self.company.users.first.id, :holiday=> \"Mahatma Gandhi Jayanti\", :holiday_date => holiday_date3, :description =>\"Gandhi Jayanti celebrated in India to mark the occasion of the birthday of Mahatma Gandhi.\")\n\n end\n\n if Subscription.find(self.id).plan.payroll_enabled? && self.company.payheads.blank?\n accounts = Account.where(:name => [\"Basic\",\"House Rent Allowance\", \"Dearness Allowance\", \"Travelling Allowance\", \"Bonus\"], :company_id => self.company_id)\n if accounts.blank?\n # Account.create_default_accounts(self.company_id, self.company.users.first.id)\n end\n Payhead.create_default_payheads(self.company_id, self.company.users.first.id)\n end\n if !Subscription.find(self.id).plan.free_plan? && self.company.custom_fields.blank?\n CustomField.create_default_record(self.company_id)\n end\n logger.debug \"After subscription attributes\"\n #update users enrolled with appropriate roles in new plans\n if subscription_history.plan_id != self.plan_id\n self.company.users.each do |user|\n # user.roles[0] = new_plan.roles.find_by_name(user.roles[0].name)\n\t\t\t\t\t# user.save\n # logger.debug \"Updated roles\"\n new_role = new_plan.roles.find_by_name(user.roles[0].name)\n assignment = Assignment.find_by_user_id(user.id)\n assignment.update_attribute(:role_id, new_role.id)\n end\n end\n end\n end", "def test_assign_next_plan_upgrade\n subscription = Factory(:paid_subscription, :next_subscription_plan => @paid_plan)\n\n assert_equal @paid_plan, subscription.next_plan\n\n subscription.assign_next_plan\n\n assert_equal @paid_plan.id, subscription.subscription_plan_id\n assert_equal @paid_plan, subscription.subscription_plan(true)\n end", "def plan\n AcceptOn::Plan.new(@plan)\n end", "def assign_plan\n self.plan_id = Plan.find_by_name('Free').id\n end", "def offer_contract(startup, invested_amt, investment_type)\n new_funding_round = FundingRound.new(startup, self, investment_type, invested_amt) \nend", "def change_plan_internal(new_plan)\n if result = super\n user_account.push_web_hooks_later(:event => \"plan_changed\")\n result\n end\n end", "def generate_reactivation_transaction\n\n payment_method = params[:mp]\n company = Company.find(current_user.company_id)\n\n downgradeLog = DowngradeLog.where(company_id: company.id).order('created_at desc').first\n\n new_plan = downgradeLog.plan\n\n #Should have free plan\n previous_plan = company.plan\n\n if new_plan.custom\n price = new_plan.plan_countries.find_by(country_id: company.country.id).price\n else\n price = new_plan.plan_countries.find_by(country_id: company.country.id).price company.computed_multiplier\n end\n\n sales_tax = company.country.sales_tax\n\n day_number = Time.now.day\n month_number = Time.now.month\n month_days = Time.now.days_in_month\n\n plan_month_value = ((month_days - day_number + 1).to_f / month_days.to_f) * price\n due_amount = downgradeLog.debt\n\n accepted_payments = [\"16\",\"03\",\"04\",\"05\",\"06\",\"07\"]\n\n if accepted_payments.include?(payment_method) && company\n mockCompany = Company.find(current_user.company_id)\n mockCompany.plan_id = new_plan.id\n mockCompany.months_active_left = 1.0\n mockCompany.due_amount = 0.0\n mockCompany.due_date = nil\n\n if !mockCompany.valid?\n redirect_to select_plan_path, notice: \"No se pudo completar la operación ya que hubo un error en la solicitud de pago. Por favor escríbenos a [email protected] si el problema persiste. (9)\"\n else\n\n trx_comp = company.id.to_s + \"0\" + new_plan.id.to_s + \"0\"\n trx_offset = 4\n trx_date = DateTime.now.to_s.gsub(/[-:T]/i, '')\n trx_date = trx_date[0, trx_date.size - trx_offset]\n trx_date = trx_date[trx_date.size - 15 + trx_comp.size, trx_date.size]\n trx_id = trx_comp + trx_date\n\n if trx_id.size > 15\n trx_id = trx_id[0, 15]\n end\n\n due = sprintf('%.2f', ((plan_month_value + due_amount /(1 + sales_tax) )*(1 + sales_tax)).round(0))\n req = PuntoPagos::Request.new()\n resp = req.create(trx_id, due, payment_method)\n if resp.success?\n PlanLog.create(trx_id: trx_id, new_plan_id: new_plan.id, prev_plan_id: previous_plan.id, company_id: company.id, amount: due)\n PuntoPagosCreation.create(trx_id: trx_id, payment_method: payment_method, amount: due, details: \"Reactivación plan empresa id \"+company.id.to_s+\", nombre \"+company.name+\". Cambia de plan \"+company.plan.name+\"(\"+company.plan.id.to_s+\"), por un costo de \"+due+\". trx_id: \"+trx_id+\" - mp: \"+company.id.to_s+\". Resultado: Se procesa\")\n redirect_to resp.payment_process_url\n else\n PuntoPagosCreation.create(trx_id: trx_id, payment_method: payment_method, amount: due, details: \"Error creación de reactivación de plan empresa id \"+company.id.to_s+\", nombre \"+company.name+\". Cambia de plan \"+company.plan.name+\"(\"+company.plan.id.to_s+\"), por un costo de \"+due+\". trx_id: \"+trx_id+\" - mp: \"+company.id.to_s+\". Resultado: \"+resp.get_error+\".\")\n redirect_to select_plan_path, notice: \"No se pudo completar la operación ya que hubo un error en la solicitud de pago. Por favor escríbenos a [email protected] si el problema persiste. (3)\"\n end\n end\n\n end\n\n end", "def upgrade\n plan_code = params[:plan_code]\n current_subscriber.change_plan_to(plan_code)\n\n flash[:notice] = 'Subscription plan has been changed.'\n render json: { success: true }\n end", "def make_subscription(params = {})\n plan = params.delete(:plan) || 'gold'\n {\n :current_period_end => 1308681468,\n :status => \"trialing\",\n :plan => {\n :interval => \"month\",\n :amount => 7500,\n :trial_period_days => 30,\n :object => \"plan\",\n :identifier => plan\n },\n :current_period_start => 1308595038,\n :start => 1308595038,\n :object => \"subscription\",\n :trial_start => 1308595038,\n :trial_end => 1308681468,\n :customer => \"c_test_customer\",\n :id => 's_test_subscription'\n }.merge(params)\n end", "def plan_params plan\n {\n name: plan.name,\n plan_id: plan.id,\n status: plan.status,\n chargebee_data: {\n price: plan.price,\n period: plan.period,\n period_unit: plan.period_unit,\n trial_period: plan.trial_period,\n trial_period_unit: plan.trial_period_unit,\n charge_model: plan.charge_model,\n free_quantity: plan.free_quantity\n }\n }\n end", "def change_plan!(new_plan)\n changed = change_plan_internal(new_plan) do\n self.save!\n end\n\n changed && self.plan\n end", "def _create_resevation(base, subject, owner)\n\t\t\t\t\t\n\t\t\t\t\t# Create reservation\n\t\t\t\t\treservation = RicReservation.reservation_model.new\n\t\t\t\t\treservation.kind = \"event\"\n\t\t\t\t\treservation.event = self\n\t\t\t\t\treservation.date_from = base\n\t\t\t\t\treservation.date_to = base + (self.date_to - self.date_from).to_i.days\n\t\t\t\t\treservation.time_from = self.time_from\n\t\t\t\t\treservation.time_to = self.time_to\n\n\t\t\t\t\t# Bind subject\n\t\t\t\t\tif !subject.nil?\n\t\t\t\t\t\treservation.size = subject.size\n\t\t\t\t\t\treservation.subject = subject\n\t\t\t\t\telse\n\t\t\t\t\t\treservation.size = self.default_reservation_size\n\t\t\t\t\tend\n\n\t\t\t\t\t# Bind owner\n\t\t\t\t\tif !owner.nil?\n\t\t\t\t\t\treservation.owner_name = owner.name if !owner.name.nil?\n\t\t\t\t\t\treservation.owner = owner if owner.is_a?(ActiveRecord::Base) # In case owner is not ActiveRecord, only name can be stored\n\t\t\t\t\tend\n\n\t\t\t\t\treturn reservation\n\t\t\t\tend", "def create\n @plan = Plan.new(params[:plan])\n @plan.user = current_user\n @plan.request = Request.find( params[:request_id] )\n\n respond_to do |format|\n if @plan.save\n @plan.request.days.times do |day|\n @plan.plan_days << PlanDay.create( { plan_id: @plan.id, day: day+1 } )\n end\n\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render json: @plan, status: :created, location: @plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_reactivation_transaction\n\n payment_method = params[:mp]\n company = Company.find(current_user.company_id)\n\n downgradeLog = DowngradeLog.where(company_id: company.id).order('created_at desc').first\n\n new_plan = downgradeLog.plan\n\n #Should have free plan\n previous_plan = company.plan\n\n if new_plan.custom\n price = new_plan.plan_countries.find_by(country_id: company.country.id).price\n else\n price = new_plan.plan_countries.find_by(country_id: company.country.id).price company.computed_multiplier\n end\n\n sales_tax = company.country.sales_tax\n\n day_number = Time.now.day\n month_number = Time.now.month\n month_days = Time.now.days_in_month\n\n plan_month_value = ((month_days - day_number + 1).to_f / month_days.to_f) * price\n due_amount = downgradeLog.debt\n\n\n if company\n mockCompany = Company.find(current_user.company_id)\n mockCompany.plan_id = new_plan.id\n mockCompany.months_active_left = 1.0\n mockCompany.due_amount = 0.0\n mockCompany.due_date = nil\n\n if !mockCompany.valid?\n redirect_to select_plan_path, notice: \"No se pudo completar la operación ya que hubo un error en la solicitud de pago. Por favor escríbenos a [email protected] si el problema persiste. (9)\"\n else\n\n trx_comp = mockCompany.id.to_s + \"0\" + new_plan.id.to_s + \"0\"\n trx_offset = 4\n trx_date = DateTime.now.to_s.gsub(/[-:T]/i, '')\n trx_date = trx_date[0, trx_date.size - trx_offset]\n trx_date = trx_date[trx_date.size - 15 + trx_comp.size, trx_date.size]\n trx_id = trx_comp + trx_date\n\n if trx_id.size > 15\n trx_id = trx_id[0, 15]\n end\n\n due = sprintf('%.2f', ((plan_month_value + due_amount /(1 + sales_tax) )*(1 + sales_tax)).round(0))\n\n crypt = ActiveSupport::MessageEncryptor.new(Agendapro::Application.config.secret_key_base)\n\n encrypted_data = crypt.encrypt_and_sign({reference: trx_id, description: \"Cambio a plan \" + mockCompany.plan.name, amount: due, source_url: select_plan_path})\n\n\n if encrypted_data\n PlanLog.create(trx_id: trx_id, new_plan_id: new_plan.id, prev_plan_id: previous_plan.id, company_id: mockCompany.id, amount: due)\n PayUCreation.create(trx_id: trx_id, payment_method: '', amount: due, details: \"Creación de reactivación de plan empresa id \"+mockCompany.id.to_s+\", nombre \"+mockCompany.name+\". Cambia de plan \"+mockCompany.plan.name+\"(\"+mockCompany.plan.id.to_s+\"), por un costo de \"+due+\". trx_id: \"+trx_id+\" - mp: \"+mockCompany.id.to_s+\". Resultado: Se procesa\")\n redirect_to action: 'generate_transaction', encrypted_task: encrypted_data\n return\n else\n PayUCreation.create(trx_id: trx_id, payment_method: '', amount: due, details: \"Error creación de cambio de plan empresa id \"+mockCompany.id.to_s+\", nombre \"+mockCompany.name+\". Cambia de plan \"+mockCompany.plan.name+\"(\"+mockCompany.plan.id.to_s+\"), por un costo de \"+due+\". trx_id: \"+trx_id+\" - mp: \"+mockCompany.id.to_s+\". Resultado: \"+resp.get_error+\".\")\n redirect_to select_plan_path, notice: \"No se pudo completar la operación ya que hubo un error en la solicitud de pago. Por favor escríbenos a [email protected] si el problema persiste. (3)\"\n end\n end\n end\n end", "def view\n {\n 'canceled_at' => canceled_at,\n 'plan' => plan,\n 'status' => status,\n }\n end", "def changed\n customer_ref = params[:SubscriptionReferrer]\n plan_ref = params[:ProductPath].sub(\"/\", \"\")\n subscription_ref = params[:SubscriptionReference]\n \n # subscription info\n end_date = params[:SubscriptionEndDate]\n next_period_date = params[:SubscriptionNextPeriodDate]\n status = params[:SubscriptionStatus].downcase.strip\n status_reason = params[:SubscriptionStatusReason]\n total_price = params[:SubscriptionTotalPriceValue]\n currency = params[:SubscriptionTotalPriceCurrency]\n\n user = User.find(customer_ref)\n raise \"Received subscription changed for #{user.id} but they don't have an active subscription\" unless user.subscribed?\n \n subscription = user.active_subscription\n raise \"Received subscription changed for #{user.id} but the active subscription (#{subscription.reference}) doesn't match the notification (#{subscription_ref})\" unless subscription.reference == subscription_ref\n \n plan = Plan.find_by_fastspring_reference(plan_ref)\n raise \"Received subscription changed for #{user.id} but couldn't find a matching plan: #{plan_ref}\" unless plan\n \n # update subscription info, including status\n subscription.update_attributes!(\n status: status.to_s.downcase.strip,\n end_date: end_date,\n next_period_date: next_period_date,\n status_reason: status_reason,\n total_price: total_price,\n currency: currency\n )\n \n # change plan \n user.plan = plan\n user.save!\n \n # de-activate excess channels\n user.deactivate_excess_channels!\n \n render nothing: true, status: 200\n end", "def new\n\tif params[:id].present?\n \t#@bought=BuyPlan.where(user_id: current_user.id).where(status: 1).first\n \t@bought=BuyPlan.find_by user_id: current_user.id\n\t\tchange=\"Z\"\n\n\t\tif @bought.present?\n\t\t\tcase @bought.plan_id\n\t\t\twhen 1\n\t\t\t\tcase params[:id]\n\t\t\t\twhen 1\n\t\t\t\t\tchange=\"N\"\n\t\t\t\twhen 2\n\t\t\t\t\tchange=\"U\"\n\t\t\t\twhen 3\n\t\t\t\t\tchange=\"U\"\n\t\t\t\twhen 4\n\t\t\t\t\tchange=\"U\"\n\t\t\t\tend\n\t\t\twhen 2\n\t\t\t\tcase params[:id]\n\t\t\t\twhen 1\n\t\t\t\t\tchange=\"D\"\n\t\t\t\twhen 2\n\t\t\t\t\tchange=\"N\"\n\t\t\t\twhen 3\n\t\t\t\t\tchange=\"U\"\n\t\t\t\twhen 4\n\t\t\t\t\tchange=\"U\"\n\t\t\t\tend\n\t\t\twhen 3\n\t\t\t\tcase params[:id]\n\t\t\t\twhen 1\n\t\t\t\t\tchange=\"D\"\n\t\t\t\twhen 2\n\t\t\t\t\tchange=\"D\"\n\t\t\t\twhen 3\n\t\t\t\t\tchange=\"N\"\n\t\t\t\twhen 4\n\t\t\t\t\tchange=\"U\"\n\t\t\t\tend\n\t\t\twhen 4\n\t\t\t\tcase params[:id]\n\t\t\t\twhen 1\n\t\t\t\t\tchange=\"D\"\n\t\t\t\twhen 2\n\t\t\t\t\tchange=\"D\"\n\t\t\t\twhen 3\n\t\t\t\t\tchange=\"D\"\n\t\t\t\twhen 4\n\t\t\t\t\tchange=\"N\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tcase change\n\t\twhen \"N\"\n \tredirect_to pages_page0_path, :flash => { :notice => \"You are subscribed\"}\n\t\t\treturn\n\t\twhen \"D\"\n\t\t\tredirect_to pages_page0_path, :flash => { :notice => \"We will make change after current period.\" }\n\t\t\treturn\n \telse\n\t\t\tif current_user.stripe_id.present?\n\t\t\t\t@card=Stripe::Customer.retrieve(current_user.stripe_id)\n\t\t\tend\n\t\t\t@plan=Plan.find(params[:id])\n \tend\n\telse\n\t\tredirect_to pages_products_path, :flash => { :notice => \"plan not found\" }\n\tend\n\trescue ActiveRecord::RecordNotFound => e\n\t\tredirect_to pages_products_path, :flash => { :notice => \"plan not found\" }\n end", "def new_plan(name, puppet: false)\n Bolt::PlanCreator.validate_input(config.project, name)\n Bolt::PlanCreator.create_plan(config.project.plans_path, name, puppet)\n end", "def renewal_plan\n if @enrollment.coverage_kind == 'dental'\n renewal_plan = @enrollment.plan.renewal_plan_id\n else\n if has_catastrophic_plan? && is_cat_plan_ineligible?\n renewal_plan = @enrollment.plan.cat_age_off_renewal_plan_id\n if renewal_plan.blank?\n raise \"#{renewal_coverage_start.year} Catastrophic age off plan missing on HIOS id #{@enrollment.plan.hios_id}\"\n end\n else\n if @enrollment.plan.csr_variant_id == '01' || has_catastrophic_plan?\n renewal_plan = @enrollment.plan.renewal_plan_id\n else\n renewal_plan = Plan.where({\n :active_year => renewal_coverage_start.year, \n :hios_id => \"#{@enrollment.plan.renewal_plan.hios_base_id}-01\"\n }).first.id\n end\n end\n end\n\n if renewal_plan.blank?\n raise \"#{renewal_coverage_start.year} renewal plan missing on HIOS id #{@enrollment.plan.hios_id}\"\n end\n \n renewal_plan\n end", "def equality_fields\n [:status, :plan]\n end", "def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end", "def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end", "def test_next_plan_upgrade\n subscription = Factory(:paid_subscription, :next_subscription_plan => @paid_plan)\n assert subscription.renewable?\n tran = subscription.renew!\n assert_not_nil tran\n assert_equal @paid_plan, subscription.reload.subscription_plan\n end", "def status_change\n petition = Petition.where(status: 'live').first\n PetitionMailer.status_change_mail(Petition.live.first)\n end", "def update_to_video_calendar_invite(virtual_hearing, email_recipient_info)\n create_calendar_event(virtual_hearing.hearing) do |event, time_zone, start_time|\n if email_recipient_info.title == HearingEmailRecipient::RECIPIENT_TITLES[:judge]\n # For judges, just cancel the original invitation.\n event.status = \"CANCELLED\"\n else\n template_context = {\n virtual_hearing: virtual_hearing,\n time_zone: time_zone,\n start_time_utc: start_time\n }\n\n event.status = \"CONFIRMED\"\n event.summary = summary(email_recipient_info)\n event.description = render_virtual_hearing_calendar_event_template(\n email_recipient_info, :changed_to_video, template_context\n )\n end\n end\n end", "def change_plan_internal(new_plan, &block)\n return if self.plan == new_plan || new_plan.nil?\n raise 'change_plan_internal must be called with a block' unless block_given?\n\n transaction do\n\n\n\n # workaround - remove with Rails 3\n @old_plan = self.plan\n\n self.plan = new_plan\n # TODO: change to notify_observers and add old/new params after\n # migration to Rails 3\n\n res = yield\n\n new_plan.reset_contracts_counter\n\n @old_plan.customized? ? @old_plan.destroy : @old_plan.reset_contracts_counter\n\n res\n end\n end", "def create_plan(plan:, params:)\n plan.visibility = if params['visibility'].blank?\n Rails.configuration.x.plans.default_visibility\n else\n plan_params[:visibility]\n end\n\n plan.template = ::Template.find(params[:template_id])\n\n plan.title = if params[:title].blank?\n if current_user.firstname.blank?\n format(_('My Plan (%{title})'), title: plan.template.title)\n else\n format(_('%{user_name} Plan'), user_name: \"#{current_user.firstname}'s\")\n end\n else\n params[:title]\n end\n\n plan.org = process_org!(user: current_user)\n # If the user said there was no research org, use their org since Plan requires one\n plan.org = current_user.org if plan.org.blank?\n plan.funder = process_org!(user: current_user, namespace: 'funder')\n\n plan.title = plan.title.strip\n\n return unless plan.save\n\n # pre-select org's guidance and the default org's guidance\n ids = (::Org.default_orgs.pluck(:id) << plan.org_id).flatten.uniq\n ggs = ::GuidanceGroup.where(org_id: ids, optional_subset: false, published: true)\n\n plan.guidance_groups << ggs unless ggs.empty?\n plan.add_user!(current_user.id, :creator)\n\n # Set new identifier to plan id by default on create.\n # (This may be changed by user.)\n # ================================================\n # Start DMPTool customization\n # We are using this field as a Funding Opportunity Number\n # ================================================\n # @plan.identifier = @plan.id.to_s\n # ================================================\n # End DMPTool customization\n # ================================================\n plan.save\n plan\n end", "def create_activity(object, symbol, old_value, new_value, activity_params)\n object.create_activity \"change_#{symbol}\".to_sym,\n owner: current_user,\n recipient: object,\n parameters: activity_params.merge(old: old_value, new: new_value)\n end", "def create # rubocop:disable Metrics/AbcSize\n attrs = params.require(plan_type).permit(CREATE_PARAMS)\n @plan = collection.build(attrs)\n\n if plan.save\n if block_given?\n yield\n else\n plan.reload\n\n respond_to do |format|\n format.html do\n flash[:notice] = \"Created #{plan.class.model_name.human} #{plan.name}\"\n # collection.build to create new record to properly generate path to index action (rails)\n redirect_to plans_index_path\n end\n end\n end\n\n else\n render :new\n end\n end", "def plan\n plan_rebuilder.plan\n end", "def convert_to_plan(result)\n plan = PLAN_CLASS.new(origin_stack)\n PLAN_MAP.each do |src, dst|\n collection = result[src].map do |name, info|\n item = PLAN_CLASS::Item.new(\n :name => name,\n :type => info[:type],\n )\n unless info[:diffs].empty?\n item.diffs = info[:diffs].map do |d_info|\n diff = PLAN_CLASS::Diff.new(\n :name => d_info.fetch(:property_name, d_info[:path]),\n :current => d_info[:original].to_json,\n :proposed => d_info[:updated].to_json,\n )\n diff.valid_state\n end\n end\n item.valid_state\n end\n plan.send(\"#{dst}=\", collection)\n end\n plan.stacks = Smash[\n result.fetch(:stacks, {}).map { |name, info|\n [name, convert_to_plan(info)]\n }\n ]\n plan.valid_state\n end", "def rev_allocation_change(project, current_user, effective_date)\n @project = project\n @current_user = current_user\n\n # only send notifications to roles that have had a change of percentage.\n roles = []\n @project.team_memberships.each do | tm |\n if tm.previous_changes.has_key? \"percentage\"\n roles << tm.role.name.downcase.gsub(/ /, \"_\").to_sym\n end\n end\n\n tokens = {}\n project.team_memberships.each do |m|\n tokens.store(\"#{m.member.name} (#{m.role.name})\", m.percentage.to_s + \"%\")\n end\n\n tokens.store('Effective Date', effective_date)\n\n tokens['Published'] = 'No'\n\n if @project.project_grid_table_row.production_task_name == \"Production Complete\"\n tokens['Published'] = 'Yes'\n tokens['Publication Date'] = @project.published_file.publication_date unless @project.published_file.nil? || @project.published_file.publication_date.nil?\n end\n\n user_subject = \"Revenue Allocation for #{project.book_title}\"\n admin_subject = \"New Project Revenue Allocation from #{current_user.name} for #{project.book_title}\"\n\n send_email_message('rev_allocation_change', tokens, get_project_recipient_list(@project, roles: roles), user_subject)\n send_email_message('rev_allocation_change_admin', tokens, admin_rev_allocation_change_list, admin_subject)\n end", "def create\n super do |resource| # super do oznacza ze dziedziczymy akcje \"create\" i rozszerzamy ją\n if params[:plan]\n resource.plan_id = params[:plan]\n if resource.plan_id == 2\n resource.save_with_subscription \n else\n resource.save\n end\n end\n end\n end", "def new\n @plan = Plan.new\nend", "def test_set_status\n # in the future\n @absence = Absence.create(:start_time => '1-10-3000 00:00',\n :end_time => '1-10-3000 00:00',\n :reason => 'reason',\n :user_id => User.find_by_admin(true).id,\n :variety => 'Holiday',\n :start_half_day => 'Lunch Time',\n :end_half_day => 'Lunch Time')\n assert_valid @absence\n assert_equal 'Pending', @absence.status\n # in the past\n @absence = Absence.create(:start_time => '1-10-1000 00:00',\n :end_time => '1-10-1000 00:00',\n :reason => 'reason',\n :user_id => User.find_by_admin(true).id,\n :variety => 'Holiday',\n :start_half_day => 'Lunch Time',\n :end_half_day => 'Lunch Time' )\n assert_valid @absence\n assert_equal 'Approved', @absence.status\n end", "def initialize(data={})\n @canceled_at = data.fetch('canceled_at', data.fetch(:canceled_at, nil))\n @plan = data.fetch('plan', data.fetch(:plan, ''))\n @status = data.fetch('status', data.fetch(:status, 'inactive'))\n end", "def create\n @user = @current_user\n @title = 'Todays Events ('+ Time.now.to_date.to_s + ')'\n @current_event, @events = Event.find_todays_events( @user )\n @plans = @user.plans.find(:all, :order=>\"deadline ASC\")\n\n if params[:event]['end_time(4i)'].blank? and \n params[:event]['end_time(5i)'].blank?\n \n params[:event].delete('end_time(1i)') \n params[:event].delete('end_time(2i)') \n params[:event].delete('end_time(3i)') \n params[:event].delete('end_time(4i)') \n params[:event].delete('end_time(5i)') \n \n elsif params[:event]['end_time(4i)'].blank?\n params[:event]['end_time(4i)'] = params[:event]['start_time(4i)']\n elsif params[:event]['end_time(5i)'].blank?\n params[:event]['end_time(5i)'] = params[:event]['start_time(5i)']\n end\n\n @new_event = Event.new(params[:event])\n @new_event.user = @user\n @new_plan = Plan.new()\n\n respond_to do |format|\n if @new_event.save\n flash[:notice] = 'Event was successfully created.'\n if @current_event != nil\n @current_event.end_time = @new_event.start_time \n @current_event.save\n end\n format.html { redirect_to(events_path()) }\n format.xml { render :xml => @new_event, :status => :created, \n :location => @new_event }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @new_event.errors, \n :status => :unprocessable_entity }\n end\n end\n end", "def create\n ActiveRecord::Base.transaction do\n @membership = @member.memberships.build(membership_params)\n @plan = Plan.find(params[:membership][:plan_id])\n coupon = params[:membership][:coupon].present? ? params[:membership][:coupon] : nil\n @trial_period_end = params[:membership][:trial_period_days].present? ? set_trial_period_end_date : 'now'\n\n if params[:membership][:payment_type] == 'Stripe'\n stripe_sub = Stripe::Subscription.create(\n customer: @member.stripe_id,\n trial_end: @trial_period_end,\n coupon: coupon,\n :items => [\n {\n :plan => @plan.stripe_id,\n },\n ]\n )\n\n @membership.stripe_sub_id = stripe_sub.id\n @membership.next_invoice_date = Time.at(stripe_sub.current_period_end).to_datetime\n @membership.start_date = set_start_date\n elsif @plan.stripe_id.present?\n @stripe_plan = Stripe::Plan.retrieve(@plan.stripe_id)\n start_date = set_start_date\n plan_interval = @stripe_plan.interval\n plan_interval_count = @stripe_plan.interval_count\n next_date = case plan_interval\n when 'day'\n start_date + plan_interval_count.days\n when 'week'\n start_date + plan_interval_count.weeks\n when 'month'\n start_date + plan_interval_count.months\n when 'year'\n start_date + plan_interval_count.years\n end\n @membership.next_invoice_date = next_date\n end\n\n respond_to do |format|\n if @membership.save!\n format.html { redirect_to @member, notice: 'Membership was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def plan( &block )\n nested_class( 'Plan', Yacl::Define::Plan, &block )\n end", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n handle == o.handle &&\n customer == o.customer &&\n plan == o.plan &&\n state == o.state &&\n test == o.test &&\n amount == o.amount &&\n quantity == o.quantity &&\n expires == o.expires &&\n reactivated == o.reactivated &&\n timezone == o.timezone &&\n created == o.created &&\n activated == o.activated &&\n renewing == o.renewing &&\n plan_version == o.plan_version &&\n amount_incl_vat == o.amount_incl_vat &&\n start_date == o.start_date &&\n end_date == o.end_date &&\n grace_duration == o.grace_duration &&\n current_period_start == o.current_period_start &&\n next_period_start == o.next_period_start &&\n first_period_start == o.first_period_start &&\n last_period_start == o.last_period_start &&\n trial_start == o.trial_start &&\n trial_end == o.trial_end &&\n is_cancelled == o.is_cancelled &&\n in_trial == o.in_trial &&\n has_started == o.has_started &&\n renewal_count == o.renewal_count &&\n cancelled_date == o.cancelled_date &&\n expired_date == o.expired_date &&\n expire_reason == o.expire_reason &&\n on_hold_date == o.on_hold_date &&\n on_hold_reason == o.on_hold_reason &&\n payment_method_added == o.payment_method_added &&\n scheduled_plan_change == o.scheduled_plan_change &&\n reminder_email_sent == o.reminder_email_sent &&\n failed_invoices == o.failed_invoices &&\n failed_amount == o.failed_amount &&\n cancelled_invoices == o.cancelled_invoices &&\n cancelled_amount == o.cancelled_amount &&\n pending_invoices == o.pending_invoices &&\n pending_amount == o.pending_amount &&\n dunning_invoices == o.dunning_invoices &&\n dunning_amount == o.dunning_amount &&\n settled_invoices == o.settled_invoices &&\n settled_amount == o.settled_amount &&\n refunded_amount == o.refunded_amount &&\n pending_additional_costs == o.pending_additional_costs &&\n pending_additional_cost_amount == o.pending_additional_cost_amount &&\n transferred_additional_costs == o.transferred_additional_costs &&\n transferred_additional_cost_amount == o.transferred_additional_cost_amount &&\n pending_credits == o.pending_credits &&\n pending_credit_amount == o.pending_credit_amount &&\n transferred_credits == o.transferred_credits &&\n transferred_credit_amount == o.transferred_credit_amount &&\n hosted_page_links == o.hosted_page_links &&\n subscription_discounts == o.subscription_discounts &&\n pending_change == o.pending_change &&\n subscription_changes == o.subscription_changes &&\n subscription_add_ons == o.subscription_add_ons\n end", "def purchase_sub_existing\n @first_plan = Plan.find_by_my_plan_id(plan_set_one) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\n @second_plan = Plan.find_by_my_plan_id(plan_set_two)\n @third_plan = Plan.find_by_my_plan_id(plan_set_three)\nend", "def bill_plan_change_for_unbilled_contract(contract, period)\n # We bill the old plan for the previous period\n previous_period = TimeRange.new(contract.paid_until.utc, period.end.utc)\n plan = contract.plan\n old_plan = contract.old_plan\n old_plan_name = old_plan.name\n plan_name = plan.name\n\n add_plan_cost(:bill, contract, old_plan, previous_period)\n info(\"Plan change occurring but billing was not done yet from ('#{old_plan_name}' to '#{plan_name}')\")\n\n # We refund the old plan for the current period and upgrade the new plan\n upgrade_on_plan_change(contract, old_plan, plan, period)\n rescue Plan::PeriodRangeCalculationError\n # Something bad happens calculating the cost\n System::ErrorReporting.report_error(BadPeriodError.new(contract, period, previous_period))\n error(\"Plan change occurring but an error occurred billing the period #{previous_period} for ('#{old_plan_name}' to '#{plan_name}')\")\n # We still bill on upgrade only\n bill_plan_change_for_billed_contract(contract, period)\n end", "def convert_plan(plan)\n pal.convert_plan(plan)\n end", "def bought_plan\n bought_cinstance.plan\n rescue ActiveRecord::RecordNotFound => error\n System::ErrorReporting.report_error(error)\n\n ApplicationPlan.new\n end", "def get_instance(payload)\n RatePlanInstance.new(@version, payload, )\n end", "def plan_status(plan)\r\n cur_stat = Plan::STATUS_NO_RELATION\r\n existing_plan = self.plans.detect { | item | item.id == plan.id }\r\n cur_stat = existing_plan.cal_pln_status if !existing_plan.nil?\r\n return cur_stat\r\n end", "def planer_params\n params.require(:planer).permit(:new_plan, :priority, :date, :status)\n end", "def billing_plan_notification_template\n 'billing_plan_notification'\n end", "def update\n # @employee_plan = EmployeePlan.all\n # @employee_plan = @employee_plan.check_availability(current_user, params[:employee_plan][:from_date], params[:employee_plan][:to_date], params[:employee_plan][:from_time], params[:employee_plan][:to_time])\n # if @employee_plan == true\n # flash[:alert] = 'Sorry..!! This Time was already reserved...'\n # redirect_to employee_plans_url\n # else\n # @employee_plan = EmployeePlan.new(employee_plan_params)\n respond_to do |format|\n if @employee_plan.update(employee_plan_params)\n format.html { redirect_to employee_plans_url, notice: 'Employee plan was successfully created.' }\n format.json { render :show, status: :created, location: @employee_plan }\n else\n format.html { render :new }\n format.json { render json: @employee_plan.errors, status: :unprocessable_entity }\n end\n end\n # end\n end", "def create\n Payjp.api_key = \"sk_test_c62fade9d045b54cd76d7036\"\n @user = user\n\n if customer_id = @user.customer_id\n customer = Payjp::Customer.retrieve(id: customer_id)\n else\n customer = Payjp::Customer.create(card:payjp_token)\n @user.customer_id = customer.id\n @user.save!\n end\n\n plans = customer.subscriptions.data.collect(&:plan).collect(&:id)\n plan_id = \"#{@item.id}_#{@item.interval}\"\n if plans.include?(plan_id)\n plan = Payjp::Plan.retrieve(id: \"#{@item.id}_#{@item.interval}\")\n subscription = customer.subscriptions.data.select{|data| data.plan.id == plan_id}.first\n if subscription\n unless subscription.status == \"active\"\n subscription.resume\n end\n update_role(subscription)\n else\n subscription = Payjp::Subscription.create(customer:customer.id, plan: plan.id)\n update_role(subscription)\n end\n else\n plan = Payjp::Plan.create(id: \"#{@item.id}_#{@item.interval}\", amount: \"#{@item.price}\", interval: \"#{@item.interval}\", currency: \"jpy\")\n subscription = Payjp::Subscription.create(customer:customer.id, plan: plan.id)\n update_role(subscription)\n end\n\n if subscription\n @order = Order.find_or_create_by(subscription: subscription.id)\n @order.item = item\n @order.user = @user\n @order.current_period_end = Time.at(subscription.current_period_end)\n @order.save\n redirect_to @order, notice: 'Order was successfully created.'\n else\n redirect_to new, notice: 'Order was not created.'\n end\n\n end", "def subscription\n @result = ChargeBee::Subscription.retrieve(@subscription_id)\n @billing_address = @result.customer.billing_address\n @country_codes = get_country_codes\n \n @shipping_address = retrieve_shipping_address(@subscription_id)\n @invoice_estimate = nil\n if @result.subscription.status != \"cancelled\" && @result.subscription.status != \"non_renewing\"\n @invoice_estimate = ChargeBee::Estimate.renewal_estimate(@subscription_id, {\"use_existing_balances\" => \"true\"}).estimate.invoice_estimate\n end\n \n @subscription_status = subscription_status()[@result.subscription.status]\n end", "def create_new_plans\n plan_ids = Plan.all.map(&:plan_id)\n cb_plans.reject { |cb_plan| plan_ids.include?(cb_plan.id) }\n .each { |new_plan| puts \"Creating Plan - #{new_plan.id}\"; Plan.create(plan_params(new_plan)) }\n end", "def offer_contract(startup, investment_type, amount_invested)\n FundingRound.new(investment_type, amount_invested, startup, self)\n end", "def new_plan\n\t plan.clear\n\t plan\n\tend", "def initialize()\n super\n @odata_type = \"#microsoft.graph.scheduleChangeRequest\"\n end", "def check_create_status\n if self.v_status.nil?\n status = VStatus.new\n status.v_project = self\n status.v_user_data = self.v_user_data\n self.v_status = status\n end\n end", "def fix_plan_state(plan)\n if plan.execution_plan.state == :planning\n @logger.info(\"Execution plan #{plan.execution_plan_uuid} is expected to be in 'scheduled' state, was '#{plan.execution_plan.state}', auto-fixing\")\n plan.execution_plan.set_state(:scheduled, true)\n plan.execution_plan.save\n end\n end", "def get_plan(id)\n plan = {name: \"Información no se encuentra en la Base de Datos\"}\n plan = Plan.find(id) unless id.empty?\n return plan\n end", "def plan\n super\n @trip.itineraries\n .find_by(trip_type: @outbound_trip_type, service: @outbound_service)\n .try(:select)\n @trip.save\n @trip\n end", "def join_plan \n\t\trequire 'fcm'\n\t\tactivities = [\"grab food\", \"hang out\", \"group study\", \"party\"]\n\t\tplan_member = PlanMember.new(\n \tplan_id: params[:plan_id],\n \tuser_id: current_user.id\n )\n\t\tplan = Plan.find_by(id: params[:plan_id])\n\n\t\tif plan_member.save\n\t\t\tPlanMessage.create(\n \tplan_id: params[:plan_id],\n \tuser_id: current_user.id, \n \tcontent: \"#{current_user.fullname} is in!\",\n \tsystem_message: true\n )\t\n\n member_count = PlanMember.where(plan_id: params[:plan_id]).count\n\t\t\tis_happening = false\n\t if member_count > 2 && plan.is_happening == false\n\t \tis_happening = true\n\t \tplan.is_happening = true\n\t \tplan.save \n\n\t \tPlanMessage.create(\n\t \tplan_id: params[:plan_id],\n\t \tuser_id: current_user.id, \n\t \tcontent: \"Woohoo this plan to #{activities[plan.activity]} is happening! 3 or more people are in.\",\n\t \tsystem_message: true\n\t )\t\n\t end\n\t render json: { is_success: true, is_happening: is_happening, name_of_joiner: current_user.fullname}, status: :ok\n\t\t\n\t\telse\n\t\t\trender json: { is_success: false }, status: :ok\n\t\tend\n\tend", "def create\n @plan = Plan.new(plan_params)\n respond_to do |format|\n if @plan.save\n # expire_fragment(\"plans\")\n expire_action :action => 'index'\n UserMailer.create_plan(current_user, @plan).deliver\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def plan=(plan)\r\n if plan.amount > 0\r\n # Discount the plan with the existing discount (if any)\r\n # if the plan doesn't already have a better discount\r\n plan.discount = discount if discount && discount > plan.discount\r\n # If the assigned plan has a better discount, though, then\r\n # assign the discount to the subscription so it will stick\r\n # through future plan changes\r\n self.discount = plan.discount if plan.discount && plan.discount > discount\r\n else\r\n # Free account from the get-go? No point in having a trial\r\n self.state = 'active' if new_record?\r\n end\r\n\r\n #\r\n # Find any attributes that exist in both the Subscription and SubscriptionPlan\r\n # and that match the pattern of \"something_limit\"\r\n #\r\n limits = self.attributes.keys.select { |k| k =~ /^.+_limit$/ } &\r\n plan.attributes.keys.select { |k| k =~ /^.+_limit$/ }\r\n\r\n (limits + [:amount, :renewal_period]).each do |f|\r\n self.send(\"#{f}=\", plan.send(f))\r\n end\r\n \r\n self.subscription_plan = plan\r\n end", "def converted_schedule\n if !self.read_attribute(:recurring_schedule).empty?\n the_schedule = IceCube::Schedule.new( self.created_at )\n the_rule = RecurringSelect.dirty_hash_to_rule( self.read_attribute(:recurring_schedule) )\n if RecurringSelect.is_valid_rule?(the_rule)\n the_schedule.add_recurrence_rule(the_rule)\n end\n the_schedule\n end\n end", "def statusChange\n BookingMailer.statusChange\n end", "def new\n @account = Account.new\n @account.memberships.build.build_user\n @plans = Plan.all\n end", "def assert_plan_is_new_style!(model:, **)\n flight = model.flights[0]\n if [flight.to.class, flight.from.class].include?(Country)\n raise \"uneditable travel plan\"\n end\n true\n end", "def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end", "def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end", "def schedule\n Reggora::Resources::SchedulePayment.new(config)\n end", "def viewed_plan(pln)\r\n #MES- Is the plan on the planner?\r\n if plans.include?(pln)\r\n plans.update_attributes(pln, :viewed_at => Time.now_utc)\r\n end\r\n end", "def get_rebilling_cycle_status(rebill_id)\n @PARAM_HASH[\"TRANS_TYPE\"] = \"GET\"\n @PARAM_HASH[\"REBILL_ID\"] = rebill_id\n end", "def create\n @plan = Plan.new(params[:plan])\n \n respond_to do |format|\n if @plan.save\n flash[:notice] = \"Plan successfully submitted.\"\n format.html { redirect_to :back }\n format.mobile { redirect_to :back }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_reservation_status(reservation)\n owner = reservation.item_owner\n case reservation.status\n when \"pending_owner\"\n is_current_user?(owner) ? \"awaiting_acceptance_from_you\" : \"awaiting_acceptance_from_other_party\"\n when \"pending_reserver\"\n is_current_user?(owner) ? \"awaiting_acceptance_from_other_party\" : \"awaiting_acceptance_from_you\"\n else\n \"reservation_\" + reservation.status\n end \n end", "def create\n @plan = Plan.create(plan_params)\n @incident = Incident.find(params[:incident_id])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to incident_plan_path(@incident, @plan) }\n format.json { redirect_to incident_plan_path(@incident, @plan) }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @billing_plan = BillingPlan.new(params[:billing_plan])\n\n respond_to do |format|\n if @billing_plan.save\n format.html { redirect_to(@billing_plan, :notice => 'Billing plan was successfully created.') }\n format.xml { render :xml => @billing_plan, :status => :created, :location => @billing_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @billing_plan.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_plan\n case params[:id]\n when \"course\"\n else \n @plan = Plan.find(params[:id])\n end\n end", "def new_plan\n plan.clear\n plan\n end", "def create\n super params[:application_plan]\n end", "def test_invite_change_significant_change\n old_message = <<ICS\nBEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nUID:foobar\nDURATION:PT1H\nSEQUENCE:1\nORGANIZER;CN=Strunk:mailto:[email protected]\nATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:[email protected]\nATTENDEE;CN=One:mailto:[email protected]\nATTENDEE;CN=Two:mailto:[email protected]\nDTSTART:20140716T120000Z\nDTEND:20140716T130000Z\nEND:VEVENT\nEND:VCALENDAR\nICS\n\n new_message = <<ICS\nBEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nUID:foobar\nDURATION:PT2H\nSEQUENCE:2\nORGANIZER;CN=Strunk:mailto:[email protected]\nATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:[email protected]\nATTENDEE;CN=Two:mailto:[email protected]\nATTENDEE;CN=Three:mailto:[email protected]\nDTSTART:20140716T120000Z\nDTEND:20140716T130000Z\nEND:VEVENT\nEND:VCALENDAR\nICS\n\n version = Tilia::VObject::Version::VERSION\n\n expected = [\n {\n 'uid' => 'foobar',\n 'method' => 'CANCEL',\n 'component' => 'VEVENT',\n 'sender' => 'mailto:[email protected]',\n 'sender_name' => 'Strunk',\n 'recipient' => 'mailto:[email protected]',\n 'recipient_name' => 'One',\n 'significant_change' => true,\n 'message' => <<ICS\nBEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Tilia//Tilia VObject #{version}//EN\nCALSCALE:GREGORIAN\nMETHOD:CANCEL\nBEGIN:VEVENT\nUID:foobar\nDTSTAMP:**ANY**\nSEQUENCE:2\nDTSTART:20140716T120000Z\nDTEND:20140716T130000Z\nORGANIZER;CN=Strunk:mailto:[email protected]\nATTENDEE;CN=One:mailto:[email protected]\nEND:VEVENT\nEND:VCALENDAR\nICS\n },\n {\n 'uid' => 'foobar',\n 'method' => 'REQUEST',\n 'component' => 'VEVENT',\n 'sender' => 'mailto:[email protected]',\n 'sender_name' => 'Strunk',\n 'recipient' => 'mailto:[email protected]',\n 'recipient_name' => 'Two',\n 'significant_change' => true,\n 'message' => <<ICS\nBEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Tilia//Tilia VObject #{version}//EN\nCALSCALE:GREGORIAN\nMETHOD:REQUEST\nBEGIN:VEVENT\nUID:foobar\nDURATION:PT2H\nSEQUENCE:2\nORGANIZER;CN=Strunk:mailto:[email protected]\nATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:[email protected]\nATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:[email protected]\nATTENDEE;CN=Three;PARTSTAT=NEEDS-ACTION:mailto:[email protected]\nDTSTART:20140716T120000Z\nDTEND:20140716T130000Z\nEND:VEVENT\nEND:VCALENDAR\nICS\n },\n {\n 'uid' => 'foobar',\n 'method' => 'REQUEST',\n 'component' => 'VEVENT',\n 'sender' => 'mailto:[email protected]',\n 'sender_name' => 'Strunk',\n 'recipient' => 'mailto:[email protected]',\n 'recipient_name' => 'Three',\n 'significant_change' => true,\n 'message' => <<ICS\nBEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Tilia//Tilia VObject #{version}//EN\nCALSCALE:GREGORIAN\nMETHOD:REQUEST\nBEGIN:VEVENT\nUID:foobar\nDURATION:PT2H\nSEQUENCE:2\nORGANIZER;CN=Strunk:mailto:[email protected]\nATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:[email protected]\nATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:[email protected]\nATTENDEE;CN=Three;PARTSTAT=NEEDS-ACTION:mailto:[email protected]\nDTSTART:20140716T120000Z\nDTEND:20140716T130000Z\nEND:VEVENT\nEND:VCALENDAR\nICS\n }\n ]\n\n parse(old_message, new_message, expected, 'mailto:[email protected]')\n end", "def minute_plan_new(minute_plan)\n attachments.inline['money.png'] = email_cdn_file '/img/money.png'\n @minute_plan = minute_plan\n @company_phone = minute_plan.payment_subscription.company_phone\n @company = @company_phone.company\n mail(\n to: @company_phone.extensions.admin.first.email,\n subject: '¡Tu plan de minutos con GurúComm está activado!'\n )\n end", "def waiting_date (last_promo_item, plan)\n num = ((last_promo_item.validez - last_promo_item.created_at)/60/60/24).round\n case num\n when 7\n if (plan == 'plus')\n last_promo_item.validez + 3.days\n elsif (plan == 'basic')\n last_promo_item.validez + 10.days\n end\n when 3\n if (plan == 'plus')\n last_promo_item.validez + 2.days\n elsif (plan == 'basic')\n last_promo_item.validez + 5.days\n end\n when 1\n if (plan == 'plus')\n last_promo_item.validez + 1.days\n elsif (plan == 'basic')\n last_promo_item.validez + 2.days\n end\n else\n #Error -> Promo lasted and unselectable number of days\n end\n\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end", "def set_plan\n @plan = Plan.find(params[:id])\n end" ]
[ "0.60182947", "0.59660757", "0.5834655", "0.5811939", "0.574948", "0.5744434", "0.5569099", "0.5558198", "0.5556602", "0.55485564", "0.5498216", "0.5460444", "0.5443325", "0.54411876", "0.5435703", "0.5424753", "0.54196864", "0.5415485", "0.5403401", "0.53931385", "0.5382359", "0.5356353", "0.5352106", "0.5350893", "0.53365535", "0.5329671", "0.53225005", "0.53207207", "0.5315804", "0.52641433", "0.5248226", "0.52408755", "0.5233663", "0.5231103", "0.52164763", "0.52144474", "0.5210184", "0.5210184", "0.5180735", "0.51562387", "0.5154046", "0.51414", "0.5134285", "0.5126844", "0.5126669", "0.5126569", "0.512655", "0.5126217", "0.5124349", "0.5123658", "0.5123026", "0.5122002", "0.51191944", "0.5111604", "0.51066446", "0.51046664", "0.51001865", "0.5091868", "0.5072713", "0.5067206", "0.5047754", "0.5042674", "0.50143945", "0.5007018", "0.50035477", "0.49965972", "0.49912527", "0.4983076", "0.49781147", "0.49772424", "0.49726912", "0.49676988", "0.4965098", "0.49468923", "0.49409163", "0.4934281", "0.49337554", "0.4928873", "0.49274847", "0.492142", "0.491775", "0.4915619", "0.4912985", "0.4912985", "0.49016103", "0.48996592", "0.48995692", "0.48987833", "0.48945588", "0.4894139", "0.48932463", "0.48927215", "0.48923174", "0.48873293", "0.48819628", "0.48800412", "0.4879452", "0.4879372", "0.4879366", "0.4879366" ]
0.75026447
0
loads SEO templates and format strings for SEO tags
def set_seo_data(hash) tt = Setting::get('Title for location page') unless tt.blank? hash[:title] = self.process_seo_str tt end dt = Setting::get('Description for location page') unless dt.blank? hash[:description] = self.process_seo_str dt end kt = Setting::get('Keywords for location page') unless kt.blank? hash[:keywords] = self.process_seo_str kt end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seo_tags\n seo_title + seo_meta_author + seo_meta_description\n end", "def seo_for_page\n PAGE_SEO_META.each do |meta|\n send(\"set_#{meta}_key\", \"#{seo_condition[:prefix]}#{meta}\")\n end\n\n set_title_variables(seo_variables)\n end", "def show_seo\n end", "def cama_build_seo(options = {})\n options[:image] = current_site.get_option(\"screenshot\", current_site.the_logo) unless options[:image].present?\n options[:title] = current_site.the_title unless options[:title].present?\n options[:description] = current_site.the_option(\"seo_description\") unless options[:description].present?\n options[:url] = request.original_url\n options[:keywords] = current_site.the_option(\"keywords\") unless options[:keywords].present?\n\n s = {\n keywords: options[:keywords],\n author: current_site.get_option('seo_author'),\n icon: current_site.the_icon,\n og: {\n title: options[:title],\n description: options[:description],\n type: 'website',\n url: options[:url],\n image: options[:image]\n },\n twitter: {\n card: 'summary',\n title: options[:title],\n description: options[:description],\n url: options[:url],\n image: options[:image],\n site: current_site.get_option('twitter_card'),\n creator: current_site.get_option('twitter_card'),\n domain: request.host\n },\n alternate: [\n { type: 'application/rss+xml', href: cama_rss_url }\n ]\n }.merge(options.except(:object))\n\n l = current_site.get_languages\n if l.size > 1\n l.each do |lang|\n s[:alternate] << {\n href: current_site.the_url(locale: lang),\n hreflang: lang\n }\n end\n end\n\n # call all hooks for seo\n r = { seo_data: s, object: options[:object] }\n hooks_run('seo', r)\n r[:seo_data]\n end", "def sanctify_liquid_tags(head); end", "def generate(site)\n @site = site\n\n @mode = site.config['environment']\n @template = site.config['theme']\n\n @project_path = File.join(File.dirname(__FILE__)).sub('_plugins/seo', '')\n @module_data_path = File.join(File.join(@project_path, '_data'))\n @module_config_path = File.join(File.join(@module_data_path, 'plugins'))\n @module_template_path = File.join(File.join(@module_data_path, 'templates'))\n @module_config_default = YAML::load(File.open(File.join(@module_config_path, 'defaults', 'seo-tags.yml')))\n @module_config_user = YAML::load(File.open(File.join(@module_config_path, 'seo-tags.yml')))\n\n @module_config_default_settings = @module_config_default['defaults']\n @module_config_user_settings = @module_config_user['settings']\n @module_config = @module_config_default_settings.merge!(@module_config_user_settings)\n\n if plugin_disabled?\n Jekyll.logger.info \"J1 SEO Tags:\", \"disabled\"\n return\n else\n Jekyll.logger.info \"J1 SEO Tags:\", \"enabled\"\n Jekyll.logger.info \"J1 SEO Tags:\", \"generate seo tags\"\n end\n\n end", "def prepare_meta_tags(options = {})\n defaults = {\n author: nil,\n authors: [],\n description: nil,\n description_og: nil,\n description_twitter: nil,\n images: [],\n #is_duplicate?: false,\n # # used to determine if we should rel=canonical, true if viewing a paginated\n # just comparing request url to canonical for now\n # form of a full-page-enabled resource\n keywords: [],\n nofollow?: false,\n noindex?: false,\n page: nil, # Have to throw this into the title\n pages: nil, # along with this\n title: nil, # Just the descriptive part of the title\n #title_format: nil, # Title with placeholders for sitename, pages, and separators\n # disabling this for now, because getting it to with with meta-tags\n # current title passing scheme would require reading placement and\n # then monkey-patching parameters\n #title_separator: '|', #set this at higher level # '-', 'on', ':', etc\n #title_site_name_position: 'right', #set this at higher level\n #title_site_name: SITE_IDS[:NAME], # provided earlier on, meta-tags ties to other site identifier tags\n title_og: nil,\n title_twitter: nil,\n type: 'page', # og and twitter need types, we generate from our map if missing\n type_og: nil,\n type_twitter: nil,\n video: nil,\n url: nil, # canonical, required by og \"#{request.url}\"\n url_current: request.url,\n url_next: nil, # if paged and no full-page alternative\n url_prev: nil, # if paged and no full-page alternative\n }\n options.reverse_merge! defaults\n\n # @todo Raise some errors if mandatory things are missing as required by\n # og and twitter, i.e.\n # We want this to fill out as much as possible, but it needs a base of info\n # description\n # title (except certain cards...)\n # url - this is the big one, always needed\n # image_url - for og\n if options[:url].blank?\n raise MetaTagError, 'No url defined for content, required by OG and needed if protocol different from canonical'\n end\n\n # initialize return array\n return_values = {\n author: [],\n og: { image: []},\n twitter: { creator: []}\n }\n\n # Authors\n options[:authors] << options[:author] if options[:author]\n options[:authors].each do |author|\n if author.has_key?(:gplus_id) and (id = author[:gplus_id])\n return_values[:author] << \"https://plus.google.com/#{id}\"\n end\n if author.has_key?(:twitter_id)\n return_values[:twitter][:creator] << id\n end\n end\n\n # Descriptions\n return_values[:description] = options[:description]\n return_values[:og][:description] = options[:description_og]\n return_values[:twitter][:description] = options[:description_twitter]\n\n # Images\n # @todo existence checks and warnings for sizes, AR, filesize, etc\n # @todo Need to take in all images and distribute to each stream according to size appropriateness,\n # unless specifically tagged to a stream\n\n # Images - OG\n # @todo pass https url through secure_url, width and height once after\n # https://github.com/kpumuk/meta-tags/issues/63 is resolved\n options[:images].each do |image|\n if image.has_key? :url\n return_values[:og][:image] << image[:url]\n\n #if image.has_key? :width and image.has_key? :height\n # return_values[:og][:image][:width] = image[:width].to_i\n # return_values[:og][:image][:height] = image[:height].to_i\n #end\n end\n end\n\n # Images - Twitter\n # Falls back to open graph, let's rely on that for now\n # @todo Support custom images for twitter\n\n # Keywords\n return_values[:keywords] = options[:keywords]\n\n # Noindex, nofollow\n # @todo Build in checking for if these are turned off for this object type somewhere\n return_values[:noindex] = options[:noindex?]\n return_values[:nofollow] = options[:nofollow?]\n\n # Titles\n return_values[:og][:title] = options[:title_og] if options[:title_og]\n return_values[:twitter][:title] = options[:title_twitter] if options[:title_twitter]\n\n #if options.has_key)[:title_format]\n # #if options[:title_page_format]\n #\n # end\n # return_values[:title] = options[:title_format].gsub(['special','characters'],['value','otherval'])\n #else\n if options[:pages] and options[:page] and options[:pages] > 1 and options[:page] > 1\n return_values[:title] = [\n options[:title],\n t('pagination.page_x_of_y', page: options[:page], pages: options[:pages])\n ]\n else\n return_values[:title] = options[:title]\n end\n #end\n\n # Types\n og_content_type = options[:type_og]\n if og_content_type and ZanoboRails::Crawlable.content_types_for(:og).include? og_content_type\n return_values[:og][:type] = og_content_type\n elsif type_provided = (general_type = options[:type] and ZanoboRails::Crawlable.general_content_types.include? general_type)\n return_values[:og][:type] = ZanoboRails::Crawlable::Advisor.og_content_type_for(general_type)\n else\n # Type is REQUIRED, we really should test for required values.\n return_values[:og][:type] = ZanoboRails::Crawlable::Advisor.recommend(:content_type, :og).to_s\n end\n\n twitter_content_type = options[:type_twitter]\n if twitter_content_type and ZanoboRails::Crawlable.content_types_for(:twitter).include? twitter_content_type\n return_values[:twitter][:type] = twitter_content_type\n elsif type_provided\n return_values[:twitter][:type] = ZanoboRails::Crawlable.twitter_content_type_for(general_type)\n else\n # Type is REQUIRED\n return_values[:twitter][:type] = ZanoboRails::Crawlable::Advisor.recommend(:content_type, :twitter).to_s\n end\n\n # URLS\n # og:url\n # twitter:url\n # rel=canonical\n return_values[:og][:url] = options[:url]\n return_values[:twitter][:url] = options[:url]\n return_values[:canonical] = options[:url] unless request.url == options[:url]\n return_values[:next] = options[:url_next]\n return_values[:prev] = options[:url_prev]\n\n # Video\n #og:video => {\n # :director => 'http://www.imdb.com/name/nm0000881/',\n # :writer => ['http://www.imdb.com/name/nm0918711/', 'http://www.imdb.com/name/nm0177018/']\n #}\n\n # Tell og and twitter to use primary description and title if nothing is customized to them\n return_values[:og][:description] = :description if return_values[:og][:description].nil?\n return_values[:twitter][:description] = :description if return_values[:twitter][:description].nil?\n return_values[:og][:title] = :title if return_values[:og][:title].nil?\n return_values[:twitter][:title] = :title if return_values[:twitter][:title].nil?\n\n return_values\n end", "def prepare_meta_tags(options={})\n site_name = I18n.t('meta_tag.site_name')\n title = I18n.t('meta_tag.title')\n description = I18n.t('meta_tag.description')\n image = options[:image] || ActionController::Base.helpers.image_url('/homepage/teaser_bg.jpg')\n current_url = request.url\n\n # Let's prepare a nice set of defaults\n defaults = {\n site: site_name,\n title: title,\n image: image,\n description: description,\n keywords: %w[bookmarks web mobile free application],\n twitter: {\n site_name: site_name,\n site: '@wundermarks',\n card: 'summary',\n description: :description,\n image: image\n },\n og: {\n url: current_url,\n site_name: site_name,\n title: :title,\n image: image,\n description: :description,\n type: 'website'\n }\n }\n\n options.reverse_merge!(defaults)\n\n set_meta_tags options\n end", "def show\n set_meta_tags og: {\n url: \"#{request.base_url + request.original_fullpath}\",\n type: \"website\",\n title: \"#{@news.title} Software Libre y Codigo Abierto Panama\",\n description: @news.news_content.content,\n site_name: \"floss-pa\",\n image: \"https://floss-pa.net/images/logo.png}\"\n }\n set_meta_tags twitter: {\n card: \"summary\",\n description: @news.news_content.content,\n title: @news.title,\n creator: \"@flosspa\",\n image: {\n _: \"https://floss-pa.net/images/logo.png}\",\n width: 100,\n height: 100,\n },\n domain: \"Floss-pa\"\n }\n\n\n set_meta_tags author: user_custom_path(@news.user,@news.user.name.gsub(/\\s/,'-'))\n end", "def set_meta_tags_title\n set_meta_tags site: 'benradler.com'\n end", "def template_page(site); end", "def set_seo_meta(title, options = {})\r\n #todo\r\n keywords = options[:keywords] || \"问答\"\r\n description = options[:description] || \"Kejian.TV 课件交流系统是中国最大的教育资源在线集散平台,同时,课件交流系统也是中国最专业的在线学习社区。\"\r\n\r\n if title.length > 0\r\n @seo[:title] = \"#{title}\"\r\n end\r\n @seo[:keywords] = keywords\r\n @seo[:description] = description\r\n end", "def set_seo_data(hash)\n tt = Setting::get('Title for restaurant page')\n unless tt.blank?\n hash[:title] = self.process_seo_str tt\n end\n dt = Setting::get('Description for restaurant page')\n unless dt.blank?\n hash[:description] = self.process_seo_str dt\n end\n kt = Setting::get('Keywords for restaurant page')\n unless kt.blank?\n hash[:keywords] = self.process_seo_str kt\n end\n end", "def show\n set_meta_tags og: {\n title: \"Ruby & Rails Glossary - '#{@glossary.term}'\",\n description: @glossary.glossary_definitions.map(&:definition).join(', '),\n image: root_url[0..-2] + ActionController::Base.helpers.asset_url('glossary.png'),\n url: glossary_url(@glossary)\n }, title: \"Ruby and Rails Glossary : '#{@glossary.term}' - #{@glossary.glossary_definitions.map(&:definition).join(', ')}\"\n end", "def set_meta_tags_for_url_path(base_url, request_fullpath)\n\n page_title = t(LOCALE_TITLE_KEY, default: SiteMetaInfoDefaults.title)\n page_desc = t(LOCALE_DESCRIPTION_KEY, default: SiteMetaInfoDefaults.description)\n\n set_meta_tags site: SiteMetaInfoDefaults.site_name,\n title: page_title,\n description: page_desc,\n keywords: create_keywords\n\n set_page_meta_images\n\n set_og_meta_tags(site_name: SiteMetaInfoDefaults.site_name,\n title: helpers.full_page_title(page_title: page_title),\n description: page_desc,\n type: t(LOCALE_TYPE_KEY, default: SiteMetaInfoDefaults.og_type),\n base_url: base_url,\n fullpath: request_fullpath)\n\n set_facebook_meta_tags\n\n set_twitter_meta_tags(card: t(LOCALE_TWITTER_CARD_KEY, default: SiteMetaInfoDefaults.twitter_card_type))\n\n end", "def page_tags(objectTags, allTagsUrl, locale = 'en')\r\n %{\r\n <div id=\"tags\"></div>\r\n <script type=\"text/javascript\">\r\n $(document).ready(function(){\r\n $(\"#tags\").tagit({\r\n objectTags: #{objectTags.to_json},\r\n allTags : \"#{allTagsUrl}\",\r\n locale : \"#{locale}\"\r\n });\r\n });\r\n </script>\r\n }.html_safe\r\n end", "def visit(page)\n found = @segments[page.post_title]\n return unless found\n #page.post_content = found\n file = ::Sphonglepress::STATIC_DIR.join(\"from_document\", full_path_for_page(page) << \".html.haml\")\n FileUtils.mkdir_p(file.dirname) unless Dir.exist? file.dirname\n File.open(file, 'w') do |f|\n f.write Haml::HTML.new(found, :xhtml => true).render\n end\n \n end", "def render(view)\n tags = []\n\n render_charset(tags)\n render_title(tags)\n render_icon(tags)\n render_with_normalization(tags, :description)\n render_with_normalization(tags, :keywords)\n render_refresh(tags)\n render_canonical_link(tags)\n render_noindex(tags)\n render_alternate(tags)\n render_open_search(tags)\n render_links(tags)\n\n render_hashes(tags)\n render_custom(tags)\n\n tags.tap(&:compact!).map! { |tag| tag.render(view) }\n view.safe_join tags, MetaTags.config.minify_output ? \"\" : \"\\n\"\n end", "def slug_candidates\n if self.title.present?\n title = self.title.truncate(60, separator: ' ', omission: '').gsub('_', '-')\n [\"#{title}\",\n [\"#{title}\", '2'],\n [\"#{title}\", '3'],\n [\"#{title}\", '4'],\n [\"#{title}\", '5']]\n elsif self.body.present?\n \"#{self.body.markdown2html.strip_tags.truncate(60, separator: ' ', omission: '').gsub('_', '-')}\"\n end\n end", "def set_site_meta_tags\n config = ZanoboRails::Crawlable.configuration\n\n site_ids = {\n separator: config.page_title_sitename_separator,\n reverse: config.page_title_sitename_pos == 'right'\n }\n\n if config.gplus_id.present?\n site_ids[:publisher] = \"https://plus.google.com/#{config.gplus_id}\"\n end\n if config.twitter_id.present?\n site_ids[:twitter] = \"@#{config.twitter_id}\"\n end\n if config.fb_app_id.present?\n site_ids[:fb] = { app_id: \"@#{config.fb_app_id}\" }\n end\n if config.site_name.present?\n site_ids[:open_graph] = { site_name: config.site_name }\n site_ids[:site] = config.site_name\n end\n\n set_meta_tags(site_ids)\n end", "def generate(site)\n if site.layouts.key? 'tag_index'\n dir = site.config['tag_dir'] || 'tag'\n ## Create Top level tag list /tag/index.html\n write_all_tags_index(site, dir, site.tags.keys.sort_by { |x| x.downcase } )\n \n ## Create /tag/{{tag}}/index.html\n site.tags.keys.each do |tag|\n write_tag_index(site, File.join(dir, tag.to_url), tag)\n end\n end\n end", "def show_seo_evaluation (url, seo)\n if seo\n puts \"Needs SEO! Keywords or Description were not found in this: (#{url})\"\n end\nend", "def set_seo_meta(title,keywords = '',desc = '')\n if title\n @page_title = \"#{title}\"\n if params[:page]\n @page_title += \" &raquo; (First#{params[:page]}Page)\"\n end\n @page_title += \" &raquo; #{@setting.site_name}\"\n else\n @page_title = @setting.site_name\n end\n @meta_keywords = keywords\n @meta_description = desc\n end", "def index\n @ovode = Ovode.find_by_tag(\"main\")\n \n @title = @ovode.try(:seotitle)\n @seodesc = @ovode.try(:seodesc)\n @seokeys = @ovode.try(:seokeywords)\n respond_to do |format|\n format.html # index.html.erb\n end\n \n \n end", "def skel_tags( path_storage, section_path ) \n # Get a list of all known tags\n tags = path_storage.find( :all => true ).map { |e| e.tags }.flatten.uniq\n \n tags.each do |tag|\n entries = path_storage.find.find_all { |e| e.tags.member? tag }\n page = Page.new( File::join( 'tags',tag,'index' ), section_path )\n page.updated = path_storage.last_updated( entries ) \n yield :page => page, :entries => entries\n end\n end", "def initialize(site, path)\n super\n @metadata = [ :title, :layout, :author ]\n \n @name = source_path[0..(-1-source_ext.length)].gsub(/\\//, '-')\n \n @tags = []\n unless source_metadata[:tags].nil?\n for tag in source_metadata[:tags]\n @tags << site.tags[tag]\n @tags.last << self\n end\n end\n \n if name =~ /^(\\d+-\\d+-\\d+)-(.+)$/\n @created = Time.parse $1\n @updated ||= @created\n @slug = $2\n @output_dir = created.strftime('%Y/%m/%d')\n @output_path = File.join output_dir, \"#{slug}.html\"\n @uri = \"/#{output_path}\"\n else\n raise ArgumentError, \"Bad file name: #{name}\"\n end\n end", "def head_main(options)\n options[:charset] ||= 'utf-8' \n \n # Prefix (leading space)\n if options[:prefix]\n prefix = options[:prefix]\n elsif options[:prefix] == false\n prefix = ''\n else\n prefix = ' '\n end\n\n # Separator\n unless options[:separator].blank?\n separator = options[:separator]\n else\n separator = '|'\n end\n\n # Suffix (trailing space)\n if options[:suffix]\n suffix = options[:suffix]\n elsif options[:suffix] == false\n suffix = ''\n else\n suffix = ' '\n end\n \n # Lowercase title?\n if options[:lowercase] == true\n @title = @title.downcase unless @title.blank?\n end\n \n # Default page title\n if @title.blank? && options[:default]\n @title = options[:default]\n end\n\n buffer = \"\"\n\n # Set website/page order\n if @title.blank?\n # If title is blank, return only website name\n buffer << content_tag(:title, options[:site]) \n else\n if options[:reverse] == true\n # Reverse order => \"Page : Website\"\n buffer << content_tag(:title, @title + prefix + separator + suffix + options[:site])\n else\n # Standard order => \"Website : Page\"\n buffer << content_tag(:title, options[:site] + prefix + separator + suffix + @title)\n end\n end\n \n buffer << \"\\n\"\n\t\tbuffer << tag(:meta, \"http-equiv\" => \"Content-type\", :content => \"text/html; charset=#{options[:charset]}\")\n\t\tbuffer << csrf_meta_tag\n\t\tbuffer.html_safe\n end", "def title_tag(slides = nil)\n controller, desy = controller_path, SETTINGS['application_name']\n return t('captions.titles.admin', :desy => desy) if controller.start_with? 'admin/'\n case controller\n when 'documents'\n t('captions.titles.documents', :desy => desy)\n when 'lessons', 'lesson_editor'\n t('captions.titles.lessons', :desy => desy)\n when 'audio_editor', 'image_editor', 'video_editor', 'media_elements'\n t('captions.titles.media_elements', :desy => desy)\n when 'users'\n t('captions.titles.profile', :desy => desy)\n when 'virtual_classroom'\n t('captions.titles.virtual_classroom', :desy => desy)\n when 'lesson_viewer', 'lesson_export'\n case action_name\n when 'index', 'archive'\n t('captions.titles.single_lesson', :desy => desy, :lesson => slides.first.lesson.title)\n else\n t('captions.titles.virtual_classroom', :desy => desy)\n end\n else\n t('captions.titles.default', :desy => desy)\n end\n end", "def show_seo\n people = Roxiware::Person.all\n @people = people.select { |person| can? :read, person }\n if params[:seo_index].blank?\n @person = people.select { |person| person.show_in_directory }.first\n else\n @person = Roxiware::Person.where(:seo_index => params[:seo_index]).first\n end\n raise ActiveRecord::RecordNotFound if @person.nil?\n authorize! :read, @person\n @title = @title + \": People : \" + @person.full_name\n @meta_keywords = @meta_keywords + \", \" + @person.full_name\n\n @recent_posts = Roxiware::Blog::Post.published().where(:person_id=>@person.id).order(\"post_date DESC\").limit(5).collect{|post| post}\n\n respond_to do |format|\n format.html { render :action => 'show' }\n format.json { render :json => @person.ajax_attrs(@role) }\n end\n end", "def liquid_for(markup)\n Liquid::Template.file_system = IncludeTemplateFileSystem.new(@design)\n Liquid::Template.register_tag('navigation', NavigationTag)\n Liquid::Template.register_tag('resource_link', ResourceLinkTag)\n Liquid::Template.register_tag('resource_image', ResourceImageTag)\n Liquid::Template.register_tag('search', SearchBlock)\n Liquid::Template.parse(markup)\n end", "def make_tags(item)\n\ttags_for(item, { :base_url => @site.config()[:base_url] + \"/tags/\" })\nend", "def render_title(options={})\n result = ::Liquid::Template.parse(title).render(optional_data(options))\n rescue => e\n log_error(e)\n ensure\n return result.to_s\n end", "def slug_generator_class; end", "def title_tag_for_page(slug)\n content = \"\"\n \n @slug_page ||= Page.find_by_slug(slug)\n \n if @slug_page\n content = @slug_page.part_content(\"title_tag\")\n end\n \n content\n end", "def filter_content \n\t\tself.title = ActionView::Base.full_sanitizer.sanitize(self.title)\n\t\tself.slug = ActionView::Base.full_sanitizer.sanitize(self.slug)\n\t\tself.meta_title = ActionView::Base.full_sanitizer.sanitize(self.meta_title)\n\t\tself.meta_keyword = ActionView::Base.full_sanitizer.sanitize(self.meta_keyword)\n\t\tself.meta_description = ActionView::Base.full_sanitizer.sanitize(self.meta_description)\n\t\tself.page_class = ActionView::Base.full_sanitizer.sanitize(self.page_class)\n\tend", "def render(view)\n tags = []\n\n render_title(tags)\n render_description(tags)\n render_keywords(tags)\n render_refresh(tags)\n render_noindex(tags)\n render_alternate(tags)\n render_links(tags)\n\n render_hash(tags, :twitter, :name_key => :name)\n render_hashes(tags)\n render_custom(tags)\n\n tags.compact.map { |tag| tag.render(view) }.join(\"\\n\").html_safe\n end", "def tags\n tags= Tag.find_all_with_article_counters(20)\n total= tags.inject(0) {|total,tag| total += tag[:article_counter] }\n average = total.to_f / tags.size.to_f\n sizes = tags.inject({}) {|h,tag| h[tag[:name]] = (tag[:article_counter].to_f / average); h} # create a percentage\n # apply a lower limit of 50% and an upper limit of 200%\n sizes.each {|tag,size| sizes[tag] = [[2.0/3.0, size].max, 2].min * 100}\n\n str= \"<p style=\\\"overflow:hidden\\\">\"\n tags.sort{|x,y| x[:name] <=> y[:name]}.each do |tag|\n str += \"<span style=\\\"font-size:#{sizes[tag[:name]]}%\\\"> #{link_to(tag[:name], url(:tag, tag[:name]))}</span>\"\n end\n str += \"</p>\"\n @body= str\n render\n end", "def parse_seo(body)\n parser = SeoParser.new(body)\n return {\n :meta => parser.extract_meta,\n :words => parser.extract_frequent_words,\n :title => parser.extract_title,\n :links => parser.extract_links }\n end", "def set_extra_stuff\n @templates = Template.all\n @tags = tags_for('Common')\n end", "def replace(content)\n \n # pre-structuring\n content.gsub!( /^(\\w.*)\\n(\\w.*)/ ) { \"#{$1} #{$2}\" } # remove single line breaks between text in order to avoid false paragraph markup\n content.gsub!( /<!--/ ) { \"--\" } # replace opening html commentaries\n content.gsub!( /-->/ ) { \"--\" } # replace closing html commentaries\n \n # templates\n content.gsub!( /\\{\\{Zitat\\|(.*)\\|.*\\}\\}\\s*$\\n/ ) { \"\\{p\\}\\\"#{$1}\\\"\\{/p\\}\\n\" } # citation\n content.gsub!( /\\{\\{.*(Finale Version).*\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1}</font>{/status}<br>\" } # final version\n content.gsub!( /\\{\\{Vorlage:(Dokument.*)\\n*(.*)\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1} #{$2}</font>{/status}<br>\" } # document status\n content.gsub!( /\\{\\{.*\\}\\} *$/ ) { '' } # remove single line templates\n content.gsub!( /\\{\\{.*\\n?.*\\}\\} *$/ ) { '' } # remove all remaining templates\n \n # tags\n content.gsub!( /<nowiki>(.*?)<\\/nowiki>/ ) { \"<pre>#{$1}</pre>\" }\n content.gsub!( /^ +(.*)/ ) { \"<pre>#{$1}</pre>\" }\n\n # special markup of qualidative data analysis\n content = content + \"\\n\\n{!end}\"\n \n # categories\n content.gsub!( /\\[\\[Kategorie:(.*?)\\]\\]/i ) { \"{category}<font color=\\\"#FF0000\\\">Kategorie:#{$1}</font>{/category}<br>\" }\n \n # images\n content.gsub!( /\\[\\[Bild:(.*?)\\]\\]/i ) { \"{image}Bild:#{$1.gsub!(/.*\\|/,'')}{/image}<br>\"} # Bild:lpscreen.jpg|thumb|Bereichseite des Landesportals\n\n # bold\n content.gsub!(/'''(.*?)'''/) {\"<strong>#{$1}</strong>\"}\n content.gsub!(/'''(.*?)$/) {\"<strong>#{$1}</strong>\"}\n\n # italics\n content.gsub!(/''(.*?)''/) {\"<em>#{$1}</em>\"}\n content.gsub!(/''(.*?)$/) {\"<em>#{$1}</em>\"}\n\n # headings\n 6.downto(1) { |i| content.gsub!( /^={#{i}}(.*?)={#{i}} *$/ ) { \"<h#{i}>\\{h>#{i}\\}#{$1}\\{/h>#{i}\\}</h#{i}>\" } }\n \n # links, internal\n content.gsub!( /\\[\\[([^\\[\\n]*?)\\| *(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[\\[(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n\n # links, external\n content.gsub!( /\\[([^\\[\\n]*?)\\| *(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n \n # lists\n content.gsub!(/^:+/,'') # remove forced indenting\n content.gsub!( /^((?:\\*.*\\n+)+)/ ) { \"\\{l>ul\\}<ul>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^\\*/,'')}</li>\\n\" }.join}</ul>\\{/l>ul\\}<br>\\n\" } # first level ul\n content.gsub!( /^((?:#.*\\n+)+)/ ) { \"\\{l>ol\\}<ol>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^#/,'')}</li>\\n\" }.join}</ol>\\{/l>ol\\}<br>\\n\" } # first level ol\n content.gsub!( /<li>\\s*<\\/li>\\n/ ) { '' } # remove empty list entries (this may occur if first-level wiki-lists are entered with \\n\\n; they look like a single list when, in fact, they are but multiple single lists)\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # second level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # second level ol\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # third level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # third level ol\n\n # tables\n # the table conversion barely works, cf. http://johbuc6.coconia.net/doku.php/mediawiki2html_machine/code?DokuWiki=7c542b97df2bc0f82fec0f4875265a20 for an implementation in PHP\n content.gsub!( /^\\{\\|(.*)/ ) { \"\\{table\\}\\n<table #{$1}>\" }\n content.gsub!( /\\|\\}/ ) { \"</table>\\n\\{/table\\}\" }\n content.gsub!( /^\\|-(.*)/ ) { \"<tr>#{$1}\" }\n content.gsub!( /^!(.*?)\\|(.*)/ ) { \"<th #{$1}>#{$2}</th>\" } # table header with piped markup\n content.gsub!( /^!(.*)/ ) { \"<th>#{$1}</th>\" } # table header without piped markup\n content.gsub!( /^\\|(.*?)\\|(.*)/ ) { \"<td #{$1}>#{$2}\" } # table data with piped markup\n content.gsub!( /^\\|(.*)/ ) { \"<td>#{$1}\" } # table data without piped markup\n \n # line breaks\n content.gsub!( /(^(?:\\w|<strong|<em|<a|\\\").*)\\n\\s*\\n/ ) {\"<p>\\{p\\}#{$1}\\{/p\\}</p>\\n\"}\n \n # special markup of qualidative data analysis\n content.gsub!( /(\\{id\\}.*\\{\\/title\\})/ ) { \"<p><strong><em>#{$1.gsub(/_/,' ')}</em></strong></p>\" }\n \n# //$html = nl2br($html);\n# \t// line breaks\n# \t$html = preg_replace('/[\\n\\r]{4}/',\"<br/><br/>\",$html);\n# \t$html = preg_replace('/[\\n\\r]{2}/',\"<br/>\",$html);\n\n# \t$html = preg_replace('/[>]<br\\/>[<]/',\"><\",$html);\n \n# // allowed tags\n# \t$html = preg_replace('/&lt;(\\/?)(small|sup|sub|u)&gt;/','<${1}${2}>',$html);\n#\n# \t$html = preg_replace('/\\n*&lt;br *\\/?&gt;\\n*/',\"\\n\",$html);\n# \t$html = preg_replace('/&lt;(\\/?)(math|pre|code|nowiki)&gt;/','<${1}pre>',$html);\n# \t$html = preg_replace('/&lt;!--/','<!--',$html);\n# \t$html = preg_replace('/--&gt;/',' -->',$html);\n# \n return content\n\nend", "def section_built_with(cloc, site_config)\n s = %(\n <div class=\"col-md-5\">\n #{Kramdown::Document.new(site_config['about'].gsub('[English](README.md) [Deutsche](lang/README.de.md)', '')).to_html}\n </div>\n <div class=\"col-md-7\">\n <h3>#{site_config['homepage_subheading4']}</h3>\n <pre>\n <code>\n #{cloc}\n </code>\n </pre>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-12\" id=\"d3pie_chart_div_homepage_all\"></div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-12\" id=\"d3pie_chart_div_homepage_mit\"></div>\n </div>)\n Dir['python/images/*'].map do |image|\n s += %(\n <div class=\"row\">\n <img class=\"img-responsive\" src=\"#{image}\" alt=\"#{image.split('/').last.split('.').first.capitalize.split('-').join ' '}\">\n </div>)\n end\n s\nend", "def render(page_title, options = {})\n form_data = {'action' => 'parse', 'page' => page_title}\n\n valid_options = %w(linkbase noeditsections noimages)\n # Check options\n options.keys.each{|opt| raise ArgumentError.new(\"Unknown option '#{opt}'\") unless valid_options.include?(opt.to_s)}\n\n rendered = nil\n parsed = make_api_request(form_data).first.elements[\"parse\"]\n if parsed.attributes[\"revid\"] != '0'\n rendered = parsed.elements[\"text\"].text.gsub(/<!--(.|\\s)*?-->/, '')\n # OPTIMIZE: unifiy the keys in +options+ like symbolize_keys! but w/o\n if options[\"linkbase\"] or options[:linkbase]\n linkbase = options[\"linkbase\"] || options[:linkbase]\n rendered = rendered.gsub(/\\shref=\"\\/wiki\\/([\\w\\(\\)_\\-\\.%\\d:,]*)\"/, ' href=\"' + linkbase + '/wiki/\\1\"')\n end\n if options[\"noeditsections\"] or options[:noeditsections]\n rendered = rendered.gsub(/<span class=\"editsection\">\\[.+\\]<\\/span>/, '')\n end\n if options[\"noimages\"] or options[:noimages]\n rendered = rendered.gsub(/<img.*\\/>/, '')\n end\n end\n rendered\n end", "def set_static_page_metatags! tags, record\n if record.role == 'home'\n tags['title'] = translate('we_meditate')\n image = MediaFile.find_by(id: record.content_blocks.first['data']['image']['id']) if record.content_blocks.present?\n elsif record.parsed_content.present? && record.parsed_content['mediaFiles'].present?\n image = MediaFile.find_by(id: record.parsed_content['mediaFiles'].first)\n end\n\n tags['og:image'] = image_url image.file_url if image.present?\n tags['og:type'] = 'website' if %w[home contact privacy articles meditations subtle_system].include?(record.role)\n end", "def seo_title\n if meta_title.blank?\n root? ? name : \"#{root.name} - #{name}\"\n else\n meta_title\n end\n end", "def set_locale_meta_tags\n set_meta_tags(og: {locale: t('locale.short-code', default: 'en_US')} )\n # @todo When we support multiple locales, pull them in below\n #alternate: { \"fr\" => \"http://yoursite.fr/alternate/url\",\n # \"de\" => \"http://yoursite.de/alternate/url\" }\n end", "def appTag \n #this tag :htmlfp is set in application.rb javascript_expansions field \n if @title.eql?(\"HTML5 for Publishers\") \n :html5fp\n elsif @title.eql?(\"Finger Paint\")\n :fingerpaint\n elsif @title.eql?(\"CSSGameEngine\") \n :cssgameengine\n elsif @title.eql?(\"GMP\") \n :gmp\n elsif @title.eql?(\"JawsJS\") \n :jaws\n elsif @title.eql?(\"EntityJS\") \n :entityjs\n elsif @title.eql?(\"ImpactJS\") \n :impactjs\n else #the :defaults are already being set\n \"\" \n end\n end", "def accurate_title\n Spree::Config[:default_seo_title]\n end", "def site_subtitle\n \"Cool site with cool stuff\"\n end", "def page_title(defaults = {})\n old_site = @meta_tags[:site]\n @meta_tags[:site] = nil\n full_title = with_defaults(defaults) { extract_full_title }\n full_title.presence || old_site || \"\"\n ensure\n @meta_tags[:site] = old_site\n end", "def see_tag(text); end", "def yield_tag(text); end", "def initialize_html_tags; end", "def generate(site)\n # layout: tutorial_slides\n # layout: base_slides\n\n site.pages.select { |page| SLIDE_LAYOUTS.include? page.data['layout'] }.each do |page|\n dir = File.dirname(File.join('.', page.url))\n page2 = Jekyll::Page.new(site, site.source, dir, page.name)\n page2.data['layout'] = 'slides-plain'\n page2.basename = if page2.data.key?('lang')\n \"slides-plain_#{page2.data['lang'].upcase}\"\n else\n 'slides-plain'\n end\n page2.content = page2.content.gsub(/^name:\\s*([^ ]+)\\s*$/) do\n anchor = ::Regexp.last_match(1)\n\n \"<span id=\\\"#{anchor.strip}\\\"><i class=\\\"fas fa-link\\\" aria-hidden=\\\"true\\\"></i> #{anchor}</span>\"\n end\n if page2.data.key?('redirect_from')\n page2.data['redirect_from'].map { |x| x.gsub!(%r{/slides}, '/slides-plain') }\n end\n\n site.pages << page2\n end\n end", "def webSiteBuildPageFromTemplate(template, title, content, jsDirRelativePath, pagesDirRelativePath)\n html = template.gsub(\n \"TEMPLATE_PAGE_CONTENT\", content).gsub(\n \"TEMPLATE_PAGE_TITLE\", title).gsub(\n \"TEMPLATE_JS_PATH\", jsDirRelativePath.to_s).gsub(\n \"TEMPLATE_DOC_PATH\", pagesDirRelativePath.to_s)\n html\nend", "def render_with_normalization(tags, name)\n value = TextNormalizer.public_send(\"normalize_#{name}\", meta_tags.extract(name))\n normalized_meta_tags[name] = value\n tags << Tag.new(:meta, name: name, content: value) if value.present?\n end", "def tag_page_resource(tag, articles)\n Sitemap::ProxyResource.new(@sitemap, link(tag), @tag_template).tap do |p|\n # Detect \"formatted\" tag in first article - trying to guess the correct format to show\n # tagname = articles.first.tags.detect { |article_tag| safe_parameterize(article_tag) == tag }\n\n # Add metadata in local variables so it's accessible to later extensions\n p.add_metadata locals: {\n 'page_type' => 'tag',\n 'tagname' => tag,\n 'articles' => articles,\n 'blog_controller' => @blog_controller\n }\n end\n end", "def insert_google_site_search\n if File::exist?(\n filename=File::join(Rails.root,\"config/google_site_search.html\")\n )\n File.new(filename).read.html_safe\n end\n end", "def insert_google_site_search\n if File::exist?(\n filename=File::join(Rails.root,\"config/google_site_search.html\")\n )\n File.new(filename).read.html_safe\n end\n end", "def seo_title\n meta_title.blank? ? name : meta_title\n end", "def resource_meta_tags\n meta_tags = [\n current_site.metatags,\n @page.metatags\n ].flatten.inject({}) do |tags, metatag|\n tags.merge(metatag.name => metatag.content)\n end\n\n { image_src: current_site.logo.url }.merge(meta_tags)\n .merge(title: @page.title)\n end", "def page_title \n %(<title>#{page_title_raw}My Blog</title>) # Customize this for your blog\n end", "def create_tag_pages\n tag_set(items).each do |tag|\n @items.create(\n \"= render('_tag_page', :tag => '#{tag}')\", # use locals to pass data\n { :title => \"Category: #{tag}\", :is_hidden => true}, # do not include in sitemap.xml\n \"/tags/#{tag}/\", # identifier\n :binary => false\n )\n end\nend", "def render(context)\n site = context.registers[:site]\n page = context.registers.fetch(:page, {}).fetch(\"path\", nil)\n sprockets = site.sprockets\n\n asset = find_asset(sprockets)\n add_as_jekyll_dependency(site, sprockets, page, asset)\n process_tag(sprockets, asset)\n rescue => e\n capture_and_out_error \\\n site, e\n end", "def replace_tags(str)\n str = str.gsub('<skeleton_path>',@path)\n str = str.gsub('<skeleton_project>',@project)\n str = str.gsub('<skelton_template>',@template_name)\n return str\n end", "def get_meta_tags\n if @content_package\n\n if @content_package.meta_image_uid\n image = \"#{Settings.site_url}#{@content_package.meta_image.thumb('1200x630#').url}\"\n elsif @content_package.respond_to?(:hero_image) && @content_package.hero_image.present?\n image = \"#{Settings.site_url}#{@content_package.hero_image.thumb('1200x630#').url}\"\n end\n\n meta_title = @content_package.meta_title.presence || Settings.default_meta_title\n meta_description = @content_package.meta_description.presence || Settings.default_meta_description\n meta_keywords = @content_package.meta_keywords.presence || Settings.default_meta_keywords\n if @content_package.hide_from_robots?\n meta_hide_from_robots = \"<meta name='robots' content='noindex, nofollow' />\\n\"\n end\n\n else\n meta_title = content_for(:title) || Settings.default_meta_title\n meta_description = content_for(:description) || Settings.default_meta_description\n meta_keywords = content_for(:keywords) || Settings.default_meta_keywords\n meta_hide_from_robots = nil\n end\n\n meta_description = strip_tags CGI.unescapeHTML(meta_description.strip)\n\n meta_image = image || content_for(:meta_image) || \"#{Settings.site_url}#{asset_path(Settings.default_fb_meta_image)}\"\n\n meta_values = [meta_title, meta_description, meta_image, meta_keywords, meta_hide_from_robots]\n\n pig_meta_tags(meta_values)\n end", "def head_content\n meta 'http-equiv' => 'content-type', :content => 'text/html;charset=UTF-8'\n title page_title\n\n included_stylesheets\n inline_styles\n\n included_scripts\n inline_scripts\n end", "def create_html(options)\n if(options[:html_template] && options[:html_template] == :scientific) then\n\n if(options[:language] && options[:language] == :english) then\n html = '<h2>Academic Interests<\\/h2>\\r\\n' +\n '<p>Add information about academic fields of interest.<\\/p>\\r\\n' +\n '<h2>Teaching<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li>&lt;Link to programme of study/course&gt;<\\/li>\\r\\n' +\n ' <li>&lt;Link to programme of study/course&gt;<\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Higher education and employment history<\\/h2>\\r\\n' +\n '<p>Brief introduction to previous education and employment.<\\/p>\\r\\n' +\n '<h2>Honoraria<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li>&lt;Name of prize and (if applicable) link 1&gt;<\\/li>\\r\\n' +\n ' <li>&lt;Name of prize and (if applicable) link 2&gt;<\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Appointments<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li>&lt;Title and (if applicable) link 1&gt;<\\/li>\\r\\n' +\n ' <li>&lt;Title and (if applicable) link 2&gt;<\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Cooperation<\\/h2>\\r\\n' +\n '<p>&nbsp;<\\/p>'\n else\n html = '<h2>Faglige interesser<\\/h2>\\r\\n' +\n '<p>Her kan du skrive om faglige interesser.<\\/p>\\r\\n' +\n '<h2>Undervisning<\\/h2>\\r\\n<p>' +\n '&lt;Lenke til studieprogram/emne&gt; <br />\\r\\n' +\n '&lt;Lenke til studieprogram/emne&gt; <br />\\r\\n...<\\/p>\\r\\n' +\n '<h2>Bakgrunn<\\/h2>\\r\\n' +\n '<p>Kort om tidligere arbeidserfaring og utdanning<\\/p>\\r\\n' +\n '<h2>Priser<\\/h2>\\r\\n' +\n '<p>&lt;Navn og eventuelt lenke til pris 1&gt; <br />\\r\\n' +\n '&lt;Navn og eventuelt lenke til pris 2&gt; <br />\\r\\n' +\n '...<\\/p>\\r\\n' +\n '<h2>Verv<\\/h2>\\r\\n<p>' +\n '&lt;Navn og eventuelt lenke til verv 1&gt; <br />\\r\\n' +\n '&lt;Navn og eventuelt lenke til verv 2&gt; <br />\\r\\n...' +\n '<\\/p>\\r\\n' +\n '<h2>Samarbeid<\\/h2>\\r\\n' +\n '<p>&nbsp;<\\/p>'\n end\n else\n\n if(options[:language] && options[:language] == :english) then\n html = '<h2>Tasks performed<\\/h2>\\r\\n' +\n '<p>Add information about job duties, as a short text or a bulleted list:<\\/p>' +\n '\\r\\n<ul>\\r\\n' +\n ' <li>&lt;Task 1&gt;<\\/li>\\r\\n' +\n ' <li>&lt;Task 1&gt;<\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Background<\\/h2>\\r\\n' +\n '<p>Add information about previous education and employment.<\\/p>'\n else\n html = '<h2>Arbeidsomr&aring;der<\\/h2>\\r\\n' +\n '<p>Her kan du skrive om arbeidsomr&aring;der, ' +\n 'enten som kort tekst eller som listepunkter:</p>' +\n '\\r\\n' +\n '<ul>\\r\\n' +\n ' <li>&lt;Arbeidsomr&aring;de 1&gt;</li>\\r\\n' +\n ' <li>&lt;Arbeidsomr&aring;de 1&gt;</li>\\r\\n' +\n ' <li>...</li>\\r\\n' +\n '</ul>' +\n '\\r\\n' +\n '<h2>Bakgrunn</h2>\\r\\n' +\n '<p>Eventuelt kort om tidligere arbeidserfaring og utdanning.</p>'\n end\n end\n return html\n end", "def title\n if request.path =~ /services/\n \"Singapore Web Design, Web Development, Iphone, Facebook, Twitter Apps Development Company | Hosting Services | Ruby on Rails\"\n elsif request.path =~ /portfolio/\n \"Web and Facebook Applications | eCommerce | CMS | Website Design Projects | Ruby on Rails\"\n elsif request.path =~ /partners/\n \"Microsoft Innovation Center Vietnam | Anideo Singapore | Singapore Start-up Businesses\"\n elsif request.path =~ /contact/ or request.path =~ /send_email/\n \"Singapore Web Design, Web Development, Iphone, Facebook, Twitter Apps Development Company | Hosting | Ruby on Rails\"\n else\n \"Vinova Singapore | CMS | eCommerce | Web Design and Development Company | Ruby on Rails\"\n end\n end", "def initialize(*tags)\n @tags = tags.map{|tag| \"/tag/#{tag}\" }\n @wrap_tag = \"html\"\n end", "def taggings_with_slugs(links)\n links_with_slugs = {}\n\n # We still call topics \"specialist sectors\" in rummager.\n links_with_slugs[\"specialist_sectors\"] = links[\"topics\"].to_a.map do |content_item|\n content_item[\"base_path\"].sub(\"/topic/\", \"\")\n end\n\n links_with_slugs[\"mainstream_browse_pages\"] = links[\"mainstream_browse_pages\"].to_a.map do |content_item|\n content_item[\"base_path\"].sub(\"/browse/\", \"\")\n end\n\n links_with_slugs[\"organisations\"] = links[\"organisations\"].to_a.map do |content_item|\n content_item[\"base_path\"].sub(\"/government/organisations/\", \"\").sub(\"/courts-tribunals/\", \"\")\n end\n\n links_with_slugs[\"primary_publishing_organisation\"] = links[\"primary_publishing_organisation\"].to_a.map do |content_item|\n content_item[\"base_path\"].sub(\"/government/organisations/\", \"\").sub(\"/courts-tribunals/\", \"\")\n end\n\n links_with_slugs[\"taxons\"] = content_ids_for(links, \"taxons\")\n\n links_with_slugs\n end", "def replace_slugs(markdown, toc_map)\n markdown.gsub(/(\\[\\[slug:)(.+?)(\\]\\])/) {\n if $2.start_with?('en:')\n val = \"[[#{$2}]]\"\n elsif toc_map.key?($2)\n itm = toc_map[$2]\n href = get_page_from_anchor(itm[:href])\n val = '<a href=\"%s\">%s</a>' % [href, itm[:title]]\n else\n val = \"#{$1}#{$2}#{$3}\"\n msg = \"ERROR: Not able to find slug \\\"#{$2}\\\" in TOC.\"\n print_error_msg(msg)\n end\n val\n }\n end", "def show\n\n @main_SEO_title = @show.name\n \n end", "def head_content\n meta 'http-equiv' => 'content-type', :content => 'text/html;charset=UTF-8'\n title page_title\n end", "def slug_generator_class=(_arg0); end", "def pick_template_for_etag(options); end", "def render_page_title\n (sanitize(content_for(:page_title), tags: []) if content_for?(:page_title)) || sanitize(@page_title, tags: []) || application_name\n end", "def tag\n # Whats the last tag we are asking for? (the rest don't matter I don't think..)\n requested_tag = params[:tag].split(\"/\").last\n tag = Taxonomy.find_by_seo_url requested_tag\n\n if tag.present?\n @tag = tag\n @posts = get_posts tag.posts\n\n\n respond_to do |format|\n format.html { render :template => 'default/index' }\n format.json { render json: @posts }\n end\n else\n # No such category found, redirect to root index\n redirect_to root_path\n end\n end", "def set_seo_params\n @seo = {\n :title => ::Setting::get('Title for index page'),\n :keywords => ::Setting::get('Keywords for index page'),\n :description => ::Setting::get('Description for index page')\n }\n end", "def execute site\n if site.cache.nil?\n site.send('cache=', Aweplug::Cache::YamlFileCache.new)\n end\n searchisko = Aweplug::Helpers::Searchisko.new({:base_url => site.dcp_base_url, \n :authenticate => true, \n :searchisko_username => ENV['dcp_user'], \n :searchisko_password => ENV['dcp_password'], \n :cache => site.cache,\n :logger => site.log_faraday,\n :searchisko_warnings => site.searchisko_warnings})\n Find.find @directory do |path|\n Find.prune if File.directory?(path) && !@recurse_subdirectories\n\n next if File.directory?(path) # If it's a directory, start recursing\n\n Find.prune if File.extname(path) !~ /\\.a(scii)?doc/ || @additional_excludes.include?(File.basename path)\n\n # TODO: Skip adding the page to the site if it's already there\n\n page = site.engine.load_site_page path\n page.layout = @layout\n # TODO: Set the imagedir attribute for the page\n page.output_dir = File.join(@output_dir, File.basename(page.output_path, File.extname(page.output_path))).downcase\n page.output_path = File.join(page.output_dir, 'index.html')\n\n doc = Asciidoctor.load_file path\n metadata = {:author => doc.author, \n :commits => commit_info(@repo, path), \n :current_tag => current_tag(@repo, path),\n :current_branch => current_branch(@repo, path),\n :title => doc.doctitle, \n :tags => doc.attributes['tags'],\n :toc => doc.sections.inject([]) {|result, elm| result << {:id => elm.id, :text => elm.title}; result},\n :github_repo_url => repository_url(@repo),\n # Will need to strip html tags for summary\n :summary => doc.sections.first.blocks.first.content,\n :searchisko_type => 'jbossdeveloper_example',\n :searchisko_id => Digest::SHA1.hexdigest(doc.doctitle)[0..7],\n }\n\n site.pages << page\n\n searchisko_hash = {\n :sys_title => metadata[:title], \n :sys_description => metadata[:summary],\n :sys_content => doc.render, \n :sys_url_view => \"#{site.base_url}#{site.ctx_root.nil? ? '/' : '/' + site.ctx_root + '/'}#{page.output_dir}\",\n :contributors => metadata[:commits].collect { |c| c[:author_email] }.unshift(metadata[:author]).uniq,\n :sys_created => metadata[:commits].collect { |c| DateTime.parse c[:date] }.last,\n :sys_activity_dates => metadata[:commits].collect { |c| DateTime.parse c[:date] },\n } \n\n @additional_metadata_keys.inject(searchisko_hash) do |hash, key|\n hash[key.to_sym] = doc.attributes[key]\n hash\n end\n\n # unless !@push_to_searchisko || site.profile =~ /development/\n # searchisko.push_content(metadata[:searchisko_type],\n # metadata[:searchisko_id],\n # searchisko_hash.to_json)\n # end\n page.send('metadata=', metadata)\n end\n end", "def title_tag\n content_tag :title, title_text.to_s\n end", "def old_heading match\n if match[:had_slug?]\n \"<h#{match[:level]} id=\\\"#{match[:slug]}\\\">#{match[:title]}</h#{match[:level]}>\"\n else\n \"<h#{match[:level]}>#{match[:title]}</h#{match[:level]}>\"\n end\nend", "def content_helper\n\t\tif session[:source]\n\t\t\tgreeting = \"Gracias por visitarme desde #{session[:source]}\"\n content_tag(:p, greeting, class: 'source-greeting')\n end\n # primero le pasamos el tag que queremos que tenga\n # despues el string o la variable que queremos que ponga dentro de ese tag\n # Al final la clase si es que queramos que tenga una\n #Tambien le podemos pasar argumentos a los helpers\n\tend", "def render_open_search(tags)\n open_search = meta_tags.extract(:open_search)\n return unless open_search\n\n href = open_search[:href]\n title = open_search[:title]\n\n type = \"application/opensearchdescription+xml\"\n tags << Tag.new(:link, rel: \"search\", type: type, href: href, title: title) if href.present?\n end", "def render_content(content = nil)\n content = cms_layout.content.dup if !content\n while (!(tags = CmsTag::parse_tags(content, :page => self).sort_by{|t| t.class.render_priority}).blank?)\n tags.each do |tag|\n content.gsub!(tag.regex) { tag.render }\n end\n end\n content\n end", "def title_tag_content(page_title: '')\n base_title = COMPETITIONS_CONFIG[:application_name]\n page_title.empty? ? base_title : \"#{page_title} | #{base_title}\"\n end", "def generate_seo_option_name\n self.name = self.name.to_url\n end", "def parse_tag_with_types_and_title(tag_name, text); end", "def meta name, contents\n Tagz.tag :meta, :name => name, :contents => contents \n end", "def partial\n \"/otus/page/tags_on_otu_by_keyword\"\n end", "def logo_tag\n image_tag \"rails.png\", :alt => @page_title\n end", "def set_titles\n DynamicUrl.all.each do |url|\n if request.host == url.url\n @title = url.title\n @subtitle = url.subtitle\n end\n end\n\n # set default title if title could not be fetched\n @title ||= MySettings.title\n @subtitle ||= MySettings.subtitle\n end", "def name_seo_display\n (self.name_seo[I18n.locale].present?) ? self.name_seo[I18n.locale].parameterize : \"-\"\n end", "def prepare_html(content , page_type = 'N')\n #header\n 1.upto 5 do |no| content.gsub! /^(={#{no}}) (.*) (={#{no}})/ ,\"\\nh#{no+1}. \\\\2\\n\" end\n 1.upto 5 do |no| content.gsub! /^(={#{no}}) (.*)/ ,\"\\nh#{no+1}. \\\\2\\n\" end\n\n #list\n 1.upto 5 do |no| content.gsub! /^([ ]{#{no}})(\\*) ?(.*)/ ,\"#{'*'*no} \\\\3\" end\n 1.upto 5 do |no| content.gsub! /^([ ]{#{no}})(#) ?(.*)/ ,\"#{'#'*no} \\\\3\" end\n #content.gsub! /(\\*) v (.*)/ , \"\\\\1 -\\\\2-\"\n \n #block\n content.gsub! /^\\{\\{\\{/ , \"<pre>\" ; content.gsub! /^\\}\\}\\}/ , \"</pre>\"\n content.gsub! /^\\{\\{\\\"/ , \"<blockquote>\" ; content.gsub! /^\\\"\\}\\}/ , \"</blockquote>\"\n content.gsub! /^\\{\\{\\[/ , \"<math>\" ; content.gsub! /^\\]\\}\\}/ , \"</math>\"\n \n #concept & property\n content.gsub! /\\[\\[(.*?):=(.*?)\\]\\]/ , '\\1(\\2)'\n #content.gsub! /\\[\\[(.*?)[<>=].*?\\]\\]/ , \\\"\\\\1\\\":#{APP_ROOT}/page/\\\\1\" \n content.gsub! /\\[\\[(.*?)\\]\\]/ , \"\\\"\\\\1\\\":#{APP_ROOT}/entry/\\\\1\" if defined?(APP_ROOT)\n\n #comment\n content.gsub! PTN_COMMENT , \"\\\\1\"\n content.gsub! PTN_COMMENT_MULTILINE , \"\"\n if defined? SystemConfig\n SystemConfig.site_info.each do |e|\n content.gsub! /(\\s)#{e[1]}:/ , \"\\\\1#{e[2]}\"\n end\n content.gsub! SystemConfig.ptn_url_unnamed , \"\\\\1\\\"\\\\2\\\":\\\\2\"\n content.gsub! \"%ROOT%\" , APP_ROOT\n end\n \n #Process by page_type\n case page_type\n when 'N'\n math_list = content.scan( PTN_MATH ) ; math_list.each do |m|\n #content.gsub! \"$#{m[0]}$\" , latex_render(m[0])\n content.gsub! \"$#{m[0]}$\" , get_math_img(m[0])\n end\n math_block_list = content.scan( PTN_MATH_BLOCK ) ; math_block_list.each do |m|\n #content.gsub! \"#{m[0]}\" , latex_render(m[0])\n content.gsub! \"#{m[0]}\" , get_math_img(m[0])\n end\n when 'S'\n menu_list = content.scan( PTN_MENU ) ; menu_list.each do |m|\n menu_title = m[0] ; menu_target = m[1] ; menu_str = \"M{{#{menu_title}|#{menu_target}}}\"\n #$lgr.info \"#{menu_title} / #{menu_target}\"\n result = link_to_remote(menu_title , :url => { :action => 'menu' , :query => CGI.escape(menu_target) })\n content.gsub! menu_str , result\n end\n end\n #$lgr.info \"[prepare_html] \"+content\n query_list = content.scan( PTN_QUERY ) ; query_list.each do |q|\n query_type = q[0] ; query_content = q[1] ; query_str = \"#{query_type}{{#{query_content}}}\"\n case query_type\n when 'P'\n result = eval(\"find_page :display=>'|@title|@tags|@created_at|' ,\" + query_content )\n result = result.join(\"\\n\") if result.class == Array\n result = \"|_.Title|_.Tag|_.CreatedAt|\\n\"+result if query_content.scan(/:display/).size == 0\n #$lgr.info \"[prepare_html] Query : #{query_str} , #{result}\"\n content.gsub! query_str , result\n end\n end\n #content.gsub! SystemConfig.ptn_url , \"\\\"\\\\0\\\":\\\\0\"\n #???content.gsub!(SystemConfig.ptn_site) \"\\\"#{ApplicationController.SystemConfig(\\\\0)}\\\":\\\\0\"\n content\n end", "def editing_help(editing_help_type)\n case editing_help_type\n when 'Partial'\n help = '<h4>Useful tags</h4>'\n help << '<p><code><%= navigation %></code><br />'\n help << '<code><%= page.page_title %><c/ode><br />' \n help << '<code><%= stylesheet_link_tag \"stylename\" %></code><br />' \n help << '<code><%= javascript_include_tag \"scriptname\" %></code><br />' \n help << '<code><%= region :example %></code></p>' \n # help << '<h4>Tags for this Custom Type</h4>'\n when 'Layout' \n help = '<h4>Useful tags</h4>'\n help << '<p><code><%= navigation %></code><br />'\n help << '<code><%= page.page_title %><c/ode><br />' \n help << '<code><%= stylesheet_link_tag \"stylename\" %></code><br />' \n help << '<code><%= javascript_include_tag \"scriptname\" %></code><br />' \n help << '<code><%= region :example %></code></p>' \n end\n end", "def existing_tags\n Notion.where(locale: @lecture.locale || I18n.default_locale)\n .pluck('title') & @content_descriptions\n end", "def show\n @title = \"#{@press_release.title} - Think India NITR club\"\n @description = ActionController::Base.helpers.strip_tags(@press_release.article)[0..200] \n end", "def show\n @page_title = @blog.title\n # this works because of the before_action method that calls set_blog to retrieve the actual blog title\n @seo_keywords = @blog.body\n end", "def send_to_searchisko(metadata, page, site, converted_html)\n metadata[:searchisko_id] = Digest::SHA1.hexdigest(metadata[:title])[0..7]\n metadata[:searchisko_type] = 'jbossdeveloper_quickstart'\n\n searchisko_hash = {\n :sys_title => metadata[:title], \n :level => metadata[:level],\n :tags => metadata[:technologies],\n :sys_description => metadata[:summary],\n :sys_content => converted_html, \n :sys_url_view => \"#{site.base_url}#{site.ctx_root.nil? ? '/' : '/' + site.ctx_root + '/'}#{page.output_path}\",\n :contributors => metadata[:contributors_email],\n :author => metadata[:author],\n :sys_created => metadata[:commits].collect { |c| DateTime.parse c[:date] }.last,\n :sys_activity_dates => metadata[:commits].collect { |c| DateTime.parse c[:date] },\n :target_product => metadata[:target_product],\n :github_repo_url => metadata[:github_repo_url],\n :experimental => metadata[:experimental]\n } \n\n # Not sure if it's better to do this once per class, \n # once per site, or once per invocation\n searchisko = Aweplug::Helpers::Searchisko.new({:base_url => site.dcp_base_url, \n :authenticate => true, \n :searchisko_username => ENV['dcp_user'], \n :searchisko_password => ENV['dcp_password'], \n :cache => site.cache,\n :logger => site.log_faraday,\n :searchisko_warnings => site.searchisko_warnings})\n\n searchisko.push_content(metadata[:searchisko_type], \n metadata[:searchisko_id], \n searchisko_hash.to_json)\n end", "def site_description\n headings = @doc.xpath(\"//h3[@class='clearl']\")\n content_sections = @doc.xpath(\"//h3[@class='clearl']/following-sibling::p[1]\")\n content = \"\"\n headings.zip(content_sections).each do |h, c| \n unless (c.to_s().squeeze().empty?)\n content << \"<h3>#{sanitize(h.to_s)}</h3>\" \n content << \"<p>#{sanitize(c.to_s)}\"\n end\n end\n rhtml = IO.read(File.expand_path(\"site_description.rhtml\", File.dirname(__FILE__)))\n content_html = Erubis::Eruby.new(rhtml)\n content_html.result(:content => content)\n end", "def abstract_tag(text); end" ]
[ "0.6205917", "0.60901994", "0.60728276", "0.60494053", "0.599405", "0.58108777", "0.5797078", "0.5694372", "0.569129", "0.5674238", "0.5668645", "0.5616299", "0.5606037", "0.558438", "0.55697536", "0.55638504", "0.5536742", "0.5536026", "0.55350375", "0.5528014", "0.55126846", "0.54896873", "0.54896337", "0.5469241", "0.5449905", "0.5427153", "0.54269487", "0.5416608", "0.5411013", "0.5375221", "0.5374132", "0.5336848", "0.5335006", "0.5322419", "0.53180754", "0.53158617", "0.53112096", "0.53100437", "0.53079224", "0.52679765", "0.5261011", "0.52604693", "0.52580607", "0.52524257", "0.52424264", "0.5238656", "0.5225363", "0.5218894", "0.52143425", "0.52007735", "0.5197437", "0.5196254", "0.51940525", "0.5189649", "0.516783", "0.51625013", "0.5157681", "0.5157681", "0.51551205", "0.5154098", "0.5142334", "0.51421463", "0.51346236", "0.51313853", "0.5130447", "0.51273197", "0.51259696", "0.5117169", "0.5115514", "0.5109856", "0.51064837", "0.5103041", "0.51012975", "0.50999385", "0.5093365", "0.50907826", "0.5090108", "0.5090061", "0.5083394", "0.507972", "0.5078823", "0.5077314", "0.50767094", "0.506933", "0.50680953", "0.5064937", "0.5061082", "0.5057829", "0.5055866", "0.5054204", "0.5052181", "0.5042694", "0.50387347", "0.503054", "0.5029057", "0.5028498", "0.50233096", "0.50157124", "0.50150293", "0.5008696" ]
0.55816007
14
Gets the current type attribute's value
def type self['type'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type\n self.attributes[:type]\n end", "def type\n @attributes[:type]\n end", "def type\n @attributes[:type]\n end", "def type\n @attributes[:type]\n end", "def type\n @attributes[:type]\n end", "def value_type\n @type.value_type\n end", "def type\n attr_val('./@typeCode')\n end", "def type\n @attributes.fetch('type', nil)\n end", "def type\n read_attr :type, :to_sym\n end", "def _type\n special_attribute('@type'.freeze)\n end", "def value(instance = nil)\n if nil == instance\n return attribute_type\n end\n attribute_type.new(instance, @options.merge({\n :cls => model,\n :type => type,\n :name => name\n }))\n end", "def value_type\n return @value_type\n end", "def type\n self[:type]\n end", "def type\n self[:type]\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def value\n send property.type_field\n end", "def type\n self['type']['type']\n end", "def current_type\n @type\n end", "def value\n attributes.fetch(:value)\n end", "def value\n @attributes[:value]\n end", "def type\n self['TYPE'].to_i\n end", "def type\n @type\n end", "def type\n @@type\n end", "def type\n @@type\n end", "def type\n @type\n end", "def type\n @type\n end", "def type\n @type\n end", "def type\n @type\n end", "def type\n @type\n end", "def type_name\n self['type_name']\n end", "def type\n self.class::TYPE\n end", "def type\n\t\t@type\n\tend", "def attribute_type(x)\n self.class.attribute_type qualified_name(x)\n end", "def type\n return @type if @type != \"unknown\"\n info\n @type\n end", "def type\n @type.to_s\n end", "def type\n @type.name\n end", "def type\n\t\t\t@data[\"type\"]\n\t\tend", "def value\n to_type(@value)\n end", "def type\n @data['type']\n end", "def type\n Attribute::Float\n end", "def type\n Attribute::Float\n end", "def type\n @data['type']\n end", "def fetch_upstream_primitive(attr)\n registered_properties[attr].type\n end", "def type; self._type; end", "def attribute_value\n @attributes.each { | id, value | return value }\n end", "def type\n data.type\n end", "def type\n\t\tself.class.type\n\tend", "def type\n\t\tself.class.type\n\tend", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n _type\n end", "def type\n Attribute.infer_type(operand)\n end", "def get_type()\n res = super(context,self)\n return res\n end", "def get_type\n\n end", "def type\n @type ||= calculate_type\n end", "def type\n field[:type]\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n @props[:type]\n end", "def data_type\n return @data_type\n end", "def dynamo_attribute_definition_type\n dynamo_attribute_value_type_key.to_s.upcase\n end", "def type\n return constant_value_type\n end", "def value\n self[@name]\n end", "def attribute_type\n (float? || integer? || text? || boolean? ? field_type : 'string').to_sym\n end", "def _type\n self.class.to_s\n end", "def type\n @node[\"type\"]\n end", "def type\n self.class.type_to_string(self)\n end", "def type_of_2fa\n @attributes[:type_of_2fa]\n end", "def attribute_get(name)\n @attributes[:current][name]\n end", "def attribute(name)\n current_attributes[name]\n end", "def get_value(value) #method\n if is_memory(value)\n @current_context[value]\n else\n digested_value = digest_constant(value)\n if is_number(digested_value)\n get_type(digested_value)\n elsif is_bool(digested_value)\n get_type(digested_value)\n else\n digested_value\n end\n end\n end", "def type\n raw_data['type']\n end", "def type_code\n type.try(:code)\n end", "def type_value\n master_class.base_class.name if polymorphic_type\n end", "def object_value(dynamo_data)\n dynamo_data[dynamo_attribute_key].send dynamo_attribute_value_type_key\n end", "def get_typePont\n return @typePont\n end", "def get_attribute_value(attribute)\n values = read_attr_val(attribute.id)\n return nil unless values\n if attribute.atype == ProductAttribute::Atype_String\n return values[0]\n elsif attribute.atype == ProductAttribute::Atype_Currency\n MoneyUtils.format(values[1])\n else\n return Integer(values[1])\n end\n end", "def human_type\n self[:type].to_human\n end", "def event_type\n @attributes[:event_type]\n end", "def typecast_attribute(type, value)\n raise ArgumentError, \"a Class must be given\" unless type\n return value if value.nil?\n typecast_value(type, value)\n end", "def type\n TYPES[@type_id]\n end", "def type_for_attribute(attr_name)\n attr_name = attr_name.to_s\n attribute_types[attr_name]\n end", "def type_for_attribute(attr_name)\n attr_name = attr_name.to_s\n attribute_types[attr_name]\n end", "def type_for_attribute(attr_name)\n attr_name = attr_name.to_s\n attribute_types[attr_name]\n end", "def get_data_type\n get_field_config['type']\n end", "def type\n self.class\n end", "def record_type\n attributes['item_type']\n end", "def type\n data['type'].to_sym\n end" ]
[ "0.78003544", "0.77100164", "0.7668282", "0.7668282", "0.7668282", "0.75117207", "0.7466865", "0.7422981", "0.7300822", "0.7290232", "0.71729934", "0.7155426", "0.71400565", "0.71258974", "0.70320106", "0.70320106", "0.70320106", "0.70320106", "0.70320106", "0.70320106", "0.70320106", "0.698893", "0.69845915", "0.697037", "0.6935619", "0.68897045", "0.68887365", "0.68562967", "0.68502975", "0.6797649", "0.6797649", "0.6780016", "0.67600584", "0.6759157", "0.6759157", "0.6759157", "0.67566204", "0.6726099", "0.6718027", "0.67072546", "0.6706576", "0.667771", "0.6666478", "0.6647815", "0.664677", "0.66456777", "0.66231585", "0.66231585", "0.661458", "0.65858966", "0.6564648", "0.6554722", "0.6547415", "0.6541806", "0.6541806", "0.65382105", "0.65382105", "0.65382105", "0.6506262", "0.6506262", "0.6506262", "0.64928997", "0.6443115", "0.6381714", "0.6381099", "0.6379536", "0.63748974", "0.6370922", "0.6370922", "0.6370922", "0.6344649", "0.6321024", "0.63036495", "0.62976444", "0.62957567", "0.62937367", "0.6280311", "0.62732774", "0.627165", "0.62639946", "0.62510294", "0.6239313", "0.62372863", "0.6223069", "0.62195665", "0.6217608", "0.6213423", "0.62037593", "0.6199092", "0.61940444", "0.61868685", "0.61690366", "0.61649245", "0.6153181", "0.6153181", "0.6153181", "0.6142626", "0.61390805", "0.61317873", "0.6131389" ]
0.704443
14
Sets the type attribute's value
def type=(type) self['type'] = type end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type=(type)\n write_attr :type, type\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def type=(value)\n @type = value\n end", "def set_type(val)\n self.type = val\n self\n end", "def set_type(v)\n self.type = v\n self\n end", "def type=(value)\n @type = value.to_sym\n end", "def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n write_attr :type, type\n end", "def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n write_attr :type, type\n end", "def type=(type)\n @type = type\n end", "def type=(val)\n @type = val.to_sym\n end", "def type(val); @type = val; self; end", "def type=(type)\n validate_type_values(type)\n @type = type\n end", "def type=(type)\n @type = type\n end", "def type=(type)\n @type = type.to_sym\n end", "def type=(type); end", "def type=(type)\n @type = type\n\n setOption('type', @type)\n end", "def type=(type)\n @type = type\n end", "def set_type\n end", "def set_Type(value)\n set_input(\"Type\", value)\n end", "def set_Type(value)\n set_input(\"Type\", value)\n end", "def type=(new_type)\n @type = new_type.to_sym\n end", "def set_Type(value)\n set_input(\"Type\", value)\n end", "def set_Type(value)\n set_input(\"Type\", value)\n end", "def type=(type)\n @@type = type\n end", "def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end", "def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end", "def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end", "def type=(type)\n Munson.register_type(type, self)\n munson.type = type\n end", "def class_type=(value)\n\t\tself[:type] = value\n\tend", "def type=(type)\n validator = EnumAttributeValidator.new('String', ['Once', 'Hourly', 'Daily', 'Weekly', 'Monthly', 'Yearly'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', ['string', 'number', 'boolean', 'date', 'address', 'country', 'email', 'url', 'image', 'signature', 'barcode', 'combined'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', ['String', 'Number', 'Date'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"random\", \"hash\", \"client\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type=(new_type)\n self[:type_flags] = (flags | TYPES[new_type])\n end", "def value_type=(value)\n @value_type = value\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', ['digital', 'physical'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end", "def type value\n @settings[:type] = value\n return self\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', ['active', 'notActive', 'unknown'])\n unless validator.valid?(type)\n fail ArgumentError, %Q'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end", "def type=(type)\n type = type.intern\n super type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"NFS\", \"SMB\", \"iSCSI\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"Agreement\", \"CreditMemo\", \"DownPayment\", \"Miscellaneous\", \"Progress\", \"Standard\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type_name=(val)\n self['type_name'] = val\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', ['Title', 'Body', 'CenteredTitle', 'Subtitle', 'DateAndTime', 'SlideNumber', 'Footer', 'Header', 'Object', 'Chart', 'Table', 'ClipArt', 'Diagram', 'Media', 'SlideImage', 'Picture'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end", "def data_type=(value)\n @data_type = value\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"ITEM\", \"CATEGORY\", \"ITEM_VARIATION\", \"TAX\", \"DISCOUNT\", \"MODIFIER_LIST\", \"MODIFIER\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type= new_type\n frozen_check!\n @gapi.type = new_type\n end", "def type= new_type\n frozen_check!\n @gapi.type = new_type\n end", "def type= new_type\n @gapi.update! type: verify_type(new_type)\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', ['Shape', 'Chart', 'Table', 'PictureFrame', 'VideoFrame', 'AudioFrame', 'SmartArt', 'OleObjectFrame', 'GroupShape', 'GraphicalObject', 'Connector', 'SmartArtShape', 'ZoomFrame', 'SectionZoomFrame', 'SummaryZoomFrame', 'SummaryZoomSection'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"person\", \"business\"])\n unless validator.valid?(type) || type.empty?\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"Weekly\", \"BiWeekly\", \"SemiMonthly\", \"Monthly\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"PHYSICAL\", \"MOBILE\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def bar_type=(s)\n self[:type] = s\n end", "def record_type(t)\n @type = t\n end", "def value_type= value_type\n self.type = value_type.gsub(\"-\", \"_\").camelize\n end", "def set_type(name)\n @type = name\n ProcessRecord::TYPE_TABLE[name] = self\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"Paragraph\", \"Character\", \"Table\", \"List\"])\n if type.to_i == 0\n unless validator.valid?(type)\n raise ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n else\n @type = validator.allowable_values[type.to_i]\n end\n end", "def of_type(type)\n options[:type] = type\n self\n end", "def type_setter\n @type_setter ||= type.__setter__\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"\", \"APIC\", \"DCNM\", \"UCSFI\", \"UCSFIISM\", \"IMC\", \"IMCM4\", \"IMCM5\", \"IMCRack\", \"UCSIOM\", \"HX\", \"HyperFlexAP\", \"IWE\", \"UCSD\", \"IntersightAppliance\", \"IntersightAssist\", \"PureStorageFlashArray\", \"UCSC890\", \"NetAppOntap\", \"NetAppActiveIqUnifiedManager\", \"EmcScaleIo\", \"EmcVmax\", \"EmcVplex\", \"EmcXtremIo\", \"VmwareVcenter\", \"MicrosoftHyperV\", \"AppDynamics\", \"Dynatrace\", \"NewRelic\", \"ServiceNow\", \"ReadHatOpenStack\", \"CloudFoundry\", \"MicrosoftAzureApplicationInsights\", \"OpenStack\", \"MicrosoftSqlServer\", \"Kubernetes\", \"AmazonWebService\", \"AmazonWebServiceBilling\", \"MicrosoftAzureServicePrincipal\", \"MicrosoftAzureEnterpriseAgreement\", \"DellCompellent\", \"HPE3Par\", \"RedHatEnterpriseVirtualization\", \"NutanixAcropolis\", \"HPEOneView\", \"ServiceEngine\", \"HitachiVirtualStoragePlatform\", \"IMCBlade\", \"TerraformCloud\", \"TerraformAgent\", \"CustomTarget\", \"AnsibleEndpoint\", \"HTTPEndpoint\", \"SSHEndpoint\", \"CiscoCatalyst\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"PricingComponent\", \"Coupon\", \"Migration\", \"AggregatedInvoice\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def device_type=(s)\n self[:type] = s\n end", "def device_type=(s)\n self[:type] = s\n end", "def device_type=(s)\n self[:type] = s\n end", "def type=(type)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\" if type && !VALID_TYPES.include?(type.to_sym)\n super\n end", "def type=(type)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\" if type && !VALID_TYPES.include?(type.to_sym)\n super\n end", "def set_type_of_value\n @type_of_value = TypeOfValue.find(params[:id])\n end", "def type=(val)\n @type = val.to_sym if %w(UNSPECIFIED MEDIA MASTER).include? val.to_s\n end", "def type(value_=nil)\n if value_\n @type = value_\n else\n @type\n end\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"Subscription\", \"FixedTerm\", \"Trial\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"Subscription\", \"FixedTerm\", \"Trial\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n super\n end", "def type=(type)\n allowed_values = [\"STRING\", \"BOOLEAN\", \"DECIMAL\", \"INTEGER\", \"DATE_TIME\", \"REFERENCE\", \"COMPLEX\"]\n if type && !allowed_values.include?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{allowed_values}.\"\n end\n @type = type\n end", "def update_value_type\n write_attribute :value_type, EavEntry.get_value_type(@value)\n end", "def type=(value)\n @type = value\n self << \"#{self.var}.setMapType(#{value.to_map_type});\"\n end", "def set_type\n @type = Type.find(params[:id])\n end", "def set_type\n @type = Type.find(params[:id])\n end", "def set_type\n @type = Type.find(params[:id])\n end", "def type=(type)\n if !type.nil? && type.to_s.length > 100\n fail ArgumentError, 'invalid value for \"type\", the character length must be smaller than or equal to 100.'\n end\n @type = type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"fc-initiator\", \"fc-nvme-initiator\", \"fc-nvme-target\", \"fc-target\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def type= (type)\n self.tweet_type = type\n end", "def set_typecode(v)\n @typecode = v\n end", "def tag_type=(value)\n @tag_type = value\n end", "def type(type)\n opts[:type] = type\n end", "def set_type\n @type = Type.find(params[:id])\n\n end", "def _type\n special_attribute('@type'.freeze)\n end", "def data_type(data_type)\n state_depth_must_be(States::ATTRIBUTE)\n raise 'data_type already defined' if @current_attribute.data_type\n @current_attribute.data_type = data_type\n end", "def type=(type)\n @type = type\n @signed = type.name.split('::').last[0] != \"U\"\n type\n end", "def type=(type)\n validator = EnumAttributeValidator.new('String', [\"alert\", \"notification\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end", "def set_type sym, type\n @types[sym] = type\n end", "def type=(val)\n if (val.kind_of?(Integer))\n @type = val & 0xff\n elsif(val.kind_of?(String))\n raise ArgumentError, \"Value should be 1-byte, but was #{val.length}.\" if (val.length != 1) \n @type = val.unpack('C')[0]\n else\n raise ArgumentError, \"Expected String or Integer, but #{val.class} provided.\" \n end\n end", "def type=(value)\n if value == @defaults['ai.device.type']\n @values.delete 'ai.device.type' if @values.key? 'ai.device.type'\n else\n @values['ai.device.type'] = value\n end\n end", "def entity_type=(value)\n @entity_type = value\n end", "def reference_type=(value)\n write_attribute(:reference_type, value) unless value.blank?\n end", "def set_type(qualified_name, type)\n @types[qualified_name] = type\n end" ]
[ "0.86953473", "0.8539794", "0.8539794", "0.8539794", "0.8539794", "0.8539794", "0.8539794", "0.8539794", "0.8466387", "0.8302757", "0.8230761", "0.8181526", "0.817837", "0.8114125", "0.80668706", "0.80517", "0.805084", "0.80491745", "0.8015288", "0.7978776", "0.7974479", "0.79567933", "0.7945556", "0.7939791", "0.7939791", "0.7937511", "0.7929468", "0.7929468", "0.7921739", "0.7874296", "0.7874296", "0.7874296", "0.7748051", "0.7693008", "0.76913595", "0.7635954", "0.7631852", "0.75420433", "0.7538631", "0.7530852", "0.7518952", "0.74925226", "0.7466976", "0.7452605", "0.7427137", "0.74132776", "0.74068123", "0.7402109", "0.7390002", "0.73824644", "0.73714197", "0.73714197", "0.73644763", "0.7359979", "0.7352162", "0.7338087", "0.732973", "0.73248994", "0.73225653", "0.7293594", "0.7281153", "0.72740436", "0.7269127", "0.7257055", "0.72490764", "0.72489935", "0.72388947", "0.7237433", "0.7233302", "0.7230604", "0.7230604", "0.72250456", "0.7215061", "0.7207932", "0.719621", "0.719621", "0.71957964", "0.71868277", "0.71587837", "0.7152882", "0.7141892", "0.7141892", "0.7141892", "0.71199167", "0.71178323", "0.7108208", "0.7104904", "0.7075113", "0.7054302", "0.70384175", "0.70372456", "0.7017992", "0.69937634", "0.6983729", "0.6982168", "0.6980758", "0.69676715", "0.6951886", "0.69328666", "0.69067204" ]
0.8063848
15
Gets the current value attribute's value
def value self['value'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value\n @attributes[:value]\n end", "def value\n attributes.fetch(:value)\n end", "def current_value\n @value\n end", "def get_value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n return @value\n end", "def value\n return @value\n end", "def value\n return @value\n end", "def get\n @value\n end", "def value\r\n @value\r\n end", "def get_value\n value\n end", "def get_value\n value\n end", "def value\n return @val\n end", "def attribute_value\n @attributes.each { | id, value | return value }\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def value\n @value\n end", "def get_value\n @value \n end", "def get\n val\n end", "def get\n val\n end", "def value \n @value\n end", "def value\n return @children['value'][:value]\n end", "def value\n data.value\n end", "def value\n self\n end", "def value\n @value ||= extract_value\n end", "def current_value; end", "def value\n parsed_value\n end", "def get_value\n read_attribute('text_value')\n end", "def value\n `#{@el}.value`\n end", "def value\n @value || default_value\n end", "def get_value name=nil\n @value\n end", "def get(value)\n value\n end", "def value\n attributes['FieldValue']\n end", "def value\n @value || ''\n end", "def value\n variable.value\n end", "def value\n self[@name]\n end", "def value\n node.value\n end", "def get_value(element)\n element.value\n end", "def get_value\n read_attribute('number_value')\n end", "def raw_value\n @value\n end", "def node_value\n return @value\n end", "def value\n Reac.value(self)\n end", "def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end", "def value\n record.send(name).value\n end", "def get\n data[\"_value\"]\n end", "def value(context)\n context[@value]\n end", "def value!\n @value\n end", "def value\n if @value_set\n @value\n else\n value_from_response\n end\n end", "def value\n @property_hash[:value]\n end", "def actual_value\n JSON.parse(self.value)['actual_value']\n end", "def value\n if @value\n @value\n else\n @value = resolve( :value )\n end\n end", "def value\n data[1]\n end", "def value\n selected&.value\n end", "def value\n bound? ? state.symbol : @value\n end", "def value(); self.data.value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value; end", "def value\n children[1]\n end", "def value\n children[1]\n end", "def value\n children[1]\n end", "def value\n children[2]\n end", "def value\n children[2]\n end", "def getBaseValue\n @base_value\n end", "def value_raw\n @value\n end", "def value() end", "def value\r\n \tbase_value = read_attribute('value')\r\n \t#\r\n \tif ! base_value.nil?\r\n \treturn YAML::load(base_value)\r\n end\r\n return nil\r\n\tend", "def fetch\n @value\n end", "def get_value\n @value.to_i\n end", "def current_value\n get_value_from_combined_key(combined_key, value_field)\n end", "def get_value\n if @value != nil\n return @value\n else\n return @df_int\n end\n end", "def value\n return self.actual\n end", "def value\n return self.actual\n end", "def value\n join and @value\n end", "def attribute_get(name)\n @attributes[:current][name]\n end", "def print_value\n\t\t\treturn @value\n\t\tend" ]
[ "0.8574868", "0.85322654", "0.8309908", "0.80959237", "0.80002624", "0.80002624", "0.79958004", "0.79958004", "0.79958004", "0.7941724", "0.7914703", "0.79025954", "0.79025954", "0.7884767", "0.7882802", "0.7803875", "0.7803875", "0.7803875", "0.7803875", "0.7803875", "0.7803875", "0.7803875", "0.77961916", "0.7723522", "0.7723522", "0.77162695", "0.77004385", "0.7637952", "0.759297", "0.7551381", "0.74767864", "0.7462434", "0.74591506", "0.74010175", "0.7397125", "0.73617285", "0.73554087", "0.73350143", "0.73346895", "0.73293114", "0.7314069", "0.73024076", "0.7238519", "0.7238436", "0.72366285", "0.72187084", "0.72131896", "0.7185674", "0.7168838", "0.7144821", "0.7132673", "0.7127778", "0.7120584", "0.7113039", "0.7112345", "0.70838034", "0.70624435", "0.7051591", "0.70397735", "0.7031139", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.70178014", "0.69975346", "0.69975346", "0.69975346", "0.6975287", "0.6975287", "0.6959438", "0.6958815", "0.69575304", "0.6956961", "0.6955182", "0.69453627", "0.69287646", "0.69027066", "0.68864024", "0.68864024", "0.68786377", "0.6868505", "0.6864029" ]
0.80789804
4
Sets the value attribute's value
def value=(value) self['value'] = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value=(value)\n @value = value\n @value_set = true\n end", "def value=(value)\n @value = value\n end", "def set_value(value)\n @value = value\n end", "def value=(value)\n @value = value\n end", "def value=(value)\n @value = value\n end", "def value=(value)\n @value = value\n end", "def value=(value)\n @value = value\n end", "def value=(value)\n `#{@element}.value = #{value}`\n end", "def set_value( value )\n @value = value \n end", "def setValue(value)\n @value = value\n end", "def value(value)\n\t\t@value=value\n\tend", "def value=(v)\n @value = v\n @value_set = true\n @value\n end", "def value=(v)\n set(v)\n end", "def set(value)\n value\n end", "def value=(val)\n self[:value] = serialize_value(val)\n end", "def value(value)\n with_attribute(:value => value)\n end", "def value=(value)\n `#{@el}.value = #{value}`\n end", "def set_value new_value\n if validate_value new_value\n @value = new_value\n end\n end", "def value=(val); end", "def value=(value)\n @value = value.nil? ? nil : _set_value(value)\n end", "def set_value(value)\n send(\"set_#{value[:type]}_value\", value)\n end", "def value=(value); self.data.value = value; end", "def value=(v)\n @value = from_type(v)\n end", "def value= value\n\t\t@value = value\n\t\trefresh\n\tend", "def value=(new_value)\n\t\t@value = new_value\n\t\tinform_obeservers\n\tend", "def value=(value)\n @changed = true if value != @value\n @value = value\n end", "def set_value\n if resolver.params.key?(name) && options.key?(resolver.params[name])\n self.value = resolver.params[name]\n else\n self.value = attributes.delete(:value)\n end\n end", "def value=(new_value)\n validate(new_value)\n @value = parse_value(new_value)\n end", "def value=(new_value)\n validate(new_value)\n @value = parse_value(new_value)\n end", "def set_value\n @value = Value.find(params[:id])\n end", "def value=(v)\n self.explicitly_set_value = true\n @casted_value = nil\n @value = v\n end", "def raw_value=(v)\n @value = v\n end", "def value=(obj)\n @value = to_value(obj)\n end", "def set_value value\n if allows? value\n @set_value_handler.call value\n end\n end", "def value= (val) ; write_attribute(:value, Marshal.dump(val)) ; end", "def value=(value)\n @value = Data.coerce_value(value, String, :to_s)\n end", "def set(val)\n @value = val\n @http_value = nil\n self\n end", "def set(value)\n execute_only(:set, value)\n end", "def set(value)\n old_value = refresh(value)\n handle_event :type => :change, :old_value => old_value, :value => @value if old_value != @value\n old_value\n end", "def set_field_value(name, value)\n\t\tend", "def value=(value)\n @object.instance_variable_set(:\"@#{@name}\",coerce(value))\n end", "def value=(value)\n @model.generic_set(@name, value ? @true_value : @false_value)\n end", "def value=(value)\n mutate(@group, @name, @params, value)\n value\n end", "def set(value)\n execute(:set, value)\n end", "def set_EntityValue(value)\n set_input(\"EntityValue\", value)\n end", "def value=(val)\n self.send :\"#{_mapped_value_column}=\", val\n end", "def with_value(value)\n options[:value] = value\n self\n end", "def set_attribute_value(attribute, value)\n\n # This product needs to have an id in order to set\n # attribute values on it.\n save! if new_record?\n\n if attribute.atype == ProductAttribute::Atype_String\n str_val = value\n int_val = nil\n elsif attribute.atype == ProductAttribute::Atype_Currency\n str_val = nil\n int_val = MoneyUtils.parse(value)\n else\n # It is possible that the admin did not fill in a value for\n # a text field, so we get an empty string for \"value\". We\n # could implement a default value for the attribute (probably\n # stored in the attribute itself, but for now just store 0.)\n str_val = nil\n if value.blank?\n int_val = 0\n else\n int_val = Integer(value)\n end\n end\n write_attr_val(attribute.id, str_val, int_val)\n\n end", "def value=(new_value)\n new_value = value_from_string(new_value) if new_value.is_a?(String)\n validate!(new_value)\n @is_explicit = true\n @value = new_value\n end", "def value=(value)\n if @value.class == value.class\n @value = value\n @updater = nil\n else\n raise \"Class of new value (#{value.class}) does not match class of current value (#{@value.class})\"\n end\n end", "def explicitly_set_value=(value)\n @explicitly_set_value = value\n end", "def update(new_value)\n self.value = new_value\n end", "def value=(new_value)\n self[:value] = new_value.to_yaml\n end", "def value=(new_value)\n self[:value] = new_value.to_yaml\n end", "def value=(value)\n @value = Puppet::ResourceApi::DataTypeHandling.mungify(\n @data_type,\n value,\n \"#{@type_name}.#{@attribute_name}\",\n Puppet::ResourceApi.caller_is_resource_app?,\n )\n end", "def value=(new_value)\n self[:value] = new_value.to_yaml\n end", "def value=(new_value)\n self[:value] = new_value.to_yaml\n end", "def as(value)\n @value = value\n end", "def set(v)\n @val = v\n end", "def value=(val)\n session.set(@name, val)\n end", "def set_value\n if resolver.params.key?(name)\n\n # Check if all values present in the options\n if multiple?\n acceptable_values = (resolver.params[name] - options.keys).empty?\n else\n acceptable_values = options.keys.include?(resolver.params[name])\n end\n\n self.value = resolver.params[name] if acceptable_values\n else\n self.value = @attributes[:value]\n end\n end", "def value=(value)\n @value = Data.coerce_value(value, Fixnum, :to_i)\n end", "def set(value)\n @mutex.synchronize { @value = value }\n end", "def value=( val )\n data[ address ] = val\n end", "def set_value(owner, value)\n if value.nil?\n raw_value = nil\n else\n raw_value = case type\n when 'string' then value.to_s\n when 'integer' then value.to_i\n when 'decimal' then value.to_f\n when 'length' then value.to_i\n when 'color' then value[1..-1].to_i(16)\n when 'percent' then value.to_f/100\n end\n end\n\n owner.set_raw_property_value(name, raw_value)\n end", "def set(value)\n case value\n when DateTime\n set(value.to_time)\n when Time\n set(value.to_i)\n when Integer\n self.val = value\n else\n self.val = value.to_i\n end\n val\n end", "def set_value(attribute_id, value)\n get_custom_value_hash\n if @custom_value_hash[attribute_id].nil?\n create_value(attribute_id, value)\n else\n if value && @custom_value_hash[attribute_id] != value\n sql = \"UPDATE #{CustomValue.table_name} SET #{Person::_(:value, :custom_value)} = '#{quote_string(value)}' \n WHERE #{Person::_(:person_id, :custom_value)} = #{id} \n AND #{Person::_(:custom_attribute_id, :custom_value)} = #{attribute_id}\"\n CustomValue.connection.execute(sql)\n @custom_value_hash[attribute_id] = value\n end\n end\n value\n end", "def set_record_value_for_attribute(record, attr, value, role = :default)\n end", "def value= (val)\n @value = (val.nil? ? 'None' : val)\n end", "def set(value)\n @value = value\n #info(@name, ' = ', value.inspect, '(type:', value.class,')')\n info('value = ', value.inspect, ' (',value.class,')')\n @changeListeners.each { |l|\n l.call(value)\n }\n TraceState.property(@name, :set, {'value' => value.inspect})\n end", "def set(value)\n @value = handler.sanitize(value)\n validate\n @value\n end", "def set(value)\n raise NotImplementedError\n end", "def set_attribute(name, value); end", "def value=(value)\n\t\tself.updated_at = Time.now\n\t\tif is_multi_object?\n\t\t\t(@value ||= []) << value\n\t\telse\n\t\t\t@value = value\n\t\tend\n\tend", "def set_attribute_value(node_id:, name:, value:)\n {\n method: \"DOM.setAttributeValue\",\n params: { nodeId: node_id, name: name, value: value }.compact\n }\n end", "def set_value(new_value, index)\n update_tag(index, new_value)\n end", "def set_to(value)\n @native.set_current_value(value)\n end", "def set(item, value)\n @items[item] ||= {:value => nil}\n @items[item][:value] = value\n @normalized = false\n value\n end", "def set(value)\n @value = value\n #info(@name, ' = ', value.inspect, '(type:', value.class,')')\n info(\"#{@name} = #{value.inspect} (#{value.class})\")\n @changeListeners.each { |l|\n l.call(value)\n }\n TraceState.property(@name, :set, {'value' => value.inspect})\n end", "def set_value(*args)\n raise ReadOnlyRecord if readonly?\n resource.set_value(*args)\n end", "def value=(newval)\n raise\n end", "def value=(value)\n self.remove_children :value\n if value\n self << (v = XMPPNode.new(:value))\n v.namespace = self.namespace\n v << value\n end\n end", "def set_value(value)\n unless value.kind_of?(String) or value == nil\n raise \"Illegal value passed to set_value!\"\n end\n\n @value = nil\n @value_string = value\n if value and value != \"\"\n @value = SimpleExpression.new(value)\n end\n\n @vartype = nil\n @depends_on = nil\n @diffeq_deps = nil\n end", "def process_attribute(key, value)\n return super unless key == :value\n\n @built[:value] = value\n nil\n end", "def value=(should)\n @property_hash[:value] = should\n end", "def value=(value)\n @block = nil\n @value = value\n end", "def update!(value:, **)\n @value = value\n self\n end", "def set(instance, value)\n set!(instance, coerce(value))\n end", "def value=(val)\n mutex.lock\n @value = val\n ensure\n mutex.unlock\n end", "def setValue(value)\n @current = value\n self.limitCurrentValue\n end", "def __overwrite_value(val)\n @__node.content = __export_to_xml(val)\n self.__value = val\n end", "def set(value)\n @value = value\n info \"#{name} = #{value.inspect} (#{value.class})\"\n @change_observers.each { |proc| proc.call(value) }\n OmfEc.experiment.log_metadata(name, value, :prop)\n end", "def set_value(opt = {})\n fail 'the value must exists !' if opt == {}\n # click @element_id\n url=@session_url + \"/element/#{@element_id}/value\"\n click=post(url,opt.to_json)\n return click\n end", "def value=(attr)\n attributes['FieldValue'] = attr unless read_only?\n end", "def set(object, value); end", "def value=(new_value)\n @value = self.lazy_proc?(new_value) ? new_value : self.coerce(new_value)\n end", "def set(instance, value)\n set!(instance, typecast(value))\n end", "def value=(val)\n replace(Array(val))\n end", "def set attribute, value\n attributes[attribute] = value\n end", "def value=(v)\n connection.set(key, v)\n end" ]
[ "0.8652245", "0.8651793", "0.86175907", "0.8599462", "0.8599462", "0.8599462", "0.8485731", "0.8447393", "0.84305567", "0.83629733", "0.8352488", "0.8293621", "0.82422143", "0.82364106", "0.8217837", "0.81796056", "0.81599414", "0.81295973", "0.8120572", "0.8077543", "0.8070282", "0.79966676", "0.78852177", "0.7854013", "0.7845128", "0.7761617", "0.7715771", "0.77142066", "0.77142066", "0.7656013", "0.76154095", "0.75608534", "0.75564635", "0.7539329", "0.75088996", "0.7485609", "0.7477968", "0.7466108", "0.7457626", "0.74252725", "0.7420055", "0.7411532", "0.7408617", "0.73821855", "0.7382029", "0.7314412", "0.7269829", "0.7256339", "0.72523975", "0.72302103", "0.7215903", "0.7199353", "0.71955836", "0.71955836", "0.71942186", "0.71857303", "0.71857303", "0.71856564", "0.7166883", "0.7153467", "0.715292", "0.71516657", "0.714645", "0.7141899", "0.71417916", "0.7130979", "0.7117917", "0.70996696", "0.7093069", "0.7090034", "0.7089731", "0.7086785", "0.70825267", "0.708244", "0.7072245", "0.7067359", "0.70479834", "0.70439804", "0.7039357", "0.7025271", "0.7024124", "0.7020465", "0.7006409", "0.69766927", "0.69674623", "0.6965895", "0.6953023", "0.69199085", "0.6919648", "0.6910122", "0.689216", "0.6887266", "0.6880845", "0.6845438", "0.68409944", "0.6825504", "0.6817615", "0.681533", "0.68091154", "0.68088573" ]
0.85437864
6
List all mailing lists
def list(options={}) response = Mailgun.submit(:get, list_url, options)["items"] || [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n @client.call(method: :get, path: 'recipient-lists')\n end", "def list\n @mailing_list.contacts(limit: 10000).map{|contact| contact.email}\n end", "def index\n @mail_lists = MailList.all\n end", "def mailboxes_list\n get \"mailboxes\"\n end", "def mailing\n gb = Gibbon.new\n @lists = Hash.new\n for i in 1..gb.lists['total'] do\n list_id = gb.lists['data'][i - 1]['id']\n name = gb.lists['data'][i - 1]['name']\n @lists[name] = []\n members = gb.list_members({:id => list_id})\n members['data'].map { |m| @lists[name].push(m['email']) }\n end\n end", "def email_list\n end", "def all\n get(\"#{domain}/mailboxes\")\n end", "def index\n @mailing_lists = MailingList.all\n @email = @mailing_lists.collect(&:email).join(\"; \")\n end", "def lists\n @links = Link.all\n @short_link = ActionMailer::Base.default_url_options[:host]\n end", "def list\n perform_request(Entities::MarketingEmail, 'newsletter/list.json')\n end", "def list(domain, opts = {}, map_mailboxes = true)\n mailboxes = call('domain.mailbox.list', domain.fqdn, opts)\n \n if map_mailboxes\n mailboxes.map! do |mailbox|\n self.new(domain, mailbox['login'])\n end\n end\n return mailboxes\n end", "def all_lists\n FfcrmMailchimp::Api.all_lists.map(&:stringify_keys).map { |list| new( list ) }\n end", "def get_mailboxes()\n begin\n mblist = @imap_client.list('', '*')\n rescue => error\n p \"ERROR getting mailboxes: #{error}\"\n return [] \n end\n\n return order_mailboxes(mblist)\n end", "def index\n @email_lists = EmailList.all\n end", "def list_all(mailbox)\n\tmailbox.list(:new) + mailbox.list(:cur)\nend", "def empty_mailing_lists\n\tbegin\n\t\tmailing_lists.each do |list_name|\n\t\t\tlist_id = Rails.configuration.mailing_lists[:mailchimp_list_ids][list_name.to_sym]\n\t\t\tr = Gibbon::Request.lists(list_id).members.retrieve params: {fields: 'members.email_address'}\n\t\t\tr['members'].try(:each) do |member|\n\t\t\t\temail = member['email_address']\n\t\t\t\tGibbon::Request.lists(list_id).members(email_md5_hash(email)).delete\n\t\t\tend\n\t\tend\n\trescue Gibbon::MailChimpError => e\n\t\tputs \"MailChimp error while deleting: #{e.title}; #{e.detail}; status: #{e.status_code}\"\n\tend\nend", "def maillist_dev\n maillist_parse(maillist_dev_file)\n end", "def mailboxes\n if @mailboxes.nil?\n list_mailboxes\n end\n @mailboxes\n end", "def mailboxes\n if @mailboxes.nil?\n list_mailboxes\n end\n @mailboxes\n end", "def mail_list\n str =\"\"\n self.users.each do |person|\n str << \"#{person.login} <#{person.email}> \\n\"\n end\n str\n end", "def list(options={})\n Mailgun.submit(:get, complaint_url, options)[\"items\"] || []\n end", "def list_url(address=nil)\n \"#{@mailgun.base_url}/lists#{'/' + address if address}\"\n end", "def maillist_prod\n maillist_parse(maillist_prod_file)\n end", "def list\n ContactDatabase.list\n end", "def get_mailboxes\n get(\"mailboxes\")\n end", "def list(opts = {})\n data, _status_code, _headers = self_mailers_list_with_http_info(opts)\n data\n end", "def lists\n @lists ||= ActsAsIcontact::Subscription.lists(:contactId => id)\n end", "def calendar_list\n logger.info(\"-- calendar list st --\") if logger\n auth unless @auth\n uri = URI.parse(CALENDAR_LIST_PATH + @email)\n res = do_get(uri, {})\n logger.info(\"-- calendar list en(#{res.message}) --\") if logger\n res\n end", "def get_mails\n gmail = Gmail.connect @current_user.login, @current_user.password\n return nil unless gmail.logged_in?\n\n mails = gmail.inbox.find :unread, after: @filter_date + 1\n sent_mails = gmail.label(\"[Gmail]/Sent Mail\").find(afetr: @filter_date + 1)\n sent_mails.each { |e| mails << e }\n mails.sort_by!(&:date)\n\n end", "def index\n all_mail_users =\n case @type\n when 'applicable'\n @recipient_list.applicable_mail_users\n when 'included'\n @recipient_list.included_mail_users\n when 'excluded'\n @recipient_list.excluded_mail_users\n end&.order(:name)\n\n @mail_users =\n if params[:page] == 'all'\n all_mail_users&.page(nil)&.per(all_mail_users&.count)\n else\n all_mail_users&.page(params[:page])\n end\n\n flash.alert = '指定のリストはありません。' if @mail_users.nil?\n end", "def email_list\n @entries.collect do |line|\n name, email = line.split(\",\")\n format_email_address name, email.chomp\n end.join(\", \")\n end", "def set_mailing_list\n @mailing_list = MailingList.find(params[:id])\n end", "def fNotificationListFrom (email)\n @users.notificationListFrom(email)\n end", "def admin_1099_received_list\n %w( [email protected] )\n end", "def lists\n client.get_lists\n end", "def index\n redirect_to mailerlists_path\n #@mailernames = Mailername.all\n end", "def mailbox_list(str, opt)\n ret = []\n split_by(Tokenizer.token(str), \",\").each do |m|\n if a1 = m.index(\"<\") and a2 = m.rindex(\">\") and a2 > a1 then\n display_name = m[0..a1-1].join(\" \")\n if opt[:decode_mime_header] then\n display_name = RFC2047.decode(display_name, opt)\n end\n mailaddr = _conv(m[a1+1..a2-1].join, opt)\n local_part, domain = mailaddr.split(/@/, 2)\n ret << RFC2822::Mailbox.new(RFC2822::AddrSpec.new(local_part, domain), _conv(display_name, opt))\n else\n local_part, domain = _conv(m.join, opt).split(/@/, 2)\n ret << RFC2822::Mailbox.new(RFC2822::AddrSpec.new(local_part, domain))\n end\n end\n return ret\n end", "def list(options={})\n Mailgun.submit(:get, campaign_url, options)[\"items\"] || []\n end", "def set_mail_list\n @mail_list = MailList.find(params[:id])\n end", "def get_email_list\n return get_townhall_list_and_url.map{|town, url| {town => get_townhall_email(url)}}\n end", "def list(domain=nil)\n if domain\n @mailgun.response = Mailgun::Base.fire(:get, @mailgun.api_url + \"/domains/#{domain}\")\n else\n @mailgun.response = Mailgun::Base.fire(:get, @mailgun.api_url + \"/domains\")[\"items\"] || []\n end\n end", "def recipient_list(workgroup)\n list = Array.new\n wrkgrpusrs = WorkgroupUser.find(:all, :conditions => {:workgroup_id => workgroup})\n wrkgrpusrs.each do |usr|\n s = User.find(:first, :conditions => {:id => usr.user_id})\n list << s.email unless s.email.nil? || s.email == \"\"\n end\n if list.length < 1\n list << \"blank@example\" #duct-tape-uber-hack an empty array of recipients breaks the mailer and cause the referral to not be sent...\n end\n return list\n end", "def announce_list(listname,domain)\n doc = request(\"announcement_list-list_subscribers\",{ \"listname\" => listname, \"domain\" => domain})\n api_error?(doc)\n (doc/:data).inject([]) { |subs, sub| subs << Subscriber.new_from_xml(sub); subs }\n end", "def proms_mailing_list_email\n \"#{gadz_tabagns}#{gadz_ans}@gadz.org\"\n end", "def get_mails()\n emails = Mail.find(:what => :first, :count => 20, :order => :asc)\n relevant = filter_mails emails\n parse_mails relevant\n end", "def list_of_messages()\n\t\t\n\t\t#Create a new request\n\t\trequest_url = \"https://www.googleapis.com/gmail/v1/users/#{@email}/messages?labelIds=Label_1&access_token=#{@access_token}\"\n\n\t\t#GET REQUEST\n\t\tresponse = RestClient.get request_url\n\t\tresponse_body = JSON.parse(response.body)\n\n\t\t#Looping through all the Messages and grabbing id\n\t\tmessages= Array.new\n\n\t\ttemp = response_body['messages']\n\t\ttemp.each do |item|\n\t\t\tmessages.push(item['id'])\n\t\tend \n\t\n\t\treturn messages\n\tend", "def lists(project_id, complete=nil)\n records \"todo-list\", \"/projects/#{project_id}/todos/lists\", :complete => complete\n end", "def all(*args, &block)\n Mail.all(*args, &block)\n end", "def all_email(email)\n content = \"\"\n address = email\n Membership.where(email: email).each do |membership|\n Task.where(group_id: membership.group_id).each do |task|\n content << \"#{task.title}\\n\"\n end\n Subtask.where(group_id: membership.group_id).each do |subtask|\n content << \"#{subtask.task.title}: #{subtask.title}\\n\"\n end\n end\n unless content.empty?\n mail(to: address, subject: \"Your Tasks\", body: content)\n end\n end", "def update_list\n\t\tif emails_changed? and from_contacts\n\t\t\temails_was_arr = emails_was.split(\",\")\n\t\t\temails_arr = emails.split(\",\")\n\t\t\tdeleted_emails = emails_was_arr.diff emails_arr\n\t\t\tadded_emails = emails_arr.diff - emails_was_arr\n\t\t\t\n\t\t\tdeleted_emails.each do |email|\n\t\t\t\tnewsletter.email_service(delete_member_from_list(email))\n\t\t\tend\n\n\t\t\tadded_emails.each do |email|\n\t\t\t\tnewsletter.email_service(add_member_to_list(email))\n\t\t\tend\n\t\tend\n\tend", "def lists\n load_user_lists\n end", "def admin_project_created_list\n %w( [email protected] )\n end", "def index\n @lists = @organization.lists.all\n end", "def index\n @mails = Mail.all\n end", "def get_email_list(email)\n mail_list_array = []\n response = get_emails(email)\n if !response.blank?\n json_body = JSON.parse(response.body)\n if !json_body[\"items\"].blank?\n Rails.logger.info \"Total Emails: #{json_body[\"items\"].count}\"\n json_body[\"items\"].each do |item|\n Rails.logger.info \"Subject: #{item['message']['headers']['subject']}\"\n Rails.logger.info \"Storage Url: #{item['storage']['url']}\"\n mail_list_array.push(item['storage']['url'])\n end\n end\n end\n mail_list_array\n end", "def refresh_lists\n settings = current_user.settings_for(\"mailchimp\")\n unless settings && settings.settings[\"api_key\"]\n flash[:warning] = \"You need to configure your Mailchimp API key!\"\n redirect_to(root_url) and return\n end\n counts = Mailchimp.refresh_lists_for(current_user)\n\n flash[:notice] = \"Successfully cached #{pluralize counts[:lists], 'list'}, #{pluralize counts[:groupings], 'grouping'}, and #{pluralize counts[:groups], 'group'}.\"\n redirect_to(root_url)\n end", "def domains_list\n call('domains.list')[:domains]\n end", "def mcget_list_menbers(list_id)\n # 82dfd7f973, a38ec3df9c\n begin\n lists_res = setup_mcapi.lists.list({'list_id' => list_id})\n @list = lists_res['data'][0]\n members_res = setup_mcapi.lists.members(list_id)\n @members = members_res['data']\n rescue Mailchimp::ListDoesNotExistError\n flash[:error] = \"The list could not be found\"\n redirect_to \"/lists/\"\n rescue Mailchimp::Error => ex\n if ex.message\n flash[:error] = ex.message\n else\n flash[:error] = \"An unknown error occurred\"\n end\n redirect_to \"/lists/\"\n end\n end", "def index\n @event_mailing_list = EventMailingList.new\n @event_sites = EventSite.all\n # if params[:id]\n # @mail = EventMailingList.find(params[:id])\n # end\n end", "def index\n @mail_items = MailItem.all\n end", "def email_all\n wc = Incoming::Workcamp.find(params[:id])\n addresses = wc.participants.map { |p| p.organization.email.to_s.strip }\n redirect_to \"mailto:#{addresses.join(',')}\"\n end", "def list_boxes\r\n command = 'List-Folder'\r\n execute_outlook_script(command)\r\n end", "def index\n @mail_contexts = MailContext.all\n end", "def list\r\n\t\t@current_area = 'newsletter_signups'\r\n\t\t@current_menu = 'newsletter_signups'\r\n\r\n\t\tsort_order ||= get_sort_order(\"s-name\", [\"first_name\", \"last_name\"])\r\n\t\tsort_order ||= get_sort_order(\"s-email\", \"email\")\r\n\t\tsort_order ||= \"id ASC\"\r\n\r\n\t\tpage = params[:page] ? params[:page].to_i : 1\r\n\t\titems_per_page = 30\r\n\t\toffset = (page - 1) * items_per_page\r\n\r\n\t\tif params[:delete] and params[:select]\r\n\t\t\tc = params[:select].keys.collect do |cur_key|\r\n\t\t\t\tNewsletterSignup.delete(cur_key.to_i)\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\t@signup_count = NewsletterSignup.count\r\n\r\n\t\t@pages = Paginator.new(self, @signup_count, items_per_page, page)\r\n\r\n\t\t@signups = NewsletterSignup.find(:all, :order => sort_order)\r\n\tend", "def subscribe_to_lists(list_names, email)\n walk_recipients(list_names, email) do |lr, list_id, contact_id|\n if lr.nil?\n ::Mailjet::Listrecipient.create(list_id: list_id, contact_id: contact_id, is_unsubscribed: 'false')\n elsif lr.is_unsubscribed\n lr.update_attributes(is_unsubscribed: 'false', unsubscribed_at: nil)\n end\n end\n rescue ::Mailjet::ApiError\n # ignore\n end", "def link_to_mailing_list(text, mailing_list_name, *args)\n link_to_function text, \"CCPEVE.joinMailingList(#{mailing_list_name.inspect})\", *args\n end", "def index\n @ourmails = Mail.all\n end", "def maillist_parse(file)\n maillist = []\n\n # if file doesn't exist, just return empty array, otherwise, parse for emails\n if File.exist?(file)\n File.readlines(file).each do |line|\n if index = (line =~ /\\#/)\n # line contains some kind of comment\n # check if there is any useful info, ignore it not\n unless line[0, index].strip.empty?\n maillist << Origen::Users::User.new(line[0, index].strip).email\n end\n else\n # if line is not empty, generate an email\n unless line.strip.empty?\n maillist << Origen::Users::User.new(line.strip).email\n end\n end\n end\n end\n maillist\n end", "def no_such_list(email)\n @address = email.to\n mail(\n :to => email.from,\n :subject => \"Mailinglist '#{@address}' does not exist\",\n :date => Time.zone.now\n )\n end", "def list(id)\n get(\"lists/#{id}\").list\n end", "def index\n authorize! :read, Ml::List\n @ml_lists = Ml::List.accessible_by(current_ability).includes(redirection_aliases: :email_virtual_domain).search(params[:search])\n #authorize! :read, @ml_lists\n end", "def list_test_dispatch(list)\n list.subscribers.each do |subscriber|\n mail(\n :to => \"#{subscriber.name} <#{subscriber.email}>\",\n :subject => \"[#{list.name}] Test Mailing\",\n :date => Time.zone.now\n )\n end\n end", "def make_mailchimp_list(from_name, from_email, event)\n Person.roles.keys.each_with_index do |role, index|\n if index == 0 \n participant_ids = []\n Participant.statuses.keys.each do |s|\n response = gibbon.lists.create(make_mailchimp_hash(from_name, from_email, event, role, s))\n participant_ids << response['id']\n end\n event.mailchimp_ids << participant_ids.join(',')\n else\n response = gibbon.lists.create(make_mailchimp_hash(from_name, from_email, event, role))\n event.mailchimp_ids << response['id']\n end\n end\n end", "def mailbox_list\n begin\n @imap = WmailImapUtils.current_imap\n folder_list = WmailImapUtils.get_mailbox_list\n @folders_count_hash = Hash[ folder_list.map do |a|\n [a.name, @imap.status(a.name, [\"UNSEEN\"])[\"UNSEEN\"]] unless a.name == \"[Gmail]\"\n end ]\n rescue\n respond_to do|format|\n format.html {redirect_to authenticate_wmail_accounts_path(:redirect => params),\n :alert => 'Connection Lost. Please login to your account'}\n format.js {render :js => \"window.location = '\" + authenticate_wmail_accounts_path(:redirect => params) + \"';\"}\n end\n end\n end", "def index\n @lists = current_user.lists.all\n end", "def get_lists()\n lists = api_request(\"list\")\n return lists.split(\"\\n\")\n end", "def recipients_list\n to.split(/\\s*,\\s*/)\n end", "def member_of_mailing_list(email, list_name)\n\tbegin\n\t\tlist_id = Rails.configuration.mailing_lists[:mailchimp_list_ids][list_name.to_sym]\n\t\tGibbon::Request.lists(list_id).members(email_md5_hash(email)).retrieve\n\trescue Gibbon::MailChimpError => e\n\t\tputs \"MailChimp error while retrieving member info: #{e.title}; #{e.detail}; status: #{e.status_code}; email: #{email}; list: #{list_name}\"\n\tend\nend", "def tasklists\n get gtasks_tasklists_url\n end", "def create_list(params)\n MailManager::List.create(params)\n end", "def list(options={})\n Mailgun.submit(:get, unsubscribe_url, options)[\"items\"]\n end", "def add_list!\n commit_list!\n @last_log_recipient_list = mail_log.mail_log_recipient_lists.build(:recipients => [])\n end", "def user_email_list\n @email_list = []\n\n EmailList.all.each do |email|\n if email.creator_id == current_user.id\n @email_list << email \n end\n end\n @email_list\n end", "def subscribe_all\n # Get an array of all the email addresses accociated with this devise class.\n emails = all.map(&:email).select {|e| Devise::Models::Campaignable.valid_campaign_email? e}\n\n # Ask the list managed to subscibe all of these emails.\n list_manager.batch_subscribe(emails)\n end", "def index\n @receive_emails = ReceiveEmail.all\n end", "def index\n @mailing_schedules = MailingSchedule.all\n end", "def mails\n\n begin\n @imap = WmailImapUtils.current_imap\n \n if not @imap.blank?\n @mailbox = params['mailbox']\n @min = params['min'].to_i\n @max = params['max'].to_i\n @total = params['total'].to_i\n\n @imap.select(@mailbox)\n @mails = @imap.fetch(@total-@max..@total-@min, 'ENVELOPE')\n @unseen_flags = @imap.search(['NOT','SEEN'])\n end\n rescue\n redirect_to authenticate_wmail_accounts_path(:redirect => messages_mailbox_path(:label => selected_label)),\n :alert => 'Connection Lost. Please login to your account'\n end\n end", "def mails(element_key, options = {})\n parameter = { query: options }\n parameter[:basic_auth] = @auth\n\n response = self.class.get(\"/elements/#{element_key}/mails\", parameter)\n return response['ElementList'] if response.success?\n end", "def cache_list(force_reload=false)\n unless self.is_cached? or force_reload\n @messages = []\n \n # get the list of message id's and return an empty array if there \n # are no messages in the box\n search = @connection.search(\"All\")\n return if search.size == 0\n \n @raw_messages = @connection.fetch(search, \n [\"FLAGS\", \"INTERNALDATE\", \"RFC822.SIZE\", \"ENVELOPE\", \"UID\"])\n @is_cached = true\n \n @raw_messages.each do |raw| \n message = {\n \"seqno\" => raw.seqno, \n \"uid\" => raw.attr[\"UID\"], \n \"date\" => Time.parse(raw.attr[\"INTERNALDATE\"]), \n \"subject\" => raw.attr[\"ENVELOPE\"].subject, \n \"flags\" => raw.attr[\"FLAGS\"], \n \"size\" => raw.attr[\"RFC822.SIZE\"]\n }\n\n [\"to\", \"cc\", \"bcc\", \"from\", \"sender\", \"reply_to\"].each do |a|\n message[a] = raw.attr[\"ENVELOPE\"][a].collect { |address|\n {\n \"name\" => address.name, \n \"address\" => \"#{address.mailbox}@#{address.host}\", \n \"user\" => address.mailbox.downcase, \n \"domain\" => address.host.downcase\n }\n } unless raw.attr[\"ENVELOPE\"][a].nil?\n end #do\n \n @messages.push(message)\n end #do\n end #unless \n end", "def all\n ContactDatabase.get_all\n end", "def set_lists\n\t\t\t@lists = @intranet.lists\n\t\tend", "def getEmailList\n\t\tdata = index()\n\t\temailList = []\n\t\tdata.each do |person|\n\t\t\temailList.push(\"#{person[\"email_address\"]}\")\n\t\tend\n\t\treturn emailList\n\tend", "def maillist\n @cntcts = current_user.organization.contacts\n @tmrec = Array.new\n params[:ids].split(\",\").map do |id|\n @tmrec << TimeRecord.find_by_id(id)\n end\n @tmrec_array = params[:ids]\n render :partial => \"maillist\", :layout => false\n end", "def index\n @lists = @user.lists\n end", "def index\n @admin_system_emails = Admin::SystemEmail.all\n end", "def calendar_list\r\n logger.info(\"-- calendar list st --\") if logger\r\n auth unless @auth\r\n uri = URI.parse(CALENDAR_LIST_PATH)\r\n res = do_get(uri, {})\r\n logger.info(\"-- calendar list en(#{res.message}) --\") if logger\r\n res\r\n end", "def fetch_messages(gmail, label, criteria, save_attachments)\n mails = []\n gmail.mailbox(label).search(criteria).each do |email|\n subject = \"#{Mail::Encodings.value_decode(email.subject)}\"\n puts \"----------\"\n puts \"[#{email.uid}] #{subject}\"\n from = sender(email.from)\n to = recipients(email.to)\n attachments = attachments(email)\n body = extract_body(email)\n\n # TODO: saving attachments should be configurable\n if save_attachments && email.message.attachments.any?\n puts \"Attachments:\"\n email.message.attachments.each do |attachment|\n save_attachment(email, attachment)\n end\n end\n\n mails << { :uid => email.uid,\n :date => Time.parse(email.date),\n :subject => subject,\n :from => from,\n :to => to,\n :body => body,\n :attachments => attachments }\n end\n mails\n end", "def index\n @customer_mailers = CustomerMailer.all\n end", "def jobs_notifier(email_list)\n @listed_jobs = JobPosting.where(created_at: (Time.now.midnight-5.days)..(Time.now))\n @greeting = \"Hi\"\n headers['X-SMTPAPI'] = { :to => email_list.to_a }.to_json\n mail(\n :to => \"[email protected]\",\n :subject => \"New Job Posted!\"\n )\n \n end", "def get_list(access_token, list_id)\n url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.list'), list_id)\n url = build_url(url)\n response = RestClient.get(url, get_headers(access_token))\n Components::ContactList.create(JSON.parse(response.body))\n end" ]
[ "0.75645286", "0.7324172", "0.7314068", "0.7245025", "0.71619785", "0.68899566", "0.6879543", "0.6777096", "0.6742243", "0.6729593", "0.66930526", "0.6678078", "0.65925694", "0.65269196", "0.6502744", "0.6491451", "0.64658934", "0.6405798", "0.6405798", "0.6403956", "0.6382592", "0.62685525", "0.6267186", "0.6264317", "0.62596", "0.6224953", "0.62171745", "0.62105554", "0.6166154", "0.61428654", "0.613766", "0.6135018", "0.6125288", "0.6037652", "0.60243833", "0.6024355", "0.60147506", "0.599964", "0.59963155", "0.59889066", "0.59708947", "0.5966509", "0.5874408", "0.58694094", "0.58622175", "0.5853001", "0.5851136", "0.58494663", "0.58422726", "0.579634", "0.5790031", "0.57889664", "0.57866275", "0.57826805", "0.5775923", "0.5775", "0.5758202", "0.5757086", "0.5752454", "0.5750349", "0.5745262", "0.57425797", "0.5723379", "0.5720662", "0.5704033", "0.5701623", "0.5694828", "0.5694361", "0.5693921", "0.56803626", "0.56750673", "0.56693894", "0.56679475", "0.56637603", "0.56494343", "0.5636162", "0.5630282", "0.5624715", "0.56199867", "0.5619591", "0.56149226", "0.5613941", "0.5613096", "0.5611998", "0.56105113", "0.55996126", "0.55859375", "0.5574983", "0.5566385", "0.55652136", "0.5564841", "0.5563827", "0.5560603", "0.5558747", "0.5557024", "0.555463", "0.55424315", "0.5540496", "0.5540063", "0.55393475" ]
0.64232117
17
List a single mailing list by a given address
def find(address) Mailgun.submit :get, list_url(address) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n @mailing_list.contacts(limit: 10000).map{|contact| contact.email}\n end", "def list_url(address=nil)\n \"#{@mailgun.base_url}/lists#{'/' + address if address}\"\n end", "def address_list_fetch(field_name)\n if values = fetch_all(field_name, nil)\n list = nil\n values.each { |value|\n if list\n list.concat(Address.parse(value))\n else\n list = Address.parse(value)\n end\n }\n if list and !list.empty?\n list\n end\n end or RMail::Address::List.new\n end", "def list\n @client.call(method: :get, path: 'recipient-lists')\n end", "def mailing\n gb = Gibbon.new\n @lists = Hash.new\n for i in 1..gb.lists['total'] do\n list_id = gb.lists['data'][i - 1]['id']\n name = gb.lists['data'][i - 1]['name']\n @lists[name] = []\n members = gb.list_members({:id => list_id})\n members['data'].map { |m| @lists[name].push(m['email']) }\n end\n end", "def index\n @mail_lists = MailList.all\n end", "def list_by_email(email)\n params = Hash.new\n params[:email] = email\n self.list(params)\n end", "def list_addresses\n Address.list(@id)\n end", "def no_such_list(email)\n @address = email.to\n mail(\n :to => email.from,\n :subject => \"Mailinglist '#{@address}' does not exist\",\n :date => Time.zone.now\n )\n end", "def create(address, options={})\n \tparams = {:address => address}\n Mailgun.submit :post, list_url, params.merge(options)\n end", "def call(address)\n go_to_form\n fill_form(address)\n get_all_contacts\n end", "def member_of_mailing_list(email, list_name)\n\tbegin\n\t\tlist_id = Rails.configuration.mailing_lists[:mailchimp_list_ids][list_name.to_sym]\n\t\tGibbon::Request.lists(list_id).members(email_md5_hash(email)).retrieve\n\trescue Gibbon::MailChimpError => e\n\t\tputs \"MailChimp error while retrieving member info: #{e.title}; #{e.detail}; status: #{e.status_code}; email: #{email}; list: #{list_name}\"\n\tend\nend", "def index\n @mailing_lists = MailingList.all\n @email = @mailing_lists.collect(&:email).join(\"; \")\n end", "def get_address_list(order, user)\n if @order and @user\n # Non-guest order\n Spree::AddressBookList.new(@user, @order)\n elsif @order\n # Guest order\n Spree::AddressBookList.new(@order)\n elsif @user\n # User account\n Spree::AddressBookList.new(@user)\n else\n # Nothing; return a blank list\n Spree::AddressBookList.new(nil)\n end\n end", "def list(domain, opts = {}, map_mailboxes = true)\n mailboxes = call('domain.mailbox.list', domain.fqdn, opts)\n \n if map_mailboxes\n mailboxes.map! do |mailbox|\n self.new(domain, mailbox['login'])\n end\n end\n return mailboxes\n end", "def listreceivedbyaddress(minconf = 1, includeemepty = false)\n request :listreceivedbyaddress, minconf, includeemepty\n end", "def link_to_mailing_list(text, mailing_list_name, *args)\n link_to_function text, \"CCPEVE.joinMailingList(#{mailing_list_name.inspect})\", *args\n end", "def listreceivedbyaddress(minconf = 1, includeempty = false)\n coind.listreceivedbyaddress minconf, includeempty\n end", "def listreceivedbyaddress(minconf = 1, includeempty = false)\n @api.request 'listreceivedbyaddress', minconf, includeempty\n end", "def set_mailing_list\n @mailing_list = MailingList.find(params[:id])\n end", "def address_list_for(emails, retried = false)\n emails = emails * \", \"\n list = Mail::AddressList.new(self.class.unescape(emails))\n addrs = list.addresses.each { |a| a.decoded }\n addrs.uniq!\n addrs\n rescue Mail::Field::ParseError\n if retried\n raise\n else\n address_list_for(emails.scan(EMAIL_REGEX), true)\n end\n end", "def email_list\n end", "def list params={}\n params[:fields] = params[:fields].join(',') if params[:fields]\n params[:record_type] ||= 'person'\n @nimble.get \"contacts\", params\n end", "def find(address)\n get(\"#{domain}/complaints/#{address}\")\n end", "def set_mail_list\n @mail_list = MailList.find(params[:id])\n end", "def address_listing\n @addresses = current_user.addresses\n end", "def search_addressbook\n emails = Array.new \n flag = params[:q].to_s.match(/\\A[+-]?\\d+?(\\.\\d+)?\\Z/) == nil ? false : true\n id_search = false\n if flag\n filter = params[:q].length == 6 ? Net::LDAP::Filter.eq( \"sAMAccountName\", \"#{params[:q]}\" ) : \"\"\n id_search = true\n else\n filter = Net::LDAP::Filter.eq( \"mail\", \"*#{params[:q]}*\")\n end\n unless filter == \"\"\n ldap_connection.search( :base => AppConfig[:ldap_treebase], :filter => filter , :attributes => [\"sAMAccountName\", \"mail\"], :size => 10) do |entry|\n emails << {:name => \"#{entry[:mail].first} (#{entry[:samaccountname].first})\" , :value => entry[:mail].first}\n end\n end\n emails\n end", "def get_for_list(list_id, page)\n full_path = full_resource_path(\"/#{list_id}/contacts\", 'lists')\n query_params = MaropostApi.set_query_params({page: page})\n \n MaropostApi.get_result(full_path, query_params)\n end", "def list\n ContactDatabase.list\n end", "def email_list\n @entries.collect do |line|\n name, email = line.split(\",\")\n format_email_address name, email.chomp\n end.join(\", \")\n end", "def add_to_friends_list(email)\n send_contact_command email, 'ADL', '1'\n end", "def view_contact_list(list)\n list = list.execute(\"SELECT * FROM contacts\")\n\n list.each do |item|\n puts \"name: #{item[1]}\"\n puts \"occupation: #{item[2]} - association: #{item[3]}\"\n puts \"email: #{item[4]} - phone:#{item[5]}\"\n puts \"-------------------\"\n end\nend", "def mailbox_list(str, opt)\n ret = []\n split_by(Tokenizer.token(str), \",\").each do |m|\n if a1 = m.index(\"<\") and a2 = m.rindex(\">\") and a2 > a1 then\n display_name = m[0..a1-1].join(\" \")\n if opt[:decode_mime_header] then\n display_name = RFC2047.decode(display_name, opt)\n end\n mailaddr = _conv(m[a1+1..a2-1].join, opt)\n local_part, domain = mailaddr.split(/@/, 2)\n ret << RFC2822::Mailbox.new(RFC2822::AddrSpec.new(local_part, domain), _conv(display_name, opt))\n else\n local_part, domain = _conv(m.join, opt).split(/@/, 2)\n ret << RFC2822::Mailbox.new(RFC2822::AddrSpec.new(local_part, domain))\n end\n end\n return ret\n end", "def index\n @event_mailing_list = EventMailingList.new\n @event_sites = EventSite.all\n # if params[:id]\n # @mail = EventMailingList.find(params[:id])\n # end\n end", "def fNotificationListFrom (email)\n @users.notificationListFrom(email)\n end", "def maillist_dev\n maillist_parse(maillist_dev_file)\n end", "def address_list\n $tracer.trace(format_method(__method__))\n return ProfileAddressList.new(@tag.find.span.className(create_ats_regex_string(\"ats-addrpanel\")), format_method(__method__))\n end", "def index\n @email_lists = EmailList.all\n end", "def mailboxes_list\n get \"mailboxes\"\n end", "def mailing_address\n return unless @user.loa3?\n\n dig_out('addresses', 'address_pou', VAProfile::Models::Address::CORRESPONDENCE)\n end", "def maillist_prod\n maillist_parse(maillist_prod_file)\n end", "def parse_mailbox_list(str, opt={})\n mailbox_list(str, opt)\n end", "def by_address(address)\n Apis.client.get(\"/company?address=#{address}\")\n end", "def search\r\n @addresses = Address.find_by_address(params[:address])\r\n end", "def announce_list(listname,domain)\n doc = request(\"announcement_list-list_subscribers\",{ \"listname\" => listname, \"domain\" => domain})\n api_error?(doc)\n (doc/:data).inject([]) { |subs, sub| subs << Subscriber.new_from_xml(sub); subs }\n end", "def create_list(params)\n MailManager::List.create(params)\n end", "def mailfrom(from_addr); end", "def get_list(user, list)\n get(\"/#{user}/lists/#{list}.json\")\n end", "def call_address_service\n addresses = []\n success = call_ok?(:address_search, make_request) do |body|\n ServiceClient.iterate_element(body[:address_list]) do |address|\n add_address(addresses, address) unless address.nil?\n end\n end\n [success, addresses]\n end", "def addresses\n query(:address)\n end", "def membership_list_for_group(email)\n Gaps::DB::Cache.with_cache_key(\"mygroupinfos:#{email}\") do\n membership_list(email)\n end\n end", "def mail_list\n str =\"\"\n self.users.each do |person|\n str << \"#{person.login} <#{person.email}> \\n\"\n end\n str\n end", "def auto_complete_for_message_to\n q = params[:message][:to] if params[:message]\n render :nothing => true if q.blank?\n @users = User.find(:all, :order => \"login ASC\", :conditions => [\"login LIKE ?\", \"%#{q}%\"], :limit => 10)\n render :inline => \"<%= content_tag(:ul, @users.map { |u| content_tag(:li, h(u.login)) }) %>\"\n end", "def from\n address_list_fetch('from')\n end", "def list\n perform_request(Entities::MarketingEmail, 'newsletter/list.json')\n end", "def do_list(args)\n if args[\"zonename\"] == \"example.com\"\n @result = [\n record(\"example.com\", \"SOA\", \"sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600\"),\n record(\"example.com\", \"NS\", \"sns.dns.icann.org\"),\n record_prio(\"example.com\", \"MX\", \"test.example.com\",10),\n record(\"test.example.com\", \"A\", \"127.0.0.1\")\n ]\n end\n end", "def get_list(access_token, list_id)\n url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.list'), list_id)\n url = build_url(url)\n response = RestClient.get(url, get_headers(access_token))\n Components::ContactList.create(JSON.parse(response.body))\n end", "def address_list_assign(field_name, addresses)\n if addresses.kind_of?(Array)\n value = addresses.collect { |e|\n if e.kind_of?(RMail::Address)\n e.format\n else\n RMail::Address.parse(e.to_str).collect { |a|\n a.format\n }\n end\n }.flatten.join(\", \")\n set(field_name, value)\n elsif addresses.kind_of?(RMail::Address)\n set(field_name, addresses.format)\n else\n address_list_assign(field_name,\n RMail::Address.parse(addresses.to_str))\n end\n end", "def show\n @mailing_list = MailingList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mailing_list }\n end\n end", "def mailbox_list\n\tmailbox(address_lookahead)\n\twhile @sym == SYM_COMMA\n\t get\n\t new_address\n\t mailbox(address_lookahead)\n\tend\n end", "def recipients_in_list\n if request.get?\n render :layout => \"modal\"\n return\n end\n \n list = params[:accounts].strip.split(/\\n|,/).uniq\n conditions = [\n \"(erp_account_number IN (:list) OR serial_number IN (:list))\",\n { :list => list }\n ]\n conditions.first << \" AND do_not_contact = false\" unless params[:ignore_do_not_contact]\n @recipients = StoreUser.find(\n :all,\n :conditions => conditions,\n :joins => \"LEFT OUTER JOIN serial_numbers ON serial_numbers.account_num = erp_account_number\",\n :include => \"customer\"\n ) rescue []\n render :partial => \"mail_recipients\", :layout => false\n end", "def maillist_parse(file)\n maillist = []\n\n # if file doesn't exist, just return empty array, otherwise, parse for emails\n if File.exist?(file)\n File.readlines(file).each do |line|\n if index = (line =~ /\\#/)\n # line contains some kind of comment\n # check if there is any useful info, ignore it not\n unless line[0, index].strip.empty?\n maillist << Origen::Users::User.new(line[0, index].strip).email\n end\n else\n # if line is not empty, generate an email\n unless line.strip.empty?\n maillist << Origen::Users::User.new(line.strip).email\n end\n end\n end\n end\n maillist\n end", "def lists\n @links = Link.all\n @short_link = ActionMailer::Base.default_url_options[:host]\n end", "def index\n all_mail_users =\n case @type\n when 'applicable'\n @recipient_list.applicable_mail_users\n when 'included'\n @recipient_list.included_mail_users\n when 'excluded'\n @recipient_list.excluded_mail_users\n end&.order(:name)\n\n @mail_users =\n if params[:page] == 'all'\n all_mail_users&.page(nil)&.per(all_mail_users&.count)\n else\n all_mail_users&.page(params[:page])\n end\n\n flash.alert = '指定のリストはありません。' if @mail_users.nil?\n end", "def get_contact_list(filter, options={ skip: nil, count: nil, auth_token: nil })\n auth_token = options[:auth_token] || @auth_token\n check_auth_token(auth_token, [\"graph/read\"])\n\n response = http_client(MXIT_API_URI + \"/user/socialgraph/contactlist\") do |http, path|\n\n parameters = { :filter => filter }\n # skip and count are optional\n parameters[:skip] = options[:skip] if options[:skip]\n parameters[:count] = options[:count] if options[:count]\n\n request = Net::HTTP::Get.new(path + \"?#{URI.encode_www_form(parameters)}\")\n set_api_headers(request, auth_token.access_token)\n\n http.request(request)\n end\n\n handle_response(response)\n end", "def get_email_list\n return get_townhall_list_and_url.map{|town, url| {town => get_townhall_email(url)}}\n end", "def index\n\t\t@addresses = Address.all\t\n\tend", "def display_all_contacts\n all_contact = Contact.all\n all_contact.each do |list|\n puts:\"===============================\"\n puts \"first name: #{list.first_name}\"\n puts \"last name: #{list.last_name}\"\n puts \"email: #{list.email}\"\n puts \"note: #{list.note}\"\n puts \"id: #{list.id}\"\n puts\n\n end\n end", "def list_postal_addresses\n\treturn if authorise_for_web(program_name?,'read') == false \n\n \tif params[:page]!= nil \n\n \t\tsession[:postal_addresses_page] = params['page']\n\n\t\t render_list_postal_addresses\n\n\t\t return \n\telse\n\t\tsession[:postal_addresses_page] = nil\n\tend\n\n\tlist_query = \"@postal_address_pages = Paginator.new self, PostalAddress.count, @@page_size,@current_page\n\t @postal_addresses = PostalAddress.find(:all,\n\t\t\t\t :limit => @postal_address_pages.items_per_page,\n\t\t\t\t :offset => @postal_address_pages.current.offset)\"\n\tsession[:query] = list_query\n\trender_list_postal_addresses\nend", "def index\n @person_email_addresses = PersonEmailAddress.all\n end", "def pick_address_from_list\n params.each_key do |key|\n next unless key.start_with? 'pick_address'\n\n index = key.to_s.delete_prefix('pick_address_').to_i\n\n @show_manual_address = true\n @address_read_only = true\n @address_summary = AddressSummary.new\n @address_detail = @address_list[index]\n break\n end\n end", "def make_mailchimp_list(from_name, from_email, event)\n Person.roles.keys.each_with_index do |role, index|\n if index == 0 \n participant_ids = []\n Participant.statuses.keys.each do |s|\n response = gibbon.lists.create(make_mailchimp_hash(from_name, from_email, event, role, s))\n participant_ids << response['id']\n end\n event.mailchimp_ids << participant_ids.join(',')\n else\n response = gibbon.lists.create(make_mailchimp_hash(from_name, from_email, event, role))\n event.mailchimp_ids << response['id']\n end\n end\n end", "def list\n contacts_index(Contact.all)\n end", "def index\n @listings = Listing.where(\"host_email = ?\", current_user.email)\n end", "def display_one_contact\n contact = retrieve_contact_by_email\n end", "def to_mailing_list(topic, email, subscriber, message)\n @email = email\n \n # Set additional headers\n headers['List-ID'] = topic.list.email\n headers['List-Post'] = topic.list.email\n # headers['List-Unsubscribe'] = \"#{ENV['PROTOCOL'] || \"http\"}://#{topic.list.domain}/lists/#{ topic.list.id }/unsubscribe\"\n headers['Reply-To'] = reply_to_address(topic, message)\n\n mail(\n :to => \"#{subscriber.name} <#{subscriber.email}>\",\n :from => \"#{message.author.name} via #{topic.list.name} <#{topic.list.email}>\",\n # :from => \"#{message.author.name} <#{message.author.email}>\",\n :subject => subject(topic),\n :date => Time.zone.now\n )\n end", "def index\n @q = Address.where([\"user_email = ?\", current_user.email]).ransack(params[:q])\n @addresses = @q.result(distinct: true)\n end", "def lookup_feed_address( name )\n @feed_address_list.find { |f| f.getFeedAddress.include?(name) }\n end", "def getContacts\n @contact_list.each_with_index do |c, i|\n #puts \"#{i +1}) #{c}\"\n puts \"#{i +1}) #{c[:first_name]} #{c[:last_name]} #{c[:email]}\"\n end\n end", "def index\n @adresses = Adress.all\n end", "def proms_mailing_list_email\n \"#{gadz_tabagns}#{gadz_ans}@gadz.org\"\n end", "def add_list!\n commit_list!\n @last_log_recipient_list = mail_log.mail_log_recipient_lists.build(:recipients => [])\n end", "def reply_to\n address_list_fetch('reply-to')\n end", "def retrieve(id, show_recipients = false)\n params = { show_recipients: show_recipients }.compact\n @client.call(method: :get, path: \"recipient-lists/#{id}\", query_values: params)\n end", "def set_list\n @list = @organization.lists.find_by_permalink(params[:id])\n raise ActiveRecord::RecordNotFound unless @list\n end", "def index\n @addresses = Address.order(:number).all\n end", "def list_email()\nsession = GoogleDrive::Session.from_config(\"config.json\")\nws = session.spreadsheet_by_key(\"1v7XEnpGDtgjgRom3bp7OwzaK99zlUQIfKuW3QdawXBc\").worksheets[0]\n#define a lopp with each for the spreadsheet.\n(1..w_sheet.num_rows).each do |list|\n\t\tmail = ws[list, 2]\n\t\tcity = ws[list, 1]\n list_email(\"email\",\"password\",mail, city)\n end\nend", "def get_contact_for_list(list_id, contact_id)\n full_path = full_resource_path(\"/#{list_id}/contacts/#{contact_id}\", 'lists')\n query_params = MaropostApi.set_query_params\n \n MaropostApi.get_result(full_path, query_params)\n end", "def index\n @user_addresses = UserAddress.all\n end", "def index\n @person_addresses = PersonAddress.all\n end", "def extract_addresses(address_list)\n addresses = []\n address_list.each do |address|\n addresses << address[:address] if ['ipv4', 'hostname'].include?(address[:type])\n end\n addresses\nend", "def set_event_mailing_list\n @event_mailing_list = EventMailingList.find(params[:id])\n end", "def admin_1099_received_list\n %w( [email protected] )\n end", "def primary_mailing_address\n mailing_address_type_code = Address.mailing_address_type.to_i\n\n primary_contacts(addresses, :address_rank_code) do |ts|\n ts.detect { |t| t.address_type_code == mailing_address_type_code }\n end\n end", "def display_contacts(contacts)\n\n contacts.each do |display|\n puts \"First name: #{display.first_name} Last name: #{display.last_name} Email: #{display.email} Note: #{display.note}\"\n end\n end", "def add_domain_list(name)\n configure \"ip domain-list #{name}\"\n end", "def getaddressesbyaccount(account)\n request :getaddressesbyaccount, account\n end", "def maillist\n @cntcts = current_user.organization.contacts\n @tmrec = Array.new\n params[:ids].split(\",\").map do |id|\n @tmrec << TimeRecord.find_by_id(id)\n end\n @tmrec_array = params[:ids]\n render :partial => \"maillist\", :layout => false\n end", "def index\n @mailaddresses = Mailaddress.all\n end", "def index\n @addresses = Address.all\n end" ]
[ "0.71387213", "0.7038603", "0.6412147", "0.62788033", "0.61784786", "0.61186785", "0.6102625", "0.6073309", "0.6044168", "0.6014143", "0.5952885", "0.59479433", "0.59216946", "0.5901179", "0.5895365", "0.58914", "0.58729684", "0.58612025", "0.58373404", "0.5769141", "0.5730674", "0.5728357", "0.5722423", "0.57037467", "0.5702982", "0.5672399", "0.56324655", "0.5630631", "0.5630175", "0.5629368", "0.56171346", "0.56090283", "0.56046265", "0.55972534", "0.5592132", "0.5587969", "0.5538696", "0.5533244", "0.55265135", "0.5491446", "0.54903", "0.54879713", "0.5475657", "0.5449316", "0.54467976", "0.54457426", "0.5426995", "0.5412175", "0.5393755", "0.5389412", "0.53727716", "0.53567773", "0.5350573", "0.5349609", "0.53466666", "0.53341925", "0.53222877", "0.5314701", "0.5308483", "0.53062105", "0.5305581", "0.5294254", "0.5287429", "0.5285982", "0.52839285", "0.5261202", "0.525439", "0.52533966", "0.5249013", "0.5228172", "0.52228415", "0.5221252", "0.52196634", "0.521689", "0.52019626", "0.5201867", "0.5194802", "0.51932025", "0.51931185", "0.51921725", "0.519083", "0.51866364", "0.51825726", "0.5175235", "0.51735127", "0.5173451", "0.5169688", "0.5164436", "0.5164187", "0.5163486", "0.5161633", "0.51566285", "0.5156364", "0.5151241", "0.5147249", "0.51469165", "0.5146846", "0.513877", "0.5136027", "0.5127276" ]
0.74962294
0
Create a mailing list with a given address
def create(address, options={}) params = {:address => address} Mailgun.submit :post, list_url, params.merge(options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_address\n if @ok\n @mailing_list_address = MailingListAddress.new\n @mailing_list_address.group_id = @mailing_list_group.id\n @mailing_list_address.heading = params[:heading]\n @mailing_list_address.email = params[:email]\n @ok = @mailing_list_address.save\n end\n render 'update_addresses'\n end", "def create_list(params)\n MailManager::List.create(params)\n end", "def create_contact(name, telephone, email)\n\tcontact_list = {\n\t\tname: name,\n\t\ttelephone: telephone,\n\t\temail: email\n\t}\n\tcontacts = []\n\tcontacts << contact_list\nend", "def create\n @mailing_list = MailingList.new(params.require(:user).permit(:name, :country, :email, :message))\n @mailing_list.save\n end", "def create_mailbox name\n log \"LIST #{name}\"\n list = imap.list '', name\n return if list\n log \"CREATE #{name}\"\n imap.create name\n end", "def create(attrs)\n params = {}\n\n params.merge! extract_mail(attrs)\n params.merge! extract_subscribers(attrs)\n params.merge! extract_maillists(attrs)\n\n request 'create', params\n end", "def create\n @mailing_list = MailingList.new(params[:mailing_list])\n\n respond_to do |format|\n if @mailing_list.save\n format.html { redirect_to @mailing_list, notice: 'Mailing list was successfully created.' }\n format.json { render json: @mailing_list, status: :created, location: @mailing_list }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mailing_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(params)\n post(\"#{domain}/mailboxes\", params)\n end", "def send_test(addresses)\n\n to_list = addresses\n cc_list = []\n subject = 'Test from PCB Tracker'\n\n mail( :to => to_list,\n :subject => subject,\n :cc => cc_list\n ) \n end", "def list_url(address=nil)\n \"#{@mailgun.base_url}/lists#{'/' + address if address}\"\n end", "def build_email(user, list, todo)\n {\n :from => user.email,\n :to => list.title,\n :subject => todo.title,\n :text => todo.description\n }\n end", "def create\n @mailinglist = Mailinglist.new(params[:mailinglist])\n\n respond_to do |format|\n if @mailinglist.save\n flash[:notice] = ''\n format.html { redirect_to :controller => \"home\", :action => \"gracias_mailinglist\" }\n format.xml { render :xml => @mailinglist, :status => :created, :location => @mailinglist }\n else\n format.html { render :controller => \"home\" , :action => \"index\" }\n format.xml { render :xml => @mailinglist.errors, :status => :unprocessable_entity }\n end\n end\n end", "def link_to_mailing_list(text, mailing_list_name, *args)\n link_to_function text, \"CCPEVE.joinMailingList(#{mailing_list_name.inspect})\", *args\n end", "def address_list_assign(field_name, addresses)\n if addresses.kind_of?(Array)\n value = addresses.collect { |e|\n if e.kind_of?(RMail::Address)\n e.format\n else\n RMail::Address.parse(e.to_str).collect { |a|\n a.format\n }\n end\n }.flatten.join(\", \")\n set(field_name, value)\n elsif addresses.kind_of?(RMail::Address)\n set(field_name, addresses.format)\n else\n address_list_assign(field_name,\n RMail::Address.parse(addresses.to_str))\n end\n end", "def create_list(options={})\n database_id = options[:database_id]\n list_name = options[:contact_list_name]\n visibility = options[:visibility]\n\n raise ArgumentError, \":database_id option is required\" unless database_id\n raise ArgumentError, \":list_name option is required\" unless list_name\n raise ArgumentError, \":visibility option is required\" unless visibility\n\n request_body = ''\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n xml.instruct!\n xml.Envelope do\n xml.Body do\n xml.CreateContactList do\n xml.DATABASE_ID database_id\n xml.CONTACT_LIST_NAME list_name\n xml.VISIBILITY visibility\n end\n end\n end\n\n doc = send_xml_api_request(request_body)\n result_dom(doc)['CONTACT_LIST_ID']\n end", "def add_contact(list_id, email, attributes = {}, user_status = {})\n endpoint = \"/api/#{@version}/list/#{list_id}/add-contact/\"\n custom_params = {\n 'email' => email,\n 'attributes' => attributes,\n 'user_status' => user_status\n }\n make_post_request(endpoint, custom_params)\n end", "def make_mailchimp_list(from_name, from_email, event)\n Person.roles.keys.each_with_index do |role, index|\n if index == 0 \n participant_ids = []\n Participant.statuses.keys.each do |s|\n response = gibbon.lists.create(make_mailchimp_hash(from_name, from_email, event, role, s))\n participant_ids << response['id']\n end\n event.mailchimp_ids << participant_ids.join(',')\n else\n response = gibbon.lists.create(make_mailchimp_hash(from_name, from_email, event, role))\n event.mailchimp_ids << response['id']\n end\n end\n end", "def create\n @mail_list = MailList.new(mail_list_params)\n\n respond_to do |format|\n if @mail_list.save\n format.html { redirect_to [:admin, @mail_list], notice: 'Mail list was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mail_list }\n else\n format.html { render action: 'new' }\n format.json { render json: @mail_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @address_type_list = @address.AddressTypeList.build(address_type_list_params)\n\n respond_to do |format|\n if @address_type_list.save\n format.html { redirect_to @address_type_list, notice: 'Address type list was successfully created.' }\n format.json { render :show, status: :created, location: @address_type_list }\n else\n format.html { render :new }\n format.json { render json: @address_type_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_list(project_id, list)\n record \"/projects/#{project_id}/todos/create_list\", list\n end", "def add_list!\n commit_list!\n @last_log_recipient_list = mail_log.mail_log_recipient_lists.build(:recipients => [])\n end", "def add_contact(options={})\n list_id = options.delete(:list_id)\n email = options.delete(:email)\n auto_reply = options.delete(:auto_reply)\n\n request_body = ''\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n xml.instruct!\n xml.Envelope do\n xml.Body do\n xml.AddRecipient do\n xml.LIST_ID list_id\n xml.CREATED_FROM '1'\n xml.SEND_AUTOREPLY 'true' if auto_reply\n\n xml.COLUMN do\n xml.NAME 'EMAIL'\n xml.VALUE email\n end\n\n options.each do |field, value|\n xml.COLUMN do\n xml.NAME field.to_s\n xml.VALUE value.to_s\n end\n end\n end\n end\n end\n\n doc = send_xml_api_request(request_body)\n result_dom(doc)['RecipientId'] rescue nil\n end", "def new_listing(listing)\n template_name = \"new-listing\"\n template_content = []\n message = {\n to: [{email: \"[email protected]\"}],\n subject: \"New listing: #{listing.name}\",\n merge_vars: [\n {rcpt: \"[email protected]\",\n vars: [\n {name: \"LISTING_NAME\", content: listing.name}\n ]\n }\n ]\n }\n mandrill_client.messages.send_template template_name, template_content, message\n end", "def initialize_mailing_list_address_with_owner\n initialize_mailing_list_address\n initialize_mailing_list_group\n update_ok(!@mailing_list_address.nil? && !@mailing_list_group.nil? && @mailing_list_address.group_id == @mailing_list_group.id && current_user.id == @mailing_list_group.user_id)\n end", "def new_message(message)\n @message = message\n mail_ids = @message.batch.students.pluck(:email)*\",\"\n mail to: \"#{mail_ids}\", subject: \"A message from your trainer\"\n end", "def add_to_friends_list(email)\n send_contact_command email, 'ADL', '1'\n end", "def add(email)\n eval_response = @mailing_list.add_contacts(email, force: true)\n end", "def set_mailing_list\n @mailing_list = MailingList.find(params[:id])\n end", "def create\n user_id = @current_user.id\n input_address = params[:address].delete(\" \").delete(\",\").capitalize # removes all spaces and comma's from the newly entered address.\n address = @current_user.addresses\n address_arr = []\n address.each do |a|\n address_arr.push(a.address.delete(\" \").delete(\",\").capitalize)\n end\n # checks whether the address entered already exists for the current user\n unless (address_arr.include?(input_address))\n if (address.empty?) # if user have no address, address created first should be the delivery address.\n new_address = Address.create!(\n :user_id => user_id,\n :address => params[:address],\n :delivery_address => true,\n )\n else\n new_address = Address.create!(\n :user_id => user_id,\n :address => params[:address],\n )\n end\n else\n flash[:error] = \"Already Existing Address!!!\"\n end\n redirect_to cart_items_path\n end", "def mailing_new(name)\n return CakeMail::Mailing.create(self, name)\n end", "def mailing\n gb = Gibbon.new\n @lists = Hash.new\n for i in 1..gb.lists['total'] do\n list_id = gb.lists['data'][i - 1]['id']\n name = gb.lists['data'][i - 1]['name']\n @lists[name] = []\n members = gb.list_members({:id => list_id})\n members['data'].map { |m| @lists[name].push(m['email']) }\n end\n end", "def initialize_mailing_list_address\n @mailing_list_address_id = correct_integer?(params[:address_id]) ? params[:address_id].to_i : 0\n @mailing_list_address = MailingListAddress.find_by_id @mailing_list_address_id\n update_ok(!@mailing_list_address.nil?)\n end", "def create\n @mailing_list = MailingList.new(mailing_list_params)\n if @mailing_list.save\n redirect_to new_message_path, notice: 'You have subscribed to our Mailing List'\n else\n @message = Message.new\n render template: \"messages/new\"\n end\n end", "def add_email_addresses!(list_of_email_addresses)\n email_addresses = Expect.normalize_string_to_array(list_of_email_addresses)\n \n email_addresses.each do |email_address|\n add_email_address!(email_address)\n end\n end", "def create_list\n # First delete all current contacts for this user (no overlapping contacts)\n Contact.delete_all(\"user_id = #{current_user.id}\")\n \n # Parse the list (json encoded) and create individual contact entries\n if params[:contacts].nil? || params[:contacts].empty?\n return render :status => 170, :json => {:message => 'Contacts are missing.'}\n end\n contacts = ActiveSupport::JSON.decode(CGI::unescape(params[:contacts]))\n \n total_saved = 0\n contacts.each do |contact|\n # Verify this contact has all required params\n next if (!contact.key?('name') || !contact.key?('email') || !contact.key?('source'))\n\n # Create new contact entry\n Contact.create({\n :user_id => current_user.id,\n :name => contact['name'],\n :email => contact['email'],\n :source => contact['source']\n })\n\n total_saved += 1\n end\n\n render :status => 200, :json => {:message => \"Contacts saved successfully (#{total_saved} of #{contacts.size}).\"}\n end", "def no_such_list(email)\n @address = email.to\n mail(\n :to => email.from,\n :subject => \"Mailinglist '#{@address}' does not exist\",\n :date => Time.zone.now\n )\n end", "def add_contact(list_id, email, attributes={})\n endpoint = \"/api/v1/list/#{list_id}/add-contact/\"\n base_params = base_params(endpoint)\n custom_params = {\n \"email\" => email,\n 'attributes' => attributes\n }\n uri = post_api_uri(endpoint)\n http = setup_request(uri)\n result = http.post(uri.path, base_params.merge(custom_params).to_query)\n JSON.parse(result.body)\n end", "def mailfrom(from_addr); end", "def create\n @email_list = EmailList.new(params[:email_list])\n\n respond_to do |format|\n if @email_list.save\n format.html { redirect_to(@email_list, :notice => 'Email list was successfully created.') }\n format.xml { render :xml => @email_list, :status => :created, :location => @email_list }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @email_list.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new(email_address, config={})\n Address.new(email_address, config)\n end", "def create_address\n create_resource :address, {}\n end", "def deliver_security_notification_create\n # only deliver if this isn't the only address.\n # in that case, the user is just being created and\n # should not receive this email.\n if user.mails != [address]\n deliver_security_notification(\n message: :mail_body_security_notification_add,\n field: :field_mail,\n value: address\n )\n end\n end", "def create\n @address = Address.new(address_params)\n @num = 1\n while Address.where([\"address_id = ?\", @num]).size > 0\n @num = @num+1\n end\n @address.address_id = @num\n @address.user_email = current_user.email\n respond_to do |format|\n if @address.save\n format.html { redirect_to home_path, notice: 'Address was successfully created.' }\n format.json { render :show, status: :created, location: @address }\n else\n format.html { render :new }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def to_mailing_list(topic, email, subscriber, message)\n @email = email\n \n # Set additional headers\n headers['List-ID'] = topic.list.email\n headers['List-Post'] = topic.list.email\n # headers['List-Unsubscribe'] = \"#{ENV['PROTOCOL'] || \"http\"}://#{topic.list.domain}/lists/#{ topic.list.id }/unsubscribe\"\n headers['Reply-To'] = reply_to_address(topic, message)\n\n mail(\n :to => \"#{subscriber.name} <#{subscriber.email}>\",\n :from => \"#{message.author.name} via #{topic.list.name} <#{topic.list.email}>\",\n # :from => \"#{message.author.name} <#{message.author.email}>\",\n :subject => subject(topic),\n :date => Time.zone.now\n )\n end", "def create_group\n @mailing_list_group = MailingListGroup.new\n @mailing_list_group.user = current_user\n @mailing_list_group.name = current_user.new_mailing_list_name\n @ok = @mailing_list_group.save\n render 'update_list'\n end", "def create_areamail_lists(options = {})\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/areamail/lists.json'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'page' => options['page'],\r\n 'pagesize' => options['pagesize'],\r\n 'areamailsid' => options['areamailsid'],\r\n 'dateCreated' => options['date_created']\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n parameters: _parameters\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end", "def new_message(obj)\n @obj = obj\n @admin_recipients = User.role_users(:admin).map(&:email)\n @author_recipients = User.role_users(:author).map(&:email)\n @recipients = @admin_recipients\n emails = @recipients.join(\",\")\n m = [\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\"].join(\",\")\n mail to: m\n end", "def create_full_address\n \"#{address_line1}, #{city}, #{state} #{zip}\"\n end", "def create\n @email_list = EmailList.new(email_list_params)\n\n respond_to do |format|\n if @email_list.save\n format.html { redirect_to @email_list, notice: 'Email list was successfully created.' }\n format.json { render :show, status: :created, location: @email_list }\n else\n format.html { render :new }\n format.json { render json: @email_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def mailing_list_params\n params.require(:mailing_list).permit(:email)\n end", "def create_spree_address\n @spree_address = Spree::Address.new(address_attributes)\n @spree_address.save(validate: false)\n end", "def mail_to(email_address, name = T.unsafe(nil), html_options = T.unsafe(nil), &block); end", "def create\n ContactMailer.create\n end", "def set_mail_list\n @mail_list = MailList.find(params[:id])\n end", "def create_address(params)\n EasyPost::Address.create(params)\n end", "def create_user_blacklisted_email(id:, **args)\n params = parameters(args) do\n required_params :address\n optional_params :address\n end\n request(:post, \"users/#{id}/blacklistedEmails\", params)\n end", "def create_address(order_or_user, expect_success, values, type=nil)\n visit_addresses(order_or_user)\n\n expect(page).to have_css('#new_address_link')\n click_link 'new_address_link'\n expect(current_path).to eq(spree.new_admin_address_path)\n\n fill_in_address(values, type)\n\n click_button Spree.t('actions.create')\n\n if expect_success\n expect_address_collection_path(order_or_user)\n expect(page).to have_content(Spree.t(:successfully_created, resource: Spree::Address.model_name.human))\n else\n expect(path_with_query).to eq(spree.admin_addresses_path(user_id: @user_id, order_id: @order_id))\n expect(page).to have_no_content(Spree.t(:successfully_created, resource: Spree::Address.model_name.human))\n end\n end", "def get_address_list(order, user)\n if @order and @user\n # Non-guest order\n Spree::AddressBookList.new(@user, @order)\n elsif @order\n # Guest order\n Spree::AddressBookList.new(@order)\n elsif @user\n # User account\n Spree::AddressBookList.new(@user)\n else\n # Nothing; return a blank list\n Spree::AddressBookList.new(nil)\n end\n end", "def create\n @mailing_list = MailingList.find(params[:mailing_list_id])\n params[:customer].merge!(:mailing_list_id => @mailing_list.id)\n @customer = Customer.new(params[:customer])\n\n respond_to do |format|\n if @customer.save\n flash[:notice] = 'Customer was successfully created.'\n format.html { redirect_to mailing_list_customers_path }\n format.xml { render :xml => @customer, :status => :created, :location => @customer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @message = Mailboxer::Message.new\n p User.get_recipient_list(@user.id)\n p 'hola world'\n @recipients = User.get_recipient_list(@user.id)\n end", "def create_easypost_address\n EasyPost::Address.create(\n name: full_name,\n street1: street,\n street2: street2,\n city: city,\n state: state,\n zip: postal_code,\n country: 'US',\n verify_strict: ['delivery']\n )\n end", "def create\n # Check that there is at least something entered in the recipients and body field\n if mail_params[:recipients].blank? || mail_params[:body].blank?\n flash[:error] = \"Either recipients or body missing. Retry.\"\n redirect_to '/'\n return\n end\n\n # Loop through the recipients list breaking on every ',' character (Strips whitespace first)\n mail_params[:recipients].strip.split(\",\").each do |recipient|\n DemoMailer.send_email(recipient, mail_params[:body]).deliver_later\n end\n\n flash[:success] = \"Emails Sent.\"\n redirect_to '/'\n end", "def add_address(address)\n @addresses << address\n end", "def add_contacts\n \tap \"adding contacts\"\n # asking whether we are already authorized\n AddressBook.request_authorization unless AddressBook.authorized?\n\n \n if AddressBook.authorized?\n 25.times do\n person = AddressBook::Person.create(\n :first_name => Forgery::Name.first_name, \n :last_name => Forgery::Name.last_name, \n :email => [{ :value => Forgery(:internet).email_address , :label => 'Home'}], :phones => [{ :value => rand(10 ** 10).to_s, :label => 'Mobile'}])\n end\n else\n #ap \"This app is not authorized to access the address book.\"\n end\n #enVd\n end", "def mailing_list_params\n params.permit(:fname, :lname, :phone, :company, :email_address)\n end", "def mailing_list_params\n params.permit(:fname, :lname, :phone, :company, :email_address)\n end", "def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end", "def blank_join_list\n if params[:signup] && params[:signup][:email]\n pw = Digest::SHA1.hexdigest(\"--#{Time.now.to_s}#{self.object_id}#{Array.new(256){rand(256)}.join}\")\n user = User.new\n user.password = user.password_confirmation = pw\n user.email = params[:signup][:email]\n user.name = user.email # only by default \n\n if user.save_without_session_maintenance\t# prevents auto-login\n #flash[:notice] = \"We will add <strong>#{params[:signup][:email]}</strong> to the #{params[:signup][:list]} newsletter. #{params[:signup][:welcome]}\"\n flash[:notice] = params[:signup][:welcome] \n user.roles << Role.find_by_name(\"mail_list\")\n user.mailing_lists << MailingList.find_by_name(params[:signup][:list])\n else\n flash[:notice] = \"Email address not added. It did not look like a valid address, or has already been used. Please try again.\"\n end\n end\n redirect_back_or_default products_path\n end", "def contact_list_params\n params.require(:contact_list).permit(email_addresses: [])\n end", "def create\n @mail_user = MailUser.find_by(name_params)\n\n if !['included', 'excluded'].include?(@type)\n redirect_to @recipient_list, alert: '指定のリストにユーザーは追加できません。'\n elsif @mail_user\n @recipient = Recipient.find_or_create_by(recipient_list: @recipient_list, mail_user: @mail_user)\n @recipient.update_column(@type, true)\n\n redirect_to @recipient_list, notice: '指定のリストにユーザーを追加しました。'\n else\n redirect_to @recipient_list, alert: '該当する名前のユーザーはいません。'\n end\n end", "def create\n @contact = Contact.new\n @contact.first_name=params[:first_name]\n @contact.last_name=params[:last_name]\n @contact.email=params[:email]\n @contact.org=params[:org]\n @contact.events=params[:events]\n @contact.interests=params[:interests]\n @contact.save\n\n contacts_list\n end", "def add_list(access_token, list)\n url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.lists')\n url = build_url(url)\n payload = list.to_json\n response = RestClient.post(url, payload, get_headers(access_token))\n Components::ContactList.create(JSON.parse(response.body))\n end", "def create(subject, ow)\n @overwork = ow\n mail subject: subject,\n from: ow.user.email,\n to: ow.user.bosses.map{|boss| boss.email},\n bcc: ow.user.email\n\n end", "def create(name)\n Iterable.request(conf, '/lists').post(name: name)\n end", "def create\n @invite_friend = InviteFriend.new\n @invite_friend.friends_email=params[:email]\n @invite_friend.uid=logged_in_hmm_user.id\n \n \n if @invite_friend.save\n frindslist=@invite_friend.friends_email.split(',')\n for i in frindslist\n Postoffice.deliver_invite(logged_in_hmm_user.v_fname,logged_in_hmm_user.v_e_mail,i)\n end\n redirect_to :controller => 'invite_friends',:action =>'list'\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @invite_friend.errors.to_xml }\n end\n \n \n end", "def new_order(order)\n @order = order\n @lead = @order.selected\n @user = @order.selector\n mail(to: @user.email, subject: 'Check your address book')\n end", "def new_lead(lead)\n @greeting = \"Hi\"\n @lead = lead\n\n mail to: \"[email protected]\", subject: \"New Lead\"\n end", "def create_list(name)\n path = \"lists\"\n params = { list: { name: name }}\n list = request(path, params, :post)\n list_id = list[:id]\n # output full list again\n show_list(list_id)\n end", "def add_list_member(f)\n File.open f, 'r' do |file|\n file.each do |email|\n print email\n RestClient.post(\"https://api:key-#{API_KEY}\" \\\n \"@api.mailgun.net/v3/lists/#{LIST}@#{DOMAIN_NAME}/members\",\n :subscribed => true,\n :address => email.chomp!,\n :upsert => true )\n end\n end\nend", "def add_list(contact_list)\n if contact_list.instance_of?(ContactList)\n list = contact_list\n elsif contact_list.to_i.to_s == contact_list\n list = ContactList.new(contact_list)\n else\n raise Exceptions::IllegalArgumentException, sprintf(Util::Config.get('errors.id_or_object'), 'ContactList')\n end\n\n @sent_to_contact_lists << list\n end", "def create_contact\n @contact = Spree::Address.new(contact_params)\n # Currently for demo, I will leave the country id to be 1, later update will be noticed!\n hard_code_contact(contact_params)\n respond_to do |format|\n if @contact.save\n @seller.spree_addresses << @contact\n format.html { redirect_to contacts_admin_seller_path, notice: \"Contacts #{@contact.firstname} #{@contact.lastname} is successfully created!\" }\n else\n flash[:error] = @contact.errors.full_messages\n format.html { render :new_contact }\n format.json { render :new_contact, status: :unprocessable_entity }\n end\n end\n end", "def announce_add(listname,domain,email,name=\"\")\n doc = request(\"announcement_list-add_subscriber\",\n {\"listname\" => listname, \"domain\" => domain, \"email\" => email, \"name\" => name})\n api_error?(doc)\n true\n end", "def add_address\n \n params[:place]\n address = ReceiverAddress.new(:label => params[:place], \n :city_id => params[:city_id], \n :address => params[:address])\n @receive.document = \"234\"\n @receiver.receiver_addresses << address\n respond_to do |format|\n format.html { render @receiver, action ='new'}\n end\n end", "def create_address\n \"#{Faker::Address.street_address}, #{Faker::Address.city}, #{Faker::Address.state} #{Faker::Address.zip}\"\nend", "def subscribe_to_lists(list_names, email)\n walk_recipients(list_names, email) do |lr, list_id, contact_id|\n if lr.nil?\n ::Mailjet::Listrecipient.create(list_id: list_id, contact_id: contact_id, is_unsubscribed: 'false')\n elsif lr.is_unsubscribed\n lr.update_attributes(is_unsubscribed: 'false', unsubscribed_at: nil)\n end\n end\n rescue ::Mailjet::ApiError\n # ignore\n end", "def create_address(addr, **opts)\n Address.create(@id, addr.to_s, node: node, address: subnet.subnet_addr(addr), **opts)\n end", "def create_list(name, template, options = {}, &blk)\n\t\t\t # create the new list\n\t\t\t new_list = Lists.create_list(@web, name, template, options)\n\t\t\t context_for_new_object(new_list, ListContext, &blk)\n\t\t\tend", "def notifyRecipients (statusMsgAddress, statusMsgPassword, recipientList, downTitle, downMessage)\n recipientList.length.times do |i|\n msg = \"Subject: #{downTitle}\\n\\n#{downMessage}\"\n smtp = Net::SMTP.new 'smtp.gmail.com', 587\n smtp.enable_starttls\n smtp.start(\"gmail\", statusMsgAddress, statusMsgPassword, :login) do\n smtp.send_message(msg, statusMsgAddress, recipientList[i])\n end\n end\nend", "def on_create(instructable, address)\n @instructable = instructable\n if address == @instructable.user.email\n @reason = 'you created this class'\n else\n @reason = 'you are an admin of the system'\n end\n\n mail(to: address, subject: \"Class added: #{@instructable.name}\")\n end", "def list\n @mailing_list.contacts(limit: 10000).map{|contact| contact.email}\n end", "def add_to_email_address(email_address, friendly_name = nil)\n convert_email_address(@to_email_address, email_address, friendly_name)\n end", "def create_address!\n method_not_implemented\n end", "def create(name, email)\n id = 1\n CSV.foreach(\"contact_data.csv\") { |line| id += 1}\n contact_list = CSV.open(\"contact_data.csv\", 'a')\n new_contact = [id,name,email]\n contact_list << new_contact\n id\n end", "def add_ip_addresses(addresses, comment=\"\", list=\"GFWed\")\n logger.info \"addresses: #{addresses}\"\n message = \"\"\n counter = 0\n addresses.gsub!(\"\\r\", \"\")\n addresses.split(\"\\n\").each do |address|\n counter += 1\n message += add_ip_address(address, comment, list, false)\n end\n \n message = message == \"\" ? \"#{settings.rui_host}: #{counter} ip addresses add commands was sent.\" : message\n return message\n end", "def create_item(list_id, content, responsible_party=nil, notify=true)\n record \"/todos/create_item/#{list_id}\",\n :content => content, :responsible_party => responsible_party,\n :notify => notify\n end", "def create_address!(options = {})\n method_not_implemented\n end", "def add_to_allowed_list(email)\n send_contact_command email, 'ADL', '2'\n end", "def create_list(name)\n Wunderlist::List.new(name, false, self).save\n end", "def mailing_address\n return unless @user.loa3?\n\n dig_out('addresses', 'address_pou', VAProfile::Models::Address::CORRESPONDENCE)\n end", "def make_address (street, city, state, zip)\n\n\t \"You live at \" + street + \", in the beautiful city of \" + city + \", \" + state + \". Your zip is \" + zip + \".\"\nend" ]
[ "0.71838236", "0.7044075", "0.6479478", "0.6473532", "0.63066816", "0.6094493", "0.607733", "0.6019209", "0.60179317", "0.6014871", "0.5962647", "0.5930004", "0.5929772", "0.5924748", "0.59244263", "0.5890285", "0.588425", "0.58803403", "0.5858954", "0.5850831", "0.5850385", "0.5835778", "0.5833496", "0.58166116", "0.5758215", "0.57581764", "0.5749279", "0.57453346", "0.5740088", "0.5723883", "0.5703576", "0.569601", "0.568788", "0.5662889", "0.56584966", "0.5644063", "0.56419635", "0.5631412", "0.56269425", "0.5621878", "0.5618158", "0.56091195", "0.5604828", "0.55974126", "0.55928695", "0.55893785", "0.5585364", "0.5585261", "0.55521286", "0.55435413", "0.553936", "0.55367285", "0.55268514", "0.5491211", "0.5490798", "0.5490492", "0.54895735", "0.5460507", "0.5458596", "0.5451396", "0.543616", "0.5435232", "0.54326284", "0.5428955", "0.54243493", "0.54242486", "0.54234564", "0.5423234", "0.54125035", "0.54080373", "0.539624", "0.5395185", "0.53939664", "0.5393117", "0.53910935", "0.5390348", "0.5388843", "0.5385888", "0.53841084", "0.5382682", "0.5373567", "0.5372048", "0.53547275", "0.5354112", "0.5351551", "0.5350659", "0.53410506", "0.53395444", "0.5338839", "0.53379", "0.53368026", "0.5333749", "0.53337055", "0.5328407", "0.5328122", "0.5326334", "0.53185254", "0.5317595", "0.53172344", "0.53153056" ]
0.7912631
0
Update a mailing list with a given address with an optional new address, name or description
def update(address, new_address, options={}) params = {:address => new_address} Mailgun.submit :put, list_url(address), params.merge(options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @address = args[:address] if args.key?(:address)\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @business_name = args[:business_name] if args.key?(:business_name)\n end", "def update_contact(list_id, email, attributes = {}, user_status = {})\n endpoint = \"/api/#{@version}/list/#{list_id}/update-contact/\"\n custom_params = {\n \"email\" => email,\n 'attributes' => attributes,\n 'user_status' => user_status\n }\n make_post_request(endpoint, custom_params)\n end", "def update_address_book(address_book_id, prop_patch)\n end", "def update_contact(list_id, email, attributes={})\n endpoint = \"/api/v1/list/#{list_id}/update-contact/\"\n base_params = base_params(endpoint)\n custom_params = {\n \"email\" => email,\n 'attributes' => attributes\n }\n uri = post_api_uri(endpoint)\n http = setup_request(uri)\n result = http.post(uri.path, base_params.merge(custom_params).to_query)\n JSON.parse(result.body)\n end", "def update(id, params = {})\n @client.call(method: :put, path: \"recipient-lists/#{id}\", body_values: params.slice(:name, :description, :attributes, :recipients))\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @phone_number = args[:phone_number] if args.key?(:phone_number)\n end", "def edit_library_address(selected)\n\tl = Library.find(selected)\n\tprint \"To edit the library address please enter here: \"\n\taddress = gets.chomp\n\tl.update_attributes(address: address)\nend", "def edit_address(edited_address)\n address = Address.find(edited_address.uid)\n address.attributes = edited_address.attributes\n address.save!\n end", "def update!(**args)\n @email_address = args[:email_address] if args.key?(:email_address)\n end", "def update!(**args)\n @email_address = args[:email_address] if args.key?(:email_address)\n end", "def update_mailchimp(list_name, old_email = self[email_column])\n apikey ||= chimpLogin(monkeybrains[:username], monkeybrains[:password])\n list_id ||= find_mailing_list(apikey, list_name)\n vars = {}\n vars.merge!({\"FNAME\" => self[fname_column]}) if self.has_attribute?(fname_column)\n vars.merge!({\"LNAME\" => self[lname_column]}) if self.has_attribute?(lname_column)\n vars.merge!({\"EMAIL\" => self[email_column]})\n chimpUpdate(apikey, list_id[\"id\"], old_email, vars, self[type_column], true)\n rescue XMLRPC::FaultException\n end", "def update_and_merge(address, addresses)\n if !address.editable? # Should not happen via UI unless order has detached address not on user\n address.errors.add(:base, I18n.t(:address_not_editable, scope: [:address_book]))\n return address\n end\n\n user = address.user\n new_address = address.clone\n new_address.attributes = address_params\n new_match = addresses.find(new_address)\n old_match = addresses.find(address)\n\n attrs = address_params\n\n if new_match && new_match != old_match\n # The new address data matches a group, the existing data potentially\n # matches a different group. Need to destroy the old group, deduplicate\n # and modify the new group, and reassign default addresses as needed.\n address = new_match.primary_address\n\n # Destroy any old matching addresses, if possible.\n old_match.destroy if old_match\n new_match.destroy_duplicates\n\n # Update any remaining editable addresses.\n old_match.update_all_attributes(attrs) if old_match\n new_match.update_all_attributes(attrs)\n elsif old_match\n # The old address data matches a group, the new data is identical or does\n # not match a group. Need to update the existing addresses with the new\n # data and deduplicate.\n address = old_match.primary_address\n\n # Deduplicate and update the existing addresses.\n old_match.destroy_duplicates\n old_match.update_all_attributes(attrs)\n else\n # No matching group; just update the address and rely on order and user\n # callbacks to synchronize addresses.\n address.update_attributes(attrs)\n end\n\n # Update default address assignments in case they were destroyed\n if address.user_id && user && address.user_id == user.id\n user.bill_address_id = address.id if new_match.try(:user_bill) || old_match.try(:user_bill)\n user.ship_address_id = address.id if new_match.try(:user_ship) || old_match.try(:user_ship)\n\n if user.changed? && !user.save\n address.errors.add(:user, user.errors.full_messages.to_sentence)\n end\n end\n\n return address, new_match, old_match\n end", "def update\n\t @address_type_list = AddressTypeList.find(params[:id])\n respond_to do |format|\n if @address_type_list.update(address_type_list_params)\n format.html { redirect_to @address_type_list, notice: 'Address type list was successfully updated.' }\n format.json { render :show, status: :ok, location: @address_type_list }\n else\n format.html { render :edit }\n format.json { render json: @address_type_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_or_insert(list_id:, recipient_id:, email:, attribute_names:, attribute_values:)\n update(\n list_id: list_id,\n recipient_id: recipient_id,\n attribute_names: attribute_names,\n attribute_values: attribute_values)\n rescue OptivoApi::RecipientNotInList\n safe_add(\n list_id: list_id,\n recipient_id: recipient_id,\n email: email,\n attribute_names: attribute_names,\n attribute_values: attribute_values)\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @geo_location = args[:geo_location] if args.key?(:geo_location)\n end", "def update(firstname, lastname, email=nil)\n end", "def update\n begin\n saved = @address.update!(address_params)\n save_redirector saved, @address, \"Address was successfully updated.\"\n rescue ActiveRecord::RecordInvalid => e\n redirect_to edit_address_path(@address), notice: e.message\n end\n end", "def update!(**args)\n @email_address = args[:email_address] if args.key?(:email_address)\n @name = args[:name] if args.key?(:name)\n end", "def update\n @address = Address.find(params[:id])\n @address.update_attributes(params[:address])\n @addresses = Address.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n end", "def edit_address(order_or_user, address_id, expect_success, values, type=nil)\n visit_edit_address(order_or_user, address_id)\n fill_in_address(values, type)\n click_button Spree.t('actions.update')\n\n if expect_success\n expect_address_collection_path(order_or_user)\n expect(page).to have_content(Spree.t(:successfully_updated, resource: Spree::Address.model_name.human))\n else\n expect(page).to have_no_content(Spree.t(:successfully_updated, resource: Spree::Address.model_name.human))\n expect(path_with_query).to eq(spree.admin_address_path(address_id, user_id: @user_id, order_id: @order_id))\n end\n end", "def update_list(access_token, list)\n url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.list'), list.id)\n url = build_url(url)\n payload = list.to_json\n response = RestClient.put(url, payload, get_headers(access_token))\n Components::ContactList.create(JSON.parse(response.body))\n end", "def update\n @address = current_user.addresses.find(params[:id])\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to \"/#{current_user.name}\", notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n @address.phones.build\n @address.faxs.build\n @address.emails.build\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def address_list_assign(field_name, addresses)\n if addresses.kind_of?(Array)\n value = addresses.collect { |e|\n if e.kind_of?(RMail::Address)\n e.format\n else\n RMail::Address.parse(e.to_str).collect { |a|\n a.format\n }\n end\n }.flatten.join(\", \")\n set(field_name, value)\n elsif addresses.kind_of?(RMail::Address)\n set(field_name, addresses.format)\n else\n address_list_assign(field_name,\n RMail::Address.parse(addresses.to_str))\n end\n end", "def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to admin_path(current_user), notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render admin_path(current_user), error: 'Issue.' }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @mailing_list = MailingList.find(params[:id])\n\n respond_to do |format|\n if @mailing_list.update_attributes(params[:mailing_list])\n format.html { redirect_to @mailing_list, notice: 'Mailing list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mailing_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_address(id, params)\n put(\"addresses/#{id}\", address: params, change_case: false)\n end", "def update\n @mailinglist = Mailinglist.find(params[:id])\n\n respond_to do |format|\n if @mailinglist.update_attributes(params[:mailinglist])\n flash[:notice] = 'Mailinglist was successfully updated.'\n format.html { redirect_to(@mailinglist) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mailinglist.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mailing_list.update(mailing_list_params)\n format.html { redirect_to @mailing_list, notice: 'Mailing list was successfully updated.' }\n format.json { render :show, status: :ok, location: @mailing_list }\n else\n format.html { render :edit }\n format.json { render json: @mailing_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @address = @addressable.addresses.find_by_id(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to current_user, notice: 'address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @locality = args[:locality] if args.key?(:locality)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipient = args[:recipient] if args.key?(:recipient)\n @region_code = args[:region_code] if args.key?(:region_code)\n end", "def merge_update(m_address)\n merge_with_overwrite(m_address,\n :address_1,\n :address_2,\n :city,\n :state,\n :zip\n )\n end", "def update!(**args)\n @email_address = args[:email_address] if args.key?(:email_address)\n @fax_number = args[:fax_number] if args.key?(:fax_number)\n @name = args[:name] if args.key?(:name)\n @office_phone_number = args[:office_phone_number] if args.key?(:office_phone_number)\n @title = args[:title] if args.key?(:title)\n end", "def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to home_path, notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_or_replace_address(address, existing_addresses)\n # Update the registration's nested addresses, replacing any existing address of the same type\n updated_addresses = existing_addresses\n matched_address = updated_addresses.find(existing_address.id) if existing_address\n\n if matched_address\n updated_addresses.delete(matched_address)\n matched_address.delete\n end\n\n updated_addresses << address if address\n\n updated_addresses\n end", "def create_address\n if @ok\n @mailing_list_address = MailingListAddress.new\n @mailing_list_address.group_id = @mailing_list_group.id\n @mailing_list_address.heading = params[:heading]\n @mailing_list_address.email = params[:email]\n @ok = @mailing_list_address.save\n end\n render 'update_addresses'\n end", "def update_list(list_id, name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"patch\", \"lists/#{list_id}\", data)\n end", "def update_address(address, profile_id)\n @type = Type::CIM_UPDATE_ADDRESS\n @fields.merge!(address.to_hash)\n handle_profile_id(profile_id)\n make_request\n end", "def update!(**args)\n @address_pools = args[:address_pools] if args.key?(:address_pools)\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @address_line = args[:address_line] if args.key?(:address_line)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @dependent_locality = args[:dependent_locality] if args.key?(:dependent_locality)\n @language_code = args[:language_code] if args.key?(:language_code)\n @lat_lng = args[:lat_lng] if args.key?(:lat_lng)\n @locality = args[:locality] if args.key?(:locality)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @region_code = args[:region_code] if args.key?(:region_code)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n end", "def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to root_path, notice: 'Address was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update_address\n\t\tif !params[:profile_setting].present?\n\t\t\tredirect_to user_profile_data_profile_path \n\t\telse\n\t\t\t@address = @user.update_attributes(address_params)\n\t\t\tif @address\n\t\t\t\t# redirect to the profile app page\n\t\t\t\tredirect_to user_profile_data_profile_path\n\t\t\telse\n\t\t\t\t# redirect to the user address page\n\t\t\t\tredirect_to user_address_profiles_path(type: params[:address_type])\n\t\t\t\tflash[:notice] = \"Address can't be blank\"\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @event_mailing_list.update(event_mailing_list_params)\n format.html { redirect_to @event_mailing_list, notice: 'Event mailing list was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_mailing_list }\n else\n format.html { render :edit }\n format.json { render json: @event_mailing_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_list(list_id:, name:)\n check_token\n list = Todoable::List.new(name: name)\n response = self.class.patch(\n \"/lists/#{list_id}\",\n body: list.post_body,\n headers: headers,\n format: :text\n )\n check_and_raise_errors(response)\n # This endpoint returns a plaintext body: \"<new name> updated\", so\n # while I'd like to return a List with ListItems, that would require\n # first looking up the list which isn't ideal. So we'll return true, ask\n # todoable to fix this endpoint, and make developers keep track of the\n # name change\n true\n end", "def update\n respond_to do |format|\n if @mail_list.update(mail_list_params)\n format.html { redirect_to [:admin, @mail_list], notice: 'Mail list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mail_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def contact_update(handle, fields)\n fields = contact_prepare(fields)\n fields[:handle] = handle\n query 'contact-modify', fields\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @city = args[:city] if args.key?(:city)\n @country = args[:country] if args.key?(:country)\n @email = args[:email] if args.key?(:email)\n @phone = args[:phone] if args.key?(:phone)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @state = args[:state] if args.key?(:state)\n @web_url = args[:web_url] if args.key?(:web_url)\n end", "def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @addresses = args[:addresses] if args.key?(:addresses)\n @avoid_buggy_ips = args[:avoid_buggy_ips] if args.key?(:avoid_buggy_ips)\n @manual_assign = args[:manual_assign] if args.key?(:manual_assign)\n @pool = args[:pool] if args.key?(:pool)\n end", "def update!(**args)\n @addresses = args[:addresses] if args.key?(:addresses)\n @avoid_buggy_ips = args[:avoid_buggy_ips] if args.key?(:avoid_buggy_ips)\n @manual_assign = args[:manual_assign] if args.key?(:manual_assign)\n @pool = args[:pool] if args.key?(:pool)\n end", "def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to @address, notice: \"Address was successfully updated.\" }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @address = current_user.addresses.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to user_address_path(current_user, @address), notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def delivery_address_update\n # stores the current delivery address\n delivery_address = @current_user.addresses.find_by(delivery_address: true)\n delivery_address.delivery_address = nil\n delivery_address.save!\n # changes the current delivery address to the given address id as a parameter\n address = @current_user.addresses.find(params[:id])\n address.delivery_address = true\n address.save!\n redirect_to cart_items_path\n end", "def update\n sql = \"UPDATE contacts SET name = ?, phone_number = ?, address = ?, email = ? WHERE id = ?\"\n DB[:conn].execute(sql, name, phone_number, address, email, id)\n end", "def edit_address\n traveller = Traveller.find(params[:pk])\n address = params[:value]\n\n coordinates = GoogleAPIGeocoder.do_geocode(address)\n\n if coordinates.nil?\n render json: {success: false, msg: 'Unable to find the location of the given address. Please check that it is correct.'}\n else\n traveller.update(address: address, latitude: coordinates[0], longitude: coordinates[1])\n\n if current_user.nil?\n if session[:trip] != nil\n travellers = session[:trip].travellers\n travellers[travellers.index(traveller)].address = params[:value]\n end\n\n if session[:travellers] != nil\n session[:travellers][session[:travellers].index(traveller)].address = params[:value]\n end\n end\n\n render json: {success: true}\n end\n end", "def update!(**args)\n @addr_fprint = args[:addr_fprint] if args.key?(:addr_fprint)\n @address = args[:address] if args.key?(:address)\n @lat_e7 = args[:lat_e7] if args.key?(:lat_e7)\n @lng_e7 = args[:lng_e7] if args.key?(:lng_e7)\n end", "def update\n respond_to do |format|\n if @post_address.update(post_address_params)\n format.html { redirect_to @post_address, notice: 'Adress uppdaterad.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post_address.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_addresslist\n @addresslist = Addresslist.find(params[:id])\n @cancel_path = addresslist_path(@addresslist)\n end", "def update!(**args)\n @email = args[:email] if args.key?(:email)\n @location_details = args[:location_details] if args.key?(:location_details)\n @name = args[:name] if args.key?(:name)\n end", "def update_list(list_name, text)\n update_value(\"#{list_name}-list\", text)\n end", "def update\n # @address = Address.find(params[:id])\n @address = Address.find_by_permalink!(params[:id])\n \n respond_to do |format|\n if @address.update_attributes(params[:address])\n \n flash[:notice] = 'Address was successfully updated.'\n format.html { redirect_to(@address) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @address.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_address.update(user_address_params)\n format.html { redirect_to user_addresses_path, notice: 'User address was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to edit_company_path(@company), notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ag_address.update(ag_address_params)\n format.html { redirect_to @ag_address, notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: @ag_address }\n else\n format.html { render :edit }\n format.json { render json: @ag_address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @email_list = EmailList.find(params[:id])\n\n respond_to do |format|\n if @email_list.update_attributes(params[:email_list])\n format.html { redirect_to(@email_list, :notice => 'Email list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @email_list.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @fixability = args[:fixability] if args.key?(:fixability)\n @fixable_email_address = args[:fixable_email_address] if args.key?(:fixable_email_address)\n @out_of_domain_warning_email_address = args[:out_of_domain_warning_email_address] if args.key?(:out_of_domain_warning_email_address)\n end", "def update!(**args)\n @location_address = args[:location_address] if args.key?(:location_address)\n @location_name = args[:location_name] if args.key?(:location_name)\n end", "def update!(**args)\n @addr_fprint = args[:addr_fprint] if args.key?(:addr_fprint)\n @biz_name = args[:biz_name] if args.key?(:biz_name)\n @phone_fprint = args[:phone_fprint] if args.key?(:phone_fprint)\n end", "def update\n respond_to do |format|\n if @email_list.update(email_list_params)\n format.html { redirect_to @email_list, notice: 'Email list was successfully updated.' }\n format.json { render :show, status: :ok, location: @email_list }\n else\n format.html { render :edit }\n format.json { render json: @email_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @address\n\n respond_to do |format|\n if @address.update(@pars)\n flash[:success] = \"Address was successfully updated. #{@pars.inspect}\"\n format.html { redirect_to addresses_path }\n format.json { render json: {locale: I18n.locale,\n user_id: @user_id,\n recyclable: @address.recyclable} }\n else\n flash[:danger] = \"There was a problem updating the address.\"\n format.html { render action: 'edit' }\n format.json { render json: @address.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @country = args[:country] if args.key?(:country)\n @full_address = args[:full_address] if args.key?(:full_address)\n @is_post_office_box = args[:is_post_office_box] if args.key?(:is_post_office_box)\n @locality = args[:locality] if args.key?(:locality)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipient_name = args[:recipient_name] if args.key?(:recipient_name)\n @region = args[:region] if args.key?(:region)\n @street_address = args[:street_address] if args.key?(:street_address)\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @end_date = args[:end_date] if args.key?(:end_date)\n @latitude = args[:latitude] if args.key?(:latitude)\n @longitude = args[:longitude] if args.key?(:longitude)\n @name = args[:name] if args.key?(:name)\n @notes = args[:notes] if args.key?(:notes)\n @polling_hours = args[:polling_hours] if args.key?(:polling_hours)\n @sources = args[:sources] if args.key?(:sources)\n @start_date = args[:start_date] if args.key?(:start_date)\n @voter_services = args[:voter_services] if args.key?(:voter_services)\n end", "def update!(**args)\n @address_lines = args[:address_lines] if args.key?(:address_lines)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @language_code = args[:language_code] if args.key?(:language_code)\n @locality = args[:locality] if args.key?(:locality)\n @organization = args[:organization] if args.key?(:organization)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipients = args[:recipients] if args.key?(:recipients)\n @region_code = args[:region_code] if args.key?(:region_code)\n @revision = args[:revision] if args.key?(:revision)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n @sublocality = args[:sublocality] if args.key?(:sublocality)\n end", "def update!(**args)\n @address_lines = args[:address_lines] if args.key?(:address_lines)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @language_code = args[:language_code] if args.key?(:language_code)\n @locality = args[:locality] if args.key?(:locality)\n @organization = args[:organization] if args.key?(:organization)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipients = args[:recipients] if args.key?(:recipients)\n @region_code = args[:region_code] if args.key?(:region_code)\n @revision = args[:revision] if args.key?(:revision)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n @sublocality = args[:sublocality] if args.key?(:sublocality)\n end", "def update!(**args)\n @address_lines = args[:address_lines] if args.key?(:address_lines)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @language_code = args[:language_code] if args.key?(:language_code)\n @locality = args[:locality] if args.key?(:locality)\n @organization = args[:organization] if args.key?(:organization)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipients = args[:recipients] if args.key?(:recipients)\n @region_code = args[:region_code] if args.key?(:region_code)\n @revision = args[:revision] if args.key?(:revision)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n @sublocality = args[:sublocality] if args.key?(:sublocality)\n end", "def update!(**args)\n @address_lines = args[:address_lines] if args.key?(:address_lines)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @language_code = args[:language_code] if args.key?(:language_code)\n @locality = args[:locality] if args.key?(:locality)\n @organization = args[:organization] if args.key?(:organization)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipients = args[:recipients] if args.key?(:recipients)\n @region_code = args[:region_code] if args.key?(:region_code)\n @revision = args[:revision] if args.key?(:revision)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n @sublocality = args[:sublocality] if args.key?(:sublocality)\n end", "def update!(**args)\n @address_lines = args[:address_lines] if args.key?(:address_lines)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @language_code = args[:language_code] if args.key?(:language_code)\n @locality = args[:locality] if args.key?(:locality)\n @organization = args[:organization] if args.key?(:organization)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipients = args[:recipients] if args.key?(:recipients)\n @region_code = args[:region_code] if args.key?(:region_code)\n @revision = args[:revision] if args.key?(:revision)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n @sublocality = args[:sublocality] if args.key?(:sublocality)\n end", "def update!(**args)\n @address_lines = args[:address_lines] if args.key?(:address_lines)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @language_code = args[:language_code] if args.key?(:language_code)\n @locality = args[:locality] if args.key?(:locality)\n @organization = args[:organization] if args.key?(:organization)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n @recipients = args[:recipients] if args.key?(:recipients)\n @region_code = args[:region_code] if args.key?(:region_code)\n @revision = args[:revision] if args.key?(:revision)\n @sorting_code = args[:sorting_code] if args.key?(:sorting_code)\n @sublocality = args[:sublocality] if args.key?(:sublocality)\n end", "def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:test])\n format.html { render :partial => 'addresses/show', notice: 'Address was successfully updated.' }\n else\n format.html { render :partial => 'addresses/edit' }\n end\n end\n end", "def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to @address, notice: 'Form was updated successfully!' }\n format.json { render :show, status: :ok, location: @address }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_or_create_address(attributes)\n if attributes[:id]\n # TODO: Delete this part of the IF? It never gets called during tests.\n address = Spree::Address.find(attributes[:id])\n if address.editable?\n address.update_attributes(attributes)\n else\n address.errors.add(:base, I18n.t(:address_not_editable, scope: [:address_book]))\n end\n else\n address = Spree::Address.new(attributes)\n end\n address\n end", "def update\n respond_to do |format|\n if @address_detail.update(address_detail_params)\n format.html { redirect_to @address_detail, notice: 'Address detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @address_detail }\n else\n format.html { render :edit }\n format.json { render json: @address_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_contact(options={})\n contact_list_id = options.delete(:list_id)\n old_email = options.delete(:old_email)\n\n request_body = String.new\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n\n xml.instruct!\n xml.Envelope do\n xml.Body do\n xml.UpdateRecipient do\n xml.LIST_ID contact_list_id\n xml.OLD_EMAIL old_email\n\n options.each do |field, value|\n xml.COLUMN do\n xml.NAME field\n xml.VALUE value\n end\n end\n end\n end\n end\n\n doc = send_xml_api_request(request_body)\n result_dom(doc)['RecipientId']\n end", "def update_contact_info post\n AddressManager::set_user_address post.user, post\n end", "def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @address_book = AddressBook.find(params[:id])\n\n respond_to do |format|\n if @address_book.update_attributes(params[:address_book])\n flash[:notice] = :address_book_updated.l\n format.html { redirect_to(address_books_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @address_book.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if current_user\n @address = Address.find(params[:id])\n if current_user == @address.user\n address = Address.new(params[:address])\n address.user = current_user\n if address.save\n @address.update_attributes(:status => 'deleted')\n flash[:notice] = I18n.t(\"stizun.address.address_changed\")\n redirect_to user_addresses_path(current_user)\n else\n flash[:error] = I18n.t(\"stizun.address.address_couldnt_be_saved\")\n render :action => 'edit'\n end\n else\n flash[:error] = I18n.t(\"stizun.address.you_have_no_permission_to_edit\")\n redirect_to root_path\n end\n end\n end", "def set_address(address)\n @fields.merge!(address.to_hash)\n end", "def update\n user = User.find(params[:id])\n if user.address.update(address_params)\n render status: :ok\n else\n render status: :unprocessable_entity #was :bad_request\n end\n end", "def update\n @address = Address.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to @address, :notice => 'Address was successfully updated.' }\n format.json { render :json => @address }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @address.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @address_groups = args[:address_groups] if args.key?(:address_groups)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @address_lines = args[:address_lines] if args.key?(:address_lines)\n @sub_locality = args[:sub_locality] if args.key?(:sub_locality)\n @locality = args[:locality] if args.key?(:locality)\n @administrative_area = args[:administrative_area] if args.key?(:administrative_area)\n @country = args[:country] if args.key?(:country)\n @postal_code = args[:postal_code] if args.key?(:postal_code)\n end", "def update!(**args)\n @mailer_contact_name = args[:mailer_contact_name] if args.key?(:mailer_contact_name)\n end", "def update_list(user, list, options={})\n post(\"/#{user}/lists/#{list}.json\", options)\n end", "def add_address(addresses, address)\n address[:postcode] = postcode\n addresses.push(AddressSummary.new_from_search(address))\n end", "def update\n @user_address = UserAddress.find(params[:id])\n\n respond_to do |format|\n if @user_address.update_attributes(params[:user_address])\n format.html { redirect_to(@user_address, :notice => 'User address was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_address.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @address.update(address_params)\n render json: @address\n else\n render json: @address.errors, status: :unprocessable_entity\n end\n end" ]
[ "0.6679444", "0.6426836", "0.64000386", "0.6370609", "0.62479097", "0.62142956", "0.62118226", "0.6187356", "0.6164377", "0.6160676", "0.6160676", "0.6142797", "0.6135446", "0.61072063", "0.60949093", "0.60574806", "0.60353005", "0.6027851", "0.6025905", "0.599905", "0.5987342", "0.59757847", "0.5975779", "0.5964851", "0.59628695", "0.5954871", "0.5950527", "0.59460706", "0.5924909", "0.59095454", "0.5898045", "0.5867313", "0.58647954", "0.58625704", "0.58609986", "0.5858667", "0.58237517", "0.5817637", "0.58121985", "0.5798684", "0.5789948", "0.57895017", "0.5789204", "0.5779938", "0.5775119", "0.5762776", "0.5759469", "0.574761", "0.57472956", "0.57472956", "0.5737329", "0.57360876", "0.57338256", "0.5733652", "0.57331437", "0.5731167", "0.57299054", "0.5711123", "0.57045317", "0.56997013", "0.5689023", "0.5687652", "0.56835735", "0.5677935", "0.56724083", "0.5667662", "0.56622547", "0.5659741", "0.5657773", "0.5656755", "0.56528115", "0.56522495", "0.56481415", "0.56481415", "0.56481415", "0.56481415", "0.56481415", "0.56481415", "0.5646786", "0.56422824", "0.56376964", "0.5634896", "0.56279445", "0.56200963", "0.5617277", "0.5617277", "0.5617277", "0.5617277", "0.5612923", "0.5606403", "0.56029755", "0.55997", "0.5593113", "0.559251", "0.5578761", "0.55718994", "0.5569342", "0.5562402", "0.5556453", "0.5553512" ]
0.821938
0
Deletes a mailing list with a given address
def delete(address) Mailgun.submit :delete, list_url(address) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_address\n @mailing_list_address.destroy if @ok\n render 'update_addresses'\n end", "def delete_address_list(id)\n delete(\"addressGroups/#{id}\")\n end", "def delete_address(address)\n address.delete!\n end", "def delete(email, list_id = nil)\n query = \"email=#{CGI.escape(email)}\"\n query += \"&list_id=#{list_id}\" if list_id\n\n del \"#{@endpoint}?#{query}\", nil\n end", "def remove(email)\n @mailing_list.remove_contacts(email, force:true)\n end", "def remove_contact(list_id, email)\n endpoint = \"/api/#{@version}/list/#{list_id}/remove-contact/\"\n custom_params = {\n \"email\" => email\n }\n make_post_request(endpoint, custom_params)\n end", "def delete_contact(list_id, contact_id)\n delete(\"contactLists/#{list_id}/#{contact_id}\")\n end", "def destroy\n @mailinglist = Mailinglist.find(params[:id])\n @mailinglist.destroy\n\n respond_to do |format|\n format.html { redirect_to(mailinglists_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @mailing_list = MailingList.find(params[:id])\n @mailing_list.destroy\n\n respond_to do |format|\n format.html { redirect_to mailing_lists_url }\n format.json { head :no_content }\n end\n end", "def remove(address_or_id)\n delete(\"#{domain}/complaints/#{address_or_id}\")\n end", "def delete_list_contact(list_id, contact_id)\n full_path = full_resource_path(\"/#{list_id}/contacts/#{contact_id}\", \"lists\")\n query_params = MaropostApi.set_query_params\n \n MaropostApi.delete_result(full_path, query_params)\n end", "def delete\n @@contact_list.delete(self)\n end", "def delete\n @addresses = Address.where(person_id: params[:id])\n @addresses.each do |c|\n Address.find(c.id).destroy\n end\n Person.find(params[:id]).destroy\n redirect_to :action => 'list'\n end", "def delete_address(id)\n delete(\"addresses/#{id}\")\n end", "def destroy\n @mail_list.destroy\n respond_to do |format|\n format.html { redirect_to admin_mail_lists_url, notice: 'Mail list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end", "def delete_list(list_id)\n rest(\"delete\", \"lists/#{list_id}\")\n\n return true\n end", "def remove_contact(list_id, email)\n endpoint = \"/api/v1/list/#{list_id}/remove-contact/\"\n base_params = base_params(endpoint)\n custom_params = {\n \"email\" => email\n }\n uri = post_api_uri(endpoint)\n http = setup_request(uri)\n result = http.post(uri.path, base_params.merge(custom_params).to_query)\n JSON.parse(result.body)\n end", "def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { render :partial => 'addresses/list' }\n end\n end", "def delete_address_book(address_book_id)\n end", "def delete_contact(contact_to_delete)\n @contacts.delete(contact_to_delete)\n end", "def destroy\n @mailing_list.destroy\n respond_to do |format|\n format.html { redirect_to mailing_lists_url, notice: 'Mailing list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_list(id)\n query(\"DELETE FROM todos WHERE list_id = $1\", id)\n query(\"DELETE FROM lists WHERE id = $1\", id)\n end", "def delete(list_id)\n Iterable.request(conf, \"/lists/#{list_id}\").delete\n end", "def delete\n @address = Address.find(params[:address_id])\n end", "def delete_list(list)\n @lists[list.title].delete(list.title)\n end", "def destroy\n\t @address_type_list = AddressTypeList.find(params[:id])\n @address_type_list.destroy\n respond_to do |format|\n format.html { redirect_to address_type_lists_url, notice: 'Address type list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_address_group(id)\n delete(\"addressGroups/#{id}\")\n end", "def delete_todo_from_list(list_id, todo_id)\n sql = \"DELETE FROM todos WHERE id = $1 AND list_id = $2\"\n query(sql, todo_id, list_id)\n end", "def remove_from_friends_list(email)\n send_contact_command email, 'RML', '1'\n end", "def delete_address(order_or_user, address_id, expect_success)\n address_id = address_id.id if address_id.is_a?(Spree::Address)\n\n visit_addresses(order_or_user)\n\n click_link \"delete-address-#{address_id}\"\n\n if expect_success\n expect(page).to have_content(Spree.t(:successfully_removed, resource: Spree::Address.model_name.human))\n else\n expect(page).to have_no_content(Spree.t(:successfully_removed, resource: Spree::Address.model_name.human))\n end\n end", "def destroy\n @mailing_list = MailingList.find(params[:mailing_list_id])\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to(mailing_list_customers_url) }\n format.xml { head :ok }\n \n end\n end", "def delete(user)\n @@contact_list.delete(user)\n end", "def destroy\n @email_list = EmailList.find(params[:id])\n @email_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(email_lists_url) }\n format.xml { head :ok }\n end\n end", "def delete_entry(entry)\n @address_book.entries.delete(entry)\n puts \"#{entry.name} has been deleted\"\n end", "def remove_mailing(id)\n delete(\"/mailings/#{id}\")\n end", "def delete_from_all_lists(email)\n full_path = full_resource_path('/delete_all')\n query_params = MaropostApi.set_query_params({\"contact[email]\" => email})\n \n MaropostApi.delete_result(full_path, query_params)\n end", "def remove_from_mailchimp(list_name)\n apikey ||= chimpLogin(monkeybrains[:username], monkeybrains[:password])\n list_id ||= find_mailing_list(apikey, list_name)\n chimpUnsubscribe(apikey, list_id[\"id\"], self[email_column])\n rescue XMLRPC::FaultException\n end", "def destroy\n address = Address.find(params[:id])\n status = address.delivery_address # stores whether it is delivery address or not\n address.destroy\n current_user_address = @current_user.addresses\n # if the address deleted is the current delivery address and the user should have atleast one address to mark the first address as delivery address.\n if (status && !(current_user_address.empty?))\n addrs = Address.first\n addrs.delivery_address = true\n addrs.save!\n end\n redirect_to cart_items_path\n end", "def delete_from_lists(contact_id, lists_to_delete_from)\n full_path = full_resource_path(\"/#{contact_id}\")\n query_params = MaropostApi.set_query_params({'list_ids' => lists_to_delete_from.join(',')})\n \n MaropostApi.delete_result(full_path, query_params)\n end", "def destroy\n @event_mailing_list.destroy\n respond_to do |format|\n format.html { redirect_to event_mailing_lists_url, notice: 'Event mailing list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @addresses = Address.paginate(:page => params[:page], :per_page => 5).order('updated_at DESC')\n @address = Address.find(params[:id])\n @error = nil\n\n begin\n @address.destroy\n rescue ActiveRecord::DeleteRestrictionError => e\n @error = e.message\n end\n end", "def delete_item(list_item)\n @list.delete(list_item)\n @list\n end", "def remove_recipient(name)\n name_li(name).link(:text=>\"x\").click\n end", "def del_host(wspace, address, comm='')\n\t\thost = wspace.hosts.find_by_address_and_comm(address, comm)\n\t\thost.destroy if host\n\tend", "def destroy\n @email_list.destroy\n respond_to do |format|\n format.html { redirect_to email_lists_url, notice: 'Email list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove(mailbox)\n delete(\"#{domain}/mailboxes/#{mailbox}\")\n end", "def delete_contact(params={})\n @obj.delete('delete-contact', @auth.merge(params))\n end", "def delete\n self.class.call('domain.mailbox.delete', @domain.fqdn, @login)\n end", "def delete(recipient_email)\n recipient_email = @client.url_encode(recipient_email)\n @client.call(method: :delete, path: \"suppression-list/#{recipient_email}\")\n end", "def destroy\n @address.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Address was successfully destroyed.' }\n end\n end", "def delete_item(list_id:, id:)\n path = \"lists/#{list_id}/items/#{id}\"\n request(method: :delete, path: path)\n end", "def delete()\n\n MailAccount.destroy(self.id)\n end", "def destroy\n @address = current_user.addresses.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to user_addresses_path(current_user) }\n format.json { head :no_content }\n end\n end", "def remove(ip_address)\n if entry = find_entry_by_ip_address(ip_address)\n @entries.delete(entry)\n end\n end", "def remove_email (e)\n emails.delete_at e\n end", "def destroy\n email_address.destroy\n flash[:notice] = 'The email address was successfully removed.'\n respond_with(email_address)\n end", "def remove_contact(options={})\n list_id = options.delete(:list_id)\n email = options.delete(:email)\n\n request_body = ''\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n\n xml.instruct!\n xml.Envelope do\n xml.Body do\n xml.RemoveRecipient do\n xml.LIST_ID list_id\n xml.EMAIL email unless email.nil?\n options.each do |field, value|\n xml.COLUMN do\n xml.NAME field.to_s\n xml.VALUE value.to_s\n end\n end\n end\n end\n end\n\n send_xml_api_request(request_body)\n true\n end", "def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to addresses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to addresses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to addresses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to addresses_url }\n format.json { head :no_content }\n end\n end", "def delete_contact(id)\n delete(\"contacts/#{id}\")\n end", "def destroy\n @list = current_user.lists.find(list_params)\n @list.destroy\n flash[:success] = \"List deleted\"\n redirect_to current_user\n end", "def delete(contacts)\n @@contacts.delete(contact)\n end", "def delete_list(id:)\n check_token\n response = self.class.delete(\"/lists/#{id}\", headers: headers)\n check_and_raise_errors(response)\n true\n end", "def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action=>'index') }\n format.xml { head :ok }\n end\n end", "def delete_contact\n contact = retrieve_contact_by_email\n if contact\n if @rolodex.delete(contact)\n puts \"Contact successfully deleted.\"\n end\n end\n end", "def contact_delete(handle)\n query 'contact-delete', { handle: handle }\n end", "def delete_pre_address(address)\n address = address.sub(/^\\s*mail\\:\\s*/i, '')\n address.gsub(/.*\\,\\s+(\\d+\\b\\s+\\w)/i, '\\1')\n end", "def remove_an_item(code_item_to_delete)\n to_do_list.delete_at(code_item_to_delete)\n end", "def delete(options = {})\n default_options = {:conditions => [\"mail_items.user_id = ?\", @user.id]}\n add_mailbox_condition!(default_options, @type)\n return delete_mail(default_options, options)\n end", "def destroy\n @address.destroy\n respond_to do |format|\n format.html { redirect_to admin_path(current_user), notice: 'Address was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(item, list)\n\tlist.delete(item)\nend", "def remove_email(mail)\n @emails.delete_at (mail)\n end", "def destroy\n @address.destroy\n respond_to do |format|\n format.html { redirect_to addresses_url, notice: 'Form was deleted successfully!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @address = current_user.addresses.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to addresses_url }\n format.json { head :no_content }\n format.js { render :js => \"$(this).parent().parent().remove(); this.preventDefault();\" } \n end\n end", "def destroy\n @recipient = Recipient.find_by(recipient_list: @recipient_list, mail_user: @mail_user)\n\n if !['included', 'excluded'].include?(@type)\n redirect_to @recipient_list, alert: '指定のリストからユーザーは削除できません。'\n elsif @recipient\n @recipient.update_column(@type, false)\n if [email protected] && [email protected] &&\n (@mail_user.mail_groups & @recipient_list.mail_groups).empty?\n @recipient.destroy\n end\n redirect_to @recipient_list, notice: '指定のリストからユーザーを削除しました。'\n else\n redirect_to @recipient_list, alert: 'ユーザーはリストに含まれていません。'\n end\n end", "def destroy\n @address_book = AddressBook.find(params[:id])\n @address_book.destroy\n flash[:notice] = :address_book_deleted.l\n\n respond_to do |format|\n format.html { redirect_to(address_books_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user_address = UserAddress.find(params[:id])\n @user_address.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_addresses_url) }\n format.xml { head :ok }\n end\n end", "def delete(contactname)\n\n end", "def remove_contact(contact)\n @contacts.delete(contact)\n end", "def destroy\n @user_address_book_item = UserAddressBookItem.find(params[:id])\n @user_address_book_item.destroy\n end", "def destroy\n # @address = Address.find(params[:id])\n @address = Address.find_by_permalink!(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to(addresses_url) }\n format.xml { head :ok }\n end\n end", "def delete\n @carddav_backend.delete_address_book(@address_book_info['id'])\n end", "def delete_list_member(f)\n File.open f, 'r' do |file|\n file.each do |email|\n begin\n print email\n email.chomp!\n RestClient.delete(\"https://api:key-#{API_KEY}\" \\\n \"@api.mailgun.net/v3/lists/#{LIST}@#{DOMAIN_NAME}/members/#{email}\")\n rescue\n puts \"--------\\n#{email} Not found..NEXT\\n\"\n next\n end\n end\n end\nend", "def delete(id)\n results = connection.exec_params('DELETE FROM contacts WHERE id=$1;', [id]) \n end", "def delete_group\n @mailing_list_group.destroy if @ok\n render 'update_list'\n end", "def remove(address_or_id)\n delete(\"#{domain}/unsubscribes/#{address_or_id}\")\n end", "def empty_mailing_lists\n\tbegin\n\t\tmailing_lists.each do |list_name|\n\t\t\tlist_id = Rails.configuration.mailing_lists[:mailchimp_list_ids][list_name.to_sym]\n\t\t\tr = Gibbon::Request.lists(list_id).members.retrieve params: {fields: 'members.email_address'}\n\t\t\tr['members'].try(:each) do |member|\n\t\t\t\temail = member['email_address']\n\t\t\t\tGibbon::Request.lists(list_id).members(email_md5_hash(email)).delete\n\t\t\tend\n\t\tend\n\trescue Gibbon::MailChimpError => e\n\t\tputs \"MailChimp error while deleting: #{e.title}; #{e.detail}; status: #{e.status_code}\"\n\tend\nend", "def remove_contact(params={})\n @obj.put('remove-contact', @auth.merge(params))\n end", "def delete_list(id)\n record \"/todos/delete_list/#{id}\"\n end", "def destroy\n @user_address.destroy\n respond_to do |format|\n format.html { redirect_to user_addresses_path, notice: 'User address was successfully destroyed.' }\n end\n end", "def remove_from_list(list_name, lead_or_idnum, options={})\n list_operation(list_name, \"REMOVEFROMLIST\", lead_or_idnum, options)\n end", "def remove\n recipient_list_members.destroy_all\n if message_recipients.count.zero?\n destroy\n else\n self.removed = true\n save!\n end\n end", "def destroy\n @list = @project.lists.find(params[:id])\n @list.destroy\n\n respond_to do |format|\n format.html { redirect_to project_lists_url(@project) }\n format.json { head :no_content }\n end\n end", "def delete(contact)\n @@contacts.delete(contact)\n end", "def remove(list)\n puts \"Please enter contact to remove\"\n input = gets.chomp\n\n contact = list.execute(\"SELECT * FROM contacts\")\n\n contact.each do |individual_contact|\n if individual_contact[1] == input\n list.execute(\"DELETE FROM contacts WHERE name = '#{input}' \")\n else\n puts \"Sorry, you don't have that contact!\"\n end\n end\nend", "def destroy\n @entry_mail = EntryMail.find(params[:id])\n @entry_mail.destroy\n \n respond_to do |format|\n format.html { redirect_to entry_mails_url }\n format.json { head :no_content }\n end\n end", "def force_remove(list_id:, recipient_id:)\n @recipient_id = recipient_id\n remove(list_id: list_id, recipient_id: recipient_id)\n rescue OptivoApi::RecipientNotInList # rubocop:disable Lint/HandleExceptions\n end" ]
[ "0.75958645", "0.74267596", "0.70941395", "0.6842968", "0.681401", "0.67526555", "0.66959757", "0.66598684", "0.65694076", "0.6516752", "0.6470642", "0.64618486", "0.6448635", "0.6431369", "0.64174503", "0.6406945", "0.6396984", "0.6389896", "0.63549894", "0.6335586", "0.63345695", "0.63276106", "0.6298286", "0.62615454", "0.6253615", "0.62339544", "0.62108374", "0.61907613", "0.615358", "0.61525667", "0.614887", "0.6138971", "0.61370337", "0.6135704", "0.6131008", "0.6102788", "0.6078119", "0.60770416", "0.6053651", "0.60293514", "0.6019977", "0.5985378", "0.5960534", "0.5959851", "0.59484196", "0.5941396", "0.59330237", "0.59234285", "0.59114075", "0.58819735", "0.5875131", "0.5862473", "0.5858017", "0.5852512", "0.58392256", "0.5828332", "0.5821115", "0.58134615", "0.5812838", "0.5812838", "0.5812838", "0.5812838", "0.5809487", "0.58061427", "0.5803651", "0.5791905", "0.5791033", "0.5788766", "0.57857007", "0.5783435", "0.57797116", "0.57712734", "0.5766916", "0.5762825", "0.57619935", "0.57494426", "0.5740391", "0.57380396", "0.572148", "0.57187134", "0.57168734", "0.5716574", "0.5714496", "0.57137126", "0.57050127", "0.5702447", "0.5698273", "0.5681676", "0.56757325", "0.56637114", "0.5658292", "0.56530184", "0.5651169", "0.56447995", "0.56424445", "0.5636852", "0.56362784", "0.5635276", "0.5633939", "0.5629164" ]
0.75007063
1
Helper method to generate the proper url for Mailgun mailbox API calls
def list_url(address=nil) "#{@mailgun.base_url}/lists#{'/' + address if address}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_url\n \"#{Mailgun.protocol}://api:#{Mailgun.api_key}@#{Mailgun.mailgun_host}/#{Mailgun.api_version}\"\n end", "def make_url(dav_uri, mailbox)\n \"#{dav_uri}/#{mailbox}/\"\n end", "def build_url(base_url, queue_name)\n return \"#{base_url}/#{queue_name}\"\n end", "def publish_messages_url(address=nil)\n \"#{@mailgun.base_url}/#{@domain}/messages\"\n end", "def endpoint\n @endpoint ||= 'https://api.emailcampaigns.net/2/REST/'\n end", "def api_service_uri\n api_service_host = API_SERVICE_HOST\n return \"https://#{api_service_host}/sendsms/\"\n end", "def uri\n sprintf(\"%s/%s?token=%s\", API_ENDPOINT, COMMAND, config.slack_bot_token)\n end", "def url_for(base_url,msg)\n if msg[:id]\n if base_url.end_with?('/')\n \"#{base_url}#{msg[:id]}.json\"\n else\n \"#{base_url}/#{msg[:id]}.json\"\n end\n else\n base_url\n end\nend", "def api_url\n \"#{@@base_url}/#{format}/#{resource}?apikey=#{@@api_key}#{parameters}\"\n end", "def api_url\n \"#{protocol}://api:#{api_key}@#{host}/#{api_version}\"\n end", "def url\n URI.parse(endpoint).join(path.to_s).to_s\n end", "def generate_url\n api_key = WavecellOtpAndSms.configuration.api_key\n sub_account = WavecellOtpAndSms.configuration.sub_account\n details = [uid, code]\n parameters = {\n uid: uid,\n code: code\n }\n query_string = parameters.to_a.map { |x| \"#{x[0]}=#{x[1]}\" }.join(\"&\")\n url = \"https://api.wavecell.com/otp/v1/#{sub_account}/#{uid}?code=#{code}\"\n HTTParty.get(url.to_str,\n :body => parameters.to_json,\n :headers => {\n \"Content-Type\" => \"application/json\",\n \"Authorization\" => \"Bearer #{api_key}\"\n })\n end", "def base_url\n \"https://api.beezup.com/\"\n end", "def api_url\n base_url.concat api_query_parameter\n end", "def api_url\n base_url.concat api_query_parameter\n end", "def api_url\n @api_url ||= URI.parse(\"#{super}?#{URI.encode_www_form(query_params)}\")\n end", "def api_base_path\n 'https://messaging.bandwidth.com/api/v2'\n end", "def base_url\n BASE_URL.dup % [\"%s\", \"%s\", @api_key, \"%s\"] \n end", "def endpoint_url\n # @@api_base + @request.endpoint\n ApiBase + @endpoint\n end", "def request_url\n base_url = \"http://#{api_host}#{PATH}?\"\n base_url << \"appid=#{app_id}\"\n base_url << \"&callname=#{call_name}\"\n base_url << \"&siteid=#{site_id}\"\n base_url << \"&version=#{API_VERSION}\"\n base_url\n end", "def request_uri(path)\n \"#{@api_url}#{path}\"\n end", "def build_uri\n uri = URI(\"#{Phantomblaster::API_URL}#{path}\")\n query = build_query(uri, args)\n uri.query = query\n uri\n end", "def build_urlpath\n render_endpoint_request do\n erb = EndpointRequestBuilder.new(@endpoint)\n extra_params = erb.formatted_url_path(@arguments)\n render json: { success: extra_params }, status: 200\n end\n end", "def to_uri\n build_uri\n end", "def build_call_url(word)\r\n\t\t\tURI.parse(URI.escape(base_url + word))\r\n\t\tend", "def endpoint_url\n protocol = @secure ? 'https' : 'http'\n endpoint_host = SmsNotify::Api.endpoint_host\n \"#{protocol}://#{endpoint_host}/\"\n end", "def link\n \"<a href='http://www.mailgun.com/'>Mailgun</a>\"\n end", "def base_api_uri\n \"#{self.class.base_uri}/#{@account_id}\"\n end", "def post_api_uri(endpoint)\n URI(@api_base_url + endpoint)\n end", "def build_url(path, params = {})\n \"#{self.class.endpoint}#{path}?#{Rack::Utils.build_query(params.merge(:key => api_key.to_s))}\"\n end", "def bookkeeper_invitation_url(access)\n \"#{::AppConfig.mail.host}/access/#{access}\"\n end", "def api_url(endpoint)\n \"https://www.bloc.io/api/v1/#{endpoint}\"\n end", "def format_url(request)\n \"#{@api_prefix}#{request}\"\n end", "def get_url endpoint\n url = @url\n if !url.end_with? \"/\"\n url = \"#{url}/\"\n end\n\n \"#{url}wc-api/#{@version}/#{endpoint}\"\n end", "def url\n ::URI.join(\"#{service.service_url}/\", ::URI.escape(url_chunk)).to_s\n end", "def pubsubhubbub_callback_url\n ENV['PUBSUBHUBBUB_CALLBACK_URL'].presence || Rails.application.routes.url_helpers\n .url_for(controller: 'curry/pull_request_updates', action: 'create',\n host: ENV['FQDN'], protocol: ENV['PROTOCOL'], port: ENV['PORT'])\n end", "def makeURL(path)\n \"#{self.api_endpt + path}?token=#{self.token}\"\n end", "def get_api_url(endpoint)\n @api_base_url + endpoint\n end", "def organization_url\n \"#{organization_base_url}.#{request_format}\"\n end", "def api_uri\n options.endpoint\n end", "def _url\n URI.join(domain, path_gen.for_uri)\n end", "def url\n endpoint+'?'+query_string\n end", "def api_url\n api_key? ? base_url.concat(api_query_parameter) : base_url\n end", "def base_url\n \"http://sms.yunpian.com/#{SmartSMS.config.api_version}/\"\n end", "def url(path)\n \"#{API}/#{path}\"\n end", "def url_for queue_name, options = {}\n client_opts = {}\n client_opts[:queue_name] = queue_name\n client.get_queue_url(client_opts.merge(options))[:queue_url]\n end", "def build_url(input)\n url = \"#{GOOGLE_BOOKS_API_BASE_URL}#{input}\"\n url\nend", "def create_url\n uri = Addressable::URI.new\n uri.query_values = properties\n \"#{ BASE_URI }#{ Hubspotter.configuration.portal_id }#{ create_endpoint }#{ uri.query }\"\n end", "def build_uri(resource)\n URI(\"#{API_URL}/#{resource}\")\n end", "def to_url\n \"%s/web/api/%s/%s/authkey=%s/%s\" % [ host, target, url_options, authkey, output ]\n end", "def url\n connection.build_url(url_chunk, params).to_s\n end", "def url\n URI.escape(\"#{protocol}#{host}/#{path_prefix}#{key}\")\n end", "def request_url(method, params={})\n url = \"#{@host}#{@api}/#{method}?ApiKey=#{@api_key}\"\n params.each_pair do |key, val|\n url += \"&#{key}=\" + CGI::escape(val.to_s)\n end\n url\n end", "def url\n channel_path(params[:message][:channel_id], anchor: \"message_#{params[:message][:id]}\")\n end", "def webhook_url(id=nil)\n \"#{@mailgun.base_url}/domains/#{domain}/webhooks#{'/' + id if id}\"\n end", "def make_url\n # This works for most of the twitter calls\n \"http://ws.audioscrobbler.com/2.0/?method=#{resource_path}&artist=#{identifier}&limit=100&page=#{page}&api_key=#{api_key}&format=json\"\n end", "def build_url(url_suffix)\n return @base_url+url_suffix\nend", "def make_url\n [ \"http://ws.audioscrobbler.com/2.0/?method=#{api_method}#{identifier}\",\n \"&limit=#{max_items}&api_key=#{api_key}&format=json\",\n \"&page=#{page}\" ].join(\"\")\n end", "def api_url\n if PagSeguro.developer?\n File.join PagSeguro.config[\"base\"], \"pagseguro_developer/confirm\"\n else\n API_URL\n end\n end", "def build_uri(from, to)\n from, to = Currency.wrap(from), Currency.wrap(to)\n raise NoApiKey if api_key.nil? || api_key.empty?\n uri = URI::HTTP.build(\n :host => SERVICE_HOST,\n :path => SERVICE_PATH,\n :query => \"from=#{from.iso_code}&to=#{to.iso_code}&apiKey=#{api_key}\"\n )\n end", "def api_url\n @api_url ||=\"#{base_url}#{@options['api_url']}\"\n end", "def initialize(mailbox, apiKey)\n @MAILBOX = ENV['MAILOSAUR_MAILBOX'] || mailbox\n @API_KEY = ENV['MAILOSAUR_APIKEY'] || apiKey\n @BASE_URI = 'https://mailosaur.com/v2'\n end", "def api_url\n @api_url ||= URI.parse(::File.join(base_url, endpoint))\n end", "def endpoint\n \"#{@scheme}://#{@host}#{@path}\"\n end", "def uri_endpoint\n URI( self.endpoint )\n end", "def build_uri\n @uri = URI( SEARCH_BASE + '/' + send(\"#{@method}_url\") )\n end", "def build_uri\n @uri = URI( SEARCH_BASE + '/' + send(\"#{@method}_url\") )\n end", "def build_uri\n @uri = URI( SEARCH_BASE + '/' + send(\"#{@method}_url\") )\n end", "def api_create_url\n \"#{self.name.split(\"::\").last.downcase}\"\n end", "def base_url(info)\n main_url(info[:booking])\n end", "def api_url(url = '')\n configuration.api_base + url\n end", "def url(params)\n \"%s%s\" % [config['endpoint'], query_string(params)]\n end", "def url() \n\t #'http://' << ENV['DOMAIN'] << \n\t '/' << self.author.username.to_s << '/' << self.name.to_s\n end", "def api_url\n Settings.mobile_lighthouse_letters.api_url\n end", "def get_url\n \"http://#{self.domain}/#{self.path}#{self.params.it_keys_to_get_param}\"\n end", "def item_url(result)\n query = CGI.parse(env.url.query.to_s)\n url = \"#{env.url.scheme}://#{env.url.host}/officers/#{result['identifiers'][0]['identifier']}\"\n if query['api_token'].any?\n url += \"?api_token=#{CGI.escape(query['api_token'][0].to_s)}\"\n end\n url\n end", "def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end", "def url(path)\n \"#{self.api_root}/#{self.api_version}/#{self.tenancy_code}/#{path}\"\n end", "def api_url\n ensure_full_data!\n @gapi[\"selfLink\"]\n end", "def url(email, format = nil)\n argument(email) { should be_a(String) }\n argument(format) { should be_one_of(:json, :xml) } if format\n\n uri = URI.parse('https://www.gravatar.com/')\n uri.path = '/' + email.to_md5\n uri.path += '.' + format.to_s if format\n uri.to_s\n end", "def do_rest_url(api_name)\n raise 'Signature should not be blank. Please generate signature by LazadaOP#do_signature.' if @common_params[:sign].blank?\n length = @server_url.length\n rest_url = @server_url[(length - 1)] == '/' ? @server_url.chomp!('/') : @server_url\n\n common_params_string = ''\n @common_params.each do |key, value|\n common_params_string += '&' unless common_params_string.blank?\n common_params_string += \"#{key}=#{value}\"\n end\n \"#{rest_url + api_name}?#{common_params_string}\"\n end", "def build_request_url(path, params)\n\t\t\t\t\tURI::HTTP.build :host => API_SERVER,\n\t\t\t\t\t\t\t\t\t\t\t\t\t:path => \"#{API_BASE}/#{path}\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t:query => params.map {|k,v| \"#{k}=#{v}\"}.join('&')\n\t\t\t\tend", "def build_url(api_method, options = {})\n if api_method['mediaUpload'] && options[:media]\n # we need to do [1..-1] to remove the prepended slash\n url = GoogleAPI.discovered_apis[api]['rootUrl'] + api_method['mediaUpload']['protocols']['resumable']['path'][1..-1]\n else\n url = GoogleAPI.discovered_apis[api]['baseUrl'] + api_method['path']\n query_params = []\n api_method['parameters'].each_with_index do |(param, settings), index|\n param = param.to_sym\n case settings['location']\n when 'path'\n raise ArgumentError, \":#{param} was not passed\" if settings['required'] && !options[param]\n url.sub!(\"{#{param}}\", options.delete(param).to_s)\n when 'query'\n query_params << \"#{param}=#{options.delete(param)}\" if options[param]\n end\n end if api_method['parameters']\n url += \"?#{query_params.join('&')}\" if query_params.length > 0\n end\n\n [url, options]\n end", "def api_url\n authentication_credentials_provided? ? \"https://api.gowalla.com\" : \"http://api.gowalla.com\"\n end", "def api_url\n @api_url ||= \"https://api.neverbounce.com\"\n end", "def api_url(path)\n path\n end", "def uri\n uri_for({}, nil)\n end", "def auth_url\n client.authorization.authorization_uri(state: '', approval_prompt: :force, access_type: :offline, user_id: client_email).to_s\n end", "def build_uri\n URI.parse(base_url + \"?\" + query_params)\n end", "def url(path='')\n path = \"/#{path}\" unless path.start_with? '/'\n URI::Generic.build({\n :scheme => 'https',\n :host => 'app.realpush.cc',\n :port => 443,\n :path => \"/api/#{RealPush::API_VERSION_BE}#{path}\"\n })\n end", "def hms_api_url\n 'https://' + settings.hms_hostname + '/hms/bb/token'\n end", "def api_url(service, options = {})\n \"#{connection.base_url}/api/#{service}?token=#{connection.token}\"\n end", "def log_url\n \"#{@mailgun.base_url}/#{@domain}/log\"\n end", "def base_uri\n \"#{api}/provider\"\n end", "def base_url\n \"https://api.twitter.com\"\n end", "def url\n api_url\n end", "def base_href\n '/api/v1'\n end", "def build_url(params)\n \"#{@base_url}?#{params.to_query}\"\n end", "def unsubscribe_url(address=nil)\n \"#{@mailgun.base_url}/#{@domain}/unsubscribes#{'/' + address if address}\"\n end", "def uri_string_for_pull_requests\n uri_parts(\"/repos/#{@github_user}/#{@github_repo}/pulls\").values.join\n end" ]
[ "0.7624175", "0.66184914", "0.6617954", "0.661051", "0.64382964", "0.6246601", "0.6235379", "0.6214893", "0.619302", "0.61212283", "0.60938257", "0.60920215", "0.60911274", "0.6088733", "0.6088733", "0.605631", "0.604059", "0.6031597", "0.6018392", "0.6011611", "0.6011569", "0.59902155", "0.59580696", "0.5956581", "0.5922268", "0.59216726", "0.59185356", "0.59145904", "0.5913289", "0.5913159", "0.59113544", "0.59059846", "0.58964247", "0.5895142", "0.58827937", "0.5879115", "0.5875855", "0.58606035", "0.5860226", "0.5856549", "0.5855936", "0.5852371", "0.584792", "0.58249", "0.57891965", "0.57726336", "0.5765188", "0.5763061", "0.5756714", "0.57562995", "0.5753012", "0.5752216", "0.57368994", "0.57146287", "0.5701422", "0.5698617", "0.5690337", "0.5689609", "0.56704473", "0.56663907", "0.56640476", "0.566122", "0.5658391", "0.5655672", "0.5652922", "0.5647487", "0.5647487", "0.5647487", "0.5645073", "0.56447846", "0.56381786", "0.5638151", "0.56343454", "0.5633667", "0.5631533", "0.56283987", "0.561111", "0.5610687", "0.56099373", "0.56071025", "0.56062806", "0.56051606", "0.5594195", "0.55940825", "0.5592711", "0.55898464", "0.5586426", "0.55812883", "0.5575109", "0.55722004", "0.5568802", "0.55633116", "0.5562462", "0.55617416", "0.55594164", "0.5557274", "0.5555351", "0.5554773", "0.5554582", "0.55539507" ]
0.580421
44
2 is obviously not helpful
def find_good_set(numbers,i) return [] if i==0 while not numbers.empty? x = numbers.shift test = find_good_set(numbers.find_all{|y| good_pair?(x,y)},i-1) return [x]+test unless test == nil end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def two_or_more\n -3\n end", "def anchored; end", "def one_or_more\n -2\n end", "def m3; 3 end", "def arity; 2; end", "def bad_smell_by_nfunctions\n end", "def mystery(n)\n 0\nend", "def low_two_of_a_kind\n values.reverse.each do |i|\n if values.reverse.count(i) == 2\n return i\n end\n end\n return false\n end", "def coast_guard_rank; end", "def check_for_implication_loops\n # actually this is tricky\n end", "def probers; end", "def count_triple\nend", "def offences_by; end", "def no_learn\n 8\n end", "def big_bad; end", "def diff1; end", "def diff2; end", "def second_great_low(arr)\r\n\r\nend", "def passes; end", "def passes; end", "def cops; end", "def cops; end", "def cops; end", "def too_many_hops?; end", "def positive; end", "def positive; end", "def ismn; end", "def magic_numbers(count)\nend", "def too_complex; end", "def count_ops()\n 0\n end", "def odds\n return 1\n end", "def terpene; end", "def mambo_no_5; end", "def weight\n 2 # ounces\n end", "def cardinal; end", "def slop!; end", "def slop!; end", "def cac2\n 0\n end", "def most_specific_subdivision; end", "def silly_adjective; end", "def weight; end", "def p15\n\t\nend", "def num_tankoubon; end", "def two_pair\n is_two_pair? ? repetitions(2).keys.max.to_i : 0 \n end", "def seuil()\n\t\treturn 0\n\tend", "def rule_2 *cards\n if cards.any?(&:wild?)\n cards.raw_integer_value * 2\n end\n end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def two_pt\n fg - three_p\n end", "def stderrs; end", "def m1\n\t\t\t\t\tsuper * 2 \t\t\t\t\t\t\t\t\t\t\t# second override to #m1 \n\t\t\t\tend", "def s2(n)\n n*(n+1)*(2*n+1)/6\nend", "def h(x)\n 2*x - @n - 1\n end", "def check_two(two_count, one_count)\n open_space = nil\n winning_combos.each do |winning_combo|\n open_space ||= two_inline(winning_combo, two_count, one_count)\n end\n \n open_space\n \n end", "def internship_passed; end", "def rassoc(p0) end", "def number_returned; 0; end", "def high_five; end", "def two\n end", "def star; end", "def verdi; end", "def type_2_effectiveness(source, target, move)\n\tElementalType::TYPE_MULTIPLIERS[ElementalType.elemental_types[move.type_1]][ElementalType.elemental_types[target.type_2]] if !target.type_2.nil?\nend", "def test_sg_not_one\n\n p = Prospector.new(0, 0, 0)\n assert p.sg?(4), 's'\n end", "def intensifier; end", "def num_unknown\n @num_unknown ||= num_researched - num_known\nend", "def number_of_bench_replace(class_a,class_b,class_c)\n\treturn (class_a / 2 + class_a %2) + (class_b / 2 +class_b%2) + (class_c / 2 + class_c%2)\nend", "def c2= c; @c2 = (c == 1) ? 1 : 0; end", "def zero_or_more\n -1\n end", "def bunny(n)\n return 0 if n == 0\n\n return (2 + (2 * (n - 1)))\nend", "def test_leaving_first_3_false_both_found\n p = Prospector.new(0,0,0)\n\tp.gold_found = 3\n\tp.silver_found = 4\n\tp.num_loc_visited = 3\n\trefute p.leaving?\n end", "def king_richard_iii; end", "def private; end", "def measure\n\t\t1\n\tend", "def thnum()\n #This is a stub, used for indexing\n end", "def weight(i, j)\n return 1\n end", "def malts; end", "def count=(_arg0); end", "def succ!() end", "def two_inline(winning_combo, two_count, one_count)\n if board_spaces(winning_combo).count(two_count) == 2 && board_spaces(winning_combo).count(one_count) == 1\n winning_combo.find {|space| board[space] == 0 }\n end\n end", "def abundant?(num)\nend", "def numerator() end", "def y() self[1]; end", "def alternatives; end", "def s(x); 1; end", "def offences_by=(_arg0); end", "def suivre; end", "def number_of_flipping_slots(integer1, integer2)\n (integer1 ^ integer2).to_s(2).count('1')\nend", "def tricks_taken \n \t\tself.score-(self.correct*10)\n \tend", "def nonzero?; end", "def third\n at(2)\n end", "def tricky_number\n\tif true\n\t\tnumber = 1\n\telse\n\t 2\n\tend\nend", "def masterwork_prob_bonus; 0; end", "def hungry?\n@stuff_in_belly <= 2\nend", "def two_pt_a\n fga - three_p_a\n end", "def celebrity; end", "def celebrity; end", "def succ() end", "def succ() end", "def succ() end", "def score=(_); end", "def abundant?(num)\n\nend", "def abundant?(num)\n\nend" ]
[ "0.61581075", "0.6010702", "0.5963642", "0.5943594", "0.5872732", "0.58667123", "0.5824876", "0.581235", "0.57657164", "0.57438016", "0.5736968", "0.5723011", "0.57149154", "0.57115537", "0.57045156", "0.5700724", "0.5675906", "0.566252", "0.5647478", "0.5647478", "0.5639143", "0.5639143", "0.5639143", "0.5625027", "0.56221", "0.56221", "0.5618763", "0.56172997", "0.56031156", "0.5591518", "0.55785257", "0.55773145", "0.55737686", "0.55727327", "0.55662745", "0.5566267", "0.5566267", "0.55660254", "0.5565176", "0.5561682", "0.55556095", "0.5550694", "0.554429", "0.5539465", "0.55268306", "0.552626", "0.55246687", "0.5523413", "0.5521648", "0.5499748", "0.5499611", "0.54924405", "0.54881114", "0.548278", "0.5469411", "0.5462994", "0.5454277", "0.5446669", "0.5440005", "0.54191244", "0.5415904", "0.53985405", "0.53964704", "0.5393715", "0.53901714", "0.5389017", "0.5387487", "0.5380487", "0.5380232", "0.53790617", "0.5373778", "0.5373199", "0.5371542", "0.5361994", "0.53619677", "0.5360617", "0.535889", "0.5356923", "0.5352314", "0.5351538", "0.5349705", "0.53495353", "0.5340877", "0.5339969", "0.53378147", "0.5335653", "0.533107", "0.53264475", "0.5324867", "0.5320332", "0.53195745", "0.5319418", "0.53193486", "0.5316573", "0.5316573", "0.531634", "0.531634", "0.531634", "0.5311493", "0.531003", "0.531003" ]
0.0
-1
human readable description of modeling approach
def modeler_description return "" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end", "def modeler_description\n return \"Example use case is adding special loads like an elevator to a model as part of an analysis workflow\"\n end", "def modeler_description\n return 'Currently this is just setup for design level calculation method, but it could be extended as needed..'\n end", "def modeler_description\n return 'shift or/and adjust heaing and cooling setpoint'\n end", "def modeler_description\n return 'This model replaces the existing HVAC system with a VRF + DOAS system.'\n end", "def modeler_description\n return \"This uses the OpenStudio::Model::Space::fromFloorPrint method, and is very much like the Create Spaaces From Diagram tool in the OpenStudio SketchUp plugin, but lets you draw teh diagram in the tool of your choice, and then imports it into the OpenStudio application via a measure.\"\n end", "def modeler_description\n return 'This can be used in apply measure now, or can be used in a parametric workflow to load in any custom user profiles or floor/ceiling values.'\n end", "def modeler_description\r\n return \"objective function\"\r\n end", "def modeler_description\r\n return \"objective function\"\r\n end", "def modeler_description\n return \"Any generators and electric load center distribution objects are removed. An electric load center distribution object is added with a track schedule equal to the hourly output from SAM. A micro turbine generator object is add to the electric load center distribution object. The fuel used to make the electricity is zeroed out.\"\n end", "def modeler_description\r\n return \"For each model, find every DX cooling and heating coil and increase the COP to 6. Since very little information about this technology is available, do not change performance curves or upper/lower operating temperature limits.\"\r\n end", "def modeler_description\n return 'Modify the cooling setpoint of the HVAC system during a DR event'\n end", "def modeler_description\n return 'This a test measure in relation with https://github.com/NREL/OpenStudio/issues/4156'\n end", "def modeler_description\n return \"When have existing OSM wanted to be able to grab geometry from model vs. trying to enter on website. This is useful when there is no built structures yet to use as reference on the website.\"\n end", "def modeler_description\n return \"Grey water tank overflow will be dirrected to drainage. \"\n end", "def modeler_description\n return \"NOTE: This will load and respond slowly in the OS app, especially if you select * on a variable with many possible keys or you select timestep data. Suggest you open it in a web browser like Chrome instead.\"\n end", "def modeler_description\n return 'HVAC system creation logic uses [openstudio-standards](https://github.com/NREL/openstudio-standards) and efficiency values are defined in the openstudio-standards Standards spreadsheet under the *NREL ZNE Ready 2017* template.'\n end", "def description()\n\t\tself.namespaced_class(:ModelDescriptor).goal(self)\n\tend", "def modeler_description\n 'NOTE: This will load and respond slowly in the OS app, especially if you select * on a variable with many possible keys or you select timestep data. Suggest you open it in a web browser like Chrome instead.'\n end", "def modeler_description\n return 'Not sure how I will handle arguments. Maybe lump together all spaces on same sotry that have the same multilier value. This will have variable number of arguments basd on the model pased in. Alternative is to either only allo w one group to be chosen at at time, or allow a comlex string that describes everything. Also need to see how to define shirting. There is an offset but it may be above and below and may not be equal. In Some cases a mid floor is halfway betwen floors which makes just copying the base surfaces as shading multiple times probemeatic, since there is overlap. It coudl be nice to stretch one surface over many stories. If I check for vertial adn orthogonal surface that may work fine. '\n end", "def modeler_description\n return \"It does not even send anything related to the model. It just sends a simple pagkage at the end of every run, just to test if things really work.\"\n end", "def modeler_description\n return ['Adds', 'the', 'properties', 'for', 'the', 'MoisturePenetrationDepthConductionTransferFunction', 'or', 'effective', 'moisture', 'penetration', 'depth', '(EMPD)', 'Heat', 'Balance', 'Model', 'with', 'inputs', 'for', 'penetration', 'depths.', \"\\n\\n\", 'Leaving', 'Change', 'heat', 'balance', 'algorithm?', 'blank', 'will', 'use', 'the', 'current', 'OpenStudio', 'heat', 'balance', 'algorithm', 'setting.', \"\\n\\n\", 'At', 'least', '1', 'interior', 'material', 'needs', 'to', 'have', 'moisture', 'penetration', 'depth', 'properties', 'set', 'to', 'use', 'the', 'EMPD', 'heat', 'balance', 'algorithm.'].join(' ')\n end", "def modeler_description\n return \"Change water heater efficiency and fuel type.\"\n end", "def modeler_description\n return \"Assume that the starting point technology is primarily 90.1-2013 T8 lighting, with an efficacy of 90 lm/W. According to Table 5.2, LED Efficacy Improvement, in (1), 2015 LED luminaire efficacy is 145 lm/W. Calculate the total lighting power of the model and divide by this initial efficacy to determine the total number of lumens needed. Assuming that this same number of lumens should be provided by LED lighting, divide by the LED efficacy to determine the total wattage of LEDs that would be necessary to achieve the same lighting. Reduce the overall building lighting power by the resulting multiplier. IE new LPD = old LPD * (1 - 90 lm/W /145 lm/W). This is a very crude estimate of the impact of current LED technology. In order to perform a more nuanced analysis, lighting in the prototype buildings should be broken down by use type (general space lighting, task lighting, etc.) and by currently assumed technology (T12, T8, metal halide, etc.). If this breakdown were available, each type of lighting could be modified according to its own efficacy characteristics. Additionally, this measure does not account for the impact of LEDs on outdoor lighting.\"\n end", "def modeler_description\n return 'For each model, find every DX cooling and heating coil and increase the COP to 6. Since very little information about this technology is available, do not change performance curves or upper/lower operating temperature limits.'\n end", "def modeler_description\n return \"This measure will replicate the functionality described in the EnergyPlus Energy Management System Application Guide, Example 2., based on user input.\"\n end", "def modeler_description\n return 'This measure assigns load and flow information to a selected plant loop load profile.'\n end", "def modeler_description\n return \"This is intended to run on an empty model. It will create the proper model associate it with the proper weather file, and add in necessary output requests. Internally to the measure the test case argument will be mapped to the proper inputs needed to assemble the model. The measure will make some objects on the fly, other objects will be pulled from existing data resources. This measure creates cases described all of section 5.3.\"\n end", "def modeler_description\n return \"Each DX cooling coil in the model is replaced by a membrane heat pump. To represent the membrane heat pump, the DX cooling coil COP is increased to 7.62 (26 EER). Additionally, add a water use equipment object to account for the 3 gallons of water used per ton*hr of sensible cooling process.\"\n end", "def modeler_description\n 'For the most part consumption data comes from the tabular EnergyPlus results, however there are a few requests added for time series results. Space type and loop details come from the OpenStudio model. The code for this is modular, making it easy to use as a template for your own custom reports. The structure of the report uses bootstrap, and the graphs use dimple js.'\n end", "def modeler_description\n return 'Adds typical refrigeration equipment to a building'\n end", "def modeler_description\r\n return \"\"\r\n end", "def modeler_description\n return \"E+ RESNET\"\n end", "def modeler_description\n return \"Reads the model and sql file to pull out the necessary information and run the model checks. The check results show up as warning messages in the measure's output on the PAT run tab.\"\n end", "def modeler_description\n return \"A measure that will take Annual Building Utilty Performance tables, Demand End use Components summary table, Source Energy End Use Components Summary and produce an output Json\"\n end", "def modeler_description\n return \"Reads the model and sql file to pull out the necessary information and run the model checks. The check results show up as Warning messages in the measure's output on the PAT run tab.\"\n end", "def modeler_description\n return 'The goal of this measure is to create a single space type that represents the loads and schedules of a collection of space types in a model. When possible the measure will create mulitple load instances of a specific type in the resulting blended space type. This allows the original schedules to be used, and can allow for down stream EE measures on specific internal loads. Design Ventilation Outdoor Air objects will have to be merged into a single object. Will try to maintain the load design type (power, per area, per person) when possible. Need to account for zone multipliers when createding blended internal loads. Also address what happens to daylighting control objets. Original space types will be left in the model, some may still be assigned to spaces not included in the building area.'\n end", "def modeler_description\n 'It will be used for calibration maximum flow rate, efficiency, pressure rise and motor efficiency. User can choose between a SINGLE Fan or ALL the Fans.'\n end", "def modeler_description\n return ''\n end", "def modeler_description\n return ''\n end", "def modeler_description\n return ''\n end", "def modeler_description\n return ''\n end", "def modeler_description\n return ''\n end", "def modeler_description\n return ''\n end", "def modeler_description\n return ''\n end", "def modeler_description\n return 'This measure has optional arguments to apply recommendations from different sections of the Zero Energy Multifamily Design Guide.'\n end", "def modeler_description\n 'It will be used for calibration of WaterHeaterMixed. User can choose between a SINGLE WaterHeaterMixed or ALL the WaterHeaterMixed objects.'\n end", "def modeler_description\n return \"It will be used for calibration of inlet water temperatures, inlet and outlet air temperatures and design flowrates. User can choose between a SINGLE coil or ALL the Coils.\"\n end", "def modeler_description\n return 'Find the exterior lighting template for the building, and assume the existing efficiency level in the model (low, medium, high). Find the desing level and multiplier for each category of the exterior lighting definition. Apply the lighting upgrades by reducing the design level associated with each outdoor lighting category by a percent (depends on starting and target efficiency levels).'\n end", "def modeler_description\n return 'Change UrbanOpt Scenario CSV'\n end", "def modeler_description\n return 'Calculate thermal capacitance and UA for surfaces, furniture, and spaces.'\n end", "def modeler_description\n return 'Reports resilience metric(s) of interest.'\n end", "def modeler_description\n return \"The default space types in the measure inputs are automatically filled by the spaces' standard space types. User can overwrite the default assumptions in the library.csv file in the measure's resources folder.\"\n end", "def modeler_description\n return 'Find the interior lighting template for the building, and assume the existing efficiency level in the model (low, medium, high, very high). Find the LPD and LPD fractions for each space type. Apply the lighting upgrades by reducing the LPD associated with compact lighting by a percent (depends on starting and target efficiency levels).'\n end", "def modeler_description\n 'Run a simulation to autosize HVAC equipment and then apply these autosized values back to the model.'\n end", "def modeler_description\r\n return \"E+ measure to popolate the Kiva settings values\"\r\n end", "def modeler_description\n return 'This method calculates the annualized coefficient of performance (Btu out / Btu in) of equipment in the model from the annual simulation. This is used in Scout as the equipment efficiency for the technology competition categories.'\n end", "def modeler_description\n return 'This will only impact schedule rulesets. It will use methods in openstudio-standards to infer hours of operation, develop a parametric formula for all of the ruleset schedules, alter the hours of operation inputs to that formula and then re-apply the schedules. Input is expose to set ramp frequency of the resulting schedules. If inputs are such that no changes are requested, bypass the measure with NA so that it will not be parameterized. An advanced option for this measure would be bool to use hours of operation from OSM schedule ruleset hours of operation instead of inferring from standards. This should allow different parts of the building to have different hours of operation in the seed model.'\n end", "def modeler_description\n return \"Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.\"\n end", "def modeler_description\n return \"Any supply components or baseboard convective electrics/waters are removed from any existing air/plant loops or zones. Any existing air/plant loops are also removed. A heating DX coil, cooling DX coil, electric supplemental heating coil, and an on/off supply fan are added to a unitary air loop. The unitary air loop is added to the supply inlet node of the air loop. This air loop is added to a branch for the living zone. A diffuser is added to the branch for the living zone as well as for the finished basement if it exists.\"\n end", "def modeler_description\r\n return 'modify simulation timestep'\r\n end", "def modeler_description\n return 'Will add the necessary UtilityCost objects and associated schedule into the model.'\n end", "def modeler_description\n return 'Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.'\n end", "def modeler_description\n return 'Replace this text with an explanation for the energy modeler specifically. It should explain how the measure is modeled, including any requirements about how the baseline model must be set up, major assumptions, citations of references to applicable modeling resources, etc. The energy modeler should be able to read this description and understand what changes the measure is making to the model and why these changes are being made. Because the Modeler Description is written for an expert audience, using common abbreviations for brevity is good practice.'\n end", "def modeler_description\n return 'Passes in all arguments from the options lookup, processes them, and then registers values to the runner to be used by other measures.'\n end", "def modeler_description\n return 'Daylighting controls will physically add in daylighting controls to spaces in the building, while occupancy control will reduce lighting schedules by 10%.'\n end", "def modeler_description\n return 'This measure is used to calibrate the BRICR baseline model.'\n end", "def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to model the performance of HVAC equipment that cannot be represented well by using single “standard” performance curve objects (cubic, quadratic, biquadratic, etc.) For example, properly characterizing some HVAC equipment objects requires using different performance curves that cover operation of different parts of the performance regime. This measure will alter (overwrite) the Coil Cooling DX Single Speed Cooling Capacity as a function of temperature performance curve object and attributes used by the simulation if the outdoor air temperature falls below a user defined threshold. This measure allows the user to define the biquadratic curve coefficients associated with the Coil Cooling DX Single Speed Cooling Capacity.\"\n end", "def modeler_description\n return \"This EEM adds EMS logic to the model that actuates the infiltration, HVAC operation, cooling set point, and heating set point schedules. The measure first identifies the schedule HVAC stopping point by day of week (Saturday, Sunday, and Weekdays). Early HVAC system shutoff is determined entirely by the outdoor air temperature (OAT). If the OAT is less than or equal to 2C or greater than or equal to 18C, then no action is taken. The HVAC system is shut off one hour early when the OAT is between 12C and 18C. The HVAC system shut off time varies linearly with OAT from one hour to zero hours between 12C and 2C, and between 18C and 28C. AvailabilityManager:OptimumStart objects are inserted for each HVAC system in the model and use the AdaptiveASHRAE algorithm to dynamically adjust HVAC startup time each day.\"\n end", "def modeler_description\n return \"Multipliers for LPD, EPD, and people densities.\"\n end", "def modeler_description\n return \"This measure takes the user selected standards space type and sets the interior lighting and equipment load definitions subcategory to match the space type name. \"\n end", "def modeler_description\n return 'Will add the necessary UtilityCost objects into the model.'\n end", "def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to override specified thermostat control logic and set alternate modes of operation. This EMS measure sets a specific (user defined) indoor VRF terminal unit to operate at a specific (user-defined) part load ratio, constrained by operate minimum and maximum outdoor temperature limits of the paired condenser unit. The main input objects that implement this example are the variable refrigerant flow actuators that control the VRF system and specific terminal unit. Note that the terminal unit PLR can be controlled without controlling the mode of the VRF condenser, however, the specific terminal unit will operate in whatever mode the existing operation control scheme chooses. This example program simply “sets” the operating mode and PLR, other more complex control algorithms can be developed by the user as needed\"\n end", "def modeler_description\n return 'This measure swaps old cases with 2017 code compliant cases and more efficient ones.'\n end", "def modeler_description\n return \"The example demonstrates the use of a thermostat schedule object as and EMS actuator object. The EMS program alters the scheduled values as a function of hour of day and day of week.\"\n end", "def modeler_description\n 'This measure changes the Layer 0 properties of Thickness, Density, Thermal Absorptance, Solar Absorptance, Visible Absoptance, Thermal Conductivity, Specific Heat.'\n end", "def modeler_description\n return \"The measure loops through the AirLoops associated with the model, and determines an occupancy weighted schedule with values of 1 or 0 based on the percent of peak occupancy at the timestep being above or below a set threshold value of 5 percent. The resulting occupancy schedule is applied to the airloop attribute for the availability schedule. The measure then loops through all thermal zones, examining if there are zone equipment objects attached. If there are one or more zone equipment object attached to the zone, a thermal zone occupancy weighted schedule with values of 1 or 0 based on the percent of peak occupancy at the timestep being above or below a set threshold value of 5 percent is generated. The schedule is then assigned to the availability schedule of the associated zone equipment. To prevent energy use by any corresponding plant loops, the pump control type attribute of Constant or Variable speed pump objects in the model are set to intermittent. The measure them adds heating and cooling unmet hours and Simplified ASHRAE Standard 55 warning reporting variable to each thermal zone. \"\n end", "def modeler_description\r\n return \"This measure loops through the existing airloops, looking for loops that have a constant speed fan. (Note that if an object such as an AirloopHVAC:UnitarySystem is present in the model, that the measure will NOT identify that loop as either constant- or variable-speed, since the fan is located inside the UnitarySystem object.) The user can designate which constant-speed airloop they'd like to apply the measure to, or opt to apply the measure to all airloops. The measure then replaces the supply components on the airloop with an AirloopHVAC:UnitarySystem object. Any DX coils added to the UnitarySystem object are of the type CoilCoolingDXMultiSpeed / CoilHeatingDXMultiSpeed, with the number of stages set to either two or four, depending on user input. If the user opts for a gas furnace, an 80% efficient CoilHeatingGas object is added. Fan properties (pressure rise and total efficiency) are transferred automatically from the existing (but deleted) constant speed fan to the new variable-speed fan. Currently, this measure is only applicable to the Standalone Retail DOE Prototype building model, but it has been structured to facilitate expansion to other models with a minimum of effort.\"\r\n end", "def modeler_description\n return \"The measure loops through the heating and cooling thermostat schedules associated each thermal zone. The existing heating and cooling schedules are cloned, and the all run period profiles are then modified by adding a +1.5 deg F shift to the all values of the cooling thermostat schedule and a -1.5 degree F shift to all values of the heating thermostat schedule. Design Day profiles are not modified. The modified thermostat schedules are then assigned to the thermal zone. For each Thermal Zone, ASHRAE 55 Thermal Comfort Warnings is also enabled. Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status output variables is also added to the model.\"\n end", "def modeler_description\r\n return \"The Measure adds a Schedule Availability Manager to the Selected Plant Loop\"\r\n end", "def modeler_description\n return 'Converts the OpenStudio model to vA3C JSON format and renders using Three.js, simulation data is applied to surfaces of the model'\n end", "def modeler_description\n return 'This energy efficiency measure (EEM) replaces all cooling tower objects in a model of the following types: (OS:CoolingTowerPerformanceCoolTools, OS:CoolingTowerPerformanceYorkCalc, OS:CoolingTowerSingleSpeed, OS:CoolingTowerTwoSpeed, or OS:CoolingTowerVariableSpeed) with a new OS:CoolingTower:VariableSpeed object. If an existing cooling tower is already configured for variable speed, the measure will inform the user. When replacing an existing tower object, the following values from the existing tower configuration will be reused: Design Inlet Air Wet Bulb Temp, Design Approach Temperature, Design Range Temperature, Design Water Flow Rate, Design Air Flow Rate, Design Fan Power, Fraction of Tower Capacity in the Free Convection Regime, Basin Heater Capacity, Basin Heater Setpoint Temperature, Basin Heater Operating Schedule, Number of Cells, Cell Control, Cell Minimum and Maximum Water Flow Rate Fractions and Sizing Factor. A performance curve relating fan power to tower airflow rates is used. The curve assumes the fan power ratio is directly proportional to the air flow rate ratio cubed. A Minimum Air Flow Rate Ratio of 20% will be set. To model minimal but realistic water consumption, the Evaporation Loss Mode for new Tower objects will be set to ?Saturated Exit? and Drift Loss Percent will be set to a value of 0.05% of the Design Water Flow. Blowdown water usage will be based on maintaining a Concentration Ratio of 3.0.'\n end", "def make_and_model; end", "def modeler_description\n return 'Replaces exterior window constructions with a different construction from the model.'\n end", "def modeler_description\n return \"This measure will demonstrate how an OpenStudio measure calling EMS functions can be used to investigate dynamic envelope technologies such as emulating thermochromic window performance using EMS actuators and control types. This measure will replace the construction description of a user-selected window based on the outside surface temperature of that window, evaluated at each timestep\"\n end", "def modeler_description\n return \"This measure will demonstrate how EMS functions can be used to demonstrate how information from a sizing run can be used to select HVAC equipment from nominal product sizes where unit total capacity is directly related to the unit supply airflow (1 ton = 1200 cfm, 1.5 ton = 1600 cfm, etc.) of commercial packaged single-zone HVAC air systems. This measure is designed to work on AirLoops with packaged DX cooling equipment only. EMS functions will be used to extract the design supply airflow generated from system auto-sizing calculations. An interval variable is used to override the Sizing:System - 'Intermediate Air System Main Supply Volume Flow Rate' value variable. This measure approximates the manner that appropriate ‘real world’ equipment selections are made by HVAC design engineers. The table below will be used to map to the Maximum Flow rate of the packaged unit Fan:ConstantVolume object.\"\n end", "def modeler_description\n return \"This measure adds active or passive chilled beam units to selected conditioned thermal zones. In addition the user can select an existing air loop to serve active beams, or create a new Dual Wheel DOAS. Users can also select an existing chilled water loop to provide chilled water to beams, or create a new high temperature chiller water loop. Users are highly encouraged to review and modify the control strategies that this measure creates, such that it reflects their modeling scenario of interest.\"\n end", "def modeler_description\n return \"The difference between actual spaces and effective spaces takes into account the zone multipliers. The goal was to get average floor area assuming that each space represents a room vs. a collection of rooms. This was used to help determine average space sizes of different space types from the prototype buildings. In some cases I had to manaually adjust for where a space didn't map to a single room.\"\n end", "def modeler_description\n return \"Any heating components or baseboard convective electrics/waters are removed from any existing air/plant loops or zones. A boiler along with constant speed pump and water baseboard coils are added to a hot water plant loop.\"\n end", "def modeler_description\n return 'Thermal zones will be named after the spac with a prefix added'\n end", "def inspect\n \"#<#{self.class.name} @model=#{model.name} @relation_name=#{relation_name} @repository=#{self.class.repository}>\"\n end", "def inspect\n \"#<#{self.class.name} @model=#{model.inspect} @name=#{name.inspect}>\"\n end", "def modeler_description\n return \"Reduces runtime fraction of lights by user-specified amount during the user-specified time period (typically daytime). This is an attempt to represent the impact of using the light collected on the roof instead of electric lighting. This modeling approach does not capture the impact of using a PV cell to turn the IR spectrum of the captured light into electricity.\"\n end", "def modeler_description\n return 'This measure receives the AntiSweat heater Control from the user. Then it looks for refrigerated display cases; it loops through them; it checks the current AntiSweat heater Control of each case and it substitute it with the one chosen by the user.'\n end" ]
[ "0.7710149", "0.76145315", "0.75934714", "0.74018747", "0.7299891", "0.7296635", "0.727943", "0.71912926", "0.71912926", "0.7191264", "0.7100944", "0.70977926", "0.70629936", "0.7045383", "0.7044268", "0.70413125", "0.7040473", "0.7032938", "0.70267737", "0.70182866", "0.69875926", "0.6980763", "0.69496983", "0.69420075", "0.6936087", "0.6927004", "0.6908837", "0.6901907", "0.6893215", "0.6888214", "0.68663764", "0.6865241", "0.68641704", "0.68588334", "0.6833133", "0.68219167", "0.68055475", "0.6791062", "0.67879057", "0.67879057", "0.67879057", "0.67879057", "0.67879057", "0.67879057", "0.67879057", "0.67796487", "0.6773994", "0.6751447", "0.67244256", "0.6720888", "0.6716974", "0.6708703", "0.67021894", "0.668961", "0.66878057", "0.6672712", "0.6662903", "0.6649447", "0.6643762", "0.6634445", "0.66330194", "0.662195", "0.6616422", "0.6616422", "0.66100585", "0.659982", "0.6589568", "0.6588373", "0.65865505", "0.6584234", "0.65638506", "0.6560483", "0.6554784", "0.65097153", "0.64903986", "0.64771026", "0.6466807", "0.6462787", "0.6450267", "0.6443914", "0.64391804", "0.6431919", "0.6429849", "0.6426015", "0.6422519", "0.6421918", "0.64181775", "0.6415888", "0.6409096", "0.64074343", "0.64067763", "0.6405944", "0.64003026", "0.6370144" ]
0.6852012
38
define the arguments that the user will input
def arguments(model) args = OpenStudio::Ruleset::OSArgumentVector.new return args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arguments; end", "def arguments; end", "def arguments; end", "def arguments\n \"\"\n end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def get_input \n puts \"to save this game, input 's,filename'\"\n puts \"to load a game, input 'l,filename'\"\n puts \"input a coordinate to access. prefix with r for reveal or f for flag\"\n puts \"example 'f,1,2' places a flag at 1,2\"\n input = gets.chomp\n \n args = input.split(',')\n end", "def args(*) end", "def arguments(required, *optional)\n puts \"required: #{required}\"\n puts \"optional: #{optional}\"\nend", "def args()\n #This is a stub, used for indexing\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make an argument for the variable name\n variable_name = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"variable_name\",true)\n variable_name.setDisplayName(\"Enter Variable Name.\")\n variable_name.setDescription(\"Valid values can be found in the eplusout.rdd file after a simulation is run.\")\n args << variable_name\n \n #make an argument for the electric tariff\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Detailed\"\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Zone Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"Runperiod\"\n reporting_frequency = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName(\"Reporting Frequency.\")\n reporting_frequency.setDefaultValue(\"Hourly\")\n args << reporting_frequency\n\n #make an argument for the key_value\n key_value = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"key_value\",true)\n key_value.setDisplayName(\"Enter Key Name.\")\n key_value.setDescription(\"Enter * for all objects or the full name of a specific object to.\")\n key_value.setDefaultValue(\"*\")\n args << key_value\n \n env = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"env\", true)\n env.setDisplayName(\"availableEnvPeriods\")\n env.setDescription(\"availableEnvPeriods\")\n env.setDefaultValue(\"RUN PERIOD 1\")\n args << env\n \n return args\n end", "def set_arguments (args)\n end", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make an argument for the variable name\n variable_name = OpenStudio::Measure::OSArgument.makeStringArgument('variable_name', true)\n variable_name.setDisplayName('Enter Variable Name.')\n variable_name.setDescription('Valid values can be found in the eplusout.rdd file after a simulation is run.')\n args << variable_name\n\n # make an argument for the electric tariff\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << 'Detailed'\n reporting_frequency_chs << 'Timestep'\n reporting_frequency_chs << 'Zone Timestep'\n reporting_frequency_chs << 'Hourly'\n reporting_frequency_chs << 'Daily'\n reporting_frequency_chs << 'Monthly'\n reporting_frequency_chs << 'Runperiod'\n reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency.')\n reporting_frequency.setDefaultValue('Hourly')\n args << reporting_frequency\n\n # make an argument for the key_value\n key_value = OpenStudio::Measure::OSArgument.makeStringArgument('key_value', true)\n key_value.setDisplayName('Enter Key Name.')\n key_value.setDescription('Enter * for all objects or the full name of a specific object to.')\n key_value.setDefaultValue('*')\n args << key_value\n\n env = OpenStudio::Measure::OSArgument.makeStringArgument('env', true)\n env.setDisplayName('availableEnvPeriods')\n env.setDescription('availableEnvPeriods')\n env.setDefaultValue('RUN PERIOD 1')\n args << env\n\n args\n end", "def handle_arguments(args)\n if input_file.nil?\n print_usage\n true\n else\n args.help || args.version\n end\n end", "def arguments=(_arg0); end", "def command_line\r\n ARGV.each do |arg|\r\n if arg == \"instructions\"\r\n instructions\r\n elsif arg == \"calculator\"\r\n ask_for_digits\r\n else\r\n \r\n end\r\n end\r\n \r\n end", "def prescreen_input(args)\n if ((args.nil?) || (args.empty?))\n ['-eq', Date.today.strftime('%Y-%m-%d')]\n elsif ((args.length == 1) && (args[0].is_date?))\n ['-eq', args[0]]\n else\n args\n end\nend", "def varios_args(*args)\n puts \"Tamanho de args: #{args.size}\"\n args.each { |x| p x}\n end", "def process_arguments\n @e_addr = @options.email\n @r_name = @options.run_names\n @m_name = @options.machine_names\n @action = @options.action\n @snfs = @options.snfs\n end", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # url of the city database\n city_db_url = OpenStudio::Measure::OSArgument.makeStringArgument('city_db_url', true)\n city_db_url.setDisplayName('City Database Url')\n city_db_url.setDescription('Url of the City Database')\n city_db_url.setDefaultValue('')\n args << city_db_url\n\n # project id to update\n project_id = OpenStudio::Measure::OSArgument.makeStringArgument('project_id', true)\n project_id.setDisplayName('Project ID')\n project_id.setDescription('Project ID to generate reports for.')\n project_id.setDefaultValue('0')\n args << project_id\n\n # datapoint id to update\n datapoint_id = OpenStudio::Measure::OSArgument.makeStringArgument('datapoint_id', true)\n datapoint_id.setDisplayName('Datapoint ID')\n datapoint_id.setDescription('Datapoint ID to generate reports for.')\n datapoint_id.setDefaultValue('0')\n args << datapoint_id\n\n return args\n end", "def validate_args (args)\n\t# todo\nend", "def args() return @args end", "def input=(_arg0); end", "def process_inputs(args)\n @input = ((name = args[:in_file]) && (IO.read(name, mode: \"rb\"))) ||\n args[:in_str] ||\n fail(\"An input must be specified.\")\n\n @generator = args[:generator] ||\n ((key = args[:key]) && Generator.new(key)) ||\n fail(\"A key or generator must be specified.\")\n\n @window = args[:window] || 16\n\n #The filler value is for testing purposes only. It should\n #not be specified when secure operation is desired.\n @fill_value = args[:filler]\n end", "def parse_args\r\n if(cmd.args =~ /\\=/)\r\n self.names = InputFormatter.titlecase_arg(cmd.args.before(\"=\"))\r\n self.action_args = cmd.args.after(\"=\")\r\n elseif (cmd.args && one_word_command)\r\n self.names = InputFormatter.titlecase_arg(cmd.args)\r\n self.action_args = \"\"\r\n else\r\n self.names = enactor.name\r\n self.action_args = cmd.args\r\n end\r\n\r\n self.names = self.names ? self.names.split(/[ ,]/) : nil\r\n\r\n self.combat_command = cmd.switch ? cmd.switch.downcase : nil\r\n end", "def manage_args(*args)\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make an argument for your name\n user_name = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"user_name\",true)\n user_name.setDisplayName(\"What is your name?\")\n args << user_name\n\n #make an argument to add new space true/false\n add_space = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"add_space\",true)\n add_space.setDisplayName(\"Add a space to your model?\")\n add_space.setDefaultValue(true)\n args << add_space\n \n return args\n end", "def greeting\n puts \"Hello, MTA rider! How can we help?\"\n puts \"please enter one of the following commands:\"\n puts \"lines / stops the_line / calculate Departing_Line Departing_Stop Arriving_Line Arriving_Stop\"\n user_call, *user_args = gets.chomp\n user_args.to_s\n # user_args.split(\" \")\n # puts user_input\n\n if user_call == lines\n show_lines()\n elsif user_call == stops\n show_stops(user_args[0])\n elsif user_call == calculate\n if user_args.length < 4\n puts 'please enter \"Departing_Line Departing_Stop Arriving_Line Arriving_Stop\"'\n puts 'or enter \"exit\" to return to the home screen' \n user_input = gets.chomp\n if user_input == \"exit\"\n greeting()\n end \n user_input = user_input.split(\" \")\n calculate(user_input[0], user_input[1], user_input[2], user_input[3])\n else\n calculate(user_args[0], user_args[1], user_args[2], user_args[3])\n end\n else\n \n end\nend", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n\n\n # Make an argument for evap effectiveness\n input_csv_path = OpenStudio::Measure::OSArgument::makeStringArgument(\"input_csv_folder_path\",true)\n input_csv_path.setDisplayName(\"raw_data_input_folder_path\")\n input_csv_path.setDefaultValue(\"data_file\")\n args << input_csv_path\n\n test_numbers = OpenStudio::StringVector.new\n test_numbers << 'Test_3'\n test_numbers << 'Test_6'\n test_numbers << 'Test_8'\n \n test_names = OpenStudio::StringVector.new\n test_names << 'UA_test'\n test_names << 'Cooling_test'\n test_names << 'Plenum_test'\n\n test_selections = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('test_data',test_numbers,test_names,true)\n\n \n test_selections.setDisplayName(\"Experiment\")\n test_selections.setDefaultValue(\"Test_3\")\n args << test_selections\n\n \n return args\n end", "def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # URL of the DEnCity server that will be posted to\n hostname = OpenStudio::Ruleset::OSArgument::makeStringArgument('hostname', true)\n hostname.setDisplayName('URL of the DEnCity Server')\n hostname.setDefaultValue('http://www.dencity.org')\n args << hostname\n\n # DEnCity server user id at hostname\n user_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('user_id',true)\n user_id.setDisplayName('User ID for DEnCity Server')\n args << user_id\n\n # DEnCIty server user id's password\n auth_code = OpenStudio::Ruleset::OSArgument::makeStringArgument('auth_code', true)\n auth_code.setDisplayName('Authentication code for User ID on DEnCity server')\n args << auth_code\n\n # Building type for DEnCity's metadata\n building_type = OpenStudio::Ruleset::OSArgument::makeStringArgument('building_type', false)\n building_type.setDisplayName('Building type')\n args << building_type\n\n # HVAC system for DEnCity's metadata\n primary_hvac = OpenStudio::Ruleset::OSArgument::makeStringArgument('primary_hvac', false)\n primary_hvac.setDisplayName('Primary HVAC system in building')\n args << primary_hvac\n\n args\n\n end", "def arguments\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n #make choice argument for facade\r\n choices = OpenStudio::StringVector.new\r\n choices << \"MessagePack\"\r\n choices << \"CSV\"\r\n choices << \"Both\"\r\n output_format = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"output_format\", choices)\r\n output_format.setDisplayName(\"Output Format\")\r\n output_format.setDefaultValue(\"Both\")\r\n args << output_format\r\n\r\n args\r\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\t\n #make an argument for entering furnace installed afue\n afue = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"afue\",true)\n afue.setDisplayName(\"Installed AFUE\")\n afue.setUnits(\"Btu/Btu\")\n afue.setDescription(\"The installed Annual Fuel Utilization Efficiency (AFUE) of the furnace, which can be used to account for performance derating or degradation relative to the rated value.\")\n afue.setDefaultValue(1.0)\n args << afue\n\n #make an argument for entering furnace installed supply fan power\n fanpower = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"fan_power_installed\",true)\n fanpower.setDisplayName(\"Installed Supply Fan Power\")\n fanpower.setUnits(\"W/cfm\")\n fanpower.setDescription(\"Fan power (in W) per delivered airflow rate (in cfm) of the indoor fan for the maximum fan speed under actual operating conditions.\")\n fanpower.setDefaultValue(0.5)\n args << fanpower\t\n\t\n #make a string argument for furnace heating output capacity\n furnacecap = OpenStudio::Measure::OSArgument::makeStringArgument(\"capacity\", true)\n furnacecap.setDisplayName(\"Heating Capacity\")\n furnacecap.setDescription(\"The output heating capacity of the furnace. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n furnacecap.setUnits(\"kBtu/hr\")\n furnacecap.setDefaultValue(Constants.SizingAuto)\n args << furnacecap\n \n return args\n end", "def greeting(args)\r\n greet = args[:greet] || \"Hi\"\r\n title = args[:title] || \"Citizen\"\r\n name = args[:name] \r\n puts \"#{greet} #{title} #{name}\"\r\nend", "def parse_args\n\t\t@args = @args_a.each_slice(2).to_a.inject({}) { |h, k| h[k[0]] = k[1]; h }\n\t\tkeys = @skeys + @lkeys\n\t\[email protected] do |k, v|\n\t\t\tif !keys.include?(k)\n\t\t\t\tputs \"Unknown option `#{k}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif keys.include?(v)\n\t\t\t\tputs \"Missing values for `#{k}' and `#{v}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif v != nil\n\t\t\t\tif v.start_with?('-')\n\t\t\t\t\tputs \"Warning: Value of `#{k}' appears to be a flag\"\n\t\t\t\tend\n\n\t\t\t\tif @static.has_key?(k)\n\t\t\t\t\tif !@static[k].include?(v)\n\t\t\t\t\t\tputs \"Unknown option `#{v}' for `#{k}'\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\tif remove_keys(@no_vals).has_blank?\n\t\t\tputs \"Missing argument(s)\"\n\t\t\texit\n\t\tend\t\t\t\n\tend", "def command_line_arguments(array)\n array.size.times do\n if array.include?('-nc')\n colour_changer(:white)\n array.delete('-nc')\n elsif array.any? { |x| ['-d1', '-d2', '-d3', '-d4'].include? x }\n key = (array[0])[1, 2].to_sym\n @difficulty = DIFFICULTY[key]\n @promptarr = prompt_select(key)\n @intro = false\n end\n end\n end", "def arguments()\n args = OpenStudio::Measure::OSArgumentVector.new\n \n #make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Detailed\"\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"Runperiod\"\n reporting_frequency = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName(\"Reporting Frequency\")\n reporting_frequency.setDefaultValue(\"Hourly\")\n args << reporting_frequency\n \n # TODO: argument for subset of output meters\n \n return args\n end", "def arguments()\n args = OpenStudio::Measure::OSArgumentVector.new\n\n #make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << \"Timestep\"\n reporting_frequency_chs << \"Hourly\"\n reporting_frequency_chs << \"Daily\"\n reporting_frequency_chs << \"Monthly\"\n reporting_frequency_chs << \"RunPeriod\"\n arg = OpenStudio::Measure::OSArgument::makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n arg.setDisplayName(\"Reporting Frequency\")\n arg.setDefaultValue(\"Hourly\")\n args << arg\n\n #make an argument for including optional output variables\n arg = OpenStudio::Measure::OSArgument::makeBoolArgument(\"inc_output_variables\", true)\n arg.setDisplayName(\"Include Output Variables\")\n arg.setDefaultValue(false)\n args << arg\n\n return args\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make an argument for entering furnace installed afue\n userdefined_eff = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"userdefinedeff\",true)\n userdefined_eff.setDisplayName(\"Efficiency\")\n\tuserdefined_eff.setUnits(\"Btu/Btu\")\n\tuserdefined_eff.setDescription(\"The efficiency of the electric baseboard.\")\n userdefined_eff.setDefaultValue(1.0)\n args << userdefined_eff\n\n #make a choice argument for furnace heating output capacity\n cap_display_names = OpenStudio::StringVector.new\n cap_display_names << Constants.SizingAuto\n (5..150).step(5) do |kbtu|\n cap_display_names << \"#{kbtu} kBtu/hr\"\n end\n\n #make a string argument for furnace heating output capacity\n selected_baseboardcap = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"selectedbaseboardcap\", cap_display_names, true)\n selected_baseboardcap.setDisplayName(\"Heating Output Capacity\")\n selected_baseboardcap.setDefaultValue(Constants.SizingAuto)\n args << selected_baseboardcap\n\t\n return args\n end", "def user_input_command_line_menu\n\tcommand_line_input = gets.strip.to_i\n\tcommand_line_input_logic(command_line_input)\nend", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n #make an argument for entering baseboard efficiency\n baseboardeff = OpenStudio::Measure::OSArgument::makeDoubleArgument(\"efficiency\",true)\n baseboardeff.setDisplayName(\"Efficiency\")\n baseboardeff.setUnits(\"Btu/Btu\")\n baseboardeff.setDescription(\"The efficiency of the electric baseboard.\")\n baseboardeff.setDefaultValue(1.0)\n args << baseboardeff\n\n #make a string argument for baseboard heating output capacity\n baseboardcap = OpenStudio::Measure::OSArgument::makeStringArgument(\"capacity\", true)\n baseboardcap.setDisplayName(\"Heating Capacity\")\n baseboardcap.setDescription(\"The output heating capacity of the electric baseboard. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n baseboardcap.setUnits(\"kBtu/hr\")\n baseboardcap.setDefaultValue(Constants.SizingAuto)\n args << baseboardcap\n\t\n return args\n end", "def cmdarg; end", "def cmdarg; end", "def cmdarg; end", "def check_inputs_g(args)\n raise TypeError, Ajaila::Messager.warning(\"Nothing to generate...\") if args == []\n raise TypeError, Ajaila::Messager.warning(\"Only miners, selectors, presenters supported\\n(ex. miner SomeMiner, selector SomeSelector,\\n presenter SomePresenter, table SomeTable)\") if KNOWN_INSTANCES.include?(args[0]) == false\n raise TypeError, Ajaila::Messager.warning(\"Your #{args[0]} needs a name!\") if args[1] == nil\n raise TypeError, Ajaila::Messager.warning(\"Wrong format of the #{args[0]} name (use only A-Z and a-z symbols)\") if args[1][/^[A-Z]+$/i] == nil\n return 0\n end", "def arguments\n parser.arguments\n end", "def valid_args(type)\n case type\n when 'search' then %i[q format addressdetails extratags namedetails viewbox bounded exclude_place_ids limit accept-language email]\n when 'reverse' then %i[format lat lon zoom addressdetails extratags namedetails accept-language email]\n else []\n end\n end", "def madlib_inputs\n print \"Enter a noun: \" \n noun = gets.chomp\n print \"Enter a verb: \" \n verb = gets.chomp\n print \"Enter an adjective: \" \n adjective = gets.chomp\n print \"Enter an adverb: \" \n adverb = gets.chomp\n madlib_line(noun, verb, adjective, adverb)\nend", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n id = OpenStudio::Measure::OSArgument.makeStringArgument('feature_id', false)\n id.setDisplayName('Feature unique identifier')\n id.setDefaultValue('1')\n args << id\n\n name = OpenStudio::Measure::OSArgument.makeStringArgument('feature_name', false)\n name.setDisplayName('Feature scenario specific name')\n name.setDefaultValue('name')\n args << name\n\n feature_type = OpenStudio::Measure::OSArgument.makeStringArgument('feature_type', false)\n feature_type.setDisplayName('URBANopt Feature Type')\n feature_type.setDefaultValue('Building')\n args << feature_type\n\n feature_location = OpenStudio::Measure::OSArgument.makeStringArgument('feature_location', false)\n feature_location.setDisplayName('URBANopt Feature Location')\n feature_location.setDefaultValue('0')\n args << feature_location\n\n # make an argument for the frequency\n reporting_frequency_chs = OpenStudio::StringVector.new\n reporting_frequency_chs << 'Detailed'\n reporting_frequency_chs << 'Timestep'\n reporting_frequency_chs << 'Hourly'\n reporting_frequency_chs << 'Daily'\n # reporting_frequency_chs << 'Zone Timestep'\n reporting_frequency_chs << 'BillingPeriod' # match it to utility bill object\n ## Utility report here to report the start and end for each fueltype\n reporting_frequency_chs << 'Monthly'\n reporting_frequency_chs << 'Runperiod'\n\n reporting_frequency = OpenStudio::Measure::OSArgument.makeChoiceArgument('reporting_frequency', reporting_frequency_chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency')\n reporting_frequency.setDescription('The frequency at which to report timeseries output data.')\n reporting_frequency.setDefaultValue('Timestep')\n args << reporting_frequency\n\n return args\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make a start date argument\n start_date = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"start_date\",true)\n start_date.setDisplayName(\"Start date\")\n args << start_date\n \n #make an end date argument\n end_date = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"end_date\",true)\n end_date.setDisplayName(\"End date\")\n args << end_date\n \n return args\n end", "def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end", "def process_arguments\n # clean unsupport symbols, e.g. JieFang;\n # or error argument due to option typo, e.g. '-list' will put 'ist' into the array in this src.\n @support_newspapers = Array.new #TODO: move to elsewhere\n @support_newspapers << :XM\n @support_newspapers << :WHB\n @support_newspapers << :YZ\n # ATTENTION: command line input is an array of string, to be consistent, internally I use only symbol when using this symbol\n @options.newspapers = @options.newspapers.collect { | item | item.to_sym } & @support_newspapers\n \n if @options.newspapers.size == 0\n @support_newspapers.each do | sym |\n @options.newspapers << sym\n end\n end\n end", "def args\n raw_args\n end", "def argv; end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make an argument for your name\n code_choices = OpenStudio::StringVector.new \n code_choices << \"ASHRAE 90.1-2007\" \n code_choices << \"ASHRAE 90.1-2010\" \n energy_code = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('energy_code', code_choices, true)\n energy_code.setDisplayName(\"Code baseline\")\n energy_code.setDefaultValue(\"ASHRAE 90.1-2010\")\n args << energy_code\n \n #make an argument to add new space true/false\n leed_check = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"leed_check\",true)\n leed_check.setDisplayName(\"Perform typical LEED checks?\")\n leed_check.setDefaultValue(true)\n args << leed_check\n \n return args\n end", "def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \t\"os_object_type\"\t],\n [ \"weather_file_name\", \"STRING\", true, false, \"Weather File Name\", nil, nil, nil, nil, \t nil\t\t\t\t\t],\n #Default set for server weather folder.\n [ \"weather_directory\", \"STRING\", true, false, \"Weather Directory\", \"../../weather\", nil, nil, nil,\t nil\t\t\t\t\t]\n \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end", "def inflamed _args\n \"inflamed _args;\" \n end", "def more_options\n puts Rainbow(\"Specify your additional options for your search: 'release date', 'search history', or go back\").yellow.underline\n input = gets.chomp.downcase\n \n if input == \"release date\"\n option_release_date\n \n elsif input == \"search history\"\n game_history\n\n elsif input == \"go back\"\n continue_or_exit\n \n else \n puts \"Input not recognized please try again\"\n more_options\n end\n end", "def cmd(options={})\n arguments\n end", "def user_input\n\tgets\nend", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # this measure will require arguments, but at this time, they are not known\n geometry_profile = OpenStudio::Ruleset::OSArgument::makeStringArgument('geometry_profile', true)\n geometry_profile.setDefaultValue(\"{}\")\n os_model = OpenStudio::Ruleset::OSArgument::makeStringArgument('os_model', true)\n os_model.setDefaultValue('multi-model mode')\n user_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('user_id', true)\n user_id.setDefaultValue(\"00000000-0000-0000-0000-000000000000\")\n job_id = OpenStudio::Ruleset::OSArgument::makeStringArgument('job_id', true)\n #job_id.setDefaultValue(SecureRandom.uuid.to_s)\n ashrae_climate_zone = OpenStudio::Ruleset::OSArgument::makeStringArgument('ashrae_climate_zone', false)\n ashrae_climate_zone.setDefaultValue(\"-1\")\n building_type = OpenStudio::Ruleset::OSArgument::makeStringArgument('building_type', false)\n building_type.setDefaultValue(\"BadDefaultType\")\n\n args << geometry_profile\n args << os_model\n args << user_id\n args << job_id\n args << ashrae_climate_zone\n args << building_type\n\n return args\n end", "def input\n @input ||= args.dig(:input)\n end", "def parse_args\n require 'optimist'\n opts = Optimist.options do\n opt :source, \"Inventory Source UID\", :type => :string, :required => ENV[\"SOURCE_UID\"].nil?, :default => ENV[\"SOURCE_UID\"]\n opt :ingress_api, \"Hostname of the ingress-api route\", :type => :string, :default => ENV[\"INGRESS_API\"] || \"http://localhost:9292\"\n opt :config, \"Configuration file name\", :type => :string, :default => ENV[\"CONFIG\"] || \"default\"\n opt :data, \"Amount & custom values of generated items\", :type => :string, :default => ENV[\"DATA\"] || \"default\"\n end\n\n opts\nend", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # lat arg\n lat = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"lat\", true)\n lat.setDisplayName(\"Latitude\")\n lat.setDefaultValue(39.7392000000)\n args << lat\n\n # long arg\n lon = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"lon\", true)\n lon.setDisplayName(\"Longitude\")\n lon.setDefaultValue(-104.9903000000)\n args << lon\n\n return args\n end", "def add args\n db = get_db\n if args.empty?\n print \"Enter a short summary: \"\n STDOUT.flush\n text = gets.chomp\n if text.empty?\n exit ERRCODE\n end\n else\n # if you add last arg as P1..P5, I'll update priority automatically\n if args.last =~ /P[1-5]/\n $default_priority = args.pop\n end\n text = args.join \" \"\n end\n # convert actual newline to C-a. slash n's are escapes so echo -e does not muck up.\n #atitle=$( echo \"$atitle\" | tr -cd '\\40-\\176' )\n text.tr! \"\\n\", '\u0001'\n title = text\n desc = nil\n if $prompt_desc\n # choice of vim or this XXX also how to store in case of error or abandon\n # and allow user to edit, so no retyping. This could be for mult fields\n message \"Enter a detailed description (. to exit): \"\n desc = Cmdapp.get_lines\n #message \"You entered #{desc}\"\n end\n type = $default_type || \"bug\"\n severity = $default_severity || \"normal\"\n status = $default_status || \"open\"\n priority = $default_priority || \"P3\"\n if $prompt_type\n type = Cmdapp._choice(\"Select type:\", %w[bug enhancement feature task] )\n #message \"You selected #{type}\"\n end\n if $prompt_priority\n #priority = Cmdapp._choice(\"Select priority:\", %w[normal critical moderate] )\n priority = ask_priority\n #message \"You selected #{severity}\"\n end\n if $prompt_severity\n severity = Cmdapp._choice(\"Select severity:\", %w[normal critical moderate] )\n #message \"You selected #{severity}\"\n end\n if $prompt_status\n status = Cmdapp._choice(\"Select status:\", %w[open started closed stopped canceled] )\n #message \"You selected #{status}\"\n end\n assigned_to = $default_assigned_to\n if $prompt_assigned_to\n message \"Assign to:\"\n #assigned_to = $stdin.gets.chomp\n assigned_to = Cmdapp._gets \"assigned_to\", \"assigned_to\", $default_assigned_to\n #message \"You selected #{assigned_to}\"\n end\n project = component = version = nil\n # project\n if $use_project\n project = Cmdapp.user_input('project', $prompt_project, nil, $valid_project, $default_project)\n end\n if $use_component\n component = Cmdapp.user_input('component', $prompt_component, nil, $valid_component, $default_component)\n end\n if $use_version\n version = Cmdapp.user_input('version', $prompt_version, nil, $valid_version, $default_version)\n end\n\n start_date = @now\n due_date = default_due_date\n comment_count = 0\n priority ||= \"P3\" \n description = desc\n fix = nil #\"Some long text\" \n #date_created = @now\n #date_modified = @now\n body = {}\n body[\"title\"]=title\n body[\"description\"]=description\n body[\"type\"]=type\n body[\"status\"]=status\n body[\"start_date\"]=start_date.to_s\n body[\"due_date\"]=due_date.to_s\n body[\"priority\"]=priority\n body[\"severity\"]=severity\n body[\"assigned_to\"]=assigned_to\n body[\"created_by\"] = $default_user\n # only insert if its wanted by user\n body[\"project\"]=project if $use_project\n body[\"component\"]=component if $use_component\n body[\"version\"]=version if $use_version\n\n rowid = db.table_insert_hash(\"bugs\", body)\n puts \"Issue #{rowid} created\"\n logid = db.sql_logs_insert rowid, \"create\", \"#{rowid} #{type}: #{title}\"\n body[\"id\"] = rowid\n mail_issue nil, body\n \n 0\n end", "def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \"os_object_type\"\t ],\n [ \"alternativeModel\", \"STRING\", true, false, \"Alternative Model\", 'FullServiceRestaurant.osm', nil, nil, nil, \t nil\t\t\t\t\t],\n [ \"osm_directory\", \"STRING\", true, false, \"OSM Directory\", \"../../lib/btap/resources/models/smart_archetypes\", nil, nil, nil,\t nil\t\t\t\t\t] \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end", "def arguments(model)\n #list of arguments as they will appear in the interface. They are available in the run command as\n @argument_array_of_arrays = [\n [ \"variable_name\", \"type\", \"required\", \"model_dependant\", \"display_name\", \"default_value\", \"min_value\", \"max_value\", \"string_choice_array\", \"os_object_type\"\t ],\n [ \"alternativeModel\", \"STRING\", true, false, \"Alternative Model\", 'FullServiceRestaurant.osm', nil, nil, nil, \t nil\t\t\t\t\t],\n [ \"osm_directory\", \"STRING\", true, false, \"OSM Directory\", \"../../lib/btap/resources/models/smart_archetypes\", nil, nil, nil,\t nil\t\t\t\t\t] \n ]\n #set up arguments. \n args = OpenStudio::Ruleset::OSArgumentVector.new\n self.argument_setter(args)\n return args\n end", "def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n # the name of the sql file\r\n csv_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_name\", true)\r\n csv_name.setDisplayName(\"CSV file name\")\r\n csv_name.setDescription(\"CSV file name.\")\r\n csv_name.setDefaultValue(\"mtr.csv\")\r\n args << csv_name\r\n \r\n csv_time_header = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_time_header\", true)\r\n csv_time_header.setDisplayName(\"CSV Time Header\")\r\n csv_time_header.setDescription(\"CSV Time Header Value.\")\r\n csv_time_header.setDefaultValue(\"Date/Time\")\r\n args << csv_time_header\r\n \r\n csv_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var\", true)\r\n csv_var.setDisplayName(\"CSV variable name\")\r\n csv_var.setDescription(\"CSV variable name\")\r\n csv_var.setDefaultValue(\"Whole Building:Facility Total Electric Demand Power [W](TimeStep)\")\r\n args << csv_var\r\n \r\n csv_var_dn = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var_dn\", true)\r\n csv_var_dn.setDisplayName(\"CSV variable display name\")\r\n csv_var_dn.setDescription(\"CSV variable display name\")\r\n csv_var_dn.setDefaultValue(\"\")\r\n args << csv_var_dn\r\n \r\n years = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"year\", true)\r\n years.setDisplayName(\"Year in csv data\")\r\n years.setDescription(\"Year in csv data => mm:dd:yy or mm:dd\")\r\n years.setDefaultValue(true)\r\n args << years\r\n \r\n seconds = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"seconds\", true)\r\n seconds.setDisplayName(\"Seconds in csv data\")\r\n seconds.setDescription(\"Seconds in csv data => hh:mm:ss or hh:mm\")\r\n seconds.setDefaultValue(true)\r\n args << seconds\r\n \r\n sql_key = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_key\", true)\r\n sql_key.setDisplayName(\"SQL key\")\r\n sql_key.setDescription(\"SQL key\")\r\n sql_key.setDefaultValue(\"Whole Building\")\r\n args << sql_key \r\n\r\n sql_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_var\", true)\r\n sql_var.setDisplayName(\"SQL var\")\r\n sql_var.setDescription(\"SQL var\")\r\n sql_var.setDefaultValue(\"Facility Total Electric Demand Power\")\r\n args << sql_var \r\n \r\n norm = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"norm\", true)\r\n norm.setDisplayName(\"norm of the difference of csv and sql\")\r\n norm.setDescription(\"norm of the difference of csv and sql\")\r\n norm.setDefaultValue(1)\r\n args << norm \r\n\r\n find_avail = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"find_avail\", true)\r\n find_avail.setDisplayName(\"find_avail\")\r\n find_avail.setDescription(\"find_avail\")\r\n find_avail.setDefaultValue(true)\r\n args << find_avail \r\n\r\n compute_diff = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"compute_diff\", true)\r\n compute_diff.setDisplayName(\"compute_diff\")\r\n compute_diff.setDescription(\"compute_diff\")\r\n compute_diff.setDefaultValue(true)\r\n args << compute_diff\r\n \r\n verbose_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"verbose_messages\", true)\r\n verbose_messages.setDisplayName(\"verbose_messages\")\r\n verbose_messages.setDescription(\"verbose_messages\")\r\n verbose_messages.setDefaultValue(true)\r\n args << verbose_messages \r\n\r\n return args\r\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\t\t\n\n #Make a string argument for occupants (auto or number)\n num_occ = OpenStudio::Measure::OSArgument::makeStringArgument(\"num_occ\", false)\n num_occ.setDisplayName(\"Number of Occupants\")\n num_occ.setDescription(\"Specify the number of occupants. For a multifamily building, specify one value for all units or a comma-separated set of values (in the correct order) for each unit. A value of '#{Constants.Auto}' will calculate the average number of occupants from the number of bedrooms. Used to specify the internal gains from people only.\")\n num_occ.setDefaultValue(Constants.Auto)\n args << num_occ\n\n #Make a string argument for 24 weekday schedule values\n weekday_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"weekday_sch\", true)\n weekday_sch.setDisplayName(\"Weekday schedule\")\n weekday_sch.setDescription(\"Specify the 24-hour weekday schedule.\")\n weekday_sch.setDefaultValue(\"1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 0.88310, 0.40861, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.29498, 0.55310, 0.89693, 0.89693, 0.89693, 1.00000, 1.00000, 1.00000\")\n args << weekday_sch\n \n #Make a string argument for 24 weekend schedule values\n weekend_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"weekend_sch\", true)\n weekend_sch.setDisplayName(\"Weekend schedule\")\n weekend_sch.setDescription(\"Specify the 24-hour weekend schedule.\")\n weekend_sch.setDefaultValue(\"1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 0.88310, 0.40861, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.24189, 0.29498, 0.55310, 0.89693, 0.89693, 0.89693, 1.00000, 1.00000, 1.00000\")\n args << weekend_sch\n\n #Make a string argument for 12 monthly schedule values\n monthly_sch = OpenStudio::Measure::OSArgument::makeStringArgument(\"monthly_sch\", true)\n monthly_sch.setDisplayName(\"Month schedule\")\n monthly_sch.setDescription(\"Specify the 12-month schedule.\")\n monthly_sch.setDefaultValue(\"1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0\")\n args << monthly_sch\n\n return args\n end", "def validate_arguments()\n usage unless ARGV.count > 0\nend", "def input args\n if args.state.inputlist.length > 5\n args.state.inputlist.pop\n end\n\n should_process_special_move = (args.inputs.keyboard.key_down.j) ||\n (args.inputs.keyboard.key_down.k) ||\n (args.inputs.keyboard.key_down.a) ||\n (args.inputs.keyboard.key_down.d) ||\n (args.inputs.controller_one.key_down.y) ||\n (args.inputs.controller_one.key_down.x) ||\n (args.inputs.controller_one.key_down.left) ||\n (args.inputs.controller_one.key_down.right)\n\n if (should_process_special_move)\n if (args.inputs.keyboard.key_down.j && args.inputs.keyboard.key_down.k) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"shield\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.inputlist[0] == \"forward-attack\") && ((args.state.tick_count - args.state.lastpush) <= 15)\n args.state.inputlist.unshift(\"dash-attack\")\n args.state.player.dx = 20\n elsif (args.inputs.keyboard.key_down.j && args.inputs.keyboard.a) ||\n (args.inputs.controller_one.key_down.x && args.inputs.controller_one.key_down.left)\n args.state.inputlist.unshift(\"back-attack\")\n elsif ( args.inputs.controller_one.key_down.x || args.inputs.keyboard.key_down.j)\n args.state.inputlist.unshift(\"forward-attack\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y) &&\n (args.state.player.y > 128)\n args.state.inputlist.unshift(\"dair\")\n elsif (args.inputs.keyboard.key_down.k || args.inputs.controller_one.key_down.y)\n args.state.inputlist.unshift(\"up-attack\")\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a) &&\n (args.state.inputlist[0] == \"<\") &&\n ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.inputlist.unshift(\"<<\")\n args.state.player.dx = -15\n elsif (args.inputs.controller_one.key_down.left || args.inputs.keyboard.key_down.a)\n args.state.inputlist.unshift(\"<\")\n args.state.timeleft = args.state.tick_count\n elsif (args.inputs.controller_one.key_down.right || args.inputs.keyboard.key_down.d)\n args.state.inputlist.unshift(\">\")\n end\n\n args.state.lastpush = args.state.tick_count\n end\n\n if args.inputs.keyboard.space || args.inputs.controller_one.r2 # if the user presses the space bar\n args.state.player.jumped_at ||= args.state.tick_count # jumped_at is set to current frame\n\n # if the time that has passed since the jump is less than the player's jump duration and\n # the player is not falling\n if args.state.player.jumped_at.elapsed_time < args.state.player_jump_power_duration && !args.state.player.falling\n args.state.player.dy = args.state.player_jump_power # change in y is set to power of player's jump\n end\n end\n\n # if the space bar is in the \"up\" state (or not being pressed down)\n if args.inputs.keyboard.key_up.space || args.inputs.controller_one.key_up.r2\n args.state.player.jumped_at = nil # jumped_at is empty\n args.state.player.falling = true # the player is falling\n end\n\n if args.inputs.left # if left key is pressed\n if args.state.player.dx < -5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = -5\n end\n\n elsif args.inputs.right # if right key is pressed\n if args.state.player.dx > 5\n args.state.player.dx = args.state.player.dx\n else\n args.state.player.dx = 5\n end\n else\n args.state.player.dx *= args.state.player_speed_slowdown_rate # dx is scaled down\n end\n\n if ((args.state.player.dx).abs > 5) #&& ((args.state.tick_count - args.state.lastpush) <= 10)\n args.state.player.dx *= 0.95\n end\nend", "def arguments(model = nil)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n chs = OpenStudio::StringVector.new\n chs << 'Last OSM'\n chs << 'Last IDF'\n file_source = OpenStudio::Ruleset::OSArgument.makeChoiceArgument('file_source', chs, true)\n file_source.setDisplayName('Model Source')\n file_source.setDefaultValue('Last OSM')\n args << file_source\n\n chs = OpenStudio::StringVector.new\n chs << 'Timestep'\n chs << 'Hourly'\n reporting_frequency = OpenStudio::Ruleset::OSArgument.makeChoiceArgument('reporting_frequency', chs, true)\n reporting_frequency.setDisplayName('Reporting Frequency')\n reporting_frequency.setDefaultValue('Hourly')\n args << reporting_frequency\n\n variable1_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable1_name', true)\n variable1_name.setDisplayName('Variable 1 Name')\n variable1_name.setDefaultValue('Surface Outside Face Temperature')\n args << variable1_name\n\n variable2_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable2_name', true)\n variable2_name.setDisplayName('Variable 2 Name')\n variable2_name.setDefaultValue('Surface Inside Face Temperature')\n args << variable2_name\n\n variable3_name = OpenStudio::Ruleset::OSArgument.makeStringArgument('variable3_name', true)\n variable3_name.setDisplayName('Variable 3 Name')\n variable3_name.setDefaultValue('Zone Mean Radiant Temperature')\n args << variable3_name\n\n return args\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Create a list of the names and handles of space types\n # used in the building.\n used_space_type_handles = OpenStudio::StringVector.new\n used_space_type_names = OpenStudio::StringVector.new\n model.getSpaceTypes.sort.each do |space_type|\n if space_type.spaces.size > 0 # only show space types used in the building\n used_space_type_handles << space_type.handle.to_s\n used_space_type_names << space_type.name.to_s\n end\n end\n\t\n # Make an argument for plenum space type\n ceiling_return_plenum_space_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"ceiling_return_plenum_space_type\", used_space_type_handles, used_space_type_names,false)\n ceiling_return_plenum_space_type.setDisplayName(\"This space type should be part of a ceiling return air plenum.\")\n args << ceiling_return_plenum_space_type\n\t\n # Make a bool argument to edit/not edit each space type\n\t\tmodel.getSpaceTypes.sort.each do |space_type|\n\t\t\tif space_type.spaces.size > 0 # only show space types used in the building\n\t\t\t\tspace_type_to_edit = OpenStudio::Ruleset::OSArgument::makeBoolArgument(space_type.name.get.to_s,false)\n\t\t\t\t# Make a bool argument for this space type\n\t\t\t\tspace_type_to_edit.setDisplayName(\"Add #{space_type.name.get} space type to GSHP system?\")\n\t\t\t\tspace_type_to_edit.setDefaultValue(false)\t\t\n\t\t\t\targs << space_type_to_edit\n\t\t\tend\n\t\tend\n\t \n\t\t# Heating COP of GSHP\n\t\tgshp_htg_cop = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"gshp_htg_cop\",false)\n\t\tgshp_htg_cop.setDisplayName(\"GSHP DX Heating Coil Heating COP\")\n\t\tgshp_htg_cop.setDefaultValue(4.0)\n\t\targs << gshp_htg_cop\n\t\t\n\t\t# Cooling EER of GSHP\n\t\tgshp_clg_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"gshp_clg_eer\",false)\n\t\tgshp_clg_eer.setDisplayName(\"GSHP DX Cooling Coil Cooling EER\")\n\t\tgshp_clg_eer.setDefaultValue(14)\n\t\targs << gshp_clg_eer\n\t\t\n\t\t# GSHP Fan Type PSC or ECM\n\t\tfan_choices = OpenStudio::StringVector.new\n\t\tfan_choices << \"PSC\"\n\t\tfan_choices << \"ECM\"\n\t\tgshp_fan_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"gshp_fan_type\",fan_choices,true) # note ECM fan type may correspond to different set of heat pump performance curves\n\t\tgshp_fan_type.setDisplayName(\"GSHP Fan Type: PSC or ECM?\")\n\t\tgshp_fan_type.setDefaultValue(\"PSC\")\n args << gshp_fan_type\n\t\t\n\t\t# Condenser Loop Cooling Temperature\n\t\t# condLoopCoolingTemp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"condLoopCoolingTemp\",false)\n\t\t# condLoopCoolingTemp.setDisplayName(\"Condenser Loop Cooling Temperature (F)\")\n\t\t# condLoopCoolingTemp.setDefaultValue(90)\n\t\t# args << condLoopCoolingTemp\n\t\t\n\t\t# Condenser Loop Heating Temperature\n\t\t# condLoopHeatingTemp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"condLoopHeatingTemp\",false)\n\t\t# condLoopHeatingTemp.setDisplayName(\"Condenser Loop Heating Temperature (F)\")\n\t\t# condLoopHeatingTemp.setDefaultValue(60)\t\n\t\t# args << condLoopHeatingTemp\n\t\t\n\t\t# Vertical Bore HX\n\t\tbuilding_area = model.getBuilding.floorArea \n\t\tbuilding_cool_ton = building_area*10.7639/500\t\t# 500sf/ton estimated\n\t\tbore_hole_no = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"bore_hole_no\",false)\n\t\tbore_hole_no.setDisplayName(\"Number of Bore Holes\")\n\t\tbore_hole_no.setDefaultValue(building_cool_ton.to_i) \n\t\targs << bore_hole_no\n\n\t\t\n\t\tbore_hole_length = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"bore_hole_length\",false)\n\t\tbore_hole_length.setDisplayName(\"Bore Hole Length (ft)\")\n\t\tbore_hole_length.setDefaultValue(200)\n\t\targs << bore_hole_length\n\n\t\tbore_hole_radius = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"bore_hole_radius\",false)\n\t\tbore_hole_radius.setDisplayName(\"Bore Hole Radius (inch)\")\n\t\tbore_hole_radius.setDefaultValue(6.0)\n\t\targs << bore_hole_radius\n\t\t\n\t\tground_k_value = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"ground_k_value\",false)\n\t\tground_k_value.setDisplayName(\"Ground Conductivity (Btu/hr.F.R\")\n\t\tground_k_value.setDefaultValue(0.75)\n\t\targs << ground_k_value\n\t\t\n\t\tgrout_k_value = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"grout_k_value\",false)\n\t\tgrout_k_value.setDisplayName(\"Grout Conductivity (Btu/hr.F.R\")\n\t\tgrout_k_value.setDefaultValue(0.75)\n\t\targs << grout_k_value\n\t\t\n\t\tchs = OpenStudio::StringVector.new\n\t\tchs << \"Yes\"\n\t\tchs << \"No\"\n\t\tsupplemental_boiler = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"supplemental_boiler\",chs, true)\n\t\tsupplemental_boiler.setDisplayName(\"Supplemental Heating Boiler?\")\n\t\tsupplemental_boiler.setDefaultValue(\"No\")\n\t\targs << supplemental_boiler\n\t\t\n\t\t# Boiler Capacity\n\t\tboiler_cap = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_cap\",false)\n\t\tboiler_cap.setDisplayName(\"boiler normal capacity (MBtuh)\")\n\t\tboiler_cap.setDefaultValue(500.0)\n\t\targs << boiler_cap\n\t\t\t\t\n\t\t# Boiler Efficiency\n\t\tboiler_eff = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_eff\",false)\n\t\tboiler_eff.setDisplayName(\"Boiler Thermal Efficiency\")\n\t\tboiler_eff.setDefaultValue(0.9)\n\t\targs << boiler_eff\n\t\t\n\t\t# Boiler fuel Type\n\t\tfuel_choices = OpenStudio::StringVector.new\n\t\tfuel_choices << \"NaturalGas\"\n\t\tfuel_choices << \"PropaneGas\"\n\t\tfuel_choices << \"FuelOil#1\"\n\t\tfuel_choices << \"FuelOil#2\"\n\t\tfuel_choices << \"Electricity\"\n\t\tboiler_fuel_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"boiler_fuel_type\",fuel_choices,false) \n\t\tboiler_fuel_type.setDisplayName(\"Boiler Fuel Type\")\n\t\tboiler_fuel_type.setDefaultValue(\"NaturalGas\")\n\t\targs << boiler_fuel_type\n\t\t\n\t\t# boiler Hot water supply temperature\n\t\tboiler_hw_st = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"boiler_hw_st\",false)\n\t\tboiler_hw_st.setDisplayName(\"Boiler Design Heating Water Outlet Temperature (F)\")\n\t\tboiler_hw_st.setDefaultValue(120)\t\n\t\targs << boiler_hw_st\n\t\t\n\t\t# DOAS Fan Type\n\t\tdoas_fan_choices = OpenStudio::StringVector.new\n\t\tdoas_fan_choices << \"Constant\"\n\t\tdoas_fan_choices << \"Variable\"\n\t\tdoas_fan_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_fan_type\",doas_fan_choices,true)\n\t\tdoas_fan_type.setDisplayName(\"DOAS Fan Flow Control - Variable means DCV controls\")\n\t\tdoas_fan_type.setDefaultValue(\"Variable\")\n\t\targs << doas_fan_type\n\t\t\n\t\t# DOAS Energy Recovery\n\t\terv_choices = OpenStudio::StringVector.new\n\t\terv_choices << \"plate w/o economizer lockout\"\n\t\terv_choices << \"plate w/ economizer lockout\"\n\t\terv_choices << \"rotary wheel w/o economizer lockout\"\n\t\terv_choices << \"rotary wheel w/ economizer lockout\"\n\t\terv_choices << \"none\"\n\t\tdoas_erv = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_erv\",erv_choices,true)\n\t\tdoas_erv.setDisplayName(\"DOAS Energy Recovery?\")\n\t\tdoas_erv.setDefaultValue(\"none\")\n\t\targs << doas_erv\n\t\t\n\t\t# DOAS Evaporative Cooling\n\t\tevap_choices = OpenStudio::StringVector.new\n\t\tevap_choices << \"Direct Evaporative Cooler\"\n\t\tevap_choices << \"none\"\n\t\tdoas_evap = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"doas_evap\",evap_choices,true)\n\t\tdoas_evap.setDisplayName(\"DOAS Direct Evaporative Cooling?\")\n\t\tdoas_evap.setDefaultValue(\"none\")\n\t\targs << doas_evap\n\t\t\n\t\t# DOAS DX Cooling\n\t\tdoas_dx_eer = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"doas_dx_eer\",false)\n\t\tdoas_dx_eer.setDisplayName(\"DOAS DX Cooling EER\")\n\t\tdoas_dx_eer.setDefaultValue(10.0)\n\t\targs << doas_dx_eer\n\t\n # make an argument for material and installation cost\n # todo - I would like to split the costing out to the air loops weighted by area of building served vs. just sticking it on the building\n cost_total_hvac_system = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cost_total_hvac_system\",true)\n cost_total_hvac_system.setDisplayName(\"Total Cost for HVAC System ($).\")\n cost_total_hvac_system.setDefaultValue(0.0)\n args << cost_total_hvac_system\n \n #make an argument to remove existing costs\n remake_schedules = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"remake_schedules\",true)\n remake_schedules.setDisplayName(\"Apply recommended availability and ventilation schedules for air handlers?\")\n remake_schedules.setDefaultValue(true)\n args << remake_schedules\n\n return args\n end", "def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n # the name of the sql file\r\n csv_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_name\", true)\r\n csv_name.setDisplayName(\"CSV file name\")\r\n csv_name.setDescription(\"CSV file name.\")\r\n csv_name.setDefaultValue(\"mtr.csv\")\r\n args << csv_name\r\n \r\n csv_time_header = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_time_header\", true)\r\n csv_time_header.setDisplayName(\"CSV Time Header\")\r\n csv_time_header.setDescription(\"CSV Time Header Value.\")\r\n csv_time_header.setDefaultValue(\"Date/Time\")\r\n args << csv_time_header\r\n \r\n csv_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var\", true)\r\n csv_var.setDisplayName(\"CSV variable name\")\r\n csv_var.setDescription(\"CSV variable name\")\r\n csv_var.setDefaultValue(\"Whole Building:Facility Total Electric Demand Power [W](TimeStep)\")\r\n args << csv_var\r\n \r\n csv_var_dn = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"csv_var_dn\", true)\r\n csv_var_dn.setDisplayName(\"CSV variable display name\")\r\n csv_var_dn.setDescription(\"CSV variable display name\")\r\n csv_var_dn.setDefaultValue(\"\")\r\n args << csv_var_dn\r\n \r\n years = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"year\", true)\r\n years.setDisplayName(\"Year in csv data\")\r\n years.setDescription(\"Year in csv data => mm:dd:yy or mm:dd\")\r\n years.setDefaultValue(true)\r\n args << years\r\n \r\n seconds = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"seconds\", true)\r\n seconds.setDisplayName(\"Seconds in csv data\")\r\n seconds.setDescription(\"Seconds in csv data => hh:mm:ss or hh:mm\")\r\n seconds.setDefaultValue(true)\r\n args << seconds\r\n \r\n sql_key = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_key\", true)\r\n sql_key.setDisplayName(\"SQL key\")\r\n sql_key.setDescription(\"SQL key\")\r\n sql_key.setDefaultValue(\"\")\r\n args << sql_key \r\n\r\n sql_var = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"sql_var\", true)\r\n sql_var.setDisplayName(\"SQL var\")\r\n sql_var.setDescription(\"SQL var\")\r\n sql_var.setDefaultValue(\"Facility Total Electric Demand Power\")\r\n args << sql_var \r\n \r\n stp = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"stp\", true)\r\n stp.setDisplayName(\"Timeseries Timestep\")\r\n stp.setDescription(\"Timeseries Timestep\")\r\n stp.setDefaultValue(\"Zone Timestep\")\r\n args << stp\r\n \r\n env = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"env\", true)\r\n env.setDisplayName(\"availableEnvPeriods\")\r\n env.setDescription(\"availableEnvPeriods\")\r\n env.setDefaultValue(\"RUN PERIOD 1\")\r\n args << env\r\n \r\n norm = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"norm\", true)\r\n norm.setDisplayName(\"norm of the difference of csv and sql\")\r\n norm.setDescription(\"norm of the difference of csv and sql\")\r\n norm.setDefaultValue(1)\r\n args << norm \r\n\r\n scale = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"scale\", true)\r\n scale.setDisplayName(\"scale factor to apply to the difference\")\r\n scale.setDescription(\"scale factor to apply to the difference\")\r\n scale.setDefaultValue(1)\r\n args << scale \r\n\r\n find_avail = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"find_avail\", true)\r\n find_avail.setDisplayName(\"find_avail\")\r\n find_avail.setDescription(\"find_avail\")\r\n find_avail.setDefaultValue(true)\r\n args << find_avail \r\n\r\n compute_diff = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"compute_diff\", true)\r\n compute_diff.setDisplayName(\"compute_diff\")\r\n compute_diff.setDescription(\"compute_diff\")\r\n compute_diff.setDefaultValue(true)\r\n args << compute_diff\r\n \r\n verbose_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"verbose_messages\", true)\r\n verbose_messages.setDisplayName(\"verbose_messages\")\r\n verbose_messages.setDescription(\"verbose_messages\")\r\n verbose_messages.setDefaultValue(true)\r\n args << verbose_messages \r\n \r\n algorithm_download = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"algorithm_download\", true)\r\n algorithm_download.setDisplayName(\"algorithm_download\")\r\n algorithm_download.setDescription(\"algorithm_download\")\r\n algorithm_download.setDefaultValue(false)\r\n args << algorithm_download \r\n \r\n plot_flag = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"plot_flag\", true)\r\n plot_flag.setDisplayName(\"plot_flag timeseries data\")\r\n plot_flag.setDescription(\"plot_flag timeseries data\")\r\n plot_flag.setDefaultValue(true)\r\n args << plot_flag\r\n \r\n plot_name = OpenStudio::Ruleset::OSArgument.makeStringArgument(\"plot_name\", true)\r\n plot_name.setDisplayName(\"Plot name\")\r\n plot_name.setDescription(\"Plot name\")\r\n plot_name.setDefaultValue(\"\")\r\n args << plot_name\r\n \r\n warning_messages = OpenStudio::Ruleset::OSArgument.makeBoolArgument(\"warning_messages\", true)\r\n warning_messages.setDisplayName(\"warning_messages\")\r\n warning_messages.setDescription(\"warning_messages\")\r\n warning_messages.setDefaultValue(false)\r\n args << warning_messages\r\n\r\n return args\r\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # the name of the space to add to the model\n setpoint = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"setpoint_temperature\", true)\n setpoint.setUnits(\"Degrees Celsius\")\n setpoint.setDisplayName(\"Ambient Loop Temperature\")\n setpoint.setDefaultValue(20)\n setpoint.setDescription(\"Temperature setpoint for the ambient loop\")\n args << setpoint\n\n delta = OpenStudio::Ruleset::OSArgument.makeDoubleArgument(\"design_delta\", true)\n delta.setUnits(\"Delta Temperature\")\n delta.setDefaultValue(5.55) # 10 Deg F default delta\n delta.setDisplayName(\"Delta Design Loop Temperature\")\n delta.setDescription(\"Delta design temperature for the ambient loop\")\n args << delta\n\n return args\n end", "def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n return args\n end", "def print_two_again(arg1, arg2) # Non-variable list of inputs it will accept\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend", "def commander _args\n \"commander _args;\" \n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make a string argument for furnace fuel type\n fuel_display_names = OpenStudio::StringVector.new\n fuel_display_names << Constants.FuelTypeGas\n fuel_display_names << Constants.FuelTypeOil\n fuel_display_names << Constants.FuelTypePropane\n fuel_display_names << Constants.FuelTypeElectric\n fuel_type = OpenStudio::Measure::OSArgument::makeChoiceArgument('fuel_type', fuel_display_names, true)\n fuel_type.setDisplayName('Fuel Type')\n fuel_type.setDescription('Type of fuel used for heating.')\n fuel_type.setDefaultValue(Constants.FuelTypeGas)\n args << fuel_type\n\n # make an argument for entering furnace installed afue\n afue = OpenStudio::Measure::OSArgument::makeDoubleArgument('afue', true)\n afue.setDisplayName('Installed AFUE')\n afue.setUnits('Btu/Btu')\n afue.setDescription('The installed Annual Fuel Utilization Efficiency (AFUE) of the furnace, which can be used to account for performance derating or degradation relative to the rated value.')\n afue.setDefaultValue(0.78)\n args << afue\n\n # make an argument for entering furnace installed supply fan power\n fan_power_installed = OpenStudio::Measure::OSArgument::makeDoubleArgument('fan_power_installed', true)\n fan_power_installed.setDisplayName('Installed Supply Fan Power')\n fan_power_installed.setUnits('W/cfm')\n fan_power_installed.setDescription('Fan power (in W) per delivered airflow rate (in cfm) of the indoor fan for the maximum fan speed under actual operating conditions.')\n fan_power_installed.setDefaultValue(0.5)\n args << fan_power_installed\n\n # make a string argument for furnace heating output capacity\n capacity = OpenStudio::Measure::OSArgument::makeStringArgument('capacity', true)\n capacity.setDisplayName('Heating Capacity')\n capacity.setDescription(\"The output heating capacity of the furnace. If using '#{Constants.SizingAuto}', the autosizing algorithm will use ACCA Manual S to set the capacity.\")\n capacity.setUnits('kBtu/hr')\n capacity.setDefaultValue(Constants.SizingAuto)\n args << capacity\n\n # make a string argument for distribution system efficiency\n dse = OpenStudio::Measure::OSArgument::makeStringArgument('dse', true)\n dse.setDisplayName('Distribution System Efficiency')\n dse.setDescription('Defines the energy losses associated with the delivery of energy from the equipment to the source of the load.')\n dse.setDefaultValue('NA')\n args << dse\n\n # make a bool argument for open hvac flue\n has_hvac_flue = OpenStudio::Measure::OSArgument::makeBoolArgument('has_hvac_flue', true)\n has_hvac_flue.setDisplayName('Air Leakage: Has Open HVAC Flue')\n has_hvac_flue.setDescription('Specifies whether the building has an open flue associated with the HVAC system.')\n has_hvac_flue.setDefaultValue(true)\n args << has_hvac_flue\n\n return args\n end", "def args\n @args\n end", "def default_args(a,b,c=1)\n puts \"\\nValues of variables: \",a,b,c\nend", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n return args\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n \n \t#Make a string argument for 24 weekday cooling set point values\n clg_wkdy = OpenStudio::Measure::OSArgument::makeStringArgument(\"clg_wkdy\", false)\n clg_wkdy.setDisplayName(\"Weekday Setpoint\")\n clg_wkdy.setDescription(\"Specify a single cooling setpoint or a 24-hour comma-separated cooling schedule for the weekdays.\")\n clg_wkdy.setUnits(\"degrees F\")\n clg_wkdy.setDefaultValue(\"76\")\n args << clg_wkdy \n \n \t#Make a string argument for 24 weekend cooling set point values\n clg_wked = OpenStudio::Measure::OSArgument::makeStringArgument(\"clg_wked\", false)\n clg_wked.setDisplayName(\"Weekend Setpoint\")\n clg_wked.setDescription(\"Specify a single cooling setpoint or a 24-hour comma-separated cooling schedule for the weekend.\")\n clg_wked.setUnits(\"degrees F\")\n clg_wked.setDefaultValue(\"76\")\n args << clg_wked\t\n\t\n return args\n end", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n # this measure does not require any user arguments, return an empty list\n return args\n end" ]
[ "0.73748195", "0.73748195", "0.73748195", "0.7087363", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.7008232", "0.682961", "0.6826167", "0.6759192", "0.6747159", "0.6589147", "0.6579065", "0.65786225", "0.6544587", "0.6501246", "0.64746875", "0.64696026", "0.64695764", "0.6468071", "0.64624786", "0.6409045", "0.6388565", "0.6377955", "0.6372687", "0.6372046", "0.63623196", "0.63580847", "0.634898", "0.63470536", "0.6346329", "0.6328366", "0.6327314", "0.6293709", "0.6288431", "0.6271303", "0.6256699", "0.62562937", "0.6239551", "0.62357897", "0.62354136", "0.62218416", "0.62218416", "0.62218416", "0.6203231", "0.6194215", "0.6180256", "0.61709577", "0.6168221", "0.6167057", "0.6164105", "0.61599123", "0.61444277", "0.612839", "0.6116114", "0.6098567", "0.608949", "0.60889053", "0.60807997", "0.6075578", "0.60739285", "0.60689557", "0.60689074", "0.60529596", "0.6047003", "0.6036175", "0.6036175", "0.60353076", "0.6028083", "0.6026514", "0.60262996", "0.602028", "0.60061544", "0.6004837", "0.5999588", "0.5995959", "0.59910905", "0.5985314", "0.5982308", "0.5973571", "0.5967936", "0.59673434", "0.5966534", "0.5957761" ]
0.0
-1
define what happens when the measure is run
def run(model, runner, user_arguments) super(model, runner, user_arguments) # use the built-in error checking if !runner.validateUserArguments(arguments(model), user_arguments) return false end model.getSurfaces.each do |surface| # vertices are in space coordinates vertices = surface.vertices # site vertices are the vertices in site coordinates site_transformation = surface.space.get.siteTransformation site_vertices = site_transformation*vertices # face vertices are the vertices in face coordinates face_transformation = OpenStudio::Transformation.alignFace(vertices) face_vertices = face_transformation.inverse*vertices # put the point 0,0,0 in face coordiantes back into space coordinates face_origin = face_transformation*OpenStudio::Point3d.new(0,0,0) runner.registerInfo("Surface #{surface.name}<br/><span style='font-family:courier new;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vertices = #{print_vertices(vertices)}<br/>&nbsp;site_vertices = #{print_vertices(site_vertices)}<br/>&nbsp;face_vertices = #{print_vertices(face_vertices)}<br/>&nbsp;&nbsp;&nbsp;face_origin = [#{print_vertex(face_origin)}]</span>") end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def measure; end", "def measure=(_arg0); end", "def measure\n\t\t1\n\tend", "def measure(*args, &b)\n end", "def communicate_measure_result(_ = nil, _ = nil); end", "def communicate_measure_result(_ = nil, _ = nil); end", "def called\n self.measurement.called\n end", "def measure\n start = Time.now\n yield\n Time.now - start\n end", "def measure\n start = Time.now\n yield\n Time.now - start\n end", "def measure\n Measure.new(1, self)\n end", "def measurement(n)\n @options[:before_hook].call(n)\n measure = measure(n, &@options[:fn])\n @options[:after_hook].call(n)\n measure\n end", "def measure\n Measure.new(@counter+=1)\n end", "def communicate_measure_result(_ = nil, _ = nil)\r\n end", "def benchmark\nend", "def calculated; end", "def setup_metrics\n end", "def setup_metrics\n end", "def setup_metrics\n end", "def run()\n\t\tputs \"#{@name} ran for #{@meters} meters in #{self.getTimeLapse} seconds\"\n\t\t# chiama funzione per stampare quante volte ha respirato\n\t\tself.breathe\n\tend", "def runs; end", "def statistics; end", "def medical_use; end", "def measure\n start_real = System.monotonic_time\n start_cpu = System.cpu_time\n retval = yield\n\n real_time = System.monotonic_time - start_real\n cpu_time = System.cpu_time - start_cpu\n\n @real_time += real_time\n @cpu_time += cpu_time\n @call_count += 1\n\n if call_measurement_enabled? && above_threshold?\n self.class.call_duration_histogram.observe(@transaction.labels.merge(labels), real_time / 1000.0)\n end\n\n retval\n end", "def stats; end", "def stats; end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n\n \n \n # Check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n # Find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n\n # Make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n # Copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n new_sch.setName(\"#{new_sch.name.get} with occ sensor\")\n # Reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n end\n \n # Replace the old schedules with the new, reduced schedules\n spaces_sensors_added_to = []\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n \n # Report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the building.\")\n return true\n end \n \n # Report final condition\n runner.registerFinalCondition(\"Added occupancy sensors to #{num_sensors_added} spaces in the building.\")\n\n return true\n\n end", "def run\n\t\t\tsummary\n\t\tend", "def quick_stats\n\tend", "def stats\n \n end", "def benchmark(reporter); end", "def stats\n end", "def stats\n end", "def measure(name, &block)\n if self.running? name\n yield\n else\n result = nil\n self.results[name] ||= 0\n self.running << name\n self.results[name] += Benchmark.measure{result = yield}.real\n self.running.delete(name)\n result\n end\n end", "def measure\n start_real = System.monotonic_time\n start_cpu = System.cpu_time\n retval = yield\n\n real_time = System.monotonic_time - start_real\n cpu_time = System.cpu_time - start_cpu\n\n @real_time += real_time\n @cpu_time += cpu_time\n @call_count += 1\n\n if above_threshold?\n self.class.gitlab_method_call_duration_seconds.observe(@transaction.labels.merge(labels), real_time)\n end\n\n retval\n end", "def measure_code(model,runner)\n measure_folder = \"#{File.dirname(__FILE__)}/\"\n baseline_spreadsheet = \"#{File.dirname(__FILE__)}/baseline.csv\"\n #Note: place output folder locally to run faster! (e.g. your C drive)\n output_folder = \"#{File.dirname(__FILE__)}/tests/output\"\n create_models = true\n simulate_models = true\n create_annual_outputs = true\n create_hourly_outputs = true\n #This creates the measures object and collects all the csv information for the\n # measure_id variant.\n csv_measures = BTAP::Measures::CSV_OS_Measures.new(\n baseline_spreadsheet,\n measure_folder#script root folder where all the csv relative paths are used.\n )\n csv_measures.create_cold_lake_vintages(output_folder) unless create_models == false\n BTAP::SimManager::simulate_all_files_in_folder(output_folder) unless simulate_models == false\n BTAP::Reporting::get_all_annual_results_from_runmanger(output_folder) unless create_annual_outputs == false\n #convert eso to csv then create terminus file.\n BTAP::FileIO::convert_all_eso_to_csv(output_folder, output_folder).each {|csvfile| BTAP::FileIO::terminus_hourly_output(csvfile)} unless create_hourly_outputs == false\n\n end", "def cpu_metrics\n super\n end", "def instrument; end", "def profiler; end", "def profiler; end", "def setup\n\t\n # create an instance of the measure\n @measure = VentilationQAQC.new\n \n #create an instance of the runner\n @runner = OpenStudio::Ruleset::OSRunner.new\t\n\t\n # get arguments \n @arguments = @measure.arguments()\n\n # make argument map\n make_argument_map\n\t\n # Make an empty model\n @model = OpenStudio::Model::Model.new\n\[email protected](@model)\n\t\n\t# Create a fake sql file - our measure will crash if @runner has no sql file set.\n\t# We don't get data from this file because we get data from our patched SqlFile class instead (see above)\n\tsqlFile = OpenStudio::SqlFile.new(OpenStudio::Path.new(sqlPath))\n\[email protected](OpenStudio::Path.new(sqlPath))\n\t\n\t$serieses[\"Zone Mechanical Ventilation Mass Flow Rate|ZONE1\"] = OpenStudio::TimeSeries.new(OpenStudio::Date.new, OpenStudio::Time.new(1.0), (0..364).to_a.to_vector, \"m^3/s\")\n end", "def monitor(*args, &bl)\n result = nil\n took = Benchmark.realtime {\n result = bl.call\n }\n Tools.info(args, op_took: took)\n result\n end", "def measure_code(model,runner)\n ################ Start Measure code here ################################\n \n #Check weather directory Weather File\n unless (Pathname.new @lib_directory).absolute?\n @lib_directory = File.expand_path(File.join(File.dirname(__FILE__), @lib_directory))\n end\n lib_file = File.join(@lib_directory, @lib_file_name)\n if File.exists?(lib_file) and @lib_file_name.downcase.include? \".osm\"\n BTAP::runner_register(\"Info\",\"#{@lib_file_name} Found!.\", runner)\n else\n BTAP::runner_register(\"Error\",\"#{lib_file} does not exist or is not an .osm file.\", runner)\n return false\n end\n \n #load model and test.\n construction_set = BTAP::Resources::Envelope::ConstructionSets::get_construction_set_from_library( lib_file, @construction_set_name )\n #Set Construction Set.\n unless model.building.get.setDefaultConstructionSet( construction_set.clone( model ).to_DefaultConstructionSet.get )\n BTAP::runner_register(\"Error\",\"Could not set Default Construction #{@construction_set_name} \", runner)\n return false\n end\n BTAP::runner_register(\"FinalCondition\",\"Default Construction set to #{@construction_set_name} from #{lib_file}\",runner)\n ##########################################################################\n return true\n end", "def run(workspace, runner, user_arguments)\n super(workspace, runner, user_arguments)\n\n # use the built-in error checking \n if !runner.validateUserArguments(arguments(workspace), user_arguments)\n return false\n end\n \n # Report that this is an anti-measure\n runner.registerValue('anti_measure',true) \n \n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n\t# Initialize counter variables\n\tno_economizer = 0\n\tfixed_dry_bulb = 0\n\tdifferential_dry_bulb = 0\t\n\tfixed_enthalpy = 0\n\tdifferential_enthalpy = 0\n\tfixed_dew_point_and_dry_bulb = 0\n\telectronic_enthalpy = 0\n\tdifferential_dry_bulb_and_enthalpy = 0\n\t\n\t# Retrieve all Controller:Outdoor air objects in the idf \t\n\toa_controllers = workspace.getObjectsByType(\"Controller:OutdoorAir\".to_IddObjectType)\n\t\n\t# Get the names of each Controller:Outdoor Air object\n\toa_controllers.each do |oa_controller|\n\n\t\toa_controller_name = oa_controller.getString(0).to_s #(0) is field Name\n\t\toa_controller_economizer_control_type = oa_controller.getString(7).to_s #(7) is field Economizer Control Type\n\t\n\t\t# test for presence No economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"NoEconomizer\" # or empty\n\t\t\trunner.registerInfo(\"The Controller:Outdoor air object named #{oa_controller_name} has a disabled airside economizer. Economizer sensor faults will not be added.\")\n\t\t\tno_economizer = no_economizer + 1\n\t\tend\n\t\t\n\t\t# test for presence of differential dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"DifferentialDryBulb\"\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir \n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\tdifferential_dry_bulb = differential_dry_bulb + 1\n\t\t\t# info message\n\t\t\trunner.registerInfo(\"To model dry bulb sensor drift, a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg F has been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\t\n\n\t\tend # OA Controller Type DifferentialDryBulb\n\n\t\t# test for presence of fixed dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"FixedDryBulb\"\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\trunner.registerInfo(\"To model dry bulb sensor drift, a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg F has been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_dry_bulb = fixed_dry_bulb + 1\n\t\t\t\n\t\tend # OA Controller Type = FixedDryBulb \t\t\n\t\t\n\t\t# test for presence of fixed enthalpy economizer controller setting \t\t\t\t\n\t\tif oa_controller_economizer_control_type == \"FixedEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\twworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_enthalpy = fixed_enthalpy + 1\n\t\tend # OA Controller Type = FixedEnthalpy \n\t\t\n\t\t# test for presence of differential enthalpy economizer controller setting \t\t\n\t\tif oa_controller_economizer_control_type == \"DifferentialEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tdifferential_enthalpy = differential_enthalpy + 1\n\t\t\t\n\t\tend # OA Controller Type =\"Differential Enthalpy\"\t\t\n\t\t\n\t\n\t\t# test for presence of electronic enthalpy economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"ElectronicEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model enthalpy sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\telectronic_enthalpy = electronic_enthalpy + 1\n\n\t\tend # OA Controller Type = \"ElectronicEnthalpy\" \t\t\n\t\t\n\t\t# test for presence of fixed dew point and dry bulb economizer controller setting \n\t\tif oa_controller_economizer_control_type == \"FixedDewPointAndDryBulb\" \n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model both enthalpy and dry bulb sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb and a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tfixed_dew_point_and_dry_bulb = fixed_dew_point_and_dry_bulb + 1\n\n\t\tend # OA Controller Type = \"FixedDewPointAndDryBulb\" \n\t\n\t\t# test for presence of differential dry bulb and enthalpy economizer controller setting \t\t\n\t\tif oa_controller_economizer_control_type == \"DifferentialDryBulbAndEnthalpy\"\n\t\t\t# Initialze array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t5; \t\t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\n\t\t\t# Create IDF object text for FaultModel:EnthalpySensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:EnthalpySensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Enthalpy Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-5; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\n\t\t\t# Initialize array to hold new IDF objects\n\t\t\tstring_object = []\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:OutdoorAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:OutdoorAir,\n\t\t\t\t#{oa_controller_name}_Outdoor Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\t\t\t\t\t\t\n\t\t\t# Create IDF object text for FaultModel:TemperatureSensorOffset:ReturnAir\n\t\t\tstring_object = \"\n\t\t\t\tFaultModel:TemperatureSensorOffset:ReturnAir,\n\t\t\t\t#{oa_controller_name}_Return Air Temp Sensor Bias, !- Name\n\t\t\t\tAlways On Discrete, \t\t\t\t\t\t\t!- Availability Schedule Name\n\t\t\t\t, \t\t\t\t\t\t\t\t\t\t\t\t!- Severity Schedule Name\n\t\t\t\tController:OutdoorAir, \t\t\t\t\t\t\t!- Controller Object Type\n\t\t\t\t#{oa_controller_name}, \t\t\t\t\t\t\t!- Controller Object Name\n\t\t\t\t-1.11; \t\t\t\t\t\t\t\t\t\t\t!- Temperature Sensor Offset \n\t\t\t\t\"\n\t\t\t# Add string object to workspace to create idf object\n\t\t\tidfObject = OpenStudio::IdfObject::load(string_object)\n\t\t\tobject = idfObject.get\n\t\t\tworkspace.addObject(object)\n\n\t\t\trunner.registerInfo(\"To model both enthalpy and dry bulb sensor drift, a FaultModel:EnthalpySensorOffset:ReturnAir object with an offset of -2 Btu/lb and a FaultModel:EnthalpySensorOffset:OutdoorAir object with an offset of +2 Btu/lb and a FaultModel:TemperatureSensorOffset:ReturnAir object with an offset of -2 deg F and a FaultModel:TemperatureSensorOffset:OutdoorAir object with an offset of +2 deg have been added to the #{oa_controller_economizer_control_type} controlled airside economizer associated with the Controller:Outdoor air object named #{oa_controller_name}. The fault availability is scheduled using the 'Always On Discrete' schedule.\")\n\t\t\tdifferential_dry_bulb_and_enthalpy = differential_dry_bulb_and_enthalpy + 1\n\t\tend # OA Controller Type \"DifferentialDryBulbAndEnthalpy\"\n\t\t\n\t\t\t\t\n\tend # end loop through oa controller objects\n\n\t# reporting when N/A condition is appropriate\n\tif fixed_dry_bulb +\tdifferential_dry_bulb + fixed_enthalpy + differential_enthalpy + fixed_dew_point_and_dry_bulb +\telectronic_enthalpy + differential_dry_bulb_and_enthalpy == 0\n\t\trunner.registerAsNotApplicable(\"Measure not applicable because the model contains no OutdoorAir:Controller objects with operable economizers.\")\n\tend \n\t\n\ttotal = fixed_dry_bulb + differential_dry_bulb + fixed_enthalpy + differential_enthalpy + fixed_dew_point_and_dry_bulb + electronic_enthalpy + differential_dry_bulb_and_enthalpy\n\t\n\t# reporting initial condition of model\n\trunner.registerInitialCondition(\"The measure started with #{total} Outdoor Air Controllers configured for operational airside economizers. #{no_economizer} Outdoor Air Controller had the Economizer Contrrol Type set to 'NoEconomizer'.\")\n\t# reporting final condition of model\n\trunner.registerFinalCondition(\"The measure finished by adding outdoor and return air temperature and enthalpy sensor faults to #{total} economizer configurations.\")\n \n return true\n \n end", "def calculation\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n # initialize variables\n affected_space_types = []\n affected_flag = false\n power_tot = 0\n power_tot_new = 0\n control_factor = 0.05 #90.1-2010 Table 9.6.2\n\n # standards space types\n affected_space_types << \"BreakRoom\"\n affected_space_types << \"Conference\"\n affected_space_types << \"Office\"\n affected_space_types << \"Restroom\"\n affected_space_types << \"Stair\"\n\n # get model objects\n space_types = model.getSpaceTypes\n\n # DO STUFF\n #TODO account for zone multipliers?\n space_types.each do |st|\n\n std_spc_typ = st.standardsSpaceType.to_s\n area = st.floorArea\n people = st.getNumberOfPeople(area)\n power = st.getLightingPower(area, people)\n power_tot += power\n\n #calcualte LPD\n lpd_area = power / area\n lpd_people = power / people\n\n affected_space_types.each do |ast|\n\n if ast == std_spc_typ\n\n #calculate adjustment and new power\n power_adj = power * control_factor\n power_new = power - power_adj\n\n lpd_area_new = power_new / area\n lpd_people_new = power_new / people\n\n #set new power\n if st.lightingPowerPerFloorArea.is_initialized\n\n runner.registerInfo(\"Adjusting interior lighting power for space type: #{st.name}\")\n st.setLightingPowerPerFloorArea(lpd_area_new)\n\n lpd_area_ip = OpenStudio.convert(lpd_area,\"ft^2\",\"m^2\").get\n lpd_area_new_ip = OpenStudio.convert(lpd_area_new,\"ft^2\",\"m^2\").get\n lpd_area_change = (1 - (lpd_area_new / lpd_area)) * 100\n\n runner.registerInfo(\"=> Initial interior lighting power = #{lpd_area_ip.round(2)} W/ft2\")\n runner.registerInfo(\"=> Final interior lighting power = #{lpd_area_new_ip.round(2)} W/ft2\")\n runner.registerInfo(\"=> Interior lighting power reduction = #{lpd_area_change.round(0)}%\")\n\n elsif st.lightingPowerPerPerson.is_initialized\n\n runner.registerInfo(\"Adjusting interior lighting power for space type: #{st.name}\")\n st.setLightingPowerPerPerson(lpd_people_new)\n\n lpd_people_change = (1 - (lpd_people_new / lpd_people)) * 100\n\n runner.registerInfo(\"=> Initial interior lighting power = #{lpd_people} W/person\")\n runner.registerInfo(\"=> Final interior lighting power = #{lpd_people_new} W/person\")\n runner.registerInfo(\"=> Interior lighting power reduction = #{lpd_people_change.round(0)}%\")\n\n else\n\n runner.registerWarning(\"Lighting power is specified using Lighting Level (W) for affected space type: #{st.name}\")\n\n end #set new power\n\n affected_flag = true\n\n end\n\n end #affected space types\n\n # calculate new total lighting power\n power = st.getLightingPower(area, people)\n power_tot_new += power\n\n end #space types\n\n # report not applicable\n if affected_flag == false\n runner.registerAsNotApplicable(\"No affected space types found\")\n end\n\n # report initial condition\n runner.registerInitialCondition(\"Total interior lighting power = #{power_tot.round(0)} W\")\n\n # report final condition\n runner.registerFinalCondition(\"Total interior lighting power = #{power_tot_new.round(0)} W\")\n\n return true\n\n end", "def monitor; end", "def measure key,value\n @context= {}\n @path = \"#{key}\" \n @context[:callcount] = 1\n @context[:firsttimestampoffset] = Time.now.to_f*1000 - value\n @context[:name] = @path\n @context[:responsetime] = value\n @context_list << @context\n end", "def total_time=(_arg0); end", "def run(workspace, runner, user_arguments)\n super(workspace, runner, user_arguments)\n\n #use the built-in error checking \n if not runner.validateUserArguments(arguments(workspace), user_arguments)\n return false\n end\n \n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n require 'json'\n \n # Get the last openstudio model\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError(\"Could not load last OpenStudio model, cannot apply measure.\")\n return false\n end\n model = model.get\n \n results = {}\n \n #get all DX coils in model\n dx_single = workspace.getObjectsByType(\"Coil:Cooling:DX:SingleSpeed\".to_IddObjectType)\n dx_two = workspace.getObjectsByType(\"Coil:Cooling:DX:TwoSpeed\".to_IddObjectType)\n \n dx_single.each do |dx|\n dx_name = {}\n coil_name = dx.getString(0).get\n runner.registerInfo(\"DX coil: #{coil_name} Initial COP: #{dx.getDouble(4).get}\")\n dx.setDouble(4,7.62)\n runner.registerInfo(\"DX coil: #{coil_name} Final COP: #{dx.getDouble(4).get}\")\n dx_name[:dxname] = \"#{coil_name}\"\n results[\"#{coil_name}\"] = dx_name\n end\n\n dx_two.each do |dx|\n dx_name = {}\n coil_name = dx.getString(0).get\n runner.registerInfo(\"DX coil: #{coil_name} Initial High COP: #{dx.getDouble(4).get}, Initial Low COP: #{dx.getDouble(16).get}\")\n dx.setDouble(4,7.62)\n dx.setDouble(16,7.62)\n runner.registerInfo(\"DX coil: #{coil_name} Final High COP: #{dx.getDouble(4).get}, Final Low COP: #{dx.getDouble(16).get}\")\n dx_name[:dxname] = \"#{coil_name}\"\n results[\"#{coil_name}\"] = dx_name\n end\n \n if results.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\n end\n \n #save airloop parsing results to ems_results.json\n runner.registerInfo(\"Saving ems_results.json\")\n FileUtils.mkdir_p(File.dirname(\"ems_results.json\")) unless Dir.exist?(File.dirname(\"ems_results.json\"))\n File.open(\"ems_results.json\", 'w') {|f| f << JSON.pretty_generate(results)}\n \n if results.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\n #save blank ems_membrane_heat_pump_cooling_only.ems file so Eplus measure does not crash\n ems_string = \"\"\n runner.registerInfo(\"Saving blank ems_membrane_heat_pump_cooling_only file\")\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\n f.write(ems_string)\n end\n return true\n end\n \n timeStep = model.getTimestep.numberOfTimestepsPerHour\n \n runner.registerInfo(\"Making EMS string for Membrane Heat Pump Cooling Only\")\n #start making the EMS code\n ems_string = \"\" #clear out the ems_string\n ems_string << \"\\n\" \n ems_string << \"Output:Variable,*,Cooling Coil Sensible Cooling Energy,timestep; !- HVAC Sum [J]\" + \"\\n\"\n ems_string << \"\\n\" \n \n results.each_with_index do |(key, value), i| \n ems_string << \"EnergyManagementSystem:Sensor,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}SensibleClgJ,\" + \"\\n\"\n ems_string << \" #{value[:dxname]},\" + \"\\n\"\n ems_string << \" Cooling Coil Sensible Cooling Energy;\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"WaterUse:Equipment,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUse, !- Name\" + \"\\n\"\n ems_string << \" Membrane HP Cooling, !- End-Use Subcategory\" + \"\\n\"\n ems_string << \" 0.003155, !- Peak Flow Rate {m3/s} = 3000 gal/hr\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule; !- Flow Rate Fraction Schedule Name\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"Schedule:Constant,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule, !- Name\" + \"\\n\"\n ems_string << \" , !- Schedule Type Limits Name\" + \"\\n\"\n ems_string << \" 1; !- Hourly Value\" + \"\\n\"\n ems_string << \"\\n\" \n ems_string << \"EnergyManagementSystem:Actuator,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseCtrl,\" + \"\\n\"\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule,\" + \"\\n\"\n ems_string << \" Schedule:Constant,\" + \"\\n\"\n ems_string << \" Schedule Value;\" + \"\\n\"\n ems_string << \"\\n\" \n end\n ems_string << \"EnergyManagementSystem:ProgramCallingManager,\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgramControl, !- Name\" + \"\\n\"\n ems_string << \" AfterPredictorBeforeHVACManagers, !- EnergyPlus Model Calling Point\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgram; !- Program Name 1\" + \"\\n\"\n ems_string << \"\\n\"\n ems_string << \"EnergyManagementSystem:Program,\" + \"\\n\"\n ems_string << \" MembraneHPWaterUseProgram, !- Name\" + \"\\n\"\n ems_string << \" SET TimeStepsPerHr = #{timeStep}\" + \"\\n\"\n results.each_with_index do |(key, value), i|\n ems_string << \" SET MembraneHP#{i+1}SensibleClgTonHr = MembraneHP#{i+1}SensibleClgJ * 0.0000007898,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGal = MembraneHP#{i+1}SensibleClgTonHr * 3.0,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGalPerHr = MembraneHP#{i+1}SensibleWtrGal * TimeStepsPerHr,\" + \"\\n\"\n ems_string << \" SET MembraneHP#{i+1}WaterUseCtrl = MembraneHP#{i+1}SensibleWtrGalPerHr / 3000.0,\" + \"\\n\"\n end \n ems_string << \" SET UnusedLine = 0;\" + \"\\n\"\n \n #save EMS snippet\n runner.registerInfo(\"Saving ems_membrane_heat_pump_cooling_only file\")\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\n f.write(ems_string)\n end\n \n #unique initial conditions based on\n runner.registerInitialCondition(\"The building has #{results.size} DX coils for which this measure is applicable.\")\n\n #reporting final condition of model\n runner.registerFinalCondition(\"The efficiency of the following coils was increased to SEER 26 to reflect the replacement of these coils with membrane heatpumps: #{results.keys}\")\n \n ems_path = '../MembraneHeatPumpCoolingOnly/ems_membrane_heat_pump_cooling_only.ems'\n json_path = '../MembraneHeatPumpCoolingOnly/ems_results.json'\n if File.exist? ems_path\n ems_string = File.read(ems_path)\n if File.exist? json_path\n json = JSON.parse(File.read(json_path))\n end\n else\n ems_path2 = Dir.glob('../../**/ems_membrane_heat_pump_cooling_only.ems')\n ems_path1 = ems_path2[0]\n json_path2 = Dir.glob('../../**/ems_results.json')\n json_path1 = json_path2[0]\n if ems_path2.size > 1\n runner.registerWarning(\"more than one ems_membrane_heat_pump_cooling_only.ems file found. Using first one found.\")\n end\n if !ems_path1.nil? \n if File.exist? ems_path1\n ems_string = File.read(ems_path1)\n if File.exist? json_path1\n json = JSON.parse(File.read(json_path1))\n else\n runner.registerError(\"ems_results.json file not located\") \n end \n else\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\")\n end \n else\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\") \n end\n end\n if json.nil?\n runner.registerError(\"ems_results.json file not located\")\n return false\n end\n \n if json.empty?\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\n return true\n end\n \n idf_file = OpenStudio::IdfFile::load(ems_string, 'EnergyPlus'.to_IddFileType).get\n runner.registerInfo(\"Adding EMS code to workspace\")\n workspace.addObjects(idf_file.objects)\n \n return true\n\n end", "def apply_measure_to_model(test_name, args, model_name = nil, result_value = 'Success', warnings_count = 0, info_count = nil)\n # create an instance of the measure\n measure = ChangeBuildingLocation.new\n\n # create an instance of a runner with OSW\n osw_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/test.osw')\n osw = OpenStudio::WorkflowJSON.load(osw_path).get\n runner = OpenStudio::Measure::OSRunner.new(osw)\n\n # get model\n if model_name.nil?\n # make an empty model\n model = OpenStudio::Model::Model.new\n else\n # load the test model\n translator = OpenStudio::OSVersion::VersionTranslator.new\n path = OpenStudio::Path.new(File.dirname(__FILE__) + '/' + model_name)\n model = translator.loadModel(path)\n assert(!model.empty?)\n model = model.get\n end\n\n # get arguments\n arguments = measure.arguments(model)\n argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)\n\n # populate argument with specified hash value if specified\n arguments.each do |arg|\n temp_arg_var = arg.clone\n if args.key?(arg.name)\n assert(temp_arg_var.setValue(args[arg.name]))\n end\n argument_map[arg.name] = temp_arg_var\n end\n\n # temporarily change directory to the run directory and run the measure (because of sizing run)\n start_dir = Dir.pwd\n begin\n unless Dir.exist?(run_dir(test_name))\n Dir.mkdir(run_dir(test_name))\n end\n Dir.chdir(run_dir(test_name))\n\n # run the measure\n measure.run(model, runner, argument_map)\n result = runner.result\n ensure\n Dir.chdir(start_dir)\n\n # delete sizing run dir\n FileUtils.rm_rf(run_dir(test_name))\n end\n\n # show the output\n puts \"measure results for #{test_name}\"\n show_output(result)\n\n # assert that it ran correctly\n if result_value.nil? then result_value = 'Success' end\n assert_equal(result_value, result.value.valueName)\n\n # check count of warning and info messages\n unless info_count.nil? then assert(result.info.size == info_count) end\n unless warnings_count.nil? then assert(result.warnings.size == warnings_count) end\n\n # if 'Fail' passed in make sure at least one error message (while not typical there may be more than one message)\n if result_value == 'Fail' then assert(result.errors.size >= 1) end\n\n # save the model to test output directory\n output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + \"/output/#{test_name}_test_output.osm\")\n model.save(output_file_path, true)\n end", "def measure_code(model,runner)\n ################ Start Measure code here ################################\n # Argument will be passed as instance variable. So if your argument was height, your can access it using @height. \n\n # report initial condition\n site = model.getSite\n initial_design_days = model.getDesignDays\n if site.weatherFile.is_initialized\n weather = site.weatherFile.get\n runner.registerInitialCondition(\"The initial weather file path was '#{weather.path.get}' and the model had #{initial_design_days.size} design days.\")\n else\n runner.registerInitialCondition(\"The initial weather file has not been set and the model had #{initial_design_days.size} design days.\")\n end\n\n\n #Check form weather directory Weather File\n unless (Pathname.new @weather_directory).absolute?\n @weather_directory = File.expand_path(File.join(File.dirname(__FILE__), @weather_directory))\n end\n weather_file = File.join(@weather_directory, @weather_file_name)\n if File.exists?(weather_file) and @weather_file_name.downcase.include? \".epw\"\n BTAP::runner_register(\"Info\", \"The epw weather file #{weather_file} was found!\", runner)\n else\n BTAP::runner_register(\"Error\",\"'#{weather_file}' does not exist or is not an .epw file.\", runner)\n return false\n end\n\n begin\n weather = BTAP::Environment::WeatherFile.new(weather_file)\n #Set Weather file to model.\n weather.set_weather_file(model)\n #Store information about this run in the runner for output. This will be in the csv and R dumps.\n runner.registerValue( 'city',weather.city )\n runner.registerValue( 'state_province_region ',weather.state_province_region )\n runner.registerValue( 'country',weather.country )\n runner.registerValue( 'hdd18',weather.hdd18 )\n runner.registerValue( 'cdd18',weather.cdd18 )\n runner.registerValue( 'necb_climate_zone',BTAP::Compliance::NECB2011::get_climate_zone_name(weather.hdd18).to_s)\n runner.registerFinalCondition( \"Model ended with weatherfile of #{model.getSite.weatherFile.get.path.get}\" )\n rescue\n BTAP::runner_register(\"Error\",\"'#{weather_file}' could not be loaded into model.\", runner)\n\n return false\n end\n BTAP::runner_register(\"FinalCondition\",\"Weather file set to #{weather_file}\",runner)\n return true\n end", "def run(workspace, runner, user_arguments)\r\n super(workspace, runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(workspace), user_arguments)\r\n return false\r\n end\r\n \r\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\r\n if run_measure == 0\r\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\r\n return true \r\n end\r\n \r\n require 'json'\r\n \r\n # Get the last openstudio model\r\n model = runner.lastOpenStudioModel\r\n if model.empty?\r\n runner.registerError(\"Could not load last OpenStudio model, cannot apply measure.\")\r\n return false\r\n end\r\n model = model.get\r\n \r\n results = {}\r\n #get all DX coils in model\r\n dx_single = model.getCoilCoolingDXSingleSpeeds \r\n dx_two = model.getCoilCoolingDXTwoSpeeds\r\n \r\n if !dx_single.empty?\r\n dx_single.each do |dx|\r\n dx_name = {}\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP.get}\")\r\n dx.setRatedCOP(OpenStudio::OptionalDouble.new(7.62))\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP.get}\")\r\n dx_name[:dxname] = \"#{dx.name.get}\"\r\n results[\"#{dx.name.get}\"] = dx_name\r\n end\r\n end\r\n if !dx_two.empty?\r\n dx_two.each do |dx|\r\n dx_name = {}\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial High COP: #{dx.ratedHighSpeedCOP.get} Low COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx.setRatedHighSpeedCOP(7.62)\r\n dx.setRatedLowSpeedCOP(7.62)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final High COP: #{dx.ratedHighSpeedCOP.get} Final COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx_name[:dxname] = \"#{dx.name.get}\"\r\n results[\"#{dx.name.get}\"] = dx_name\r\n end\r\n end\r\n \r\n if results.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n end\r\n \r\n #save airloop parsing results to ems_results.json\r\n runner.registerInfo(\"Saving ems_results.json\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_results.json\")) unless Dir.exist?(File.dirname(\"ems_results.json\"))\r\n File.open(\"ems_results.json\", 'w') {|f| f << JSON.pretty_generate(results)}\r\n \r\n if results.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n #save blank ems_membrane_heat_pump_cooling_only.ems file so Eplus measure does not crash\r\n ems_string = \"\"\r\n runner.registerInfo(\"Saving blank ems_membrane_heat_pump_cooling_only file\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\r\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\r\n f.write(ems_string)\r\n end\r\n return true\r\n end\r\n \r\n timeStep = model.getTimestep.numberOfTimestepsPerHour\r\n \r\n runner.registerInfo(\"Making EMS string for Membrane Heat Pump Cooling Only\")\r\n #start making the EMS code\r\n ems_string = \"\" #clear out the ems_string\r\n ems_string << \"\\n\" \r\n ems_string << \"Output:Variable,*,Cooling Coil Sensible Cooling Energy,timestep; !- HVAC Sum [J]\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n \r\n results.each_with_index do |(key, value), i| \r\n ems_string << \"EnergyManagementSystem:Sensor,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}SensibleClgJ,\" + \"\\n\"\r\n ems_string << \" #{value[:dxname]},\" + \"\\n\"\r\n ems_string << \" Cooling Coil Sensible Cooling Energy;\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"WaterUse:Equipment,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUse, !- Name\" + \"\\n\"\r\n ems_string << \" Membrane HP Cooling, !- End-Use Subcategory\" + \"\\n\"\r\n ems_string << \" 0.003155, !- Peak Flow Rate {m3/s} = 3000 gal/hr\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule; !- Flow Rate Fraction Schedule Name\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"Schedule:Constant,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule, !- Name\" + \"\\n\"\r\n ems_string << \" , !- Schedule Type Limits Name\" + \"\\n\"\r\n ems_string << \" 1; !- Hourly Value\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n ems_string << \"EnergyManagementSystem:Actuator,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseCtrl,\" + \"\\n\"\r\n ems_string << \" MembraneHP#{i+1}WaterUseSchedule,\" + \"\\n\"\r\n ems_string << \" Schedule:Constant,\" + \"\\n\"\r\n ems_string << \" Schedule Value;\" + \"\\n\"\r\n ems_string << \"\\n\" \r\n end\r\n ems_string << \"EnergyManagementSystem:ProgramCallingManager,\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgramControl, !- Name\" + \"\\n\"\r\n ems_string << \" AfterPredictorBeforeHVACManagers, !- EnergyPlus Model Calling Point\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgram; !- Program Name 1\" + \"\\n\"\r\n ems_string << \"\\n\"\r\n ems_string << \"EnergyManagementSystem:Program,\" + \"\\n\"\r\n ems_string << \" MembraneHPWaterUseProgram, !- Name\" + \"\\n\"\r\n ems_string << \" SET TimeStepsPerHr = #{timeStep}\" + \"\\n\"\r\n results.each_with_index do |(key, value), i|\r\n ems_string << \" SET MembraneHP#{i+1}SensibleClgTonHr = MembraneHP#{i+1}SensibleClgJ * 0.0000007898,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGal = MembraneHP#{i+1}SensibleClgTonHr * 3.0,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}SensibleWtrGalPerHr = MembraneHP#{i+1}SensibleWtrGal * TimeStepsPerHr,\" + \"\\n\"\r\n ems_string << \" SET MembraneHP#{i+1}WaterUseCtrl = MembraneHP#{i+1}SensibleWtrGalPerHr / 3000.0,\" + \"\\n\"\r\n end \r\n ems_string << \" SET UnusedLine = 0;\" + \"\\n\"\r\n \r\n #save EMS snippet\r\n runner.registerInfo(\"Saving ems_membrane_heat_pump_cooling_only file\")\r\n FileUtils.mkdir_p(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\")) unless Dir.exist?(File.dirname(\"ems_membrane_heat_pump_cooling_only.ems\"))\r\n File.open(\"ems_membrane_heat_pump_cooling_only.ems\", \"w\") do |f|\r\n f.write(ems_string)\r\n end\r\n \r\n #unique initial conditions based on\r\n runner.registerInitialCondition(\"The building has #{results.size} DX coils for which this measure is applicable.\")\r\n\r\n #reporting final condition of model\r\n runner.registerFinalCondition(\"The efficiency of the following coils was increased to SEER 26 to reflect the replacement of these coils with membrane heatpumps: #{results.keys}\")\r\n \r\n ems_path = '../MembraneHeatPumpCoolingOnlyEms/ems_membrane_heat_pump_cooling_only.ems'\r\n json_path = '../MembraneHeatPumpCoolingOnlyEms/ems_results.json'\r\n if File.exist? ems_path\r\n ems_string = File.read(ems_path)\r\n if File.exist? json_path\r\n json = JSON.parse(File.read(json_path))\r\n end\r\n else\r\n ems_path2 = Dir.glob('../../**/ems_membrane_heat_pump_cooling_only.ems')\r\n ems_path1 = ems_path2[0]\r\n json_path2 = Dir.glob('../../**/ems_results.json')\r\n json_path1 = json_path2[0]\r\n if ems_path2.size > 1\r\n runner.registerWarning(\"more than one ems_membrane_heat_pump_cooling_only.ems file found. Using first one found.\")\r\n end\r\n if !ems_path1.nil? \r\n if File.exist? ems_path1\r\n ems_string = File.read(ems_path1)\r\n if File.exist? json_path1\r\n json = JSON.parse(File.read(json_path1))\r\n else\r\n runner.registerError(\"ems_results.json file not located\") \r\n end \r\n else\r\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\")\r\n end \r\n else\r\n runner.registerError(\"ems_membrane_heat_pump_cooling_only.ems file not located\") \r\n end\r\n end\r\n if json.nil?\r\n runner.registerError(\"ems_results.json file not located\")\r\n return false\r\n end\r\n \r\n if json.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n return true\r\n end\r\n \r\n idf_file = OpenStudio::IdfFile::load(ems_string, 'EnergyPlus'.to_IddFileType).get\r\n runner.registerInfo(\"Adding EMS code to workspace\")\r\n workspace.addObjects(idf_file.objects)\r\n \r\n return true\r\n\r\n end", "def modeler_description\n return 'The measure performs the following functions: (1) IDs all chillers, (2) Locates their performance curves and outputs the data, (3) Adds reporting variables for chiller-related data.'\n end", "def build_timing; end", "def measure_gc\n return unless enabled?\n\n @raw_data << { fake: true }\n @total_time += 1.1\n\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # define if the measure should run to a specific time period or whole day\n apply_to_time = true\n\n # assign the user inputs to variables\n object = runner.getOptionalWorkspaceObjectChoiceValue('space_type', user_arguments, model)\n single_space_type = runner.getDoubleArgumentValue('single_space_type', user_arguments)\n occupied_space_type = runner.getDoubleArgumentValue('occupied_space_type', user_arguments)\n unoccupied_space_type = runner.getDoubleArgumentValue('unoccupied_space_type', user_arguments)\n starttime_winter2 = runner.getStringArgumentValue('starttime_winter2', user_arguments)\n endtime_winter2 = runner.getStringArgumentValue('endtime_winter2', user_arguments)\n starttime_winter1 = runner.getStringArgumentValue('starttime_winter1', user_arguments)\n endtime_winter1 = runner.getStringArgumentValue('endtime_winter1', user_arguments)\n starttime_summer = runner.getStringArgumentValue('starttime_summer', user_arguments)\n endtime_summer = runner.getStringArgumentValue('endtime_summer', user_arguments)\n auto_date = runner.getBoolArgumentValue('auto_date', user_arguments)\n alt_periods = runner.getBoolArgumentValue('alt_periods', user_arguments)\n demo_cost_initial_const=false\n\n winter_start_month1 = 1\n winter_end_month1 = 5\n summer_start_month = 6\n summer_end_month = 9\n winter_start_month2 = 10\n winter_end_month2 = 12\n\n######### GET CLIMATE ZONES ################\n if auto_date\n ashraeClimateZone = ''\n #climateZoneNUmber = ''\n climateZones = model.getClimateZones\n climateZones.climateZones.each do |climateZone|\n if climateZone.institution == 'ASHRAE'\n ashraeClimateZone = climateZone.value\n runner.registerInfo(\"Using ASHRAE Climate zone #{ashraeClimateZone}.\")\n end\n end\n\n if ashraeClimateZone == '' # should this be not applicable or error?\n runner.registerError(\"Please assign an ASHRAE Climate Zone to your model using the site tab in the OpenStudio application. The measure can't make AEDG recommendations without this information.\")\n return false # note - for this to work need to check for false in measure.rb and add return false there as well.\n # else\n # climateZoneNumber = ashraeClimateZone.split(//).first\n end\n # #runner.registerInfo(\"CLIMATE ZONE #{ashraeClimateZone}. Right now does not do anything.\")\n # if !['1', '2', '3', '4', '5', '6', '7', '8'].include? climateZoneNumber\n # runner.registerError('ASHRAE climate zone number is not within expected range of 1 to 8.')\n # return false # note - for this to work need to check for false in measure.rb and add return false there as well.\n # end\n\n if alt_periods\n if ashraeClimateZone == '3A'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4A'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5A'\n starttime_summer = '14:01:00'\n endtime_summer = '17:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n elsif ashraeClimateZone == '6A'\n starttime_summer = '13:01:00'\n endtime_summer = '16:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n end\n else\n if ashraeClimateZone == '2A'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '2B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '3A'\n starttime_summer = '19:01:00'\n endtime_summer = '22:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '3B'\n starttime_summer = '18:01:00'\n endtime_summer = '21:59:00'\n starttime_winter1 = '19:01:00'\n endtime_winter1 = '22:59:00'\n starttime_winter2 = '19:01:00'\n endtime_winter2 = '22:59:00'\n elsif ashraeClimateZone == '3C'\n starttime_summer = '19:01:00'\n endtime_summer = '22:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4A'\n starttime_summer = '12:01:00'\n endtime_summer = '15:59:00'\n starttime_winter1 = '16:01:00'\n endtime_winter1 = '19:59:00'\n starttime_winter2 = '16:01:00'\n endtime_winter2 = '19:59:00'\n elsif ashraeClimateZone == '4B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '4C'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5A'\n starttime_summer = '20:01:00'\n endtime_summer = '23:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '5C'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '6A'\n starttime_summer = '16:01:00'\n endtime_summer = '19:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n elsif ashraeClimateZone == '6B'\n starttime_summer = '17:01:00'\n endtime_summer = '20:59:00'\n starttime_winter1 = '17:01:00'\n endtime_winter1 = '20:59:00'\n starttime_winter2 = '17:01:00'\n endtime_winter2 = '20:59:00'\n elsif ashraeClimateZone == '7A'\n starttime_summer = '16:01:00'\n endtime_summer = '19:59:00'\n starttime_winter1 = '18:01:00'\n endtime_winter1 = '21:59:00'\n starttime_winter2 = '18:01:00'\n endtime_winter2 = '21:59:00'\n end\n end\n end \n\n # check the lighting power reduction percentages and for reasonableness\n if occupied_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif occupied_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (occupied_space_type < 1) && (occupied_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{occupied_space_type} percent is abnormally low.\")\n elsif occupied_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{occupied_space_type} percent is abnormally high.\")\n elsif occupied_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the equipment_power_reduction_percent and for reasonableness\n if unoccupied_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif unoccupied_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (unoccupied_space_type < 1) && (unoccupied_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{unoccupied_space_type} percent is abnormally low.\")\n elsif unoccupied_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{unoccupied_space_type} percent is abnormally high.\")\n elsif unoccupied_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the equipment_power_reduction_percent and for reasonableness\n if single_space_type > 100\n runner.registerError('Please Enter a Value less than or equal to 100 for the Electric Equipment Power Reduction Percentage.')\n return false\n elsif single_space_type == 0\n runner.registerInfo('No Electric Equipment power adjustment requested, but some life cycle costs may still be affected.')\n elsif (single_space_type < 1) && (single_space_type > -1)\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{single_space_type} percent is abnormally low.\")\n elsif single_space_type > 90\n runner.registerWarning(\"A Electric Equipment Power Reduction Percentage of #{single_space_type} percent is abnormally high.\")\n elsif single_space_type < 0\n runner.registerInfo('The requested value for Electric Equipment power reduction percentage was negative. This will result in an increase in Electric Equipment power.')\n end\n\n # check the time periods for reasonableness\n if (starttime_winter1.to_f > endtime_winter1.to_f) && (starttime_winter2.to_f > endtime_winter2.to_f) && (starttime_summer.to_f > endtime_summer.to_f)\n runner.registerError('The end time should be larger than the start time.')\n return false\n end\n\n # check the space_type for reasonableness\n space_type = nil\n if object.empty?\n handle = runner.getStringArgumentValue('space_type', user_arguments)\n if handle.empty?\n runner.registerError('No space type was chosen.')\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !object.get.to_SpaceType.empty?\n space_type = object.get.to_SpaceType.get\n elsif !object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError('Script Error - argument not showing up as space type or building.')\n return false\n end\n end\n\n\n ############################################\n\n # assign the time duration when DR strategy is applied, from shift_time1 to shift_time2, only applied when apply_to_time is ture\n shift_time1 = OpenStudio::Time.new(starttime_winter1)\n shift_time2 = OpenStudio::Time.new(endtime_winter1)\n shift_time3 = OpenStudio::Time.new(0, 24, 0, 0)\n shift_time4 = OpenStudio::Time.new(starttime_summer)\n shift_time5 = OpenStudio::Time.new(endtime_summer)\n shift_time6 = OpenStudio::Time.new(starttime_winter2)\n shift_time7 = OpenStudio::Time.new(endtime_winter2)\n \n \n # get space types in model\n if apply_to_building\n space_types = model.getSpaceTypes\n else\n space_types = []\n space_types << space_type # only run on a single space type\n end\n\n # make a hash of old defs and new equipments and luminaire defs\n cloned_equi_defs = {}\n # loop through space types\n space_types.each do |space_type|\n\n equi_set_schs = {}\n if apply_to_building # measure will be applied differently to space types, based on whether the space type is occupied\n if !space_type.people.empty?\n equipment_power_reduction_percent = 1 - (occupied_space_type/100)\n else\n equipment_power_reduction_percent = 1 - (unoccupied_space_type/100)\n end\n runner.registerInitialCondition(\"Equipment power will be reduced by #{occupied_space_type}% in occupied spaces, and reduced by #{unoccupied_space_type}% in unoccupied spaces\")\n\n else\n equipment_power_reduction_percent = 1 - (single_space_type/100) # measure will be applied evenly to all zones\n runner.registerInitialCondition(\"Equipment power will be reduced by #{single_space_type}% to '#{space_type.name}'.\")\n end\n\n space_type_equipments = space_type.electricEquipment\n space_type_equipments.each do |space_type_equipment|\n #clone of not already in hash\n equi_set_sch = space_type_equipment.schedule\n if !equi_set_sch.empty?\n # clone of not already in hash\n if equi_set_schs.key?(equi_set_sch.get.name.to_s)\n new_equi_set_sch = equi_set_schs[equi_set_sch.get.name.to_s]\n else\n new_equi_set_sch = equi_set_sch.get.clone(model)\n new_equi_set_sch = new_equi_set_sch.to_Schedule.get\n new_equi_set_sch_name = new_equi_set_sch.setName(\"#{new_equi_set_sch.name} adjusted #{equipment_power_reduction_percent}\")\n # add to the hash\n equi_set_schs[new_equi_set_sch.name.to_s] = new_equi_set_sch\n end\n # hook up clone to equipment\n \n if space_type_equipment.name.to_s != \"OfficeLarge Data Center Elec Equip\" && space_type_equipment.name.to_s != \"OfficeLarge Main Data Center Elec Equip\"\n space_type_equipment.setSchedule(new_equi_set_sch)\n runner.registerInfo(\"#{space_type_equipment.name} has a new electric equipment schedule\")\n end\n else\n runner.registerWarning(\"#{space_type.equipments.name} doesn't have a schedule.\")\n end\n end\n \n if apply_to_time\n runner.registerFinalCondition(\" equipment power is reduced from #{shift_time1} to #{shift_time2}.\")\n runner.registerFinalCondition(\" equipment power is reduced from #{shift_time4} to #{shift_time5} during special between month #{summer_start_month} and #{summer_end_month}\")\n else\n runner.registerFinalCondition(\" equipment power is reduced all day.\")\n end\n\n \n # make equipment schedule adjustments and rename.\n equi_set_schs.each do |k, v| # old name and new object for schedule\n if !v.to_ScheduleRuleset.empty?\n\n schedule = v.to_ScheduleRuleset.get\n default_rule = schedule.defaultDaySchedule\n rules = schedule.scheduleRules\n\n days_covered = Array.new(7, false)\n\n if rules.length > 0\n rules.each do |rule|\n summerStartMonth = OpenStudio::MonthOfYear.new(summer_start_month)\n summerEndMonth = OpenStudio::MonthOfYear.new(summer_end_month)\n summerStartDate = OpenStudio::Date.new(summerStartMonth, 1)\n summerEndDate = OpenStudio::Date.new(summerEndMonth, 30)\n \n summer_rule = rule.clone(model).to_ScheduleRule.get\n summer_rule.setStartDate(summerStartDate)\n summer_rule.setEndDate(summerEndDate)\n\n allDaysCovered(summer_rule, days_covered)\n\n cloned_day_summer = rule.daySchedule.clone(model)\n cloned_day_summer.setParent(summer_rule)\n\n summer_day = summer_rule.daySchedule\n day_time_vector = summer_day.times\n day_value_vector = summer_day.values\n summer_day.clearValues\n \n summer_day = createDaySchedule(summer_day, day_time_vector, day_value_vector, shift_time4, shift_time5, equipment_power_reduction_percent)\n \n ##############################################\n winterStartMonth1 = OpenStudio::MonthOfYear.new(winter_start_month1)\n winterEndMonth1 = OpenStudio::MonthOfYear.new(winter_end_month1)\n winterStartDate1 = OpenStudio::Date.new(winterStartMonth1, 1)\n winterEndDate1 = OpenStudio::Date.new(winterEndMonth1, 31)\n \n winter_rule1 = rule #rule.clone(model).to_ScheduleRule.get\n winter_rule1.setStartDate(winterStartDate1)\n winter_rule1.setEndDate(winterEndDate1)\n\n\n cloned_day_winter = rule.daySchedule.clone(model)\n cloned_day_winter.setParent(winter_rule1)\n\n winter_day1 = winter_rule1.daySchedule\n day_time_vector = winter_day1.times\n day_value_vector = winter_day1.values\n winter_day1.clearValues\n \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time6, shift_time7, equipment_power_reduction_percent)\n if shift_time1 != shift_time6 \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time1, shift_time2, equipment_power_reduction_percent)\n end\n ###################################################\n winterStartMonth2 = OpenStudio::MonthOfYear.new(winter_start_month2)\n winterEndMonth2 = OpenStudio::MonthOfYear.new(winter_end_month2)\n winterStartDate2 = OpenStudio::Date.new(winterStartMonth2, 1)\n winterEndDate2 = OpenStudio::Date.new(winterEndMonth2, 31)\n \n winter_rule2 = winter_rule1.clone(model).to_ScheduleRule.get\n winter_rule2.setStartDate(winterStartDate2)\n winter_rule2.setEndDate(winterEndDate2)\n \n cloned_day_winter2 = winter_day1.clone(model)\n cloned_day_winter2.setParent(winter_rule2)\n end\n end\n #runner.registerInfo(\"BEFORE #{days_covered}\")\n if days_covered.include?(false)\n summerStartMonth = OpenStudio::MonthOfYear.new(summer_start_month)\n summerEndMonth = OpenStudio::MonthOfYear.new(summer_end_month)\n summerStartDate = OpenStudio::Date.new(summerStartMonth, 1)\n summerEndDate = OpenStudio::Date.new(summerEndMonth, 30)\n \n summer_rule = OpenStudio::Model::ScheduleRule.new(schedule)\n summer_rule.setStartDate(summerStartDate)\n summer_rule.setEndDate(summerEndDate)\n coverSomeDays(summer_rule, days_covered)\n allDaysCovered(summer_rule, days_covered)\n\n cloned_day_summer = default_rule.clone(model)\n cloned_day_summer.setParent(summer_rule)\n\n summer_day = summer_rule.daySchedule\n day_time_vector = summer_day.times\n day_value_vector = summer_day.values\n summer_day.clearValues\n \n summer_day = createDaySchedule(summer_day, day_time_vector, day_value_vector, shift_time4, shift_time5, equipment_power_reduction_percent)\n \n ##############################################\n winterStartMonth1 = OpenStudio::MonthOfYear.new(winter_start_month1)\n winterEndMonth1 = OpenStudio::MonthOfYear.new(winter_end_month1)\n winterStartDate1 = OpenStudio::Date.new(winterStartMonth1, 1)\n winterEndDate1 = OpenStudio::Date.new(winterEndMonth1, 31)\n \n winter_rule1 = summer_rule.clone(model).to_ScheduleRule.get #OpenStudio::Model::ScheduleRule.new(schedule)\n winter_rule1.setStartDate(winterStartDate1)\n winter_rule1.setEndDate(winterEndDate1)\n\n #coverSomeDays(winter_rule1, days_covered)\n #allDaysCovered(summer_rule, days_covered)\n\n cloned_day_winter = default_rule.clone(model)\n cloned_day_winter.setParent(winter_rule1)\n\n winter_day1 = winter_rule1.daySchedule\n day_time_vector = winter_day1.times\n day_value_vector = winter_day1.values\n winter_day1.clearValues\n \n\n\n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time6, shift_time7, equipment_power_reduction_percent)\n if shift_time1 != shift_time6 \n winter_day1 = createDaySchedule(winter_day1, day_time_vector, day_value_vector, shift_time1, shift_time2, equipment_power_reduction_percent)\n end\n ###################################################\n winterStartMonth2 = OpenStudio::MonthOfYear.new(winter_start_month2)\n winterEndMonth2 = OpenStudio::MonthOfYear.new(winter_end_month2)\n winterStartDate2 = OpenStudio::Date.new(winterStartMonth2, 1)\n winterEndDate2 = OpenStudio::Date.new(winterEndMonth2, 31)\n \n winter_rule2 = winter_rule1.clone(model).to_ScheduleRule.get #OpenStudio::Model::ScheduleRule.new(schedule)\n winter_rule2.setStartDate(winterStartDate2)\n winter_rule2.setEndDate(winterEndDate2)\n \n cloned_day_winter2 = winter_day1.clone(model)\n cloned_day_winter2.setParent(winter_rule2)\n end\n #runner.registerInfo(\"AFTER Summer #{days_covered}\")\n else\n runner.registerWarning(\"Schedule '#{k}' isn't a ScheduleRuleset object and won't be altered by this measure.\")\n v.remove # remove un-used clone\n end\n end\n\n end\n return true\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assume the occ sensors will last the full analysis\n expected_life = 25\n \n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n material_and_installation_cost_per_space = runner.getDoubleArgumentValue(\"material_and_installation_cost_per_space\",user_arguments)\n\n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n #find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n if apply_to_building #apply to the whole building\n \n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n space_type.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n space.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n end\n end\n \n #make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n #TODO skip non-schedule-ruleset schedules\n \n #copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n #reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n #runner.registerInfo(\"***\")\n end\n \n #replace the old schedules with the new schedules\n spaces_sensors_added_to = []\n if apply_to_building #apply to the whole building\n runner.registerInfo(\"Adding occupancy sensors to whole building\")\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n runner.registerInfo(\"Adding occupancy sensors to space type '#{space_type.name}'\")\n space_type.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n runner.registerInfo(\"Adding occupancy sensors to space '#{space.name}\")\n space.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end \n end\n end \n \n #report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the specified areas of the building.\")\n return true\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has several areas where occupancy sensors could be used to reduce lighting energy by turning off the lights while no occupants are present.\") \n \n #add cost of adding occ sensors\n if material_and_installation_cost_per_space != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Add #{material_and_installation_cost_per_space} Occ Sensors to the Building\", model.getBuilding, material_and_installation_cost_per_space * num_sensors_added, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n else\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} #{space_type.name} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n end\n \n return true\n \n end", "def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\r\n if run_measure == 0\r\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\r\n return true \r\n end\r\n \r\n require 'json'\r\n \r\n results = {}\r\n dx_name = []\r\n #get all DX coils in model\r\n dx_single = model.getCoilCoolingDXSingleSpeeds \r\n dx_two = model.getCoilCoolingDXTwoSpeeds\r\n dx_heat = model.getCoilHeatingDXSingleSpeeds\r\n \r\n if !dx_single.empty?\r\n dx_single.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP.get}\")\r\n dx.setRatedCOP(OpenStudio::OptionalDouble.new(6.0))\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP.get}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n if !dx_two.empty?\r\n dx_two.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial High COP: #{dx.ratedHighSpeedCOP.get} Low COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx.setRatedHighSpeedCOP(6.0)\r\n dx.setRatedLowSpeedCOP(6.0)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final High COP: #{dx.ratedHighSpeedCOP.get} Final COP: #{dx.ratedLowSpeedCOP.get}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n if !dx_heat.empty?\r\n dx_heat.each do |dx|\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Initial COP: #{dx.ratedCOP}\")\r\n dx.setRatedCOP(6.0)\r\n runner.registerInfo(\"DX coil: #{dx.name.get} Final COP: #{dx.ratedCOP}\")\r\n dx_name << dx.name.get\r\n end\r\n end\r\n \r\n if dx_name.empty?\r\n runner.registerWarning(\"No DX coils are appropriate for this measure\")\r\n runner.registerAsNotApplicable(\"No DX coils are appropriate for this measure\")\r\n end\r\n \r\n #unique initial conditions based on\r\n runner.registerInitialCondition(\"The building has #{dx_name.size} DX coils for which this measure is applicable.\")\r\n\r\n #reporting final condition of model\r\n runner.registerFinalCondition(\"The COP of the following coils was increased to 6: #{dx_name}\")\r\n return true\r\n\r\n end", "def around_perform_stats(*args)\n start = Time.now\n yield\n time_taken = Time.now - start\n statsd.timing(\"duration:#{self}\", time_taken)\n statsd.increment(\"total_successful:#{self}\")\n statsd.increment(\"total_successful\")\n run_hooks(:duration, :duration, args) {|key| statsd.timing(key, time_taken)}\n end", "def defMeasurement(name,&block)\n mp = {:mp => name, :fields => []}\n @fields = []\n # call the block with ourserlves to process its 'defMetric' statements\n block.call(self) if block\n @fields.each { |f| mp[:fields] << f }\n define_measurement_point(mp)\n end", "def measure(heading)\n start_time = Time.now\n print heading\n result = yield\n end_time = Time.now - start_time\n puts \" (#{end_time} s)\"\n result\nend", "def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end", "def update\n if @clock1_measure.nil?\n discipline_freq\n else\n elapsed = @clock1.time - @clock1_measure.local_time\n discipline_freq if elapsed > @frequency_discipline_interval\n end\n if @clock2_measure.nil?\n discipline_phase\n else\n elapsed = @clock2.time - @clock2_measure.local_time\n discipline_phase if elapsed > @phase_discipline_interval\n end\n end", "def run_examination\n true\n end", "def record_measure(label)\n $logger.debug(\n tms = Benchmark.measure(label) do\n yield\n end.format(\"%n: %10.6rreal %10.6u user %10.6y sys\")\n )\nend", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n pct_red = runner.getDoubleArgumentValue(\"pct_red\",user_arguments)\n start_hr = runner.getDoubleArgumentValue(\"start_hr\",user_arguments)\n end_hr = runner.getDoubleArgumentValue(\"end_hr\",user_arguments)\n \n\n\n #check the fraction for reasonableness\n if not 0 <= pct_red and pct_red <= 100\n runner.registerError(\"Percent reduction value needs to be between 0 and 100.\")\n return false\n end\n\n #check start_hr for reasonableness and round to 15 minutes\n start_red_hr = nil\n start_red_min = nil\n if not 0 <= start_hr and start_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24\")\n return false\n else\n rounded_start_hr = ((start_hr*4).round)/4.0\n if not start_hr == rounded_start_hr\n runner.registerInfo(\"Start time rounded to nearest 15 minutes: #{rounded_start_hr}\")\n end\n start_red_hr = rounded_start_hr.truncate\n start_red_min = (rounded_start_hr - start_red_hr)*60\n start_red_min = start_red_min.to_i\n end\n\n #check end_hr for reasonableness and round to 15 minutes\n end_red_hr = nil\n end_red_min = nil \n if not 0 <= end_hr and end_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n elsif end_hr > end_hr\n runner.registerError(\"Please enter an end time later in the day than end time.\")\n return false\n else\n rounded_end_hr = ((end_hr*4).round)/4.0\n if not end_hr == rounded_end_hr\n runner.registerInfo(\"End time rounded to nearest 15 minutes: #{rounded_end_hr}\")\n end\n end_red_hr = rounded_end_hr.truncate\n end_red_min = (rounded_end_hr - end_red_hr)*60\n end_red_min = end_red_min.to_i\n end\n\n # Translate the percent reduction into a multiplier\n red_mult = pct_red/100\n\n # Get schedules from all lights.\n original_lights_schs = []\n model.getLightss.each do |lights|\n if lights.schedule.is_initialized\n lights_sch = lights.schedule.get\n original_lights_schs << lights_sch\n end\n end\n\n # loop through the unique list of lights schedules, cloning\n # and reducing schedule fraction during the specified time range.\n original_lights_schs_new_schs = {}\n original_lights_schs.uniq.each do |lights_sch|\n if lights_sch.to_ScheduleRuleset.is_initialized\n new_lights_sch = lights_sch.clone(model).to_ScheduleRuleset.get\n new_lights_sch.setName(\"#{lights_sch.name} with Solar Cogeneration and Daylighting\")\n original_lights_schs_new_schs[lights_sch] = new_lights_sch\n new_lights_sch = new_lights_sch.to_ScheduleRuleset.get\n \n # method to adjust the values in a day schedule by a \n # specified percentage during a range of hours.\n def reduce_schedule(day_sch, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n start_time = OpenStudio::Time.new(0, start_red_hr, start_red_min, 0)\n end_time = OpenStudio::Time.new(0, end_red_hr, end_red_min, 0)\n\n # Get the original values at the desired start and end times\n # and put points into the schedule at those times.\n day_sch.addValue(start_time, day_sch.getValue(start_time))\n day_sch.addValue(end_time, day_sch.getValue(end_time))\n \n # Store the original time/values then clear the schedule\n times = day_sch.times\n values = day_sch.values\n day_sch.clearValues\n\n # Modify the time/values and add back to the schedule\n for i in 0..(values.length - 1)\n if times[i] > start_time and times[i] <= end_time # Inside range\n day_sch.addValue(times[i], values[i] * red_mult)\n else\n day_sch.addValue(times[i], values[i])\n end\n end\n\n end #end reduce schedule\n\n # Reduce default day schedule\n if new_lights_sch.scheduleRules.size == 0\n runner.registerWarning(\"Schedule '#{new_lights_sch.name}' applies to all days. It has been treated as a Weekday schedule.\")\n end\n reduce_schedule(new_lights_sch.defaultDaySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n \n # Reduce all other schedule rules\n new_lights_sch.scheduleRules.each do |sch_rule|\n reduce_schedule(sch_rule.daySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n end\n \n end \n end #end of original_lights_schs.uniq.each do\n\n #loop through all lights instances, replacing old lights schedules with the reduced schedules\n model.getLightss.each do |lights|\n if lights.schedule.empty?\n runner.registerWarning(\"There was no schedule assigned for the lights object named '#{lights.name}. No schedule was added.'\")\n else\n old_lights_sch = lights.schedule.get\n lights.setSchedule(original_lights_schs_new_schs[old_lights_sch])\n runner.registerInfo(\"Schedule for the lights object named '#{lights.name}' was reduced to simulate the application of Solar Cogeneration and Daylighting.\")\n end\n end\n\n # NA if the model has no lights\n if model.getLightss.size == 0\n runner.registerNotAsApplicable(\"Not Applicable - There are no lights in the model.\")\n end\n\n # Reporting final condition of model\n runner.registerFinalCondition(\"#{original_lights_schs.uniq.size} schedule(s) were edited to reflect the addition of Solar Cogeneration and Daylighting to the building.\")\n \n return true\n\n end", "def benchmark!\n @benchmark = true\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n \n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n\n\t#initialize variables\n\ttz_count = 0\n\tclg_tstat_schedule = []\n\tthermal_zone_array = []\n\t\t\n\t# get the thermal zones and loop through them \n\tmodel.getThermalZones.each do |thermal_zone|\n\t\n\t\tthermal_zone_array << thermal_zone\n\t\t\n\t\t# test to see if thermal zone has a thermostat object assigned or is unconditioned. \n\t\tif thermal_zone.thermostatSetpointDualSetpoint.is_initialized\n\t\t\tzone_thermostat = thermal_zone.thermostatSetpointDualSetpoint.get\n\t\t\ttz_count += 1\n\t\t\t\n\t\t\tif zone_thermostat.coolingSetpointTemperatureSchedule.is_initialized\n\t\t\t\tclg_tstat_schedule = zone_thermostat.coolingSetpointTemperatureSchedule.get\n\t\t\t\t\n\t\t\t\t# clone the existing cooling T-stat schedule in case it is used somewhere else in the model\n\t\t\t\tcloned_clg_tstat_schedule = clg_tstat_schedule.clone\n\t\t\t\t@new_clg_tstat_schedule_name = (\"#{clg_tstat_schedule.name}+1.5F\")\n\t\t\t\n\t\t\t\tif cloned_clg_tstat_schedule.to_ScheduleRuleset.is_initialized\n\t\t\t\t\tschedule = cloned_clg_tstat_schedule.to_ScheduleRuleset.get\n\t\t\t\t\t# gather profiles of cloned schedule\n\t\t\t\t\tprofiles = []\n\t\t\t\t\tcooling_thermostat_array = []\n\t\t\t\t\tdefaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule\n\t\t\t\t\n\t\t\t\t\tprofiles << defaultProfile\n\t\t\t\t\trules = schedule.scheduleRules\n\t\t\t\t\n\t\t\t\t\trules.each do |rule|\n\t\t\t\t\t\tprofiles << rule.daySchedule\n\t\t\t\t\tend # end the do loop through the rulesetsdo\n\n\t\t\t\t\t#adjust profiles of temperature schedule of cloned schedule by + 1.5 deg F delta (0.833 C)\n\t\t\t\t\tprofiles.each do |profile|\n\t\t\t\t\t\ttime = profile.times\n\t\t\t\t\t\ti = 0\n\t\t\t\t\t\t#TODO - name new profile\n\t\t\t\t\t\tprofile.values.each do |value|\n\t\t\t\t\t\t\tdelta = 0.8333\n\t\t\t\t\t\t\tnew_value = value + delta # Note this is where the cooling setpoint is raised\n\t\t\t\t\t\t\tprofile.addValue(time[i], new_value)\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\t\tcloned_clg_tstat_schedule.setName(@new_clg_tstat_schedule_name)\n\t\t\t\t\t\t\tcooling_thermostat_array << cloned_clg_tstat_schedule\n\t\t\t\t\t\tend # end loop through each profile values\n\t\t\t\t\tend # end loop through each profile\n\t\t\t\t\t\n\t\t\t\t\tzone_thermostat.setCoolingSetpointTemperatureSchedule(cloned_clg_tstat_schedule.to_ScheduleRuleset.get)\n\t\t\t\t\trunner.registerInfo(\"The existing cooling thermostat '#{clg_tstat_schedule.name}' has been changed to #{cloned_clg_tstat_schedule.name}. Inspect the new schedule values using the OS App.\")\n\t\t\t\tend # end if statement for cloning and modifying cooling tstat schedule object\n\t\t\telse\n\t\t\t\trunner.registerInfo(\"The dual setpoint thermostat object named #{zone_thermostat.name} serving thermal zone #{thermal_zone.name} did not have a cooling setpoint temperature schedule associated with it. The measure will not alter this thermostat object\")\n\t\t\tend # end if statement for cooling Setpoint Temperature is initialized\n\t\t\t\n\t\t\tif zone_thermostat.heatingSetpointTemperatureSchedule.is_initialized\n\t\t\t\thtg_tstat_schedule = zone_thermostat.heatingSetpointTemperatureSchedule.get\n\t\t\t\t\t\t\n\t\t\t\t# clone the existing heating T-stat schedule in case it is used somewhere else\n\t\t\t\tcloned_htg_tstat_schedule = htg_tstat_schedule.clone\n\t\t\t\t\n\t\t\t\t#name cloned heating t-stat schedule\n\t\t\t\tcloned_htg_tstat_schedule.setName(\"#{htg_tstat_schedule.name}-1.5F\")\n\n\t\t\t\tif cloned_htg_tstat_schedule.to_ScheduleRuleset.is_initialized\n\t\t\t\t\tschedule = cloned_htg_tstat_schedule.to_ScheduleRuleset.get\n\t\t\t\t\n\t\t\t\t\t# gather profiles of cloned schedule\n\t\t\t\t\tprofiles_h = []\n\t\t\t\t\tdefaultProfile = schedule.to_ScheduleRuleset.get.defaultDaySchedule\n\t\t\t\t\t\n\t\t\t\t\tprofiles_h << defaultProfile\n\t\t\t\t\trules_h = schedule.scheduleRules\n\t\t\t\t\trules_h.each do |rule_h|\n\t\t\t\t\t\tprofiles_h << rule_h.daySchedule\n\t\t\t\t\tend # end the rule_h do\n\n\t\t\t\t\t#adjust profiles_h of temperature schedule of cloned schedule by + 1.5 deg F delta (0.833 C)\n\t\t\t\t\tprofiles_h.each do |profile_h|\n\t\t\t\t\t\ttime_h = profile_h.times\n\t\t\t\t\t\ti = 0\n\t\t\t\t\t\t#TODO - name new profile\n\t\t\t\t\t\tprofile_h.values.each do |value_h|\n\t\t\t\t\t\t\tdelta_h = 0.8333\n\t\t\t\t\t\t\tnew_value_h = value_h - delta_h # Note this is where the heating setpoint is lowered \n\t\t\t\t\t\t\tprofile_h.addValue(time_h[i], new_value_h)\n\t\t\t\t\t\t\ti += 1\n\t\t\t\t\t\tend # end loop through each profile values\n\t\t\t\t\tend # end loop through each profile_h\n\t\t\t\t\t\n\t\t\t\t\tzone_thermostat.setHeatingSetpointTemperatureSchedule(cloned_htg_tstat_schedule.to_ScheduleRuleset.get)\n\t\t\t\t\trunner.registerInfo(\"The existing heating thermostat '#{htg_tstat_schedule.name}' has been changed to #{cloned_htg_tstat_schedule.name}. Inspect the new schedule values using the OS App.\")\n\t\t\t\tend # end if statement for cloning and modifying heating tstat schedule object\t\n\t\t\telse\n\t\t\t\trunner.registerInfo(\"The dual setpoint thermostat object named #{zone_thermostat.name} serving thermal zone #{thermal_zone.name} did not have a heating setpoint temperature schedule associated with it. The measure will not alter this thermostat object\")\n\t\t\tend # end if statement for heating Setpoint Temperature is initialized\n\t\tend\t# end if statement for zone_thermstat cooling schedule\n\t\t\n\tend # end loop through thermal zones\t\t\t\n\t\t\t\n\t# Add ASHRAE 55 Comfort Warnings are applied to people objects\n\t# get people objects and people definitions in model\n\tpeople_defs = model.getPeopleDefinitions\n\tpeople_instances = model.getPeoples\n\n\t# loop through people objects\n\tpeople_def_counter = 0\n\tpeople_defs.sort.each do |people_def|\n\t next if not people_def.instances.size > 0\n\t people_def_counter += 1\n\t people_def.setEnableASHRAE55ComfortWarnings(true)\n\tend\n\t\t\t\n\treporting_frequency = \"Timestep\"\n\toutputVariable = OpenStudio::Model::OutputVariable.new(\"Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status []\",model)\n\toutputVariable.setReportingFrequency(reporting_frequency)\n\trunner.registerInfo(\"Adding output variable for 'Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status' reporting '#{reporting_frequency}'\")\n\n\t# write As Not Applicable message\n\tif tz_count == 0\n\t\trunner.registerAsNotApplicable(\"Measure is not applicable. There are no conditioned thermal zones in the model.\")\n\t\treturn true\n\tend\n\n\t# report initial condition of model\n\trunner.registerInitialCondition(\"The initial model contained #{tz_count} thermal zones with #{thermal_zone_array.length} 'Cooling Thermostat Schedule' and #{thermal_zone_array.length} 'Heating Thermostat Schedule' objects for which this measure is applicable.\")\n\n\t# report final condition of model\n\trunner.registerFinalCondition(\"The #{thermal_zone_array.length} Heating and #{thermal_zone_array.length} Cooling Thermostats schedules for #{thermal_zone_array.length} Thermal Zones were altered to reflect a additional deadband width of 3 Deg F . \")\n\treturn true\n\n end", "def stat(*args)\n @recorder.call(*args) if @recorder\n end", "def measure (n=1)\n cnt=0\nelapsed_time=Time.now\n\nn.times {\n cnt+=1\n yield} \nelapsed_time=(Time.now-elapsed_time)/cnt\n\nend", "def run() end", "def running_test_step; end", "def stat() end", "def measure(msg)\n start = Time.now\n yield\n printf \"%<msg>s in %<elapsed>.2f seconds\\n\", msg: msg, elapsed: Time.now - start\nend", "def measure(msg)\n start = Time.now\n yield\n printf \"%<msg>s in %<elapsed>.2f seconds\\n\", msg: msg, elapsed: Time.now - start\nend", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n #initialize variables\n zone_hvac_count = 0\n pump_count = 0\n air_loop_count = 0\n \n #loop through each air loop in the model\n model.getAirLoopHVACs.sort.each do |air_loop|\n\n # call the method to generate a new occupancy schedule based on a 5% threshold\n occ_sch = air_loop.get_occupancy_schedule(0.15)\n old_sch = air_loop.availabilitySchedule\n next unless compare_eflh(runner, old_sch, occ_sch)\n # set the availability schedule of the airloop to the newly generated schedule\n air_loop.setAvailabilitySchedule(occ_sch)\n runner.registerInfo(\"The availability schedule named #{old_sch.name} for #{air_loop.name} was replaced with a new schedule named #{occ_sch.name} which tracks the occupancy profile of the thermal zones on this airloop.\")\n air_loop_count +=1\n \n end\n\n #loop through each thermal zone\n model.getThermalZones.sort.each do |thermal_zone|\n \n # zone equipments assigned to thermal zones\n thermal_zone_equipment = thermal_zone.equipment \n \n if thermal_zone_equipment.size >= 1\n # run schedule method to create a new schedule ruleset, routines \n occ_sch = thermal_zone.get_occupancy_schedule(0.15)\n \n #loop through Zone HVAC Equipment\n thermal_zone_equipment.each do |equip|\n \n # getting the fan exhaust object & getting relevant information for it. \n if equip.to_FanZoneExhaust.is_initialized\n zone_equip = equip.to_FanZoneExhaust.get\n old_schedule = zone_equip.availabilitySchedule.get\n next unless compare_eflh(runner, old_schedule, occ_sch)\n #assign the 'occ_sch' here as exhaust's availability schedule\n zone_equip.setAvailabilitySchedule(occ_sch)\n runner.registerInfo(\"The availability schedule named #{old_schedule.name} for the OS_Fan_ZoneExhaust named #{zone_equip.name} was replaced with a new schedule named #{occ_sch.name} representing the occupancy profile of the thermal zone named #{thermal_zone.name}.\")\n zone_hvac_count += 1 \t\n elsif equip.to_RefrigerationAirChiller.is_initialized\n zone_equip = equip.to_RefrigerationAirChiller.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_WaterHeaterHeatPump.is_initialized\n zone_equip = equip.to_WaterHeaterHeatPump.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardConvectiveElectric.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardConvectiveElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardConvectiveWater.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardConvectiveWater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardRadiantConvectiveElectric.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardRadiantConvectiveElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACBaseboardRadiantConvectiveWater.is_initialized\n zone_equip = equip.to_ZoneHVACBaseboardRadiantConvectiveWater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACDehumidifierDX.is_initialized\n zone_equip = equip.to_ZoneHVACDehumidifierDX.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACEnergyRecoveryVentilator.is_initialized\n zone_equip = equip.to_ZoneHVACEnergyRecoveryVentilator.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\n elsif equip.to_ZoneHVACFourPipeFanCoil.is_initialized\n zone_equip = equip.to_ZoneHVACFourPipeFanCoil.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACHighTemperatureRadiant.is_initialized\n zone_equip = equip.to_ZoneHVACHighTemperatureRadiant.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\n elsif equip.to_ZoneHVACIdealLoadsAirSystem.is_initialized\n zone_equip = equip.to_ZoneHVACIdealLoadsAirSystem.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t \n elsif equip.to_ZoneHVACLowTemperatureRadiantElectric.is_initialized\n zone_equip = equip.to_ZoneHVACLowTemperatureRadiantElectric.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACLowTempRadiantConstFlow.is_initialized\n zone_equip = equip.to_ZoneHVACLowTempRadiantConstFlow.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t \t\n elsif equip.to_ZoneHVACLowTempRadiantVarFlow.is_initialized\n zone_equip = equip.to_ZoneHVACLowTempRadiantVarFlow.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneHVACPackagedTerminalAirConditioner.is_initialized\n zone_equip = equip.to_ZoneHVACPackagedTerminalAirConditioner.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACPackagedTerminalHeatPump.is_initialized\n zone_equip = equip.to_ZoneHVACPackagedTerminalHeatPump.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\n elsif equip.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.is_initialized\n next unless compare_eflh(runner, old_schedule, occ_sch) \n equip.to_ZoneHVACTerminalUnitVariableRefrigerantFlow.get.setTerminalUnitAvailabilityschedule(occ_sch)\n runner.registerInfo(\"The availability schedule for the Zone HVAC Terminal Unit Variable Refrigerant Flow Object has been replaced with a new schedule named #{occ_sch.name} representing the occupancy profile of the thermal zone named #{thermal_zone.name}.\")\t\t\t\t\t\n zone_hvac_count += 1 \n elsif equip.to_ZoneHVACUnitHeater.is_initialized\n zone_equip = equip.to_ZoneHVACUnitHeater.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\n elsif equip.to_ZoneHVACUnitVentilator.is_initialized\n zone_equip = equip.to_ZoneHVACUnitVentilator.get\n zone_hvac_count += 1 if set_equip_availability_schedule(runner, thermal_zone, occ_sch, zone_equip)\t\t\t\t\t\n elsif equip.to_ZoneVentilationDesignFlowRate.is_initialized\n runner.registerInfo(\"Thermal Zone named #{thermal_zone.name} has a Zone Ventilation Design Flow Rate object attacjhed as a ZoneHVACEquipment object. No modification were made to this object.\")\t\t\n end \t\n \n end # end loop through Zone HVAC Equipment\n \n else\n runner.registerInfo(\"Thermal Zone named #{thermal_zone.name} has no Zone HVAC Equipment objects attached - therefore no schedule objects have been altered.\")\t\n end # end of if statement\n \n end # end loop through thermal zones\n\n # Change pump control status if any airloops or\n # zone equipment were changed.\n if air_loop_count > 0 || zone_hvac_count > 0\n model.getPlantLoops.each do |plantLoop|\n #Loop through each plant loop demand component\n plantLoop.demandComponents.each do |dc|\n if dc.to_PumpConstantSpeed.is_initialized\n cs_pump = dc.to_PumpConstantSpeed.get\n if cs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Demand side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{dc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Pump Control Type attribute of Demand side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{dc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end\n end\n \n if dc.to_PumpVariableSpeed.is_initialized\n vs_pump = dc.to_PumpVariableSpeed.get\n if vs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Demand side Variable Speed Pump named #{vs_pump.name} on the plant loop named #{dc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Demand side Pump Control Type attribute of Variable Speed Pump named #{vs_pump.name} on the plant loop named #{dc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end\n end\n end\n \n #Loop through each plant loop supply component\n plantLoop.supplyComponents.each do |sc|\n if sc.to_PumpConstantSpeed.is_initialized\n cs_pump = sc.to_PumpConstantSpeed.get\n if cs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Supply side Constant Speed Pump object named #{cs_pump.name} on the plant loop named #{sc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Supply Side Pump Control Type atteribute of Constant Speed Pump named #{cs_pump.name} on the plant loop named #{sc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end #end if statement\t\n end #end if statement for changing supply component constant speed pump objects\n \n if sc.to_PumpVariableSpeed.is_initialized\n vs_pump = sc.to_PumpVariableSpeed.get\n if vs_pump.pumpControlType == (\"Intermittent\")\n runner.registerInfo(\"Supply side Variable Speed Pump object named #{vs_pump.name} on the plant loop named #{sc.name} had a pump control type attribute already set to intermittent. No changes will be made to this object.\")\n else \n cs_pump.setPumpControlType(\"Intermittent\")\n runner.registerInfo(\"Pump Control Type attribute of Supply Side Variable Speed Pump named #{vs_pump.name} on the plant loop named #{sc.name} was changed from continuous to intermittent.\")\n pump_count +=1\n end #end if statement\t\n end #end if statement for changing supply component variable speed pump objects\n \n end # end loop throught plant loop supply side components\n \n end # end loop through plant loops\n end\n \n #Write N/A message\n if air_loop_count == 0 && zone_hvac_count == 0 && pump_count == 0 \n runner.registerAsNotApplicable(\"The model did not contain any Airloops, Thermal Zones having ZoneHVACEquipment objects or associated plant loop pump objects to act upon. The measure is not applicable.\")\n return true\n end\t\n \n #report initial condition of model\n runner.registerInitialCondition(\"The model started with #{air_loop_count} AirLoops, #{zone_hvac_count} Zone HVAC Equipment Object and #{pump_count} pump objects subject to modifications.\")\n \n # report final condition of model\n runner.registerFinalCondition(\"The measure modified the availability schedules of #{air_loop_count} AirLoops and #{zone_hvac_count} Zone HVAC Equipment objects. #{pump_count} pump objects had control settings modified.\")\n \n # Add ASHRAE Standard 55 warnings\n reporting_frequency = \"Timestep\"\n outputVariable = OpenStudio::Model::OutputVariable.new(\"Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status []\",model)\n outputVariable.setReportingFrequency(reporting_frequency)\n runner.registerInfo(\"Adding output variable for 'Zone Thermal Comfort ASHRAE 55 Adaptive Model 90% Acceptability Status' reporting at the model timestep.\")\n \n return true\n\t\n end", "def calc_next_run\n nil\n end", "def calc_next_run\n nil\n end", "def running_test_case; end", "def estimate\n # (native code) \n end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def tick; end", "def tick; end", "def tick; end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n fixed_window_subsurface = runner.getOptionalWorkspaceObjectChoiceValue('fixed_window_subsurface', user_arguments, model) # model is passed in because of argument type\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments) \n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments) \n \n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n # declare arrys for scope\n array_of_21_sets = []\n material_property_glazing_spectral_data_vector = []\n standard_glazing_layer_array = []\n construction_array = []\n ems_window_construction_array = []\n \n # load idf into workspace\n workspace = OpenStudio::Workspace::load(OpenStudio::Path.new(\"#{File.dirname(__FILE__)}/resources/EMSThermochromicWindow.idf\")).get\n \n # get all MaterialPropertyGlazingSpectralData objects from within the idf\n # material_property_glazing_spectral_datas = source_idf.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n material_property_glazing_spectral_datas = workspace.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n if verbose_info_statements == true\n runner.registerInfo(\"The model has #{material_property_glazing_spectral_datas.size} material_property_glazing_spectral_datas objects.\")\n end\n \n material_property_glazing_spectral_datas.each do |material_property_glazing_spectral_data|\n \n spectral_data = {\"name\" => \"\",\"properties\" => []}\n spectral_data[\"name\"] = material_property_glazing_spectral_data.getString(0).to_s\n \n # Note: EnergyPlus file MaterialProperty:GlazingSpectralData objects have 1764 /4 = 441 sets of 4 values each \n n = material_property_glazing_spectral_data.numFields\n (1..n).each do |i| \n spectral_data[\"properties\"] << material_property_glazing_spectral_data.getString(i).to_s \n end\n array_of_21_sets << spectral_data\n end\n \n array_of_21_sets.each do |set|\n \n props = set[\"properties\"]\n material_property_glazing_spectral_data = OpenStudio::Model::MaterialPropertyGlazingSpectralData.new(model)\n material_property_glazing_spectral_data.setName(\"#{set[\"name\"]}\")\n \n k = (props.length / 4) - 1\n (0..k).each do |i| # note 440 uniques (a, b, c, d) pairs of attributes for each spectral data field object\n material_property_glazing_spectral_data.addSpectralDataField(props[(i*4)+0].to_f, props[(i*4)+1].to_f, props[(i*4)+2].to_f, props[(i*4)+3].to_f)\t\n end\n \n material_property_glazing_spectral_data_vector << material_property_glazing_spectral_data\n end \n \n # create (2) required new air gas materials to used by all EMS window constructions \n air_gas_3mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.003) \n air_gas_3mm_material.setName(\"AIR 3MM\")\n \n air_gas_8mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.008) \n air_gas_8mm_material.setName(\"AIR 8MM\")\n \n # loop through array of OS MaterialPropertyGlazingSpectralData objects and create 21 new Standard Glazing objects \n material_property_glazing_spectral_data_vector.each do |spec_data_obj|\n spec_data_obj_name = spec_data_obj.name\n layer_name = spec_data_obj_name.to_s.slice(\"sp\")\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.0075)\n else\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.003276)\n end\n layer.setName(\"#{layer_name}\")\n layer.setWindowGlassSpectralDataSet(spec_data_obj)\n layer.setInfraredTransmittanceatNormalIncidence(0) # same for all 21 constructions\n layer.setFrontSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n layer.setBackSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer.setConductivity(1.0) \n else\n layer.setConductivity(0.6) \n end\n layer.setDirtCorrectionFactorforSolarandVisibleTransmittance(1) # same for all 21 constructions\n layer.setSolarDiffusing(false)\n standard_glazing_layer_array << layer\n end\n\n # Create (2) unique standard glazing layers not used for Thermochromatic performance \n sb60_clear_3_ppg_layer = standard_glazing_layer_array[0]\n clear_3ppg_layer = standard_glazing_layer_array[1]\n remaining_standard_glazing_layer_array = standard_glazing_layer_array.drop(2)\n \n # create (19) new arrays of layered constructions representing thermochromatic layers\n remaining_standard_glazing_layer_array.each do |remaining_standard_glazing_layer|\n construction = [sb60_clear_3_ppg_layer, air_gas_3mm_material, remaining_standard_glazing_layer, air_gas_8mm_material, sb60_clear_3_ppg_layer]\n construction_array << construction\n end\n \n # create 19 new OS:Construction objects representing EMS thermochromatic windows\n name_index_array = [25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 50, 55, 60, 65, 70, 75, 80, 85]\n index = 0\n \n construction_array.each do |const|\n ems_window_construction = OpenStudio::Model::Construction.new(const)\n ems_window_construction.setName(\"TCwindow_#{name_index_array[index]}\")\n if verbose_info_statements == true\n runner.registerInfo(\"Created a new Construction named #{ems_window_construction.name} representing a thermochromatic window construction.\")\n end\n ems_window_construction_array << ems_window_construction\n index +=1\n end\n\n # check the user argument of the fixed window subsurface for reasonableness\n if fixed_window_subsurface.empty?\n handle = runner.getStringArgumentValue('fixed_window_subsurface', user_arguments)\n if handle.empty?\n runner.registerError('No fixed window subsurface was chosen.')\n else\n runner.registerError(\"The selected fixed window subsurface with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !fixed_window_subsurface.get.to_SubSurface.empty?\n fixed_window_subsurface = fixed_window_subsurface.get.to_SubSurface.get\n else\n runner.registerError('Script Error - argument not showing up as construction.')\n return false\n end\n end\n \n # Create a new EnergyManagementSystem:Sensor object representing the Surface Outside Face temp of the EMS thermochromatic window subsurface\n ems_win_Tout_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Surface Outside Face Temperature\")\n ems_win_Tout_sensor.setName(\"Win1_Tout\")\n ems_win_Tout_sensor.setKeyName(\"#{fixed_window_subsurface.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Sensor object named '#{ems_win_Tout_sensor.name}' representing the Surface Outside Face temp of the EMS thermochromatic window subsurface was added to the model.\") \n end\n \n # Create a new EMS Actuator Object representing the construction state of the EMS generated thermochromatic window \n ems_win_construct_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fixed_window_subsurface, \"Surface\", \"Construction State\")\n ems_win_construct_actuator.setName(\"Win1_Construct\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator object named '#{ems_win_construct_actuator.name}' representing construction state of the EMS generated thermochromatic window was added to the model.\") \n end\n \n # Create 19 EnergyManagementSystem:ConstructionIndexVariable objects for each unique thermochromatic construction\n ems_window_construction_array.each do |ems_window_construction|\n ems_constr_index_var = OpenStudio::Model::EnergyManagementSystemConstructionIndexVariable.new(model, ems_window_construction ) \n ems_constr_index_var.setName(\"#{ems_window_construction.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS SystemConstructionIndexVariable object named '#{ems_constr_index_var.name}' representing the the EMS construction state of the thermochromatic window was added to the model.\") \n end\n end\n \n # Create new EnergyManagementSystem:Program object for assigning different window constructions by dynamically evaluating the exterior surface temp of the fixed window subsurface \n ems_apply_thermochromatic_constructions_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_apply_thermochromatic_constructions_prgm.setName(\"#{fixed_window_subsurface.name}_Control\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"IF #{ems_win_Tout_sensor.name} <= 26.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_25\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 28.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_27\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 30.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_29\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 32.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_31\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 34.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_33\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 36.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_35\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 38.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_37\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 40.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_39\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 42.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_41\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 44.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_43\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 47.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_45\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 52.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_50\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 57.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_55\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 62.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_60\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 67.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_65\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 72.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_70\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 77.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_75\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 82.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_80\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSE\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_85\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ENDIF\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Program Object named '#{ems_apply_thermochromatic_constructions_prgm.name}' for dynamically assigning different window constructions based on the exterior surface temp was added to the model.\") \n end\n \n # Create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS programs\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"My thermochromic window emulator\")\n ems_prgm_calling_mngr.setCallingPoint(\"BeginTimestepBeforePredictor\")\n ems_prgm_calling_mngr.addProgram(ems_apply_thermochromatic_constructions_prgm)\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call EMS program for dynamically applying a thermochromatic window.\") \n end\n \n # create unique object for OutputEnergyManagementSystems and configure to allow EMS reporting\n outputEMS = model.getOutputEnergyManagementSystem\n outputEMS.setInternalVariableAvailabilityDictionaryReporting(\"internal_variable_availability_dictionary_reporting\")\n outputEMS.setEMSRuntimeLanguageDebugOutputLevel(\"ems_runtime_language_debug_output_level\")\n outputEMS.setActuatorAvailabilityDictionaryReporting(\"actuator_availability_dictionary_reporting\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS OutputEnergyManagementSystem object configured per user arguments.\") \n end\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end", "def bench(action, msg = nil)\n @t ||= Time.now\n @total ||= 0\n @step ||= 0\n case action\n when :start\n @step = 0\n @total = 0\n @t = Time.now\n when :step\n @step += 1\n int = Time.now - @t\n @total += int\n @t = Time.now\n dbg(\"Benchmark #{msg.nil? ? (\"%02d\" % @step) : msg}: #{\"%8.3fms\" % (int * 1000)} (Total: #{\"%8.3fms\" % (@total * 1000)}).\")\n end\nend", "def after_assumption(name); end", "def apply_measure_and_run(test_name, measure, argument_map, osm_path, epw_path, run_model: false)\n assert(File.exist?(osm_path))\n assert(File.exist?(epw_path))\n\n # create run directory if it does not exist\n if !File.exist?(run_dir(test_name))\n FileUtils.mkdir_p(run_dir(test_name))\n end\n assert(File.exist?(run_dir(test_name)))\n\n # change into run directory for tests\n start_dir = Dir.pwd\n Dir.chdir run_dir(test_name)\n\n # remove prior runs if they exist\n if File.exist?(model_output_path(test_name))\n FileUtils.rm(model_output_path(test_name))\n end\n if File.exist?(report_path(test_name))\n FileUtils.rm(report_path(test_name))\n end\n\n # copy the osm and epw to the test directory\n new_osm_path = \"#{run_dir(test_name)}/#{File.basename(osm_path)}\"\n FileUtils.cp(osm_path, new_osm_path)\n new_epw_path = \"#{run_dir(test_name)}/#{File.basename(epw_path)}\"\n FileUtils.cp(epw_path, new_epw_path)\n # create an instance of a runner\n runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)\n\n # load the test model\n model = load_model(new_osm_path)\n\n # set model weather file\n epw_file = OpenStudio::EpwFile.new(OpenStudio::Path.new(new_epw_path))\n OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file)\n assert(model.weatherFile.is_initialized)\n\n # run the measure\n puts \"\\nAPPLYING MEASURE...\"\n measure.run(model, runner, argument_map)\n result = runner.result\n\n # show the output\n show_output(result)\n\n # save model\n model.save(model_output_path(test_name), true)\n\n errs = []\n if run_model && (result.value.valueName == 'Success')\n puts \"\\nRUNNING ANNUAL SIMULATION...\"\n\n std = Standard.build('NREL ZNE Ready 2017')\n std.model_run_simulation_and_log_errors(model, run_dir(test_name))\n\n # check that the model ran successfully and generated a report\n assert(File.exist?(model_output_path(test_name)))\n assert(File.exist?(sql_path(test_name)))\n assert(File.exist?(report_path(test_name)))\n\n # set runner variables\n runner.setLastEpwFilePath(epw_path)\n runner.setLastOpenStudioModelPath(OpenStudio::Path.new(model_output_path(test_name)))\n runner.setLastEnergyPlusSqlFilePath(OpenStudio::Path.new(sql_path(test_name)))\n sql = runner.lastEnergyPlusSqlFile.get\n model.setSqlFile(sql)\n\n # test for unmet hours\n unmet_heating_hrs = std.model_annual_occupied_unmet_heating_hours(model)\n unmet_cooling_hrs = std.model_annual_occupied_unmet_cooling_hours(model)\n unmet_hrs = std.model_annual_occupied_unmet_hours(model)\n max_unmet_hrs = 550\n if unmet_hrs\n if unmet_hrs > 550\n errs << \"For #{test_name} there were #{unmet_heating_hrs.round(1)} unmet occupied heating hours and #{unmet_cooling_hrs.round(1)} unmet occupied cooling hours (total: #{unmet_hrs.round(1)}), more than the limit of #{max_unmet_hrs}.\" if unmet_hrs > max_unmet_hrs\n else\n puts \"There were #{unmet_heating_hrs.round(1)} unmet occupied heating hours and #{unmet_cooling_hrs.round(1)} unmet occupied cooling hours (total: #{unmet_hrs.round(1)}).\"\n end\n else\n errs << \"For #{test_name} could not determine unmet hours; simulation may have failed.\"\n end\n end\n\n # change back directory\n Dir.chdir(start_dir)\n\n assert(errs.empty?, errs.join(\"\\n\"))\n\n return result\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n retrofit_month = runner.getStringArgumentValue('retrofit_month', user_arguments).to_i\n retrofit_day = runner.getStringArgumentValue('retrofit_day', user_arguments).to_i\n\n # report initial condition of model\n runner.registerInitialCondition(\"Measure started successfully.\")\n\n # TODO: check the month and day for reasonableness\n runner.registerInfo(\"User entered retrofit month: #{retrofit_month}\")\n runner.registerInfo(\"User entered retrofit day: #{retrofit_day}\")\n\n prog_calling_manager = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n prog_calling_manager.setCallingPoint('BeginTimestepBeforePredictor')\n\n # Remove old and add new equip with EMS by spaces\n hash_space_epd = Hash.new\n v_spaces = model.getSpaces\n v_spaces.each do |space|\n current_space_equip = space.electricEquipment[0]\n unless current_space_equip.nil?\n\n # Get equipment power density for each space type\n new_space_epd = runner.getOptionalDoubleArgumentValue(\"new_#{space.name.to_s}_epd\", user_arguments)\n if new_space_epd.is_initialized\n hash_space_epd[\"new_#{space.name.to_s}_epd\"] = new_space_epd\n runner.registerInfo(\"User entered new electric equipment power density for #{space.name.to_s} is #{new_space_epd} W/m2\")\n # Set ems\n current_space_equip_def = current_space_equip.electricEquipmentDefinition\n equip_sch_name = current_space_equip.schedule.get.nameString\n equip_sch_ems_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')\n equip_sch_ems_sensor.setKeyName(equip_sch_name)\n runner.registerInfo(\"Delete old equip object for #{space.name}\")\n current_space_equip.remove\n\n new_equip = add_equip_space(space, current_space_equip_def)\n equip_level_w = new_space_epd.to_f * space.floorArea.to_f\n ems_equip_program = add_equip_ems(model, new_equip, equip_level_w, equip_sch_ems_sensor, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n else\n # Get equipment power ratio for each space type\n new_space_ratio = runner.getDoubleArgumentValue(\"new_#{space.name.to_s}_ratio\", user_arguments)\n\n old_equip_sch = current_space_equip.schedule.get\n ems_equip_program = add_equip_ems_w_occ_var(model, current_space_equip, old_equip_sch, new_space_ratio, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n # runner.registerInfo(\"Delete old equip object for #{space.name}\")\n # current_space_equip.remove\n end\n\n end\n end\n\n # Remove old and add new equip with EMS by space types\n hash_space_type_epd = Hash.new\n v_space_types = model.getSpaceTypes\n v_space_types.each do |space_type|\n current_spaces = space_type.spaces\n current_space_type_equip = space_type.electricEquipment[0]\n unless current_space_type_equip.nil?\n # Get equipment power density for each space type\n current_space_type_epd = runner.getStringArgumentValue(\"new_#{space_type.name.to_s}_epd\", user_arguments)\n hash_space_type_epd[\"new_#{space_type.name.to_s}_epd\"] = current_space_type_epd\n runner.registerInfo(\"User entered new electric equipment power density for #{space_type.name.to_s} is #{current_space_type_epd} W/m2\")\n\n # Set ems\n current_space_type_equip_def = current_space_type_equip.electricEquipmentDefinition\n current_space_type_sch_set = space_type.defaultScheduleSet.get\n current_space_type_equip_sch_set = current_space_type_sch_set.electricEquipmentSchedule.get\n\n equip_sch_name = current_space_type_equip_sch_set.nameString\n equip_sch_ems_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, 'Schedule Value')\n equip_sch_ems_sensor.setKeyName(equip_sch_name)\n\n puts \"Delete old equip object for #{space_type.name}\"\n current_space_type_equip.remove\n\n current_spaces.each do |space|\n # Calculate equipemtn electric power for each space\n new_equip = add_equip_space_type(model, space, space_type, current_space_type_equip_def)\n equip_level_w = current_space_type_epd.to_f * space.floorArea.to_f\n ems_equip_program = add_equip_ems(model, new_equip, equip_level_w, equip_sch_ems_sensor, retrofit_month, retrofit_day)\n prog_calling_manager.addProgram(ems_equip_program)\n runner.registerInfo(\"Add ems equipment control for #{space.name} succeeded.\")\n end\n end\n end\n\n # echo the model updates back to the user\n runner.registerInfo(\"The electric equipment retrofit measure is applied.\")\n\n # report final condition of model\n runner.registerFinalCondition(\"Measure ended successfully.\")\n\n return true\n end", "def call\n result = while_measuring_memory_usage { action.call }\n\n Measurement.from_result(result)\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n runner.registerInfo(\"Start to create lighting measure from occupant schedule\")\n\n ### Get user selected lighting space assumptions for each space\n v_space_types = model.getSpaceTypes\n i = 1\n lght_space_type_arg_vals = {}\n # Loop through all space types, group spaces by their types\n v_space_types.each do |space_type|\n # Loop through all spaces of current space type\n v_current_spaces = space_type.spaces\n next if not v_current_spaces.size > 0\n v_current_spaces.each do |current_space|\n lght_space_type_val = runner.getStringArgumentValue(@@v_space_args[current_space.nameString], user_arguments)\n lght_space_type_arg_vals[current_space.nameString] = lght_space_type_val\n i += 1\n end\n end\n\n puts lght_space_type_arg_vals\n\n ### Start creating new lighting schedules based on occupancy schedule\n occ_schedule_dir = runner.getStringArgumentValue('occ_schedule_dir', user_arguments)\n model_temp_run_path = Dir.pwd + '/'\n measure_root_path = File.dirname(__FILE__)\n\n puts '=' * 80\n puts measure_root_path\n\n if File.file?(occ_schedule_dir)\n # Check if user provided a occupancy schedule CSV file\n csv_file = occ_schedule_dir\n puts 'Use user provided occupancy schedule file at: ' + csv_file.to_s\n runner.registerInitialCondition('Location check:' + File.expand_path(\"../..\", measure_root_path))\n # runner.registerInitialCondition('Use user provided occupancy schedule file at: ' + csv_file.to_s)\n else\n # Check if schedule file at several places\n # 1. Default fils path when run with OSW in CLI\n csv_path_lookup_1 = File.expand_path(\"../..\", measure_root_path) + \"/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"First lookup location: \" + csv_path_lookup_1\n runner.registerInfo(\"First lookup location: \" + csv_path_lookup_1)\n # 2. Default path when run with OpenStudio CLI\n csv_path_lookup_2 = File.expand_path(\"../..\", model_temp_run_path) + \"/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Second lookup location: \" + csv_path_lookup_2\n runner.registerInfo(\"Second lookup location: \" + csv_path_lookup_2)\n # 3. Default path when run with OpenStudio GUI\n csv_path_lookup_3 = File.expand_path(\"../../..\", model_temp_run_path) + \"/resources/files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Third lookup location: \" + csv_path_lookup_3\n runner.registerInfo(\"Third lookup location: \" + csv_path_lookup_3)\n # 4. Generated files folder when run with rspec\n csv_path_lookup_4 = File.expand_path(\"..\", model_temp_run_path) + \"/generated_files/#{@@default_occupant_schedule_filename}\"\n puts '#' * 80\n puts \"Forth lookup location: \" + csv_path_lookup_4\n runner.registerInfo(\"Forth lookup location: \" + csv_path_lookup_4)\n # 5. Generated files folder with OpenStudio V2.9.0+\n csv_path_lookup_5 = File.join(File.expand_path(\"../..\", model_temp_run_path), 'generated_files', @@default_occupant_schedule_filename)\n puts '#' * 80\n puts \"Fifth lookup location: \" + csv_path_lookup_5\n runner.registerInfo(\"Fifth lookup location: \" + csv_path_lookup_5)\n\n if File.file?(csv_path_lookup_1)\n csv_file = csv_path_lookup_1\n elsif File.file?(csv_path_lookup_2)\n csv_file = csv_path_lookup_2\n elsif File.file?(csv_path_lookup_3)\n csv_file = csv_path_lookup_3\n elsif File.file?(csv_path_lookup_4)\n csv_file = csv_path_lookup_4 \n elsif File.file?(csv_path_lookup_5)\n csv_file = csv_path_lookup_5\n else\n csv_file = ''\n end\n puts 'Use default occupancy schedule file at: ' + csv_file.to_s\n runner.registerInfo('Use default occupancy schedule file at: ' + csv_file.to_s)\n end\n\n # Get the spaces with occupancy count schedule available\n v_spaces_occ_sch = File.readlines(csv_file)[3].split(',') # Room ID is saved in 4th row of the occ_sch file\n v_headers = Array.new\n v_spaces_occ_sch.each do |space_occ_sch|\n if !['Room ID', 'Outdoor', 'Outside building'].include? space_occ_sch and !space_occ_sch.strip.empty?\n v_headers << space_occ_sch\n end\n end\n v_headers = [\"Time\"] + v_headers\n\n # report initial condition of model\n runner.registerInfo(\"The building has #{v_headers.length - 1} spaces with available occupant schedule file.\")\n\n # Read the occupant count schedule file and clean it\n clean_csv = File.readlines(csv_file).drop(6).join\n csv_table_sch = CSV.parse(clean_csv, headers: true)\n new_csv_table = csv_table_sch.by_col!.delete_if do |column_name, column_values|\n !v_headers.include? column_name\n end\n\n runner.registerInfo(\"Successfully read occupant count schedule from CSV file.\")\n runner.registerInfo(\"Creating new lighting schedules...\")\n\n # Create lighting schedule based on the occupant count schedule\n v_cols = Array.new\n v_ts = new_csv_table.by_col!['Time']\n v_headers.each do |header|\n if header != 'Time'\n space_name = header\n v_occ_n = new_csv_table.by_col![space_name]\n v_light = create_lighting_sch_from_occupancy_count(space_name, v_ts, v_occ_n, @@off_delay)\n v_cols << v_light\n end\n end\n\n runner.registerInfo(\"Writing new lighting schedules to CSV file.\")\n # Write new lighting schedule file to CSV\n file_name_light_sch = \"#{model_temp_run_path}/#{@@lighting_schedule_CSV_name}\"\n vcols_to_csv(v_cols, file_name_light_sch)\n\n # Add new lighting schedule from the CSV file created\n runner.registerInfo(\"Removing old OS:Lights and OS:Lights:Definition for office and conference rooms.\")\n # Remove old lights definition objects for office and conference rooms\n v_space_types.each do |space_type|\n space_type.spaces.each do |space|\n selected_space_type = lght_space_type_arg_vals[space.name.to_s]\n if (@@office_type_names.include? selected_space_type) || (@@conference_room_type_names.include? selected_space_type)\n space_type.lights.each do |lght|\n puts 'Remove old lights definition object: ' + lght.lightsDefinition.name.to_s\n lght.lightsDefinition.remove\n end\n end\n end\n end\n\n # Remove old lights objects for office and conference rooms\n # Caution: the order of deletion matters\n v_space_types.each do |space_type|\n space_type.spaces.each do |space|\n selected_space_type = lght_space_type_arg_vals[space.name.to_s]\n if (@@office_type_names.include? selected_space_type) || (@@conference_room_type_names.include? selected_space_type)\n space_type.lights.each do |lght|\n puts 'Remove old lights object: ' + lght.name.to_s\n lght.remove\n end\n end\n end\n end\n\n puts '---> Create new lighting schedules from CSV.'\n\n runner.registerInfo(\"Adding new OS:Schedule:File objects to the model....\")\n v_spaces = model.getSpaces\n v_spaces.each do |space|\n v_headers.each_with_index do |s_space_name, i|\n if s_space_name == space.name.to_s\n col = i\n temp_file_path = file_name_light_sch\n sch_file_name = space.name.to_s + ' lght sch'\n schedule_file = get_os_schedule_from_csv(model, temp_file_path, sch_file_name, col, skip_row = 1)\n schedule_file.setMinutesperItem(@@minute_per_item.to_s)\n model = add_light(model, space, schedule_file)\n end\n end\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"Finished creating and adding new lighting schedules for #{v_headers.length - 1} spaces.\")\n\n return true\n end", "def span\n measure\n @span\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # System Type 2: PTHP, Residential\n # This measure creates:\n # a constant volume packaged terminal heat pump unit with DX heating \n # and cooling for each zone in the building\n \n always_on = model.alwaysOnDiscreteSchedule\n\n # Make a PTHP for each zone\n model.getThermalZones.each do |zone|\n \n fan = OpenStudio::Model::FanConstantVolume.new(model,always_on)\n fan.setPressureRise(300)\n\n supplemental_htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model,always_on)\n\n clg_cap_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)\n clg_cap_f_of_temp.setCoefficient1Constant(0.942587793)\n clg_cap_f_of_temp.setCoefficient2x(0.009543347)\n clg_cap_f_of_temp.setCoefficient3xPOW2(0.0018423)\n clg_cap_f_of_temp.setCoefficient4y(-0.011042676)\n clg_cap_f_of_temp.setCoefficient5yPOW2(0.000005249)\n clg_cap_f_of_temp.setCoefficient6xTIMESY(-0.000009720)\n clg_cap_f_of_temp.setMinimumValueofx(17.0)\n clg_cap_f_of_temp.setMaximumValueofx(22.0)\n clg_cap_f_of_temp.setMinimumValueofy(13.0)\n clg_cap_f_of_temp.setMaximumValueofy(46.0)\n\n clg_cap_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n clg_cap_f_of_flow.setCoefficient1Constant(0.718954)\n clg_cap_f_of_flow.setCoefficient2x(0.435436)\n clg_cap_f_of_flow.setCoefficient3xPOW2(-0.154193)\n clg_cap_f_of_flow.setMinimumValueofx(0.75)\n clg_cap_f_of_flow.setMaximumValueofx(1.25)\n\n clg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveBiquadratic.new(model)\n clg_energy_input_ratio_f_of_temp.setCoefficient1Constant(0.342414409)\n clg_energy_input_ratio_f_of_temp.setCoefficient2x(0.034885008)\n clg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(-0.000623700)\n clg_energy_input_ratio_f_of_temp.setCoefficient4y(0.004977216)\n clg_energy_input_ratio_f_of_temp.setCoefficient5yPOW2(0.000437951)\n clg_energy_input_ratio_f_of_temp.setCoefficient6xTIMESY(-0.000728028)\n clg_energy_input_ratio_f_of_temp.setMinimumValueofx(17.0)\n clg_energy_input_ratio_f_of_temp.setMaximumValueofx(22.0)\n clg_energy_input_ratio_f_of_temp.setMinimumValueofy(13.0)\n clg_energy_input_ratio_f_of_temp.setMaximumValueofy(46.0)\n\n clg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n clg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.1552)\n clg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.1808)\n clg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0256)\n clg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.5)\n clg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.5)\n\n clg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)\n clg_part_load_fraction.setCoefficient1Constant(0.75)\n clg_part_load_fraction.setCoefficient2x(0.25)\n clg_part_load_fraction.setCoefficient3xPOW2(0.0)\n clg_part_load_fraction.setMinimumValueofx(0.0)\n clg_part_load_fraction.setMaximumValueofx(1.0)\n\n clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model,\n always_on,\n clg_cap_f_of_temp,\n clg_cap_f_of_flow,\n clg_energy_input_ratio_f_of_temp,\n clg_energy_input_ratio_f_of_flow,\n clg_part_load_fraction)\n\n htg_cap_f_of_temp = OpenStudio::Model::CurveCubic.new(model)\n htg_cap_f_of_temp.setCoefficient1Constant(0.758746)\n htg_cap_f_of_temp.setCoefficient2x(0.027626)\n htg_cap_f_of_temp.setCoefficient3xPOW2(0.000148716)\n htg_cap_f_of_temp.setCoefficient4xPOW3(0.0000034992)\n htg_cap_f_of_temp.setMinimumValueofx(-20.0)\n htg_cap_f_of_temp.setMaximumValueofx(20.0)\n\n htg_cap_f_of_flow = OpenStudio::Model::CurveCubic.new(model)\n htg_cap_f_of_flow.setCoefficient1Constant(0.84)\n htg_cap_f_of_flow.setCoefficient2x(0.16)\n htg_cap_f_of_flow.setCoefficient3xPOW2(0.0)\n htg_cap_f_of_flow.setCoefficient4xPOW3(0.0)\n htg_cap_f_of_flow.setMinimumValueofx(0.5)\n htg_cap_f_of_flow.setMaximumValueofx(1.5)\n\n htg_energy_input_ratio_f_of_temp = OpenStudio::Model::CurveCubic.new(model)\n htg_energy_input_ratio_f_of_temp.setCoefficient1Constant(1.19248)\n htg_energy_input_ratio_f_of_temp.setCoefficient2x(-0.0300438)\n htg_energy_input_ratio_f_of_temp.setCoefficient3xPOW2(0.00103745)\n htg_energy_input_ratio_f_of_temp.setCoefficient4xPOW3(-0.000023328)\n htg_energy_input_ratio_f_of_temp.setMinimumValueofx(-20.0)\n htg_energy_input_ratio_f_of_temp.setMaximumValueofx(20.0)\n\n htg_energy_input_ratio_f_of_flow = OpenStudio::Model::CurveQuadratic.new(model)\n htg_energy_input_ratio_f_of_flow.setCoefficient1Constant(1.3824)\n htg_energy_input_ratio_f_of_flow.setCoefficient2x(-0.4336)\n htg_energy_input_ratio_f_of_flow.setCoefficient3xPOW2(0.0512)\n htg_energy_input_ratio_f_of_flow.setMinimumValueofx(0.0)\n htg_energy_input_ratio_f_of_flow.setMaximumValueofx(1.0)\n\n htg_part_load_fraction = OpenStudio::Model::CurveQuadratic.new(model)\n htg_part_load_fraction.setCoefficient1Constant(0.75)\n htg_part_load_fraction.setCoefficient2x(0.25)\n htg_part_load_fraction.setCoefficient3xPOW2(0.0)\n htg_part_load_fraction.setMinimumValueofx(0.0)\n htg_part_load_fraction.setMaximumValueofx(1.0)\n\n htg_coil = OpenStudio::Model::CoilHeatingDXSingleSpeed.new( model,\n always_on,\n htg_cap_f_of_temp,\n htg_cap_f_of_flow,\n htg_energy_input_ratio_f_of_temp,\n htg_energy_input_ratio_f_of_flow,\n htg_part_load_fraction ) \n\n pthp = OpenStudio::Model::ZoneHVACPackagedTerminalHeatPump.new(model,\n always_on, \n fan,\n htg_coil,\n clg_coil,\n supplemental_htg_coil)\n\n pthp.setName(\"#{zone.name} PTHP\")\n pthp.addToThermalZone(zone)\n\n end\n\n \n return true\n \n end" ]
[ "0.7983946", "0.76391083", "0.7635224", "0.7169362", "0.66924226", "0.66924226", "0.6672431", "0.6630611", "0.65984803", "0.6585971", "0.65319055", "0.6481404", "0.6405025", "0.64017195", "0.6333557", "0.62834954", "0.62834954", "0.62834954", "0.6281307", "0.6270175", "0.62411726", "0.6219405", "0.61981004", "0.6195291", "0.6195291", "0.61330277", "0.6107579", "0.60707116", "0.60510164", "0.6016975", "0.6007831", "0.6007831", "0.60001457", "0.5977325", "0.59637624", "0.5961444", "0.59590185", "0.595676", "0.595676", "0.5944699", "0.59336853", "0.5927608", "0.5921924", "0.5917269", "0.5914171", "0.5912747", "0.590211", "0.5871486", "0.5866328", "0.58647937", "0.58474255", "0.5838858", "0.58363855", "0.578834", "0.57726806", "0.5770023", "0.575742", "0.5745794", "0.5741831", "0.5723824", "0.5717452", "0.5712654", "0.5698619", "0.5698198", "0.569785", "0.5689505", "0.5688274", "0.56861794", "0.5674258", "0.5662209", "0.56495583", "0.5648633", "0.56451166", "0.563777", "0.563777", "0.56352866", "0.5622475", "0.5622475", "0.5608525", "0.5608282", "0.55983496", "0.55983496", "0.55983496", "0.55983496", "0.55983496", "0.55983496", "0.55983496", "0.55983496", "0.55983496", "0.55958045", "0.55958045", "0.55958045", "0.5589365", "0.5582615", "0.5569014", "0.55674785", "0.55652153", "0.5565155", "0.5559671", "0.5556153", "0.5549652" ]
0.0
-1
When we want to reference a Position object's coordinates, we must use ship.positions[i].x and ship.positions[i].y
def initialize(x, y) @x = x @y = y @hit = false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ship_coordinates\n @ship_squares.map do |squares|\n squares.map { |square| [square.x, square.y] }\n end\n end", "def get_ship_coords_from_player\n @fleet.each do |ship|\n until ship.valid_coords == true #ship knows if its coords are valid\n orientation = @board.get_player_orientation(ship)\n @board.get_player_coords(orientation, ship, @fleet)\n end\n @board.save_ship_to_board(ship)\n end\n end", "def position\n [@x, @y]\n end", "def coords; {:x => @x, :y => @y} end", "def position\n [x, y]\n end", "def pos\n [posx, posy]\n end", "def position\n\t\t[ @x, @y ]\n\tend", "def location\n [@posX, @posY, @facing]\n end", "def get_ship_coords_automatically\n @fleet.each do |ship|\n # fetch coords for this ship automatically, given fleet and board\n # no return needed, as ship is an object which is updated by ShipCoords\n ShipCoords.new(ship:ship, fleet:@fleet, board:@board)\n @board.save_ship_to_board(ship)\n ship_count = 0\n if @autogenerated == true && ship_count == 4\n $message << \"Here is how your ships are placed. [Enter] to continue. \" unless\n $testing == true # see comment in settings.rb\n @board.show_board_and_get_input unless $testing == true\n end\n ship_count += 1\n end # of this ship\n end", "def position= o\n self.x = o.x\n self.y = o.y\n end", "def place_fleet(pos_list)\n # Try to set all ships on the field\n res = pos_list.inject(true) do |a, l|\n a && @all_ships[l[0]].set!(l[1], l[2], l[3])\n end\n\n # If success, check something???\n res = @all_ships.inject(true) { |a, ship| a && ship.coord } if res\n\n # Remove all ships otherwise\n @all_ships.each { |ship| ship.kill if ship.coord } if !res\n\n res\n end", "def position_init\n raise 'position_init method NotImplemented! Please implement in the correct Ship implementation.'\n end", "def place(coord_array) \n #sets spots array to the coordinates occupied by the ship\n @spots = coord_array.dup \n end", "def weapon_pos\n raise 'weapon_pos method NotImplemented! Must implement in Ship implementation.'\n end", "def create_positions\n (1..GAME_BOARD_LENGTH).each do |y|\n (1..GAME_BOARD_LENGTH).each do |x|\n self.positions.new(x: x, y: y)\n end\n end\n set_ships\n save\n end", "def coordinates\n [@y_location, @x_location]\n end", "def placeShip (shipID, coords, who)\n which_squares = (who == \"me\") ? \"squares\" : \"enemy_squares\"\n transaction do\n coords.each do |i|\n square = self.send(which_squares).find_by_index(i)\n square.ship_id = shipID\n square.save\n end\n end\n end", "def place_ship(ship, vertical, row, col)\n return false unless placable?(ship, vertical,row,col)\n ship.size.times do\n spot(row,col)[:shipid] = ship.id\n vertical ? row += 1 : col += 1\n end\n true\n end", "def place_ships!\n\t\t[\n\t\t\t['T', 2],\n\t\t\t['D', 3],\n\t\t\t['S', 3],\n\t\t\t['B', 4],\n\t\t\t['C', 5]\n\t\t].each do |ship|\n\t\t\tplace_ship(ship[0], ship[1])\n\t\tend\n\tend", "def position\n Vector2.new x, y\n end", "def place(ship, coordinates)\n coordinates.each do |sel_coord|\n @board_hash[sel_coord].place_ship(ship)\n end\n end", "def make\n @spaces.each { |position| position.occupied = true }\n # pp \"made ship: #{@spaces}\"\n end", "def position\n fetch('football.positions')\n end", "def coords\n [x, y]\n end", "def place_ship(ship, board)\n direction = %i[horizontal vertical].sample\n coord = board.cells.keys.sample\n\n generate_coords(ship, direction, coord)\n end", "def position \n\t\treturn @y,@x\n\tend", "def place(ship, starts_at)\n raise ArgumentError, \"That ship has already placed\" if ship.placed?\n for attempt_x in 0..(ship.size_x.to_i - 1)\n for attempt_y in 0..(ship.size_y.to_i- 1)\n copy = test_cell_then_place(ship, attempt_x, attempt_y, starts_at)\n end\n end\n end", "def check_ship(x,y)\n\n # If player guess is not already a hit and the position is occupied by the ship update the hit value from '0' to '1'\n if grid[x][y] != 'X'\n s = ships.detect { |s| s.name == grid[x][y] }\n puts 'Ship hit!!!'\n s.position.each do |p|\n if p[:x] == x and p[:y] == y\n p[:hit] = 1\n end\n end\n\n # If none of the ships hit values is a '0' then ship is sunk\n sink = s.position.detect { |p| p[:hit] == 0 }\n if sink.nil?\n puts 'Ship '+s.name+' was sunk!!'\n end\n else\n puts 'You dont win if you hit the same place multiple times, the try still counts though.'\n end\n\n end", "def place_at(x, y)\n\t\t@x = x\n\t\t@y = y\n\t\tcoords\n\tend", "def position\n V[x, y]\n end", "def populate\n self.start_coordinate_x = rand(11)\n self.start_coordinate_y = rand(11)\n if ship_position == 'vertical'\n self.end_coordinate_x = self.start_coordinate_x\n self.end_coordinate_y = (self.start_coordinate_y + SHIP_SIZE) > MAX_SIZE_BOARD ? (self.start_coordinate_y - SHIP_SIZE) : (self.start_coordinate_y + SHIP_SIZE)\n else\n self.end_coordinate_y = self.start_coordinate_y\n self.end_coordinate_x = (self.start_coordinate_x + SHIP_SIZE) > MAX_SIZE_BOARD ? (self.start_coordinate_x - SHIP_SIZE) : (self.start_coordinate_x + SHIP_SIZE)\n end\n end", "def pos=(pos)\n x, y = pos[0], pos[1]\n step_x, step_y = TABLEAU['indent']['x'], TABLEAU['indent']['y']\n\n piles.each { |pile|\n pile.pos = [x, y]\n x += step_x # Margin between piles along the axis X.\n y2 = 0 # Y position of the first card.\n\n pile.cards.each_with_index do |card, i|\n card.sprite.y += y2\n y2 += step_y # Y axis margin.\n card.face_down unless pile.last_card?(card)\n end\n }\n end", "def pos\r\n { x: @tile.x,\r\n y: @tile.y }\r\n end", "def coords\n Vector[@ob.x, @ob.y, @ob.z]\n end", "def pos\n\t\tif not moved_to.nil? and moved?\n\t\t\tsquare.neighbor( moved_to )\n\t\telse\n\t\t\tsquare\n\t\tend\n\tend", "def updatePosition\n super\n\n Bullet.BulletInstances.each { |bullet|\n if collision?(bullet)\n bullet.destroy\n explode\n end\n }\n\n Ship.ShipInstances.each { |ship|\n if collision?(ship)\n ship.destroy\n explode\n end\n }\n end", "def update_ships\n # A data structure to store the ships in\n\n ships = [\n [\"Brittana\", [\"Brittany P.\", \"Santana L.\"]],\n [\"Faberry\", [\"Quinn F.\", \"Rachel B.\"]],\n [\"Flanamotta\", [\"Rory F.\", \"Sugar\"]],\n [\"Sory\", [\"Rory F.\", \"Sam E.\"]],\n [\"Seblaine\", [\"Sebastian S.\", \"Blaine A.\"]],\n [\"Santofsky\", [\"D. Karofsky\", \"Santana L.\"]],\n [\"Bartie\", [\"Brittany P.\", \"Artie A.\"]],\n [\"Tike\", [\"Mike C.\", \"Tina C.\"]],\n [\"Pezberry\", [\"Santana L.\", \"Rachel B.\"]],\n [\"Pizes\", [\"Lauren Z.\", \"Puck\"]],\n [\"St. Berry\", [\"Jesse sJ.\", \"Rachel B.\"]],\n [\"Kill\", [\"Kurt H.\", \"Will S.\"]],\n [\"Puckurt\", [\"Kurt H.\", \"Puck\"]],\n [\"Artina\", [\"Tina C.\", \"Artie A.\"]],\n [\"Partie\", [\"Puck\", \"Artie A.\"]],\n [\"Blainofskyve\", [\"Blaine A.\", \"D. Karofsky\"]],\n [\"Klaine\", [\"Kurt H.\", \"Blaine A.\"]],\n [\"Hummelberry\", [\"Kurt H.\", \"Rachel B.\"]],\n [\"Furt\", [\"Kurt H.\", \"Finn H.\"]],\n [\"Pinn\", [\"Puck\", \"Finn H.\"]],\n [\"Samcedes\", [\"Sam E.\", \"Mercedes J.\"]],\n [\"Artcedes\", [\"Artie A.\", \"Mercedes J.\"]],\n [\"Finchel\", [\"Finn H.\", \"Rachel B.\"]],\n [\"Puckleberry\", [\"Puck\", \"Rachel B.\"]],\n [\"Wemma\", [\"Will S.\", \"Emma P.\"]]\n ]\n\n ships.each do |ship_data|\n ship = Ship.find_by_name(ship_data[0])\n\n # Make sure the ship doesn't already exist\n if !ship\n\n # create a new ship\n ship = Ship.new()\n ship.name = ship_data[0]\n ship.save\n\n # For each character in the ship\n ship_characters = ship_data[1]\n generate_log(\"Generating New Ship: #{ship_data[0]} between #{ship_data[1]}\")\n ship_characters.each do |ship_character|\n character = generate_character(ship_character)\n # Save the relationship\n relationship = Relationship.new()\n relationship.ship = ship\n relationship.character = character\n relationship.save\n\n end\n else\n ship.update_attributes(:name => ship_data[0])\n ship.save\n generate_log(\"Updating: #{ship_data[0]} between #{ship_data[1]}\")\n\n\n end\n end\nend", "def position\n puts \"X: #{@x_coord}\"\n puts \"Y: #{@y_coord}\"\n puts \"Direction: #{@direction}\"\n end", "def ships\n MyShip.where(\"location ~= POINT(?)\", self.location)\n end", "def place_ship(ship, grid)\n print \"\\n\\nPlace your #{ship.name}:\\n\"\n show_grid(grid, true)\n print_ship(ship)\n print \"\\n\"\n ship.orientation = get_orientation(ship, grid)\n get_and_set_coordinates(ship, grid)\n end", "def ship; end", "def get_coordinates(pos)\n row = (pos / @width) + 1\n col = (pos % @width) + 1\n [row, col]\n end", "def pos=(pos)\n x, y, step_x = pos[0], pos[1], FOUNDATION['indent']\n\n piles.each do |pile|\n pile.pos = [x, y]\n pile.background = Ray::Sprite.new image_path('foundation_bg')\n x += step_x # Margin between piles along the axis X.\n end\n end", "def set_ship(x, y, svalue)\n\t\t rowMark(x, y)\n\t\t return modGrid\n\t\tend", "def position\n return [@x, @y, @heading]\n end", "def add_ship(ship)\n size = ship.size - 1\n\n case ship.orientation\n when \"Right\"\n if ship.start_position.row > @max_row || ship.start_position.row < 1 || ship.start_position.column + size > @max_column || ship.start_position.column < 1\n return false\n end\n\n for i in ship.start_position.column - 1..ship.start_position.column - 1 + size\n if @board[ship.start_position.row - 1][i] =~ /^B/\n return false\n end\n end\n\n return put_ship_on_board(ship)\n when \"Left\"\n if ship.start_position.row > @max_row || ship.start_position.row < 1 || ship.start_position.column > @max_column || ship.start_position.column - size < 1\n return false\n end\n\n for i in (ship.start_position.column - 1).downto(ship.start_position.column - 1 - size)\n if @board[ship.start_position.row - 1][i] =~ /^B/\n return false\n end\n end\n\n return put_ship_on_board(ship)\n when \"Up\"\n if ship.start_position.row > @max_row || ship.start_position.row - size < 1 || ship.start_position.column > @max_column || ship.start_position.column < 1\n return false\n end\n\n for i in (ship.start_position.row - 1).downto(ship.start_position.row - 1 - size)\n if @board[i][ship.start_position.column - 1] =~ /^B/\n return false\n end\n end\n\n return put_ship_on_board(ship)\n when \"Down\"\n if ship.start_position.row + size > @max_row || ship.start_position.row < 1 || ship.start_position.column > @max_column || ship.start_position.column < 1\n return false\n end\n\n for i in ship.start_position.row - 1..ship.start_position.row - 1 + size\n puts i\n if @board[i][ship.start_position.column - 1] =~ /^B/\n return false\n end\n end\n\n return put_ship_on_board(ship)\n else\n puts \"Invalid ship orientation\"\n return false\n end\n end", "def set_player_positions\n self.print_grid\n\n xy = self.ask_for_x_y do\n \"Player 1: Where would you like to place your flag?\"\n end\n\n @player1_x = xy[0]\n @player1_y = xy[1]\n \n xy = self.ask_for_x_y do\n \"Player 2: Where would you like to place your flag?\"\n end\n\n @player2_x = xy[0]\n @player2_y = xy[1]\n end", "def active_ship?(ship_obj)\n @active_pos.has_value?(ship_obj)\n end", "def coordinates\n @coordinates\n end", "def move\n # Stores change in x and y position based off of vel and current x,y\n newX = @x + @vel_x\n newY = @y + @vel_y\n # Prevents ship from exiting bounds in x along the ship's edge\n if newX >= @image.width and newX <= @[email protected] then\n @x += @vel_x\n end\n # Prevents ship from exiting bounds in y along the ship's edge\n if newY >= @image.height and newY <= @[email protected] then\n @y += @vel_y\n end\n # Slows down the ship if no new input is given\n # Lower values for tighter controls\n @vel_x *= 0.50\n @vel_y *= 0.50\n end", "def cal_pos\n x, y = map_location(@grid_x, @grid_y)\n x += @tile_size/2\n y += @tile_size/2\n [x,y]\n end", "def pos\n return Rubygame::Ftor.new(@x,@y)\n end", "def place_ship\n puts\"Your battle ship is 4 squares long.\\nPlease place it on your grid.\\nIt can not be placed diagonally.\\nCo-ordinates could be '2a 3a 4a 5a' \"\n @coordinates_string=gets.chomp\n marker=@coordinates_string.split(\" \")\n marker.each do |x|\n @grid[x]=\" + \"\n end\n end", "def place_ship(x, y, ship, horizontal)\n if horizontal && all_water_in_row?(y, x, x + ship)\n set_horizontal_ship(y, x, x + ship)\n elsif !horizontal && all_water_in_column?(x, y, y + ship)\n set_vertical_ship(x, y, y + ship)\n end\n end", "def initialize( position_x, position_y )\n @x = position_x\n @y = position_y\n end", "def extend_ship(pos, direction = ship_direction, size = nil)\n # this should be an option hash for direction and size\n possible_ship = []\n x, y = pos\n\n if size.nil?\n size = random_ship\n end\n\n if direction == \"N\" && (x - size - 1) >= 0\n (size-1).times do\n x -= 1\n possible_ship << [x, y]\n end\n\n elsif direction == \"S\" && (x + size - 1) <= @grid.length-1\n (size-1).times do\n x += 1\n possible_ship << [x, y]\n end\n\n elsif direction == \"W\" && (y - size - 1) >= 0\n (size-1).times do\n y -= 1\n possible_ship << [x, y]\n end\n\n elsif direction == \"E\" && (y + size - 1) <= @grid.length-1\n (size-1).times do\n y += 1\n possible_ship << [x, y]\n end\n end\n\n if possible_ship.all? {|pos| self[pos].nil?} && possible_ship.length >= 1\n possible_ship.each {|pos| self[pos] = :s}\n return true\n else\n return false\n end\n end", "def update_position\n xsub = find{ |n| n.respond_to?(:position) }\n position = xsub.position if xsub\n end", "def current_pos\n\t\treturn arr = [pos_x, pos_y]\n\tend", "def update\n get_x\n get_y\n end", "def set_ship\n @ship = Ship.find(params[:id])\n end", "def set_ship\n @ship = Ship.find(params[:id])\n end", "def position=(point); end", "def find_ship(x, y, ships)\n\t\t_has_ship = false\n\t\tships.each do |ship|\n\t\t\t_has_ship = ship.is_at(x, y)\n\n\t\t\tif (_has_ship) \n\t\t\t\treturn ship\n\t\t\tend\n\t\tend\n\n\t\tnil\t\t\n\tend", "def clean_positions\n self.x_pos = self.x_pos.strip.to_i.to_s\n self.y_pos = self.y_pos.strip.to_i.to_s\n end", "def at(*coordinates)\n position.coordinates = coordinates\n end", "def place_ships(ships, board)\n placed = []\n rows = board.size\n cols = board.first.size\n\n while ships.any?\n length = ships.first\n orientation = rand(2) == 0 ? 'h' : 'v'\n\n if orientation == 'h'\n height = 1\n width = length\n else\n height = length\n width = 1\n end\n\n x = rand(cols - width)\n y = rand(rows - height)\n ship = Ship.new(x, y, orientation, length)\n\n if ship.coords.none? { |x, y| placed.map(&:coords).flatten(1).include? [x, y] }\n placed << ship\n ships.shift\n end\n end\n\n placed\n end", "def update_position\n DIMS.values.each { |dim| @position[dim] += @velocity[dim] }\n end", "def place_ships_on_the_field ships, field\n\t\tships.each do |ship|\n\t\t\tif ship.to_i == 10 then field[ship] = Symbols::SHIP + ' '\n\t\t\telse field[ship] = Symbols::SHIP\n\t\t\tend\n\t\tend\n\tend", "def remains\n @all_ships.each_with_index.map { |x, i| [i, x.coord, x.len, x.health] }\n end", "def set_ship(ship)\n loop do\n print \"Introduce the initial coordinate of your #{ship.name} ship - x, y: \".blue\n coordinate = $stdin.gets.chomp.split(\",\").map(&:to_i)\n break if valid_coord?(find_cell(coordinate), ship)\n end\n end", "def shoot(coords)\n x = coords[0]\n y = coords[1]\n\n # Check that there is a ship at [x, y]\n if @field[x][y]\n # Check that ship is killed\n if (res = @field[x][y].explode)\n refresh\n \"killed #{res}\"\n else\n 'wounded'\n end\n else\n 'miss'\n end\n end", "def to_gpos\n Point[ self.x, self.y ]\n end", "def move\n @leading_x = coordinate_array[0]\n @leading_y = coordinate_array[1]\n end", "def get_input_to_place(ship)\n\t\tputs \"\"\n\t\tputs \"Place your #{ship.name} (length: #{ship.length})...\"\n\t\tx, y = get_coordinate\n\t\tdirection = get_direction\n\t\treturn [{x: x, y: y}, direction]\n\tend", "def to_coordinates\n\n CGPointMake(self.x.to_coordinates, self.y.to_coordinates)\n end", "def position(y, x)\n [START[0] + (y * SPACING[0]),\n START[1] + (x * SPACING[1])]\n end", "def set_ship_info\n @ship_info = @order_info.ship_info\n end", "def placement x, y, face\n @pos_x = x\n @pos_y = y\n @face = face\n self\n end", "def initialize(grid, x, y)\n @grid = grid\n @x = x\n @y = y\n @ship = nil\n end", "def put_small_ship(row,column)\n verify_small_ship_location(row,column)\n @coords[row][column] = SmallShip.new\n end", "def [](pos)\n x, y = pos.first, pos[1]\n @grid[x][y]\n end", "def initialize(type)\n @type = type\n @coords = [] # placeholder for later construction\n @valid_coords = false # until proven true\n construct_ship_details\n\n end", "def s_coords(attrs)\n height = (attrs['HEIGHT'] || 0).to_i\n width = (attrs['WIDTH'] || 0).to_i\n hpos = (attrs['HPOS'] || 0).to_i\n vpos = (attrs['VPOS'] || 0).to_i\n [hpos, vpos, width, height]\n end", "def test_cell_then_place(ship, attempt_x, attempt_y, starts_at)\n alpha, numb = starts_at.split(\"\")\n coordinates = \"#{get_alpha(get_index(alpha) + attempt_y)}#{numb.to_i + attempt_x}\"\n cells[coordinates].accept ship\n end", "def setposition(x,y)\n\t\t@x = x\n\t\t@y = y\n\tend", "def position\n attributes.fetch(:position)\n end", "def pos\n @pos\n end", "def set_player_ship\n @player_ship = PlayerShip.find(params[:id])\n end", "def ship_addable?(ship)\n\n # first, check if ship origin is within grid\n return :out_of_coords unless ship.x >= 0 && ship.y >= 0\n return :out_of_coords unless ship.x < self.size_x && ship.y < self.size_y\n # second, check if rest of ship is within grid\n if ship.orientation == :horizontal\n return :out_of_coords unless ship.x + ship.length <= self.size_x\n elsif ship.orientation == :vertical\n return :out_of_coords unless ship.y + ship.length <= self.size_y\n else\n # we want program to break if ship doesn't have an orientation\n raise ArgumentError.new(\"must call with ship with location data, ship must be :horizontal or :vertical\")\n end\n # third, check if ship intersects other ships\n self.ships.each { |other_ship| return :intersects_ship unless ship.clears?(other_ship) }\n # otherwise, ship is addable\n :addable\n end", "def put_large_ship(row,column)\n \tverify_large_ship_location(row,column)\n \tprow,stern = LargeShipParts.parts\n @coords[row][column] = prow\n @coords[row][column+1] = stern\n end", "def update_pos(x=0,y=0)\n\n # E.g. for a yet to be hit submarine placed at starting position (0,0) horizontally, pos will be:\n # pos [ {:x => 0, :y => 0, :hit => 0 }, {:x => 1, :y => 0, :hit => 0 } ]\n @pos << {:x => x, :y => y, :hit => 0 }\n\n end", "def update_pos(x=0,y=0)\n\n # E.g. for a yet to be hit submarine placed at starting position (0,0) horizontally, pos will be:\n # pos [ {:x => 0, :y => 0, :hit => 0 }, {:x => 1, :y => 0, :hit => 0 } ]\n @pos << {:x => x, :y => y, :hit => 0 }\n\n end", "def loc\r\n { x: @mapx,\r\n y: @mapy }\r\n end", "def xy\n @geometries.dig(@geometry_index, @coordinates_index)\n end", "def get_current_position\n [@current_X_pos, @current_Y_pos]\n end", "def x\n @position.x\n end", "def ship_at(a_point)\n\tindex = ships.find_index { |ship| ship.a_point_belongs_to_ship(a_point) }\n\tships[index]\n end", "def place_ships\n place_carrier\n place_battleship\n place_destroyer\n place_submarines\n place_patrol_boats\n end", "def initialize(battle_field, x, y)\n @battle_field = battle_field\n @x = x\n @y = y\n @ship = nil\n end", "def update_position(battler)\n sprite = battler.sprite\n self.x = sprite.x\n self.y = sprite.y - sprite.oy\n end", "def initialize\n @x\n @y\n @facing\n @placed = false\n end" ]
[ "0.76592076", "0.6969124", "0.6720254", "0.6709193", "0.6685841", "0.6643278", "0.66182053", "0.6608212", "0.654357", "0.6446469", "0.6413517", "0.6408827", "0.6398969", "0.6392892", "0.6328625", "0.6318411", "0.62878954", "0.62839276", "0.626582", "0.6235921", "0.62311447", "0.6218555", "0.61569154", "0.61490846", "0.61394393", "0.61072797", "0.60687214", "0.60515493", "0.6038171", "0.60182613", "0.601343", "0.60043013", "0.6001202", "0.599947", "0.5985782", "0.5982426", "0.59421724", "0.594134", "0.5939479", "0.5913539", "0.59052944", "0.5901486", "0.58871967", "0.5871732", "0.5861528", "0.5847358", "0.5845039", "0.58436894", "0.5837703", "0.583597", "0.5834021", "0.58293", "0.5825182", "0.5814024", "0.58132887", "0.5791651", "0.57909614", "0.578657", "0.57860994", "0.5775002", "0.5775002", "0.57638747", "0.5762937", "0.5748721", "0.57407635", "0.5738656", "0.57313913", "0.5725501", "0.57204294", "0.5712997", "0.5712311", "0.57111424", "0.5710229", "0.57083327", "0.5706387", "0.5696513", "0.5696385", "0.5691908", "0.5690605", "0.5686423", "0.5680295", "0.5679637", "0.56675017", "0.5662856", "0.56615955", "0.56608784", "0.5648728", "0.5643101", "0.5640808", "0.5636527", "0.56342036", "0.56342036", "0.5630162", "0.56298506", "0.56245416", "0.5624353", "0.56237835", "0.56216663", "0.56200165", "0.56150454", "0.56138587" ]
0.0
-1
Test submitting form with two fields of the same name
def test_post_multival page = @agent.get("http://localhost/form_multival.html") form = page.form_with(:name => 'post_form') assert_not_nil(form) assert_equal(2, form.fields_with(:name => 'first').length) form.fields_with(:name => 'first')[0].value = 'Aaron' form.fields_with(:name => 'first')[1].value = 'Patterson' page = @agent.submit(form) assert_not_nil(page) assert_equal(2, page.links.length) assert_not_nil(page.link_with(:text => 'first:Aaron')) assert_not_nil(page.link_with(:text => 'first:Patterson')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_submit_on_form\n page = @agent.get(\"http://localhost/form_multival.html\")\n form = page.form_with(:name => 'post_form')\n\n assert_not_nil(form)\n assert_equal(2, form.fields_with(:name => 'first').length)\n\n form.fields_with(:name => 'first')[0].value = 'Aaron'\n form.fields_with(:name => 'first')[1].value = 'Patterson'\n\n page = form.submit\n\n assert_not_nil(page)\n\n assert_equal(2, page.links.length)\n assert_not_nil(page.link_with(:text => 'first:Aaron'))\n assert_not_nil(page.link_with(:text => 'first:Patterson'))\n end", "def test_get_multival\n page = @agent.get(\"http://localhost/form_multival.html\")\n form = page.form_with(:name => 'get_form')\n\n assert_not_nil(form)\n assert_equal(2, form.fields_with(:name => 'first').length)\n\n form.fields_with(:name => 'first')[0].value = 'Aaron'\n form.fields_with(:name => 'first')[1].value = 'Patterson'\n\n page = @agent.submit(form)\n\n assert_not_nil(page)\n\n assert_equal(2, page.links.length)\n assert_not_nil(page.link_with(:text => 'first:Aaron'))\n assert_not_nil(page.link_with(:text => 'first:Patterson'))\n end", "def test_validinput1\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219') # Find the name field\n element.send_keys(\"Michael\")\n element = @driver.find_element(:id,'group_310473641_1') # Select the \"Yes\" checkbox\n element.click\n element.submit\n element = @driver.find_element(:class,'ss-resp-message')\n assert_equal(element.text,\"Your response has been recorded.\")\n end", "def test_validinput2\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219') # Find the name field\n element.send_keys(\"Michael\")\n element = @driver.find_element(:id,'group_310473641_1') # Select the \"Yes\" checkbox\n element.click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id => 'entry_262759813')).select_by :text, 'JUnit' # From the dropdown, select \"JUnit\"\n element = @driver.find_element(:id,'entry_649813199')\n element.send_keys(\"Some random text here.\") # Enter some text in the text area\n element.submit\n element = @driver.find_element(:class,'ss-resp-message') \n assert_equal(element.text,\"Your response has been recorded.\") # Check if on the submit page, the message displayed is the one expected\n end", "def test_invalidinput2\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219')\n element.send_keys(\"Michael\") # Valid value for question 1\n element.submit # Submit without valid input for question 2\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[2]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 2 shows up\n end", "def submit_without_clicking_button\n path = self.action.blank? ? self.uri : self.action # If no action attribute on form, it submits to the same URI where the form was displayed\n params = {}\n fields.each {|field| params[field.name] = field.value unless field.value.nil? || field.value == [] || params[field.name] } # don't submit the nils, empty arrays, and fields already named\n \n # Convert arrays and hashes in param keys, since test processing doesn't do this automatically\n params = ActionController::UrlEncodedPairParser.new(params).result\n @testcase.make_request(request_method, path, params, self.uri, @xhr)\n end", "def test_invalidinput1 \n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219')\n element.submit # Submit without entering anything on the page\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[1]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 1 shows up\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[2]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 2 shows up\n end", "def check_server_form\n has_element(\"input#bigbluebutton_server_name\",\n { :name => 'bigbluebutton_server[name]', :type => 'text' })\n has_element(\"input#bigbluebutton_server_url\",\n { :name => 'bigbluebutton_server[url]', :type => 'text' })\n has_element(\"input#bigbluebutton_server_secret\",\n { :name => 'bigbluebutton_server[secret]', :type => 'text' })\n has_element(\"input#bigbluebutton_server_version\",\n { :name => 'bigbluebutton_server[version]', :type => 'text' })\n has_element(\"input#bigbluebutton_server_slug\",\n { :name => 'bigbluebutton_server[slug]', :type => 'text' })\n has_element(\"label\", { :for => 'bigbluebutton_server_name' })\n has_element(\"label\", { :for => 'bigbluebutton_server_url' })\n has_element(\"label\", { :for => 'bigbluebutton_server_secret' })\n has_element(\"label\", { :for => 'bigbluebutton_server_version' })\n has_element(\"label\", { :for => 'bigbluebutton_server_slug' })\n has_element(\"input\", { :name => 'commit', :type => 'submit' })\n end", "def click_submit\n end", "def auto_submit?\n false\n end", "def submit_button?(button_name); end", "def test_field(field, value, error = false)\n field.set value\n field.trigger 'blur'\n\n no_php_js_errors\n\n if error\n @page.wait_for_error_message_count(1)\n should_have_form_errors(@page)\n should_have_error_text(field, error)\n else\n @page.wait_for_error_message_count(0)\n should_have_no_form_errors(@page)\n should_have_no_error_text(field)\n end\n end", "def test_submit_signup\n post :submit_signup, { :create_password2 =>\"freddy\", :create_username =>\"fred\", :create_password => \"freddy1\", :create_email =>\"[email protected]\" }\n assert_response :bad_request\n assert_equal \"Passwords do not match\", @response.body\n assert_nil session[:user]\n\n post :submit_signup, { :create_password2 =>\"freddy\", :create_username =>\"fred\", :create_password => \"freddy\", :create_email =>\"[email protected]\" }\n assert_response :success\n assert_equal 'fred', session[:user][:username]\n end", "def test_create_observation\n requires_login(:create_observation)\n assert_form_action(:action => 'create_observation', :approved_name => '')\n end", "def test_create_observation\n requires_login(:create_observation)\n assert_form_action(:action => 'create_observation', :approved_name => '')\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def test_create_failure\n post :new, :grape => { :name => \"\", }\n assert_response :success #success of HTTP, not success of registration process\n assert_template \"new\"\n #test display of error messages\n assert_tag \"div\", :attributes => { :id => \"errorExplanation\",\n :class => \"errorExplanation\"}\n #test that each form field has at least one error diplayed\n assert_tag \"li\", :content => /Name/\n \n #test to see that the input fields are being wrapped with the correct div\n error_div = { :tag => \"div\", :attributes => { :class => \"fieldWithErrors\"}}\n \n assert_tag \"input\",\n :attributes => { :name => \"grape[name]\",\n :value => \"\"},\n :parent => error_div\n end", "def verify_component_before_saving(fieldname)\n if(fieldname == \"Formatted content\")\n @browser.find_elements(:xpath => \"//strong[contains(text(), 'New HTML Markup')]\").should have_at_least(1).items #\"#{fieldname} is not present in the Form Builder space area.\")\n elsif(fieldname == \"Page break\" || fieldname == \"Hidden field\")\n @browser.find_elements(:xpath => \"//div[contains(text(), '#{fieldname}')]\").should have_at_least(1).items #\"#{fieldname} is not present in the Form Builder space area.\")\n elsif(fieldname == \"Fieldset\")\n @browser.find_elements(:xpath => \"//span[contains(text(), '#{fieldname}')]\").should have_at_least(1).items #\"#{fieldname} is not present in the Form Builder space area.\")\n else\n @browser.find_elements(:xpath => \"//label[contains(text(), '#{fieldname}')]\").should have_at_least(1).items #\"#{fieldname} is not present in the Form Builder space area.\")\n end\n end", "def validate_fields\n expect(@browser.textfield(:id => 'lbl_val_1').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_val_2').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_val_3').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_val_4').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_val_5').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_ttl_val').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_1').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_2').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_4').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_5').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_6').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_ttl_val').present?).to eq(true)\n end", "def equal_pair(key, request)\n if @event[\"required\"][key] == request[\"object_attributes\"][key] || event[\"required\"][key] == \"\"\n true\n else\n false\n end\n end", "def submit_all_blank_and_validate\n blank_dates\n click_on 'Add'\n validate_fields(@fields)\n end", "def assert_submit_button(button_label = nil)\n if button_label\n assert_tag \"input\", :attributes => { :type => \"submit\",\n :value => button_label}\n else\n assert_tag \"input\", :attributes => { :type => \"submit\" }\n end\n end", "def assert_same_text_input(attribute, value)\n assert_equal(\n %Q[<input type=\"text\" value=\"#{value}\" name=\"product[#{attribute}]\" id=\"product_#{attribute}\" />],\n @template.text_field(:product, attribute, object: @localized)\n )\n end", "def submit\r\n assert_exists\r\n submit_form \r\n @o.wait\r\n end", "def submit_form\n click_button 'submit'\n end", "def submitIncidentForm(page, startYear, endYear)\n form = page.form_with(:action => \"search.php\");\n form['start_year'] = startYear;\n form['end_year'] = endYear;\n page = page.form_with(:action => \"search.php\").click_button();\nend", "def test_create_failure\n post :new, :appellation => { :name => \"\",\n :apptype_id => 1 }\n assert_response :success #success of HTTP, not success of create process\n assert_template \"new\"\n #test display of error messages\n assert_tag \"div\", :attributes => { :id => \"errorExplanation\",\n :class => \"errorExplanation\"}\n #test that each form field has at least one error diplayed\n assert_tag \"li\", :content => /Name/\n \n #test to see that the input fields are being wrapped with the correct div\n error_div = { :tag => \"div\", :attributes => { :class => \"fieldWithErrors\"}}\n \n assert_tag \"input\",\n :attributes => { :name => \"appellation[name]\",\n :value => \"\"},\n :parent => error_div\n end", "def test_edit_name_get\n name = names(:coprinus_comatus)\n params = { id: name.id.to_s }\n requires_login(:edit, params)\n assert_form_action(action: :update, id: name.id.to_s)\n assert_select(\"form #name_icn_id\", { count: 1 },\n \"Form is missing field for icn_id\")\n end", "def expect_fields_to_be_blank\n expect(page).to have_field(\"Email\", with: \"\", type: \"email\")\n expect(find_field(\"Password\", type: \"password\").value).to be_nil\n expect(find_field(\"Password confirmation\", type: \"password\").value).to be_nil\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def submit(form_name)\n Praline::browser.find_element(:name, form_name).submit\n end", "def test_create_naming_get\n obs = observations(:coprinus_comatus_obs)\n params = {\n :id => obs.id.to_s\n }\n requires_login(:create_naming, params)\n assert_form_action(:action => 'create_naming', :approved_name => '', :id => obs.id.to_s)\n end", "def test_new\n login(\"rolf\")\n get(:new)\n assert_select(\n \"form[action='#{herbaria_path}'][method='post']\", { count: 1 },\n \"'new' action should render a form that posts to #{herbaria_path}\"\n )\n end", "def param_posted?(symbol)\n request.post? and (not params[symbol].blank?)\n end", "def test_put_form_field\n filename = 'test_multi_pages.docx'\n remote_name = 'TestPutFormField.docx'\n dest_name = remote_test_out + remote_name\n body = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true,\n :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => '123',\n :TextInputFormat => 'UPPERCASE'})\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_common_folder + filename, \"r\").read\n @storage_api.put_create st_request\n\n request = PutFormFieldRequest.new remote_name, body, remote_test_folder + test_folder, :dest_file_name => dest_name, :node_path => 'sections/0/paragraphs/0'\n result = @words_api.put_form_field request\n assert_equal 200, result.code\n end", "def test_new\n login\n get(:new)\n\n assert_response(:success)\n assert_head_title(:create_glossary_term_title.l)\n\n ESSENTIAL_ATTRIBUTES.each do |attr|\n assert_select(\"form [name='glossary_term[#{attr}]']\", { count: 1 },\n \"Form should have one field for #{attr}\")\n end\n assert_select(\"input#upload_image\", { count: 1 },\n \"Form should include upload image field\")\n end", "def submit(opts={})\n msg = \"Submit button not found in form\"\n selector = 'input[type=\"submit\"], input[type=\"image\"], button[type=\"submit\"]'\n if @submit_value\n msg << \" with a value of '#{@submit_value}'\"\n selector.gsub!(/\\]/, \"][value=#{@submit_value}]\")\n end\n raise MissingSubmitError, msg unless tag.select(selector).any?\n fields_hash.update(opts)\n submit_without_clicking_button\n end", "def test_ID_25841_edit_profile_i_am_a_optional\n login_as_user1\n go_to_edit_profile_page\n verify_i_am_a_text_optional\n verify_text_can_be_entered_saved_on_i_am_a_textfield\n end", "def test_uniqueness_of\n # Create a page named 'test' and save it\n page1 = new_page()\n assert page1.save\n\n # Duplicate page name won't work\n page2 = new_page()\n assert !page2.save\n assert page2.errors.on(:name)\n\n # Fix name and it should work\n page2.name = 'test2'\n assert page2.save\n end", "def test_create_naming_get\n obs = observations(:coprinus_comatus_obs)\n params = {\n :id => obs.id.to_s\n }\n requires_login(:create_naming, params)\n assert_form_action(:action => 'create_naming', :approved_name => '')\n end", "def check_room_form\n has_element(\"input#bigbluebutton_room_name\",\n { :name => 'bigbluebutton_room[name]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_meetingid\",\n { :name => 'bigbluebutton_room[meetingid]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_private\",\n { :name => 'bigbluebutton_room[private]', :type => 'checkbox' })\n has_element(\"input#bigbluebutton_room_attendee_key\",\n { :name => 'bigbluebutton_room[attendee_key]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_moderator_key\",\n { :name => 'bigbluebutton_room[moderator_key]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_welcome_msg\",\n { :name => 'bigbluebutton_room[welcome_msg]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_logout_url\",\n { :name => 'bigbluebutton_room[logout_url]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_dial_number\",\n { :name => 'bigbluebutton_room[dial_number]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_max_participants\",\n { :name => 'bigbluebutton_room[max_participants]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_external\",\n { :name => 'bigbluebutton_room[external]', :type => 'checkbox' })\n has_element(\"input#bigbluebutton_room_slug\",\n { :name => 'bigbluebutton_room[slug]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_voice_bridge\",\n { :name => 'bigbluebutton_room[voice_bridge]', :type => 'text' })\n has_element(\"label\", { :for => 'bigbluebutton_room_name' })\n has_element(\"label\", { :for => 'bigbluebutton_room_meetingid' })\n has_element(\"label\", { :for => 'bigbluebutton_room_private' })\n has_element(\"label\", { :for => 'bigbluebutton_room_attendee_key' })\n has_element(\"label\", { :for => 'bigbluebutton_room_moderator_key' })\n has_element(\"label\", { :for => 'bigbluebutton_room_welcome_msg' })\n has_element(\"label\", { :for => 'bigbluebutton_room_logout_url' })\n has_element(\"label\", { :for => 'bigbluebutton_room_dial_number' })\n has_element(\"label\", { :for => 'bigbluebutton_room_max_participants' })\n has_element(\"label\", { :for => 'bigbluebutton_room_external' })\n has_element(\"label\", { :for => 'bigbluebutton_room_slug' })\n has_element(\"label\", { :for => 'bigbluebutton_room_voice_bridge' })\n has_element(\"input\", { :name => 'commit', :type => 'submit' })\n end", "def form_submit\r\n form.submit\r\n @form = nil\r\nend", "def test_values_unique\n\n #Arrange\n @user3 = User.new\n @user4 = User.new\n\n # Act\n @user3.name = \"fede\"\n @user3.surname = \"guti\"\n @user3.username = \"fede3\"\n @user3.email = \"[email protected]\"\n @user3.password = \"123456789\"\n\n @user4.name = \"fede\"\n @user4.surname = \"guti\"\n @user4.username = \"luca\"\n @user4.email = \"[email protected]\"\n @user4.password = \"123456789\"\n\n\n # Assert\n @user3.save\n @user4.save\n all_ok = assert_equal @user3.valid? && @user4.valid? , true\n\n # Act\n @user4.email = \"[email protected]\"\n @user4.save\n\n # Assert\n email_check = assert_equal @user4.valid?, false\n\n # Act\n @user4.email = \"[email protected]\"\n @user4.username = \"fede3\"\n @user4.save\n\n # Assert\n user_check = assert_equal @user4.valid?, false\n\n # Assert\n assert_equal (all_ok || email_check || user_check) , true\n\n end", "def fill_form_and_submit(agent, creds, url, category, tech, data)\n case category\n when 'extensions'\n puts \"uploading #{category.chop}: #{data[category.chop].to_s}\" unless $quiet\n cat_page = get_page(agent, creds, url + CONFIG, {display: category, tech_hardware: 'custom_custom'})\n frm = cat_page.form('frm_extensions')\n when 'trunks'\n puts \"uploading #{category.chop}: #{data['trunk_name'].to_s}\" unless $quiet\n cat_page = get_page(agent, creds, url + CONFIG, {display: category, tech: tech.upcase})\n frm = cat_page.form('trunkEdit')\n end\n abort 'error: form not found' unless frm\n\n if $debug\n frm.fields.each { |field| puts \"send_sever_request: #{field.name}: #{field.value}\" }\n frm.checkboxes.each { |chkbx| puts \"send_sever_request: #{chkbx.name}: #{chkbx.value}\" }\n frm.radiobuttons.each { |rdb| puts \"send_sever_request: #{rdb.name}: #{rdb.value}\" if rdb.checked }\n end\n # Fill in the form, and submit it!\n data.each { |key, val| frm[key] = val }\n frm.submit\nend", "def submit\n frm.button(:value=>\"Submit\").click\n SubmissionConfirmation.new(@browser)\n end", "def submit\n frm.button(:value=>\"Submit\").click\n SubmissionConfirmation.new(@browser)\n end", "def text_field?(field_name); end", "def sign_in_and_play\n visit('/')\n fill_in :p1_name, with: 'Pavi'\n fill_in :p2_name, with: 'Ash'\n click_button 'Submit'\nend", "def test_submit\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: SAMPLE_UDPRN, quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end", "def submit?\n self.type == :submit\n end", "def test_delete_form_test_with_multiliner_name()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\\\\nnouman\",\"field\":\"QA\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_form(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def should_see_new_song_fields\n expect(page).to have_field(\"artist\")\n expect(page).to have_field(\"title\")\n expect(page).to have_selector(\"#add_song_button\")\n end", "def test_edit_naming_get\n nam = namings(:coprinus_comatus_naming)\n params = {\n :id => nam.id.to_s\n }\n requires_user(:edit_naming, [\"observer\", \"show_observation\"], params)\n assert_form_action(:action => 'edit_naming', :approved_name => nam.text_name, :id => nam.id.to_s)\n end", "def test_text_field\n _erbout = ''\n \n uni_form_for(:user, @user) do |f|\n f.fieldset do\n _erbout.concat f.text_field(:first_name)\n end\n end\n \n expected = <<-html\n <form action=\"http://www.example.com\" method=\"post\" class=\"uniForm\">\n <fieldset class=\"blockLabels\">\n <div class=\"ctrlHolder\">\n <label for=\"user_first_name\">First name</label>\n <input name=\"user[first_name]\" size=\"30\" type=\"text\" class=\"textInput\" id=\"user_first_name\" value=\"Marcus\"/>\n </div>\n </fieldset>\n </form>\n html\n \n assert_dom_equal expected, _erbout\n end", "def assert_text_field(*args)\n options = args.extract_options!\n assert_select \"input[type=text][name=?]\", extract_name(args)\n end", "def param_posted?(symbol)\n request.post? and params[symbol]\n end", "def param_posted?(symbol)\n request.post? and params[symbol]\n end", "def param_posted?(symbol)\n request.post? and params[symbol]\n end", "def param_posted?(symbol)\n request.post? and params[symbol]\n end", "def hidden_field?(field_name); end", "def validate_form(_formdata: {})\n true # Futureuse\nend", "def change_submit_button(fieldname, button_name)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n wait.until { @browser.find_element(:xpath => @webformmgr.fieldset_label(fieldname)) }.click\n wait.until { @browser.find_element(:xpath => @webformmgr.properties_link) }.click\n temp = wait.until { @browser.find_element(:xpath => \"//input[@id='edit-submit-button']\") }\n temp.clear\n temp.send_keys(button_name)\n wait.until { @browser.find_element(:xpath => @webformmgr.fieldset_label(button_name)) }\n return button_name\n end", "def test_edit_naming_get\n nam = namings(:coprinus_comatus_naming)\n params = {\n :id => nam.id.to_s\n }\n requires_user(:edit_naming, [\"observer\", \"show_observation\"], params)\n assert_form_action(:action => 'edit_naming', :approved_name => nam.text_name)\n end", "def test_submit_rent\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: '123456',\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: '123456', quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end", "def submit_for_grading\n frm.button(:value=>\"Submit for Grading\").click\n ConfirmSubmission.new(@browser)\n end", "def submit; end", "def test_strips_form_inputs\n f = BasicForm.new(:form => { :age => \" 3 \\r\\n\", :email => ' [email protected] '})\n assert_equal 3, f.age\n assert_equal '[email protected]', f.email\n end", "def test_allow_dynamic_form_fields()\n # Parameters for the API call\n name = 'farhan'\n\n # dictionary for optional form parameters\n optional_form_parameters = {}\n optional_form_parameters['field'] = 'QA'\n\n # Perform the API call through the SDK function\n result = @controller.allow_dynamic_form_fields(name, _field_parameters: optional_form_parameters)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def update_same_fields? model, method\n intersection = fields_from_model(model).map(&:to_s) & fields_from_model_method(model, method).map(&:to_s)\n intersection.present?\n end", "def edit_webform2(fieldnames)\n fieldnames.each {|fieldname|\n element_id = @browser.find_element(:xpath => \"#{@webformmgr.fieldset_label(fieldname)}\").attribute(\"for\")\n class_name = @browser.find_element(:xpath => \"//*[@id='#{element_id}']\").attribute(\"class\")\n case class_name\n when 'form-text'\n self.edit_text_field(element_id, val = \"test\")\n when 'form-textarea'\n self.edit_text_field(element_id, val = \"testing text\")\n when 'email form-text'\n self.edit_text_field(element_id, val = \"[email protected]\")\n when 'form-select'\n self.edit_dropdown_field(element_id, val = \"test\")\n when 'form-checkboxes'\n self.edit_checkbox_field(element_id, val = [\"test\", \"one\"])\n when 'form-radios'\n self.edit_radio_field(element_id, val = \"test\")\n else\n Log.logger.info(\"This #{class_name} is not valid class, therefore can't be edited.\")\n end\n }\n end", "def test_ID_25841_edit_profile_i_am_a_optional\n login_as_user1\n go_to_edit_profile_page\n verify_i_am_a_text_optional\n verify_text_can_be_entered_saved_on_i_am_a\n end", "def verify_component_after_saving(fieldname)\n if(fieldname == \"Page break\")\n element_id = \"//input[@id='edit-next']\"\n self.check_element_presence_nextpage(element_id, fieldname)\n elsif (fieldname == \"Hidden field\")\n element_id = \"//input[@type = 'hidden' and @value = '' and contains(@name, 'submitted')]\"\n self.check_element_presence_nextpage(element_id, fieldname)\n elsif (fieldname == \"Formatted content\")\n element_id = \"//strong[contains(text(), 'New HTML Markup')]\"\n self.check_element_presence_nextpage(element_id, fieldname)\n else\n element_id = \"//*[contains(text(), '#{fieldname}')]\"\n self.check_element_presence_nextpage(element_id, fieldname)\n end\n end", "def verify_options_settings(fieldname, remove_options, change_options, new_options, default_options)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n wait.until { @browser.find_element(:xpath => \"//label[contains(text(), '#{fieldname}')]\") }\n class_name = @browser.find_element(:xpath => \"//label[contains(text(), '#{fieldname}')]/following-sibling::*[1]\").attribute(\"class\")\n if class_name == \"form-select\"\n removed_options, added_options = configure_options_test(remove_options, change_options, new_options)\n removed_options.each do |rem|\n @browser.find_elements(:xpath => \"//option[text()='#{rem}']\").should have(0).items\n end\n added_options.each do |new|\n @browser.find_elements(:xpath => \"//option[text()='#{new}']\").should have_at_least(1).items\n end\n Log.logger.info \"default_options: #{default_options.inspect}\"\n @browser.find_element(:xpath => \"//option[text()='#{default_options[0]}']\").should be_selected\n elsif class_name == \"form-checkboxes\" || class_name == \"form-radios\"\n removed_options, added_options = configure_options_test(remove_options, change_options, new_options)\n removed_options.each do |rem|\n @browser.find_elements(:xpath => \"//label[contains(text(), '#{rem}')]\").should have(0).items\n end\n added_options.each do |new|\n @browser.find_elements(:xpath => \"//label[contains(text(), '#{new}')]\").should have_at_least(1).items\n end\n default_options.each do |default|\n @browser.find_elements(:xpath => \"//label[contains(text(), '#{default}')]/../input[@checked = 'checked']\").should have_at_least(1).items\n end\n else\n Log.logger.info(\"Following class '#{class_name}' is not a part of test for Webform.\")\n end\n end", "def test_should_flag_ON_INIT_PAGE_NEXT_when_clicking_next_on_valid_init_page\n post :init, :user=>{:first_name=>field_first_name, :last_name=>field_last_name}, :commit=>:next\n #assert_redirected_to :action=>second_page\n assert assigns['on_init_page_next']\n end", "def click_submit_button\n\t\tsubmit_button.click\n\tend", "def assert_text_field(model, *attributes)\n attributes.each do |attribute|\n assert_select \"input[type=text][name=?]\",\n \"#{model.to_s}[#{attribute.to_s}]\"\n end\n end", "def select_and_submit(page, form_name, select_name, selection)\r\n option = nil\r\n form = page.form(form_name)\r\n unless form.nil?\r\n selector = form.field(select_name)\r\n unless selector.nil?\r\n option = select_option(selector, selection)\r\n form.submit\r\n end\r\n end\r\n return option\r\n end", "def fill_in_fields_and_submit(email, password, password_confirmation)\n @session.fill_in(@first_name_field, :with => @first_name_value)\n @session.fill_in(@last_name_field, :with => @last_name_value)\n @session.fill_in(@email_field, :with => email)\n @session.fill_in(@phone_one_key, :with => @phone_one_value)\n @session.fill_in(@phone_two_key, :with => @phone_two_value)\n @session.fill_in(@phone_three_key, :with => @phone_three_value)\n @session.fill_in(@user_extension_field, :with => @user_extension_value)\n @session.fill_in(@password_field, :with => password)\n @session.fill_in(@password_confirmation_field, :with => password_confirmation)\n @session.find(@form_submit_button_name).click\n end", "def test_delete_form_test_with_blank_name_field()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\" \",\"field\":\" \"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_form(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def test_update_form_field\n remote_file_name = 'TestUpdateFormField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/FormFilled.docx'), remote_data_folder + '/' + remote_file_name\n\n request_form_field = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true, :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => 'No name'})\n request = UpdateFormFieldRequest.new(name: remote_file_name, index: 0, form_field: request_form_field, node_path: 'sections/0', folder: remote_data_folder, dest_file_name: remote_test_out + '/' + remote_file_name)\n\n result = @words_api.update_form_field(request)\n assert_equal false, result.nil?\n end", "def in_submit attrs = nil\n attrs ||= Hash.new\n a_droite = attrs.delete(:right)\n au_centre = attrs.delete(:center)\n f = \"\".in_input(attrs.merge(:value => self, :type => 'submit'))\n # Valeur retournée\n case true\n when a_droite then f.in_div(class: 'right')\n when au_centre then f.in_div(class: 'center')\n else f\n end\n end", "def visit_questionnaire_submission_page questionnaire\n visit submission_questionnaire_path(questionnaire)\n\n assert page.has_content?(questionnaire.questionnaire_fields.first.title)\n assert page.has_content?(\"Submit questionnaire\")\nend", "def test_post_form_field\n filename = 'FormFilled.docx'\n remote_name = 'TestPostFormField.docx'\n dest_name = remote_test_out + remote_name\n index = 0\n body = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true,\n :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => ''})\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, \"r\").read \n @storage_api.put_create st_request\n\n request = PostFormFieldRequest.new remote_name, body, index, remote_test_folder + test_folder, :dest_file_name => dest_name, :node_path => 'sections/0'\n result = @words_api.post_form_field request\n assert_equal 200, result.code\n end", "def test_doesnt_strips_non_form_inputs\n f = BasicForm.new(:age => \" 3 \\r\\n\", :email => ' [email protected] ')\n assert_equal \" 3 \\r\\n\", f.age\n assert_equal ' [email protected] ', f.email\n end", "def test_edit_institution_with_duplicate_name\n number_of_institution = Institution.count\n post :update,:id => institutions(:institution0).id, :institution => { :name => institutions(:institution1).name}\n assert_equal Institution.count, number_of_institution\n assert_equal 1, Institution.count(:all, :conditions => \"name = 'Test state university'\");\n assert Institution.find(:all, :conditions => \"name = 'Computer Science'\").count == 0;\n end", "def spoofForm(val)\n @deltaflag = false\n @form = val\n end", "def select_and_submit(page, form_name, select_name, selection)\n option = nil\n form = page.form(form_name)\n unless form.nil?\n selector = form.field(select_name)\n unless selector.nil?\n option = select_option(selector, selection)\n form.submit\n end\n end\n return option\n end", "def submit!\n\tend", "def onSubmit(request, response, form, errors)\r\n return form\r\n end", "def onSubmit(request, response, form, errors)\r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def being_submitted?(item = nil)\n # noinspection RubyMismatchedArgumentType\n super(item || self)\n end", "def onSubmit(request, response, form, errors)\r\n\treturn form\r\n end", "def check_has_form(page)\n inputs = page.search('input')\n inputs.each do |input|\n attrs = input.attributes.select { |k,v| v.value =~ /^name|login|password|username|^email$$/i } \n go_ahead = (!attrs.compact.empty?)\n if go_ahead\n puts \"I think I found the login url for #{page.uri.to_s}\"\n login_page = page\n puts \">> #{login_page.uri}\\n\\n\"\n return true\n end\n\n \n end\n return false\nend" ]
[ "0.69689614", "0.67568964", "0.6102426", "0.6010265", "0.59461796", "0.5911001", "0.5732697", "0.5601203", "0.55539143", "0.5479292", "0.54697484", "0.5452993", "0.54526776", "0.5413721", "0.5413721", "0.54122156", "0.5398371", "0.5380142", "0.5380108", "0.53337073", "0.5326929", "0.53230053", "0.5317807", "0.5302551", "0.53007525", "0.52980405", "0.5271681", "0.52522004", "0.5252149", "0.5241482", "0.5241482", "0.5241482", "0.5241482", "0.52401143", "0.5221019", "0.5207176", "0.51926666", "0.5186489", "0.51825833", "0.51791143", "0.5173234", "0.5169924", "0.5164932", "0.5159139", "0.5153508", "0.5146535", "0.5146522", "0.5135049", "0.5135049", "0.5127119", "0.51198906", "0.51177657", "0.5107817", "0.5096985", "0.50886387", "0.50868297", "0.5085102", "0.5080037", "0.50408036", "0.50408036", "0.50408036", "0.50408036", "0.50285614", "0.502119", "0.4994445", "0.4985296", "0.49836", "0.49815598", "0.49687585", "0.49585325", "0.49518114", "0.4951172", "0.49451795", "0.4939532", "0.49287596", "0.49266037", "0.49191055", "0.49162057", "0.4915036", "0.49139437", "0.490629", "0.4903954", "0.48997498", "0.48951837", "0.4890699", "0.48843455", "0.48759624", "0.48699918", "0.4867278", "0.48626143", "0.485697", "0.48569444", "0.48569444", "0.48548186", "0.48548186", "0.48548186", "0.48548186", "0.4841524", "0.4841004", "0.48381606" ]
0.6770113
1
Test calling submit on the form object
def test_submit_on_form page = @agent.get("http://localhost/form_multival.html") form = page.form_with(:name => 'post_form') assert_not_nil(form) assert_equal(2, form.fields_with(:name => 'first').length) form.fields_with(:name => 'first')[0].value = 'Aaron' form.fields_with(:name => 'first')[1].value = 'Patterson' page = form.submit assert_not_nil(page) assert_equal(2, page.links.length) assert_not_nil(page.link_with(:text => 'first:Aaron')) assert_not_nil(page.link_with(:text => 'first:Patterson')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form_submit\r\n form.submit\r\n @form = nil\r\nend", "def submit\r\n assert_exists\r\n submit_form \r\n @o.wait\r\n end", "def submit_form\n @page = @form.submit\n end", "def submit_form\n click_button 'submit'\n end", "def click_submit\n end", "def submit; end", "def submit_form(form)\n @agent.submit(form)\n end", "def submit\n end", "def submit\n frm.button(:value=>\"Submit\").click\n SubmissionConfirmation.new(@browser)\n end", "def submit\n frm.button(:value=>\"Submit\").click\n SubmissionConfirmation.new(@browser)\n end", "def submit?\n self.type == :submit\n end", "def submit!\n\tend", "def submit_without_clicking_button\n path = self.action.blank? ? self.uri : self.action # If no action attribute on form, it submits to the same URI where the form was displayed\n params = {}\n fields.each {|field| params[field.name] = field.value unless field.value.nil? || field.value == [] || params[field.name] } # don't submit the nils, empty arrays, and fields already named\n \n # Convert arrays and hashes in param keys, since test processing doesn't do this automatically\n params = ActionController::UrlEncodedPairParser.new(params).result\n @testcase.make_request(request_method, path, params, self.uri, @xhr)\n end", "def submit\n # we are authenticated from params or session\n if authenticated?\n @test_instance = submission_instance\n submission_save\n # params authentication failed. Redirect (html) or report failure (JSON)\n else\n submission_fail_authentication\n end\n end", "def onSubmit(request, response, form, errors)\r\n return form\r\n end", "def onSubmit(request, response, form, errors)\r\n return form\r\n end", "def onSubmit(request, response, form, errors)\r\n\treturn form\r\n end", "def submit(form_name)\n Praline::browser.find_element(:name, form_name).submit\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def submit\n click_button 'SEND'\n self\n end", "def onSubmit(request, response, form, errors) \n return form\n end", "def click_submit_button\n\t\tsubmit_button.click\n\tend", "def on_submit\n controller.send(@form_name+'_submit', @model) unless controller.nil?\n clear\n end", "def submits; end", "def submit_for_grading\n frm.button(:value=>\"Submit for Grading\").click\n ConfirmSubmission.new(@browser)\n end", "def i_submit(form, args = {})\n assert_not_nil form, __last_because + \"(form has not been found)\"\n raise ArgumentError, \"i_submit requires a Tag instance, #{form.inspect} received\" unless Tag===form\n i_invoke(form[:action], args)\n end", "def submit\n\t\tif save\n\t\t\tsubmit_request\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def submit(form, button = T.unsafe(nil), headers = T.unsafe(nil)); end", "def submit\n frm.button(:value=>\"Submit\").click\n @@file_number=0\n if frm.div(:class=>\"portletBody\").h3.text=~/Submission Confirmation/\n SubmissionConfirmation.new(@browser)\n elsif frm.button(:value=>\"Back to list\").exist?\n SubmissionConfirmation.new(@browser)\n else\n AssessmentsList.new(@browser)\n end\n end", "def submit\n frm.button(:value=>\"Submit\").click\n @@file_number=0\n if frm.div(:class=>\"portletBody\").h3.text=~/Submission Confirmation/\n SubmissionConfirmation.new(@browser)\n elsif frm.button(:value=>\"Back to list\").exist?\n SubmissionConfirmation.new(@browser)\n else\n AssessmentsList.new(@browser)\n end\n end", "def submit(locator)\n find_element(locator).submit\n end", "def submit(form_selector='form', submit_matcher='submit', input_values_hash={})\n forms = (self.html/form_selector)\n\n if forms.length != 1\n raise \"Problem with parsing form page -- expected only 1 form tag on `#{self.url}` matching selector `#{form_selector}`, but selected `#{forms.length}` fom tags\\n#{forms.inspect}\"\n end\n\n form_values = Hpricotscape::Form.parse(forms[0])\n full_action_url = if form_values[:action].starts_with?('/')\n \"#{self.url.split('://').first}://#{self.url.split('://').last.split('/').first}#{form_values[:action]}\"\n elsif form_values[:action].index('://').nil?\n \"#{self.url.rpartition('/').first}/#{form_values[:action]}\"\n else\n form_values[:action]\n end\n\n # Allow user to use strings or symbols for input values, and merge them into the form\n form_values[:inputs].keys.each do |k|\n form_values[:inputs][k.to_s] = input_values_hash[k.to_s] if input_values_hash.has_key?(k.to_s)\n form_values[:inputs][k.to_s] = input_values_hash[k.to_sym] if input_values_hash.has_key?(k.to_sym)\n end\n\n submit_key = form_values[:submits].keys.select { |k| k.downcase.index(submit_matcher) }.first\n form_post_body = form_values[:inputs].merge(submit_key => form_values[:submits][submit_key])\n\n _load(full_action_url, form_values[:method], form_post_body)\n end", "def submit(opts={})\n msg = \"Submit button not found in form\"\n selector = 'input[type=\"submit\"], input[type=\"image\"], button[type=\"submit\"]'\n if @submit_value\n msg << \" with a value of '#{@submit_value}'\"\n selector.gsub!(/\\]/, \"][value=#{@submit_value}]\")\n end\n raise MissingSubmitError, msg unless tag.select(selector).any?\n fields_hash.update(opts)\n submit_without_clicking_button\n end", "def submitted\n submitted?\n end", "def submit_for_grading\n frm.button(:value=>\"Submit for Grading\").click\n SubmissionSummary.new(@browser)\n end", "def post_message(form)\n begin\n config.sleep_before_post\n form.submit\n rescue StandardError => err\n raise Impostor::PostError.new(err)\n end\n end", "def submit(form, button = nil, headers = {})\n form.add_button_to_query(button) if button\n\n case form.method.upcase\n when 'POST'\n post_form(form.action, form, headers)\n when 'GET'\n get(form.action.gsub(/\\?[^\\?]*$/, ''),\n form.build_query,\n form.page,\n headers)\n else\n raise ArgumentError, \"unsupported method: #{form.method.upcase}\"\n end\n end", "def submitted?\n raise \"submitted? should be implemented by the extending class\"\n end", "def submit_button?(button_name); end", "def test_post_multival\n page = @agent.get(\"http://localhost/form_multival.html\")\n form = page.form_with(:name => 'post_form')\n\n assert_not_nil(form)\n assert_equal(2, form.fields_with(:name => 'first').length)\n\n form.fields_with(:name => 'first')[0].value = 'Aaron'\n form.fields_with(:name => 'first')[1].value = 'Patterson'\n\n page = @agent.submit(form)\n\n assert_not_nil(page)\n\n assert_equal(2, page.links.length)\n assert_not_nil(page.link_with(:text => 'first:Aaron'))\n assert_not_nil(page.link_with(:text => 'first:Patterson'))\n end", "def validate_form(_formdata: {})\n true # Futureuse\nend", "def form_submit(form, opts = {})\n opts[:class] ||= \"btn btn-primary\"\n opts[:value] ||= submit_default_value(form)\n content_tag(:div, :class => \"form-actions\") do\n form.submit(opts)\n end\n end", "def submit(contents, attrs = {})\n current_form_context.submit(contents, attrs)\n end", "def submit locator\r\n command 'submit', locator\r\n end", "def submit locator\r\n command 'submit', locator\r\n end", "def test_submit\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: SAMPLE_UDPRN, quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end", "def fill_form_and_submit(agent, creds, url, category, tech, data)\n case category\n when 'extensions'\n puts \"uploading #{category.chop}: #{data[category.chop].to_s}\" unless $quiet\n cat_page = get_page(agent, creds, url + CONFIG, {display: category, tech_hardware: 'custom_custom'})\n frm = cat_page.form('frm_extensions')\n when 'trunks'\n puts \"uploading #{category.chop}: #{data['trunk_name'].to_s}\" unless $quiet\n cat_page = get_page(agent, creds, url + CONFIG, {display: category, tech: tech.upcase})\n frm = cat_page.form('trunkEdit')\n end\n abort 'error: form not found' unless frm\n\n if $debug\n frm.fields.each { |field| puts \"send_sever_request: #{field.name}: #{field.value}\" }\n frm.checkboxes.each { |chkbx| puts \"send_sever_request: #{chkbx.name}: #{chkbx.value}\" }\n frm.radiobuttons.each { |rdb| puts \"send_sever_request: #{rdb.name}: #{rdb.value}\" if rdb.checked }\n end\n # Fill in the form, and submit it!\n data.each { |key, val| frm[key] = val }\n frm.submit\nend", "def submitted?\n self.state == 'submitted'\n end", "def click_submit_button\n @driver.find_element(xpath: @submit_button).click\n end", "def submit!\n raise('already submitted') if was_submitted?\n raise('expected a purchased order') unless submit_order&.purchased?\n\n wizard_steps[:checkout] ||= Time.zone.now\n wizard_steps[:submitted] = Time.zone.now\n submitted!\n end", "def assert_submit_button(button_label = nil)\n if button_label\n assert_tag \"input\", :attributes => { :type => \"submit\",\n :value => button_label}\n else\n assert_tag \"input\", :attributes => { :type => \"submit\" }\n end\n end", "def submit\n submit!\n rescue Exception => e\n if e.respond_to?(:record)\n inherit_errors(e.record) unless e.record == self\n false\n else\n raise\n end\n end", "def xf_submit (label = \"Submit\", target_options = {}, id = \"submit\", attrs = {})\n attrs = attrs.symbolize_keys()\n attrs[:submission] = id\n labelAttrs = attrs.delete(:labelAttrs)\n label = label(label, labelAttrs)\n method = attrs.delete(:method)\n model = model(attrs[:model])\n model.submission = submission(method, url_for(target_options), {:id => id})\n typeWithAttrs(\"submit\", label, attrs)\n end", "def submit(value = \"Submit\", options = {})\n @template.submit_tag(value, options)\n end", "def submit(captcha_answer)\n @submit_f.(captcha_answer)\n end", "def submit(button_name=nil, opts={})\n # 1. Loop through the non hidden fields and if they're active and displayed enter the value\n fill_in_field_data\n\n # 2. Submit Form\n submit_button = select_submit_button(button_name, opts)\n\n wait_for_submit(submit_button)\n submit_button.node.click\n\n # 3. Wait for Page page\n wait_for_page(driver, metz)\n\n # 4. Return new Page\n Metallize::Page.new(driver, metz)\n\n end", "def click_submit\n @chrome_driver.find_element(:name,SUBMIT_BUTTON).click\n end", "def submit_button \n\t\[email protected](id: @submit)\n\tend", "def test_get_multival\n page = @agent.get(\"http://localhost/form_multival.html\")\n form = page.form_with(:name => 'get_form')\n\n assert_not_nil(form)\n assert_equal(2, form.fields_with(:name => 'first').length)\n\n form.fields_with(:name => 'first')[0].value = 'Aaron'\n form.fields_with(:name => 'first')[1].value = 'Patterson'\n\n page = @agent.submit(form)\n\n assert_not_nil(page)\n\n assert_equal(2, page.links.length)\n assert_not_nil(page.link_with(:text => 'first:Aaron'))\n assert_not_nil(page.link_with(:text => 'first:Patterson'))\n end", "def submit(buttonName = nil)\r\n if (buttonName.nil?) then\r\n buttons.each { |button|\r\n next if button.type != 'submit'\r\n button.click\r\n return\r\n }\r\n else\r\n click_button_with_name(buttonName)\r\n end\r\n end", "def test_new\n login(\"rolf\")\n get(:new)\n assert_select(\n \"form[action='#{herbaria_path}'][method='post']\", { count: 1 },\n \"'new' action should render a form that posts to #{herbaria_path}\"\n )\n end", "def test_validinput1\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219') # Find the name field\n element.send_keys(\"Michael\")\n element = @driver.find_element(:id,'group_310473641_1') # Select the \"Yes\" checkbox\n element.click\n element.submit\n element = @driver.find_element(:class,'ss-resp-message')\n assert_equal(element.text,\"Your response has been recorded.\")\n end", "def submit(value = \"Submit\", options = {})\n @template.submit_tag(value, options)\n end", "def test_validinput2\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219') # Find the name field\n element.send_keys(\"Michael\")\n element = @driver.find_element(:id,'group_310473641_1') # Select the \"Yes\" checkbox\n element.click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id => 'entry_262759813')).select_by :text, 'JUnit' # From the dropdown, select \"JUnit\"\n element = @driver.find_element(:id,'entry_649813199')\n element.send_keys(\"Some random text here.\") # Enter some text in the text area\n element.submit\n element = @driver.find_element(:class,'ss-resp-message') \n assert_equal(element.text,\"Your response has been recorded.\") # Check if on the submit page, the message displayed is the one expected\n end", "def submit\n setup_listing\n if valid?\n persist!\n true\n else\n false\n end\n end", "def form; end", "def submit_search\n click SEARCH_SUBMIT_BUTTON\n end", "def click_submit\n @chrome_driver.find_element(:name, SUBMIT_BUTTON).click\n sleep 2\n end", "def submit(value = nil, name = nil)\n attributes = if (not value) or value.kind_of?(String)\n { \"TYPE\" => \"submit\", \"VALUE\" => value, \"NAME\" => name }\n else\n value[\"TYPE\"] = \"submit\"\n value\n end\n input(attributes)\n end", "def visit url\n @agent.get url\n @agent.page.form&.submit\n end", "def submit(button = T.unsafe(nil), headers = T.unsafe(nil)); end", "def fb_request_form_submit\n tag \"fb:request-form-submit\"\n end", "def form_submitted(evt)\n unless evt[:form_action] == 'cancel'\n attributes, special = get_form_attributes(evt)\n set_record evt[:id], evt[:pid]\n was_new = record.new_record?\n record.update_attributes(attributes)\n reaction = after_form_update(:record => record, :was_new => was_new,\n :form_action => evt[:form_action], :special => special)\n trigger :flash, :notice => reaction[:notice]\n trigger :display_form, reaction[:display_form] if reaction[:display_form]\n trigger :reload_grid\n render :text => reaction[:text]\n else\n trigger :flash_deveal\n render :text => form_deveal('#FF8888') #cancel\n end\n end", "def test_create_observation\n requires_login(:create_observation)\n assert_form_action(:action => 'create_observation', :approved_name => '')\n end", "def test_create_observation\n requires_login(:create_observation)\n assert_form_action(:action => 'create_observation', :approved_name => '')\n end", "def auto_submit?\n false\n end", "def current_page?\n form.has_submit_button?\n end", "def post_form_to_external?\n true\n end", "def being_submitted?(item = nil)\n # noinspection RubyMismatchedArgumentType\n super(item || self)\n end", "def ajax_form_submit(opts = {})\n form_id = opts[:form_id] || id\n \"javascript:$('form##{form_id}').submit()\"\n end", "def link_to_formsubmit(name, id, html_options = {}) \n \tlink_to_function(name, \"if(document.forms['#{id}'].onsubmit()) { document.forms['#{id}'].submit(); }\", html_options)\n end", "def submit(params)\n preload_fields_with(params)\n\n if completely_valid?\n course.save!\n true\n else\n promote_errors(course.errors)\n false\n end\n end", "def submit\n\t\t# puts params.inspect\n\n\n\t\tif params[:authenticity_token].present?\n\t\t\tputs \"here\"\n\t\t\t# submit hit\n\t\t\tsubmission_result = validation_submission(params)\n\t\t\tputs submission_result \n\t\t\t# puts submission_result.class \n\t\t\t# Test passed... Need more test\n\n\t\t\tif submission_result.class == Hash\n\t\t\t\t# submit_sequence_caller_for_aa_nt will save success and new to database automatically\n\t\t\t\t# uploading_result is for showing the status for user\n\t\t\t\tuploading_result = submit_sequence_caller_for_aa_nt(submission_result[\"aa\"],submission_result[\"nt\"], params[:uploader_name],params[:uploader_email])\n\n\t\t\t\trender json: { \"result\": uploading_result }\n\n\t\t\telsif submission_result.class == Array\n\t\t\t\t# there are errors\n\t\t\t\trender json: { \"errors\": submission_result }\n\t\t\tend\n\t\t\n\t\tend\n\n\tend", "def submit\n\t\tset_post_data\n get_response @url\n parse_response\n\tend", "def submit_form_with_rest(form_element: nil, action: nil, params: nil, expected_redirect: nil)\n if form_element.nil? && ( action.nil? && params.nil?)\n raise \"Must pass in either a form element to submit or an action url with a parameters hash\"\n end\n\n if form_element\n params = form_element.all(:css, \"input\").inject({}){|result, input| result[input[\"name\"]] = input.value ; result }\n action = form_element[\"action\"]\n end\n\n rest_request(:post, action, payload: params, format: :html, retry_login: true, expected_redirect: expected_redirect)\n end", "def test_invalidinput2\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219')\n element.send_keys(\"Michael\") # Valid value for question 1\n element.submit # Submit without valid input for question 2\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[2]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 2 shows up\n end", "def ci_negative_demo_form_submit\r\n sleep 4\r\n $browser.send_keys :enter \r\n # $browser.element.button(:xpath,\"//*[contains(@class, 'form-submit form-buttonSubmit cta-btn blue')]\").click\r\n sleep 6\r\n\trescue\r\n\t $results.puts \"Form Submit Failed! for CI Negative Demo Form!\"\r\n\t $summary_results.puts \"Form Submit Failed! for CI Negative Demo Form!\"\r\n\t get_unique_number\r\n\t $browser.screenshot.save \"#{$x}CI_Negative_Submit_Page_Error\"+$unique_number+\".png\"\r\n\t else\r\n\t\t $results.puts \"Successfully clicked submit button!\"\r\n\t\t $summary_results.puts \"Pass - Negative Test\"\r\nend", "def click_commit(session: self)\n session.first(:button, type: \"submit\").click\n end", "def form\n end", "def fb_request_form_submit(options={})\n\t\t\t tag(\"fb:request-form-submit\",stringify_vals(options))\n\t\t\tend", "def done\n frm.button(:name=>\"takeAssessmentForm:_id5\").click\n EditAssessment.new(@browser)\n end", "def submitIncidentForm(page, startYear, endYear)\n form = page.form_with(:action => \"search.php\");\n form['start_year'] = startYear;\n form['end_year'] = endYear;\n page = page.form_with(:action => \"search.php\").click_button();\nend", "def test_invalidinput1 \n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219')\n element.submit # Submit without entering anything on the page\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[1]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 1 shows up\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[2]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 2 shows up\n end", "def link_to_submit text, args\n link_to_function text, \"$(this).closest('form').submit()\", args\n end", "def submit_question\n @filename ||= ask 'Filename: '\n\n puts \"Submitting #{@question}...\"\n\n form = @submission_page.forms.first\n form.file_uploads.first.file_name = @filename\n @agent.submit form\n\n puts \"#{@question} has been successfully uploaded to Marmoset.\"\n\n rescue Mechanize::ResponseCodeError\n puts \"File #{@question} submission failed. Please try again!\"\n exit\n end", "def on_submitting_entry(state, event, *event_args)\n super\n\n # Verify validity of the submission. # TODO: simulation - remove\n if simulating\n # From UploadController#create:\n # @item, failed = upload_create(data)\n __debug_sim('CODE') do\n args = \"data=#{submission.data.inspect}\"\n opt = 'index: false'\n \"@item, failed = upload_create(#{args}, #{opt})\"\n end\n bad = nil\n if (db_fail = submission.db_failure)\n self.failures << 'DB create failed'\n elsif (bad = !(submission.metadata_valid = !submission.invalid_entry))\n self.failures << 'bad metadata'\n else\n self.succeeded << submission.id\n end\n if db_fail\n __debug_sim('[db_failure: true]')\n __debug_sim('The database entry could not be created.')\n elsif bad\n __debug_sim('[invalid_entry: true]')\n __debug_sim('The entry is invalid/incomplete.')\n __debug_sim('(NOTE: PROBABLE FAILURE OF CLIENT-SIDE FORM VALIDATION)')\n else\n __debug_sim('[invalid_entry: false]')\n __debug_sim('[db_failure: false]')\n end\n end\n\n # Verify validity of the submission.\n unless simulating\n wf_validate_submission(*event_args)\n end\n\n valid = ready?\n\n # TODO: simulation - remove\n if valid\n __debug_sim('The database entry was created.')\n else\n __debug_sim('System generates a form error message to be displayed.')\n end\n\n # Automatically transition to the next state based on submission status.\n if valid\n advance! # NOTE: => :submitted\n else\n reject! # NOTE: => :creating\n end\n self\n end", "def submit_search\n @page.click_button('searchButton')\n end" ]
[ "0.77359384", "0.77248186", "0.7687927", "0.74157035", "0.73261464", "0.7246452", "0.71802634", "0.71379143", "0.70889956", "0.70889956", "0.6980076", "0.69614476", "0.68712854", "0.68674284", "0.6802274", "0.6802274", "0.6778336", "0.6757847", "0.6732922", "0.6732922", "0.6732922", "0.6732922", "0.6709227", "0.6679213", "0.66442406", "0.6630905", "0.66058093", "0.65542257", "0.6445516", "0.64279246", "0.6403932", "0.63889915", "0.63889915", "0.63393945", "0.62887424", "0.62765765", "0.6272149", "0.6267025", "0.622109", "0.6217181", "0.6128512", "0.6127887", "0.6127274", "0.6094284", "0.6087595", "0.6069814", "0.6060454", "0.6060454", "0.60492736", "0.6024646", "0.60093683", "0.59966356", "0.5996178", "0.5974462", "0.5948032", "0.59456724", "0.59390813", "0.59273225", "0.5927086", "0.5896048", "0.58886313", "0.5873012", "0.58689797", "0.5866264", "0.5831397", "0.5817796", "0.5806576", "0.58024406", "0.57623225", "0.5760197", "0.5743725", "0.5739578", "0.5738771", "0.5738417", "0.5730094", "0.5727124", "0.5715284", "0.5715284", "0.57074416", "0.5702055", "0.5701382", "0.56811404", "0.5675114", "0.56745225", "0.5644697", "0.5634097", "0.5633964", "0.5617577", "0.5615737", "0.558419", "0.5577075", "0.5575557", "0.5567912", "0.5567078", "0.5549434", "0.55421925", "0.5533242", "0.5531983", "0.5527819", "0.55272985" ]
0.7216442
6
Test submitting form with two fields of the same name
def test_get_multival page = @agent.get("http://localhost/form_multival.html") form = page.form_with(:name => 'get_form') assert_not_nil(form) assert_equal(2, form.fields_with(:name => 'first').length) form.fields_with(:name => 'first')[0].value = 'Aaron' form.fields_with(:name => 'first')[1].value = 'Patterson' page = @agent.submit(form) assert_not_nil(page) assert_equal(2, page.links.length) assert_not_nil(page.link_with(:text => 'first:Aaron')) assert_not_nil(page.link_with(:text => 'first:Patterson')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_submit_on_form\n page = @agent.get(\"http://localhost/form_multival.html\")\n form = page.form_with(:name => 'post_form')\n\n assert_not_nil(form)\n assert_equal(2, form.fields_with(:name => 'first').length)\n\n form.fields_with(:name => 'first')[0].value = 'Aaron'\n form.fields_with(:name => 'first')[1].value = 'Patterson'\n\n page = form.submit\n\n assert_not_nil(page)\n\n assert_equal(2, page.links.length)\n assert_not_nil(page.link_with(:text => 'first:Aaron'))\n assert_not_nil(page.link_with(:text => 'first:Patterson'))\n end", "def test_post_multival\n page = @agent.get(\"http://localhost/form_multival.html\")\n form = page.form_with(:name => 'post_form')\n\n assert_not_nil(form)\n assert_equal(2, form.fields_with(:name => 'first').length)\n\n form.fields_with(:name => 'first')[0].value = 'Aaron'\n form.fields_with(:name => 'first')[1].value = 'Patterson'\n\n page = @agent.submit(form)\n\n assert_not_nil(page)\n\n assert_equal(2, page.links.length)\n assert_not_nil(page.link_with(:text => 'first:Aaron'))\n assert_not_nil(page.link_with(:text => 'first:Patterson'))\n end", "def test_validinput1\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219') # Find the name field\n element.send_keys(\"Michael\")\n element = @driver.find_element(:id,'group_310473641_1') # Select the \"Yes\" checkbox\n element.click\n element.submit\n element = @driver.find_element(:class,'ss-resp-message')\n assert_equal(element.text,\"Your response has been recorded.\")\n end", "def test_validinput2\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219') # Find the name field\n element.send_keys(\"Michael\")\n element = @driver.find_element(:id,'group_310473641_1') # Select the \"Yes\" checkbox\n element.click\n Selenium::WebDriver::Support::Select.new(@driver.find_element(:id => 'entry_262759813')).select_by :text, 'JUnit' # From the dropdown, select \"JUnit\"\n element = @driver.find_element(:id,'entry_649813199')\n element.send_keys(\"Some random text here.\") # Enter some text in the text area\n element.submit\n element = @driver.find_element(:class,'ss-resp-message') \n assert_equal(element.text,\"Your response has been recorded.\") # Check if on the submit page, the message displayed is the one expected\n end", "def test_invalidinput2\n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219')\n element.send_keys(\"Michael\") # Valid value for question 1\n element.submit # Submit without valid input for question 2\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[2]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 2 shows up\n end", "def submit_without_clicking_button\n path = self.action.blank? ? self.uri : self.action # If no action attribute on form, it submits to the same URI where the form was displayed\n params = {}\n fields.each {|field| params[field.name] = field.value unless field.value.nil? || field.value == [] || params[field.name] } # don't submit the nils, empty arrays, and fields already named\n \n # Convert arrays and hashes in param keys, since test processing doesn't do this automatically\n params = ActionController::UrlEncodedPairParser.new(params).result\n @testcase.make_request(request_method, path, params, self.uri, @xhr)\n end", "def test_invalidinput1 \n @driver.navigate.to(@url)\n element = @driver.find_element(:id,'entry_1041466219')\n element.submit # Submit without entering anything on the page\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[1]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 1 shows up\n elementError = @driver.find_element(:xpath,\"//form[@id='ss-form']/ol/div[2]/div/div/div[@class='required-message']\")\n assert_equal(elementError.text,\"This is a required question\") # Check if error message for question 2 shows up\n end", "def check_server_form\n has_element(\"input#bigbluebutton_server_name\",\n { :name => 'bigbluebutton_server[name]', :type => 'text' })\n has_element(\"input#bigbluebutton_server_url\",\n { :name => 'bigbluebutton_server[url]', :type => 'text' })\n has_element(\"input#bigbluebutton_server_secret\",\n { :name => 'bigbluebutton_server[secret]', :type => 'text' })\n has_element(\"input#bigbluebutton_server_version\",\n { :name => 'bigbluebutton_server[version]', :type => 'text' })\n has_element(\"input#bigbluebutton_server_slug\",\n { :name => 'bigbluebutton_server[slug]', :type => 'text' })\n has_element(\"label\", { :for => 'bigbluebutton_server_name' })\n has_element(\"label\", { :for => 'bigbluebutton_server_url' })\n has_element(\"label\", { :for => 'bigbluebutton_server_secret' })\n has_element(\"label\", { :for => 'bigbluebutton_server_version' })\n has_element(\"label\", { :for => 'bigbluebutton_server_slug' })\n has_element(\"input\", { :name => 'commit', :type => 'submit' })\n end", "def click_submit\n end", "def auto_submit?\n false\n end", "def submit_button?(button_name); end", "def test_field(field, value, error = false)\n field.set value\n field.trigger 'blur'\n\n no_php_js_errors\n\n if error\n @page.wait_for_error_message_count(1)\n should_have_form_errors(@page)\n should_have_error_text(field, error)\n else\n @page.wait_for_error_message_count(0)\n should_have_no_form_errors(@page)\n should_have_no_error_text(field)\n end\n end", "def test_submit_signup\n post :submit_signup, { :create_password2 =>\"freddy\", :create_username =>\"fred\", :create_password => \"freddy1\", :create_email =>\"[email protected]\" }\n assert_response :bad_request\n assert_equal \"Passwords do not match\", @response.body\n assert_nil session[:user]\n\n post :submit_signup, { :create_password2 =>\"freddy\", :create_username =>\"fred\", :create_password => \"freddy\", :create_email =>\"[email protected]\" }\n assert_response :success\n assert_equal 'fred', session[:user][:username]\n end", "def test_create_observation\n requires_login(:create_observation)\n assert_form_action(:action => 'create_observation', :approved_name => '')\n end", "def test_create_observation\n requires_login(:create_observation)\n assert_form_action(:action => 'create_observation', :approved_name => '')\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def test_create_failure\n post :new, :grape => { :name => \"\", }\n assert_response :success #success of HTTP, not success of registration process\n assert_template \"new\"\n #test display of error messages\n assert_tag \"div\", :attributes => { :id => \"errorExplanation\",\n :class => \"errorExplanation\"}\n #test that each form field has at least one error diplayed\n assert_tag \"li\", :content => /Name/\n \n #test to see that the input fields are being wrapped with the correct div\n error_div = { :tag => \"div\", :attributes => { :class => \"fieldWithErrors\"}}\n \n assert_tag \"input\",\n :attributes => { :name => \"grape[name]\",\n :value => \"\"},\n :parent => error_div\n end", "def verify_component_before_saving(fieldname)\n if(fieldname == \"Formatted content\")\n @browser.find_elements(:xpath => \"//strong[contains(text(), 'New HTML Markup')]\").should have_at_least(1).items #\"#{fieldname} is not present in the Form Builder space area.\")\n elsif(fieldname == \"Page break\" || fieldname == \"Hidden field\")\n @browser.find_elements(:xpath => \"//div[contains(text(), '#{fieldname}')]\").should have_at_least(1).items #\"#{fieldname} is not present in the Form Builder space area.\")\n elsif(fieldname == \"Fieldset\")\n @browser.find_elements(:xpath => \"//span[contains(text(), '#{fieldname}')]\").should have_at_least(1).items #\"#{fieldname} is not present in the Form Builder space area.\")\n else\n @browser.find_elements(:xpath => \"//label[contains(text(), '#{fieldname}')]\").should have_at_least(1).items #\"#{fieldname} is not present in the Form Builder space area.\")\n end\n end", "def validate_fields\n expect(@browser.textfield(:id => 'lbl_val_1').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_val_2').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_val_3').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_val_4').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_val_5').present?).to eq(true)\n expect(@browser.textfield(:id => 'lbl_ttl_val').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_1').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_2').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_4').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_5').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_val_6').present?).to eq(true)\n expect(@browser.textfield(:id => 'txt_ttl_val').present?).to eq(true)\n end", "def equal_pair(key, request)\n if @event[\"required\"][key] == request[\"object_attributes\"][key] || event[\"required\"][key] == \"\"\n true\n else\n false\n end\n end", "def submit_all_blank_and_validate\n blank_dates\n click_on 'Add'\n validate_fields(@fields)\n end", "def assert_submit_button(button_label = nil)\n if button_label\n assert_tag \"input\", :attributes => { :type => \"submit\",\n :value => button_label}\n else\n assert_tag \"input\", :attributes => { :type => \"submit\" }\n end\n end", "def assert_same_text_input(attribute, value)\n assert_equal(\n %Q[<input type=\"text\" value=\"#{value}\" name=\"product[#{attribute}]\" id=\"product_#{attribute}\" />],\n @template.text_field(:product, attribute, object: @localized)\n )\n end", "def submit\r\n assert_exists\r\n submit_form \r\n @o.wait\r\n end", "def submit_form\n click_button 'submit'\n end", "def submitIncidentForm(page, startYear, endYear)\n form = page.form_with(:action => \"search.php\");\n form['start_year'] = startYear;\n form['end_year'] = endYear;\n page = page.form_with(:action => \"search.php\").click_button();\nend", "def test_create_failure\n post :new, :appellation => { :name => \"\",\n :apptype_id => 1 }\n assert_response :success #success of HTTP, not success of create process\n assert_template \"new\"\n #test display of error messages\n assert_tag \"div\", :attributes => { :id => \"errorExplanation\",\n :class => \"errorExplanation\"}\n #test that each form field has at least one error diplayed\n assert_tag \"li\", :content => /Name/\n \n #test to see that the input fields are being wrapped with the correct div\n error_div = { :tag => \"div\", :attributes => { :class => \"fieldWithErrors\"}}\n \n assert_tag \"input\",\n :attributes => { :name => \"appellation[name]\",\n :value => \"\"},\n :parent => error_div\n end", "def test_edit_name_get\n name = names(:coprinus_comatus)\n params = { id: name.id.to_s }\n requires_login(:edit, params)\n assert_form_action(action: :update, id: name.id.to_s)\n assert_select(\"form #name_icn_id\", { count: 1 },\n \"Form is missing field for icn_id\")\n end", "def expect_fields_to_be_blank\n expect(page).to have_field(\"Email\", with: \"\", type: \"email\")\n expect(find_field(\"Password\", type: \"password\").value).to be_nil\n expect(find_field(\"Password confirmation\", type: \"password\").value).to be_nil\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def param_posted?(sym)\n request.post? and params[sym]\n end", "def submit(form_name)\n Praline::browser.find_element(:name, form_name).submit\n end", "def test_create_naming_get\n obs = observations(:coprinus_comatus_obs)\n params = {\n :id => obs.id.to_s\n }\n requires_login(:create_naming, params)\n assert_form_action(:action => 'create_naming', :approved_name => '', :id => obs.id.to_s)\n end", "def test_new\n login(\"rolf\")\n get(:new)\n assert_select(\n \"form[action='#{herbaria_path}'][method='post']\", { count: 1 },\n \"'new' action should render a form that posts to #{herbaria_path}\"\n )\n end", "def param_posted?(symbol)\n request.post? and (not params[symbol].blank?)\n end", "def test_put_form_field\n filename = 'test_multi_pages.docx'\n remote_name = 'TestPutFormField.docx'\n dest_name = remote_test_out + remote_name\n body = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true,\n :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => '123',\n :TextInputFormat => 'UPPERCASE'})\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_common_folder + filename, \"r\").read\n @storage_api.put_create st_request\n\n request = PutFormFieldRequest.new remote_name, body, remote_test_folder + test_folder, :dest_file_name => dest_name, :node_path => 'sections/0/paragraphs/0'\n result = @words_api.put_form_field request\n assert_equal 200, result.code\n end", "def test_new\n login\n get(:new)\n\n assert_response(:success)\n assert_head_title(:create_glossary_term_title.l)\n\n ESSENTIAL_ATTRIBUTES.each do |attr|\n assert_select(\"form [name='glossary_term[#{attr}]']\", { count: 1 },\n \"Form should have one field for #{attr}\")\n end\n assert_select(\"input#upload_image\", { count: 1 },\n \"Form should include upload image field\")\n end", "def submit(opts={})\n msg = \"Submit button not found in form\"\n selector = 'input[type=\"submit\"], input[type=\"image\"], button[type=\"submit\"]'\n if @submit_value\n msg << \" with a value of '#{@submit_value}'\"\n selector.gsub!(/\\]/, \"][value=#{@submit_value}]\")\n end\n raise MissingSubmitError, msg unless tag.select(selector).any?\n fields_hash.update(opts)\n submit_without_clicking_button\n end", "def test_ID_25841_edit_profile_i_am_a_optional\n login_as_user1\n go_to_edit_profile_page\n verify_i_am_a_text_optional\n verify_text_can_be_entered_saved_on_i_am_a_textfield\n end", "def test_uniqueness_of\n # Create a page named 'test' and save it\n page1 = new_page()\n assert page1.save\n\n # Duplicate page name won't work\n page2 = new_page()\n assert !page2.save\n assert page2.errors.on(:name)\n\n # Fix name and it should work\n page2.name = 'test2'\n assert page2.save\n end", "def test_create_naming_get\n obs = observations(:coprinus_comatus_obs)\n params = {\n :id => obs.id.to_s\n }\n requires_login(:create_naming, params)\n assert_form_action(:action => 'create_naming', :approved_name => '')\n end", "def check_room_form\n has_element(\"input#bigbluebutton_room_name\",\n { :name => 'bigbluebutton_room[name]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_meetingid\",\n { :name => 'bigbluebutton_room[meetingid]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_private\",\n { :name => 'bigbluebutton_room[private]', :type => 'checkbox' })\n has_element(\"input#bigbluebutton_room_attendee_key\",\n { :name => 'bigbluebutton_room[attendee_key]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_moderator_key\",\n { :name => 'bigbluebutton_room[moderator_key]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_welcome_msg\",\n { :name => 'bigbluebutton_room[welcome_msg]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_logout_url\",\n { :name => 'bigbluebutton_room[logout_url]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_dial_number\",\n { :name => 'bigbluebutton_room[dial_number]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_max_participants\",\n { :name => 'bigbluebutton_room[max_participants]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_external\",\n { :name => 'bigbluebutton_room[external]', :type => 'checkbox' })\n has_element(\"input#bigbluebutton_room_slug\",\n { :name => 'bigbluebutton_room[slug]', :type => 'text' })\n has_element(\"input#bigbluebutton_room_voice_bridge\",\n { :name => 'bigbluebutton_room[voice_bridge]', :type => 'text' })\n has_element(\"label\", { :for => 'bigbluebutton_room_name' })\n has_element(\"label\", { :for => 'bigbluebutton_room_meetingid' })\n has_element(\"label\", { :for => 'bigbluebutton_room_private' })\n has_element(\"label\", { :for => 'bigbluebutton_room_attendee_key' })\n has_element(\"label\", { :for => 'bigbluebutton_room_moderator_key' })\n has_element(\"label\", { :for => 'bigbluebutton_room_welcome_msg' })\n has_element(\"label\", { :for => 'bigbluebutton_room_logout_url' })\n has_element(\"label\", { :for => 'bigbluebutton_room_dial_number' })\n has_element(\"label\", { :for => 'bigbluebutton_room_max_participants' })\n has_element(\"label\", { :for => 'bigbluebutton_room_external' })\n has_element(\"label\", { :for => 'bigbluebutton_room_slug' })\n has_element(\"label\", { :for => 'bigbluebutton_room_voice_bridge' })\n has_element(\"input\", { :name => 'commit', :type => 'submit' })\n end", "def form_submit\r\n form.submit\r\n @form = nil\r\nend", "def test_values_unique\n\n #Arrange\n @user3 = User.new\n @user4 = User.new\n\n # Act\n @user3.name = \"fede\"\n @user3.surname = \"guti\"\n @user3.username = \"fede3\"\n @user3.email = \"[email protected]\"\n @user3.password = \"123456789\"\n\n @user4.name = \"fede\"\n @user4.surname = \"guti\"\n @user4.username = \"luca\"\n @user4.email = \"[email protected]\"\n @user4.password = \"123456789\"\n\n\n # Assert\n @user3.save\n @user4.save\n all_ok = assert_equal @user3.valid? && @user4.valid? , true\n\n # Act\n @user4.email = \"[email protected]\"\n @user4.save\n\n # Assert\n email_check = assert_equal @user4.valid?, false\n\n # Act\n @user4.email = \"[email protected]\"\n @user4.username = \"fede3\"\n @user4.save\n\n # Assert\n user_check = assert_equal @user4.valid?, false\n\n # Assert\n assert_equal (all_ok || email_check || user_check) , true\n\n end", "def fill_form_and_submit(agent, creds, url, category, tech, data)\n case category\n when 'extensions'\n puts \"uploading #{category.chop}: #{data[category.chop].to_s}\" unless $quiet\n cat_page = get_page(agent, creds, url + CONFIG, {display: category, tech_hardware: 'custom_custom'})\n frm = cat_page.form('frm_extensions')\n when 'trunks'\n puts \"uploading #{category.chop}: #{data['trunk_name'].to_s}\" unless $quiet\n cat_page = get_page(agent, creds, url + CONFIG, {display: category, tech: tech.upcase})\n frm = cat_page.form('trunkEdit')\n end\n abort 'error: form not found' unless frm\n\n if $debug\n frm.fields.each { |field| puts \"send_sever_request: #{field.name}: #{field.value}\" }\n frm.checkboxes.each { |chkbx| puts \"send_sever_request: #{chkbx.name}: #{chkbx.value}\" }\n frm.radiobuttons.each { |rdb| puts \"send_sever_request: #{rdb.name}: #{rdb.value}\" if rdb.checked }\n end\n # Fill in the form, and submit it!\n data.each { |key, val| frm[key] = val }\n frm.submit\nend", "def submit\n frm.button(:value=>\"Submit\").click\n SubmissionConfirmation.new(@browser)\n end", "def submit\n frm.button(:value=>\"Submit\").click\n SubmissionConfirmation.new(@browser)\n end", "def text_field?(field_name); end", "def sign_in_and_play\n visit('/')\n fill_in :p1_name, with: 'Pavi'\n fill_in :p2_name, with: 'Ash'\n click_button 'Submit'\nend", "def test_submit\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: SAMPLE_UDPRN, quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end", "def submit?\n self.type == :submit\n end", "def test_delete_form_test_with_multiliner_name()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\\\\nnouman\",\"field\":\"QA\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_form(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def should_see_new_song_fields\n expect(page).to have_field(\"artist\")\n expect(page).to have_field(\"title\")\n expect(page).to have_selector(\"#add_song_button\")\n end", "def test_edit_naming_get\n nam = namings(:coprinus_comatus_naming)\n params = {\n :id => nam.id.to_s\n }\n requires_user(:edit_naming, [\"observer\", \"show_observation\"], params)\n assert_form_action(:action => 'edit_naming', :approved_name => nam.text_name, :id => nam.id.to_s)\n end", "def test_text_field\n _erbout = ''\n \n uni_form_for(:user, @user) do |f|\n f.fieldset do\n _erbout.concat f.text_field(:first_name)\n end\n end\n \n expected = <<-html\n <form action=\"http://www.example.com\" method=\"post\" class=\"uniForm\">\n <fieldset class=\"blockLabels\">\n <div class=\"ctrlHolder\">\n <label for=\"user_first_name\">First name</label>\n <input name=\"user[first_name]\" size=\"30\" type=\"text\" class=\"textInput\" id=\"user_first_name\" value=\"Marcus\"/>\n </div>\n </fieldset>\n </form>\n html\n \n assert_dom_equal expected, _erbout\n end", "def assert_text_field(*args)\n options = args.extract_options!\n assert_select \"input[type=text][name=?]\", extract_name(args)\n end", "def param_posted?(symbol)\n request.post? and params[symbol]\n end", "def param_posted?(symbol)\n request.post? and params[symbol]\n end", "def param_posted?(symbol)\n request.post? and params[symbol]\n end", "def param_posted?(symbol)\n request.post? and params[symbol]\n end", "def hidden_field?(field_name); end", "def validate_form(_formdata: {})\n true # Futureuse\nend", "def change_submit_button(fieldname, button_name)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n wait.until { @browser.find_element(:xpath => @webformmgr.fieldset_label(fieldname)) }.click\n wait.until { @browser.find_element(:xpath => @webformmgr.properties_link) }.click\n temp = wait.until { @browser.find_element(:xpath => \"//input[@id='edit-submit-button']\") }\n temp.clear\n temp.send_keys(button_name)\n wait.until { @browser.find_element(:xpath => @webformmgr.fieldset_label(button_name)) }\n return button_name\n end", "def test_edit_naming_get\n nam = namings(:coprinus_comatus_naming)\n params = {\n :id => nam.id.to_s\n }\n requires_user(:edit_naming, [\"observer\", \"show_observation\"], params)\n assert_form_action(:action => 'edit_naming', :approved_name => nam.text_name)\n end", "def test_submit_rent\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: '123456',\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: '123456', quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end", "def submit_for_grading\n frm.button(:value=>\"Submit for Grading\").click\n ConfirmSubmission.new(@browser)\n end", "def submit; end", "def test_strips_form_inputs\n f = BasicForm.new(:form => { :age => \" 3 \\r\\n\", :email => ' [email protected] '})\n assert_equal 3, f.age\n assert_equal '[email protected]', f.email\n end", "def test_allow_dynamic_form_fields()\n # Parameters for the API call\n name = 'farhan'\n\n # dictionary for optional form parameters\n optional_form_parameters = {}\n optional_form_parameters['field'] = 'QA'\n\n # Perform the API call through the SDK function\n result = @controller.allow_dynamic_form_fields(name, _field_parameters: optional_form_parameters)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def update_same_fields? model, method\n intersection = fields_from_model(model).map(&:to_s) & fields_from_model_method(model, method).map(&:to_s)\n intersection.present?\n end", "def edit_webform2(fieldnames)\n fieldnames.each {|fieldname|\n element_id = @browser.find_element(:xpath => \"#{@webformmgr.fieldset_label(fieldname)}\").attribute(\"for\")\n class_name = @browser.find_element(:xpath => \"//*[@id='#{element_id}']\").attribute(\"class\")\n case class_name\n when 'form-text'\n self.edit_text_field(element_id, val = \"test\")\n when 'form-textarea'\n self.edit_text_field(element_id, val = \"testing text\")\n when 'email form-text'\n self.edit_text_field(element_id, val = \"[email protected]\")\n when 'form-select'\n self.edit_dropdown_field(element_id, val = \"test\")\n when 'form-checkboxes'\n self.edit_checkbox_field(element_id, val = [\"test\", \"one\"])\n when 'form-radios'\n self.edit_radio_field(element_id, val = \"test\")\n else\n Log.logger.info(\"This #{class_name} is not valid class, therefore can't be edited.\")\n end\n }\n end", "def test_ID_25841_edit_profile_i_am_a_optional\n login_as_user1\n go_to_edit_profile_page\n verify_i_am_a_text_optional\n verify_text_can_be_entered_saved_on_i_am_a\n end", "def verify_component_after_saving(fieldname)\n if(fieldname == \"Page break\")\n element_id = \"//input[@id='edit-next']\"\n self.check_element_presence_nextpage(element_id, fieldname)\n elsif (fieldname == \"Hidden field\")\n element_id = \"//input[@type = 'hidden' and @value = '' and contains(@name, 'submitted')]\"\n self.check_element_presence_nextpage(element_id, fieldname)\n elsif (fieldname == \"Formatted content\")\n element_id = \"//strong[contains(text(), 'New HTML Markup')]\"\n self.check_element_presence_nextpage(element_id, fieldname)\n else\n element_id = \"//*[contains(text(), '#{fieldname}')]\"\n self.check_element_presence_nextpage(element_id, fieldname)\n end\n end", "def verify_options_settings(fieldname, remove_options, change_options, new_options, default_options)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n wait.until { @browser.find_element(:xpath => \"//label[contains(text(), '#{fieldname}')]\") }\n class_name = @browser.find_element(:xpath => \"//label[contains(text(), '#{fieldname}')]/following-sibling::*[1]\").attribute(\"class\")\n if class_name == \"form-select\"\n removed_options, added_options = configure_options_test(remove_options, change_options, new_options)\n removed_options.each do |rem|\n @browser.find_elements(:xpath => \"//option[text()='#{rem}']\").should have(0).items\n end\n added_options.each do |new|\n @browser.find_elements(:xpath => \"//option[text()='#{new}']\").should have_at_least(1).items\n end\n Log.logger.info \"default_options: #{default_options.inspect}\"\n @browser.find_element(:xpath => \"//option[text()='#{default_options[0]}']\").should be_selected\n elsif class_name == \"form-checkboxes\" || class_name == \"form-radios\"\n removed_options, added_options = configure_options_test(remove_options, change_options, new_options)\n removed_options.each do |rem|\n @browser.find_elements(:xpath => \"//label[contains(text(), '#{rem}')]\").should have(0).items\n end\n added_options.each do |new|\n @browser.find_elements(:xpath => \"//label[contains(text(), '#{new}')]\").should have_at_least(1).items\n end\n default_options.each do |default|\n @browser.find_elements(:xpath => \"//label[contains(text(), '#{default}')]/../input[@checked = 'checked']\").should have_at_least(1).items\n end\n else\n Log.logger.info(\"Following class '#{class_name}' is not a part of test for Webform.\")\n end\n end", "def test_should_flag_ON_INIT_PAGE_NEXT_when_clicking_next_on_valid_init_page\n post :init, :user=>{:first_name=>field_first_name, :last_name=>field_last_name}, :commit=>:next\n #assert_redirected_to :action=>second_page\n assert assigns['on_init_page_next']\n end", "def click_submit_button\n\t\tsubmit_button.click\n\tend", "def assert_text_field(model, *attributes)\n attributes.each do |attribute|\n assert_select \"input[type=text][name=?]\",\n \"#{model.to_s}[#{attribute.to_s}]\"\n end\n end", "def select_and_submit(page, form_name, select_name, selection)\r\n option = nil\r\n form = page.form(form_name)\r\n unless form.nil?\r\n selector = form.field(select_name)\r\n unless selector.nil?\r\n option = select_option(selector, selection)\r\n form.submit\r\n end\r\n end\r\n return option\r\n end", "def fill_in_fields_and_submit(email, password, password_confirmation)\n @session.fill_in(@first_name_field, :with => @first_name_value)\n @session.fill_in(@last_name_field, :with => @last_name_value)\n @session.fill_in(@email_field, :with => email)\n @session.fill_in(@phone_one_key, :with => @phone_one_value)\n @session.fill_in(@phone_two_key, :with => @phone_two_value)\n @session.fill_in(@phone_three_key, :with => @phone_three_value)\n @session.fill_in(@user_extension_field, :with => @user_extension_value)\n @session.fill_in(@password_field, :with => password)\n @session.fill_in(@password_confirmation_field, :with => password_confirmation)\n @session.find(@form_submit_button_name).click\n end", "def test_delete_form_test_with_blank_name_field()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\" \",\"field\":\" \"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_form(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def test_update_form_field\n remote_file_name = 'TestUpdateFormField.docx'\n\n upload_file File.join(local_test_folder, field_folder + '/FormFilled.docx'), remote_data_folder + '/' + remote_file_name\n\n request_form_field = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true, :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => 'No name'})\n request = UpdateFormFieldRequest.new(name: remote_file_name, index: 0, form_field: request_form_field, node_path: 'sections/0', folder: remote_data_folder, dest_file_name: remote_test_out + '/' + remote_file_name)\n\n result = @words_api.update_form_field(request)\n assert_equal false, result.nil?\n end", "def in_submit attrs = nil\n attrs ||= Hash.new\n a_droite = attrs.delete(:right)\n au_centre = attrs.delete(:center)\n f = \"\".in_input(attrs.merge(:value => self, :type => 'submit'))\n # Valeur retournée\n case true\n when a_droite then f.in_div(class: 'right')\n when au_centre then f.in_div(class: 'center')\n else f\n end\n end", "def visit_questionnaire_submission_page questionnaire\n visit submission_questionnaire_path(questionnaire)\n\n assert page.has_content?(questionnaire.questionnaire_fields.first.title)\n assert page.has_content?(\"Submit questionnaire\")\nend", "def test_post_form_field\n filename = 'FormFilled.docx'\n remote_name = 'TestPostFormField.docx'\n dest_name = remote_test_out + remote_name\n index = 0\n body = FormFieldTextInput.new({:Name => 'FullName', :Enabled => true, :CalculateOnExit => true,\n :StatusText => '', :TextInputType => 'Regular', :TextInputDefault => ''})\n\n st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_test_folder + test_folder + '/' + filename, \"r\").read \n @storage_api.put_create st_request\n\n request = PostFormFieldRequest.new remote_name, body, index, remote_test_folder + test_folder, :dest_file_name => dest_name, :node_path => 'sections/0'\n result = @words_api.post_form_field request\n assert_equal 200, result.code\n end", "def test_doesnt_strips_non_form_inputs\n f = BasicForm.new(:age => \" 3 \\r\\n\", :email => ' [email protected] ')\n assert_equal \" 3 \\r\\n\", f.age\n assert_equal ' [email protected] ', f.email\n end", "def test_edit_institution_with_duplicate_name\n number_of_institution = Institution.count\n post :update,:id => institutions(:institution0).id, :institution => { :name => institutions(:institution1).name}\n assert_equal Institution.count, number_of_institution\n assert_equal 1, Institution.count(:all, :conditions => \"name = 'Test state university'\");\n assert Institution.find(:all, :conditions => \"name = 'Computer Science'\").count == 0;\n end", "def spoofForm(val)\n @deltaflag = false\n @form = val\n end", "def select_and_submit(page, form_name, select_name, selection)\n option = nil\n form = page.form(form_name)\n unless form.nil?\n selector = form.field(select_name)\n unless selector.nil?\n option = select_option(selector, selection)\n form.submit\n end\n end\n return option\n end", "def submit!\n\tend", "def onSubmit(request, response, form, errors)\r\n return form\r\n end", "def onSubmit(request, response, form, errors)\r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def being_submitted?(item = nil)\n # noinspection RubyMismatchedArgumentType\n super(item || self)\n end", "def onSubmit(request, response, form, errors)\r\n\treturn form\r\n end", "def check_has_form(page)\n inputs = page.search('input')\n inputs.each do |input|\n attrs = input.attributes.select { |k,v| v.value =~ /^name|login|password|username|^email$$/i } \n go_ahead = (!attrs.compact.empty?)\n if go_ahead\n puts \"I think I found the login url for #{page.uri.to_s}\"\n login_page = page\n puts \">> #{login_page.uri}\\n\\n\"\n return true\n end\n\n \n end\n return false\nend" ]
[ "0.69689614", "0.6770113", "0.6102426", "0.6010265", "0.59461796", "0.5911001", "0.5732697", "0.5601203", "0.55539143", "0.5479292", "0.54697484", "0.5452993", "0.54526776", "0.5413721", "0.5413721", "0.54122156", "0.5398371", "0.5380142", "0.5380108", "0.53337073", "0.5326929", "0.53230053", "0.5317807", "0.5302551", "0.53007525", "0.52980405", "0.5271681", "0.52522004", "0.5252149", "0.5241482", "0.5241482", "0.5241482", "0.5241482", "0.52401143", "0.5221019", "0.5207176", "0.51926666", "0.5186489", "0.51825833", "0.51791143", "0.5173234", "0.5169924", "0.5164932", "0.5159139", "0.5153508", "0.5146535", "0.5146522", "0.5135049", "0.5135049", "0.5127119", "0.51198906", "0.51177657", "0.5107817", "0.5096985", "0.50886387", "0.50868297", "0.5085102", "0.5080037", "0.50408036", "0.50408036", "0.50408036", "0.50408036", "0.50285614", "0.502119", "0.4994445", "0.4985296", "0.49836", "0.49815598", "0.49687585", "0.49585325", "0.49518114", "0.4951172", "0.49451795", "0.4939532", "0.49287596", "0.49266037", "0.49191055", "0.49162057", "0.4915036", "0.49139437", "0.490629", "0.4903954", "0.48997498", "0.48951837", "0.4890699", "0.48843455", "0.48759624", "0.48699918", "0.4867278", "0.48626143", "0.485697", "0.48569444", "0.48569444", "0.48548186", "0.48548186", "0.48548186", "0.48548186", "0.4841524", "0.4841004", "0.48381606" ]
0.67568964
2
revert if is resolved
def hash @__set.to_a.hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def revert\n end", "def unresolve\n change_state(:unresolve)\n end", "def revert\n self.class.revert [self]\n end", "def revert_to!(version)\n revert version, :hard\n self\n end", "def revert\n\t\tself.clear_caches\n\t\t@dirty = false\n\n\t\treturn true\n\tend", "def revert!\n track_changes_save = self.class.track_changes_save\n self.class.track_changes_save = false\n self.transaction do\n content_versions.each do | c |\n if c.content.version == c.version\n c.content.revert_to(c)\n end\n end\n content_key_versions.each do | c |\n if c.content_key.version == c.version\n c.content_key.revert_to(c)\n end\n end\n end\n ensure \n self.class.track_changes = track_changes_save\n end", "def revert_to(version)\n revert version\n self\n end", "def revert!\n published_pid = PidUtils.to_published(pid)\n draft_pid = PidUtils.to_draft(pid)\n\n if self.class.exists? published_pid\n destroy_draft_version!\n deep_copy_fedora_object from: published_pid, to: draft_pid\n end\n end", "def unresolve_external\r\n return if @resolved_refs.nil?\r\n raise \"can not unresolve, missing fragment information\" if @resolved_refs == :dirty || @resolved_refs[:unknown]\r\n rrefs = @resolved_refs.values.flatten\r\n @resolved_refs = {}\r\n unresolve_refs(rrefs)\r\n end", "def rollback\n self.revert_to self.previous_version\n end", "def revert\n version = InvoiceVersion.find(self.versions.last.id) if self.versions.last\n # if there are versions then revert to the previous one.\n if !version.blank? && version.reify\n self.transaction do\n # if the current status is :partial_payment or :paid_in_full then delete the last payment\n self.invoice_payments.last.revert if self.payment_made_current? && self.invoice_payments.last\n version.reify.save\n end\n else\n return false\n end\n return true\n end", "def revert_to!(value)\n revert_to(value)\n reset_version if saved = save\n saved\n end", "def rollback!\n self.revert_to! self.previous_version\n end", "def revert_conflicts\r\n self.update_conflicts(-1)\r\n #@tile.hit()\r\n end", "def restore; end", "def flunk(workitem, err_class_or_instance, *err_arguments)\n\n r = remove_workitem('reject', workitem)\n\n return flunk(workitem) if r != nil\n\n workitem.h.delete('_rev')\n\n super(workitem, err_class_or_instance, *err_arguments)\n end", "def revert_complete\n QcInspection.transaction do\n self.set_status STATUS_IN_PROGRESS\n end\n end", "def revert()\n if(@proxy == nil)\n @proxy = Action::Proxy.new(self.method('revert'))\n end\n @proxy\n end", "def down\n update_relative(:-)\n end", "def revert(commitish = nil, opts = {})\n self.lib.revert(commitish, opts)\n end", "def restore\r\n self.update(deleted: false)\r\n end", "def restore_merge_state; end", "def restore_merge_state; end", "def restore\n end", "def resolve\n original_scope.none\n end", "def undo_changes\r\n return synchronize( true )\r\n end", "def unresolve\n @query = Alerte.where(statu_id: 2).order(created_at: :desc)\n render layout: 'fylo'\n end", "def revert(path)\n cleanup(path)\n new_client.revert(path)\n rescue\n false\n else\n true\n end", "def revert\n @name_1 = @ori_backdrop1\n @name_2 = @ori_backdrop2\n end", "def revert_to!(version)\n revert_to(version) ? save_without_revision : false\n end", "def revert(evt)\n version = Version.find(evt[:id])\n if version.reify\n version.reify.save!\n else\n version.item.destroy\n end\n is_redo = evt[:redo] == 'true'\n trigger :flash, :notice => undo_notice(is_redo, version)\n trigger :reload_grid\n render :nothing => true\n end", "def revert_to(status)\n if status == AbsenteeNotStarted\n self.county = nil\n self.town = nil\n self.zip_code = nil\n end\n end", "def rollback()\n #This is a stub, used for indexing\n end", "def revert_changes!\n # Reassign the first value since we started tracking\n @changed_attributes.each_pair do |key, value|\n @attributes[key] = value.first\n end\n\n clear_tracked_changes!\n end", "def revert_code()\n\t\t\n\tend", "def revert!\n %x[git checkout master]\n %x[git branch -D deployment]\nend", "def revert!\n %x[git checkout master]\n %x[git branch -D deployment]\nend", "def replace\n result = super\n delete_backup!(@old) if result && delete_backup?\n result\n end", "def restore \n raise NotImplementedError.new\n end", "def reverse_completed_goals(caller)\n\t\tgls = self.goals.reverse\n\t\tgls.each do |goal|\n\t\t\tgoal.undo() if goal != caller and goal.can_undo?\n\t\tend\n\tend", "def try_resolve_conflict\n # retry the merge\n working_changeset = self[nil]\n merge_changeset = working_changeset.parents.last\n \n # backup the current file to a .resolve file (but retain the extension\n # so editors that rely on extensions won't bug out)\n path = working_join file\n File.copy(path, path + \".resolve\" + File.extname(path))\n \n # try to merge the files!\n merge_state.resolve(file, working_changeset, merge_changeset)\n \n # restore the backup to .orig (overwriting the old one)\n File.move(path + \".resolve\" + File.extname(path), path + \".orig\" + File.extname(path))\n end", "def revert!\n %x[git checkout master]\nend", "def reset\n set_deferred_status(nil)\n end", "def revert_to version\r\n while [email protected]? && @data.version > version\r\n @data = @data.prev_version\r\n end\r\n [email protected]?\r\n end", "def revert_unchanged_files(files = nil)\n files = (files && files.flatten) || self.files\n unless files.empty?\n @perforce.run(\"revert\", \"-a\", \"-c\", @number, *files)\n end\n end", "def revert\n @version = PaperTrail::Version.find(params[:id])\n if @version.reify\n @version.reify.save!\n else\n @version.item.destroy\n end\n link_name = params[:redo] == \"true\" ? \"undo\" : \"redo\"\n link = view_context.link_to(link_name, revert_version_path(@version.next, :redo => !params[:redo]), class: \"btn btn-warning\", :method => :post)\n redirect_to :back, :notice => \"Undid #{@version.event}. #{link}\".html_safe\n end", "def file_revert(file, ref)\n if file_revisions(file).map { |r| r[:commit] }.include? ref\n file = file.gsub(%r{^/}, '')\n full_path = File.expand_path(file, @root)\n content = File.read(file_revision_at(file, ref))\n File.open(full_path, 'w') { |f| f.puts content }\n end\n end", "def p4_revert dir\n puts \"reverting #{dir}\"\n p4sh \"p4 revert #{dir}/...\"\n end", "def undo\n return unless applied = self.applied\n\n applied.undo\n\n self.applied = applied.parent\n self.pending = applied\n end", "def undo_changes\n @statistics[:rejected] += 1\n \n # restore state of previous solution\n case @last_change\n when :offset\n @current_offset[@changed_sc] = @previous_offset\n when :speed\n @current_speed[@changed_coord] = @previous_speed\n else\n raise \"Don't know how to undo a '#{@last_change}' change!\"\n end\n \n # delta-restore the value of the solution\n for coord, old_value in @delta_contribution\n current_value = @coord_contribution[coord]\n @direction_sum[coord.left_to_right] -= current_value\n @coord_contribution[coord] = old_value\n @direction_sum[coord.left_to_right] += old_value\n end\n \n store_current_value\n \n raise \"Restoration of previous solution failed after change in #{@last_change}:\\n\" +\n \"expected value #{@current_value_check} got #{@current_value}\" if (1 - @current_value_check / @current_value).abs > EPS\n end", "def rescind!\n Decision.transaction do\n if initial\n paper.rescind_initial_decision!\n else\n paper.rescind_decision!\n end\n update! rescinded: true\n end\n end", "def rollback_to_latest_milestone!\n self.revert_to_milestone! self.milestones.count\n end", "def fix_up_references\n if self.task_type.nil? and !self.task_type_id.nil?\n self.task_type = TaskType.find(self.task_type_id)\n end\n if self.task_status.nil? and !self.task_status_id.nil?\n self.task_status = TaskType.find(self.task_status_id)\n end\n end", "def decline!\n return unless accepted.nil?\n\n update(accepted: false)\n end", "def unresolve_external_fragment(fragment)\r\n return if @resolved_refs.nil?\r\n raise \"can not unresolve, missing fragment information\" if @resolved_refs == :dirty || @resolved_refs[:unknown]\r\n rrefs = @resolved_refs[fragment]\r\n @resolved_refs.delete(fragment)\r\n unresolve_refs(rrefs) if rrefs\r\n end", "def deprovision\n reverse_method_proxy(:deprovision)\n\n true\n end", "def revert!\n ::ActionView::Template.class_eval do\n alias_method :compile!, :cb_original_compile! # rubocop:disable Lint/DuplicateMethods\n undef_method :cb_patched_compile!\n end\n end", "def revert\n remove_from_approved_tickets_count\n @application.update_attributes(status: 'pending')\n redirect_to admin_event_path(@application.event_id),\n flash: { info: \"#{ @application.name}'s application has been changed to pending\" }\n end", "def demote_resolver(res)\n TheLog.debug(\"Demoting resolver priority for #{res.server} to bottom\\n\")\n # @parent.single_res_mutex.synchronize {\n @parent.single_resolvers.delete(res)\n @parent.single_resolvers.push(res)\n # }\n end", "def revert_changes(old_algorithm)\n new_algorithm = old_algorithm.deep_copy\n new_algorithm.update_attributes(next: nil)\n old_algorithm.update_attributes(next: new_algorithm)\n self.destroy\n new_algorithm.update_attributes(status: :published)\n new_algorithm.update_attributes(status_message: \"Algorithm is published\")\n new_algorithm\n end", "def revert_clone(version)\n return self if self.version == version\n\n result = self.class.find(id)\n result = nil unless result.revert_to(version)\n result\n end", "def rollback!\n restore_attributes\n end", "def rollback_to_latest_milestone\n self.revert_to_milestone self.milestones.count\n end", "def resolve_success\n nil\n end", "def revert(files=nil, opts={})\n # get the parents - used in checking if we haven an uncommitted merge\n parent, p2 = dirstate.parents\n \n # get the revision\n rev = opts[:revision] || opts[:rev] || opts[:to]\n \n # check to make sure it's logically possible\n unless rev || p2 == Amp::Mercurial::RevlogSupport::Node::NULL_ID\n raise abort(\"uncommitted merge - please provide a specific revision\")\n end\n \n # if we have anything here, then create a matcher\n matcher = if files\n Amp::Match.create :files => files ,\n :includer => opts[:include],\n :excluder => opts[:exclude]\n else\n # else just return nil\n # we can return nil because when it gets used in :match => matcher,\n # it will be as though it's not even there\n nil\n end\n \n # the changeset we use as a guide\n changeset = self[rev]\n \n # get the files that need to be changed\n stats = status :node_1 => rev, :match => matcher\n \n ###\n # now make the changes\n ###\n \n ##########\n # MODIFIED and DELETED\n ##########\n # Just write the old data to the files\n (stats[:modified] + stats[:deleted]).each do |path|\n File.open path, 'w' do |file|\n file.write changeset.get_file(path).data\n end\n UI::status \"restored\\t#{path}\"\n end\n \n ##########\n # REMOVED\n ##########\n # these files are set to be removed, and have thus far been dropped from the filesystem\n # we restore them and we alert the repo\n stats[:removed].each do |path|\n File.open path, 'w' do |file|\n file.write changeset.get_file(path).data\n end\n \n staging_area.normal path # pretend nothing happened\n UI::status \"saved\\t#{path}\"\n end\n \n ##########\n # ADDED\n ##########\n # these files have been added SINCE +rev+\n stats[:added].each do |path|\n remove path\n UI::status \"destroyed\\t#{path}\"\n end # pretend these files were never even there\n \n staging_area.save\n true # success marker\n end", "def unrealize\n return unless @realized\n unrealize_dependents\n unrealize_self\n @realized = false\n end", "def rollback()\n oldpos = @checkpoints.pop\n unless oldpos\n oldpos = 0\n end\n self.pos = oldpos\n return self \n end", "def uncomplete\n @project.uncomplete!\n respond_to do |format|\n format.html { redirect_to request.referer||project_path(@project), notice: 'Project uncompleted successfully!' }\n format.json { head :no_content }\n end\n end", "def transferee\n return @transferee\n end", "def restore\n RESTORE\n end", "def resolve\n debug do\n <<~MSG\n Filtering out #{conflicts.size} conflicts from #{base_local_diffs.size + base_remote_diffs.size} diffs\n Remaining diffs #{unconflicted_diffs.size}\n MSG\n end\n\n conflicts.each_with_object(unconflicted_diffs) do |conflict, diffs|\n # TODO: this will result in diffs being out of order from their\n # original order. diffs should be flagged as conflicted and\n # this method should instead remove the conflicted flag.\n diffs.concat(@conflict_resolver.resolve(conflict))\n # TODO: if the conflict is resolved, it should be removed from the\n # @conflicts array.\n end\n end", "def resolve\n self # simple Check never has references\n end", "def revert_pos(data); end", "def reset_forward\n return unless dependency_forward_any?\n each_forward_dependency do |task|\n task.reset\n end\n end", "def reverted?\n version != last_version\n end", "def revert!\n @shell.call \"rm -rf #{self.checkout_path}\"\n\n last_deploy = previous_deploy_name(true)\n\n if last_deploy && !last_deploy.empty?\n @shell.symlink \"#{self.deploys_path}/#{last_deploy}\", self.current_path\n\n Sunshine.logger.info @shell.host, \"Reverted to #{last_deploy}\"\n\n else\n @crontab.delete!\n\n Sunshine.logger.info @shell.host, \"No previous deploy to revert to.\"\n end\n end", "def revert!(objects = [], commit = nil)\n revert(objects, commit)\n commit(nil, \"Reverted commit #{self.repository.commits.first.sha}\")\n end", "def restore_attachment_reference_change\n return unless attachment_reference_changed?\n\n self.attachment_reference = @original_attachment\n clear_attachment_change\n end", "def reset!\n raise if working?\n @is_complete = false\n end", "def obsolete!\n update!(:revision => -1)\n end", "def revert_additional_behaviour_after_save(revert_to, current_newest, new)\n\t\t# change report/block/delete\n\t\tchange_rbc current_newest, new, 0\n\tend", "def cancel\n self.solved(:abort)\n end", "def repair!\n update!\n end", "def resolve_reference; end", "def restore_attachment_reference_change\n return unless attachment_reference_changed?\n self.attachment_reference = @original_attachment\n clear_attachment_change\n end", "def payload_for_reverted\n super\n end", "def revert\n @update_span = params[:update]\n @object = referenced_object\n if current_user.role? :superadmin\n @version = PaperTrail::Version.find(params[:id])\n @version.reify.save!\n @object = @Klass.find(@version.item_id)\n authorize!(:revert, @object) if cancan_enabled?\n respond_to do |format|\n format.html { } unless @Klass.not_accessible_through_html?\n format.js { render :close }\n end\n end\n end", "def deplete(result)\n self.result = result\n self.depleted = true\n self.depleted_at = Time.now\n Fibril.deplete_guard(self, result)\n end", "def revert_sandbox_file_commit\n unless original_committed_file_location\n raise Chef::Exceptions::IllegalChecksumRevert, \"Checksum #{self.inspect} cannot be reverted because the original sandbox file location is not known\"\n end\n\n Chef::Log.warn(\"Reverting sandbox file commit: moving #{@storage} back to #{original_committed_file_location}\")\n @storage.revert(original_committed_file_location)\n cdb_destroy\n end", "def unstage\n self.staging=(nil) # yes, the self is required. not sure why.\n end", "def undo\n\t\t\n\tend", "def undo\n\t\t\n\tend", "def reject\n transition_to :rejected\n end", "def restore!\n restore\n save!(validate: false)\n end", "def clean_post_fetch\n @base = nil\n end", "def mark_as_restored\n @restored = true\n end", "def rollback\n # implement in subclasses\n end", "def restore\n return unless @cached\n update(@cached[:y], @cached[:x])\n @cached = nil\n end", "def reset_change!\n @_changed = false\n self\n end", "def performed\n design.clear_version_cache\n end", "def revert_to_milestone!(n)\n verify_milestone_exists n\n self.revert_to! self.milestones[n.to_i-1].version\n end" ]
[ "0.7244867", "0.7137545", "0.6626651", "0.64322037", "0.6375228", "0.6312392", "0.63080513", "0.61527157", "0.607998", "0.6076882", "0.607032", "0.60539263", "0.6034204", "0.602577", "0.60107523", "0.597025", "0.59442115", "0.5926339", "0.5906725", "0.59026825", "0.58871853", "0.5886285", "0.5886285", "0.58631647", "0.58211774", "0.58186513", "0.58038265", "0.5767427", "0.57125455", "0.5686122", "0.5674262", "0.56549156", "0.5646564", "0.56283116", "0.5599588", "0.5598035", "0.5598035", "0.55918247", "0.5542806", "0.551532", "0.55153126", "0.5487323", "0.5455167", "0.54463065", "0.54369724", "0.54099214", "0.54047865", "0.5403147", "0.54024774", "0.5391627", "0.53865516", "0.538434", "0.53842795", "0.5374939", "0.53748196", "0.53726137", "0.5371106", "0.53636974", "0.534986", "0.5329389", "0.53091955", "0.52852345", "0.5279555", "0.5275154", "0.5271536", "0.52690905", "0.52671134", "0.5263559", "0.52611274", "0.52433866", "0.52366054", "0.5234119", "0.52340335", "0.5227903", "0.5223785", "0.5222106", "0.5220113", "0.52153575", "0.5214732", "0.52122486", "0.5204184", "0.5203692", "0.5196652", "0.51958483", "0.5195761", "0.518514", "0.5184317", "0.51813203", "0.51756316", "0.517335", "0.517234", "0.517234", "0.5171798", "0.5161653", "0.5161309", "0.5151817", "0.5142151", "0.51288223", "0.51280725", "0.5125706", "0.512487" ]
0.0
-1
def package(&block) instance_eval(&block) end def create_method(name, &block) self.send(:define_method, name, &block) end allows appending of configure flags for the current package (default) gd.configure do |c| c << 'withwhatever=prefix' end or alternatively append configure flags for other packages: gd.configure :php do |c| c << 'withgd=prefix' end
def configure(*args) conf_target = self if args[0].is_a?(String) or args[0].is_a?(Symbol) conf_target = FACTORY.send(args[0].to_sym) end yield conf_target.instance_variable_get("@configure") if block_given? conf_target.instance_variable_get("@configure").join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install!\n @method_name ||= self.name.split('::').last.downcase.to_sym\n _cls = self # for self is obscured in define_method block's body\n ( class << Vendorificator::Config ; self ; end ).\n send(:define_method, @method_name ) do |name, *args, &block|\n mod = _cls.new(name.to_s, *args, &block)\n self[:modules] << mod\n mod\n end\n end", "def create_method( name, &block )\n self.class.send( :define_method, name, &block )\n end", "def install_configure_in(base)\n base.class_eval <<-EOF\n class << self\n # The central configure method\n # @params [Proc] block the block to configure host module with\n # @raise [ArgumentError] error when not given a block\n # @example Configure a configuration\n # MyGem.configure do |c|\n # c.foo = :bar\n # end\n #\n def configure(&block)\n raise ArgumentError, 'can not configure without a block' unless block_given?\n @configuration = #{self}::Configuration.new(@configuration_defaults, @configurable, &block)\n end\n end\n EOF\n end", "def add_convenience_method(name_, pattern_, indexes_)\n @mutex.synchronize do\n raise ConfigurationLockedError if @locked\n name_ = name_.to_sym\n if @methods.has_key?(name_)\n raise IllegalConfigurationError, \"Factory method already exists\"\n end\n @methods[name_] = [pattern_, indexes_]\n end\n self\n end", "def create_method(name, &block)\n\t\t\tself.class.send(:define_method, name, &block)\n\t\tend", "def di_init(name, &block)\n di_define_method(name, block, nil)\n end", "def define(name, code=nil, &blk)\r\n\t\t\tif code and not blk then blk = proc{instance_eval(code)} end\r\n\t\t\tmetaclass.__send__(:define_method, name, &blk)\r\n\t\t\t@commands << name.to_s unless @commands.include?(name.to_s)\r\n\t\tend", "def scaffold_define_method(name, &block)\n scaffolded_methods.add(name)\n define_method(name, &block)\n end", "def add( name , options={} , &proc )\n options = name if name.is_a? Hash\n if options[:package]\n package options.delete(:package)\n else\n package self\n end.add( name , options , &proc )\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def create_method(name, &block)\n eigen = class << self; self; end\n eigen.send(:define_method, name, &block)\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def run\n install if methods.include?(:install)\n methods.select { |m| m.to_s.start_with?(\"configure\") }\n .each { |m| send(m) }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def method_missing(method, *args, &block)\n self.class.class_eval do\n attr_accessor method.to_sym\n\n # Defined a method according to the given method name\n define_method method.to_sym do\n obj = OpenStruct.new(request_options: @request_options)\n obj.extend Zcloudjp.const_get(method.capitalize.to_sym)\n instance_variable_set(:\"@#{method}\", obj)\n end\n end\n\n # Sends to the now-defined method.\n self.__send__(method.to_sym)\n end", "def method_missing(method, *args, &block)\n if /^define_(?<klass>[a-z0-9_]+)_group/ =~ method\n define_group_for_class(klass.classify, args[0], &block)\n else\n super\n end\n end", "def newcommand(options, &block)\n raise \"No name given in command\" unless options.include?(:name)\n\n command = options[:name]\n\n SLAF::Commands.module_eval {\n define_method(\"#{command}_command\", &block)\n }\n\n SLAF::command_options || SLAF.command_options = {}\n\n if options.include?(:allow_arguments)\n SLAF::command_options[command] = options[:allow_arguments]\n else\n SLAF::command_options[command] = false\n end\nend", "def method_missing(method_name, *args, &block)\n if self.class.has_dsl_attribute?(method_name.to_sym)\n @builded_attributes[method_name.to_sym] = if block_given?\n build_hash_from_block(&block)\n else\n args[0]\n end\n else\n raise \"Configuration '#{method_name}' is not allowed for #{self}\"\n end\n end", "def meta_def name, &blk\r\n meta_eval { define_method name, &blk }\r\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def build(name, *traits_and_overrides, &block); end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def internal_create_override(method_name, mode=:instance, &block)\n builder = ExpectationBuilder.new method_name\n block.call builder unless block.nil?\n exp = builder.build\n exp.events = events[mode] \n expectations.add_expectation exp, mode\n exp\n end", "def meta_def( name, &blk )\r\n meta_eval { define_method name, &blk }\r\n end", "def configure &block\n\t\tinstance_eval &block\n\tend", "def meta_def(name, &block)\n meta_eval{define_method(name, &block)}\n end", "def create\n\n # Let's get a few things straight\n @work_dir = \"#{@resource[:cache_dir]}/#{@resource[:extension]}\"\n @php_version_prefix = \"#{@resource[:phpenv_root]}/versions/#{@resource[:php_version]}\"\n @resource[:compiled_name] ||= \"#{@resource[:extension]}.so\"\n\n # Update the repository\n fetch @resource[:version], @resource[:extension]\n\n # Prepare for building\n prep_build @resource[:version]\n\n # PHPize, build & install\n phpize\n configure\n make\n install\n end", "def meta_def(name, &blk)\n meta_eval { define_method name, &blk }\n end", "def pkg_default_configure(args='')\n <<CONFIGURE\nautoreconf\n\nCC=\"#{$bsyscfg.get_cc}\" \\\\\nCPP=\"#{$bsyscfg.get_cpp}\" \\\\\nCXX=\"#{$bsyscfg.get_cxx}\" \\\\\nCFLAGS=\"#{$bsyscfg.get_cflags} #{@cflags}\" \\\\\nCPPFLAGS=\"#{$bsyscfg.get_cppflags} #{@cppflags}\" \\\\\nCXXFLAGS=\"#{$bsyscfg.get_cxxflags} #{@cxxflags}\" \\\\\nLDFLAGS=\"#{$bsyscfg.get_ldflags} #{@ldflags}\" \\\\\n${SRCDIR}/configure #{args}\nCONFIGURE\n end", "def di(name, &block)\n rc = ::Dizzy::DSL::RuleContext.new\n rc.instance_exec(&block)\n\n di_define_method(name, rc.init_proc, rc.wire_proc)\n end", "def define_and_call_method(method, &block)\n self.class.send(:define_method, method, block)\n send method\n end", "def create_override(method_name, &block)\n internal_create_override method_name, :instance, &block\n end", "def configure(&block); end", "def configure(&block); end", "def meta_def( name, &blk )\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def meta_def name, &blk\n meta_eval { define_method name, &blk }\n end", "def configure &blk\n instance_eval &blk\n end", "def method_builder; end", "def helper_method(name, &block)\n application.send(:define_method, name, &block)\n end", "def class_def name, &blk\r\n class_eval { define_method name, &blk }\r\n end", "def configure(&blk)\n instance_eval &blk\n end", "def create_method(method, *args, &block)\n if respond_to?(method, true)\n raise AlreadyImplemented, \"#{inspect}::#{method}\"\n else\n define_method(method, *args, &block)\n end\n end", "def define method_name, &block\n machine.named_procs[method_name] = block\n end", "def meta_def(name, &blk)\n meta_eval { define_method(name, &blk) }\n end", "def mk_method(proc)\n @klass.send(:define_method, @method_name, proc)\n end", "def compile!( name, &block )\n # Get the already defined method\n m = instance_method( name )\n\n # Create a new method with leading underscore\n define_method( \"_#{name}\", &block )\n _m = instance_method( \"_#{name}\" )\n remove_method( \"_#{name}\" )\n\n # Define instance method\n define!( name, _m, m, &block )\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def meta_def name, &block\n meta_eval { define_method name, &block }\n end", "def configure; end", "def install_configure_in(base)\n base.instance_eval <<-EOF\n # Configuration class for host module\n #\n #{base.name}::Configuration = Class.new(Configurations::Configuration)\n\n # The central configure method\n # @params [Proc] block the block to configure host module with\n # @raise [ArgumentError] error when not given a block\n # @example Configure a configuration\n # MyGem.configure do |c|\n # c.foo = :bar\n # end\n #\n def self.configure(&block)\n fail ArgumentError, \"configure needs a block\" unless block_given?\n include_configuration_type!(#{base.name}::Configuration)\n\n set_configuration!(&block)\n end\n\n # A reader for Configuration\n #\n def configuration\n return Thread.current[configuration_name] if Thread.current.key?(configuration_name)\n\n @configuration_defaults && configure {}\n end\n\n\n private\n\n # Sets the configuration instance variable\n #\n def self.set_configuration!(&block)\n Thread.current[configuration_name] = #{base.name}::Configuration.__new__(\n configuration_options,\n &block\n )\n end\n\n def self.configuration_name\n :\"#{underscore_camelized(base.name)}\"\n end\n\n EOF\n end", "def meta_def(name, &block)\n meta_eval { define_method(name, &block) }\n end", "def def_method(object, method_name, filename=nil)\n\t\t\t\tm = object.is_a?(Module) ? :module_eval : :instance_eval\n\t\t\t\tobject.__send__(m, \"def #{method_name}; #{@src}; end\", filename || @filename || '(eruby)')\n\t\t\t\t#erb.rb: src = self.src.sub(/^(?!#|$)/) {\"def #{methodname}\\n\"} << \"\\nend\\n\" #This pattern insert the 'def' after lines with leading comments\n\t\t\tend", "def configure(&block)\n self.instance_eval(&block)\n end", "def ruby_package(options)\n package_common(:ruby, options) do |pkg|\n # Documentation code. Ignore if the user provided its own documentation\n # task, or disabled the documentation generation altogether by setting\n # rake_doc_task to nil\n if !pkg.has_doc? && pkg.rake_doc_task\n pkg.with_doc\n end\n if !pkg.test_utility.has_task?\n if !pkg.test_utility.source_dir\n test_dir = File.join(pkg.srcdir, 'test')\n if File.directory?(test_dir)\n pkg.test_utility.source_dir = test_dir\n end\n end\n\n if pkg.test_utility.source_dir\n pkg.with_tests\n end\n end\n\n yield(pkg) if block_given?\n end\nend", "def define(&blk)\n instance_eval(&blk)\n end", "def package_file\n self.class.must_implement(__method__)\n end", "def create_method( class_name , method_name , args = {})\n raise \"create_method #{class_name}.#{class_name.class}\" unless class_name.is_a? Symbol\n clazz = Register.machine.space.get_class_by_name class_name\n raise \"No such class #{class_name}\" unless clazz\n create_method_for( clazz , method_name , args)\n end", "def def(name, &block)\n @runtime_methods[name.to_s] = block\n end", "def helper(name, &block)\n (class << self; self; end).send(:define_method, name, &block)\n end", "def configure(&block)\n instance_eval(&block)\n end", "def configure(&block)\n instance_eval(&block)\n end", "def grammed_by(method_name, options = {})\n mod = get_or_set_const(:\"GammerMod#{object_id}\")\n mod.class_exec(method_name, options, &Grammer::MacroHandler::DEFINE)\n prepend mod\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def class_def name, &blk\n class_eval { define_method name, &blk }\n end", "def create_methods!\n return unless type == :normal\n\n fn = name\n dmm = session_class._dynamic_methods_module\n mn = name.to_s.downcase\n\n dmm.define_method(mn) do\n self[fn]\n end\n\n dmm.define_method(\"#{mn}=\") do |new_value|\n self[fn] = new_value\n end\n\n if visibility == :private\n dmm.send(:private, mn, \"#{mn}=\".to_sym)\n end\n end", "def di_wire(name, clazz, *args, &block)\n init_proc = lambda{ clazz.new(*args) }\n di_define_method(name, init_proc, block)\n end", "def add(conf, package)\n raise NoMethodError.new \"Not implemented\"\n end", "def define_class_method(name, &block)\n (class << self; self; end).instance_eval do\n define_method name, &block\n end\n end", "def create_class_override(method_name, &block)\n internal_create_override method_name, :class, &block \n end", "def define\n end", "def define\n end", "def autotools_package(options, &block)\n package_common(:autotools, options) do |pkg|\n pkg.depends_on 'autotools'\n common_make_based_package_setup(pkg)\n yield(pkg) if block_given?\n end\nend", "def get_definition(cls, bld, fun)\r\n bld.add(\"//\")\r\n bld.add(\"// Configuration \")\r\n bld.add(\"//\")\r\n\r\n entityClassName = XCTECSharp::Utils.instance.getStyledClassName(cls.getUName())\r\n configFunName = \"Configure(EntityTypeBuilder<\" + entityClassName + \"> builder)\"\r\n\r\n bld.startFunction(\"public void \" + configFunName)\r\n\r\n get_body(cls, bld, fun)\r\n\r\n bld.endFunction\r\n end", "def package_setup\n raise NotImplementedError\n end", "def redefine_method(name, &block)\n if instance_methods(false).any? {|x| x.to_s == name.to_s }\n method = instance_method(name)\n mod = Module.new do\n define_method(name) {|*args| method.bind(self).call(*args) }\n end\n remove_method(name)\n include(mod)\n end\n include(Module.new { define_method(name, &block) })\n end", "def class_def( name, &blk )\r\n class_eval { define_method name, &blk }\r\n end", "def class_def(name, &blk)\n class_eval { define_method name, &blk }\n end", "def define_dynamic_config_field(method_sym)\n class_eval <<-RUBY\n def #{method_sym}\n @values[:#{method_sym}]\n end\n\n def #{method_sym}=(value)\n @values[:#{method_sym}] = value\n end\n RUBY\n end", "def configure(&block)\n self.instance_eval(&block) if block_given?\n end", "def define &blk\n self.instance_eval(&blk)\n end", "def build_method\nend", "def build_method\nend", "def class_def( name, &blk )\n class_eval { define_method name, &blk }\n end", "def orogen_package(options, &block)\n package_common(:orogen, options) do |pkg|\n common_make_based_package_setup(pkg)\n yield(pkg) if block_given?\n end\nend" ]
[ "0.6358286", "0.59426403", "0.5877358", "0.5869282", "0.5863037", "0.5859998", "0.5667525", "0.56672543", "0.5645333", "0.5634808", "0.5634808", "0.56293875", "0.56216025", "0.56216025", "0.5618099", "0.55913615", "0.55913615", "0.5585487", "0.5579566", "0.55751896", "0.5568414", "0.55494404", "0.55137116", "0.55112565", "0.55112565", "0.5508749", "0.5503176", "0.55008435", "0.54990464", "0.54905957", "0.5489285", "0.5487721", "0.54822487", "0.54771006", "0.5474841", "0.5466679", "0.546372", "0.5460425", "0.5460425", "0.5455203", "0.5453245", "0.5453245", "0.5453245", "0.5453245", "0.5453245", "0.5453245", "0.5453245", "0.54457915", "0.5435718", "0.54220223", "0.5420587", "0.5395659", "0.53930885", "0.5390356", "0.53791213", "0.5368393", "0.53681266", "0.53623384", "0.53589165", "0.53518176", "0.5349511", "0.5338309", "0.5337877", "0.533415", "0.5327564", "0.5324852", "0.53236014", "0.5315355", "0.531202", "0.53109366", "0.53030896", "0.53030896", "0.5300983", "0.5297043", "0.5297043", "0.5297043", "0.5297043", "0.5297043", "0.5297043", "0.5296499", "0.52959764", "0.52949625", "0.5289202", "0.52878124", "0.5274533", "0.52692395", "0.5267553", "0.5267553", "0.52632856", "0.52569735", "0.5252903", "0.5251851", "0.5248418", "0.5245237", "0.524196", "0.5241546", "0.5232681", "0.5205375", "0.5205375", "0.51982427", "0.5191693" ]
0.0
-1
def package_dependencies(force=false) return [] if is_installed unless force return package_depends_on end
def package_depends_on depends_on end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dependencies\n []\n end", "def dependencies\n []\n end", "def build_local_dependency_list(force=true)\n install_root = self.internal_package_root\n\n unless File.exists?(install_root)\n return nil unless force\n rebuild_dependency_list\n end\n\n Dir[File.join(install_root, '*')].map do |package_name|\n pkg = BPM::Package.new package_name\n pkg.load_json\n pkg\n end\n end", "def dependencies\n []\n end", "def dependencies\n self.config.depends || []\n end", "def dependencies\n @dependencies ||= ElmPackage.dependencies 'elm-package.json',\n silent: false\n end", "def dependencies\n @dependencies ||= []\n end", "def dependencies\n @dependencies ||= []\n end", "def dependencies\n @dependencies ||= []\n end", "def dependencies\n @dependencies ||= []\n end", "def dependencies\n @dependencies ||= []\n end", "def runtime_dependencies\n dependencies.select(&:runtime?)\n end", "def requires\n require_items.collect(&:package)\n end", "def dependent_gems(check_dev=true)\n out = []\n Gem::Specification.each do |spec|\n deps = check_dev ? spec.dependencies : spec.runtime_dependencies\n deps.each do |dep|\n if self.satisfies_requirement?(dep)\n sats = []\n find_all_satisfiers(dep) do |sat|\n sats << sat\n end\n out << [spec, dep, sats]\n end\n end\n end\n out\n end", "def dependencies(pkg)\n pkg.resolve_optional_dependencies\n deps_rock_packages = pkg.dependencies.map do |pkg_name|\n debian_name(Autoproj.manifest.package(pkg_name).autobuild)\n end.sort\n\n pkg_osdeps = Autoproj.osdeps.resolve_os_dependencies(pkg.os_packages)\n # There are limitations regarding handling packages with native dependencies\n #\n # Currently gems need to converted into debs using gem2deb\n # These deps dependencies are updated here before uploading a package\n # \n # Generation of the debian packages from the gems can be done in postprocessing step\n # i.e. see convert_gems\n \n deps_osdeps_packages = []\n native_package_manager = Autoproj.osdeps.os_package_handler\n _, native_pkg_list = pkg_osdeps.find { |handler, _| handler == native_package_manager }\n\n deps_osdeps_packages += native_pkg_list if native_pkg_list\n\n # Update global list\n @osdeps += deps_osdeps_packages\n\n non_native_handlers = pkg_osdeps.collect do |handler, pkg_list|\n if handler != native_package_manager\n [handler, pkg_list]\n end\n end.compact\n\n non_native_handlers.each do |pkg_handler, pkg_list|\n # Convert native ruby gems package names to rock-xxx \n if pkg_handler.kind_of?(Autoproj::PackageManagers::GemManager)\n pkg_list.each do |name,version|\n @ruby_gems << [name,version]\n deps_osdeps_packages << debian_ruby_name(name)\n end\n else\n raise ArgumentError, \"cannot package #{pkg.name} as it has non-native dependencies (#{pkg_list}) -- #{pkg_handler.class} #{pkg_handler}\"\n end\n end\n\n # Remove duplicates\n @osdeps.uniq!\n @ruby_gems.uniq!\n\n # Return rock packages and osdeps\n [deps_rock_packages, deps_osdeps_packages]\n end", "def depends_all\n pkg_depends = self.class.depends_all\n if self.class.omnibus_package\n self.class.omnibus_recipes.each { |omni_recipe|\n recipe_file = File.expand_path(omni_recipe + '.rb', File.dirname(filename))\n\n Book.instance.load_recipe(recipe_file, config) do |recipe|\n pkg_depends << recipe.depends_all\n end\n }\n end\n\n pkg_depends.flatten.uniq\n end", "def depends_all\n pkg_depends = self.class.depends_all\n if self.class.omnibus_package\n self.class.omnibus_recipes.each { |omni_recipe|\n recipe_file = File.expand_path(omni_recipe + '.rb', File.dirname(filename))\n\n Book.instance.load_recipe(recipe_file, config) do |recipe|\n pkg_depends << recipe.depends_all\n end\n }\n end\n\n pkg_depends.flatten.uniq\n end", "def get_dependencies\n @dependencies\n end", "def requires\n @requires ||= @dependencies.map { |e| make_path(e.split(RUBY_PKG_SEP)) }.sort.uniq\n end", "def os_dependencies\n []\n end", "def dependencies\n manager.dependencies\n end", "def initial_dependencies\n []\n end", "def direct_dependencies; end", "def runtime_dependencies\n @runtime_dependencies ||= []\n end", "def runtime_dependencies\n @runtime_dependencies ||= []\n end", "def gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem? }\n end", "def manifest_dependencies()\n as_bundle = Bundle.fromProject(self)\n as_bundle.nil? ? [] : as_bundle.bundles.collect{|b| b.resolve}.compact + as_bundle.imports.collect {|i| i.resolve}.flatten\n end", "def development_dependencies\n Gem::Specification.load(gemspec_path.to_s).development_dependencies\n end", "def gem_dependencies(rubygem)\n (latest = latest_gemspec(rubygem)) ?\n latest.dependencies.select {|e| e.type == :runtime }.map {|e| e.name} : []\n end", "def dependencies\n @dependencies\n end", "def go_pkg_deps(pkgs, root_path)\n deps = []\n pkgs.each do |pkg|\n deps << pkg\n `go list -f '{{ join .Deps \"\\\\n\"}}' #{pkg}`.split(\"\\n\").select do |path|\n if path.start_with? root_path\n deps << path\n end\n end\n end\n return deps.sort.uniq\nend", "def go_pkg_deps(pkgs, root_path)\n deps = []\n pkgs.each do |pkg|\n deps << pkg\n `go list -f '{{ join .Deps \"\\\\n\"}}' #{pkg}`.split(\"\\n\").select do |path|\n if path.start_with? root_path\n deps << path\n end\n end\n end\n return deps.sort.uniq\nend", "def getdeps(pkg)\n deps = []\n @pkg.each {|k, v| deps << k if v.include?(pkg) }\n\n return deps\n end", "def install_dependencies(dependencies, force, install_dir)\n return if @options[:ignore_dependencies]\n installed_gems = []\n dependencies.each do |dependency|\n if @options[:include_dependencies] ||\n\t ask_yes_no(\"Install required dependency #{dependency.name}?\", true)\n remote_installer = RemoteInstaller.new(@options)\n installed_gems << remote_installer.install(\n\t dependency.name,\n\t dependency.version_requirements,\n\t force,\n\t install_dir)\n else\n raise DependencyError.new(\"Required dependency #{dependency.name} not installed\")\n end\n end\n installed_gems\n end", "def depends_on\n return @depends_on\n end", "def dependencies; end", "def dependencies; end", "def dependencies; end", "def find_dependencies(env)\n args = [] if (env = env.dup).sub!(REGEXP_DEVPKG,'') # are we in compile mode?\n return [[], [], args] if args && env.empty?\n\n require 'rubygems/remote_fetcher'\n @@deps = YAML.load(fetch(env))['gems'] unless defined?(@@deps)\n @@deps.key?(spec.name) or return(args ? [[], [], args] : nil)\n\n # find dependencies\n case deps = @@deps[spec.name]\n when nil, \"*\" # for nil or '*', use the default extension name\n deps = [\"*\"]\n when String # string of space-delimited packages and extensions\n when Array # array of packages and extensions\n when Hash # hash of packages and extensions, indexed by version requirements\n reqs, deps = deps.find do |reqs, info| # deps is an array or space-delimited string\n Gem::Requirement.new(reqs.split(',')).satisfied_by?(spec.version)\n end\n reqs or return # can't find the right version\n deps ||= [\"*\"] # deps are nil, use the default extension name\n end\n deps = deps.strip.split(/\\s+/) if deps.is_a?(String)\n deps = deps.compact.uniq\n\n # helpful variables\n bcwd = Dir.pwd\n benv = File.dirname(env.split(/[?;#]/,2).first)\n name = \"#{spec.full_name}.tar.gz\"\n\n # grok dependencies\n pkgs, exts = [], []\n deps.each do |item|\n if item.include?(\"*\") || item =~ REGEXP_SCHEMA || item.include?(\".tar.gz\")\n exts << item unless args\n elsif item =~ REGEXP_DEVPKG\n pkgs << $' if args\n elsif item =~ REGEXP_DEVARG\n args << $' if args\n else\n pkgs << item unless args\n end\n end\n exts.map! do |item|\n case item\n when \"*\" then item = File.join(benv, name) # use complete default tarball name\n when /\\A\\*/ then item[0,1] = benv # path relative to env variable\n when /\\A[^\\/]/ then item[0,0] = bcwd + \"/\" # path relative to current directory\n end\n item.gsub(\"*\", name) # swap inline wildcards with default tarball name\n end\n [pkgs, exts, args]\n end", "def required_dependencies\n dependencies - optional_dependencies\n end", "def dependencies\n @dependencies.collect { |name, dependency| dependency }\n end", "def dependencies\n if @options[:dependencies]\n deps = [] << @options[:dependencies]\n deps.flatten.collect { |item|\n item = File.join(item,'**/*') if File.directory?(item)\n Dir.glob item\n }.flatten.uniq.collect { |item|\n File.directory?(item) ? nil : item\n }.compact\n else\n false\n end\n end", "def dependencies\n return @dependencies unless @dependencies.nil?\n @dependencies = [ ]\n lockfile.each_line do |line|\n if line =~ /^\\s{4}([-\\w_.0-9]+)\\s*\\((.*)\\)/\n @dependencies << [$1, $2]\n end\n end\n @dependencies\n end", "def deps(pkg) # FIXME: \"*** PACKAGE MAY NOT BE DELETED *** \"\n if pkg.status != :available\n components = `#{@cmd} -n #{pkg.name}`.split(\"Requires:\\n\")\n if components.size > 1\n return components[1].strip\n else\n return \"[No depends]\"\n end\n else\n if File.exist?(File.expand_path(\"~/Library/Application Support/Guigna/pkgsrc/INDEX\"))\n # TODO: parse INDEX\n end\n \"[Not available]\"\n end\n end", "def find_dependencies(deps=nil, verbose=false)\n \n deps ||= all_dependencies\n\n search_list = Array(deps)\n found = []\n ret = []\n \n # if we discover a new local package via indirect dependencies then\n # it's dependencies will be fetchable one time.\n fetchable = Set.new\n \n until search_list.empty?\n name, version = search_list.shift\n\n if dup = found.find{|p| p.name == name}\n # already found, check for conflicts\n next if satisfied_by?(version, dup.version)\n raise PackageConflictError.new(name, dup.version, version)\n end\n\n pkg = locate_package(name, version, verbose)\n if pkg.nil? && fetchable.include?(name)\n fetchable.reject! { |x| x == name }\n core_fetch_dependency(name, version, :runtime, true) \n pkg = locate_package name, version, verbose\n end\n \n raise PackageNotFoundError.new(name, version) unless pkg\n\n found << pkg\n\n # Look up dependencies of dependencies\n new_deps = Array(pkg.dependencies) + Array(pkg.dependencies_build)\n if has_local_package? pkg.name\n new_deps += Array(pkg.dependencies_development)\n new_deps.each { |dep| fetchable.add dep.first }\n end\n \n search_list += new_deps\n\n ret << pkg\n end\n\n ret\n end", "def resolve_dependencies(dependencies)\n dependencies.inject([]) do |deps, dep|\n deps + dep.determine(:ubuntu, :precise).map do |pkg, version|\n !version.nil? ? \"#{pkg} (#{version})\" : pkg\n end\n end.join(', ')\n end", "def core_fetch_dependencies(deps, verbose)\n deps.each do |pkg_name, pkg_version|\n core_fetch_dependency pkg_name, pkg_version, :runtime, verbose\n end\n end", "def get_requirements\n result = `rake gems 2>&1`\n parse_required(result) + parse_missing(result) + parse_deps(result)\n end", "def non_gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| !r.gem? }\n end", "def dependencies\n @dependencies ||= {}\n end", "def required_gem_list\n Mack::Utils::GemManager.instance.required_gem_list\n end", "def extension_dependencies\n latest_extension_version.try(:extension_dependencies) || []\n end", "def arduino_library_dependencies\n return [] unless library_properties?\n return [] if library_properties.depends.nil?\n\n library_properties.depends\n end", "def packages\n @packages ||= []\n end", "def packages\n @packages ||= []\n end", "def gem_dependencies(list, gem_dependencies, options = {})\n gem_dependencies.each do |gd|\n if options['excludes'] && options['excludes'].to_s.split(',').include?(gd.name)\n next\n end\n\n gs = gd.matching_specs.first\n if gs\n unless list[gs.name]\n list[gs.name] = gs\n unless gs.dependencies.empty?\n list = gem_dependencies(list, gs.dependencies, options)\n end\n end\n else\n unless list[gd.name]\n list[gd.name] = Gem::Specification.new(\n gd.name,\n gd.requirements_list.last.scan(/[\\d\\.\\w]+/).first\n )\n rm_dep = remote_dependencies(gd.name, gd.requirements_list.last)\n unless rm_dep.empty?\n list = gem_dependencies(list, rm_dep, options)\n end\n end\n end\n end\n\n list\n end", "def packages\n # don't include go std packages\n # don't include packages under the root project that aren't vendored\n go_list_deps\n .reject { |pkg| go_std_package?(pkg) }\n .reject { |pkg| local_package?(pkg) }\n end", "def install_dependencies\n raise 'Not implemented'\n end", "def dependencies\n @dependencies.values\n end", "def enabled_dependencies\n @dependencies.reject(&:ignore?)\n end", "def find_dependencies\n\t\tunless GEMDEPS_FILE.readable?\n\t\t\tself.prompt.warn \"Deps file (%s) is missing or unreadable, assuming no dependencies.\" %\n\t\t\t\t[ GEMDEPS_FILE ]\n\t\t\treturn []\n\t\tend\n\n\t\tfinder = Rake::DevEiate::GemDepFinder.new( GEMDEPS_FILE )\n\t\tfinder.load\n\t\treturn finder.dependencies\n\tend", "def default_requires\n PackageList.new\n end", "def fetch_development_dependencies # :nodoc:\n end", "def load_dependencies\r\n @local_gems.each do |gem_info|\r\n gem_file_name = gem_info.gem_file\r\n gem_name = installed_as_name_for( short_form_of_gem_name( gem_file_name ) )\r\n @required_gem_names.delete gem_file_name\r\n end\r\n @required_gem_paths.each do |gem_path|\r\n gem_short_name = short_form_of_gem_name gem_path\r\n if @required_gem_names.include? gem_short_name\r\n puts \"installing #{gem_path}\"\r\n installer = @force_require ? PreloadingInstaller.new( gem_path, @local_gems ) : Installer.new( gem_path )\r\n installer.install\r\n end\r\n end\r\n end", "def dependencies(include_parent = false)\n []\n end", "def dependencies(include_parent = false)\n []\n end", "def dependencies(include_parent = false)\n []\n end", "def dependencies\n version_req = if options[:version]\n ::Gem::Requirement.create(options[:version])\n else\n ::Gem::Requirement.default\n end\n if gem_dir\n ::Gem.clear_paths; ::Gem.path.unshift(gem_dir)\n ::Gem.source_index.refresh!\n end\n deps = []\n ::Gem.source_index.each do |fullname, gemspec| \n if version_req.satisfied_by?(gemspec.version)\n deps << ::Gem::Dependency.new(gemspec.name, \"= #{gemspec.version}\")\n end\n end\n ::Gem.clear_paths if gem_dir\n deps.sort\n end", "def installed_packages()\n\t\t\tend", "def load_dependencies\n dependencies.each { |dependency| dependency }\n end", "def development_dependencies\n dependencies.select {|d| d.type == :development }\n end", "def bundler_dependencies_for(bundler_runtime, *groups); end", "def dependent_modules\n out = [ ]\n @dependencies.each { |dependency| out << @module_set[dependency] }\n out\n end", "def packages\n return @packages if @packages\n\n @packages = resolve_packages.map do |pkg|\n next if ignored?(pkg)\n\n package_set = pkg.kind_of? Autoproj::InstallationManifest::PackageSet\n pkg = pkg.to_h\n local_dir = if package_set\n pkg[:raw_local_dir]\n else\n pkg[:importdir] || pkg[:srcdir]\n end\n\n Autoproj::Daemon::PackageRepository.new(\n pkg[:name] || pkg[:package_set],\n pkg[:vcs],\n package_set: package_set,\n local_dir: local_dir,\n ws: ws\n )\n end.compact\n @packages\n end", "def requires\n []\n end", "def dependencies\n @dependencies ||= begin\n YARD::Registry.all(:dependency)\n end\nend", "def dependencies\n @dependencies ||= Set.new\n end", "def dependencies\n EMPTY_SET\n end", "def dependent_specs\n runtime_dependencies.map {|dep| dep.to_specs }.flatten\n end", "def depends_upon(match_name) #, constraint)\n list = []\n $LEDGER.each do |name, libs|\n case libs\n when Library\n list << libs if libs.requirements.any?{ |r| match_name == r['name'] } \n else\n libs.each do |lib|\n list << lib if lib.requirements.any?{ |r| match_name == r['name'] } \n end\n end\n end\n list\n end", "def resolve_packages\n installation_manifest =\n Autoproj::InstallationManifest.from_workspace_root(ws.root_dir)\n installation_manifest.each_package.to_a +\n installation_manifest.each_package_set.to_a\n end", "def vendor_dependencies\n fetch_bundler\n bundle_install\n end", "def unused_dependencies_list\n imports = all_unique_imports.map { |import| import.split.last }\n dependency_list - imports\n end", "def walk_down_dependencies(pkg_name, known_deps=Array.new)\n\talldeps = Array.new\n\t@total_deps[pkg_name].each { |m|\n\t\tunless alldeps.include?(m) || m.nil? || known_deps.include?(m) \n\t\t\talldeps = alldeps + walk_down_dependencies(m, alldeps)\n\t\tend\n\t\talldeps.push m\n\t}\n\talldeps.uniq!\n\talldeps.push pkg_name\n\t# puts alldeps.join(\", \") \n\treturn alldeps.compact \nend", "def fetch_dependencies()\n\t\"berks vendor cookbooks #{(@debug ? '-v' : '-q')}\"\n end", "def check_dependencies\n fetch_module_dependencies.map do |dependency, constraint|\n dependency = dependency.sub('-', '/')\n current = dependency == @updated_module ? SemanticPuppet::Version.parse(@updated_module_version) : @forge.get_current_version(dependency)\n [dependency, constraint, current, constraint.include?(current)]\n end\n end", "def gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem? }\n end", "def test_dependencies\n []\n end", "def test_dependencies\n []\n end", "def forced_packages_missing_candidates\n @forced_packages_missing_candidates ||=\n begin\n missing = []\n each_package do |package_name, new_version, current_version, candidate_version, magic_version|\n next if new_version.nil? || current_version.nil?\n\n if use_magic_version?\n if !magic_version && candidate_version.nil?\n missing.push(package_name)\n end\n else\n if !version_requirement_satisfied?(current_version, new_version) && candidate_version.nil?\n missing.push(package_name)\n end\n end\n end\n missing\n end\n end", "def gems\n @gems ||=\n Bundler.load.current_dependencies.map do |dependency|\n GemsBond::Gem.new(dependency)\n end\n end", "def dependencies\n\t\t0\n\tend", "def check_all_packages\n packages_not_installed = []\n Constants::PACKAGES.each do |pkg|\n string = \"Looking for package #{pkg}...\"\n installed = check_package(pkg)\n installed ? string << green(\"Found\") : string << red(\"Not Found\")\n log_print string\n if !installed\n #if not installed append package name to packages_not_installed list\n packages_not_installed << pkg\n end #if\n end #do\n \n packages_not_installed\n end", "def dependencies\n spec.dependencies\n end", "def dependencies\n spec.dependencies\n end", "def declared_dependencies(ast)\n raise_unless_xpath!(ast)\n deps = ast.xpath(%q{//command[ident/@value='depends']/\n descendant::args_add/descendant::tstring_content[1]})\n # handle quoted word arrays\n var_ref = ast.xpath(%q{//command[ident/@value='depends']/\n descendant::var_ref/ident})\n unless var_ref.empty?\n deps += ast.xpath(%Q{//block_var/params/ident#{var_ref.first['value']}/\n ancestor::method_add_block/call/descendant::tstring_content})\n end\n deps.map{|dep| dep['value']}\n end", "def non_gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| !r.gem? }\n end", "def elm_dependencies(package)\n ElmPackage.dependencies elm_package_path(package)\n rescue\n {}\n end", "def vendor(dependencies)\n return nil if dependencies.nil? || dependencies.empty?\n @dep_list = Resolver.resolve(dependencies, @cache, @cwd, @backend)\n end", "def installed_packages()\n\t\t\t\treturn(PackageList.new())\n\t\t\tend" ]
[ "0.77388394", "0.7629285", "0.7601581", "0.7553305", "0.7541763", "0.74454284", "0.7425449", "0.7376971", "0.7376971", "0.7376971", "0.7376971", "0.736357", "0.7360789", "0.7349574", "0.7341946", "0.73008835", "0.73008835", "0.7253065", "0.72396785", "0.7235444", "0.7216514", "0.7182403", "0.71712327", "0.71597624", "0.71597624", "0.7131768", "0.7125533", "0.7080921", "0.707656", "0.70569295", "0.70433635", "0.70433635", "0.70281535", "0.7023905", "0.7018481", "0.70151347", "0.70151347", "0.70151347", "0.6996459", "0.6987112", "0.6964189", "0.69558614", "0.6955247", "0.6936996", "0.6935035", "0.6931938", "0.690593", "0.69011515", "0.6893343", "0.68901396", "0.6889515", "0.68884915", "0.68751276", "0.6861378", "0.6861378", "0.6860683", "0.68548113", "0.68483466", "0.6823696", "0.6808707", "0.68069947", "0.68037665", "0.68007296", "0.6800106", "0.67960495", "0.67960495", "0.67960495", "0.67698985", "0.6748628", "0.6746125", "0.6734114", "0.67274326", "0.6727225", "0.6719893", "0.67054904", "0.6696233", "0.6692215", "0.66911846", "0.6686748", "0.66663283", "0.6659081", "0.6658542", "0.6652717", "0.6651806", "0.6638837", "0.66359174", "0.662571", "0.6625443", "0.6625443", "0.66218346", "0.6597454", "0.65917623", "0.6573923", "0.655304", "0.655304", "0.65405625", "0.6537295", "0.65361917", "0.65357196", "0.652543" ]
0.79597485
0
def compile_cmd 'make j2' end def install_cmd 'make install' end def clean_cmd 'make clean' end
def is_gotten File.exist?(package_path) && is_md5_verified end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install\n\tsystem \"make\"\n end", "def build\n cd_and_sh( pkg_dir, build_commands )\n end", "def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n# system \"make package\"\n# end\nend", "def compile\n download_jonas\n download_deployme\n remove_jcl_over_slf\n puts 'Compile completed, release cmd to be run:'\n puts release\n end", "def common_build\n puts \"common_build dir=#{pwd} #{SHOES_TGT_ARCH}\"\n #mkdir_p \"#{TGT_DIR}/ruby\"\n #cp_r \"#{EXT_RUBY}/lib/ruby/#{RUBY_V}\", \"#{TGT_DIR}/ruby/lib\"\n %w[req/ftsearch/lib/* req/rake/lib/*].each do |rdir|\n FileList[rdir].each { |rlib| cp_r rlib, \"#{TGT_DIR}/lib/ruby/#{TGT_RUBY_V}\" }\n end\n %w[req/ftsearch/ext/ftsearchrt req/chipmunk/ext/chipmunk].\n #%w[req/binject/ext/binject_c req/ftsearch/ext/ftsearchrt req/bloopsaphone/ext/bloops req/chipmunk/ext/chipmunk].\n each { |xdir| copy_ext xdir, \"#{TGT_DIR}/lib/ruby/#{TGT_RUBY_V}/#{SHOES_TGT_ARCH}\" }\n\n gdir = \"#{TGT_DIR}/lib/ruby/gems/#{RUBY_V}\"\n {'hpricot' => 'lib', 'sqlite3' => 'lib'}.each do |gemn, xdir|\n #{'hpricot' => 'lib', 'json' => 'lib/json/ext', 'sqlite3' => 'lib'}.each do |gemn, xdir|\n spec = eval(File.read(\"req/#{gemn}/gemspec\"))\n mkdir_p \"#{gdir}/specifications\"\n mkdir_p \"#{gdir}/gems/#{spec.full_name}/lib\"\n FileList[\"req/#{gemn}/lib/*\"].each { |rlib| cp_r rlib, \"#{gdir}/gems/#{spec.full_name}/lib\" }\n mkdir_p \"#{gdir}/gems/#{spec.full_name}/#{xdir}\"\n FileList[\"req/#{gemn}/ext/*\"].each { |elib| copy_ext elib, \"#{gdir}/gems/#{spec.full_name}/#{xdir}\" }\n cp \"req/#{gemn}/gemspec\", \"#{gdir}/specifications/#{spec.full_name}.gemspec\"\n end\n end", "def install\n system \"./configure\", \"--disable-debug\",\n \"--prefix=#{prefix}\",\n \"--enable-guile2=yes\"\n system \"make\"\n system \"make\", \"install\"\n end", "def install\n mkdir \"build\" do\n system \"meson\", \"..\"\n system \"meson\", \"configure\", \"--prefix\", prefix\n system \"ninja\", \"--verbose\"\n system \"ninja\", \"install\", \"--verbose\"\n end\n end", "def install\n system \"./configure\", \"--prefix=#{prefix}\", \"--disable-debug\", \"--disable-dependency-tracking\"\n# system \"cmake . #{cmake_std_parameters}\"\n system \"make install\"\n end", "def install\n ohai \"THIS BUILD DIDN'T WORK!\"\n \n resource(\"7zip\").stage \"#{buildpath}/7zip\"\n\n system \"chmod +x compile*\"\n\n system \"cd HsLua && make\"\n\n # GHC 7.4.2 compatibility fixes\n #system \"sed -i.bak -e 's/^import System.Posix.Internals/import System.Posix.Internals hiding (CFilePath)/' 'Files.hs'\"\n #system \"sed -i.bak -e 's/^import Foreign/import Foreign hiding (unsafePerformIO)/' 'Files.hs'\"\n #system \"sed -i.bak -e '3,4d' 'Compression/CompressionLib.hs'\"\n #system \"sed -i.bak -e 's/foreign import ccall threadsafe/foreign import ccall safe/' 'Compression/CompressionLib.hs'\"\n\n system \"./compile-O2\"\n\n system \"cd Unarc && make unix\"\n end", "def compile_c\n puts \"Compilando archivos fuentes:\"\n objs = @objs + [@main]\n objs.each do |obj|\n command = \"#{@cc} #{@debug} -c -o #{obj} #{obj[0..-2] + \"c\"} #{@cflags}\"\n puts \"\\t\"+ command\n exit (0) if not((system(command)))\n end\n command = \"#{@cc} #{@debug} -o #{@main[0..-3]} #{objs.join(\" \")}\" +\n \" #{@cflags}\"\n puts \"\\t\"+ command\n puts \"No compilo de forma correcta\" if not(system(command))\nend", "def install\n # use the brew python to install the tools needed\n\t system 'python', 'setup.py', 'install', \"--prefix=#{prefix}\", \"--single-version-externally-managed\", \"--record=installed.txt\"\n\n\n # install the gyp executable\n bin.install(\"gyp\")\n bin.install(\"gyp_main.py\")\n end", "def install\n system \"cd c; make build\"\n\n bin.install \"c/helloworld\" => \"helloworld-c\"\n end", "def install\n # ENV.deparallelize # if your formula fails when building in parallel\n\n # Remove unrecognized options if warned by configure\n #system \"./configure\", \"--disable-debug\",\n #\"--disable-dependency-tracking\",\n #\"--disable-silent-rules\",\n #\"--prefix=#{prefix}\"\n # system \"cmake\", \".\", *std_cmake_args\n #system \"make\", \"install\" # if this fails, try separate make/make install steps\n bin.install \"c9ide\"\n end", "def exec\r\n if valid?\r\n _result = configure\r\n _result &&= compile\r\n _result &&= install\r\n end\r\n end", "def compile_eth(dir, to)\n Dir.chdir(dir) do\n sh 'make'\n sh \"cp build/bin/geth #{to}/geth\"\n end\nend", "def install\n system \"./configure\", \"--prefix=#{prefix}\",\n \"--target=i386-jos-elf\",\n \"--disable-multilib\",\n \"--disable-nls\",\n \"--disable-werror\"\n system \"make\"\n system \"make\", \"install\"\n end", "def build_gem; end", "def install\n system \"./configure\", \"--disable-debug\",\n \"--disable-dependency-tracking\",\n \"--disable-silent-rules\",\n \"--prefix=#{prefix}\"\n system \"make\", \"install\" \n end", "def compile\n cmd = self.command\n#puts ' + ' + cmd\n log.debug \"Invoking the compiler\"\n rc = Platform.execute cmd\n log.debug \"Compilation complete; rc=#{rc.to_s}\"\n rc\n end", "def install\n system \"make\"\n bin.install \"wrk\"\n end", "def install\n system \"./configure\", \"--disable-dependency-tracking\", \"--enable-shared\",\n \"--prefix=#{prefix}\"\n system \"rm\", \"src/bits.o\", \"src/c_dd.o\", \"src/c_qd.o\", \"src/dd_const.o\", \"src/dd_real.o\", \"src/fpu.o\", \"src/qd_const.o\", \"src/qd_real.o\", \"src/util.o\"\n system \"rm\", \"src/bits.lo\", \"src/c_dd.lo\", \"src/c_qd.lo\", \"src/dd_const.lo\", \"src/dd_real.lo\", \"src/fpu.lo\", \"src/qd_const.lo\", \"src/qd_real.lo\", \"src/util.lo\"\n system \"make\"\n system \"make\", \"install\"\n end", "def install\n # Get rid of the JRE directory so it'll use the system JRE\n system \"rm\", \"-rf\", \"jre\"\n\n # There's probably a more correct way to do this\n system \"cp\", \"-a\", \".\", \"#{libexec}\"\n\n # Link in the actual commands\n bin.install_symlink \"../libexec/SMCIPMITool\"\n end", "def install\n system \"python\", \"setup.py\", \"install\", \"--prefix=#{prefix}\"\n system \"make\", \"man\"\n man1.install gzip(\"cvs2svn.1\", \"cvs2git.1\", \"cvs2bzr.1\")\n prefix.install %w[ BUGS COMMITTERS HACKING\n cvs2bzr-example.options\n cvs2git-example.options\n cvs2hg-example.options\n cvs2svn-example.options contrib ]\n doc.install Dir[\"{doc,www}/*\"]\n end", "def compile\n puts \"Compilando archivos fuentes:\"\n @objs.each do |obj|\n command = \"#{@cc} -fpic -c -o #{obj} #{obj[0..-2] + \"c\"} #{@cflags}\"\n puts \"\\t\"+ command\n exit (0) if not((system(command)))\n end\n \n puts \"Convirtiendo a bibliotecas dinamicas\"\n system(\"mkdir lib\")\n @shared.each do |obj|\n library = obj.split('/').last\n compiled_libraries = `ls #{@lib_dir}`.split(\" \")\n \n libs = compiled_libraries.inject(\"\") {\n |string,lib|\n string += \"-l#{lib[3...-3]} \"\n }\n \n if (@so == \"linux\")\n command = \"#{@cc} -shared -o lib/lib#{library} #{obj[0..-3] + \"o\"}\" +\n \" -L#{@lib_dir} #{libs}\"\n elsif (@so == \"mac\")\n command = \"#{@cc} -shared -o lib/lib#{library} #{obj[0..-3] + \"o\"}\" +\n \" -L#{@lib_dir} #{libs}\" \n end\n puts \"\\t\" + command\n puts \"No compilo de forma correcta\" if not((system(command)))\n end\nend", "def install\n # ENV.deparallelize # if your formula fails when building in parallel\n prefix.mkpath\n prefix.install Dir[\"*\"]\n\n meson_args = std_meson_args\n meson_args += [\n \"--prefix=#{prefix}\",\n \"-Denable-autodiff=false\", #those two are disabled otherwise there is compiler error\n \"-Denable-directdiff=false\", #NOTE: need to figure out why and then enable\n \"-Denable-pywrapper=true\",\n \"-Dwith-mpi=auto\", #auto, enabled, disabled\n \"-Dwith-omp=false\", #experimental feature\n \"-Denable-cgns=true\", \n \"-Denable-tecio=true\", \n \"-Denable-mkl=false\",\n \"-Denable-openblas=false\", \n \"-Denable-pastix=false\"\n ]\n \n Dir.chdir(\"#{prefix}\") do\n # Note running meson.py could download additional packages, which should\n # be managed by homebrew. The current approach is bloated. \n system \"./meson.py\", \"build\", *meson_args\n Dir.chdir(\"build\") do\n system \"ninja\", \"-v\"\n system \"ninja\", \"install\", \"-v\"\n end\n end\n end", "def build\n\n\t\t\tFlexMate::SDK.add_flex_bin_to_path\n\t\t\tTextMate.require_cmd('mxmlc')\n\n\t\t\tcmd = MxmlcCommand.new\n\t\t\tcmd.file_specs = get_file_specs\n\t\t\tcmd.o = get_flex_output(cmd.file_specs)\n\n\t\t\tputs html_head( :window_title => \"ActionScript 3 Build Command\",\n\t\t\t\t\t\t\t\t\t\t\t:page_title => \"Build (mxmlc)\",\n\t\t\t\t\t\t\t\t\t\t\t:sub_title => cmd.file_specs_name )\n\n\t\t\tputs \"<h2>Building...</h2>\"\n\t\t\tputs \"<p><pre>-file-specs=#{cmd.file_specs}\"\n\t\t\tputs \"-o=#{cmd.o}</pre></p>\"\n\n\t\t\texhaust = get_exhaust\n\t\t\t\n\t\t\tTextMate::Process.run(cmd.line) do |str|\n\t\t\t\tSTDOUT << exhaust.line(str)\n\t\t\tend\n\n\t\t\texhaust.complete\n\n\t\t\thtml_footer\n\n\t\tend", "def install\n system \"make\"\n system \"make install PREFIX=#{prefix}\"\n end", "def install\n \t# ENV.deparallelize # if your formula fails when building in parallel\n \t# Remove unrecognized options if warned by configure\n #system \"./configure\", \"--disable-debug\",\n # \"--disable-dependency-tracking\",\n # \"--disable-silent-rules\",\n # \"--prefix=#{prefix}\"\n # system \"cmake\", \".\", *std_cmake_args\n # system \"make\", \"install\" # if this fails, try separate make/make install steps\n\t# system \"install\"\n\t#bin.install \"buteemj-macos\"\n\t#bin.install Dir[\"*\"]\n\t#prefix.install \"buteemj-macos\"\n\n\t # If your formula's build system is not thread safe:\n ENV.deparallelize\n\n\t bin.install \"binding.node\"\n\t bin.install \"config.json\"\n\t bin.install \"ffi_bindings.node\"\n\n\t bin.install \"iconv.node\"\n\t bin.install \"node_sqlite3.node\"\n\t bin.install \"screenshot.node\"\n\t bin.install \"snapshot.dat\"\n\t bin.install \"install.sh\"\n\t bin.install \"main\"\n\t bin.install \"buteemj-macos\"\n\n\t system \"chmod u+w #{bin}/snapshot.dat\"\n\t # system \"#{bin}/install.sh\" #, \"--arg1\", \"--prefix=#{prefix}\"\n\t # chmod ugo+w snapshot.dat\n\n\t# system \"install\"\n end", "def install\n for t in CROSS_TARGETS\n mkdir \"#{t}\" do\n system \"../configure\",\n \"--srcdir=../\",\n \"--target=#{t}\",\n \"--prefix=#{prefix}\",\n \"--disable-sim\"\n system \"make\", \"all\", \"ERROR_ON_WARNING=no\"\n system \"make\", \"install\"\n end\n end\n\n # Remove items conflicting with binutils\n rm_rf share/\"info\"\n\n end", "def install\n system \"./configure\", \"--prefix=#{prefix}\"\n system \"make\"\n system \"make\", \"install\"\n end", "def compile_ruby\n if $DEBUG\n puts \"user_home: #{user_home}\"\n puts \"user_local: #{user_local}\"\n puts \"make_command: #{make_command}\"\n puts \"version: #{version}\"\n puts \"ruby_cc_version: #{ruby_cc_version}\"\n puts \"ruby_source: #{ruby_source}\"\n puts \"srcdir: #{srcdir}\"\n puts \"blddir: #{blddir}\"\n puts \"libdir: #{libdir}\"\n end\n\n mingw32\n environment\n download_source\n extract_source\n makefile_in_bak # create Makefile.in.bak\n makefile_in # create Makefile.in\n configure # create Makefile\n make # creates ruby.exe\n make_install\n update_config\n end", "def install\n system \"./configure\", \"--prefix=#{prefix}\", \"--disable-debug\", \"--disable-dependency-tracking\"\n# system \"cmake\", \".\", *std_cmake_args\n system \"make install\"\n end", "def compile\n read_yml if File.exists?(@project)\n\n default_options = {}\n other_options = {}\n\n @compile_options.each do |k,v| \n if /default/.match(k)\n default_options[k] = v\n else\n other_options[k] = v\n end\n end\n\n command = \"#{@flex_sdk_bin}#{@compiler}\"\n other_options.each { |k,v| command += \" -#{k}=\\\"#{[v].flatten.join ','}\\\"\" }\n default_options.each { |k,v| command += \" -#{k}=\\\"#{[v].flatten.join ','}\\\"\" }\n command += \" #{@document_class}.as\"\n\n# puts command\n# TextMate.exit_show_html\n\n @command = command\n#TextMate.exit_show_html\n if process_output command\n# load_debugger\n display_web_player #unless ARGV[0] = \"--display\"\n# display_player\n end\nend", "def compiledo\n\n end", "def build\n system(\"make build\", :chdir => self.config['destination'], :out => :err)\n end", "def install\n system \"./configure\", *std_configure_args\n system \"make\", \"install\"\n end", "def setup_java_extension(extension_name, gem_spec = nil, opts = {})\n ext_name = \"#{extension_name}.jar\"\n directory 'lib'\n opts = {\n :source_dir => 'ext-java/src/main/java',\n :add_buildr_task => true\n }.merge!(opts)\n\n desc 'Compile Extension for current Ruby (= compile:jruby)'\n task :compile => [ 'compile:jruby' ] if JRUBY\n\n namespace :compile do\n\n desc \"Compile Java Extension for JRuby\"\n task :jruby => [ :clean ] do\n pkg_classes = File.join(*%w(pkg classes))\n mkdir_p pkg_classes\n\n if extension_name == 'do_jdbc_internal'\n classpath_arg = java_classpath_arg\n else\n unless File.exists?('../do_jdbc/lib/do_jdbc_internal.jar')\n # Check for the presence of do_jdbc_internal.jar in the do_jdbc project\n # which we need to compile against.\n print \"\\n\"; 80.times { print '-' }; print \"\\n\"\n puts \"To compile the Java extension, #{extension_name}, you will first need to compile\"\n puts \"common JDBC support for DataObjects, do_jdbc:\"\n puts \"cd ../do_jdbc; jruby -S rake compile\"\n 80.times { print '-' }; print \"\\n\\n\"\n\n raise \"Required file for compilation (do_jdbc_internal.jar) not found.\"\n end\n\n classpath_arg = java_classpath_arg '../do_jdbc/lib/do_jdbc_internal.jar'\n end\n\n # just use the extension directory from the executing java\n # for compilation as well\n extdir = java.lang.System.getProperty('java.ext.dirs')\n extdir_arg = extdir.nil? ? \"\" : \"-extdirs #{extdir}\"\n\n # Check if DO_JAVA_DEBUG env var was set to TRUE\n # TRUE means compile java classes with debug info\n if ENV['DO_JAVA_DEBUG'] && ENV['DO_JAVA_DEBUG'].upcase.eql?(\"TRUE\")\n sh \"javac #{extdir_arg} -target 1.5 -source 1.5 -Xlint:unchecked -g -d pkg/classes #{classpath_arg} #{FileList[\"#{opts[:source_dir]}/**/*.java\"].join(' ')}\"\n else\n sh \"javac #{extdir_arg} -target 1.5 -source 1.5 -Xlint:unchecked -d pkg/classes #{classpath_arg} #{FileList[\"#{opts[:source_dir]}/**/*.java\"].join(' ')}\"\n end\n\n sh \"jar cf lib/#{ext_name} -C #{pkg_classes} .\"\n end\n\n if opts[:add_buildr_task]\n desc \"Compile Java Extension for JRuby (with buildr)\"\n task :jruby_buildr do\n begin\n # gem 'buildr', '~>1.3'\n # FIXME: this is throwing RSpec activation errors, as buildr relies on\n # an older version of Rake.\n\n sh %{#{RUBY} -S buildr package}\n\n buildr_output = extension_name.gsub(/_(ext)$/, '-\\1-java-1.0.jar')\n cp \"ext-java/target/#{buildr_output}\", \"lib/#{ext_name}\"\n rescue LoadError\n puts \"#{spec.name} requires the buildr gem to compile the Java extension\"\n end\n end\n end\n\n end\n file \"lib/#{ext_name}\" => 'compile:jruby'\n\nend", "def install\n Dir.mkdir(\"./build\")\n Dir.chdir(\"./build\")\n system \"cmake\", \"-DCMAKE_INSTALL_PREFIX:PATH=#{prefix}\", \"..\"\n system \"make\"\n system \"make\", \"install\"\n end", "def install_tools\n # For eventmachine.\n package 'libssl-dev'\n\n # For rmagick (image processing).\n package 'libmagickwand-dev', /^libmagick\\d*-dev$/\n\n # For HTML/XML parsers (nokogiri, hpricot).\n package 'libxml2-dev'\n package 'libxslt1-dev'\n\n # For HTTP fetchers (curb).\n package 'libcurl-dev', 'libcurl-openssl-dev', /^libcurl\\d*-dev$/,\n /^libcurl\\d*-openssl-dev$/\n\n # needed for solr and other java-based services\n package /^openjdk-\\d+-jdk/\n\n # useful to be able to work with compressed data\n package 'zlib-dev', /^zlib[0-9a-z]*-dev$/\n package 'bzip2'\n package 'gzip'\n package 'tar'\n package 'zip'\n end", "def install\n ENV.j1\n ENV['MPICC'] = \"#{HOMEBREW_PREFIX}/bin/mpicc\"\n ENV['MPICXX'] = \"#{HOMEBREW_PREFIX}/bin/mpicxx\"\n ENV['MPIF90'] = \"#{HOMEBREW_PREFIX}/bin/mpif77\"\n ENV['MPIF77'] = \"#{HOMEBREW_PREFIX}/bin/mpif90\"\n system \"./configure\", \"--disable-debug\", \"--disable-dependency-tracking\",\n \"--prefix=#{prefix}\"\n system \"make\"\n system \"make install\"\n end", "def install\n system \"make\"\n system \"make\", \"PREFIX=#{prefix}\", \"install\"\n end", "def install\n system \"./configure\", \"--prefix=#{prefix}\"\n system \"make install\"\n end", "def compile\n LIBRARIES.each do |library|\n system \"gcc -march=x86_64 -Wall -bundle -bundle_loader /usr/local/mysql/bin/mysqld -o #{library}.so `/usr/local/mysql/bin/mysql_config –cflags` #{library}.c\"\n end\nend", "def install\n # When building the head, temp patch for ROOT-8032\n if build.head? || build.devel?\n inreplace \"cmake/modules/RootBuildOptions.cmake\", \"thread|cxx11|cling|builtin_llvm|builtin_ftgl|explicitlink\", \"thread|cxx11|cling|builtin_llvm|builtin_ftgl|explicitlink|python|mathmore|asimage|gnuinstall|rpath|soversion|opengl|builtin_glew\"\n end\n\n mkdir \"hb-build-root\" do\n ENV.cxx11\n\n # Defaults\n args = std_cmake_args\n args << \"-Dgnuinstall=ON\"\n args << \"-DCMAKE_INSTALL_SYSCONFDIR=etc/root\"\n args << \"-Dgminimal=ON\"\n args << \"-Dx11=OFF\" if OS.mac?\n args << \"-Dcocoa=ON\" if OS.mac?\n args << \"-Dlibcxx=ON\" if OS.mac?\n args << \"-Dfortran=OFF\"\n args << \"-Drpath=ON\"\n args << \"-Dsoversion=ON\"\n args << \"-Dasimage=ON\"\n args << \"-Dbuiltin_asimage=ON\"\n args << \"-Dbuiltin_freetype=ON\"\n args << \"-Dopengl=ON\"\n args << \"-Dbuiltin_glew=ON\"\n\n # Options\n args << \"-Dcxx11=ON\"\n args << \"-Dpython=\".concat((build.with? \"python\") ? \"ON\" : \"OFF\")\n args << \"-Dmathmore=\".concat((build.with? \"gsl\") ? \"ON\" : \"OFF\")\n\n system \"cmake\", \"../\", *args\n system \"make\"\n system \"make\", \"install\"\n end\n end", "def install\n for t in CROSS_TARGETS\n mkdir \"#{t}\" do\n system \"../configure\",\n \"--srcdir=../\",\n \"--target=#{t}\",\n \"--prefix=#{prefix}\",\n \"--disable-nls\"\n system \"make\", \"all\", \"ERROR_ON_WARNING=no\"\n system \"make\", \"install\"\n end\n end\n end", "def build\n safesystem \"autoreconf -vfi\"\n configure :prefix => prefix\n make\n end", "def install\n mktemp do\n File.open(\"make.sh\", \"w\") { |f| f.write \"\\#!/bin/sh\\nmake \\\"$@\\\"\\nexit 0\\n\" }\n arm = Utils.safe_popen_read(\"/usr/local/bin/brew\", \"--prefix\",\n \"cesarvandevelde/formulae/arm-none-eabi-gcc\").chomp\n # path = Utils.popen_read(\"/usr/bin/find\",\"#{arm}/\",\"-name\",\"stddef.h\",\"-print`\")\n # inc = path[0..-10]\n ENV[\"TARGET\"] = \"arm-none-eabi\"\n ENV[\"PREFIX\"] = \"#{arm}/gcc\"\n ENV[\"PATH\"] = \"#{ENV[\"PATH\"]}:#{arm}/gcc/bin\"\n system \"#{buildpath}/configure\",\n \"--target=arm-none-eabi\",\n \"--prefix=#{prefix}\",\n \"--with-as=#{arm}/bin/arm-none-eabi-as\", \"--with-ld=#{arm}/bin/arm-none-eabi-ld\",\n \"--disable-nls\",\n \"--disable-bootstrap\",\n \"--enable-checking=tree,rtl,assert,types\",\n \"--no-create\", \"--no-recursion\",\n \"--with-arch=armv7-a\", \"--with-fpu=vfp\", \"--with-float=hard\",\n \"CFLAGS=-g3 -O0\",\n \"--enable-languages=c,lto\",\n \"--disable-multilib\",\n \"--disable-werror\",\n \"--disable-libssp\", \"--disable-libstdcxx-pch\", \"--disable-libmudflap\",\n \"--with-newlib\",\n \"--enable-interwork\",\n \"--with-headers=yes\"\n # \"--with-headers=#{arm}/gcc/arm-none-eabi/include,#{inc}\"\n system \"sh\", \"config.status\"\n system \"sh\", \"make.sh\", \"-k\", \"-j\", \"20\" # for firefly\n system \"sh\", \"make.sh\", \"-k\", \"install\"\n # raise\n end\n end", "def compile!\n puts \"Compiling website..\"\n puts %x[rm -rf output]\n puts %x[nanoc compile]\nend", "def compile!\n puts \"Compiling website..\"\n puts %x[rm -rf output]\n puts %x[nanoc compile]\nend", "def compile!\n puts \"Compiling website..\"\n puts %x[rm -rf output]\n puts %x[nanoc compile]\nend", "def install\n system \"make\"\n system \"make\", \"install\", \"PREFIX=#{prefix}\"\n end", "def install\n system \"make\"\n system \"make\", \"install\", \"PREFIX=#{prefix}\"\n end", "def autorun_cmd(repo_name)\n [\"cp -Rf #{STARTDIR}/components/autogen/#{repo_name}/* .\",\n \"touch Makefile\"]\nend", "def emulate_extension_install\n extension_name = \"utilikilt\"\n File.open('Makefile', 'w') { |f| f.write \"all:\\n\\ninstall:\\n\\n\" }\n File.open('make', 'w') do |f|\n f.write '#!/bin/sh'\n f.chmod f.stat.mode | 0111\n end\n File.open(extension_name + '.so', 'w') {}\n File.open(extension_name + '.dll', 'w') {}\n File.open('nmake.bat', 'w') { |f| }\nend", "def install\n system \"./build.sh\"\n bin.install \"./bin/pngwolf\"\n end", "def install\n\t# ENV[\"GOPATH\"] = buildpath\n\n # commented out when building application locally when installing it\n # system \"go\", \"get\", \"github.com/aws/aws-sdk-go\"\n # system \"go\", \"get\", \"-u\", \"github.com/spf13/cobra/cobra\"\n # system \"go\", \"get\", \"github.com/cpuguy83/go-md2man\"\n # system \"go\", \"get\", \"-u\", \"github.com/disintegration/imaging\"\n # system \"go\", \"get\", \"-u\", \"github.com/satori/go.uuid\"\n #\n #\n # # Need to move directory structure to src, to be able to build\n # system \"script/move-for-homebrew.sh\"\n #\n # # Generate the bash completion script\n # system \"go\", \"run\", \"src/oc-cli/oc-cli-bash-completion.go\"\n #\n \t # system \"go\", \"build\", \"-o\", \"oc-cli\", \"-ldflags\", \"-X main.Version=0.3\", \"src/oc-cli/oc-cli.go\"\n\n\t bin.install \"oc-cli\"\n\t bash_completion.install \"bash-completion/oc-cli\"\n end", "def install\n # ENV.j1 # if your formula's build system can't parallelize\n\n system \"./configure\", \"--disable-debug\", \"--disable-dependency-tracking\",\n \"--prefix=#{prefix}\"\n # system \"cmake\", \".\", *std_cmake_args\n system \"make install\" # if this fails, try separate make/make install steps\n end", "def compile\n if @app_dir.nil?\n raise 'app directory must be provided'\n elsif @version.nil? || @uri.nil? || @nosetup_zip.nil?\n raise \"Version #{@version}, uri #{@uri}, or new jrebel-nosetup.zip #{@nosetup_zip} is not available, detect needs to be invoked\"\n end\n\n jr_home = File.join(@app_dir, JR_HOME_DIR)\n FileUtils.mkdir_p(jr_home)\n FileUtils.rm_r(File.join(jr_home, JREBEL)) if Dir.exist?(File.join(jr_home, JREBEL))\n download_and_install_agent(jr_home)\n end", "def install\n # ENV.deparallelize # if your formula fails when building in parallel\n\n # Remove unrecognized options if warned by configure\n system \"git init && git submodule init && git submodule update\"\n bin.install \"install-dot-files\"\n end", "def compile_web\n\n # Check for compiler toolchain issues\n if doctor_web(:building)\n puts \"Fix errors before building.\\n\\n\"\n end\n\n wasm_assets = \"#{Ruby2D.assets}/wasm\"\n\n # Get include directories\n incl_dir_ruby2d = \"#{Ruby2D.gem_dir}/ext/ruby2d/\"\n incl_dir_deps = \"#{Ruby2D.assets}/include/\"\n\n optimize_flags = '-Os --closure 1'\n ld_flags = \"#{wasm_assets}/libmruby.a\"\n\n # Compile using Emscripten\n run_cmd \"emcc -s WASM=1 -I#{incl_dir_ruby2d} -I#{incl_dir_deps} \"\\\n \"-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 \"\\\n \"build/app.c #{ld_flags} -o build/app.html\"\n\n # TODO: Copy HTML template from gem assets to build directory\n # FileUtils.cp \"#{wasm_assets}/template.html\", 'build/app.html'\n\n exit(1) unless $?.success?\nend", "def install\n system \"autoreconf\", \"-fiv\" if build.head?\n system \"./configure\", \"--disable-debug\",\n \"--disable-dependency-tracking\",\n \"--disable-silent-rules\",\n \"--prefix=#{prefix}\"\n system \"make\", \"install\"\n end", "def install\n #python executable files\n end", "def install\n\n # Useful paths you can use in here:\n # - `prefix` -- where you should install stuff\n # - `bin` -- usually equals prefix/\"bin\"\n # - `lib` -- usually equals prefix/\"lib\"\n # - `libexec` -- usually equals prefix/\"libexec\"\n \n # Common shellisms have dedicated functions:\n cd \"tlatools/org.lamport.tlatools\"\n rm_r \"dir\"\n mkdir_p bin\n cp \"exe\", bin\n cp_r \"path\", lib\n chmod 0755, bin/\"exe\"\n\n # Shorthand for \"cp to bin; chmod 0555\"\n bin.install \"exe\"\n\n # You can also change the name of a file as you install it to bin:\n bin.install \"filename\" => \"exename\"\n\n # Invoking a standard autotools configure script:\n system \"./configure\", *std_configure_args\n\n # Referencing the install paths of other formulae --- this is great if you\n # want to isolate installed products from the user's environment or if you\n # need to point a configure script at some specific path.\n inreplace \"etc/settings\", \"/path/to/java/bin\", Formula[\"java\"].bin\n\n # In general, you can use:\n # - Formula[\"name\"].prefix\n # - Formula[\"name\"].bin\n # - Formula[\"name\"].lib\n\n # Create a file at build time\n (bin/exe).write(\"#!/bin/bash\\nexec java -XX:+UseParallelGC -DTLA-Library=\\\"$TLA_PATH\\\" -cp '#{lib}/tla2tools.jar' Classname \\\"$@\\\"\\n\")\n chmod 0555, bin/exe\n\n # Modifying the environment --- this affects all subsequent commands.\n ENV[\"VARIABLE_NAME\"] = \"VALUE\"\n\n # Colon-separated lists of paths are very common in environment variables\n # (e.g. PATH, CLASSPATH, etc). Homebrew offers a utility for extending\n # those lists:\n ENV.prepend_path \"OCAMLPATH\", Formula[\"coq\"].lib\n\n # Managing parallelism --- Homebrew turns on `make` parallelism by default\n # using environment variables, but some packages cannot be consistently\n # compiled in parallel.\n jobs = ENV.make_jobs # capture how much parallelism Homebrew recommends\n ENV.deparallelize # turn off parallel `make`\n\n\n # ------------------------------- Python-specific advice\n\n # Use `brew create --python [pypi url]`. This will include useful install\n # lines like:\n python = Formula[\"python@3\"]\n system python.opt_libexec/\"bin\"/\"python\", *Language::Python.setup_install_args(prefix, python)\n\n\n # ------------------------------- Java-specific advice\n\n # You'll probably want\n # depends_on \"java\"\n # depends_on \"maven\" # or \"ant\" or \"gradle\"\n # depends_on \"openjdk\" => :build\n ENV[\"JAVA_HOME\"] = Formula[\"openjdk\"].libexec/\"openjdk.jdk\"/\"Contents\"/\"Home\"\n\n end", "def install\n system \"#{ENV.cc} #{ENV.cflags} src/C/bbox.c -o bbox\"\n bin.install 'bin/ps2eps'\n bin.install 'bbox'\n share.install Dir['doc/man']\n doc.install Dir['doc/pdf']\n doc.install Dir['doc/html']\n end", "def install\n # ENV.j1 # if your formula's build system can't parallelize\n\n #system \"./configure\", \"--disable-debug\", \"--disable-dependency-tracking\",\n # \"--prefix=#{prefix}\"\n # system \"cmake\", \".\", *std_cmake_args\n #system \"make\", \"install\" # if this fails, try separate make/make install steps\n bin.install('ds9')\n end", "def pre_build\n puts \"pre_build dir=#{`pwd`}\"\n rbvt = RUBY_V\n rbvm = RUBY_V[/^\\d+\\.\\d+/]\n # remove leftovers from previous rake.\n rm_rf \"#{TGT_DIR}/lib\"\n rm_rf \"#{TGT_DIR}/etc\"\n rm_rf \"#{TGT_DIR}/share\"\n rm_rf \"#{TGT_DIR}/conf.d\"\n mkdir_p \"#{TGT_DIR}/lib\"\n cp_r \"#{EXT_RUBY}/lib/ruby\", \"#{TGT_DIR}/lib\"\n # copy include files\n mkdir_p \"#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}\"\n cp_r \"#{EXT_RUBY}/include/ruby-#{rbvt}/\", \"#{TGT_DIR}/lib/ruby/include\"\n SOLOCS.each_value do |path|\n cp \"#{path}\", \"#{TGT_DIR}\"\n end\n # do some windows things\n mkdir_p \"#{TGT_DIR}/share/glib-2.0/schemas\"\n if APP['GTK'] == \"gtk+-2.0\" \n cp_r\"#{TGT_SYS_DIR}/share/glib-2.0/schemas/gschema.dtd\",\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n elsif APP['GTK'] == \"gtk+-3.0\"\n cp \"#{TGT_SYS_DIR}share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n cp_r \"#{ShoesDeps}/share/fontconfig\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/themes\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/xml\", \"#{TGT_DIR}/share\"\n cp_r \"#{ShoesDeps}/share/icons\", \"#{TGT_DIR}/share\"\n else\n cp \"#{TGT_SYS_DIR}share/glib-2.0/schemas/gschemas.compiled\" ,\n \"#{TGT_DIR}/share/glib-2.0/schemas\"\n end\n sh \"#{WINDRES} -I. shoes/appwin32.rc shoes/appwin32.o\"\n cp_r \"#{ShoesDeps}/etc\", TGT_DIR\n mkdir_p \"#{ShoesDeps}/lib\"\n if APP['GTK'] == \"gtk+-3.0\"\n cp_r \"#{ShoesDeps}/lib/gtk-3.0\", \"#{TGT_DIR}/lib\" # shoes, exerb, ruby here\n else\n cp_r \"#{ShoesDeps}/lib/gtk-2.0\", \"#{TGT_DIR}/lib\" # shoes, exerb, ruby here\n end\n bindir = \"#{ShoesDeps}/bin\"\n #cp_r \"#{bindir}/fc-cache.exe\", TGT_DIR\n cp_r \"#{bindir}/gtk-update-icon-cache.exe\", TGT_DIR\n # below for debugging purposes\n if ENV['GDB'] \n cp \"#{bindir}/fc-cat.exe\", TGT_DIR\n cp \"#{bindir}/fc-list.exe\", TGT_DIR\n cp \"#{bindir}/fc-match.exe\", TGT_DIR\n cp \"#{bindir}/fc-pattern.exe\", TGT_DIR\n cp \"#{bindir}/fc-query.exe\", TGT_DIR\n cp \"#{bindir}/fc-scan.exe\", TGT_DIR\n cp \"#{bindir}/fc-validate.exe\", TGT_DIR\n end\n # disable MS Theme\n if !ENABLE_MS_THEME \n Dir.chdir(\"#{TGT_DIR}/share/themes/MS-Windows/gtk-2.0/\") do\n mv 'gtkrc', 'disabled-gtkrc'\n end\n else\n # add our overrides to the MS-Windows theme\n cp \"platform/msw/gtkrc\", \"#{TGT_DIR}/etc/gtk-2.0/\"\n end\n end", "def install\n cd \"src\" do\n system \"make\"\n bin.install \"mbsum\", \"bucky\"\n end\n pkgshare.install [\"data\", \"scripts\", \"doc\"]\n end", "def pre_build\n puts \"pre_build dir=#{`pwd`}\"\n rbvt = RUBY_V\n rbvm = RUBY_V[/^\\d+\\.\\d+/]\n mkdir_p \"#{TGT_DIR}/lib\"\n # clean out leftovers from last build\n rm_f \"#{TGT_DIR}/libruby.so\" if File.exist? \"#{TGT_DIR}/libruby.so\"\n rm_f \"#{TGT_DIR}/libruby.so.#{rbvm}\" if File.exist? \"#{TGT_DIR}/libruby.so.#{rbvm}\"\n rm_f \"#{TGT_DIR}/libruby.so.#{rbvt}\" if File.exist? \"#{TGT_DIR}/libruby.so.#{rbvt}\"\n cp_r \"#{EXT_RUBY}/lib/ruby\", \"#{TGT_DIR}/lib\"\n # copy and link libruby.so - pick the right one to \n # cp \"#{EXT_RUBY}/lib/libruby.so.#{RUBY_V}\", \"#{TGT_DIR}\"\n cp \"#{EXT_RUBY}/lib/libruby.so.#{rbvm}\", \"#{TGT_DIR}\"\n # copy include files - it might help build gems\n mkdir_p \"#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}\"\n cp_r \"#{EXT_RUBY}/include/ruby-#{rbvt}/\", \"#{TGT_DIR}/lib/ruby/include\"\n # can't figure out ln -s? push pwd, cd, ln, pop\n #cdir = pwd\n #cd TGT_DIR\n chdir TGT_DIR do\n ln_s \"libruby.so.#{rbvm}\", \"libruby.so\"\n #ln_s \"libruby.so.#{RUBY_V}\", \"libruby.so.#{::RUBY_V[/^\\d+\\.\\d+/]}\"\n end\n SOLOCS.each_value do |path|\n cp \"#{path}\", \"#{TGT_DIR}\"\n end\n end", "def make_deps t\n sh \"gcc -MM -MF #{t.name} #{$C_FLAGS.join ' '} -c #{t.source}\"\nend", "def build_gems; end", "def pacman()\n $installCmd = \"pacman -S\"\n $reinstallCmd = \"pacman -S --force\"\n $searchCmd = \"pacman -Ss\"\n $updateCmd = \"pacman -Su\"\n $syncCmd = \"pacman -Sy\"\n $syncANDupdateCmd = \"pacman -Syu\"\n $refreshSyncCmd = \"pacman -Syy\"\n $removeCmd = \"pacman -R\"\n $recursiveRemoveCmd = \"pacman -Rdd\"\n $checkUpdatesCmd = \"checkupdates\"\n $cleanCmd = \"pacman -Rsn $(pacman -Qdtq)\"\nend", "def install\n # Fix build per Makefile instructions\n inreplace \"Makefile\", \"-static\", \"\"\n\n system \"make\"\n bin.install \"muscle\"\n end", "def compilation_without_makefile\n # Build the program\n build_msg = `#{@build_command} *.c -o #{@pgm}`\n @log_file.puts \"\\nConstruction du programme :\\n\\n#{build_msg}\"\n end", "def install_gem; end", "def pkg_build\n sysprint \"#{@name} build\"\n\n if @bsdstyle == true\n FileUtils::cd(@srcdir)\n else\n FileUtils::cd(@objdir)\n end\n\n unless sysexec @build\n syserr \"Failed to compile package #{@name}\"\n raise\n end\n\n FileUtils::cd(BSYS_ROOTDIR)\n end", "def install\n system \"make\", \"prefix=#{prefix}\", \"install\"\n end", "def install\n end", "def install\n end", "def install\n system \"make\"\n bin.install \"hisat2\", Dir[\"hisat2-*\"]\n doc.install Dir[\"doc/*\"]\n end", "def install\n mkdir \"build\" do\n system \"cmake\", \"-DSPECIFY_RPATH=ON\", *std_cmake_args, \"..\"\n system \"make\"\n system \"make\", \"install\"\n end\n end", "def install\n # ENV.j1 # if your formula's build system can't parallelize\n\n # Remove unrecognized options if warned by configure\n system \"./configure\", \"--disable-debug\",\n \"--disable-dependency-tracking\",\n \"--disable-silent-rules\",\n \"--prefix=#{prefix}\"\n # system \"cmake\", \".\", *std_cmake_args\n system \"make\", \"install\" # if this fails, try separate make/make install steps\n end", "def build_jar\n `rm framework/local.properties` if File.exists? 'framework/local.properties'\n `rm framework/phonegap.jar` if File.exists? 'framework/phonegap.jar'\n `rm framework/phonegap.js` if File.exists? 'framework/phonegap.js'\n `ECHO 'sdk-location=#{ @android_sdk_path }' > framework/local.properties`\n `cd framework; ant jar`\n end", "def install\n mkdir \"build\" do\n system \"cmake\", \"..\", \"-DCMAKE_INSTALL_SYSCONFDIR=#{etc}\", *std_cmake_args\n system \"make\", \"install\"\n end\n end", "def install\n system \"./configure\", \"--disable-dependency-tracking\",\n \"--disable-silent-rules\",\n \"--enable-introspection\",\n \"--prefix=#{prefix}\"\n system \"make\", \"install\"\n end", "def install\n qt5 = Formula[\"qt@5\"].opt_prefix\n ENV[\"QCTOOLS_USE_BREW\"]=\"true\"\n\n cd \"Project/QtCreator/qctools-lib\" do\n system \"#{qt5}/bin/qmake\", \"qctools-lib.pro\"\n system \"make\"\n end\n cd \"Project/QtCreator/qctools-cli\" do\n system \"#{qt5}/bin/qmake\", \"qctools-cli.pro\"\n system \"make\"\n bin.install \"qcli\"\n end\n end", "def compile\n JavaBuildpack::Util.download(@version, @uri, 'Auto Reconfiguration', jar_name(@version), @lib_directory)\n end", "def compile\n Logger.info \"Compiling. See rbpp_compile.log for details.\"\n require 'rbconfig'\n ruby = File.join(RbConfig::CONFIG[\"bindir\"], RbConfig::CONFIG[\"RUBY_INSTALL_NAME\"])\n FileUtils.cd @working_dir do\n system(\"#{ruby} extconf.rb > rbpp_compile.log 2>&1\")\n system(\"rm -f *.so\")\n system(\"make >> rbpp_compile.log 2>&1\")\n end\n Logger.info \"Compilation complete.\"\n end", "def install\n cmake_args = %W[-DCMAKE_INSTALL_PREFIX=#{prefix}]\n cmake_args << \"-DWITH_Hypre:BOOL=TRUE\" if build.with? \"hypre\"\n cmake_args << \"-DWITH_ElmerIce:BOOL=TRUE\" if build.with? \"elmerice\"\n cmake_args << \"-DWITH_Mumps:BOOL=TRUE\" if build.with? \"mumps\"\n cmake_args << \"-DWITH_MPI:BOOL=FALSE\" if build.without? \"open-mpi\"\n cmake_args << \"-DWITH_MPI:BOOL=TRUE\" if build.with? \"open-mpi\"\n cmake_args << \"-DWITH_OpenMP:BOOL=TRUE\" if build.with? \"openmp\"\n\n exten = (OS.mac?) ? \"dylib\" : \"so\"\n cmake_args << \"-DBLAS_LIBRARIES:STRING=#{Formula[\"openblas\"].opt_lib}/libopenblas.#{exten};-lpthread\"\n cmake_args << \"-DLAPACK_LIBRARIES:STRING=#{Formula[\"openblas\"].opt_lib}/libopenblas.#{exten};-lpthread\"\n\n if build.with? \"elmergui\"\n cmake_args << \"-DWITH_ELMERGUI:BOOL=TRUE\"\n # cmake_args << \"-DWITH_QWT:BOOL=TRUE\"\n # cmake_args << \"-DWITH_OCC:BOOL=TRUE\"\n # cmake_args << \"-DWITH_VTK:BOOL=TRUE\"\n cmake_args << \"-DQWT_INCLUDE_DIR=#{Formula[\"qwt\"].lib}/qwt.framework/Headers\"\n cmake_args << \"-DWITH_QT5:BOOL=TRUE\"\n end\n\n mkdir \"build\" do\n system \"cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/bin/g++\", \"../\", *cmake_args, *std_cmake_args\n system \"make\"\n system \"make\", \"install\"\n system \"ctest -L quick\" if build.with? \"testing\"\n end\n end", "def compile\n end", "def build_cardio()\n CommandProcessor.command(\"VERSION=#{@current_release.version} ./releasinator.sh\", live_output=true)\nend", "def install_build(entry, java_home, version)\n binary = File.join(Dir.tmpdir, \"openjdk\" + version.to_s + \"_openj9\" + \".tgz\")\n expected_checksum = entry['sha256sum']\n puts \"*** expected_checksum = #{expected_checksum}\"\n puts \"*** entry uri = #{entry['uri']}\"\n # Download the Openjdk build from source url to the local machine\n remote_file binary do\n src_url = entry['uri']\n\tsrc_url=\"https://github.com/AdoptOpenJDK/openjdk8-openj9-releases/releases/download/jdk8u152-b16/OpenJDK8-OPENJ9_x64_Linux_jdk8u152-b16.tar.gz\"\n source src_url.to_s\n mode '0755'\n checksum entry['sha256sum']\n action :create\n notifies :run, \"ruby_block[Verify Checksum of #{binary} file]\", :immediately\n end\n\n # Verify Checksum of the downloaded IBM Java build\n ruby_block \"Verify Checksum of #{binary} file\" do\n block do\n checksum = Digest::SHA256.hexdigest(File.read(binary))\n if checksum != expected_checksum\n raise \"Checksum of the downloaded IBM Java build #{checksum} does not match the expected checksum #{expected_checksum}\"\n end\n end\n action :nothing\n end\n\n execute \"Extract OpenJDK#{version} build\" do\n command \"rm -rf #{java_home}\"\n action :run\n end\n\n # Extract the OpenJDK build\n execute \"Extract OpenJDK#{version} build\" do\n command \"tar -zxf #{binary}\"\n action :run\n end\n\n execute \"Extract OpenJDK#{version} build\" do\n command \"mv ./#{entry['release']} #{java_home}\"\n action :run\n end\n\n end", "def packages_cygwin(version)\n setup_exe = \"setup-#{version}.exe\"\n\n return <<-EOF\n mkdir -p /cygdrive/c/cygwin\n # Download setup.exe\n powershell -Command '(New-Object System.Net.WebClient).DownloadFile(\"https://www.cygwin.com/#{setup_exe}\",\"C:\\\\cygwin\\\\#{setup_exe}\")'\n\n # Create a .bat file performing the installation\n echo '\n REM --- Change to use different CygWin platform and final install path\n set CYGSETUP=#{setup_exe}\n REM --- Install build version of CygWin in a subfolder\n set OURPATH=%cd%\n set CYGBUILD=\"C:\\\\cygwin\\\\CygWin\"\n set CYGMIRROR=http://mirrors.kernel.org/sourceware/cygwin/\n set BASEPKGS=openssh,rsync\n set BUILDPKGS=p7zip\n REM set BUILDPKGS=python3,python3-setuptools,python-devel,binutils,gcc-core\n %CYGSETUP% -q -B -o -n -R %CYGBUILD% -L -D -s %CYGMIRROR% -P %BASEPKGS%,%BUILDPKGS%\n cd /d C:\\\\cygwin\\\\CygWin\\\\bin\n regtool set /HKLM/SYSTEM/CurrentControlSet/Services/OpenSSHd/ImagePath \"C:\\\\cygwin\\\\CygWin\\\\bin\\\\cygrunsrv.exe\"\n bash -c \"ssh-host-config --no\"\n bash -c \"chown sshd_server /cygdrive/c/cygwin/CygWin/var/empty\"\n ' > /cygdrive/c/cygwin/install.bat\n\n # Prepare and source our profile\n echo \"alias mkdir='mkdir -p'\" > ~/.profile\n echo \"export CYGWIN_ROOT=/cygdrive/c/cygwin/CygWin\" >> ~/.profile\n echo 'export PATH=$CYGWIN_ROOT/bin:$PATH' >> ~/.profile\n\n echo '' > ~/.bash_profile\n\n cmd.exe /c 'setx /m PATH \"C:\\\\cygwin\\\\CygWin\\\\bin;%PATH%\"'\n source ~/.profile\n\n cd /cygdrive/c/cygwin && cmd.exe /c install.bat\n\n echo 'db_home: windows' > $CYGWIN_ROOT/etc/nsswitch.conf\n EOF\nend", "def compilation_with_makefile\n # Build the program\n depend_msg = `make depend 2>&1`\n build_msg = `make 2>&1`\n \n @log_file.puts \"\\nConstruction des dépendances :\\n\\n#{depend_msg}\"\n @log_file.puts \"\\nConstruction du programme :\\n\\n#{build_msg}\"\n end", "def make url\n require 'formula'\n\n path=Pathname.new url\n\n /(.*?)[-_.]?#{path.version}/.match path.basename\n raise \"Couldn't parse name from #{url}\" if $1.nil? or $1.empty?\n\n path=Formula.path $1\n raise \"#{path} already exists\" if path.exist?\n\n template=<<-EOS\n require 'brewkit'\n\n class #{Formula.class_s $1} <Formula\n @url='#{url}'\n @homepage=''\n @md5=''\n\n cmake def deps\n cmake BinaryDep.new 'cmake'\n cmake end\n cmake\n def install\n autotools system \"./configure\", \"--prefix=\\#{prefix}\", \"--disable-debug\", \"--disable-dependency-tracking\"\n cmake system \"cmake . \\#{cmake_std_parameters}\"\n system \"make install\"\n end\n end\n EOS\n\n mode=nil\n if ARGV.include? '--cmake'\n mode= :cmake\n elsif ARGV.include? '--autotools'\n mode= :autotools\n end\n\n f=File.new path, 'w'\n template.each_line do |s|\n if s.strip.empty?\n f.puts\n next\n end\n cmd=s[0..11].strip\n if cmd.empty?\n cmd=nil\n else\n cmd=cmd.to_sym\n end\n out=s[12..-1] || ''\n\n if mode.nil?\n # we show both but comment out cmake as it is less common\n # the implication being the pacakger should remove whichever is not needed\n if cmd == :cmake and not out.empty?\n f.print '#'\n out = out[1..-1]\n end\n elsif cmd != mode and not cmd.nil?\n next\n end\n f.puts out\n end\n f.close\n\n return path\nend", "def build_pkg(dist, arch, deps)\n start_dir = Dir.pwd\n build_dir = \"/tmp/rhobuild\"\n version = Rhoconnect::VERSION\n description = '\"Rhoconnect production environment\"'\n prefix = \"/opt/rhoconnect/installer\"\n gem_name = \"rhoconnect-#{version}.gem\"\n\n before_install_script = \"#{build_dir}/unix-like/pre_install.sh\"\n after_install_script = \"#{build_dir}/unix-like/post_install.sh\"\n before_remove_script = \"#{build_dir}/unix-like/pre_uninstall.sh\"\n after_remove_script = \"#{build_dir}/unix-like/post_uninstall.sh\"\n\n `rm -rf #{build_dir}` if File.exist?(\"#{build_dir}\")\n Dir.mkdir(\"#{build_dir}\")\n Dir.mkdir(\"#{build_dir}/unix-like\")\n\n # Copy all necessary Files into the build_dir\n system(\"cp install.sh Gemfile Gemfile.lock #{build_dir}\")\n system(\"cp -r installer/unix-like/*.sh #{build_dir}/unix-like\")\n system(\"cp -r installer/unix-like/*.rb #{build_dir}/unix-like\")\n system(\"cp pkg/#{gem_name} #{build_dir}\")\n\n # cd into the pkg dir so that fpm will create the package into the pkg dir.\n Dir.chdir(\"./pkg\") # it created by build task and should already exist\n\n # Construct fpm command\n fpm_cmd = \"fpm -s dir -t #{dist} -n rhoconnect -v #{version} -a #{arch} -C #{build_dir} --epoch 1 \" +\n \"--before-install #{before_install_script} --after-install #{after_install_script} \" +\n \"--before-remove #{before_remove_script} --after-remove #{after_remove_script} \" +\n \"--prefix #{prefix} --description #{description}\"\n # Add the list of dependencies to the fpm call\n deps.each { |dep| fpm_cmd << \" -d '#{dep}'\" }\n fpm_cmd << \" './'\"\n # Create the package\n system(fpm_cmd)\n # Leave no trace...\n system(\"rm -rf #{build_dir}\")\n Dir.chdir(start_dir)\nend", "def compile filetask,system_config,platform\n cmd_file=command_file(filetask.name,system_config,platform)\n if File.exists?(cmd_file)\n mkdir_p(File.dirname(filetask.name),:verbose=>false)\n config=system_config.platform_config(platform)\n if is_assembly?(filetask.prerequisites.first)\n cmdline = assembler(cmd_file,config)\n else\n cmdline = compiler(cmd_file,config)\n end\n sh(cmdline.join(' '))\n else\n raise GaudiError, \"Missing command file for #{filetask.name}\"\n end\n end", "def install\n system \"make\"\n bin.install \"ext4fuse\"\n end", "def globalSetup()\n # Build\n run(\"cd '#{Embedding::CODE_PATH}' && make clean && make\")\nend", "def install\n system \"curl\", \"-L\", \"-o\", \"nuget.exe\", \"https://nuget.org/nuget.exe\"\n system \"/usr/local/bin/mono\", \"nuget.exe\", \"restore\", \"./Source/Boogie.sln\"\n system \"/usr/local/bin/xbuild\", \"Source/Boogie.sln\"\n system \"mkdir\", \"#{prefix}/Binaries\"\n prefix.install Dir[\"Binaries/*\"]\n system \"echo '#!/bin/sh'$'\\\\n''mono\\ #{prefix}/Boogie.exe\\ \\\"$@\\\"'$'\\\\n' > boogie\"\n system \"chmod\", \"+x\", \"boogie\"\n bin.install \"boogie\"\n end", "def compile_js source, dest\r\n case COMPILER\r\n when 'closure'\r\n compilation_level = 'SIMPLE_OPTIMIZATIONS' #WHITESPACE_ONLY | SIMPLE_OPTIMIZATIONS | ADVANCED_OPTIMIZATIONS\r\n sh \"java -jar closure-compiler/compiler.jar --compilation_level #{compilation_level} --js_output_file #{dest} --js #{source}\"\r\n when 'yui'\r\n sh \"java -jar yuicompressor/build/yuicompressor-2.4.2.jar --charset UFT-8 -o #{dest} #{source}\"\r\n when 'ms'\r\n sh \"AjaxMin/AjaxMin -enc:in UFT-8 #{source} -out #{dest}\"\r\n when 'uglify'\r\n sh \"uglifyjs/uglifyjs --ascii --unsafe -o #{dest} #{source}\"\r\n end\r\nend", "def install\n system \"go\", \"install\"\n end" ]
[ "0.6734177", "0.64734024", "0.64705765", "0.64264864", "0.6146586", "0.61381656", "0.6082572", "0.60784847", "0.6038011", "0.6033691", "0.6030359", "0.60287786", "0.6020638", "0.60128796", "0.6006925", "0.6002507", "0.6000753", "0.59836894", "0.5939882", "0.59396726", "0.59269035", "0.5902761", "0.5893125", "0.5892723", "0.5890257", "0.5882002", "0.5866412", "0.5862766", "0.5857727", "0.5826635", "0.5813578", "0.58105564", "0.58096355", "0.5808284", "0.58049816", "0.5801461", "0.57997173", "0.5790216", "0.5771255", "0.57660776", "0.57627964", "0.57502705", "0.5742796", "0.5740192", "0.5737707", "0.5736854", "0.57346076", "0.5714994", "0.5714994", "0.5714994", "0.5713879", "0.5713879", "0.5705841", "0.5698768", "0.56947416", "0.56928146", "0.5686209", "0.5684717", "0.5674847", "0.5674604", "0.5666884", "0.5650736", "0.5645625", "0.5642901", "0.5638838", "0.5638574", "0.5636641", "0.5633686", "0.56300205", "0.56269157", "0.56249183", "0.56126267", "0.56120455", "0.56052184", "0.5605187", "0.5603837", "0.559029", "0.559029", "0.5576762", "0.5575672", "0.5571266", "0.5567437", "0.55662054", "0.5565874", "0.55537903", "0.5550136", "0.5549441", "0.55475223", "0.5544257", "0.5543458", "0.553896", "0.5535867", "0.5533946", "0.55320066", "0.55316967", "0.5527536", "0.5524679", "0.5524153", "0.55230314", "0.55201477", "0.55197465" ]
0.0
-1
Write code here DRY Attempt Returns hash of player given a name, so that other methods can return specific player info
def lookup_by_player (player_name) game_hash.each_pair { |h_or_a, team_info| team_info[:players].map { |player| if player[:player_name] === player_name # player[:location] = h_or_a; # player[:team_name] = game_hash[h_or_a][:team_name]; # player[:team_colors] = game_hash[h_or_a][:colors]; return player; end } } #Could add error message here if player could not be found. N/A for lab. end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player_name(hash)\n return hash[:name]\nend", "def player_stats(name)\n players = players_stats(game_hash)\n \n players.each_pair do |player, stats|\n if player == name\n \n # Fix code to pass the LEARN test\n stats.delete(:player_name)\n \n return stats\n end\n end\n nil\nend", "def player_stats(playerName)\n players[playerName]\nend", "def player_stats(player_name)\n game_hash.each do |place, team|\n team[:players].each do |player|\n if player[:player_name] == player_name\n return player\n end\n end\n end\n end", "def player_stats(name)\n players[name]\nend", "def player_stats(name)\n all_players.find do |player|\n player[:player_name] == name\n end\nend", "def player_stats (player_name)\n lookup_by_player(player_name);\nend", "def player_stats(player_name)\n stats = {}\n player_data.each do |player|\n if player_name == player[:player_name]\n stats[:number] = player[:number]\n stats[:shoe] = player[:shoe]\n stats[:points] = player[:points]\n stats[:rebounds] = player[:rebounds]\n stats[:assists] = player[:assists]\n stats[:steals] = player[:steals]\n stats[:blocks] = player[:blocks]\n stats[:slam_dunks] = player[:slam_dunks]\n end\n end\n return stats\nend", "def player_stats(player)\n game_hash.each do |location, team_info_hash|\n # location = :home,:away; players_hash = :team_name, :colors, :players\n team_info_hash[:players].each do |player_name, player_info_hash|\n # player_name = \"Jeff Adrian\" ect., player_info_hash = :number, :shoe, :points, :rebounds, :assists, :steals, :blocks, :slam_dunks\n if player_name == player\n return player_info_hash\n end\n end\n end\nend", "def player_stats(player_name)\n result = {}\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n result = player\n result.delete(:player_name)\n end\n end\n end\n end\n end\n result\nend", "def get_player_by_user(input_user)\n #current_name=self.playing_user_names.select{|name| self.user_hash[name] == input_user}.first\n current_name=input_user.nick #this uses user.nick, but other places use this too\n return self.player_hash[current_name] #could return nil if user doesn't exist\n end", "def player_name\n player.name\n end", "def player_stats(player_name)\n stat_hash = {}\n game_hash.keys.each do |location|\n if game_hash[location][:players][player_name]\n return game_hash[location][:players][player_name]\n end\n end\nend", "def player_stats(player_name_arg)\n get_me_all_players_please().find do |player_hash|\n player_hash[:player_name] == player_name_arg\n #binding.pry\n end\nend", "def player_stats(player_name, hashketball)\r\n player_name.capitalize!\r\n if hashketball[:home][:players].include?(player_name)\r\n hashketball[:home][:players][player_name][:stats]\r\n elsif hashketball[:away][:players].include?(player_name)\r\n hashketball[:away][:players][player_name][:stats]\r\n else\r\n \"No player found.\"\r\n end\r\nend", "def player_stats(player_name)\n player_stats = []\n game_hash.each do |location, keys|\n keys[:players].each do |player_info|\n if player_info[:player_name] == player_name\n player_info.delete(:player_name)\n player_stats<< player_info\n end \n end\n end\n player_stats[0]\n #binding.pry\nend", "def matching_player(player_name)\n all_players.find do |player|\n player[:player_name] == player_name\n end\nend", "def player_stats(player_name)\n player_stats = {}\n game_hash.each do |team, all_info_hash|\n all_info_hash[:players].each do |stats|\n if stats[:player_name] == player_name\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def player_stats(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e\n end\n end\n end\nend", "def find_player(name)\n all_players.find {|player| name == player.fetch(:player_name)}\nend", "def player_stats(player_name)\nplayer_stats = {}\n game_hash.each do |location, attributes|\n attributes[:players].each do |player, stats|\n if player == player_name\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def player_stats(player_name)\n game_hash.each do |side, value|\n value[:players].each do |name, stats|\n\n if name == player_name\n return stats\n end\n\n end\n end\nend", "def player_stats(name=\"Jeff Adrien\")\n player_stats={}\n if(game_hash[:home][:players].keys.include?(name))\n player_stats= game_hash[:home][:players][name]\n elsif (game_hash[:away][:players].keys.include?(name))\n player_stats = game_hash[:away][:players][name]\n else\n player_stats\n end\nend", "def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attributes, data|\n if attributes == :players\n data.each do |data_item|\n if player_name == data_item[:player_name]\n return data_item\n end\n end\n end\n end\n end\nend", "def shoe_size(player_name)\n # i want all the players first <= simplify it ideally\n # so i can look through them\n # find the player that matches the name\n\n\n # found_player = all_players.find do |player| # Hash\n # player[:player_name] == player_name\n # end\n\n # get the shoe size for that player\n found_player(player_name)[:shoe]\nend", "def player_stats(player_name)\n result = {}\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats\n end\n end\n end\n result\nend", "def player(player_name)\n players.find{|player| player.name == player_name}\n end", "def player_stats(name)\n hash = game_hash\n hash.each do |location, attributes| \n attributes.each do |attribute, info| \n if info.include?(name) \n return hash[location][attribute][name]\n end\n end\n end\nend", "def player_stats(player)\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if name.to_s == player\n return stats\n end\n end\n end\nend", "def player_stats(name)\n# player_stats start at nil (nothing)\n player_stats = nil\n# game_hash.each do |home_away, team_info| iterates over the hash to return all player_stats\n game_hash.each do |home_away, team_info|\n team_info.each do |data_label, data|\n if data_label == :players\n data.each do |player_name, stats|\n if player_name == name\n player_stats = stats\n end\n end\n end\n end\n end\n player_stats\nend", "def player_stats(player_name)\n player_name_stats = nil\n game_hash.select do |team, team_stats|\n team_stats[:players].select do |player_stats|\n if player_stats[:player_name] == player_name\n player_name_stats = player_stats\n end\n end\n end\n player_name_stats\nend", "def player_stats(name_input)\n game_hash.each do |location, team|\n team.each do |category, data|\n if category == :players\n data.find do |name|\n if name[:player_name] == name_input\n p name.reject { |key,value| key == :player_name }\n end\n end\n end\n end\n end\nend", "def player_stats(player_name)\n game_hash.each do |location, data|\n data[:players].each do |player, data_items|\n return data_items if player == \"#{player_name}\"\n end\n end\nend", "def player_label(player_hash)\r\n return \"N/A\" unless player_hash.has_key?(:player_id)\r\n\r\n \"#{player_hash[:first_name]} #{player_hash[:last_name]} (#{player_hash[:player_id]})\"\r\n end", "def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person]\n end\n end\n end\n end\n end\nend", "def player_stats(player_name)\n player_stats = []\n game_hash.collect do |team_key, team_value|\n team_value[:players].each do |stats|\n if stats[:name] == player_name\n stats.delete(:name)#deletes name to keep in same formart ask for in test.\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def player_stats(playername)\n\nif game_hash[:away][:players][playername]\n game_hash[:away][:players][playername]\nelse\n game_hash[:home][:players][playername]\n\nend\nend", "def current_player\n @players.each do |name, letter|\n if letter == whose_turn\n return name\n end\n end\n end", "def get_player\n\t @name\n\tend", "def get_player_name\n if players[1].name == \"You\"\n puts \"What's your name?\"\n players[1].name = gets.chomp\n puts \"Hey, #{players[1].name}. Let's play some blackjack.\\n\\n\"\n end\n end", "def find_player(players, name)\n players.find do |player|\n player[:player_name] == name\n end\nend", "def num_points_scored(name)\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n ## Version 2.0 ##\n\n # 1. get all of the player hashes\n players = get_all_players\n # some imaginary method that will give us all the players from both teams\n\n # 2. get the player's data who matches the given name\n player_data = players[name]\n # since the keys are the player names, we can get the player's data\n # out of the hash by accessing it like this\n\n # 3. get the points from that data\n player_data[:points]\n # finally, with the player_data, we can grab out just the value we want\n # and return it (points)\nend", "def player_stats(name)\n stats = {}\n game_hash.each do |team, team_data|\n team_data[:players].each do |data, output|\n if data == name \n stats = output\n end\n end\n end\n stats\nend", "def player_name(id)\n name = Player.find(id)\n end", "def num_points_scored(name)\n players = get_all_players # Works!\n player = find_player(players, name) # Up next...\n player[:points]\n \nend", "def num_points_scored(name)\n # However, our data is different.\n\n # Given that we have :home and :away, each being a hash with a :players key\n # that is now an array of player hashes (name included), we cannot do this\n # anymore to get the matching player:\n # game_hash[:home][:players][name]\n\n\n # If you it out with binding.pry, you'll get this error:\n # TypeError: no implicit conversion of String into Integer\n # That's because game_hash[:home][:players] is an array and trying to use\n # [name] on it won't work as that would be how you try to access a value\n # in array based on it's position (name is a string, not an integer).\n\n\n # So what do we want to do here?\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n # Let's break it down into steps:\n # 1. get an array of all the players\n # 2. loop through that array and pick out the one whose name matches\n # 3. get the points for that player\n\n # Let's write out our ideal code for accomplishing this:\n players = get_all_players\n player = find_player(players, name)\n player[:points]\nend", "def num_points_scored(name)\n ## Version 2.0 ##\n\n # 1. get all of the player hashes\n players = get_all_players\n # 2. get the player's data who matches the given name\n player_data = players[name]\n # 3. get the points from that data\n player_data[:points]\nend", "def players_hash(team_name)\n players1 = game_hash[:home][:players]\n players2 = game_hash[:away][:players]\n arr_players = players1 + players2\n all_players = arr_players[0].merge(arr_players[1])\n\n result = {\n \"Brooklyn Nets\" => players1[0],\n \"Charlotte Hornets\" => players2[0],\n \"All\" => all_players\n }\n\n # Lookup team_name passed in in above hash\n result[team_name]\nend", "def get_player_reference\n if @player.nil?\n \"Anonymous\"\n else\n @player\n end\n end", "def player_stats(player_name)\n player_stats = {}\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if player_name == element[:player_name]\n player_stats = element\n end\n end\n end\n player_stats\nend", "def get_player_name(name)\n return prompt(\"Player Name? [Player #{name}]\",\"Player #{name}\")\n end", "def num_points_scored(player_name)\n # if you were trying to explain this to someone in prework\n # who's stuck in hashketball, how would you explain how to do this?\n\n # find the num points scored as it relates to the name\n # we have all_players array\n # each value in all players has a smaller value that is the name of the player\n # that is also connected to the number of points they scored\n # find a way to sort the method / just find the value of points attributed to that name\n\n # hash of teams\n # visit each team\n # ask them for the player name list\n # check the list for the name\n # if i find it, then I have their points\n # I would return their points\n\n # argument pass in each player\n # try to return the amount of points associated with that player\n\n # pseudocode\n\n # i want all the players first <= simplify it ideally\n # home_players = game_hash[:home][:players]\n # away_players = game_hash[:away][:players]\n # all_players = home_players + away_players\n\n # so i can look through them\n # .each with an if\n # search, find, gofish\n # array of hashes\n # found_player = all_players.find do |player| # Hash\n # # find the player that matches the name\n # # binding.pry\n # # if player[:player_name] == player_name\n # # true\n # # else\n # # false\n # # end\n # player[:player_name] == player_name\n # end\n\n # get the points for that player\n found_player(player_name)[:points]\nend", "def points_per_player(player, hashketball)\r\n player.capitalize!\r\n if hashketball[:home][:players].include?(player)\r\n hashketball[:home][:players][player][:stats][:points]\r\n elsif hashketball[:away][:players].include?(player)\r\n hashketball[:away][:players][player][:stats][:points]\r\n else\r\n \"No player found.\"\r\n end\r\nend", "def num_points_scored(name)\n players = get_all_players # Works!\n player = find_player(players, name) # Works!\n\n\n player[:points] # Does this work?\n # Test it and you'll see that it does!\nend", "def num_points_scored(player_name)\n # Hash # String #Symbol\n found_player(player_name)[:points] # Number\nend", "def num_points_scored(player_name)\n # Hash # String #Symbol\n found_player(player_name)[:points] # Number\nend", "def player_by_number(number)\n players.each do |name, stats|\n if stats[:number] == number\n return name\n end\n end\nend", "def player_info\n \n clear_terminal\n @prompt = TTY::Prompt.new\n puts \"Enter the name of the player\"\n query = get_user_input\n if Player.all.find_by(name: \"#{query}\") == nil\n clear_terminal\n puts \"Try with hockey, that guy doesn't play soccer!\"\n pause\n pause\n player_info \n else player_info = Player.all.find_by(name: \"#{query}\") \n end\n clear_terminal\n divider\n choice = @prompt.select(\"#{player_info.name} is a great #{player_info.position} who plays in #{player_info.club_id} and has score #{player_info.goals} playing #{player_info.minutes} minutes this season. He had comitted #{player_info.fouls_committed} fouls and has #{player_info.yellow_cards} yellow cards and #{player_info.red_cards}\",\n [\"-> Back\",\"-> Quit\",\"-> Restart\"])\n case choice\n when \"-> Back\"\n players_home\n when \"-> Quit\" || \"QUIT\"\n when \"-> Restart\" || \"RESTART\"\n run\n else\n error\n end\n end", "def get_player_name(count)\n begin\n puts \"\"\n puts \"Enter Player #{count}'s name:\"\n\n temp = gets.chomp\n\n raise InvalidName if temp == \"\"\n\n self.name = temp\n\n rescue InvalidName\n puts \"You need to enter a player name.\"\n get_player_name(count)\n\n end\n end", "def create_player(name)\n {\n \"id\" => @player_class.create(:player_name => name).id\n }\n end", "def get_char_hash(character)\n character_hash = get_character_info_from_api(character)\n character_hash[\"results\"].find do |result|\n result[\"name\"].downcase == character #removed downcase from LH\n end\nend", "def get_player_name\n puts \"Who is playing WITCH WARRIOR today?\"\n @validate_input.get_input\n end", "def player_by_name name\n @players.select {|p| p.name == name}.first\n end", "def num_points_scored(player_name)\n\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n\n # SOLUTION 3\n # get a list of all the players\n # all_players = game_hash.values.collect do |team|\n # team[:players]\n # end.flatten\n\n # find the player whose name matches the argument 'player_name'\n # return that player's points\n # all_players.each do |player|\n # return player[:points] if player[:player_name] == player_name\n # end\nend", "def player_stats(player)\n game_hash.each do |team, team_info|\n team_info.each do |keys, values|\n if keys == :players \n values.each do |stats|\n if player == stats[:player_name]\n return stats\n end\n end\n end\n end\n end\nend", "def points_scored_for_player(name,game)\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:points] if player_hash[:player_name] == name\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:points] if player_hash[:player_name] == name\n end\nend", "def found_player(player_name)\n binding.pry\n # Array of player Hashes\n all_players.find do |player| # player Hash\n # String # String\n player[:player_name] == player_name # Boolean\n end\nend", "def found_player(player_name)\n binding.pry\n # Array of player Hashes\n all_players.find do |player| # player Hash\n # String # String\n player[:player_name] == player_name # Boolean\n end\nend", "def num_points_scored(string) \n game_hash.each do |hash, info|\n player_hash = info[:players] #this returns the key of players and the hash \n player_hash.each do |key, result|\n if(string == key[:player_name])\n return key[:points]\n #binding.pry\n \n end\n end\n\n end \nend", "def current_player_name\n Player.find(player_turn).name unless player_turn.nil?\n end", "def show_player(name)\n if player = Player.find_by_name(name)\n puts \"____________________________________________________________________\"\n puts \"#{player.player} Age:#{player.age} Position:#{player.position}\"\n puts \"Team:#{player.team}\"\n puts \"Games Played: #{player.games_played}\"\n puts \"Goals: #{player.goals}\"\n puts \"Assists: #{player.assists}\"\n puts \"Points: #{player.points}\"\n puts \"Shooting Percentage: #{player.shooting_percentage}\"\n puts \"Plus Minus: #{player.plus_minus}\"\n puts \"Penalty Minutes: #{player.penalty_minutes}\"\n puts \"Average TOI: #{player.toi_avg}\"\n puts \"Blocks: #{player.blocks}\"\n puts \"Hits: #{player.hits}\"\n puts \"Faceoff Percentage: #{player.faceoff_percentage}\"\n puts \"____________________________________________________________________\"\n else\n raise_player_error\n end\n end", "def points(name)\n \n consolidated_player_list = game_hash[:home][:players] + game_hash[:away][:players]\n consolidated_player_list\n player_stat_hash = {}\n\n consolidated_player_list.each do |player|\n key = player[:player_name]\n player_stat_hash[key] = player\n end\n\n points = 0\n player_stat_hash.each do |player|\n points = player[1][:points] if player[0] == name\n end\n points\nend", "def num_points_scored(name)\n # given an array of player data (hashes), find the one whose name matches\n # What is a player?\n\n ## iterate over the list of players\n ## Find the one whose `player_name` matches the name that we're looking for\n\n #binding.pry\n player = find_player(name)\n # find the number of points scored for that player\n #puts player[:points]\n player[:points]\nend", "def player_stats(selected_player)\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player.has_value?(selected_player)\n player.delete(:player_name)\n return player\n end\n end\n end\nend", "def get_player_by_name n\n @players.each{|p| return p if p.try(:name).try(:downcase) == n.try(:downcase) }\n end", "def player_inventory(hash)\n return hash[:inventory]\nend", "def getStats (player)\n if player == \"me\"\n my_hits = self.my_hits\n my_misses = self.my_misses\n my_sunk_ships = sunkShips(\"me\")\n finished = self.finished\n stats = {my_hits: my_hits,\n my_misses: my_misses,\n my_sunk_ships: my_sunk_ships,\n finished: finished}\n statsRet = stats.to_json\n return statsRet\n\n else # player == \"enemy\"\n enemy_hits = self.enemy_hits\n enemy_misses = self.enemy_misses\n enemy_sunk_ships = sunkShips(\"enemy\")\n finished = self.finished\n stats = {enemy_hits: enemy_hits,\n enemy_misses: enemy_misses,\n enemy_sunk_ships: enemy_sunk_ships,\n finished: finished}\n statsRet = stats.to_json\n return statsRet\n end\n end", "def player_class_id(c)\n PlayerClass.find_by(name: c['playerClass']).id\nrescue NoMethodError\n PlayerClass.find_by(name: 'Neutral').id\nend", "def find_player(players, name)\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n # 1. look at each player\n # 2. pick the one whose name matches\n\n # Very straightforward, so again, we should do the work here.\n # Now if we're looping through all the players to find the right one,\n # we could start in the same way that we started trying to do get_all_players.\n # And we'll end up with something like this:\n the_player = {}\n players.each do |player|\n if player[:player_name] == name\n the_player = player\n end\n end\n the_player\n\n # But, as we know. This probably isn't ideal. So let's look for a method\n # that better does what we want. Back to the docs:\n # https://ruby-doc.org/core-2.2.0/Array.html\n # ...\n # Back? What did you find?\n # There are two that look interesting: .select and .find\n # They both read like they do what we want, but there must be a difference.\n the_player = players.select do |player|\n # .select wants you to return a true or false value\n # anything true will count as a match that will be returned.\n # So all we need is the conditional part of our if statement:\n player[:player_name] == name\n end\n\n\n # Check the result, and it looks almost good.\n # the_player == [{ player }]\n # An array with a single player.\n # We could return the matching player like this:\n the_player[0]\n # However, that's not ideal. If we read .select more closely, we realize that\n # it returns *all* matches. So if more than one thing matches our conditional,\n # then this array will be more than a single thing.\n\n # Let's try .find:\n the_player = players.find do |player|\n # It expects the same thing so the same conditional here:\n player[:player_name] == name\n end\n # binding.pry\n # Check the result, and it looks perfect!\n # the_player == { player }\n # So what is the difference?\n # .find will return the very *first* match.\n # .select will return all matches; hence the array as a result.\n # When you need to just find a single thing, use .find.\n # When you want to select all the matches, use .select.\n the_player\nend", "def current_player\n { name: @game.cur_player.name, home_base: @game.cur_player.home_base }\n end", "def show_winner(player)\n puts \"Winner: #{player.name} #{player.identity} CONGRATULATIONS!!!\"\nend", "def player_stats(name)\nhome = game_hash[:home][:players][name]\naway = game_hash[:away][:players][name]\n\nif home != nil\n home\n else\n away\nend\nend", "def get_player_name(n)\n puts \"Player #{n}, what's your name?\"\n name = gets.chomp\n Player.new(name)\n end", "def num_points_scored(player_name)\n# we use .each do |team, random| to iterate over each piece of data to expose specific data, in this case number of points scored by each player, within the above hash\n# and we use symbols (with one object id) to take up less memory\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name, stats|\n if player_name == name\n return stats[:points]\n# then we want to return the number of points scored for each player if player_name is equal to the key of name\n\n end\n end\n end\n\nend", "def shoe_size(player_name)\n # get list of players\n players = get_players\n # find player with matching name\n found_player = find_player(players, player_name)\n # return player's shoe size\n found_player[:shoe]\nend", "def num_points_scored(player_name)\n this_player = player_name\n game_hash.each do |team, team_data|\n team_data[:players].each do |player_name, player_data|\n if player_name == this_player\n return player_data[:points]\n #over thought it, got stuck too long.\n end\n end\n end\n end", "def human_player_and_ai(size)\n\tif first?()\n @player1 = \"player\"\n @player2 = difficulty(size,\"o\")\n else\n @player1 = difficulty(size,\"x\")\n @player2 = \"player\"\n end\nend", "def iterate_through_players_for(name, statistic)\n game_hash.each do |team, game_data|\n \n game_data[:players].each do |player|\n if player[:player_name] == name\n \n return player[statistic]\n end\n end\n end\nend", "def check_cbs_id\r\n @hash = {}\r\n cbs_resp = Faraday.get \"http://api.cbssports.com/fantasy/players/list?version=3.0&SPORT=football&response_format=json\"\r\n cbs_json = JSON.parse(cbs_resp.body)\r\n players = Player.all\r\n cbs_json[\"body\"][\"players\"].each do |cbs_player|\r\n players.each do |player|\r\n if player.cbs_id == cbs_player[\"id\"].to_i && player.full_name != cbs_player[\"fullname\"]\r\n @hash[player.full_name] = cbs_player[\"fullname\"]\r\n end\r\n end\r\n end\r\n end", "def getplayername\n puts \"Enter your username:\\n\\n\"\n puts \"To exit the game, enter \" + \"EXIT\\n\\n\".red\n\n print \">> \"\n name = gets.chomp\n system('clear')\n if name.downcase == \"exit\" #if user input is exit, end the app\n end_program\n return nil\n elsif User.all.any? { |user| user.name.downcase == name.downcase } #if the user exists, get the user object\n user = User.all.select { |user| user.name.downcase == name.downcase}[0]\n puts \"Welcome back, #{user.name}\\n\\n\"\n else #create the user and give them a how to play instructions method call instead of just going to menu\n user = User.create(name: name)\n how_to_play(user)\n end\n user\nend", "def player_name(player)\n player == 1 ? @player_1_name : @player_2_name\nend", "def get_name(player_number, name)\n if player_number == 1\n then @player1 = Player.new(name)\n else\n @player2 = Player.new(name)\n end\n end", "def turns_taken(player)\n @players[player]\n end", "def num_points_scored(player_name)\n game_hash.each do |side, team|\n team.each do |specs, info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def human_and_human_player(size)\n\t@player1 = \"player\"\n @player2 = \"player\"\nend", "def shoe_size(player_name)\n # Hash # String #Symbol\n found_player(player_name)[:shoe] # Number\nend", "def shoe_size(player_name)\n # Hash # String #Symbol\n found_player(player_name)[:shoe] # Number\nend", "def generate_name\n fname = $fnames.sample\n lname = $lnames.sample\n # If the generated name is not unique, call this\n # function again (and so on until it succeeds)\n unless unique_name?(fname + lname)\n generate_name\n end\n return {\n player_fname: fname,\n player_lname: lname,\n player_nickname: fname + $nickname_suffixes.sample,\n family_id: derive_family(lname)\n }\nend", "def parse_player_explicit(name, playerClass = Player)\n player = playerClass.where.not(metanet_id: nil).find_by(name: name) rescue nil\n player = Player.joins('INNER JOIN player_aliases ON players.id = player_aliases.player_id')\n .where([\"player_aliases.alias = ?\", name])\n .take rescue nil if player.nil? && playerClass == Player\n raise OutteError.new \"#{name} doesn't have any high scores! Either you misspelled the name / alias, or they're exceptionally bad...\" if player.nil?\n player\nend", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\n\n nba_match\nend" ]
[ "0.76280874", "0.7153431", "0.6844092", "0.6835698", "0.6759702", "0.67098314", "0.6689651", "0.6685675", "0.66820216", "0.6650911", "0.6641411", "0.656579", "0.65472305", "0.6546737", "0.6545603", "0.6516204", "0.6513769", "0.64928865", "0.6455089", "0.6454938", "0.6454854", "0.64441407", "0.64413816", "0.6430394", "0.64166284", "0.64071584", "0.64020413", "0.6401575", "0.6390939", "0.6352157", "0.6349037", "0.6340573", "0.6330993", "0.6328795", "0.6280862", "0.62761706", "0.6273905", "0.6255524", "0.62402654", "0.6239072", "0.6226702", "0.61968434", "0.6192661", "0.6191061", "0.618979", "0.6176088", "0.61598533", "0.6152154", "0.61192864", "0.61101985", "0.61083794", "0.6106453", "0.6102512", "0.60919356", "0.60881144", "0.60881144", "0.6078195", "0.607391", "0.60615754", "0.6044977", "0.60263777", "0.6020513", "0.60190356", "0.60038555", "0.5984906", "0.5976571", "0.5972978", "0.5972978", "0.5967022", "0.59661216", "0.5962338", "0.5954662", "0.5950672", "0.59228325", "0.5920425", "0.5917332", "0.5910292", "0.59087807", "0.5908588", "0.5908538", "0.58942664", "0.58941925", "0.5892944", "0.58824694", "0.5860293", "0.58587605", "0.585107", "0.5839855", "0.5838877", "0.58326125", "0.5820671", "0.58137715", "0.5785572", "0.57841456", "0.57813627", "0.57803553", "0.57803553", "0.57784015", "0.5774218", "0.5770378" ]
0.685125
2
DRY Attempt Returns hash of team info when looking for a specific team
def lookup_by_team (team_name) game_hash.map { |home_or_away, team_info| if team_name === team_info[:team_name] team_info[:location] = home_or_away; return team_info; end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_team_info(team_name)\n team_info = game_hash.find do |color, team_data|\n team_data[:team_name] == team_name\n end\n team_info[1]\nend", "def team_info(team_id)\n team_info_hash(team_id)\n end", "def one_team_stats(team_name)\n game_hash.each do |home_or_away, team_stats|\n if team_stats[:team_name] == team_name\n return team_stats\n end\n end\nend", "def teamSelect(teamName)\n teams.find do|key|\n key[:team_name] == teamName\n end\n end", "def team_colors(team)\n # PREVIOUS SOLUTION\n # if game_hash[:home][:team_name] == team\n\t# \tteam_colors = game_hash[:home][:colors]\n\t# elsif game_hash[:away][:team_name] == team\n\t# \tteam_colors = game_hash[:away][:colors]\n\t# end\n game_hash.each do |location, team_info_hash|\n # location = :home,:away; players_hash = :team_name, :colors, :players\n return team_info_hash[:colors] if team_info_hash[:team_name] == team\n end\nend", "def team_names\n game_hash.collect do |team, all_info_hash|\n all_info_hash[:team_name]\n end\nend", "def find_team(team_name)\n teams.find {|team| team_name == team.fetch(:team_name)}\nend", "def team_names\n team_name = []\n game_hash.each do |team,info|\n team_name << info[:team_name]\n end\n team_name\nend", "def team_names\n team = []\n game_hash.values.each do |team_info|\n team << team_info[:team_name]\n end\n team\nend", "def team_colors(team_name)\n team_color = []\n game_hash.find do |team,info|\n if info[:team_name] == team_name\n team_color = info[:colors]\n end\n info[:team_name] == team_name\n end\n team_color\nend", "def team_names\n [\n game_hash.dig(:home, :team_name),\n game_hash.dig(:away, :team_name)\n ]\nend", "def team_names\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_names\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def player_data_by_team(team)\n players = []\n if team == game_hash[:home][:team_name]\n players << game_hash[:home][:players]\n else\n players << game_hash[:away][:players]\n end\n return players.flatten\nend", "def team_colors(team_name)\n found_team = all_team_info(team_name)\n found_team[:colors]\nend", "def team_names\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_names\n game_hash.map do |team, team_stats|\n team_stats[:team_name]\n end\nend", "def team_by_name(team_name)\n game_hash[:home].has_value?(team_name) ? game_hash[:home] : game_hash[:away]\n end", "def get_team_by_name team\n @standings.detect {|t| t[:name] == team[:name]}\nend", "def team_names\n team_names = []\n #top level\n game_hash.each do |location, team_data|\n #2nd level\n team_data.each do |team_deets, values|\n #find team name pair\n if team_deets == :team_name\n team_names << team_data[team_deets]\n end\n end\n end\n team_names = team_names.flatten\nend", "def players_hash(team_name)\n players1 = game_hash[:home][:players]\n players2 = game_hash[:away][:players]\n arr_players = players1 + players2\n all_players = arr_players[0].merge(arr_players[1])\n\n result = {\n \"Brooklyn Nets\" => players1[0],\n \"Charlotte Hornets\" => players2[0],\n \"All\" => all_players\n }\n\n # Lookup team_name passed in in above hash\n result[team_name]\nend", "def team_colors(team_name)\n result = nil\n game_hash.each do |team, about|\n if about[:team_name] == team_name\n result = about[:colors]\n end\n end\n result\nend", "def get_team\n if (!params[:team_key])\n return nil\n else\n team = Team.find_by_key(params[:team_key])\n if (!team)\n return nil\n else\n return team\n end\n end\n end", "def team_names\n game_hash.map do |place, team|\n team[:team_name]\n end\nend", "def team_colors(team_name)\n team_colors = nil\n game_hash.map do |team, team_stats|\n if team_stats[:team_name] == team_name\n team_colors = team_stats[:colors]\n end\n end\n team_colors\nend", "def team_names\n names = []\n game_hash.each do | team, attributes|\n names << game_hash[team][:team_name]\n end\n return names\nend", "def users_by_team\n result = {}\n \n memberships.each do |membership|\n result[membership.team] ||= []\n result[membership.team] << membership.user.nickname\n end\n \n result\n end", "def team_names\n names = []\n game_hash.each do |location, data|\n names << data[:team_name]\n end\n names\nend", "def team_names\n data = game_hash\n all_teams = []\n \n data.each_pair do |home_away, home_away_hash|\n home_away_hash.each_pair do |team_key, team_value|\n \n if team_key == :team_name\n all_teams << team_value\n end\n \n end\n end\n all_teams\nend", "def team_colors (team_name)\n colors = nil\n game_hash.each do |team, all_info_hash|\n if all_info_hash[:team_name] == team_name\n colors = all_info_hash[:colors].flatten\n end\n end\n colors\nend", "def team_names\n # built an empty array called teams\n teams = []\n # game_hash.each do |team, random| iterates over the hash to return all of the team_names\n game_hash.each do |team, random|\n teams.push(game_hash[team][:team_name])\n end\n return teams\nend", "def team_names\n game_hash.collect do |location, attributes|\n attributes[:team_name]\n end\nend", "def team_names\n teams = []\n teams << game_hash[:home][:team_name]\n teams << game_hash[:away][:team_name]\n return teams\nend", "def team_names\n teams.collect do|key|\n key[:team_name]\n end\nend", "def team_colors(team_name)\n (game_hash[:home][:team_name] == team_name.to_s) ? team = :home : team = :away\n game_hash[team][:colors]\nend", "def team_names\n team_names = []\n game_hash.each do |home_or_away, team_stats|\n team_names << team_stats[:team_name]\n end\n team_names\nend", "def team_names\n game_hash.collect do |team_key, team_value|\n team_value[:team_name]\n end\nend", "def team_colors(team, hashketball)\r\n sym = team.to_sym\r\n if hashketball.include?(sym)\r\n hashketball[sym][:colors]\r\n else\r\n \"Try home or away.\"\r\n end\r\nend", "def find_teams(league)\n teams = []\n league.each do |team|\n teams << team[:home_team]\n teams << team[:away_team]\n end\n uniq_teams = teams.uniq!\nend", "def all_teams_hash_by_leagues(league_ids)\n teams = {}\n league_ids.each do |league_id|\n teams_in_league = parse_api_request(\"#{BASE_URL}teams/league/#{league_id}\")[\"teams\"]\n teams_in_league.each {|team_data|\n teams[team_data[1][\"team_id\"]] = team_data[1][\"name\"]}\n end\n teams\nend", "def team_names\n game_hash.collect {|home_or_away, stats| team_name = stats[:team_name].to_s}\nend", "def team_colors(team_name)\n if team_name == \"Brooklyn Nets\"\n game_hash[:home][:colors]\n else\n game_hash[:away][:colors]\n end\nend", "def team_colors(team_name)\n game_hash.each do |place, team|\n if team[:team_name] == team_name\n return team[:colors]\n end\n end\nend", "def team\n return self[:team] if self[:team].is_a? Team\n team = if self[:team].split('-').count > 2 or self[:team].to_i > 0 or self.sport.name == 'FWC'\n Team.where(:stats_id => self[:team])\n else\n Team.where(:abbrev => self[:team])\n end\n team.first\n end", "def find_fake_team(team_name)\n owner = Owner::TEAM_NAME_MAP.find do |o|\n o[:team_names].keys.include?(team_name.to_sym)\n end\n owner[:team_names][team_name.to_sym]\n end", "def team_colors(team)\n game_hash.each do |location, team_data|\n if team_data[:team_name] == team\n return team_data[:colors]\n end\n end\nend", "def team_names\n hash = game_hash\n array = []\n hash.each do |location, attributes|\n attributes.each do |attribute, info|\n if attribute == :team_name\n array << info\n end\n end\n end\n return array\nend", "def team_colors(team)\n \n data = game_hash\n teams = team_name_stats(data)\n \n teams.each_pair do |team_name, team_hash|\n if team_name == team\n team_hash.each_pair do |team_key, team_value|\n if team_key == :colors\n return team_value\n end\n end\n end\n end\n \n nil \nend", "def team_colors(team_name)\n if team_name == \"Brooklyn Nets\"\n return game_hash[:home][:colors]\n else\n return game_hash[:away][:colors]\n end \nend", "def team_colors(team)\n game_hash.each do |location, attributes|\n if attributes[:team_name] == team\n return attributes[:colors]\n end\n end\nend", "def team_colors(teamname)\nif game_hash[:home][:team_name] == teamname\n #returns the arrar if team_name matches teamname\n game_hash[:home][:colors]\nelsif game_hash[:away][:team_name] == teamname\n game_hash[:away][:colors]\nend\nend", "def team_names\n team_names = []\n \n game_hash.each do |key, value|\n team_names << value[:team_name]\n end\n team_names\nend", "def team_names\n array = [] \n game_hash.each do |team, attributes|\n attributes.each do |key, value|\n if key == :team_name\n array.push(value)\n \n end\n end\n end\n array\nend", "def team_colors (team_name)\n lookup_by_team(team_name)[:colors];\nend", "def team_for_id(id)\n team = @teams[id]\n\n raise(ActiveRecord::RecordNotFound, \"No team found for id #{id} in #{@teams.keys.sort}\") unless team\n\n team\nend", "def team_names\n names = []\n game_hash.each do |k, team|\n names.push(team[:team_name])\n end\n names\nend", "def team_names\n arrayOfTeamNames = [] #initialize new hash\n arrayOfTeamNames << game_hash[:home][:team_name]\n arrayOfTeamNames << game_hash[:away][:team_name] #shovel it with the data\nend", "def lookup_by_player (player_name) \n game_hash.each_pair { |h_or_a, team_info|\n team_info[:players].map { |player|\n if player[:player_name] === player_name\n# player[:location] = h_or_a;\n # player[:team_name] = game_hash[h_or_a][:team_name];\n # player[:team_colors] = game_hash[h_or_a][:colors];\n return player;\n end\n }\n }\n #Could add error message here if player could not be found. N/A for lab. \nend", "def team\n @team ||= Struct.new(:name, :domain).new(@team_name, @domain)\n end", "def team\n fetch('esport.teams')\n end", "def team_names\n\tnew_hash = game_hash\n\tnew_hash.map{|key, value| new_hash[key][:team_name]}\nend", "def team_colors(team_name)\n game_hash.keys.each do |location|\n return game_hash[location][:colors] if game_hash[location][:team_name] == team_name\n end\nend", "def team_colors(user_team_name)\n game_hash.each do |k, team|\n if team[:team_name] == user_team_name\n return team[:colors]\n end\n end\nend", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def team_colors(team_name, game)\n return game[:home_team][:team_colors] if game[:home_team][:team_name] == team_name\n return game[:away_team][:team_colors] if game[:away_team][:team_name] == team_name\nend", "def team_names()\n result = []\n game_hash.each do |side,team|\n result.push(team[:team_name])\n end\n result\nend", "def team_names\n # team_array = []\n # team_array.push(game_hash[:home][:team_name])\n # team_array.push(game_hash[:away][:team_name])\n # team_array\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def get_team_details(params)\n get('team', params)\n end", "def team_names\n teams = []\n teams << game_hash[:home][:team_name] << game_hash[:away][:team_name]\nend", "def team_colors(team_name)\n \n game_hash.each do |team, attributes|\n attributes.each do |key, value|\n if value == team_name \n return game_hash[team][:colors]\n \n end\n end\n end\n \nend", "def team_names\n team_names = []\n for location in game_hash.keys\n team_names.push(game_hash[location][:team_name])\n end\n return team_names\nend", "def all_players_for_a_team(team_name, game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:home_team][:team_name] == team_name\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:away_team][:team_name] == team_name\n end\n player_names\nend", "def team_names\n output =[]\n game_hash.each do |location, team_data|\n output.push(team_data[:team_name])\n end\n output\nend", "def team_colors(name_of_team)\n # using .each do |team, random| game_hash[team].each do |name, random| to iterate over each piece of data\n # then, if the name_of_team is equal to random, we'll get a return value of the colors of each team.\n game_hash.each do |team, random|\n game_hash[team].each do |name, random|\n if name_of_team == random\n return game_hash[team][:colors]\n end\n end\n end\nend", "def team_names\n fin_arr = []\n fin_arr << game_hash[:home][:team_name]\n fin_arr << game_hash[:away][:team_name]\n fin_arr\nend", "def team_colors (team_name)\n answer = nil\n game_hash.collect do |team_key, team_value|\n if team_value[:team_name] == team_name\n answer = team_value[:colors]\n end\n end\n answer\nend", "def team_colors(team_name)\n team_colors =[]\n \n game_hash.each do |key, value|\n if team_name == value[:team_name]\n team_colors = value[:colors]\n end\n end\n team_colors\nend", "def get_team(game)\n team = 0\n get_participation_by_game game do |participation|\n team = participation.team\n end\n team\n end", "def team_colors(name)\n game_hash.each do |location, team_data|\n if team_data[:team_name] == name\n return team_data[:colors]\n end\n end\nend", "def player_numbers(team_name)\n jersey_nums = []\n game_hash.each do |location, data|\n if data[:team_name] == \"#{team_name}\" #found match\n data[:players].each do |player, value|\n jersey_nums << value[:number]\n end\n end\n end\n jersey_nums\nend", "def team_id_for(team_param)\n team_id = team_param\n if team_param.is_a?(Hash)\n team_id = team_param[:id]\n elsif team_param.is_a?(String) && team_param.to_i.to_s != team_param\n team_data = teams.values.find do |t|\n team_param == t[:slug] || team_param == \"#{t[:organization]}/#{t[:slug]}\"\n end\n team_id = team_data ? team_data[:id] : nil\n end\n team_id\n end", "def red_team\n teams[2]\n end", "def blue_team\n teams[1]\n end", "def team\n teams.where(hubstats: true).first\n end", "def team_id(team)\n # In ruby 1.8 doing a Integer(:symbol) returns an integer. Thus, test\n # for symbol first.\n if team.is_a? Symbol\n teams.fetch(team)\n else\n Integer(team) rescue teams.fetch(team.to_sym)\n end\n rescue IndexError\n fail BadConfig, \"No team id defined for team #{team}.\"\n end", "def team_names\n # team_array = []\n game_hash.map do |location, team_data|\n # p team_data[:team_name]\n team_data[:team_name]\n end\nend", "def teams\n game_hash.values\n end", "def team_names \n # team_array = []\n # game_hash.each do |location, team_data|\n # team_array << team_data[:team_name]\n # end\n # team_array\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def get_team_name_by_id(team_id)\n response = parse_api_request(\"#{BASE_URL}teams/team/#{team_id}\")[\"teams\"].values.first[\"name\"]\nend", "def team_from_payload(payload)\n metadata_from_payload(payload)['team'] || Rails.application.config.settings.default_team_name\n end", "def team_by_email\n @team_by_email ||= team_index_by_field 'email'\n end", "def team_names(hashketball)\r\n puts \"The #{hashketball[:home][:team_name]} welcome the #{hashketball[:away][:team_name]}\"\r\n puts \r\nend", "def show_team_info\n puts \"\\nEnter a team name please?\"\n answer = gets.chomp\n\n team = @sport.teams.find_by(name: answer)\n\n puts \"\\n NAME: #{team.name}\\n\\n CITY: #{team.city.name}\\n\\n MASCOT: #{team.mascot}\\n\\n COLORS: #{team.colors}\\n\\n CHAMPIONSHIPS: #{team.championships}\\n\\n DESCRIPTION: #{team.info}\\n\\n\"\n end", "def player_stats(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e\n end\n end\n end\nend", "def team_colors(team_name)\n one_team_stats(team_name)[:colors]\nend", "def home_team_name\n return home_team.try(:name)\n end", "def team_colors(team)\n game_hash.each do |side, value|\n if value[:team_name] == team\n return value[:colors]\n end\n end\n end", "def cfdb_team_key(team)\n if team.split(\" \")[1] == \"Miss\" || team.split(\" \")[1] == \"State\" || team.split(\" \")[1] == \"Carolina\" || team.split(\" \")[1] == \"A&M\"\n team_name = \"#{team.split(\" \")[0]} #{team.split(\" \")[1]}\"\n else\n team_name = \"#{team.split(\" \")[0]}\"\n end\n return team_name\n end", "def team_name\n return @team_name\n end", "def player_numbers(team)\n player_numbers = []\n game_hash.each do |location, attributes|\n if attributes[:team_name] == team\n attributes[:players].each do |player, stats|\n player_numbers << stats[:number]\n end\n end\n end\n player_numbers\nend" ]
[ "0.8209577", "0.80243915", "0.73967505", "0.7355486", "0.7327", "0.7322008", "0.73188317", "0.7280859", "0.72722125", "0.72686076", "0.71976966", "0.7189932", "0.7189932", "0.7179784", "0.71696717", "0.71151376", "0.7111152", "0.70994854", "0.70809335", "0.7073181", "0.70686865", "0.7068049", "0.70568854", "0.7032657", "0.70213634", "0.70097613", "0.70049316", "0.70045036", "0.7000643", "0.69942296", "0.698829", "0.6984485", "0.698424", "0.6982274", "0.6977081", "0.6967859", "0.6967237", "0.69655305", "0.6925376", "0.690788", "0.6907438", "0.6885058", "0.6884168", "0.68771476", "0.687054", "0.6869083", "0.686019", "0.68522686", "0.68503207", "0.68422145", "0.6820282", "0.6814181", "0.681184", "0.68106467", "0.67983806", "0.6790895", "0.6787056", "0.67844456", "0.6783024", "0.677205", "0.6768247", "0.6761", "0.67548066", "0.67420024", "0.6737576", "0.67367", "0.67362887", "0.6722988", "0.6718792", "0.6716367", "0.6695852", "0.66904366", "0.668661", "0.6678921", "0.6678741", "0.66547364", "0.66459924", "0.66318303", "0.66241765", "0.66105366", "0.660479", "0.65758574", "0.65757436", "0.65679234", "0.65549016", "0.6548547", "0.6544592", "0.6544256", "0.6540626", "0.6538686", "0.6528254", "0.65197146", "0.65188205", "0.6518631", "0.6516724", "0.65121007", "0.6508063", "0.6504152", "0.64974844", "0.64974195" ]
0.7068622
21
DRY Attempt Returns a AoH of all players
def player_collection all_players = []; game_hash.each_pair { |h_or_a, team_info| team_info[:players].map { |player| player[:location] = h_or_a; player[:team_name] = game_hash[h_or_a][:team_name]; player[:team_colors] = game_hash[h_or_a][:colors]; all_players << player; } } all_players; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_players\n home_players = game_hash[:home][:players] # Array of player Hashes\n away_players = game_hash[:away][:players] # Array of player Hashes\n home_players + away_players # Array of player Hashes\nend", "def all_players\n home_players = game_hash[:home][:players] # Array of player Hashes\n away_players = game_hash[:away][:players] # Array of player Hashes\n home_players + away_players # Array of player Hashes\nend", "def get_players\n\n end", "def all_players\n home_team = game_hash.fetch(:home).fetch(:players)\n away_team = game_hash.fetch(:away).fetch(:players)\n return home_team + away_team\nend", "def players\n all_players = {}\n game_hash.each do |home_or_away, team_stats|\n all_players.merge!(team_stats[:players])\n end\n all_players\nend", "def get_all_players\n ## Version 2.0 ##\n\n all_players = []\n\n # Same steps, but since we don't care about team, let's use .values to just\n # iterate over the team_data:\n game_hash.values.each do |team_data|\n team_data[:players].each do |player|\n all_players << player\n end\n end\n\n all_players\nend", "def all_players\n Player.all\nend", "def all_stats_for_player(name, game)\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats] if player_hash[:player_name] == name\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats] if player_hash[:player_name] == name\n end\nend", "def player_data\n players = []\n game_hash.each do |home_away, team_details|\n players << team_details[:players]\n end\n return players.flatten\nend", "def players\n @players || []\n end", "def all_players\n away_players + home_players\nend", "def all_players\n home_players + away_players\nend", "def get_all_players\n ## Version 2.0 ##\n\n # Same steps, but with a slight tweak...\n all_players = {}\n\n # We don't need team. We only want to loop through the data.\n # So, why don't we use .values to and then just loop through the values\n # in the hash!\n game_hash.values.each do |team_data|\n all_players.merge! team_data[:players]\n end\n\n all_players\nend", "def players\n @players ||= []\n end", "def players\n @players ||= []\n end", "def get_all_players\n ## Version 5.0 ##\n\n # We can just chain .flatten onto the end of map.\n # By doing this, we can get rid of all_players.\n game_hash.values.map do |team_data|\n team_data[:players]\n end.flatten\nend", "def all_players \n game_hash[:home][:players] + game_hash[:away][:players]\nend", "def all_at_table\n @players+[@dealer]\n end", "def players\n #merge list of players\n game_hash[:home][:players].merge(game_hash[:away][:players])\nend", "def build_list_of_players\nend", "def players; [@hunter, @prey] end", "def merged_players\n game_hash[:home][:players].concat(game_hash[:away][:players])\n end", "def players\n return [User.find_by(id: player1_id), User.find_by(id: player2_id),\n User.find_by(id: player3_id), User.find_by(id: player4_id)].compact\n end", "def players\n # Build two arrays of players\n cur_players = teams.map do |team|\n team.wattball_players\n end\n\n # Combine the arrays\n cur_players.flatten! \n end", "def players\n @players.select(&:playing)\n end", "def each_player\n @players.each\n end", "def all_players_for_a_team(team_name, game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:home_team][:team_name] == team_name\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:away_team][:team_name] == team_name\n end\n player_names\nend", "def all_players\n instance_variables.map { |var| instance_variable_get(var) }.reduce([]) { |acc, team| acc + team.players }\n end", "def all_players(game_hash)\n game_hash[:home][:players] + game_hash[:away][:players]\nend", "def team_players\n Player.all\n end", "def players\n # players_array = []\n # iterating through game hash and returning a list of all my players\n game_hash.map do |key, value|\n value[:players]\n end.flatten\n\nend", "def players\n users\n end", "def players\n go_fish.players\n end", "def name_all_players\n (0..num_players - 1).each { |i| @players[i].name_player('Player' + i.to_s)}\n end", "def player_data_by_team(team)\n players = []\n if team == game_hash[:home][:team_name]\n players << game_hash[:home][:players]\n else\n players << game_hash[:away][:players]\n end\n return players.flatten\nend", "def players\n game_hash[:away][:players].concat(game_hash[:home][:players])\n \nend", "def home_team_players\n home_team_players = game_hash[:home][:players]\nend", "def get_all_players\n ## Version 4.0 ##\n\n all_players = []\n\n game_hash.values.each do |team_data|\n all_players << team_data[:players]\n end\n # This pattern of going through each value and then plucking out just a single\n # piece of the data is very, very common.\n # What we are doing is what .map was built for.\n\n ## Example of .map ##\n instructors = [\n { name: 'Lyn', cats: true },\n { name: 'Princeton', cats: false },\n { name: 'Maddie', cats: true }\n ]\n # Goal, get an array that looks like this:\n # ['Lyn', 'Princeton', 'Maddie']\n # This can be accomplished by .map:\n instructor_names = instructors.map do |instructor|\n instructor[:name]\n end\n # The result of map is the data you returned in each iteration.\n # Map is very cool in that you can do more than just pick data to return.\n # You can also transform the data!\n # For example, doubling the number in this array:\n x = [1, 2, 3, 4]\n doubled_x = x.map do |num|\n num * 2\n end\n # doubled_x == [2, 4, 6, 8]\n # Or even more fun, deciding what to return based on the data you are looping over:\n meow = instructors.map do |instructor|\n if instructor[:cats]\n instructor[:cats] = \"😸\"\n else\n instructor[:cats] = \"😿\"\n end\n instructor\n end\n # meow == [{ name: \"Lyn\", cats: \"😸\" }, { name: \"Princeton\", cats: \"😿\" }, { name: \"Maddie\", cats: \"😸\" }]\n\n # Knowing how map works, we can now rewrite our .each but with a map instead\n # and get rid of the initial empty array, all_players = [], because .map\n # will now return the same resulting value:\n all_players = game_hash.values.map do |team_data|\n # We can also get rid of the shovel as we don't need to put them into an array.\n team_data[:players]\n end\n\n all_players.flatten\nend", "def home_players\n game_hash[:home][:players]\nend", "def players\n game_hash[:home][:players].merge(game_hash[:away][:players])\nend", "def players\n [player_one, player_two].compact\n end", "def players\n gp = Player.where :instance_id => self.id\n gp.map { |p| p.user_id }\n end", "def player_stats(name)\n# player_stats start at nil (nothing)\n player_stats = nil\n# game_hash.each do |home_away, team_info| iterates over the hash to return all player_stats\n game_hash.each do |home_away, team_info|\n team_info.each do |data_label, data|\n if data_label == :players\n data.each do |player_name, stats|\n if player_name == name\n player_stats = stats\n end\n end\n end\n end\n end\n player_stats\nend", "def player\n fetch('football.players')\n end", "def home_players\n game_hash[:home][:players] \nend", "def players\n (@players ||= []).map{|id| W.find_player id}.freeze\n end", "def show_favorite_players(fan) #this method is backend finding the players of a specifc fan\n players_array = favorite_players(fan)\n players_array.each do |player|\n puts player.name \n end\nend", "def players\n @a = Array.new\n @a << east \n @a << south\n @a << west\n @a\n end", "def player_stats(player_name)\n game_hash.each do |location, data|\n data[:players].each do |player, data_items|\n return data_items if player == \"#{player_name}\"\n end\n end\nend", "def get_players\n all_players = consume_player_data\n delete_id_column(all_players)\n end", "def create_players\n players = []\n players << create_player('player_1')\n players << create_player('player_2')\n players\n end", "def index\r\n @gameplayers = Gameplayer.includes(:player, :game).all\r\n end", "def get_players\n players = []\n game_hash.each do |teams, team_data|\n # players.push(team_data[:players])\n players << team_data[:players]\n end\n players.flatten\nend", "def player_stats(name)\n all_players.find do |player|\n player[:player_name] == name\n end\nend", "def index\n @players = @game.players\n end", "def index\n @players = @game.players\n end", "def get_alliance\n @alliance_player_ids = @player.alliance_ids\n end", "def away_players\n game_hash[:away][:players]\nend", "def player_stats(player_name)\n stats = {}\n player_data.each do |player|\n if player_name == player[:player_name]\n stats[:number] = player[:number]\n stats[:shoe] = player[:shoe]\n stats[:points] = player[:points]\n stats[:rebounds] = player[:rebounds]\n stats[:assists] = player[:assists]\n stats[:steals] = player[:steals]\n stats[:blocks] = player[:blocks]\n stats[:slam_dunks] = player[:slam_dunks]\n end\n end\n return stats\nend", "def show\n\t\t@players = {}\n\t\[email protected] do |player|\n\t\t\tpoints = @tournament.games.find_all { |game| game.winner == player }.count\n\t\t\t@players[points] = [] unless @players[points]\n\t\t\t@players[points] << player\n\t\tend\n\tend", "def player_stats(player_name)\nplayer_stats = {}\n game_hash.each do |location, attributes|\n attributes[:players].each do |player, stats|\n if player == player_name\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def get_players\n load_firebase\n # @player_list = Hash.new\n @player_list = Array.new\n @json_object.each do |key, value|\n @player_list << value\n end\n @player_list\n end", "def entries_to_players\n\t\tplayers = []\n\t\[email protected] do |entry|\n\t\t\tif entry.enabled\n\t\t\t\tplayers << entry.player\n\t\t\tend\n\t\tend\n\t\tplayers\n\tend", "def player_stats(player_name)\n result = {}\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n result = player\n result.delete(:player_name)\n end\n end\n end\n end\n end\n result\nend", "def player_stats(player)\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if name.to_s == player\n return stats\n end\n end\n end\nend", "def just_ai\n player1 = Players::AdvancedAI.new(\"X\")\n player2 = Players::Student01.new(\"O\")\n # player1 = Players::Student01.new(\"X\")\n # player2 = Players::AdvancedAI.new(\"O\")\n stats = []\n\n\n 2000.times do\n game = Game.new(player1, player2)\n game.play\n stats << game.winner\n end\n\n puts \"X won #{stats.count(\"X\")} and O won #{stats.count(\"O\")}!\"\n end", "def players\n results = get_parts(\"status\", 2..-1)\n results.map do |player|\n player = player.split(\" \", 3)\n {\n :name => player[2][1..-2],\n :ping => player[1].to_i,\n :score => player[0].to_i\n }\n end\n end", "def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attributes, data|\n if attributes == :players\n data.each do |data_item|\n if player_name == data_item[:player_name]\n return data_item\n end\n end\n end\n end\n end\nend", "def get_opponents(game)\n opponents = []\n game.get_players.each do |player|\n if player.get_team(game) != self.get_team(game)\n opponents.push player\n end\n end\n opponents\n end", "def index\n @game_players = GamePlayer.all\n end", "def player_names\n self.players.pluck(:username).join(\", \")\n end", "def player_stats(name=\"Jeff Adrien\")\n player_stats={}\n if(game_hash[:home][:players].keys.include?(name))\n player_stats= game_hash[:home][:players][name]\n elsif (game_hash[:away][:players].keys.include?(name))\n player_stats = game_hash[:away][:players][name]\n else\n player_stats\n end\nend", "def player_stats(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e\n end\n end\n end\nend", "def away_players\n game_hash[:away][:players] \nend", "def get_all_opponents(id, matchid, player_hash, outputarr)\n response = `curl -s --user #{CHALLONGE_USER}:#{CHALLONGE_TOKEN} -X GET #{api_url(id)}/matches/#{matchid}.json`\n match = JSON.parse(response)['match']\n if match['player1_id']\n outputarr.push(player_hash.key(match['player1_id'].to_s))\n else\n get_all_opponents(id, match['player1_prereq_match_id'].to_i, player_hash, outputarr)\n end\n if match['player2_id']\n outputarr.push(player_hash.key(match['player2_id'].to_s))\n else\n get_all_opponents(id, match['player2_prereq_match_id'].to_i, player_hash, outputarr)\n end\nend", "def player_stats(player)\n game_hash.each do |location, team_info_hash|\n # location = :home,:away; players_hash = :team_name, :colors, :players\n team_info_hash[:players].each do |player_name, player_info_hash|\n # player_name = \"Jeff Adrian\" ect., player_info_hash = :number, :shoe, :points, :rebounds, :assists, :steals, :blocks, :slam_dunks\n if player_name == player\n return player_info_hash\n end\n end\n end\nend", "def index\n @game_session_players = GameSessionPlayer.all\n end", "def list_all_players\n json_output = Player.all.map do |player|\n {\n id: player.id,\n name: player.name,\n image_url: player.image_url,\n }\n end\n\n render :json => json_output\n end", "def players_names_array \n player_names = []\n game_hash.each do |place,team|\n team.each do |attribute, data|\n next unless attribute == :players\n data.each do |player| \n player_names.push(player[:player_name])\n end\n end\n end\n player_names\nend", "def player_stats(player_name)\n game_hash.each do |side, value|\n value[:players].each do |name, stats|\n\n if name == player_name\n return stats\n end\n\n end\n end\nend", "def player_stats(player_name)\n result = {}\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats\n end\n end\n end\n result\nend", "def get_players \n game_hash[:away][:players] += game_hash[:home][:players]\nend", "def show_players\n puts @cards.length\n @players.each do |player|\n puts \"Nombre: #{player.name}\"\n player.cards.each do |card|\n puts card.id\n end\n end\n end", "def player_stats(player_name)\n game_hash.each do |place, team|\n team[:players].each do |player|\n if player[:player_name] == player_name\n return player\n end\n end\n end\n end", "def player_stats(player_name)\n player_stats = {}\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if player_name == element[:player_name]\n player_stats = element\n end\n end\n end\n player_stats\nend", "def show_players\n puts \"#{@human_player.name} a #{@human_player.life_points} points de vies\"\n @enemies.each do |mechant|\n puts \"#{mechant.name} a #{mechant.life_points} points de vies\"\n end #end of \"\".each do\" that show mechant name and life points\n end", "def set_players\n @players = Player.where(account_id: params[:id]).order_by(match_id: :desc).page(params[:page]).per(20)\n end", "def all_player_status\n linebreak\n @players.each{ |p| puts p; linebreak; }\n puts \"Dealer showing #{@dealer.hand.public_show}\"\n linebreak\n end", "def std_player_names\n\t\tnames = []\n\t\tfor i in 1..Constants::MAX_PLAYERS\n\t\t\tnames << \"Player\" + i.to_s\n\t\tend\n\t\tnames\n\tend", "def index\n @players = @tournament.players\n end", "def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person]\n end\n end\n end\n end\n end\nend", "def player_stats(player_name)\n player_stats = []\n game_hash.each do |location, keys|\n keys[:players].each do |player_info|\n if player_info[:player_name] == player_name\n player_info.delete(:player_name)\n player_stats<< player_info\n end \n end\n end\n player_stats[0]\n #binding.pry\nend", "def set_players_ontable\r\n @players_on_table = []\r\n players_default = @app_settings[\"players\"]\r\n players_default.each do |hash_player|\r\n # add the defined player\r\n @players_on_table << PlayerOnGame.new(hash_player[:name], nil, hash_player[:type], 0)\r\n end\r\n end", "def index\n player = params[:player].present? ? params[:player] : nil\n @games = if player\n Game.joins(:players).where('players.id = ?', player)\n else\n Game.all\n end\n end", "def resolve()\n Player.all\n end", "def build_list_of_players\n [\n \"cliff\",\n \"anne\",\n \"harry\",\n \"sam\",\n \"devin\",\n \"ally\",\n \"bob\",\n \"jane\",\n \"jimmy\",\n \"dave\"\n ]\nend", "def name_all_players()\n set_name()\n set_other_name()\n end", "def all_games\r\n\t\t@all_games = @tournament.all_games\r\n\tend", "def initialize_players\n\n end", "def players\n players_in_signup = []\n player_ids = self.signups.map {|sign| sign.player_id}\n User.all.select do |user|\n if player_ids.any?(user.id)\n players_in_signup << user\n end\n end\n players_in_signup.uniq\n end" ]
[ "0.7240488", "0.7240488", "0.71385586", "0.70466274", "0.69507426", "0.6912053", "0.6904409", "0.68284094", "0.68257874", "0.68008536", "0.6763472", "0.6755358", "0.6740059", "0.6724501", "0.6724501", "0.67176425", "0.6696304", "0.66931415", "0.6682255", "0.6650541", "0.6632974", "0.6627242", "0.66257524", "0.6608156", "0.65997416", "0.65994227", "0.6584267", "0.65612257", "0.65466887", "0.65451026", "0.6522272", "0.6520018", "0.6519527", "0.651824", "0.6504723", "0.6490898", "0.64875454", "0.64836365", "0.6476436", "0.6475276", "0.6458978", "0.64123666", "0.6388549", "0.6387195", "0.6383725", "0.6379049", "0.6376411", "0.637047", "0.6367601", "0.6345458", "0.6326716", "0.631941", "0.63085175", "0.6298389", "0.62954175", "0.62954175", "0.62953573", "0.6294712", "0.6293745", "0.62934965", "0.6287992", "0.6269074", "0.62626874", "0.6255558", "0.62538964", "0.62498266", "0.62426883", "0.62411916", "0.62361443", "0.6227865", "0.62252676", "0.6213093", "0.6212358", "0.6212012", "0.6211667", "0.62102264", "0.62020856", "0.6202031", "0.6195075", "0.6183816", "0.6173538", "0.6169223", "0.6161467", "0.6159929", "0.61379695", "0.61309296", "0.6125925", "0.61250806", "0.6125067", "0.61192024", "0.61010593", "0.6100364", "0.60976535", "0.60945845", "0.60899186", "0.6075046", "0.60709363", "0.606945", "0.60613304", "0.6060028" ]
0.6823564
9
Returns the points scored by player
def num_points_scored (player_name) lookup_by_player(player_name)[:points]; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def points_scored_for_player(name,game)\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:points] if player_hash[:player_name] == name\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:points] if player_hash[:player_name] == name\n end\nend", "def num_points_scored(player)\n \n data = game_hash\n player_hash = players_stats(data)\n \n player_hash.each_pair do |name, player_stat|\n \n if name == player\n player_stat.each_pair do |player_key, player_value|\n if player_key == :points\n return player_value\n end\n end\n end\n \n end\n \n nil\nend", "def num_points_scored(player)\n game_hash.each_value do |team|\n team[:players].each do |name, player_data|\n if name == player\n points = player_data[:points]\n return points\n end\n end\n end\nend", "def num_points_scored(player_name)\n players = get_players\n \n found_player = find_player(players, player_name)\n \n # return that player's points\n found_player[:points]\nend", "def num_points_scored(player)\n game_hash.each do |location, team|\n team[:players].each do |name, stats|\n if name == player\n return stats[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\n points = nil\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n binding.pry\n if name == player_name\n points = team_data[:players][player_name][:points]\n end\n end\n end\n points\n end", "def num_points_scored(player_name)\n player_points = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if player_stats[:player_name] == player_name\n player_points = player_stats[:points]\n end\n end\n end\n player_points\nend", "def num_points_scored(player_name)\n game_hash.each do |side, team|\n team.each do |specs, info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |data_item, stats|\n if data_item == player_name\n return stats[:points]\n end\n end\n end\nend", "def num_points_scored (player_name)\n points_scored = nil\n\n game_hash.each do |team, team_information_hash|\n players_array = team_information_hash[:players]\n players_array.each do |player_information_hash|\n if player_information_hash[:player_name] == player_name\n points_scored = player_information_hash[:points]\n end\n end\n end\n points_scored\nend", "def num_points_scored(name)\n game_hash.each do |location, attributes|\n attributes[:players].each do |player, stats|\n if player == name\n return stats[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes|\n if attributes[:player_name] == player_name\n return attributes[:points]\n end\n end\n end\nend", "def num_points_scored(player_lookup) \n game_hash.each do |location, team_data|\n#return the number of points scored for that player\n team_data[:players].each do |player|\n if player[:player_name] == player_lookup\n return player[:points]\n end\n end\n end\nend", "def num_points_scored(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e[:points]\n end\n end\n end\nend", "def num_points_scored(playerName)\n player_stats(playerName)[:points]\nend", "def num_points_scored(player_name)\npoints_scored = 0\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player, stats|\n if player == player_name\n points_scored = stats[:points]\n end\n end\n end\n end\nend\npoints_scored\nend", "def num_points_scored(player_name)\n if !game_hash.keys.include?(:players)\n game_hash.each do |location, team_info|\n if team_info.keys.include?(:players)\n team_info.each do |attribute, quanity|\n if attribute == :players\n quanity.each do |name, stats|\n if name == player_name\n stats.each do |stat, quanity|\n if stat == :points\n return quanity\n end\n end\n end\n end\n end\n end\n end\n end\n end\nend", "def num_points_scored(player_name)\n\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n\n # SOLUTION 3\n # get a list of all the players\n # all_players = game_hash.values.collect do |team|\n # team[:players]\n # end.flatten\n\n # find the player whose name matches the argument 'player_name'\n # return that player's points\n # all_players.each do |player|\n # return player[:points] if player[:player_name] == player_name\n # end\nend", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\nend", "def num_points_scored(player_name)\n player = player_by_name(player_name)\n player.values[0][:points]\n end", "def num_points_scored(player_name)\n this_player = player_name\n game_hash.each do |team, team_data|\n team_data[:players].each do |player_name, player_data|\n if player_name == this_player\n return player_data[:points]\n #over thought it, got stuck too long.\n end\n end\n end\n end", "def num_points_scored(player_name)\n game_hash.each do |home_or_away, team_values|\n team_values[:players].each do |player|\n if player[:player_name] == player_name \n return player[:points]\n end\n end \n end \nend", "def num_points_scored(players_name)\n game_hash.each do |place, team|\n team.each do |attr, data|\n if attr == :players\n data.each do |player|\n if player[:player_name] == players_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(player_name)\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n return player[:points] if player.has_value?(player_name)\n end\n end\nend", "def points(name)\n \n consolidated_player_list = game_hash[:home][:players] + game_hash[:away][:players]\n consolidated_player_list\n player_stat_hash = {}\n\n consolidated_player_list.each do |player|\n key = player[:player_name]\n player_stat_hash[key] = player\n end\n\n points = 0\n player_stat_hash.each do |player|\n points = player[1][:points] if player[0] == name\n end\n points\nend", "def num_points_scored(name)\n players = get_all_players # Works!\n player = find_player(players, name) # Up next...\n player[:points]\n \nend", "def num_points_scored(name)\n ## Version 2.0 ##\n\n # 1. get all of the player hashes\n players = get_all_players\n # 2. get the player's data who matches the given name\n player_data = players[name]\n # 3. get the points from that data\n player_data[:points]\nend", "def num_points_scored(player_name)\n result = nil\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats[:points]\n end\n end\n end\n result\nend", "def num_points_scored(name)\n game_hash().each do |location, team_data|\n team_data[:players].each do |player_name, player_stat|\n if name == player_name\n return player_stat[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n if data.keys.include?(player_name)\n return data[player_name][:points]\n end\n end\n end\n end\nend", "def num_points_scored(name)\n # given an array of player data (hashes), find the one whose name matches\n # What is a player?\n\n ## iterate over the list of players\n ## Find the one whose `player_name` matches the name that we're looking for\n\n #binding.pry\n player = find_player(name)\n # find the number of points scored for that player\n #puts player[:points]\n player[:points]\nend", "def num_points_scored(player_name)\n game_hash.each do |location, keys|\n keys[:players].each do |player|\n return player[:points] if player[:player_name] == player_name\n end\n end\nend", "def num_points_scored(player_name)\n# we use .each do |team, random| to iterate over each piece of data to expose specific data, in this case number of points scored by each player, within the above hash\n# and we use symbols (with one object id) to take up less memory\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name, stats|\n if player_name == name\n return stats[:points]\n# then we want to return the number of points scored for each player if player_name is equal to the key of name\n\n end\n end\n end\n\nend", "def num_points_scored(player_name)\n player_points = nil\n \n game_hash.each do |location, team_data|\n team_data.each do |ind_data, attributes|\n if attributes.class == Hash \n if attributes.keys.include?(player_name)\n player_points = attributes[player_name][:points]\n end\n end\n end\n end\n player_points\nend", "def num_points_scored (name)\n points_scored = 0\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n\n players_array.each do | player_details_hash |\n\n if player_details_hash[:player_name] == name\n points_scored = player_details_hash[:points]\n end\n end\n end\n points_scored\nend", "def num_points_scored (searched_player)\n player_points = 0\n game_hash[:away][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n game_hash[:home][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n player_points\nend", "def num_points_scored(player_name)\n # if you were trying to explain this to someone in prework\n # who's stuck in hashketball, how would you explain how to do this?\n\n # find the num points scored as it relates to the name\n # we have all_players array\n # each value in all players has a smaller value that is the name of the player\n # that is also connected to the number of points they scored\n # find a way to sort the method / just find the value of points attributed to that name\n\n # hash of teams\n # visit each team\n # ask them for the player name list\n # check the list for the name\n # if i find it, then I have their points\n # I would return their points\n\n # argument pass in each player\n # try to return the amount of points associated with that player\n\n # pseudocode\n\n # i want all the players first <= simplify it ideally\n # home_players = game_hash[:home][:players]\n # away_players = game_hash[:away][:players]\n # all_players = home_players + away_players\n\n # so i can look through them\n # .each with an if\n # search, find, gofish\n # array of hashes\n # found_player = all_players.find do |player| # Hash\n # # find the player that matches the name\n # # binding.pry\n # # if player[:player_name] == player_name\n # # true\n # # else\n # # false\n # # end\n # player[:player_name] == player_name\n # end\n\n # get the points for that player\n found_player(player_name)[:points]\nend", "def num_points_scored(name)\n points = nil\n hash_of_players = {}\n game_hash.each do |location, elements|\n hash_of_players = elements[:players]\n hash_of_players.each do |player, stats|\n if player == name\n points = hash_of_players[player][:points]\n end\n end\n end\n points\nend", "def num_points_scored(player)\n game_hash.each do |location, team_data| #location returns away, team_data returns hash\n # binding.pry\n team_data.each do |attribute, data|\n # binding.pry\n if attribute == :players\n data.each do |player_name, categories|\n # binding.pry\n if player_name == player\n # binding.pry\n return categories[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(name)\n game_hash.each do |place, team|\n\n team.each do | atribute , data|\n \n if atribute == :players\n data.each do |player|\n # binding.pry\n if player[:player_name ] == name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(name)\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n ## Version 2.0 ##\n\n # 1. get all of the player hashes\n players = get_all_players\n # some imaginary method that will give us all the players from both teams\n\n # 2. get the player's data who matches the given name\n player_data = players[name]\n # since the keys are the player names, we can get the player's data\n # out of the hash by accessing it like this\n\n # 3. get the points from that data\n player_data[:points]\n # finally, with the player_data, we can grab out just the value we want\n # and return it (points)\nend", "def num_points_scored(player_name)\n return find_player_value(player_name, game_hash, :points)\nend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def num_points_scored(player_name)\n points_scored = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if player_name == element[:player_name]\n points_scored = element[:points]\n end\n end\n end\n points_scored\nend", "def num_points_scored(player_name)\ngame_hash.values.each do |team|\n team[:players].each do |player|\n return player[:points] if player.has_value?(player_name)\n end\n end\nend", "def num_points_scored(player_name)\n for location in game_hash.keys\n if(game_hash[location][:players][player_name])\n return game_hash[location][:players][player_name][:points]\n end\n end\n return \"Player not found\"\nend", "def num_points_scored(name)\n player_stats(name)[:points]\nend", "def num_points_scored(name)\n players = get_all_players\n find_player(players, name)[:points]\nend", "def num_points_scored(name)\n game_hash.each do |team, attributes|\n game_hash[team][:players].each do |player, stats|\n if name == player \n return game_hash[team][:players][name][:points]\n end\n end\n end\nend", "def num_points_scored(player)\n #iterate through game_hash to player_name\n game_hash.each do |team , team_dets|\n team_dets[:players].each do |dets|\n dets.each do |key, value|\n if dets[:player_name] == player\n return dets[:points]\n end\n end \n end\n end \nend", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\n\n nba_match\nend", "def num_points_scored(player_name)\n\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person][:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(name)\n game_hash.each do | team, team_data_hash |\n team_data_hash.each do | attribute, data |\n if attribute == :players\n data.each do | player, player_data_hash |\n if player == name\n return game_hash[team][attribute][player][:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(team_member)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n # if attribute == :players\n next unless attribute == :players\n data.each do |player|\n return player[:points] if player[:player_name] == team_member\n end\n end\n end\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend", "def score(player)\n @score[player]\n end", "def num_points_scored(player_name)\n scored_points = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.find do |player_index|\n if player_index[:player_name] == player_name\n scored_points = player_index[:points]\n end\n end\n end\n end\n end\n end\n scored_points\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def homeTeamPoints\n teamSelect(\"Brooklyn Nets\")[:players].collect do |name, stats|\n stats[:points]\n end\nend", "def score\n \n case @points\n when 0 \n @player_score[@points] = 'Love'\n return @player_score[@points]\n when 1 \n @player_score[@points] = 'Fifteen'\n return @player_score[@points]\n when 2 \n @player_score[@points] = 'Thirty'\n return @player_score[@points]\n when 3 \n @player_score[@points] = 'Forty'\n return @player_score[@points]\n else \n return @points \n end\n end", "def awayTeamPoints\n teamSelect(\"Charlotte Hornets\")[:players].collect do|name, stats|\n stats[:points]\n end\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def num_points_scored(player_name)\n # Hash # String #Symbol\n found_player(player_name)[:points] # Number\nend", "def num_points_scored(player_name)\n # Hash # String #Symbol\n found_player(player_name)[:points] # Number\nend", "def calculate_player_points\n # Sort the teams by points in descending order. This way, the output will\n # follow the teams' finishing order, which will be easier to read.\n @teams.sort_by(&:points).reverse_each do |team|\n puts \"Awarding #{team.points} points to #{team.name}: \" +\n @players[team.id].map(&:to_s).join(\", \")\n\n @players[team.id].each do |player|\n player.points = team.points\n end\n end\n end", "def num_points_scored(name)\n game_hash.each do |location, data|\n data.each do |key, value|\n if key == :players\n value.each do |person, data|\n if person == name\n data.each do |points, data|\n if points == :points\n return data\n end\n end\n end\n end\n end\n end\n end\nend", "def num_points_scored (name)\n gh=game_hash\n gh.each do |team, stats|\n stats[:players].each_key do |nameval|\n if (nameval==name)\n return gh[team][:players][nameval][:points]\n end\n end\n end\nend", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def player_stats(player_name)\n game_hash.each do |place, team|\n team[:players].each do |player|\n if player[:player_name] == player_name\n return player\n end\n end\n end\n end", "def num_points_scored(name)\n ## Version 1.0 ##\n\n # At the end of lecture, we did the following using .each:\n\n # look through all the players => get a list of players to look through\n game_hash.each do |team, team_data|\n # binding.pry\n # data[:players][\"Alan Anderson\"][:points]\n team_data[:players].each do |player_name, player_data|\n if player_name == name\n # Exit out of all loops by using return to exit out of this function.\n return player_data[:points]\n end\n end\n end\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def num_points_scored(name)\n answer = nil\n game_hash.each do |team_key,team_value|#iterate down one level\n players_stats = team_value[:players]#set the \"value\" for players to a variable\n players_stats.each do |players_details|\n if players_details[:name] == name #compares the value at \"key:name\" to the argument name\n answer = players_details[:points]#selects value at \"key:points\" to variable answer\n end\n end\n end\n answer\nend", "def num_points_scored (sportsman)\ngame_hash\nscores = 0\n game_hash.each do |team_position, team_data|\n team_data.each do | player_name, information|\n # binding.pry\n if player_name == :players \n information.each do |name, numbers|\n #binding.pry\n if name == sportsman \n numbers.each do |key, value|\n #binding.pry\n if key == :points\n #binding.pry\n return scores = value.to_i\n #binding.pry\n end\n end\n end\n end\n end\n end\n end \n #return scores\n end", "def points(game = nil)\n points = 0\n\n if game\n coeficient = Coeficient.find(game.coeficient_id)\n get_participation_by_game game do |participation|\n opponents = get_opponents(game)\n\n points = points_formula(\n coeficient.value,\n game.number_of_teams,\n participation.position,\n opponents\n )\n end\n else\n Participation.find_all_by_player_id(self.id).each do |participation|\n game = Game.find(participation.game_id)\n coeficient = Coeficient.find(game.coeficient_id)\n opponents = get_opponents(game)\n\n points = points_formula(\n coeficient.value,\n game.number_of_teams,\n participation.position,\n opponents\n )\n end\n end\n points\n end", "def player_score()\n\t\tparams.each do |name, guess| #recieves guess from form on guess.slim\n\t\t\tsession[:player].each do |z|\n\t\t\t\tif z.name == name\n\t\t\t\t\tz.guess = guess.to_i\n\t\t\t\t\tz.round_score = (z.guess - session[:movie][session[:round_count]].ratings['critics_score'].to_i).abs\n\t\t\t\t\tz.total_score += (z.guess - session[:movie][session[:round_count]].ratings['critics_score'].to_i).abs\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def player_stats(player)\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if name.to_s == player\n return stats\n end\n end\n end\nend", "def num_points_scored(string) \n game_hash.each do |hash, info|\n player_hash = info[:players] #this returns the key of players and the hash \n player_hash.each do |key, result|\n if(string == key[:player_name])\n return key[:points]\n #binding.pry\n \n end\n end\n\n end \nend", "def num_points_scored(name)\n players = get_all_players # Works!\n player = find_player(players, name) # Works!\n\n\n player[:points] # Does this work?\n # Test it and you'll see that it does!\nend", "def num_points_scored(name)\nplayers[name][:points]\nend", "def who_win\n @players.each do |player|\n result_sum = 0\n player.cards_wins.each do |cards|\n result_sum += cards.value.to_i\n end\n player.points = result_sum\n end\n players_win = @players.sort_by(&:points).reverse![0]\n puts 'GANADOR--------GANADOR---------GANADOR----'\n puts \"Nombre: #{players_win.name} || Puntos: #{players_win.points}\"\n #players_win.cards_wins.each do |cards|\n # puts cards.id\n #end\n @players.each do |player|\n puts ''\n puts player.name\n puts 'Cartas: '\n player.cards_wins.each do |cards|\n print \"#{cards.id}\"\n print ' || '\n end\n end\n end", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def num_points_scored(name)\n #1st level\n game_hash.each do |location, team_data|\n #2nd level\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player|\n player.each do |p_name, data|\n #data.each do |k,v|\n #binding.pry\n if data[:player_name] == name\n return data[:points]\n end\n end\n end\n end\n end\n end\nend", "def num_points_scored(name)\n # However, our data is different.\n\n # Given that we have :home and :away, each being a hash with a :players key\n # that is now an array of player hashes (name included), we cannot do this\n # anymore to get the matching player:\n # game_hash[:home][:players][name]\n\n\n # If you it out with binding.pry, you'll get this error:\n # TypeError: no implicit conversion of String into Integer\n # That's because game_hash[:home][:players] is an array and trying to use\n # [name] on it won't work as that would be how you try to access a value\n # in array based on it's position (name is a string, not an integer).\n\n\n # So what do we want to do here?\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n # Let's break it down into steps:\n # 1. get an array of all the players\n # 2. loop through that array and pick out the one whose name matches\n # 3. get the points for that player\n\n # Let's write out our ideal code for accomplishing this:\n players = get_all_players\n player = find_player(players, name)\n player[:points]\nend", "def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person]\n end\n end\n end\n end\n end\nend", "def player_stats(player_name)\n game_hash.each do |side, value|\n value[:players].each do |name, stats|\n\n if name == player_name\n return stats\n end\n\n end\n end\nend", "def display_points(some_points)\n puts (\"Total Points: #{@player_points}\")\n end", "def get_score()\n score = Hash.new(0)\n players.each {|player| score[player.name] = player.score}\n score\n end", "def total_point(team)\n team[:players].collect { |player| player[:points] }.sum\nend", "def num_points_scored(name)\n output = 0\n game_hash.each {|location, team_data| #do I need to use multiple 'collect's as I navigate down a nested hash? If not, does it mater which level I use 'collect on?'\n team_data.each {|attribute, data|\n if attribute == :players\n data.each {|player_name, stat_list|\n if player_name == name\n stat_list.each {|stats, values|\n if stats == :points\n output = values\n end\n }\n end\n }\n end\n }\n }\n output\nend", "def most_points_scored_helper\n point_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n point_array << element[:point]\n end\n end\n point_array.max\nend", "def goals_scored(player)\n\t\tself.positions.where(\"positions.player_id = ?\",player.id).joins(:goals).merge(Goal.scored_goal).count\n\tend", "def num_points_scored(name)\n points_scored = nil\n game_hash.each do |home_or_away, team_details|\n team_details[:players].each do |one_hash| # one_hash is an array\n one_hash.each do |key1,value1|\n if one_hash.has_value? (name)\n points_scored = one_hash[:points]\n end\n end\n end\n end\n points_scored\nend", "def player_points_by_game\n player = Player.find(params[:id])\n stats = Statline.where(player: player).order(date: :asc)\n data = Array.new\n labels = Array.new\n stats.each do |line|\n labels << line.opponent.name\n data << line.points\n end\n json = { data: data, labels: labels }\n\n render json: json\n end", "def points_per_player(player, hashketball)\r\n player.capitalize!\r\n if hashketball[:home][:players].include?(player)\r\n hashketball[:home][:players][player][:stats][:points]\r\n elsif hashketball[:away][:players].include?(player)\r\n hashketball[:away][:players][player][:stats][:points]\r\n else\r\n \"No player found.\"\r\n end\r\nend", "def most_points_scored\n most_points_scored_helper\n most_point_player = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n most_point_player = element[:player_name]\n binding.pry\n end\n end\n end\n most_point_player\nend", "def big_shoe_points\n big_shoes_guy = 0\n points = 0\n game_hash.each do | location, attributes|\n attributes[:players].each do |player, stats|\n if stats[:shoe] > big_shoes_guy\n big_shoes_guy = stats[:shoe]\n points = stats[:points]\n end\n end\n end\n points\nend", "def most_points_scored\nplayer_with_most(:points)\nend" ]
[ "0.76588863", "0.7641648", "0.75937146", "0.7571153", "0.75394684", "0.7532965", "0.7525876", "0.7478467", "0.74774414", "0.74760145", "0.74378204", "0.74357593", "0.74313986", "0.74286175", "0.7425263", "0.74205977", "0.74188447", "0.740702", "0.73789775", "0.73740506", "0.7358026", "0.7355731", "0.7351792", "0.7348248", "0.7344765", "0.73288447", "0.7327569", "0.7321396", "0.7315143", "0.7282946", "0.72436166", "0.7238947", "0.7236761", "0.72240824", "0.72222346", "0.721823", "0.72159654", "0.7205376", "0.71982175", "0.719595", "0.7195192", "0.7178411", "0.71550363", "0.71478736", "0.7136804", "0.71349275", "0.7133741", "0.7120723", "0.7109615", "0.7095806", "0.70829964", "0.70827085", "0.70823205", "0.7046692", "0.7029208", "0.7019075", "0.70182234", "0.70170915", "0.698204", "0.6971546", "0.6944264", "0.6894015", "0.6881205", "0.68681216", "0.68671876", "0.68671876", "0.6866345", "0.6858948", "0.684102", "0.6838881", "0.68361324", "0.68318856", "0.6803649", "0.677399", "0.67446923", "0.6742359", "0.6735555", "0.6720645", "0.67007893", "0.6697793", "0.66915333", "0.6683758", "0.66635114", "0.6623649", "0.66174024", "0.66099906", "0.6608942", "0.6584934", "0.657375", "0.6562753", "0.65619504", "0.65469044", "0.6542884", "0.65298307", "0.652745", "0.6507049", "0.65023214", "0.6491237", "0.64703363", "0.6463616" ]
0.73430866
25
Returns the shoe size of player
def shoe_size (player_name) lookup_by_player(player_name)[:shoe]; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shoe_size(playerName)\n player_stats(playerName)[:shoe]\nend", "def shoe_size(player_name)\n # get list of players\n players = get_players\n # find player with matching name\n found_player = find_player(players, player_name)\n # return player's shoe size\n found_player[:shoe]\nend", "def shoe_size(name)\n player_stats(name)[:shoe]\nend", "def shoe_size(player)\n shoe_size = 0\n game_hash[:home][:players].each do |player_name, player_info_hash|\n # player_name = home game player names string(key), player_info_hash = player_info_hash = :number, :shoe, :points, :rebounds, :assists, :steals, :blocks, :slam_dunks\n if player == player_name\n\t\t\tshoe_size = player_info_hash[:shoe]\n\t\tend\n\tend\n\tgame_hash[:away][:players].each do |player_name, player_info_hash|\n\t\tif player == player_name\n\t\t\tshoe_size = player_info_hash[:shoe]\n\t\tend\n\tend\n\tshoe_size\nend", "def shoe_size(player)\n\tshoe_size = nil\n\tmy_hash = game_hash\n\tmy_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, more_data|\n\t\t\tif attribute == :players\n\t\t\t\tmore_data.each do |person|\n\t\t\t\t\tperson.each do |name, stats|\n\t\t\t\t\t\tshoe_size = stats[:shoe] if name == player\n\t\t\t\t\tend\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend \n\tshoe_size\nend", "def shoe_size(player_name)\n game_hash.each do |location, team_data|\n\t\t#iterating over the first layer\n\tteam_data.each do |k, v|\n\t\t#iterating over the second layer\n\t\tif k == :players\n\t\t\tv.each do |x|\n\t\t\tif x[:player_name] == player_name\n\t\t\treturn x[:shoe]\n\t\t\tend\n\t\t end\n\t\tend\n\t end\n\tend\nend", "def shoe_size(name)\n players[name][:shoe]\nend", "def shoe_size (player_name)\n\n game_hash.each do |side, team|\n team.each do |specs, info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n return player[:shoe]\n end\n end\n end\n end\n end\nend", "def get_shoe_size\n return prompt_positive_integer(\"Number of decks at table? [#{Decks::MIN_DECKS}]\", Decks::MIN_DECKS)\n end", "def shoe_size(player_name)\n # Hash # String #Symbol\n found_player(player_name)[:shoe] # Number\nend", "def shoe_size(player_name)\n # Hash # String #Symbol\n found_player(player_name)[:shoe] # Number\nend", "def shoe_size(player_name)\n player_shoe_size = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if player_stats[:player_name] == player_name\n player_shoe_size = player_stats[:shoe]\n end\n end\n end\n player_shoe_size\nend", "def shoe_size(player_name)\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:shoe]\n end\n end\n end\nend", "def shoe_size(name)#exact same method as above, just switched :points to :shoe\n answer = nil\n game_hash.each do |team_key,team_value|#iterate down one level\n players_stats = team_value[:players]\n players_stats.each do |players_details|\n if players_details[:name] == name\n answer = players_details[:shoe]\n end\n end\n end\n answer\n end", "def shoe_size(name)\n game_hash.each do |location, attributes|\n attributes[:players].each do |player, stats|\n if player == name\n return stats[:shoe]\n end\n end\n end\nend", "def shoe_size(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e[:shoe]\n end\n end\n end\nend", "def shoe_size(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes|\n if attributes[:player_name] == player_name\n return attributes[:shoe]\n end\n end\n end\nend", "def shoe_size(player_name)\n for location in game_hash.keys\n if(game_hash[location][:players][player_name])\n return game_hash[location][:players][player_name][:shoe]\n end\n end\n return \"Player not found\"\nend", "def shoe_size(name)\n game_hash.each do |team, attributes|\n if game_hash[team][:players][name]\n return game_hash[team][:players][name][:shoe]\n end\n end\n end", "def shoe_size(player_name)\n result = nil\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats[:shoe]\n end\n end\n end\n result\nend", "def shoe_size(player_name)\n game_hash.values.each do |team|\n team[:players].each do |player|\n return player[:shoe] if player.has_value?(player_name)\n end\n end\nend", "def shoe_size (name=\"Jeff Adrien\")\n size = 0\n if(game_hash[:home][:players].keys.include?(name))\n size= game_hash[:home][:players][name][:shoe]\n elsif (game_hash[:away][:players].keys.include?(name))\n size = game_hash[:away][:players][name][:shoe]\n else\n size\n end\nend", "def shoe_size(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person][:shoe]\n end\n end\n end\n end\n end\nend", "def shoe_size(name)\n game_hash.each do |team, team_data|\n team_data[:players].each do |player_name, player_data|\n if player_name == name\n return player_data[:shoe]\n end\n end\n end\nend", "def shoe_size(name)\n game_hash.each do |place, team|\n team.each do |attribute, data|\n if attribute == :players\n data.each do |player|\n if name == player[:player_name] \n return player[:shoe] \n end\n end\n end\n end\n end\nend", "def shoe_size(name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |player_name, data|\n if player_name == name\n return data[:shoe]\n end\n end\n end\nend", "def shoe_size(name)\n # Thinking through the steps, it works the same way up until step 3 where\n # instead of trying to get :points, we want to get :shoe.\n # So the same exact line of code will work with a slight tweak:\n get_all_players[name][:shoe]\nend", "def shoe_size (player_name)\n shoe_answer = nil\n game_hash.each do |team, all_info_hash|\n players_array = all_info_hash[:players]\n players_array.each do |player_information_hash|\n if player_information_hash[:player_name] == player_name\n shoe_answer = player_information_hash[:shoe]\n end\n end\n end\n shoe_answer\nend", "def shoe_size(player_name)\n game_hash.each do |place, team|\n team.each do |attribute, data|\n if attribute == :players \n data.each do |player|\n if player[:player_name]== player_name\n return player[:shoe]\n end\n end\n end\n end\n end\nend", "def shoe_size(player_name)\n game_hash.each do |team, team_data|\n team_data[:players].each do |this_player, player_data|\n if player_name == this_player\n return player_data[:shoe]\n end\n end\n end\nend", "def shoe_size(name)\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n # 1. get an array of all the players\n # 2. loop through that array and pick out the one whose name matches\n # 3. get the shoe size for that player\n # Deja vu?\n # We can use the same exact methods to accomplish this task!\n\n\n players = get_all_players\n find_player(players, name)[:shoe] # :shoe is the only tweak we need\nend", "def get_shirt_size\n return @size\n end", "def shoe_size(player_name)\n shoe_size = \"\"\n\n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if player_name == element[:player_name]\n shoe_size = element[:shoe]\n end\n end\n end\n shoe_size\nend", "def shoe_size(player_name)\n player_shoe_size = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.find do |player_index|\n if player_index[:player_name] == player_name\n player_shoe_size = player_index[:shoe]\n end\n end\n end\n end\n end\n end\n player_shoe_size\nend", "def shoe_size(player_x)\n game_hash.each do |home_away, keys|\n keys[:players].each do |player|\n return player[:shoe] if player[:player_name] == player_x\n end\n end\nend", "def shoe_size(player_n)\n game_hash.each do |home_away, keys|\n keys[:players].each do |player|\n return player[:shoe] if player[:player_name] == player_n\n end\n end\nend", "def shoe_size(name)\n i = 0\n while i < player_data.length\n if player_data[i][:player_name] == name\n p player_data[i][:shoe]\n end\n i+=1\n end\nend", "def shoe_size(player_name)\n # using .each do |location, team_data| to iterate over each piece of data to expose specific data, in this case the team_players\n game_hash.each do |location, team_data|\n # goes through all of the players and then a name and its value\n team_data[:players].each do |name, data|\n # if the key \"name\" is equal to player_name then the value of shoe should be returned\n if name == player_name\n return data[:shoe]\n end\n end\n end\nend", "def big_shoe_rebounds\n player_biggest_shoe_size.fetch(:rebounds)\nend", "def shoe_size(player_name)\n # i want all the players first <= simplify it ideally\n # so i can look through them\n # find the player that matches the name\n\n\n # found_player = all_players.find do |player| # Hash\n # player[:player_name] == player_name\n # end\n\n # get the shoe size for that player\n found_player(player_name)[:shoe]\nend", "def shoe_size(player_name)\n # remember that \"find\" returns the first item that matches the conditional\n get_players.find { |player| player[:player_name] == player_name }[:shoe]\nend", "def shoe_size(name)\n answer = nil\n\n game_hash.each do |team, details_hash|\n # binding.pry\n players_array = details_hash[:players]\n players_array.each do |player, player_details_hash|\n #binding.pry\n if player == name\n answer = player_details_hash[:shoe]\n end\n end\n end\n answer.to_i\nend", "def player_shoe_size(player, hashketball)\r\n player.capitalize!\r\n if hashketball[:home][:players].include?(player)\r\n hashketball[:home][:players][player][:shoe_size]\r\n elsif hashketball[:away][:players].include?(player)\r\n hashketball[:away][:players][player][:shoe_size]\r\n else\r\n \"No player found.\"\r\n end\r\nend", "def shoe_size(player)\n out=\"no player\"\n x= game_hash[:home][:players]\n x.each do |playa|\n #this is where the players are listed and his stats\n out = playa[:shoe] if playa[:player_name]==player\n # playa.each do |key,value|\n # puts \"This is the key #{key} and this is the value #{value}\"\n # out=value if player=key\n # end\n end\n y= game_hash[:away][:players]\n y.each do |playa,stats|\n out = playa[:shoe] if playa[:player_name]==player\n end\n out\nend", "def size\n @players.size\n end", "def shoe_size(name)\n game_hash.collect do |key, value|\n value.collect do |key2, value2|\n if value2.include?(name)\n return game_hash[key][key2][name][:shoe]\n\n end\n end\n end\n\nend", "def input_shoe_size\n self.print_msg(\"input_shoe_size\")\n shoe_size = gets.chomp.to_i\n return shoe_size\n end", "def shoe_size(name)\n #third level\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n data.each do |item|\n if item.class == Hash\n item.each do |k, v|\n if k == name\n return item[k][:shoe]\n end\n end\n end\n end\n end\n end\nend", "def big_shoe_rebounds()\n shoe_size = 0\n result = 0\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:shoe] > shoe_size\n shoe_size = player[:shoe]\n result = player[:rebounds]\n\n end\n end\n end\n end\n end\n result\nend", "def real_piece_size\n piece_size + connector_size\n end", "def size\n SizableLocation.new(location).size\n end", "def shoe_size(name)\n shoe_size = nil\n game_hash.each do |home_or_away, team_details|\n team_details[:players].each do |one_hash| # one_hash is an array\n one_hash.each do |key1,value1|\n if one_hash.has_value? (name)\n shoe_size = one_hash[:shoe]\n end\n end\n end\n end\n shoe_size\nend", "def big_shoe_rebounds\n largest = 0\n player = \"\"\n game_hash.each do |location, team_data|\n team_data[:players].each do |k, v|\n if largest < shoe_size(k)\n largest = shoe_size(k)\n player = k\n end\n end\n end\n return player_stats(player)[:rebounds]\nend", "def size\n sku.size * amount\n end", "def big_shoe_rebounds\n biggest_shoe_size[:rebounds]\nend", "def big_shoe_rebounds\n biggest = 0\n rebounds = 0\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n size = player[:shoe]\n if size > biggest\n biggest = size\n rebounds = player[:rebounds]\n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds\n\tbiggest_shoes_player = nil\n\tshoe_size_tracker = 0\n\trebounds_stat = nil\n\tgame_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, more_data|\n\t\t\tif attribute == :players\n\t\t\t\tmore_data.each do |player|\n\t\t\t\t\tplayer.each do |name, stats|\n\t\t\t\t\t\tstats.each do |stat, val|\n\t\t\t\t\t\t\tif stat == :shoe\n\t\t\t\t\t\t\t\tif !biggest_shoes_player || val > shoe_size_tracker\n\t\t\t\t\t\t\t\t\tshoe_size_tracker = val\n\t\t\t\t\t\t\t\t\tbiggest_shoes_player = name\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\trebounds_stat = stats[:rebounds]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\trebounds_stat\nend", "def largest_shoes(game)\nmax_shoes = 0\nrebounds = 0\nmax_shoes_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:shoe_size] == max_shoes\n max_shoes_player = max_shoes_player + \" and #{player_contents[:player_name]}\"\n rebounds = player_contents[:rebounds]\n elsif player_contents[:shoe_size] > max_shoes\n max_shoes = player_contents[:shoe_size]\n max_shoes_player = player_contents[:player_name]\n rebounds = player_contents[:rebounds]\n end\n end\nend\nputs \"#{max_shoes_player} has size #{max_shoes} shoes and #{rebounds} rebounds\"\nend", "def biggest_shoe(hashketball)\r\n player_number_with_biggest_shoe = \"\"\r\n biggest_shoe_size = 0\r\n \r\n hashketball[:home][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n hashketball[:away][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n \r\n \" #{player_number_with_biggest_shoe} : #{biggest_shoe_size} \"\r\nend", "def big_shoe_rebounds\n hash = game_hash\n #first find largest shoe size\n max_size = 0\n hash.each do |location, team_data|\n\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] > max_size\n max_size = hash[location][:players][name][:shoe]\n end\n end\n end\n\n #then return the player's number of rebounds\n hash.each do |location, team_data|\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] == max_size\n return hash[location][:players][name][:rebounds]\n end\n end\n end\n\nend", "def big_shoe_rebounds\n biggest_shoe_size = 0\n player_rebounds = 0\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:shoe] > biggest_shoe_size\n biggest_shoe_size = e[:shoe]\n player_rebounds = e[:rebounds]\n end\n end\n end\n player_rebounds\nend", "def calculate_maximum_square_size width, height, margins\n # maximum width is trimmed by opponent's view width\n main_player_view_width = WINDOW_WIDTH - OPPONENT_VIEW_WIDTH\n maximum_width = main_player_view_width - margins[:x] * 2\n maximum_height = WINDOW_HEIGHT - margins[:y] - margins[:y_bottom]\n maximum_square_size_in_width = maximum_width / width\n maximum_square_size_in_height = maximum_height / height\n\n # get the smallest possible size to fit the 'viewable' screen\n best_square_size = maximum_square_size_in_width >= maximum_square_size_in_height ?\n maximum_square_size_in_height :\n maximum_square_size_in_width\n\n # readjust player's board to the center\n margins[:x] = (main_player_view_width - width * best_square_size).to_f / 2\n margins[:y] += (WINDOW_HEIGHT - margins[:y] - height * best_square_size) / 2\n\n # return new square size\n best_square_size\nend", "def big_shoe_rebounds\n shoe_size = 0\n rebounds = 0\n game_hash.each do | team, attributes |\n attributes[:players].each do | player_data | #array\n player_data.each do | player_name, detail |\n if detail[:shoe] > shoe_size\n\n shoe_size = detail[:shoe]\n rebounds = detail[:rebounds]\n end\n end\n end\n end\n rebounds\nend", "def product_size(product)\n size_attributes = %w[size coats jacket denim knits leather overcoats ties t_shirts scarves shirts]\n size = ''\n\n size_attributes.each do |attr|\n size += product.attribute_value(attr).to_s\n end\n\n return size\n end", "def size\n deck.size\n end", "def board_size\n\t\[email protected]\n\tend", "def num_squares\n self.size ** 2\n end", "def height\n size.first\n end", "def height\n size.first\n end", "def big_shoe_rebounds\n players[player_with_most(:shoe)][:rebounds]\nend", "def size\n\t\t@w * @h\n\tend", "def size\n Stal.solve(redis, [\"SCARD\", key])\n end", "def level_size level\n\t\t\t@unit_size * tile_size(level)\n\t\tend", "def size\n cards.size\n end", "def size\n @sizes ||= strip(:size)\n end", "def size\n width * height\n end", "def total_servingSize\n food.servingSize * quantity\n end", "def big_shoe_rebounds()\n\nshoe_size = 0\nrebounds = 0\n\ngame_hash.each do |team, team_stats|\n team_stats[:players].each do |stats|\n if stats[:shoe] > shoe_size\n shoe_size = stats[:shoe]\n rebounds = stats[:rebounds]\n end\n end\n end\nrebounds\nend", "def big_shoe_points\n big_shoes_guy = 0\n points = 0\n game_hash.each do | location, attributes|\n attributes[:players].each do |player, stats|\n if stats[:shoe] > big_shoes_guy\n big_shoes_guy = stats[:shoe]\n points = stats[:points]\n end\n end\n end\n points\nend", "def big_shoe_rebounds\n b_size =0\n rebounds = 0\n player = \"\"\n\n game_hash.each do |location, team_data|\n team_data[:players].each do |p_name, stats|\n if (stats[:shoe] > b_size)\n b_size = stats[:shoe]\n player = p_name.to_s\n rebounds = stats[:rebounds]\n end #if\n end #team_data\n end #game_hash\n rebounds\nend", "def size\n easy = Curl::Easy.new\n easy.url = self.uri + \"/size\"\n easy.http_get\n\n raise(SesameException.new(easy.body_str)) unless easy.response_code == 200\n\n easy.body_str.to_i\n end", "def snake_size(snake)\n return snake[:body].length\nend", "def big_shoe_rebounds\n biggestShoes[1][:rebounds]\nend", "def size\n @size \n end", "def size\n @size \n end", "def get_size\n\t\treturn @size\n\tend", "def cards_played_size \n a = @played\n a.delete_if { |key, value| value == nil }\n a.length\n end", "def size\n # returns the value of the instance var @size\n @size\n # end of size method\n end", "def size\n @size.size\n end", "def size\n (@x2-@x1)*(@y2-@y1)\n end", "def big_shoe_rebounds\n max_shoe = 0\n rebounds = 0\n player = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |name|\n if game_hash[location][:players][name][:shoe] > max_shoe\n max_shoe = game_hash[location][:players][name][:shoe]\n rebounds = game_hash[location][:players][name][:rebounds]\n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def size\n # return the value of the instance variable @size\n @size\n # end size method\n end", "def big_shoe_rebounds\n # Set two objects to equal integer values of 0 to be called/changed by the method\n biggest_shoe_size = 0\n number_of_rebounds = 0\n \n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes| # Calls the stats of each player within the :players array \n if attributes[:shoe] > biggest_shoe_size # Finds and calls the largest integer value in the shoe key\n biggest_shoe_size = attributes[:shoe] # Sets value for biggest_shoe_size to equal the shoe value\n number_of_rebounds = attributes[:rebounds] # Sets value for number_of_rebounds to equal the rebounds value\n end\n end\n end\n return number_of_rebounds\nend", "def big_shoe_rebounds\n # built an empty array called names\n names = []\n # built an empty array called shoe_sizes\n shoe_sizes = []\n # game_hash.each do |team, random| iterates over the hash\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name,stats|\n names.push(name)\n shoe_sizes.push(stats[:shoe])\n end\n end\n # finds the player with largest shoes size\n largest = -1\n shoe_sizes.each do |x|\n if x > largest\n largest = x\n end\n end\n\n # we want to add to player_with_largest the actual largest shoe size and we can do that by adding a key with an array as a value\n player_with_largest = names[shoe_sizes.index(largest)]\n\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name, stats|\n if player_with_largest == name\n return stats[:rebounds]\n # once we've found the player with the largest shoe size\n # we've returned that player's number of rebounds by first accessing their stats and then going into the value of rebounds\n\n end\n end\n end\nend", "def size size = nil\n @size = size.to_i if size\n @size\n end", "def compute_size(e)\n user_hash = user_hash(@message)\n mulligans = @redongs[user_hash]\n\n # Modify size by an increasing value - more redongs means more and more loss\n size_modifier = roll_penalty(mulligans)\n\n # Get size by using daily seed\n size = 0\n user_seed(user_hash, mulligans * 53) do\n # Is it MICROPENIS MONDAY?!?\n if Time.now.wday == 1\n size = [2, microdong_size + size_modifier].max\n else\n size = [2, fair_dong_size + size_modifier].max\n end\n end\n\n @size_data[user_hash] = {:size => size, :nick => @message.nick, :hash => user_hash}\n\n return size\nend", "def big_shoe_rebounds\n big_shoe = 0\n result = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n stats.each do |stat, value|\n if stat == :shoe\n if big_shoe < value \n result = stats[:rebounds]\n big_shoe = value\n end\n end\n end\n end\n end\n result\nend", "def playable_length\n playable.length\n end", "def size\n\t\t7500\n\tend" ]
[ "0.8393058", "0.82261133", "0.81985044", "0.8004811", "0.79156977", "0.78123903", "0.7766805", "0.77561945", "0.7749386", "0.7732825", "0.7732825", "0.76933897", "0.7691095", "0.7686871", "0.7661001", "0.762997", "0.7612224", "0.7545879", "0.75455153", "0.7531072", "0.75131357", "0.7491966", "0.7481552", "0.7471619", "0.74588704", "0.7444762", "0.7439476", "0.7422412", "0.74074644", "0.7352979", "0.72889036", "0.72447264", "0.72387165", "0.7207733", "0.7197268", "0.71395445", "0.710318", "0.7001783", "0.70011854", "0.6997511", "0.69878155", "0.6919278", "0.687907", "0.6828716", "0.6774545", "0.6748527", "0.6738219", "0.66522807", "0.65552735", "0.65072453", "0.6503526", "0.64746344", "0.6391584", "0.6374336", "0.63664705", "0.6357868", "0.6349788", "0.6343815", "0.63246816", "0.63188", "0.6285252", "0.62428373", "0.62413585", "0.6231841", "0.6231537", "0.6211649", "0.6191084", "0.61865747", "0.61865747", "0.6186019", "0.6184148", "0.6159065", "0.6155685", "0.6136747", "0.6135622", "0.6128848", "0.6119369", "0.61164343", "0.60996836", "0.6085876", "0.60844994", "0.6082759", "0.6072487", "0.60569245", "0.60569245", "0.6043617", "0.60291356", "0.6028935", "0.6015539", "0.6001915", "0.5984385", "0.5981523", "0.5979837", "0.59721446", "0.5968099", "0.59535474", "0.595266", "0.59432375", "0.59389096", "0.5925363" ]
0.8005754
3
Returns the colors of team
def team_colors (team_name) lookup_by_team(team_name)[:colors]; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_colors(team)\n game_hash.each do |side, value|\n if value[:team_name] == team\n return value[:colors]\n end\n end\n end", "def team_colors(team_name)\n\tright_team = nil\n\tgame_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, value|\n\t\t\tif attribute == :team_name && value == team_name\n\t\t\t\tright_team = home_or_away\n\t\t\tend\n\t\tend\n\tend\n\treturn game_hash[right_team][:colors]\nend", "def team_colors(team_name)\n game_hash.each do |location, team_data|\n\t\tif team_data[:team_name] == team_name\n\t\t\treturn team_data[:colors]\n\t\tend\n\tend\nend", "def get_colors( team )\r\n\t\tif @colors_hash.has_key?( team )\r\n\t\t\treturn @colors_hash[team]\r\n\t\telse\r\n\t\t\treturn DEFAULT_COLORS\r\n\t\tend\r\n\tend", "def team_colors(team_name)\n found_team = all_team_info(team_name)\n found_team[:colors]\nend", "def team_colors(teamName)\n teamSelect(teamName)[:colors]\n\n end", "def team_colors(team_name)\n # returns an array of team colors for team_name\n game_hash.each do |location, team_hash|\n team_hash.each do |team_keys, team_values|\n if team_hash[:team_name] == team_name && team_keys == :colors\n return team_values\n end\n end\n end\n end", "def team_colors(team_name)\n one_team_stats(team_name)[:colors]\nend", "def team_colors(team)\n \n data = game_hash\n teams = team_name_stats(data)\n \n teams.each_pair do |team_name, team_hash|\n if team_name == team\n team_hash.each_pair do |team_key, team_value|\n if team_key == :colors\n return team_value\n end\n end\n end\n end\n \n nil \nend", "def team_colors(team)\n game_hash.each do |location, attributes|\n if attributes[:team_name] == team\n return attributes[:colors]\n end\n end\nend", "def team_colors (team_name)\n colors = nil\n game_hash.each do |team, all_info_hash|\n if all_info_hash[:team_name] == team_name\n colors = all_info_hash[:colors].flatten\n end\n end\n colors\nend", "def team_colors(team)\n game_hash.each do |location, team_data|\n if team_data[:team_name] == team\n return team_data[:colors]\n end\n end\nend", "def team_colors(t_name)\n game_hash.collect do |key, value|\n value.collect do |key2, value2|\n\n if game_hash[key].values.include?(t_name)\n\n if key2 == :colors\n return value2\n end\n end\n end\n end\n end", "def team_colors(team_name)\n game_hash.each do |place, team|\n if team[:team_name] == team_name\n return team[:colors]\n end\n end\nend", "def team_colors(user_team_name)\n game_hash.each do |k, team|\n if team[:team_name] == user_team_name\n return team[:colors]\n end\n end\nend", "def team_colors(team_n)\n game_hash.each do |location, team_data|\n #binding.pry\n if (team_data[:team_name] == team_n)\n return team_data[:colors].split(\", \")\n end\n end\n return nil\nend", "def team_colors(team_name)\n \n game_hash.each do |team, attributes|\n attributes.each do |key, value|\n if value == team_name \n return game_hash[team][:colors]\n \n end\n end\n end\n \nend", "def team_colors(team_name)\n team_colors = nil\n game_hash.map do |team, team_stats|\n if team_stats[:team_name] == team_name\n team_colors = team_stats[:colors]\n end\n end\n team_colors\nend", "def team_colors(team_name, game)\n return game[:home_team][:team_colors] if game[:home_team][:team_name] == team_name\n return game[:away_team][:team_colors] if game[:away_team][:team_name] == team_name\nend", "def team_colors(team_name)\n colors = []\n #top level\n game_hash.each do |location, team_data|\n #1st (team name)\n if team_data[:team_name].join == team_name\n #2nd level\n team_data.each do |team_deets, values|\n #colors pair\n if team_deets == :colors\n colors << values\n end\n end\n end\n end\n colors = colors.flatten\nend", "def team_colors(name)\n game_hash.each do |location, team_data|\n if team_data[:team_name] == name\n return team_data[:colors]\n end\n end\nend", "def team_colors(arg_team_name)\n infoAboutAsingleTeam = find_a_single_team_based_on_name(arg_team_name)\n infoAboutASingleTeam[1][:colors]\n #the above is the implicit returnand find will always return an array of 2\n #and you can uise the index to find a color \n #if you dont know the index THEN its okay to write an if statement to check if its the index that you are at\n\n binding.pry\nend", "def team_colors(team_name)\n if team_name == \"Brooklyn Nets\"\n return game_hash[:home][:colors]\n else\n return game_hash[:away][:colors]\n end \nend", "def team_colors (team_name)\n answer = nil\n game_hash.collect do |team_key, team_value|\n if team_value[:team_name] == team_name\n answer = team_value[:colors]\n end\n end\n answer\nend", "def team_colors(team_name)\n team_colors =[]\n \n game_hash.each do |key, value|\n if team_name == value[:team_name]\n team_colors = value[:colors]\n end\n end\n team_colors\nend", "def team_colors(team_name)\n result = nil\n game_hash.each do |team, about|\n if about[:team_name] == team_name\n result = about[:colors]\n end\n end\n result\nend", "def team_colors(team_name)\n game_hash.each do |home_away, keys|\n if keys[:team_name] == team_name\n return keys[:colors].map(&:capitalize)\n end\n end\nend", "def team_colors(team_name)\n game_hash.each do |home_away, keys|\n if keys[:team_name] == team_name\n return keys[:colors].map(&:capitalize)\n end\n end\nend", "def team_colors(team_name)\n game_hash.each do |location, team_data|\n if team_data[:team_name] == team_name\n return team_data[:colors].to_a \n end\n end\nend", "def team_colors(name_of_team)\n # using .each do |team, random| game_hash[team].each do |name, random| to iterate over each piece of data\n # then, if the name_of_team is equal to random, we'll get a return value of the colors of each team.\n game_hash.each do |team, random|\n game_hash[team].each do |name, random|\n if name_of_team == random\n return game_hash[team][:colors]\n end\n end\n end\nend", "def team_colors(team_name)\n team_color = []\n game_hash.find do |team,info|\n if info[:team_name] == team_name\n team_color = info[:colors]\n end\n info[:team_name] == team_name\n end\n team_color\nend", "def team_colors(team_name)\n game_hash.keys.each do |location|\n return game_hash[location][:colors] if game_hash[location][:team_name] == team_name\n end\nend", "def team_colors(team)\n # PREVIOUS SOLUTION\n # if game_hash[:home][:team_name] == team\n\t# \tteam_colors = game_hash[:home][:colors]\n\t# elsif game_hash[:away][:team_name] == team\n\t# \tteam_colors = game_hash[:away][:colors]\n\t# end\n game_hash.each do |location, team_info_hash|\n # location = :home,:away; players_hash = :team_name, :colors, :players\n return team_info_hash[:colors] if team_info_hash[:team_name] == team\n end\nend", "def team_colors(team_name)\n if team_name == \"Brooklyn Nets\"\n game_hash[:home][:colors]\n else\n game_hash[:away][:colors]\n end\nend", "def colors\n @colors\n end", "def red_team\n teams[2]\n end", "def team_name\n\t\tcolor + \" \" + number.to_s\n\tend", "def possible_colors\n %w(R G B Y)\n end", "def team_colors(team_name)\n (game_hash[:home][:team_name] == team_name.to_s) ? team = :home : team = :away\n game_hash[team][:colors]\nend", "def colors\n color1 = UIColor.colorWithWhite(1.0, alpha: 0.2).CGColor\n color2 = UIColor.colorWithWhite(1.0, alpha: 0.1).CGColor\n color3 = UIColor.clearColor().CGColor\n color4 = UIColor.colorWithWhite(0.0, alpha: 0.1).CGColor\n \n [color1, color2, color3, color4]\n end", "def team_colors (team)\n cala=[]\n game_hash.each do|status,information|\n # puts status[0]\n cala=information[:colors] if information[:team_name]==team\n # information.each do |cata,subinfo|\n # puts :team_name[subinfo] if cata==:colors\n # end\n end\n cala\nend", "def team_colors(team, hashketball)\r\n sym = team.to_sym\r\n if hashketball.include?(sym)\r\n hashketball[sym][:colors]\r\n else\r\n \"Try home or away.\"\r\n end\r\nend", "def colors() = @colors ||= %i[blue green purple magenta cyan yellow red]", "def blue_team\n teams[1]\n end", "def teams\n # find all my TeamColor relationship information\n # my_team_colors = TeamColor.all.select do |team_color|\n # team_color.color == self\n # end\n # from those relations, grab out the teams\n # Array of TeamColor instances\n self.team_colors.map do |team_color|\n team_color.team\n end\n # Array of Team instances\n end", "def get_col_colors\n col_colors = Hash.new \n col_colors[:throwing] = '#ccffff'\n col_colors[:hitting] = '#ffcccc'\n col_colors[:running] = '#ccccff'\n col_colors[:fielding] = '#ccffcc'\n col_colors[:none] = '#eeeeee'\n col_colors[:fundamentals] = '#C1C1C0'\n col_colors[:experience] = '#969696'\n col_colors\n end", "def colorNames\n colors = [\"red\", \"orange\", \"yellow\", \"green\", \"mint\", \"navy\", \"light blue\", \"lavender\", \"plum\", \"pink\"]; \n return colors;\n end", "def list_colors\n color_string = \"\\nThe available colors are \"\n COLORS.each_with_index do |color, index|\n if index%2 == 0\n color_string += \"\\n\"\n end\n color_string += color + \" \"\n end\n puts color_string\n end", "def std_player_colours\n\t\t[Gosu::Color::RED,\n\t\tGosu::Color::YELLOW,\n\t\tGosu::Color::GREEN,\n\t\tGosu::Color::FUCHSIA]\n\tend", "def colors; end", "def getcolors(gridrow)\n AnsiColor.block(usecolor) do\n return normal, normal\n end\n end", "def colors\n return\n end", "def colors\n color_codes.keys\n end", "def get_board_colors(game)\n board_colors = {}\n [1,2,3,4,5,6,7,8,9,10,11,12].each do |num|\n ['A','B','C','D','E','F', 'G','H','I'].each do |letter|\n cell = (num.to_s + letter)\n board_colors[cell] = 'none'\n end\n end \n \n placed_tiles = game.game_tiles.where(placed: true)\n placed_tiles.each do |game_tile|\n hotel = game_tile.hotel\n color = game.get_hotel_color(hotel)\n board_colors[game_tile.cell] = color\n end\n\n board_colors\n end", "def colors\n keys = []\n COLORS.each_key do |key|\n keys << key\n end\n keys\n end", "def teams\n return ['FFA (Free For All)'] if ffa?\n\n teams = []\n @doc.css('map teams').xpath('./team').each do |t|\n name = localized_sting(t.text)\n min = t.attr('min')\n max = t.attr('max')\n teams << \"<h3 style='color: #{color_to_html(t.attr('color'))}'>#{name} <small style='color: black'>(#{min} - #{max} players)</small></h3>\"\n end\n teams\n end", "def team_colors(teamname)\nif game_hash[:home][:team_name] == teamname\n #returns the arrar if team_name matches teamname\n game_hash[:home][:colors]\nelsif game_hash[:away][:team_name] == teamname\n game_hash[:away][:colors]\nend\nend", "def colors\n @colors ||= parse_colors(color_properties)\n end", "def colors\n keys = []\n COLORS.each_key do | key |\n keys << key\n end\n keys\n end", "def rgb_color\n [self.color_red, self.color_green, self.color_blue]\n end", "def visionColors\n @colors = @json[\"responses\"][0][\"imagePropertiesAnnotation\"][\"dominantColors\"][\"colors\"]\n @color_rgb = []\n @color_scores = []\n\n @colors.each do |color|\n @color_rgb << color[\"color\"]\n @color_scores << color[\"score\"] * 100\n end\n\n # Find aggregare value of color scores and stretch to 100 if necessary\n color_percent = 0\n @color_scores.each { |a| color_percent+=a }\n if color_percent < 100 \n percent_diff = (100 - color_percent)\n @color_scores.map do |score|\n score = (score + (percent_diff/10))\n end\n end\n end", "def team_neighbors(v)\n Set.new neighbors(v).select { |p| p.color == v.color }\n end", "def teams\n return [og, oo, cg, co];\n end", "def display\n board.flatten.map { |stone| stone&.color }\n end", "def product_colors(product)\n return product.color.split(',').map(&:to_s)\n end", "def color\n fetch('vehicle.colors')\n end", "def colors\n Outpost::Config.instance.colors\n end", "def colors\n colors = []\n @lines.each do |line|\n color = line.scan(/\\d{1,3},\\d{1,3},\\d{1,3}/).first\n next if color.blank?\n color = color.split(',')\n colors << rgb(color[0].to_i, color[1].to_i, color[2].to_i)\n end\n colors\n end", "def crisis_color\n return text_color(17)\n end", "def users_for_team(color)\n team = team_by_color(color)\n team ? team.users : nil\n end", "def colorsPrimary\n @color_rgb_strings_primary = []\n @color_rgb.each do |rgb|\n r = rgb[\"red\"]\n g = rgb[\"green\"]\n b = rgb[\"blue\"]\n @color_rgb_strings_primary << \"rgb(#{r},#{g},#{b})\"\n end\n end", "def team_pieces(color)\n \tteam_spaces = []\n \t(0..7).each do |x|\n \t\t(0..7).each do |y|\n \t\t\tteam_spaces << @board[x][y] if @board[x][y].piece != nil && @board[x][y].piece.color == color\n \t\tend\n \tend\n \tteam_spaces.flatten\n end", "def colors\n @colors ||= Fotolia::Colors.new(self)\n end", "def colors\n @wmiiconfig.read(\"/bar/#{@name}/colors\").split(/\\s+/).map do |txt|\n txt.scan(/[a-fA-F0-9]{2}/).map{|hex| hex.to_i(16)}\n end\n end", "def get_red_scala n\n colors = []\n r = 255; g = 0; b = 0\n max = 255\n\n # se inicia la escala con el r mas fuerte y se añade g y b por igual cantidad hasta llegar al blanco\n for i in 1..n\n g = b = (i*(max/n)).round\n colors << rgb(r, g, b)\n end\n\n #se entrega la escala de blanco a rojo\n colors.reverse\n end", "def crisis_color\n return Color.new(255, 255, 64)\n end", "def color\n fetch('creature.bird.colors')\n end", "def computer_color\n\t valid_colors = [\"r\", \"y\", \"b\", \"w\", \"c\", \"g\"] \n\t return [valid_colors[rand(0..5)],valid_colors[rand(0..5)], valid_colors[rand(0..5)], valid_colors[rand(0..5)]]\n\tend", "def each_team\n players = @game.players.shuffle\n\n blue = players.pop(@limit / 2)\n red = players\n\n yield blue, red\n end", "def values\n [@red, @green, @blue]\n end", "def tanks_on_team(color)\n if color == @my_color\n @map.mytanks.select{ |t| t.status == \"normal\" }\n else\n @map.othertanks.select{ |t| t.color == color && t.status == \"normal\" }\n end\n end", "def color\n @colors[WaterManager.first.scheduling_option]\n end", "def stopped_failed_colors\n { :light => \"F5D9C9\".to_color, :medium => \"F2F2E9\".to_color, :strong => \"AF3A00\".to_color }\n end", "def tutu_color\n\t @tutu_color\n\tend", "def get_color\n @color\n end", "def color_map\n {\n 'high_risk_ice_check_in' => '#800080',\n 'friend_in_detention' => '#e83737',\n }\n end", "def scan_for_colors; end", "def print_colors\n 1.upto(@board.number_of_pegs) { |i| print \"#{i} = \" + \" \".color(COLORS[i]) + \" \" }\n print \": \"\n end", "def colors\n hex_values = @lines.map { |line| line[/#([0-9A-F]{6})/, 1] }.compact\n hex_values.map { |hex| Colour::RGB.from_html(hex) }\n end", "def teams\n return [away_team, home_team].compact\n end", "def palette_rgb_color\n [self.palette_red, self.palette_green, self.palette_blue]\n end", "def html_colors(total)\n all_colors = [\"FF0000\", \"00FF00\", \"0000FF\", \"00FFFF\", \"FF00FF\", \"FFFF00\", \"000000\"]\n #return [] if total > all_colors.length\n return Array.new(total){|i| all_colors[i]}\n end", "def color\n return @color\n end", "def color\n return @color\n end", "def get_colour(temps)\n\tcolours = []\n\ttemps.each do |temp|\n\t\tif temp <= 15\n\t\t\tcolours << :blue\n\t\telsif temp <= 28\n\t\t\tcolours << :green\n\t\telsif temp >= 29\n\t\t\tcolours << :red\n\t\tend\n\tend\n\tcolours\nend", "def get_color\n if @thread\n return CYCLING\n end\n\n pins = COLORS.select do |pin|\n get_pin pin\n end\n\n if pins.length == 0\n return nil\n elsif pins.length == 1\n return pins.first\n else\n return INVALID_STATE\n end\n end", "def yellow\n colorize(33)\n end", "def assign_game_color count\n case count\n when 0\n return \"transparent\"\n when 6\n return $app_red\n else\n return $app_blue\n end\n end", "def split_colors\n array = []\n remainder = @sha.split('') # Yes, it's not the remainder now, but it will be at the return statement.\n 6.times { array << remainder.slice!(0, 6).to_s }\n return array, remainder.to_s\n end", "def users_for_team(color_id)\n team = team_by_color(color_id)\n team ? team.users : nil\n end" ]
[ "0.8617856", "0.8287963", "0.82117283", "0.8207186", "0.8194202", "0.81297433", "0.81168866", "0.8067711", "0.7919048", "0.7795626", "0.77830756", "0.7726006", "0.7672502", "0.7670836", "0.76211226", "0.76201755", "0.7611461", "0.76041406", "0.7576709", "0.7531364", "0.7514059", "0.7429183", "0.74098843", "0.7367495", "0.734699", "0.733268", "0.73242694", "0.73242694", "0.7261936", "0.72080624", "0.72034407", "0.71713954", "0.70692676", "0.7065913", "0.6956021", "0.6904268", "0.6872113", "0.68635607", "0.68453836", "0.6820821", "0.6797117", "0.6774427", "0.6765458", "0.6733531", "0.6689783", "0.6681642", "0.6680523", "0.6679606", "0.66064596", "0.65647566", "0.6498507", "0.6497324", "0.64861786", "0.64167976", "0.6410531", "0.641029", "0.63926864", "0.63920826", "0.6390276", "0.6389601", "0.63289595", "0.63026077", "0.62833506", "0.6270703", "0.6264617", "0.6220968", "0.6216581", "0.6141562", "0.6138623", "0.61260736", "0.6125025", "0.61217695", "0.6114689", "0.6102115", "0.61003494", "0.6093593", "0.6090951", "0.6080862", "0.6064787", "0.605885", "0.6056798", "0.60235417", "0.60154593", "0.5995556", "0.59873086", "0.59774643", "0.59759647", "0.5968568", "0.5951411", "0.5916296", "0.5915298", "0.5915143", "0.58884436", "0.58884436", "0.58883315", "0.5885364", "0.5885289", "0.58840317", "0.58744997", "0.58744055" ]
0.7780917
11
Returns both team names. Not dynamic, but does it need to be? Teams are always home and away, could be adapted into another method for tournaments
def team_names [ game_hash.dig(:home, :team_name), game_hash.dig(:away, :team_name) ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_names\n game = Game.find(self.game_id)\n type = self.bet_type\n if over_under?\n return \"#{game.away_team} vs #{game.home_team}\"\n elsif type == \"lay\"\n if game.spread <= 0\n return game.home_team\n else\n return game.away_team\n end\n else\n if game.spread <= 0\n return game.away_team\n else\n return game.home_team\n end\n end\n end", "def team_names\n teams = []\n teams << game_hash[:home][:team_name]\n teams << game_hash[:away][:team_name]\n return teams\nend", "def both_team_names(game)\n both_teams = []\n both_teams << game[:home_team][:team_name]\n both_teams << game[:away_team][:team_name]\n both_teams\nend", "def matchname\n \"#{self.date}: #{self.hometeam.name} V #{self.awayteam.name}\"\n end", "def away_team_name\n return away_team.try(:name)\n end", "def get_team_name\n team ? team.get_full_name : '?'\n end", "def get_team_name\n team ? team.get_full_name : '?'\n end", "def get_team_name\n team ? team.get_full_name : '?'\n end", "def get_team_name\n team ? team.get_full_name : '?'\n end", "def home_team_name\n return home_team.try(:name)\n end", "def battingteam\n if (hometeambatted == true)\n \"#{match.hometeam.name}\"\n else\n \"#{match.awayteam.name}\"\n end\n end", "def team_name\n return @team_name\n end", "def team_by_name(team_name)\n game_hash[:home].has_value?(team_name) ? game_hash[:home] : game_hash[:away]\n end", "def team_names\n team_names = []\n game_hash.each do |home_or_away, team_stats|\n team_names << team_stats[:team_name]\n end\n team_names\nend", "def team_names\n game_hash.collect {|home_or_away, stats| team_name = stats[:team_name].to_s}\nend", "def team_names\n teams = []\n teams << game_hash[:home][:team_name] << game_hash[:away][:team_name]\nend", "def team_name\n self.team == nil ? \"\" : self.team.name\n end", "def teams\n return [away_team, home_team].compact\n end", "def get_team_name\n team ? team.get_full_name : (data_import_team ? data_import_team.get_full_name : '?')\n end", "def team_names\n data = game_hash\n all_teams = []\n \n data.each_pair do |home_away, home_away_hash|\n home_away_hash.each_pair do |team_key, team_value|\n \n if team_key == :team_name\n all_teams << team_value\n end\n \n end\n end\n all_teams\nend", "def team_names(hashketball)\r\n puts \"The #{hashketball[:home][:team_name]} welcome the #{hashketball[:away][:team_name]}\"\r\n puts \r\nend", "def team_name\n client.team.name\n end", "def name_for_team\n self.user.show_name rescue ''\n end", "def team_names\n names = []\n game_hash.each do | team, attributes|\n names << game_hash[team][:team_name]\n end\n return names\nend", "def game_title\n\t\t\"#{home_team} vs. #{visitor_team}\"\n\tend", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def team\n return self[:team] if self[:team].is_a? Team\n team = if self[:team].split('-').count > 2 or self[:team].to_i > 0 or self.sport.name == 'FWC'\n Team.where(:stats_id => self[:team])\n else\n Team.where(:abbrev => self[:team])\n end\n team.first\n end", "def team_names\n game_hash.map do |place, team|\n team[:team_name]\n end\nend", "def team_names\n fin_arr = []\n fin_arr << game_hash[:home][:team_name]\n fin_arr << game_hash[:away][:team_name]\n fin_arr\nend", "def team_names\n team_name = []\n game_hash.each do |team,info|\n team_name << info[:team_name]\n end\n team_name\nend", "def all_players_for_a_team(team_name, game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:home_team][:team_name] == team_name\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:away_team][:team_name] == team_name\n end\n player_names\nend", "def team_names()\n result = []\n game_hash.each do |side,team|\n result.push(team[:team_name])\n end\n result\nend", "def teams\n return [og, oo, cg, co];\n end", "def innings_name\n \"#{match.matchname}: Batting team: #{self.battingteam}\"\n end", "def team_names\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_names\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def teamName _args\n \"teamName _args;\" \n end", "def team_names\n game_hash.map do |team, team_stats|\n team_stats[:team_name]\n end\nend", "def team_names\n new_array = []\n new_array<< game_hash[:home][:team_name]\n new_array<< game_hash[:away][:team_name]\n return new_array\nend", "def team_names\n team = []\n game_hash.values.each do |team_info|\n team << team_info[:team_name]\n end\n team\nend", "def team_name(location, use_alt: false)\n validate_param(location, SYMBOLS_LRGBWL)\n\n case location\n when :left, :right\n team = get_team(location)\n\n if use_alt\n return team&.alt_name || team&.name\n else\n return team&.name\n end\n when :gold\n return tournament.gold_on_left ? team_name(:left, use_alt: use_alt) :\n team_name(:right, use_alt: use_alt)\n when :blue\n return tournament.gold_on_left ? team_name(:right, use_alt: use_alt) :\n team_name(:left, use_alt: use_alt)\n when :winner\n return nil if !complete?\n return team_won?(:left) ? team_name(:left, use_alt: use_alt) :\n team_name(:right, use_alt: use_alt)\n when :loser\n return nil if !complete?\n return team_won?(:left) ? team_name(:right, use_alt: use_alt) :\n team_name(:left, use_alt: use_alt)\n end\n end", "def name_for_user\n self.team.name rescue ''\n end", "def scrap_team_names_helper(team_element)\n if team_element.key?('title') &&\n team_element['title'].match?(/^[a-záàâãéèêíïóôõöúç\\s]+ - [a-z]{2}$/i)\n\n # Extract team's name (e.g Santos - SP => Santos)\n team_element['title'][/^[a-záàâãéèêíïóôõöúç\\s]{3,50}/i].strip\n end\n end", "def team_names\n team_names = []\n for location in game_hash.keys\n team_names.push(game_hash[location][:team_name])\n end\n return team_names\nend", "def team_names\n output =[]\n game_hash.each do |location, team_data|\n output.push(team_data[:team_name])\n end\n output\nend", "def team_names\n team_names = []\n #top level\n game_hash.each do |location, team_data|\n #2nd level\n team_data.each do |team_deets, values|\n #find team name pair\n if team_deets == :team_name\n team_names << team_data[team_deets]\n end\n end\n end\n team_names = team_names.flatten\nend", "def team_name\n\t\tcolor + \" \" + number.to_s\n\tend", "def team_names\n game_hash.collect do |team_key, team_value|\n team_value[:team_name]\n end\nend", "def team_names\n game_hash.collect do |team, all_info_hash|\n all_info_hash[:team_name]\n end\nend", "def team_names\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def teams\n return ['FFA (Free For All)'] if ffa?\n\n teams = []\n @doc.css('map teams').xpath('./team').each do |t|\n name = localized_sting(t.text)\n min = t.attr('min')\n max = t.attr('max')\n teams << \"<h3 style='color: #{color_to_html(t.attr('color'))}'>#{name} <small style='color: black'>(#{min} - #{max} players)</small></h3>\"\n end\n teams\n end", "def team_names\n names = []\n game_hash.each do |location, data|\n names << data[:team_name]\n end\n names\nend", "def team_names\n teams.collect do|key|\n key[:team_name]\n end\nend", "def names_from_context\n search = [team_name_from_channel_name] + team_names_from_roles\n\n (search + [bot.config.dig(server.id, 'default_team')]).compact\n end", "def team_names\n names = []\n game_hash.each do |k, team|\n names.push(team[:team_name])\n end\n names\nend", "def return_official_team_name(entry)\n\t\tcase entry \n\n\n\n\t\t\twhen /^au|^oo/\n\t\t\t\t\"austria\"\n\t\t\twhen /^be/\n\t\t\t\t\"belgium\"\n\t\t\twhen /^ch|^cz|^tj|^ts/\n\t\t\t\t\"chech republic\"\n\t\t\twhen /^cr|^kr/\n\t\t\t\t\"croatia\"\n\t\t\twhen /^de/\n\t\t\t\t\"denmark\"\n\t\t\twhen /^en/\n\t\t\t\t\"england\"\n\t\t\twhen /^fi/\n\t\t\t\t\"finland\"\n\t\t\twhen /^fr/\n\t\t\t\t\"france\"\n\t\t\twhen /^du|^ge/\n\t\t\t\t\"germany\"\n\t\t\twhen /^ho/\n\t\t\t\t\"hongarije\"\n\t\t\twhen /^it/\n\t\t\t\t\"italy\"\n\t\t\twhen /^ma/\n\t\t\t\t\"macedonie\"\n\t\t\twhen /^ne/\n\t\t\t\t\"netherlands\"\n\t\t\twhen /^pol/\n\t\t\t\t\"poland\"\n\t\t\twhen /^por|pot/\n\t\t\t\t\"portugal\"\n\t\t\twhen /^ru/\n\t\t\t\t\"russia\"\n\t\t\twhen /^sc/\n\t\t\t\t\"schotland\"\n\t\t\twhen /^sl/\n\t\t\t\t\"slowakije\"\n\t\t\twhen /^sp/\n\t\t\t\t\"spain\"\n\t\t\twhen /^swe|^zwe/\n\t\t\t\t\"sweden\"\n\t\t\twhen /^swi|^zwi/\n\t\t\t\t\"switzerland\"\n\t\t\twhen /^tu/\n\t\t\t\t\"turkey\"\n\t\t\twhen /^oe|^uk/\n\t\t\t\t\"ukraine\"\n\t\t\twhen /^wa/\n\t\t\t\t\"wales\"\n\n\t\tend\n\tend", "def formatted_past_teams\n self.past_teams.map { |team| team.name } * \", \"\n end", "def to_s\n return \"#{away_team_name} #{away_goals_count}-#{home_goals_count} #{home_team_name}\"\n end", "def blue_team\n teams[1]\n end", "def team_names\n hash = game_hash\n array = []\n hash.each do |location, attributes|\n attributes.each do |attribute, info|\n if attribute == :team_name\n array << info\n end\n end\n end\n return array\nend", "def team_names\n arrayOfTeamNames = [] #initialize new hash\n arrayOfTeamNames << game_hash[:home][:team_name]\n arrayOfTeamNames << game_hash[:away][:team_name] #shovel it with the data\nend", "def getAllTeamNames\n return TestSuite.find_by_sql(\"select DISTINCT teamname from test_suite\");\n end", "def team_names\n game_hash.collect do |location, attributes|\n attributes[:team_name]\n end\nend", "def team_names\n\tnew_hash = game_hash\n\tnew_hash.map{|key, value| new_hash[key][:team_name]}\nend", "def get_teams\n res = Array.new\n\n @games.each do |g|\n #check if home team is in the result array\n if !res.include?(g.home_team)\n res.push(g.home_team)\n end\n\n #check if away team is in the result array\n if !res.include?(g.away_team)\n res.push(g.away_team)\n end\n end\n\n return res\n end", "def teams \n \"teams\" \n end", "def teams\n return @teams if @teams\n\n @teams ||= @team_abbreviation.split(\", \").map do |team_abbreviation|\n Team.new(team_abbreviation, season: @season)\n end\n\n end", "def printTeams(teamArray)\n\t\tprintWords = \"\"\n\t\tteamArray.each do |team|\n\t\t\tprintWords << \"Team Name: #{team.name} Email: #{team.email} Lottery Balls: #{team.balls}\\n\"\n\t\tend\n\t\treturn printWords\n\tend", "def team_names\n # built an empty array called teams\n teams = []\n # game_hash.each do |team, random| iterates over the hash to return all of the team_names\n game_hash.each do |team, random|\n teams.push(game_hash[team][:team_name])\n end\n return teams\nend", "def red_team\n teams[2]\n end", "def team_information(input)\r\n index = input - 1\r\n url = 'https://www.balldontlie.io/api/v1/teams'\r\n response = self.call_api(url)[\"data\"][index]\r\n @chosen_team_full_name = response[\"full_name\"]\r\n @chosen_team_nickname = @chosen_team_fullname.split(\" \").last\r\n\r\n # puts \"You've selected the #{response[\"full_name\"]}, from the #{response[\"division\"]} Division of the #{response[\"conference\"]}ern Conference.\"\r\n end", "def target_name\n team_name\n end", "def test_team_name\n assert_equal(\"Glasgow Celgers\",@football_team.team)\n end", "def fix_team_name(team)\n team.split.map {|w| w.capitalize}.join(' ').\n gsub('.', '').\n match(/[A-z &']+/)[0].\n gsub(/((Af|F)c|Rmi)/) {|w| w.upcase}.\n strip\nend", "def teams\n return team_1 + team_2;\n end", "def team_names\n team_names = []\n \n game_hash.each do |key, value|\n team_names << value[:team_name]\n end\n team_names\nend", "def getTeamNames\n #return TestSuite.\n end", "def team\n fetch('esport.teams')\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def homefull()\n homef = Team.find(self.hometeam_id)\n return homef.fullname\n end", "def winning_team(result)\n goals = result.split(\"-\")\n if goals[0] == goals[1]\n \"draw\"\n elsif goals[0].to_i > goals[1].to_i\n \"home\"\n else\n \"away\"\n end\n end", "def get_team_name_by_id(team_id)\n response = parse_api_request(\"#{BASE_URL}teams/team/#{team_id}\")[\"teams\"].values.first[\"name\"]\nend", "def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend", "def team_names\n # team_array = []\n # team_array.push(game_hash[:home][:team_name])\n # team_array.push(game_hash[:away][:team_name])\n # team_array\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_name_in_teams? (a_teams, a_team_name)\n a_teams.has_key?(a_team_name.to_sym)\n end", "def formatted_teams(array)\n array.map { |team| team.name } * \", \"\n end", "def teams\n parse_domain_top '/Teams/TeamList.aspx', 'lnkTeamInfo'\n end", "def one_team_stats(team_name)\n game_hash.each do |home_or_away, team_stats|\n if team_stats[:team_name] == team_name\n return team_stats\n end\n end\nend", "def folder_name\n team_name = team.team.tr(' ', '-').strip_nonalnum\n team_name.unidowncase\n end", "def test_name_getter\n team = Team.new(\"Chicago Bulls\", [\"Michael Jordan\"], \"Magic Johnson\")\n assert_equal(\"Chicago Bulls\", team.name)\n end", "def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end", "def teams_data\n # selected_team = self.class.all[prompt.to_i-1]\n puts \"\"\n puts \"---------------------------\"\n puts \"Team Name: \" + self.full_name\n puts \"City: \" + self.city\n puts \"Division: \" + self.division\n puts \"Conference: \" + self.conference\n puts \"\"\n puts \"---------------------------\"\n end", "def team_of_player(player)\n if player\n if first_team.include_player?(player)\n first_team\n elsif second_team.include_player?(player)\n second_team\n end\n end\n end", "def team_names\n array = [] \n game_hash.each do |team, attributes|\n attributes.each do |key, value|\n if key == :team_name\n array.push(value)\n \n end\n end\n end\n array\nend", "def format_teams(team_ids)\n links = []\n team_ids.each do |id|\n url, name = team_url_and_name(id)\n links << \"[#{name}](#{url})\"\n end\n if links.length == 1\n \"the #{links[0]} group\"\n elsif links.length == 2\n \"the #{links[0]} or #{links[1]} groups\"\n else\n \"the #{links[0..-1].join(\", \")} or #{links[-1]} groups\"\n end\n end", "def get_team_by_name team\n @standings.detect {|t| t[:name] == team[:name]}\nend", "def matchups\n\t# we will create a temporary array\n\t# for use only in this method,\n\t# so we don't effect the original\n\t# @teams array with an deletions\n\ttemp_arr = []\n\[email protected] do |t|\n\t\ttemp_arr.push(t)\n\tend\n\n\tif temp_arr.length % 2 != 0\n\t\t# check if there is an odd number of teams,\n\t\t# if there is an odd number, we pull pull\n\t\t# out the top one and give them a bye week\n\t\tputs \"(1) #{temp_arr.delete_at(0).name} has a bye\"\n\t\t# and now we have an even number of teams\n\tend\n\n\t# match up the even amount of teams,\n\t# assuming there are any teams...\n\twhile temp_arr.length > 0\n\t\tteam1 = temp_arr.delete_at(0)\n\t\t# team 1 is the first one in array\n\t\tteam2 = temp_arr.pop\n\t\t# team 2 is last in array\n\t\tputs \"(#{team1.ranking}) #{team1.name} versus (#{team2.ranking}) #{team2.name}\"\n\t\t# this continues until no teams are left in the array\n\t\t# Example: \n\t\t# [1,2,3,4,5,6]\n\t\t# team1 = 1\n\t\t# team2 = 6\n\t\t# [2,3,4,5]\n\t\t# team1 = 2\n\t\t# team2 = 5\n\t\t# [3,4]\n\t\t# team1 = 3\n\t\t# team2 = 4\n\tend\n\n\treturn_to_menu\nend", "def player_data_by_team(team)\n players = []\n if team == game_hash[:home][:team_name]\n players << game_hash[:home][:players]\n else\n players << game_hash[:away][:players]\n end\n return players.flatten\nend", "def team_names\n names = []\n game_hash.each do |location, team_hash|\n names << team_hash.fetch_values(:team_name)\n end\n \n names.flatten # flatten is necessary because fetch was putting two arrays inside names\n\nend", "def all_teams_in_league\n \treturnArray = []\n\t\tbase_uri = 'https://www.thesportsdb.com/api/v1/json/1/search_all_teams.php?l=' + @league_name.to_s\n\t\tresponse = RestClient.get(base_uri)\n\t\tjson_response = JSON.parse(response)\n\t\thashIds = json_response['teams'] \n\t\thashIds.length.times do |i|\n\t\t\treturnArray[i] = \"Team ID: #{hashIds[i]['idTeam']}, Name: #{hashIds[i]['strTeam']}, Short Name: #{hashIds[i]['strTeamShort']}, Formed Year: #{hashIds[i]['intFormedYear']}, Sport: #{hashIds[i]['strSport']}, Alternate Name: #{hashIds[i]['strAlternateName']}\"\n\t\tend\n\t\treturn returnArray\n\tend" ]
[ "0.8469943", "0.76590705", "0.7613365", "0.7595783", "0.7552728", "0.75323176", "0.75323176", "0.75323176", "0.75323176", "0.7456411", "0.74353874", "0.73893493", "0.73689276", "0.7319529", "0.73154485", "0.7300384", "0.7291165", "0.7198319", "0.7198089", "0.70930916", "0.7050519", "0.70282125", "0.7026136", "0.7024633", "0.7021532", "0.6975797", "0.6970811", "0.6948763", "0.68870735", "0.68820286", "0.6862082", "0.68603903", "0.6854546", "0.68489313", "0.6848788", "0.6848788", "0.6846296", "0.68407017", "0.6836858", "0.68203545", "0.679972", "0.6785812", "0.67822284", "0.67655736", "0.6761226", "0.6759704", "0.67485976", "0.67370075", "0.6735588", "0.6730539", "0.6700361", "0.6697685", "0.6672389", "0.66654384", "0.6656743", "0.66289604", "0.6628084", "0.66221994", "0.6603695", "0.6583433", "0.65762204", "0.6571566", "0.6562536", "0.65617913", "0.6530163", "0.6524703", "0.65244687", "0.65218914", "0.6506504", "0.647523", "0.64691466", "0.6457075", "0.64465296", "0.64358", "0.6418354", "0.6401865", "0.6401273", "0.63990784", "0.63967437", "0.6378144", "0.6363618", "0.63616866", "0.6352386", "0.634335", "0.6337406", "0.63342106", "0.6331437", "0.6324346", "0.6294123", "0.6285625", "0.6278577", "0.62759066", "0.6264505", "0.62644607", "0.62561363", "0.62336624", "0.62307537", "0.62157845", "0.62106454", "0.62090313" ]
0.79633147
1
Returns array of jersey numbers for team
def player_numbers (team_name) all_jersies = []; lookup_by_team(team_name)[:players].map { |player| all_jersies << player[:number]; } all_jersies; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player_numbers(team_name)\n team = all_team_info(team_name)\n team[:players].map do |player|\n player[:number]\n end\nend", "def player_numbers(team_name)\n array_of_jerseys = []\n one_team_stats(team_name)[:players].each do |player, stats|\n array_of_jerseys << stats[:number]\n end\n array_of_jerseys\nend", "def player_numbers(team)\n # data = game_hash\n jersey_data = team_name_stats(game_hash)\n jersey_nums = []\n \n jersey_data.each_pair do |team_name, team_hash|\n if team_name == team\n team_hash.each_pair do |team_key, team_value|\n if team_key == :players\n team_value.map do |player|\n player.each_pair do |player_key, player_value|\n \n if player_key == :number\n jersey_nums << player_value\n end\n \n end\n end\n end\n end\n end\n end\n \n jersey_nums\nend", "def player_numbers(team_name)\n jersey_nums = []\n game_hash.each do |place, team|\n if team[:team_name] == team_name\n team.each do |attribute, player_info|\n if attribute == :players\n player_info.each do |data|\n jersey_nums << data[:number]\n end\n end\n end\n end\n end\n jersey_nums\nend", "def player_numbers(teamName)\n infoABoutASingleTeam = find_a_single_team_based_on_name(arg_team_name)\n players_on_a_team = = infoABoutASingleTeam[1][:players]\n players_on_a_team.map do |player_hash\n\n player_hash[:number]\n end\nend", "def player_numbers(team)\n numbers = []\n game_hash.each do |location, team_data|\n if team_data[:team_name] == team\n team_data[:players].each do |player_name, stat|\n numbers << stat[:number]\n end\n end\n end\n return numbers\nend", "def player_numbers(team)\n numbers = []\n\tif team == \"Brooklyn Nets\"\n\t\tgame_hash[:home][:players].each do |player_name, player_info_hash|\n # player_name = home game player names string(key), player_info_hash = player_info_hash = :number, :shoe, :points, :rebounds, :assists, :steals, :blocks, :slam_dunks\n\t\t\tnumbers << player_info_hash[:number]\n\t\tend\n\t\treturn numbers.sort\n\telse team == \"Charlotte Hornets\"\n\t\t\tgame_hash[:away][:players].each do |player_name, player_info_hash|\n\t\t\tnumbers << player_info_hash[:number]\n\t\tend\n\t\treturn numbers.sort\n\tend\nend", "def player_numbers(team_name)\n jersey_numbers = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if team_name == value[:team_name]\n jersey_numbers << element[:number]\n end\n end\n end\n jersey_numbers\nend", "def player_numbers(team_name)\n jersey_numbers = []\n game_hash.keys.each do |location|\n next unless game_hash[location][:team_name] == team_name\n\n game_hash[location][:players].keys.each do |name|\n jersey_numbers.push(game_hash[location][:players][name][:number])\n end\n end\n jersey_numbers\nend", "def player_numbers(team_name)\n player_number = []\n game_hash.each do |place, team|\n if team[:team_name] == team_name \n team[:players].each do |player|\n player_number<< player[:number]\n end\n end\n end\n player_number\n end", "def player_numbers(team_name)\n #returning an array of all the player numbers for each team\n arr = [] \n game_hash.each do |location, team|\n if team[:team_name] == team_name\n team[:players].each do |player_name, player_info|\n arr << player_info[:number]\n end\n end\n end\n arr\nend", "def player_numbers(team)\n output = []\n hash = game_hash\n hash.each do |location, team_data|\n if team == game_hash[location][:team_name]\n hash[location][:players].each do |name, stats|\n output.push(stats[:number])\n end\n end\n end\n return output\nend", "def player_numbers(teamName)\n teamSelect(teamName)[:players].collect do|name, stats|\n stats[:number]\n end\nend", "def player_numbers(selected_team)\n game_hash.values.each do |team|\n if team.has_value?(selected_team)\n return team[:players].map {|jerseys| jerseys[:number]}\n end\n end\nend", "def player_numbers(team_name)\n result = []\n game_hash.each do |side,team|\n if team[:team_name] == team_name\n team.each do |specs, info|\n next unless specs == :players\n\n info.each do |player|\n result.push(player[:number])\n end\n end\n end\n end\n result\nend", "def player_numbers(team_name)\n results = []\n \n game_hash.each do |location, team_data|\n if team_data[:team_name] == team_name\n team_data.each do |attributes, data|\n if attributes == :players\n data.each do |data_item|\n results << data_item[:number]\n end\n end\n end\n end\n end\n return results\nend", "def player_numbers(team_name)\n jersey_nums = []\n game_hash.each do |location, data|\n if data[:team_name] == \"#{team_name}\" #found match\n data[:players].each do |player, value|\n jersey_nums << value[:number]\n end\n end\n end\n jersey_nums\nend", "def player_numbers(team)\n player_numbers = []\n game_hash.each do |location, attributes|\n if attributes[:team_name] == team\n attributes[:players].each do |player, stats|\n player_numbers << stats[:number]\n end\n end\n end\n player_numbers\nend", "def player_numbers(team_name)\n jersey_numbers = Array.new\n\n if !game_hash.keys.include?(:team_name)\n game_hash.each do |location, team_info|\n if team_info.keys.include?(:team_name)\n team_info.each do |attribute, quanity|\n if quanity == team_name\n team_info.each do |attribute, quanity|\n if attribute == :players\n # binding.pry\n quanity.each do |name, stats|\n if name.length > 0\n # binding.pry\n stats.each do |stat, stat_quanity|\n if stat == :number\n # binding.pry\n jersey_numbers << stat_quanity\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\nputs jersey_numbers\nreturn jersey_numbers\nend", "def player_numbers(team_name)\n team_numbers = nil\n game_hash.map do |team, team_stats|\n if team_stats[:team_name] == team_name\n team_numbers = team_stats[:players].map do |player_stats|\n player_stats[:number]\n end\n end\n end\n team_numbers\nend", "def player_numbers(user_team_name)\n numbers = []\n game_hash.each do |k, team|\n if team[:team_name] == user_team_name\n team[:players].each do |player|\n numbers.push(player[:number])\n end\n end\n end\n numbers\nend", "def player_numbers(team_name)\n new_Arr = []\n game_hash.each do |place, team|\n if team_name == team[:team_name]\n team.each do |attribute, data|\n if attribute == :players\n data.each do |player|\n new_Arr.push(player[:number])\n # binding.pry\n end\n end\n end\n end\n end\n new_Arr\nend", "def player_nums(team, hashketball)\r\n sym = team.to_sym\r\n player_numbers = []\r\n \r\n hashketball[sym][:players].each_value do |x|\r\n player_numbers << x[:number]\r\n end\r\n player_numbers\r\nend", "def player_numbers (name=\"Brooklyn Nets\")\n n = []\n game_hash.each do |location, team_data|\n if(team_data[:team_name] == name)\n team_data[:players].each do |key, data|\n n << data[:number]\n end\n end\n end\n\n n\nend", "def player_numbers(input_team)\nnumbers = []\ngame_hash.each do |place, team|\n if team[:team_name] == input_team\n team.each do |attribute, data|\n next unless attribute == :players\n data.each do |player| #passing through an array \n numbers.push(player[:number])\n end \n end\n end\n end\nnumbers\nend", "def player_numbers(team_name)\n team_player_numbers = []\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors && info[:team_name] == team_name\n team_data.each do |player_index|\n team_player_numbers << player_index[:number]\n end\n end\n end\n end\n end\n team_player_numbers\nend", "def player_numbers(team_input)\n return_arr = []\n game_hash.each do |location, team|\n team.each do |team_info, data|\n if data == team_input\n team[:players].each do |name, stats|\n return_arr.push(stats[:number])\n end\n end\n end\n end\n return_arr\nend", "def player_numbers (team_name)\n player_number_array = []\n game_hash.each do |team, all_info_hash|\n if all_info_hash[:team_name] == team_name\n all_info_hash[:players].each do |player|\n player.each do |key, value|\n if key == :number\n player_number_array << value\n end\n end\n end\n end\n end\n player_number_array\nend", "def player_numbers(team_name)\n result = []\n game_hash.each do |team, about|\n if team_name == about[:team_name]\n about[:players].each do |name, stats|\n result << stats[:number]\n end\n end\n end\n result\nend", "def player_numbers(name_of_team)\n #built an empty array called numbers\n numbers = []\n # game_hash.each do |team, random| iterates over the hash to return all player numbers\n game_hash.each do |team, random|\n if name_of_team == game_hash[team][:team_name]\n game_hash[team][:players].each do |name, stats|\n numbers.push(stats[:number])\n end\n end\n end\n return numbers\nend", "def team_ids\r\n self.teams.collect { |t| t.code }\r\n end", "def team_ids\r\n self.teams.collect { |t| t.code }\r\n end", "def player_numbers(team_name)\n player_nums = []\n #top level\n game_hash.each do |location, team_data|\n #team?\n if game_hash[location][:team_name].join == team_name\n #all players\n game_hash[location][:players].each do |all_players|\n #iterate over players\n all_players.each do |player_name,stats|\n #check number\n stats.each do |category, val|\n if category == :number\n player_nums << stats[category]\n end\n end\n end\n end\n end\n end\n player_nums\nend", "def player_numbers (team_name)\n player_numbers_list = [] #Empty array to hold lst of players numbers\n game_hash.each do |team_key, team_value|#iterate down 1 level\n if team_value[:team_name] == team_name\n team_value[:players].each do |player_stats|\n player_stats.each do |key, value|#iterate through each players stats\n if key == :number #set :number as the comparison ID\n player_numbers_list << value # push players numbers/\"value\" into the empty array\n end\n end\n end\n end\n end\n player_numbers_list\nend", "def homeTeamPoints\n teamSelect(\"Brooklyn Nets\")[:players].collect do |name, stats|\n stats[:points]\n end\nend", "def get_team_ids(game)\n team_ids = game.team_ids # \"1/2-4/5\"\n team_ids.split(\"-\").map do |team| #[\"1/2\", \"4/5\"]\n team.split(\"/\")\n end.flatten.map(&:to_i)\n end", "def player_numbers(team_name)\n nums = []\n \n tname = false\n game_hash.each do |location, team_hash|\n\n \n #the below is actually iterating through the keys of the hash containing the team info, because the value of game_hash is....another hash\n team_hash.each do |key, vals|\n \n #set flag to true if it's the right team\n if vals == team_name \n tname = true \n # this makes sure I'm only iterating through the right pair to begin with\n if key == :players && tname == true # might need to swap these two\n vals.each do |player, stat| # remember stat is a hash (the value of the player name)!\n \n #push the stat into the array if it's the jersey number, otherwise keep iterating. \n nums << stat.fetch_values(:number)\n end\n end\n end\n end\n end\n nums.flatten\nend", "def all_teams_in_league\n \treturnArray = []\n\t\tbase_uri = 'https://www.thesportsdb.com/api/v1/json/1/search_all_teams.php?l=' + @league_name.to_s\n\t\tresponse = RestClient.get(base_uri)\n\t\tjson_response = JSON.parse(response)\n\t\thashIds = json_response['teams'] \n\t\thashIds.length.times do |i|\n\t\t\treturnArray[i] = \"Team ID: #{hashIds[i]['idTeam']}, Name: #{hashIds[i]['strTeam']}, Short Name: #{hashIds[i]['strTeamShort']}, Formed Year: #{hashIds[i]['intFormedYear']}, Sport: #{hashIds[i]['strSport']}, Alternate Name: #{hashIds[i]['strAlternateName']}\"\n\t\tend\n\t\treturn returnArray\n\tend", "def runners\n self.teams.reduce([]){|runners, team| runners + (team.runners) }\n end", "def player_numbers(teamname)\n outArray = []\n if game_hash[:home][:team_name] == teamname\n game_hash[:home][:players].each do |k,v|\n #puts \"#{k} TEST #{v}\"\n v.each do |result,number|\n if result == :number\n outArray << number\n end\n end\n end\n outArray\n\n elsif game_hash[:away][:team_name] == teamname\n game_hash[:away][:players].each do |k,v|\n #puts \"#{k} TEST #{v}\"\n v.each do |result,number|\n if result == :number\n outArray << number\n end\n end\n end\n outArray\nend\nend", "def judge_teams\n pilot_flight.pfj_results.collect { |pfj_result| pfj_result.judge }\n end", "def index\n @teams = @competition.teams.sort_by{|t| t.number}\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end", "def team_ids\n return [og_id, oo_id, cg_id, co_id];\n end", "def started_projects\n teams.flat_map(&:projects)\n end", "def players\n # Build two arrays of players\n cur_players = teams.map do |team|\n team.wattball_players\n end\n\n # Combine the arrays\n cur_players.flatten! \n end", "def teams_with_ids\n team_array = []\n\n self.teams.all.each do |team|\n team_array << [team.name, team.id]\n end\n\n team_array\n end", "def awayTeamPoints\n teamSelect(\"Charlotte Hornets\")[:players].collect do|name, stats|\n stats[:points]\n end\nend", "def games\n self.teams.map{|team| team.game }\n end", "def teams\n @teams\n end", "def getTeams()\n for player in @skater_data\n puts player\n begin\n team = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/people/#{player[5]}\"))[\"people\"][0][\"currentTeam\"][\"name\"]\n rescue\n team = \"N/A\"\n end\n if team.include? \"Canadiens\"\n team = \"Montreal Canadiens\"\n end\n player.push(team)\n end\n for goalie in @goalie_data\n begin\n team = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/people/#{goalie[5]}\"))[\"people\"][0][\"currentTeam\"][\"name\"]\n rescue\n team = \"N/A\"\n end\n if team.include? \"Canadiens\"\n team = \"Montreal Canadiens\"\n end\n goalie.push(team)\n puts goalie\n end\nend", "def return_planets\n planet_list = \"\"\n @planets.each do |planet|\n planet_list << \"#{@planets.index(planet) + 1}. #{planet.name} \\n\"\n end\n return planet_list\n end", "def teams\n return ['FFA (Free For All)'] if ffa?\n\n teams = []\n @doc.css('map teams').xpath('./team').each do |t|\n name = localized_sting(t.text)\n min = t.attr('min')\n max = t.attr('max')\n teams << \"<h3 style='color: #{color_to_html(t.attr('color'))}'>#{name} <small style='color: black'>(#{min} - #{max} players)</small></h3>\"\n end\n teams\n end", "def getGamesPlayedArray()\n standings = JSON.parse((RestClient.get \"https://statsapi.web.nhl.com/api/v1/standings\"))[\"records\"]#[0][\"teamRecords\"][0]\n for division in standings\n divisionRecords = division[\"teamRecords\"]\n for team in divisionRecords\n teamName = team[\"team\"][\"name\"]\n if teamName.include? \"Canadiens\"\n teamName = \"Montreal Canadiens\"\n end\n @games_played[teamName] = team[\"gamesPlayed\"]\n end\n end\n @games_played[\"N/A\"] = 82\nend", "def results\n @teams.map { |team| V1::TeamPresenter.new(team).present }\n end", "def teams\n return team_1 + team_2;\n end", "def get_all_participants\n\t\tparticipants_array = []\n\t\tmatch.teams.each do |t|\n\t\t\tparticipants_array << get_team_participants(t)\n\t\tend\n\t\tparticipants_array\n\tend", "def red_team\n teams[2]\n end", "def player_numbers(team_name)\n\nnum_array = []\n\ngame_hash.each do |team, team_stats|\n if team_stats[:team_name] == team_name\n team_stats.each do |k, v|\n if k == :players \n v.each do |stats|\n num_array << stats[:number]\n end\n end\n end\nend\nend\n#the final array should be the last thing returned before program ends\nnum_array\nend", "def team(p, num)\n z = []\n num.times {z << []}\n i = 0\n while i < p.count\n z[ i%num ] << p[i]\n i+=1\n end\n puts z.inspect\nend", "def player_numbers(team_name)\n outcome = []\n game_hash.each do |home_or_away, team_details|\n team_details.each do |key,value|\n if value == team_name\n game_hash[home_or_away][:players].each do |one_hash|\n one_hash.each do |key1,value1|\n if key1 == :number \n outcome << one_hash[key1]\n end\n end\n end \n end\n end\n end\n outcome\nend", "def teams\n return [og, oo, cg, co];\n end", "def team_name_with_team_number_array(team_ids)\n team1_id, team2_id = team_ids.split(\"-\")\n team1_name, team2_name = create_game_title_from_team_ids(team_ids).split(\" vs \")\n [[team1_name, team1_id], [team2_name, team2_id]]\n end", "def get_teams\n\tteam = Array.new\n\ti = 1\n\twhile i < RC_A.num_rows\n\t\tteam[i-1] = RC_A[(i+1), 1]\n\t\ti += 1\n\tend\n\treturn team\nend", "def get_teams\n\tteam = Array.new\n\ti = 1\n\twhile i < RC_A.num_rows\n\t\tteam[i-1] = RC_A[(i+1), 1]\n\t\ti += 1\n\tend\n\treturn team\nend", "def return_teams\r\n result = Array.new(@teams) { [] }\r\n allocation = @neighbourhoods_list[0].l_best_position\r\n (0..@length - 1).each do |x|\r\n (0..@teams - 1).each do |y|\r\n result[y].append(@table[x]['id']) if allocation[x][y] == 1\r\n end\r\n end\r\n # If there are any separated students\r\n # Assign them to teams\r\n assign_separated(result) unless @separated.nil?\r\n result\r\n end", "def get_teams\n TeamNode.get(node_object_id)\n end", "def team_names\n teams = []\n teams << game_hash[:home][:team_name]\n teams << game_hash[:away][:team_name]\n return teams\nend", "def get_winners\n json = get_json('http://oscars.yipitdata.com/')\n json.results.collect do |films_array|\n find_winner(films_array.films).tap do |winner|\n winner[:year] = films_array.year[0,4]\n end\n end\n end", "def index\n @numbers = @project.numbers\n end", "def team_names\n # built an empty array called teams\n teams = []\n # game_hash.each do |team, random| iterates over the hash to return all of the team_names\n game_hash.each do |team, random|\n teams.push(game_hash[team][:team_name])\n end\n return teams\nend", "def player_data_by_team(team)\n players = []\n if team == game_hash[:home][:team_name]\n players << game_hash[:home][:players]\n else\n players << game_hash[:away][:players]\n end\n return players.flatten\nend", "def get_team(game)\n team = 0\n get_participation_by_game game do |participation|\n team = participation.team\n end\n team\n end", "def blue_team\n teams[1]\n end", "def get_players_by_team(team_id)\n response = parse_api_request(\"#{BASE_URL}players/2018/#{team_id}\")[\"players\"]\nend", "def team_colors(team_n)\n game_hash.each do |location, team_data|\n #binding.pry\n if (team_data[:team_name] == team_n)\n return team_data[:colors].split(\", \")\n end\n end\n return nil\nend", "def get_teams\n TeamNode.get(self.node_object_id)\n end", "def team\n fetch('esport.teams')\n end", "def get_monster_by_team\n @team = Team.find(params[:team_id])\n render :json => {:success => \"true\",\n :data => {\n :monsters => @team.monsters.blank? ? Array.new : @team.monsters.map { |mon| {:id => mon.id, :name => mon.name, :team_count => mon.teams.size} }\n }}\n end", "def phone_numbers\n request = @browser.get(\"#{VoipfoneClient::API_GET_URL}?nums\")\n parse_response(request)[\"nums\"].collect {|n| n.first}\n end", "def list_planets\n list = \"\"\n @planets.each do |planet|\n list += \"#{@planets.index(planet) + 1}. #{planet}\\n\"\n end\n return list\n end", "def get_team_games(team)\n res = Array.new\n\n @games.each do |g|\n if team == g.home_team\n res.push(g)\n end\n\n if team == g.away_team\n res.push(g)\n end\n end\n\n return res\n end", "def list_of_planets\n list = []\n @planets.length.times do |index|\n list << \"#{index+1}. #{@planets[index].name}\"\n end\n return list\n end", "def team_names\n output =[]\n game_hash.each do |location, team_data|\n output.push(team_data[:team_name])\n end\n output\nend", "def team_names\n team_name = []\n game_hash.each do |team,info|\n team_name << info[:team_name]\n end\n team_name\nend", "def team_names\n names = []\n game_hash.each do | team, attributes|\n names << game_hash[team][:team_name]\n end\n return names\nend", "def getTeamNames\n #return TestSuite.\n end", "def team_names\n team = []\n game_hash.values.each do |team_info|\n team << team_info[:team_name]\n end\n team\nend", "def get_team_participants(a_team)\n\t\tparticipants_array = []\n\t\tusers.each do |u|\n\t\t\ta_team.users.each do |team_user|\n\t\t\t\tif u==team_user\n\t\t\t\t\tparticipants_array << u\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tparticipants_array\n\tend", "def members\n @teams.map { |_, t|\n t.members\n }.flatten\n end", "def get_teams( org )\n teams = Homework.get(\"/orgs/#{org}/teams\", :headers => @auth)\n teams.each do |team|\n puts team['id']\n end\n end", "def team_names\n team_names = []\n for location in game_hash.keys\n team_names.push(game_hash[location][:team_name])\n end\n return team_names\nend", "def list_of_planets()\n counter = 0\n planet_names = \"\"\n @planets.each do |planet|\n planet_names += \"\\n#{counter+1}. #{planet.planet_details}\"\n counter+=1\n end\n return planet_names\n end", "def team_names\n hash = game_hash\n array = []\n hash.each do |location, attributes|\n attributes.each do |attribute, info|\n if attribute == :team_name\n array << info\n end\n end\n end\n return array\nend", "def on_team\n tweets = Tweet.select(\"text\").map{|tweet| tweet.text}\n players = Player.where(\"team_name = ?\", params[:team_name]).select(\"name\").map{|player| player.name}\n counts = Hash[*players.zip([0]*players.length).flatten]\n\n tweets.each do |tweet|\n players.each do |name, count|\n # Split name into first name and last name\n fragments = name.downcase.split\n first = fragments[0..-2].join(' ')\n last = fragments.last\n full = name.downcase\n if (tweet.downcase.include? first and tweet.downcase.include? last) or tweet.downcase.include? full\n counts[name] += 1\n end\n end\n end\n\n respond_to do |format|\n format.html # on_team.html.erb\n format.json { render json: counts.sort_by{|_key, value|}.reverse[0..9] }\n end\n end", "def get_teams\n res = Array.new\n\n @games.each do |g|\n #check if home team is in the result array\n if !res.include?(g.home_team)\n res.push(g.home_team)\n end\n\n #check if away team is in the result array\n if !res.include?(g.away_team)\n res.push(g.away_team)\n end\n end\n\n return res\n end", "def teams\n standings_data = self.standings\n display_teams = []\n\n object.teams.each do |t|\n display_teams << t if standings_data[:data].key?(t.id) && standings_data[:data][t.id][:played] > 0\n end\n\n display_teams\n end", "def team_names\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_names\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_names\n # team_array = []\n # team_array.push(game_hash[:home][:team_name])\n # team_array.push(game_hash[:away][:team_name])\n # team_array\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def team_name\n\t\tcolor + \" \" + number.to_s\n\tend" ]
[ "0.74998224", "0.7365563", "0.7351597", "0.72578573", "0.7154844", "0.7068934", "0.7041595", "0.6991162", "0.6980928", "0.6969954", "0.6894792", "0.68932664", "0.68220276", "0.6816457", "0.67398953", "0.6732363", "0.6732256", "0.6720778", "0.6692669", "0.656047", "0.65594035", "0.65354794", "0.6521198", "0.6497034", "0.64719796", "0.64392847", "0.64390486", "0.64026594", "0.63695866", "0.63396126", "0.63206035", "0.63206035", "0.6282075", "0.62754077", "0.62337536", "0.61036336", "0.6098389", "0.60940117", "0.60472184", "0.603594", "0.5971177", "0.5904441", "0.5852785", "0.58477277", "0.5837698", "0.5833379", "0.58239377", "0.58210695", "0.58145374", "0.5785419", "0.57699996", "0.57526934", "0.575263", "0.5751766", "0.5733161", "0.57020324", "0.5694373", "0.56690645", "0.56639975", "0.56597453", "0.5634536", "0.56220543", "0.56083316", "0.56083316", "0.5581556", "0.5578825", "0.5560041", "0.5558487", "0.55550873", "0.5552696", "0.5546645", "0.5541982", "0.5540693", "0.55376256", "0.5537533", "0.5534839", "0.55343026", "0.55304897", "0.5529189", "0.5529073", "0.552755", "0.5519352", "0.55072856", "0.5506582", "0.549799", "0.5495438", "0.54647976", "0.5454827", "0.5452131", "0.5446275", "0.5445401", "0.54415154", "0.54297805", "0.5427348", "0.5417451", "0.541684", "0.5416291", "0.5416291", "0.5402172", "0.5396015" ]
0.7542146
0
Returns a players stats. Basically is my lookup_by_player method.
def player_stats (player_name) lookup_by_player(player_name); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player_stats(player)\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if name.to_s == player\n return stats\n end\n end\n end\nend", "def player_stats(playerName)\n players[playerName]\nend", "def player_stats(player_name)\n game_hash.each do |place, team|\n team[:players].each do |player|\n if player[:player_name] == player_name\n return player\n end\n end\n end\n end", "def player_stats(name)\n players[name]\nend", "def player_stats(player_name)\n game_hash.each do |location, data|\n data[:players].each do |player, data_items|\n return data_items if player == \"#{player_name}\"\n end\n end\nend", "def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person]\n end\n end\n end\n end\n end\nend", "def player_stats(player_name)\n game_hash.each do |side, value|\n value[:players].each do |name, stats|\n\n if name == player_name\n return stats\n end\n\n end\n end\nend", "def player_stats(player_name)\n stats = {}\n player_data.each do |player|\n if player_name == player[:player_name]\n stats[:number] = player[:number]\n stats[:shoe] = player[:shoe]\n stats[:points] = player[:points]\n stats[:rebounds] = player[:rebounds]\n stats[:assists] = player[:assists]\n stats[:steals] = player[:steals]\n stats[:blocks] = player[:blocks]\n stats[:slam_dunks] = player[:slam_dunks]\n end\n end\n return stats\nend", "def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attributes, data|\n if attributes == :players\n data.each do |data_item|\n if player_name == data_item[:player_name]\n return data_item\n end\n end\n end\n end\n end\nend", "def player_stats(player_name)\n stat_hash = {}\n game_hash.keys.each do |location|\n if game_hash[location][:players][player_name]\n return game_hash[location][:players][player_name]\n end\n end\nend", "def getStats (player)\n if player == \"me\"\n my_hits = self.my_hits\n my_misses = self.my_misses\n my_sunk_ships = sunkShips(\"me\")\n finished = self.finished\n stats = {my_hits: my_hits,\n my_misses: my_misses,\n my_sunk_ships: my_sunk_ships,\n finished: finished}\n statsRet = stats.to_json\n return statsRet\n\n else # player == \"enemy\"\n enemy_hits = self.enemy_hits\n enemy_misses = self.enemy_misses\n enemy_sunk_ships = sunkShips(\"enemy\")\n finished = self.finished\n stats = {enemy_hits: enemy_hits,\n enemy_misses: enemy_misses,\n enemy_sunk_ships: enemy_sunk_ships,\n finished: finished}\n statsRet = stats.to_json\n return statsRet\n end\n end", "def player_stats(name)\n all_players.find do |player|\n player[:player_name] == name\n end\nend", "def player_stats(player)\n game_hash.each do |team, team_info|\n team_info.each do |keys, values|\n if keys == :players \n values.each do |stats|\n if player == stats[:player_name]\n return stats\n end\n end\n end\n end\n end\nend", "def player_stats(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e\n end\n end\n end\nend", "def player_stats(player)\n game_hash.each do |location, team_info_hash|\n # location = :home,:away; players_hash = :team_name, :colors, :players\n team_info_hash[:players].each do |player_name, player_info_hash|\n # player_name = \"Jeff Adrian\" ect., player_info_hash = :number, :shoe, :points, :rebounds, :assists, :steals, :blocks, :slam_dunks\n if player_name == player\n return player_info_hash\n end\n end\n end\nend", "def player_stats(name)\n players = players_stats(game_hash)\n \n players.each_pair do |player, stats|\n if player == name\n \n # Fix code to pass the LEARN test\n stats.delete(:player_name)\n \n return stats\n end\n end\n nil\nend", "def player_stats(name)\n# player_stats start at nil (nothing)\n player_stats = nil\n# game_hash.each do |home_away, team_info| iterates over the hash to return all player_stats\n game_hash.each do |home_away, team_info|\n team_info.each do |data_label, data|\n if data_label == :players\n data.each do |player_name, stats|\n if player_name == name\n player_stats = stats\n end\n end\n end\n end\n end\n player_stats\nend", "def all_stats_for_player(name, game)\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats] if player_hash[:player_name] == name\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats] if player_hash[:player_name] == name\n end\nend", "def player_stats(player_name)\n player_name_stats = nil\n game_hash.select do |team, team_stats|\n team_stats[:players].select do |player_stats|\n if player_stats[:player_name] == player_name\n player_name_stats = player_stats\n end\n end\n end\n player_name_stats\nend", "def player_stats(player_name)\n result = {}\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats\n end\n end\n end\n result\nend", "def player_stats(player_name)\n player_stats = {}\n game_hash.each do |team, all_info_hash|\n all_info_hash[:players].each do |stats|\n if stats[:player_name] == player_name\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def player_stats(name)\n stats = {}\n game_hash.each do |team, team_data|\n team_data[:players].each do |data, output|\n if data == name \n stats = output\n end\n end\n end\n stats\nend", "def player_stats(player_name)\nplayer_stats = {}\n game_hash.each do |location, attributes|\n attributes[:players].each do |player, stats|\n if player == player_name\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def player_stats(name)\n hash = game_hash\n hash.each do |location, attributes| \n attributes.each do |attribute, info| \n if info.include?(name) \n return hash[location][attribute][name]\n end\n end\n end\nend", "def player_stats(player_name)\n result = {}\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n result = player\n result.delete(:player_name)\n end\n end\n end\n end\n end\n result\nend", "def basic_stats\n if @player_champs_list.present?\n {\n spec_user: User.find_by(name: @player.summoner.name.downcase),\n summoner: @player.summoner,\n top_played: first_champ(top_played_champs),\n top_kd: first_champ(top_kd_champs),\n top_wl: first_champ(top_wl_champs)\n }\n else \n nil\n end\n end", "def player_stats(player_name)\n player_stats = {}\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if player_name == element[:player_name]\n player_stats = element\n end\n end\n end\n player_stats\nend", "def player_stats(player_name)\n player_stats = []\n game_hash.each do |location, keys|\n keys[:players].each do |player_info|\n if player_info[:player_name] == player_name\n player_info.delete(:player_name)\n player_stats<< player_info\n end \n end\n end\n player_stats[0]\n #binding.pry\nend", "def num_points_scored(name)\n players = get_all_players # Works!\n player = find_player(players, name) # Up next...\n player[:points]\n \nend", "def points_scored_for_player(name,game)\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:points] if player_hash[:player_name] == name\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:points] if player_hash[:player_name] == name\n end\nend", "def iterate_through_players_for(name, statistic)\n game_hash.each do |team, game_data|\n \n game_data[:players].each do |player|\n if player[:player_name] == name\n \n return player[statistic]\n end\n end\n end\nend", "def player_by_number(number)\n players.each do |name, stats|\n if stats[:number] == number\n return name\n end\n end\nend", "def player_stats(name_input)\n game_hash.each do |location, team|\n team.each do |category, data|\n if category == :players\n data.find do |name|\n if name[:player_name] == name_input\n p name.reject { |key,value| key == :player_name }\n end\n end\n end\n end\n end\nend", "def player_stats(player_name_arg)\n get_me_all_players_please().find do |player_hash|\n player_hash[:player_name] == player_name_arg\n #binding.pry\n end\nend", "def player_stats(selected_player)\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player.has_value?(selected_player)\n player.delete(:player_name)\n return player\n end\n end\n end\nend", "def player_stats(name=\"Jeff Adrien\")\n player_stats={}\n if(game_hash[:home][:players].keys.include?(name))\n player_stats= game_hash[:home][:players][name]\n elsif (game_hash[:away][:players].keys.include?(name))\n player_stats = game_hash[:away][:players][name]\n else\n player_stats\n end\nend", "def iterate_through_players_for(name, statistic)\n game_hash.each do |_team, game_data|\n game_data[:players].each do |player|\n return player[statistic] if player[:player_name] == name\n end\n end\nend", "def points(name)\n \n consolidated_player_list = game_hash[:home][:players] + game_hash[:away][:players]\n consolidated_player_list\n player_stat_hash = {}\n\n consolidated_player_list.each do |player|\n key = player[:player_name]\n player_stat_hash[key] = player\n end\n\n points = 0\n player_stat_hash.each do |player|\n points = player[1][:points] if player[0] == name\n end\n points\nend", "def num_points_scored(player)\n game_hash.each do |location, team|\n team[:players].each do |name, stats|\n if name == player\n return stats[:points]\n end\n end\n end\nend", "def num_points_scored(name)\n ## Version 2.0 ##\n\n # 1. get all of the player hashes\n players = get_all_players\n # 2. get the player's data who matches the given name\n player_data = players[name]\n # 3. get the points from that data\n player_data[:points]\nend", "def player\n fetch('football.players')\n end", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |data_item, stats|\n if data_item == player_name\n return stats[:points]\n end\n end\n end\nend", "def get_players\n\n end", "def num_points_scored(player)\n \n data = game_hash\n player_hash = players_stats(data)\n \n player_hash.each_pair do |name, player_stat|\n \n if name == player\n player_stat.each_pair do |player_key, player_value|\n if player_key == :points\n return player_value\n end\n end\n end\n \n end\n \n nil\nend", "def players\n results = get_parts(\"status\", 2..-1)\n results.map do |player|\n player = player.split(\" \", 3)\n {\n :name => player[2][1..-2],\n :ping => player[1].to_i,\n :score => player[0].to_i\n }\n end\n end", "def players(options = {})\n Player.all(options.merge(team: source_id))\n end", "def player_stats(player_name, hashketball)\r\n player_name.capitalize!\r\n if hashketball[:home][:players].include?(player_name)\r\n hashketball[:home][:players][player_name][:stats]\r\n elsif hashketball[:away][:players].include?(player_name)\r\n hashketball[:away][:players][player_name][:stats]\r\n else\r\n \"No player found.\"\r\n end\r\nend", "def player_stats(player_name)\n player_stats = []\n game_hash.collect do |team_key, team_value|\n team_value[:players].each do |stats|\n if stats[:name] == player_name\n stats.delete(:name)#deletes name to keep in same formart ask for in test.\n player_stats = stats\n end\n end\n end\n player_stats\nend", "def players_get(opts = {})\n data, _status_code, _headers = players_get_with_http_info(opts)\n return data\n end", "def homeTeamPoints\n teamSelect(\"Brooklyn Nets\")[:players].collect do |name, stats|\n stats[:points]\n end\nend", "def num_points_scored(name)\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n ## Version 2.0 ##\n\n # 1. get all of the player hashes\n players = get_all_players\n # some imaginary method that will give us all the players from both teams\n\n # 2. get the player's data who matches the given name\n player_data = players[name]\n # since the keys are the player names, we can get the player's data\n # out of the hash by accessing it like this\n\n # 3. get the points from that data\n player_data[:points]\n # finally, with the player_data, we can grab out just the value we want\n # and return it (points)\nend", "def num_points_scored(name)\n game_hash.each do |location, attributes|\n attributes[:players].each do |player, stats|\n if player == name\n return stats[:points]\n end\n end\n end\nend", "def awayTeamPoints\n teamSelect(\"Charlotte Hornets\")[:players].collect do|name, stats|\n stats[:points]\n end\nend", "def num_points_scored(player_name)\n player_points = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if player_stats[:player_name] == player_name\n player_points = player_stats[:points]\n end\n end\n end\n player_points\nend", "def num_points_scored(player_lookup) \n game_hash.each do |location, team_data|\n#return the number of points scored for that player\n team_data[:players].each do |player|\n if player[:player_name] == player_lookup\n return player[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\n\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n\n # SOLUTION 3\n # get a list of all the players\n # all_players = game_hash.values.collect do |team|\n # team[:players]\n # end.flatten\n\n # find the player whose name matches the argument 'player_name'\n # return that player's points\n # all_players.each do |player|\n # return player[:points] if player[:player_name] == player_name\n # end\nend", "def sport_players(sport_id, season, **options) = get(\"/sports/#{sport_id}/players\", **options.merge(season:))", "def num_points_scored (player_name)\n lookup_by_player(player_name)[:points]; \nend", "def player_numbers(teamName)\n teamSelect(teamName)[:players].collect do|name, stats|\n stats[:number]\n end\nend", "def num_points_scored(playerName)\n player_stats(playerName)[:points]\nend", "def players\n users\n end", "def num_points_scored(name)\n player_stats(name)[:points]\nend", "def get_player(id)\n\t\treturn @players[id]\n\tend", "def num_points_scored(player_name)\n# we use .each do |team, random| to iterate over each piece of data to expose specific data, in this case number of points scored by each player, within the above hash\n# and we use symbols (with one object id) to take up less memory\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name, stats|\n if player_name == name\n return stats[:points]\n# then we want to return the number of points scored for each player if player_name is equal to the key of name\n\n end\n end\n end\n\nend", "def get_score()\n score = Hash.new(0)\n players.each {|player| score[player.name] = player.score}\n score\n end", "def num_points_scored(name)\n players = get_all_players # Works!\n player = find_player(players, name) # Works!\n\n\n player[:points] # Does this work?\n # Test it and you'll see that it does!\nend", "def num_points_scored(name)\n game_hash().each do |location, team_data|\n team_data[:players].each do |player_name, player_stat|\n if name == player_name\n return player_stat[:points]\n end\n end\n end\nend", "def num_points_scored(player_name)\n result = nil\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats[:points]\n end\n end\n end\n result\nend", "def num_points_scored(name)\n # However, our data is different.\n\n # Given that we have :home and :away, each being a hash with a :players key\n # that is now an array of player hashes (name included), we cannot do this\n # anymore to get the matching player:\n # game_hash[:home][:players][name]\n\n\n # If you it out with binding.pry, you'll get this error:\n # TypeError: no implicit conversion of String into Integer\n # That's because game_hash[:home][:players] is an array and trying to use\n # [name] on it won't work as that would be how you try to access a value\n # in array based on it's position (name is a string, not an integer).\n\n\n # So what do we want to do here?\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n # Let's break it down into steps:\n # 1. get an array of all the players\n # 2. loop through that array and pick out the one whose name matches\n # 3. get the points for that player\n\n # Let's write out our ideal code for accomplishing this:\n players = get_all_players\n player = find_player(players, name)\n player[:points]\nend", "def display_player_stats\n @output.puts '- Players -'.center(WIDTH)\n seperator = \"\\t\"\n stat_width = WIDTH - 5\n stats = String.new\n bot_stats = String.new\n\n stats << \"Player: #{@player.name}\".ljust(WIDTH/2)\n stats << seperator\n stats << \"Chips: #{@player.chips}\"\n @output.puts stats.center(stat_width)\n\n if @bots.empty?\n @output.puts 'No AI opponents.'.center(WIDTH)\n else\n @bots.each do |bot|\n bot_stats = \"AI: #{bot.name}\".ljust(WIDTH/2)\n bot_stats << seperator\n bot_stats << \"Chips: #{bot.chips}\"\n @output.puts bot_stats.center(stat_width)\n end\n end\n end", "def num_points_scored(player_name)\n game_hash.each do |side, team|\n team.each do |specs, info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(player_name)\n if !game_hash.keys.include?(:players)\n game_hash.each do |location, team_info|\n if team_info.keys.include?(:players)\n team_info.each do |attribute, quanity|\n if attribute == :players\n quanity.each do |name, stats|\n if name == player_name\n stats.each do |stat, quanity|\n if stat == :points\n return quanity\n end\n end\n end\n end\n end\n end\n end\n end\n end\nend", "def player_numbers(team_name)\n array_of_jerseys = []\n one_team_stats(team_name)[:players].each do |player, stats|\n array_of_jerseys << stats[:number]\n end\n array_of_jerseys\nend", "def lookup_by_player (player_name) \n game_hash.each_pair { |h_or_a, team_info|\n team_info[:players].map { |player|\n if player[:player_name] === player_name\n# player[:location] = h_or_a;\n # player[:team_name] = game_hash[h_or_a][:team_name];\n # player[:team_colors] = game_hash[h_or_a][:colors];\n return player;\n end\n }\n }\n #Could add error message here if player could not be found. N/A for lab. \nend", "def num_points_scored(player_name)\n players = get_players\n \n found_player = find_player(players, player_name)\n \n # return that player's points\n found_player[:points]\nend", "def get_player(nickname)\n response = get(RESOURCE_PATH, nickname, headers: { 'API-VERSION': 'v2' })\n response_body = JSON.parse(response.body, symbolize_names: true)\n\n Rails.logger.info(\"GS Get Player Response: #{response_body}\")\n\n if response.success?\n #TODO: deserialize response json into Player object automatically\n nickname = response_body[:nickname]\n ext_id = response_body[:ext_id]\n avatar = response_body[:avatar]\n theme = response_body[:theme]\n player_point_types = []\n point_types_response = response_body[:point_types]\n (point_types_response || []).each do |point_type_response|\n player_point_types << GameServer::Model::PlayerPointType.new(point_name: point_type_response[:name], count: point_type_response[:amount])\n end\n\n player = GameServer::Model::Player.new(nickname, ext_id, avatar, theme)\n player.player_point_types = player_point_types\n\n get_player_response = GameServer::Client::Response::GetPlayerResponse.new(true, nil, player)\n else\n error_message = response_body[:error_message]\n\n get_player_response = GameServer::Client::Response::GetPlayerResponse.new(false, error_message, nil)\n end\n\n return get_player_response\n end", "def featured_stats\n player_data = {\n spec_user: @user,\n summoner: @player.summoner,\n top_played: filter_champs(top_played_champs, TOP_FIVE),\n top_kd: filter_champs(top_kd_champs, TOP_FIVE),\n top_wl: filter_champs(top_wl_champs, TOP_FIVE)\n }\n end", "def champion_stats(id, season = nil)\n ChampionStats.new(Client.get(\"/v1.2/stats/by-summoner/#{id}/ranked\", query: {\"season\" => season.to_s}))\n end", "def player_numbers(team_name)\n team_numbers = nil\n game_hash.map do |team, team_stats|\n if team_stats[:team_name] == team_name\n team_numbers = team_stats[:players].map do |player_stats|\n player_stats[:number]\n end\n end\n end\n team_numbers\nend", "def num_points_scored(name)\n points = nil\n hash_of_players = {}\n game_hash.each do |location, elements|\n hash_of_players = elements[:players]\n hash_of_players.each do |player, stats|\n if player == name\n points = hash_of_players[player][:points]\n end\n end\n end\n points\nend", "def shoe_size(player_name)\n # i want all the players first <= simplify it ideally\n # so i can look through them\n # find the player that matches the name\n\n\n # found_player = all_players.find do |player| # Hash\n # player[:player_name] == player_name\n # end\n\n # get the shoe size for that player\n found_player(player_name)[:shoe]\nend", "def num_points_scored(player)\n game_hash.each_value do |team|\n team[:players].each do |name, player_data|\n if name == player\n points = player_data[:points]\n return points\n end\n end\n end\nend", "def player_numbers(team)\n player_numbers = []\n game_hash.each do |location, attributes|\n if attributes[:team_name] == team\n attributes[:players].each do |player, stats|\n player_numbers << stats[:number]\n end\n end\n end\n player_numbers\nend", "def num_points_scored(players_name)\n game_hash.each do |place, team|\n team.each do |attr, data|\n if attr == :players\n data.each do |player|\n if player[:player_name] == players_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def num_points_scored(player_name)\n # if you were trying to explain this to someone in prework\n # who's stuck in hashketball, how would you explain how to do this?\n\n # find the num points scored as it relates to the name\n # we have all_players array\n # each value in all players has a smaller value that is the name of the player\n # that is also connected to the number of points they scored\n # find a way to sort the method / just find the value of points attributed to that name\n\n # hash of teams\n # visit each team\n # ask them for the player name list\n # check the list for the name\n # if i find it, then I have their points\n # I would return their points\n\n # argument pass in each player\n # try to return the amount of points associated with that player\n\n # pseudocode\n\n # i want all the players first <= simplify it ideally\n # home_players = game_hash[:home][:players]\n # away_players = game_hash[:away][:players]\n # all_players = home_players + away_players\n\n # so i can look through them\n # .each with an if\n # search, find, gofish\n # array of hashes\n # found_player = all_players.find do |player| # Hash\n # # find the player that matches the name\n # # binding.pry\n # # if player[:player_name] == player_name\n # # true\n # # else\n # # false\n # # end\n # player[:player_name] == player_name\n # end\n\n # get the points for that player\n found_player(player_name)[:points]\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes|\n if attributes[:player_name] == player_name\n return attributes[:points]\n end\n end\n end\nend", "def player_stats(player_name)\n player_stat = {}\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if player_index[:player_name] == player_name\n player_stat = player_index\n end\n end\n end\n end\n end\n end\n player_stat\nend", "def num_points_scored (searched_player)\n player_points = 0\n game_hash[:away][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n game_hash[:home][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n player_points\nend", "def num_points_scored(player_name)\npoints_scored = 0\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player, stats|\n if player == player_name\n points_scored = stats[:points]\n end\n end\n end\n end\nend\npoints_scored\nend", "def num_points_scored(player_name)\n game_hash.each do |home_or_away, team_values|\n team_values[:players].each do |player|\n if player[:player_name] == player_name \n return player[:points]\n end\n end \n end \nend", "def score(player)\n @score[player]\n end", "def collect_stat_by_name (stat) #returns hash of \"name\" => stat value\n team_names_array = team_names\n player_stats_array = []\n roster = []\n player_stat = {}\n \n team_names_array.each do |team|\n roster << search_team_data(team, :players)\n roster.flatten!\n roster.each do |player_entry|\n player_stats_array << player_entry.slice(:player_name, stat)\n end\n end\n player_stats_array.each do |player_stat_hash|\n player_stat[player_stat_hash[:player_name]] = player_stat_hash[stat]\n end\n player_stat\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n if data.keys.include?(player_name)\n return data[player_name][:points]\n end\n end\n end\n end\nend", "def player_numbers(name_of_team)\n #built an empty array called numbers\n numbers = []\n # game_hash.each do |team, random| iterates over the hash to return all player numbers\n game_hash.each do |team, random|\n if name_of_team == game_hash[team][:team_name]\n game_hash[team][:players].each do |name, stats|\n numbers.push(stats[:number])\n end\n end\n end\n return numbers\nend", "def points_per_player(player, hashketball)\r\n player.capitalize!\r\n if hashketball[:home][:players].include?(player)\r\n hashketball[:home][:players][player][:stats][:points]\r\n elsif hashketball[:away][:players].include?(player)\r\n hashketball[:away][:players][player][:stats][:points]\r\n else\r\n \"No player found.\"\r\n end\r\nend", "def num_points_scored(player_name)\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n return player[:points] if player.has_value?(player_name)\n end\n end\nend", "def num_points_scored(player_name)\n points = nil\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n binding.pry\n if name == player_name\n points = team_data[:players][player_name][:points]\n end\n end\n end\n points\n end", "def common_player_info(\n player_id,\n season_type=NbaStats::Constants::SEASON_TYPE_REGULAR,\n league_id=NbaStats::Constants::LEAGUE_ID_NBA\n )\n NbaStats::Resources::CommonPlayerInfo.new(\n get(COMMON_PLAYER_INFO_PATH, {\n :PlayerID => player_id,\n :SeasonType => season_type,\n :LeagueID => league_id\n })\n )\n end", "def players(ordering = :raw)\n\t\t@@logger.info { \"Retrieving players.\" } if have_logger?\n\t\tmyplayers = Player.dataset.filter(:tournament_id => self.id).all\n\t\tcase ordering\n\t\t\twhen :random then\n\t\t\t\t@@logger.info { \"Ordering players: :random.\" } if have_logger?\n\t\t\t\tmyplayers.shuffle\n\t\t\twhen :criteria then\n\t\t\t\t@@logger.info { \"Ordering players: :criteria.\" } if have_logger?\n\t\t\t\tmyplayers.sort do |a, b|\n\t\t\t\t\ta_side = []\n\t\t\t\t\tb_side = []\n\t\t\t\t\tself.criteria.each do |func|\n\t\t\t\t\t\ta_side << a.send(func)\n\t\t\t\t\t\tb_side << b.send(func)\n\t\t\t\t\tend\n\t\t\t\t\tb_side <=> a_side\n\t\t\t\tend\n\t\t\twhen :score, :soft then\n\t\t\t\t@@logger.info { \"Ordering players: :score or :soft.\" } if have_logger?\n\t\t\t\tmyplayers.sort { |a, b| b.score <=> a.score }\n\t\t\twhen :hard then\n\t\t\t\t@@logger.info { \"Ordering players: :hard.\" } if have_logger?\n\t\t\t\tscores = []\n\t\t\t\tmyplayers.each { |player| scores << player.score unless scores.include?(player.score) }\n\t\t\t\tscores.each do |score|\n\t\t\t\t\t# Select those with same score\n\t\t\t\t\tplayers_tmp = myplayers.select { |player| player.score == score }\n\t\t\t\t\tnext if players_tmp.length <= 1 # If not more than one, get next group\n\t\t\t\t\t# Great... we have a group. Remove them from the main array\n\t\t\t\t\tmyplayers.delete_if { |player| player.score == score }\n\t\t\t\t\t# Shuffle the temp array\n\t\t\t\t\tplayers_tmp.shuffle!\n\t\t\t\t\t# Give it back to the main array\n\t\t\t\t\tmyplayers += players_tmp\n\t\t\t\tend\n\t\t\t\t# Sort it again in the end\n\t\t\t\tmyplayers.sort { |a, b| b.score <=> a.score }\n\t\t\telse\n\t\t\t\t# This include the :raw case\n\t\t\t\t@@logger.info { \"Ordering players: :raw or any other thing.\" } if have_logger?\n\t\t\t\tmyplayers\n\t\tend\n\tend", "def num_points_scored(name)\n game_hash.each do |place, team|\n\n team.each do | atribute , data|\n \n if atribute == :players\n data.each do |player|\n # binding.pry\n if player[:player_name ] == name\n return player[:points]\n end\n end\n end\n end\n end\nend" ]
[ "0.7854962", "0.7849181", "0.78485507", "0.77261955", "0.7615381", "0.76011974", "0.7578505", "0.75376475", "0.75055635", "0.7481486", "0.74378526", "0.7402045", "0.73494565", "0.7302118", "0.72688746", "0.72614264", "0.72552264", "0.72197175", "0.7125658", "0.7123158", "0.7120833", "0.70812804", "0.70764637", "0.7041709", "0.7021877", "0.697007", "0.6943764", "0.6941946", "0.6899131", "0.6819886", "0.6817386", "0.6769301", "0.6731625", "0.6686495", "0.66613907", "0.66591716", "0.66568536", "0.66438186", "0.6622565", "0.6598227", "0.659801", "0.6581882", "0.6569854", "0.6556917", "0.6554231", "0.65515375", "0.6544384", "0.6540978", "0.6539996", "0.6535462", "0.6527944", "0.6490864", "0.6463987", "0.6461832", "0.6453091", "0.64501077", "0.644004", "0.64400184", "0.6436044", "0.6435556", "0.6431386", "0.6411534", "0.6410726", "0.6395834", "0.6393322", "0.63684815", "0.6350386", "0.63468564", "0.6342021", "0.6339378", "0.63314176", "0.63303334", "0.63202775", "0.6318036", "0.6314991", "0.63087034", "0.63065106", "0.63046837", "0.62898034", "0.6288537", "0.6285265", "0.62728703", "0.6268685", "0.62613845", "0.6260559", "0.6255578", "0.62550086", "0.6252655", "0.62488794", "0.62401515", "0.6237404", "0.62228525", "0.6215266", "0.6207973", "0.6200682", "0.6199377", "0.6199124", "0.6190006", "0.61896306", "0.6188285" ]
0.8242873
0
Returns the rebounds of player with the biggest shoe
def big_shoe_rebounds big_shoe_player = player_collection.reduce { |memo, next_player| memo[:shoe] > next_player[:shoe] ? memo : next_player; } big_shoe_player[:rebounds]; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def big_shoe_rebounds\n players[player_with_most(:shoe)][:rebounds]\nend", "def big_shoe_rebounds\n all_players = game_hash[:home][:players].merge(game_hash[:home][:players])\n big_object = all_players.max_by do |key,value|\n value[:shoe]\n end \n big_object[1][:rebounds]\nend", "def big_shoe_rebounds\n\tbiggest_shoes_player = nil\n\tshoe_size_tracker = 0\n\trebounds_stat = nil\n\tgame_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, more_data|\n\t\t\tif attribute == :players\n\t\t\t\tmore_data.each do |player|\n\t\t\t\t\tplayer.each do |name, stats|\n\t\t\t\t\t\tstats.each do |stat, val|\n\t\t\t\t\t\t\tif stat == :shoe\n\t\t\t\t\t\t\t\tif !biggest_shoes_player || val > shoe_size_tracker\n\t\t\t\t\t\t\t\t\tshoe_size_tracker = val\n\t\t\t\t\t\t\t\t\tbiggest_shoes_player = name\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\trebounds_stat = stats[:rebounds]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\trebounds_stat\nend", "def rebounds_for_player_with_largest_shoe_size(game)\n shoe_sizes_with_player_names = []\n game[:home_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n game[:away_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n biggest_shoe_size = {\"test\" => 0}\n shoe_sizes_with_player_names.each do |shoe_size_and_name_hash|\n biggest_shoe_size = shoe_size_and_name_hash if shoe_size_and_name_hash.values[0] > biggest_shoe_size.values[0]\n end\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\nend", "def big_shoe_rebounds\n largest = 0\n player = \"\"\n game_hash.each do |location, team_data|\n team_data[:players].each do |k, v|\n if largest < shoe_size(k)\n largest = shoe_size(k)\n player = k\n end\n end\n end\n return player_stats(player)[:rebounds]\nend", "def big_shoe_rebounds\n game_hash.values.each do |attribute|\n hash = attribute[:players]\n hash.values.each do |h|\n h.select { |k, v| k == :shoe }.sort.max\n return h[:rebounds]\n end\n end\nend", "def big_shoe_rebounds\n player_biggest_shoe_size.fetch(:rebounds)\nend", "def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end", "def big_shoe_rebounds\n biggest = 0\n rebounds = 0\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n size = player[:shoe]\n if size > biggest\n biggest = size\n rebounds = player[:rebounds]\n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds\n biggest_shoe_size = 0\n player_rebounds = 0\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:shoe] > biggest_shoe_size\n biggest_shoe_size = e[:shoe]\n player_rebounds = e[:rebounds]\n end\n end\n end\n player_rebounds\nend", "def big_shoe_rebounds\n biggest_shoe_size[:rebounds]\nend", "def big_shoe_rebounds\n # built an empty array called names\n names = []\n # built an empty array called shoe_sizes\n shoe_sizes = []\n # game_hash.each do |team, random| iterates over the hash\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name,stats|\n names.push(name)\n shoe_sizes.push(stats[:shoe])\n end\n end\n # finds the player with largest shoes size\n largest = -1\n shoe_sizes.each do |x|\n if x > largest\n largest = x\n end\n end\n\n # we want to add to player_with_largest the actual largest shoe size and we can do that by adding a key with an array as a value\n player_with_largest = names[shoe_sizes.index(largest)]\n\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name, stats|\n if player_with_largest == name\n return stats[:rebounds]\n # once we've found the player with the largest shoe size\n # we've returned that player's number of rebounds by first accessing their stats and then going into the value of rebounds\n\n end\n end\n end\nend", "def big_shoe_rebounds_helper\n shoes_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n shoes_array << element[:shoe]\n end\n end\n shoes_array.max\nend", "def big_shoe_rebounds\n big_shoes = []\n max_shoe = []\n what_team = []\n game_hash.each do |location, team_color_player|\n team_color_player.each do |tcp, players|\n if tcp == :players\n players.each do |player, stat|\n stat.each do |statistic, actual|\n if statistic == :shoe\n max_shoe.push(actual)\n if max_shoe.max == actual\n big_shoes.push(player)\n what_team.push(location)\n end\n end\n end\n end\n end\n end\n end\n return game_hash[what_team.last][:players][big_shoes.last][:rebounds]\nend", "def big_shoe_rebounds\n max_shoe = 0\n rebounds = 0\n player = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |name|\n if game_hash[location][:players][name][:shoe] > max_shoe\n max_shoe = game_hash[location][:players][name][:shoe]\n rebounds = game_hash[location][:players][name][:rebounds]\n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds\n player_shoe_sizes = {}\n largest_shoe_size = \" \"\n rebounds = \"\"\n #top level\n game_hash.each do |location, team_data|\n #1st level\n game_hash[location][:players].each do |all_players|\n #2nd level\n all_players.each do |player_name,stats|\n #add names to shoe size\n player_shoe_sizes[player_name]= stats[:shoe]\n end\n #iterates\n player_shoe_sizes.each do |k, v|\n #name of player of largest shoe size\n if v == player_shoe_sizes.values.max\n largest_shoe_size = k\n end\n end\n #rebounds of player of largest shoe size\n all_players.each do |p_name, statistics|\n if p_name == largest_shoe_size\n rebounds = statistics[:rebounds]\n end\n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds\n hash = game_hash\n #first find largest shoe size\n max_size = 0\n hash.each do |location, team_data|\n\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] > max_size\n max_size = hash[location][:players][name][:shoe]\n end\n end\n end\n\n #then return the player's number of rebounds\n hash.each do |location, team_data|\n hash[location][:players].each do |name, values|\n if hash[location][:players][name][:shoe] == max_size\n return hash[location][:players][name][:rebounds]\n end\n end\n end\n\nend", "def big_shoe_rebounds_2\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n\n game_hash.dig(:home, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n\n end\n end\n end\n end\n end\nend\n\n puts highest_rebounds\n return highest_rebounds\nend", "def big_shoe_rebounds\n biggest_shoe = 0\n rebounds = 0\n game_hash.each do |team, all_info_hash|\n all_info_hash[:players].each do |player_information_hash|\n if player_information_hash[:shoe] > biggest_shoe\n biggest_shoe = player_information_hash[:shoe] \n rebounds = player_information_hash[:rebounds] \n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds\n\nhighest_rebounds = 0\nbiggest_shoe = 0\n\n game_hash.each do |location, team_info|\n game_hash.dig(location, :players).each do |player_name, stats|\n stats.each do |stat, number|\n if stat == :shoe\n if number > biggest_shoe\n biggest_shoe = number\n stats.each do |stat, number|\n if stat == :rebounds\n highest_rebounds = number\n end\n end\n end\n end\n end\n end\n end\n puts highest_rebounds\n return highest_rebounds\nend", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def big_shoe_rebounds\n player_with_the_largest_shoe_size = 0\n most_rebounds = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if player_with_the_largest_shoe_size == 0 || player_index[:shoe] > player_with_the_largest_shoe_size \n player_with_the_largest_shoe_size = player_index[:shoe]\n most_rebounds = player_index[:rebounds]\n end\n end\n end\n end\n end\n end\n most_rebounds\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def big_shoe_rebounds()\n shoe_size = 0\n result = 0\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:shoe] > shoe_size\n shoe_size = player[:shoe]\n result = player[:rebounds]\n\n end\n end\n end\n end\n end\n result\nend", "def big_shoe_rebounds\n big_foot = 0\n boards = 0\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:shoe] > big_foot\n big_foot = player[:shoe]\n boards = player[:rebounds]\n end\n end\n end\n return boards\nend", "def big_shoe_rebounds\n biggestShoes[1][:rebounds]\nend", "def most_rebound(player_name)\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n value.each do |player, detail|\r\n if player == player_name\r\n return detail[:rebounds]\r\n end\r\n end\r\n end\r\n end\r\n end\r\nend", "def big_shoe_rebounds\nans = 0\nshoe_arr = []\nbig = 0\n\n game_hash.collect do |where, stats| \n \n game_hash[where][:players].collect do |p_name,p_stats|\n p_stats.collect do |stat_name,info|\n puts \n if stat_name == :shoe\n shoe_arr << info\n # puts shoe_arr.max_by{|x| x}\n big = shoe_arr.sort.last\n \n if game_hash[where][:players][p_name][:shoe] == big\n \n ans = game_hash[where][:players][p_name][:rebounds]\n\n end\n end\n end\n end\n end\nans \nend", "def largest_shoes(game)\nmax_shoes = 0\nrebounds = 0\nmax_shoes_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:shoe_size] == max_shoes\n max_shoes_player = max_shoes_player + \" and #{player_contents[:player_name]}\"\n rebounds = player_contents[:rebounds]\n elsif player_contents[:shoe_size] > max_shoes\n max_shoes = player_contents[:shoe_size]\n max_shoes_player = player_contents[:player_name]\n rebounds = player_contents[:rebounds]\n end\n end\nend\nputs \"#{max_shoes_player} has size #{max_shoes} shoes and #{rebounds} rebounds\"\nend", "def big_shoe_rebounds\n big_shoe = 0\n result = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n stats.each do |stat, value|\n if stat == :shoe\n if big_shoe < value \n result = stats[:rebounds]\n big_shoe = value\n end\n end\n end\n end\n end\n result\nend", "def big_shoe_rebounds\n shoe_size = 0\n rebounds = 0\n game_hash.each do | team, attributes |\n attributes[:players].each do | player_data | #array\n player_data.each do | player_name, detail |\n if detail[:shoe] > shoe_size\n\n shoe_size = detail[:shoe]\n rebounds = detail[:rebounds]\n end\n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds\n # Set two objects to equal integer values of 0 to be called/changed by the method\n biggest_shoe_size = 0\n number_of_rebounds = 0\n \n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes| # Calls the stats of each player within the :players array \n if attributes[:shoe] > biggest_shoe_size # Finds and calls the largest integer value in the shoe key\n biggest_shoe_size = attributes[:shoe] # Sets value for biggest_shoe_size to equal the shoe value\n number_of_rebounds = attributes[:rebounds] # Sets value for number_of_rebounds to equal the rebounds value\n end\n end\n end\n return number_of_rebounds\nend", "def big_shoe_rebounds\n b_size =0\n rebounds = 0\n player = \"\"\n\n game_hash.each do |location, team_data|\n team_data[:players].each do |p_name, stats|\n if (stats[:shoe] > b_size)\n b_size = stats[:shoe]\n player = p_name.to_s\n rebounds = stats[:rebounds]\n end #if\n end #team_data\n end #game_hash\n rebounds\nend", "def big_shoe_rebounds\n\nnew_array = []\nsize = 0\nrebounds = 0\n\n game_hash.each do |side, value|\n value[:players].each do |name, stats|\nif stats[:shoe] > size\n size = stats[:shoe]\n rebounds = stats[:rebounds]\n new_array[0] = name\n new_array[1] = stats[:shoe]\n new_array[2] = stats[:rebounds]\n\nend\n\nend\nend\n return new_array.last\n\n\nend", "def big_shoe_rebounds\n shoe_sizes = []\n output = nil\n game_hash.each do |team, att|\n game_hash[team][:players].each { |k, v| shoe_sizes << k[:shoe] }\n game_hash[team][:players].each { |k, v|\n k[:shoe] == shoe_sizes.sort.pop ? output = k[:rebounds] : nil }\n end\n output \nend", "def big_shoe_rebounds()\n\nshoe_size = 0\nrebounds = 0\n\ngame_hash.each do |team, team_stats|\n team_stats[:players].each do |stats|\n if stats[:shoe] > shoe_size\n shoe_size = stats[:shoe]\n rebounds = stats[:rebounds]\n end\n end\n end\nrebounds\nend", "def big_shoe_rebounds\n big_shoes_player = 0\n rebounds = 0\n game_hash.each do |team_key, team_value|\n team_value[:players].each do |stats|\n if stats[:shoe] > big_shoes_player #if the shoe stats for the current player being compared is bigger than the current \"big_shoes_player\" then continue to next lines of code that cause \"big_shoes_player\" to turn into the current player and reflect his rebounds.\n big_shoes_player = stats[:shoe]\n rebounds = stats[:rebounds]\n end\n end\n end\n rebounds\nend", "def big_shoe_rebounds\n shoe_max = 0\n rebounds = nil\n game_hash.each do |home_or_away, team_details|\n team_details[:players].each do |one_hash| # one_hash is an array\n one_hash.each do |key1,value1| #one_hash is a hash now\n if key1 == :shoe\n if value1 > shoe_max\n shoe_max = value1 \n if value1 == shoe_max\n rebounds = one_hash[:rebounds]\n end\n end\n end\n end\n end\n end\n rebounds\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def big_shoe_rebounds\n no_of_rebounds = 0 \n largest_shoesize = 0 \n player_w_largest_shoe = \"\" \n \n game_hash.each do |team_key, team_value_hash|\n players_array = team_value_hash[:players] \n players_array.each do |stats_hash|\n if stats_hash[:shoe] > largest_shoesize\n largest_shoesize = stats_hash[:shoe]\n player_w_largest_shoe = stats_hash[:player_name]\n no_of_rebounds = stats_hash[:rebounds]\n # binding.pry\n end \n end \n end \n no_of_rebounds \nend", "def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def big_shoe_rebounds\n big_shoe_rebounds_helper\n rebounds = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if big_shoe_rebounds_helper == element[:shoe]\n rebounds = element[:rebounds]\n end\n end\n end\n rebounds \nend", "def big_shoe_rebounds\n shoe_size =0 #creates a lowest size shoe_size\n rebounds = 0\ngame_hash[:home][:players].each do |player,attribute_hash|\n if attribute_hash[:shoe] > shoe_size #every shoe_size that is bigger than the last will overwrite the array.\n shoe_size = attribute_hash[:shoe]\n rebounds = attribute_hash[:rebounds]\n end\nend\n#repeat process for the away side of the hash\ngame_hash[:away][:players].each do |player,attribute_hash|\n if attribute_hash[:shoe] > shoe_size\n shoe_size = attribute_hash[:shoe]\n rebounds = attribute_hash[:rebounds]\nend\nend\nrebounds\nend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def winner\n @player_positions.max_by{|player, position| position}[0]\n end", "def biggest_shoe(hashketball)\r\n player_number_with_biggest_shoe = \"\"\r\n biggest_shoe_size = 0\r\n \r\n hashketball[:home][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n hashketball[:away][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n \r\n \" #{player_number_with_biggest_shoe} : #{biggest_shoe_size} \"\r\nend", "def max(board)\n #Generate moves array\n moves = minmax_moves(board, self)\n #Placeholder for max score, even the worst score is > -2\n max = -2\n #Find terminal and check terminal nodes and delete them from move array. If any of them are 1 instantly return\n moves.delete_if do |index, board|\n if over?(board)\n #If board is terminal get score\n res = minmax_score(board)\n #If terminal is winning instantly return it\n return res if res == 1\n max = res if res > max\n true\n else\n false\n end\n end\n\n #Else get worst scores of new states\n moves.each do |index, board|\n res = min(board)\n return res if res == 1\n max = res if res > max\n end\n max\n end", "def big_shoe_rebounds\n11\nend", "def best_move_for(player)\n return minimax(player)[1]\n end", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def calculate_maximum_square_size width, height, margins\n # maximum width is trimmed by opponent's view width\n main_player_view_width = WINDOW_WIDTH - OPPONENT_VIEW_WIDTH\n maximum_width = main_player_view_width - margins[:x] * 2\n maximum_height = WINDOW_HEIGHT - margins[:y] - margins[:y_bottom]\n maximum_square_size_in_width = maximum_width / width\n maximum_square_size_in_height = maximum_height / height\n\n # get the smallest possible size to fit the 'viewable' screen\n best_square_size = maximum_square_size_in_width >= maximum_square_size_in_height ?\n maximum_square_size_in_height :\n maximum_square_size_in_width\n\n # readjust player's board to the center\n margins[:x] = (main_player_view_width - width * best_square_size).to_f / 2\n margins[:y] += (WINDOW_HEIGHT - margins[:y] - height * best_square_size) / 2\n\n # return new square size\n best_square_size\nend", "def shoe_size(player_name)\n game_hash.each do |location, team_data|\n\t\t#iterating over the first layer\n\tteam_data.each do |k, v|\n\t\t#iterating over the second layer\n\t\tif k == :players\n\t\t\tv.each do |x|\n\t\t\tif x[:player_name] == player_name\n\t\t\treturn x[:shoe]\n\t\t\tend\n\t\t end\n\t\tend\n\t end\n\tend\nend", "def worst_case board\n\t\tworst = 0\n\t\topp_board = board.rotate 7\n\t\t6.times {|i|\n\t\t\t\ts = score_for(opp_board, i)\n\t\t\t\tworst = s if worst < s\n\t\t\t}\n\t\t\tworst\n\tend", "def winner\n @players.max_by{ |player| player.score}\n end", "def player_with_longest_name\n array = []\n array2 = []\n max_name = \"\"\n game_hash.collect do |location, team_data|\n team_data[:players].keys.collect do |name|\n array << name\n array2 << name.length\n end\n end\n\t max = array2.max\n array.collect do |name|\n if \tname.length == max\n max_name = name\n end\n end\n max_name\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def shoe_size(player)\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name] == player\n return e[:shoe]\n end\n end\n end\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def max_score\n return score if @state != STATE_OK\n\n next_boards.map(&:min_score).min\n end", "def players_with_highest_score\n players.select{|player| player.score >= highest_player_score}\n end", "def shoe_size(player_name)\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:shoe]\n end\n end\n end\nend", "def worst_loss(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.home_goals - game.away_goals\n elsif game.home_team_id.to_s == team_id\n game.away_goals - game.home_goals\n end\n end.compact.max\n end", "def shoe_size (player_name)\n\n game_hash.each do |side, team|\n team.each do |specs, info|\n if specs == :players\n\n info.each do |player|\n if player[:player_name] == player_name\n return player[:shoe]\n end\n end\n end\n end\n end\nend", "def grab_shoe\n j, k = [], 0\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute = :players\n j = game_hash[location][attribute].keys\n j.each do |name|\n if game_hash[location][attribute][name][:shoe] > k\n k = game_hash[location][attribute][name][:shoe]\n end#if\n end#j\n end#if\n end#team\n end#game\n k\nend", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def last_position\n self.players.maximum(:position)\n end", "def shoe_size(name)#exact same method as above, just switched :points to :shoe\n answer = nil\n game_hash.each do |team_key,team_value|#iterate down one level\n players_stats = team_value[:players]\n players_stats.each do |players_details|\n if players_details[:name] == name\n answer = players_details[:shoe]\n end\n end\n end\n answer\n end", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end", "def highest_total_score\n @game_manager.highest_total_score\n end", "def minmax_position(passes)\n # It's somewhere in the positions\n all_positions = positions(passes)\n\n # between the minimum and maximum seat\n min_pos, max_pos = all_positions.minmax\n\n # So we just eliminate any seat that's taken. Whatever is left over\n # is ours\n (min_pos..max_pos).to_a - all_positions\nend", "def take_worst\n roll_all.min\n end", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def shoe_size (player_name)\n lookup_by_player(player_name)[:shoe]; \nend", "def shoe_size(name)\n game_hash.each do |location, attributes|\n attributes[:players].each do |player, stats|\n if player == name\n return stats[:shoe]\n end\n end\n end\nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def shoe_size(player)\n\tshoe_size = nil\n\tmy_hash = game_hash\n\tmy_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, more_data|\n\t\t\tif attribute == :players\n\t\t\t\tmore_data.each do |person|\n\t\t\t\t\tperson.each do |name, stats|\n\t\t\t\t\t\tshoe_size = stats[:shoe] if name == player\n\t\t\t\t\tend\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend \n\tshoe_size\nend", "def shoe_size(name)\n game_hash.each do |place, team|\n team.each do |attribute, data|\n if attribute == :players\n data.each do |player|\n if name == player[:player_name] \n return player[:shoe] \n end\n end\n end\n end\n end\nend", "def biggest_team_blowout(team_id)\n @games.map do |game|\n if game.away_team_id.to_s == team_id\n game.away_goals - game.home_goals\n elsif game.home_team_id.to_s == team_id\n game.home_goals - game.away_goals\n end\n end.compact.max\n end", "def player_with_longest_name\n longest_name = 0\n longest_player_name = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if longest_name < player_stats[:player_name].length\n longest_name = player_stats[:player_name].length\n longest_player_name = player_stats[:player_name]\n end\n end\n end\n longest_player_name\nend", "def player_with_longest_name\n longest_name = 0\n the_player = \"\"\n\n game_hash.each do |location, team_data|\n team_data[:players].each do |name,stats|\n if (name.size > the_player.size)\n the_player = name\n end #if\n end #team_data\n end #game_hash\n the_player\n\nend", "def maximum_of_two_players\n # TODO implement\n end", "def shoe_size(player_name)\n game_hash.each do |location, team_data|\n team_data[:players].each do |attributes|\n if attributes[:player_name] == player_name\n return attributes[:shoe]\n end\n end\n end\nend", "def most_steal\n steals_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n steals_array << element[:steals]\n end\n end\n steals_array.max\nend", "def player_with_longest_name\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |i, j|\r\n result[i]=i.length\r\n end\r\n end\r\n end\r\n end\r\n result.max_by {|name, len| len}[0].to_s\r\n end", "def highest_match_value\n values = @hand.select { |dice| @hand.count(dice) == highest_match_count }\n values.max\n end", "def shoe_size(player_name)\n game_hash.values.each do |team|\n team[:players].each do |player|\n return player[:shoe] if player.has_value?(player_name)\n end\n end\nend", "def shoe_size(player_name)\n # get list of players\n players = get_players\n # find player with matching name\n found_player = find_player(players, player_name)\n # return player's shoe size\n found_player[:shoe]\nend", "def shoe_size(player_name)\n player_shoe_size = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if player_stats[:player_name] == player_name\n player_shoe_size = player_stats[:shoe]\n end\n end\n end\n player_shoe_size\nend", "def player_with_most(stat)\n value = nil\n owner = nil\n players.each do |player, stats|\n if value == nil || stats[stat] > value\n value = stats[stat]\n owner = player\n end\n end\n owner\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def shoe_size(player)\n shoe_size = 0\n game_hash[:home][:players].each do |player_name, player_info_hash|\n # player_name = home game player names string(key), player_info_hash = player_info_hash = :number, :shoe, :points, :rebounds, :assists, :steals, :blocks, :slam_dunks\n if player == player_name\n\t\t\tshoe_size = player_info_hash[:shoe]\n\t\tend\n\tend\n\tgame_hash[:away][:players].each do |player_name, player_info_hash|\n\t\tif player == player_name\n\t\t\tshoe_size = player_info_hash[:shoe]\n\t\tend\n\tend\n\tshoe_size\nend", "def highest_score\n sorted_all_scores = self.leaderboard_entries.order(score: :DESC)\n sorted_all_scores[0]\n end", "def shoe_size(player_name)\n game_hash.each do |place, team|\n team.each do |attribute, data|\n if attribute == :players \n data.each do |player|\n if player[:player_name]== player_name\n return player[:shoe]\n end\n end\n end\n end\n end\nend", "def shoe_size(playerName)\n player_stats(playerName)[:shoe]\nend", "def best_move\n\t\tpossible_moves.send(@turn == \"x\" ? :max_by: :min_by) { |idx| minimax(idx) }\n\tend" ]
[ "0.83024466", "0.8195294", "0.8145576", "0.81283486", "0.8090692", "0.80538493", "0.7980708", "0.79363906", "0.7789502", "0.7734409", "0.7699467", "0.7688509", "0.765567", "0.76496804", "0.7562456", "0.7560956", "0.7472922", "0.74616796", "0.7433744", "0.7408723", "0.7404332", "0.7337967", "0.72840565", "0.725736", "0.7250813", "0.72496444", "0.71977454", "0.7184886", "0.71083254", "0.7104432", "0.7069254", "0.7041177", "0.6985371", "0.6935033", "0.69124687", "0.6886331", "0.68557274", "0.68533504", "0.6825664", "0.67995065", "0.66297364", "0.652679", "0.65114444", "0.64277387", "0.63242805", "0.6314996", "0.6309131", "0.62581533", "0.6220991", "0.6187666", "0.61650753", "0.6162971", "0.61594355", "0.6133845", "0.61199105", "0.6112245", "0.6106761", "0.609408", "0.60483366", "0.6044019", "0.60431564", "0.6031436", "0.6030306", "0.6002511", "0.597867", "0.59727246", "0.5965231", "0.59545827", "0.59433424", "0.5939799", "0.59215707", "0.59159505", "0.59151924", "0.59120184", "0.59109586", "0.5892412", "0.58897257", "0.58772546", "0.58710575", "0.58700734", "0.58640945", "0.5863622", "0.586288", "0.5861836", "0.5861151", "0.58590245", "0.5852308", "0.58501303", "0.58483154", "0.58464444", "0.58460903", "0.58430135", "0.5842545", "0.5833873", "0.58322644", "0.5823463", "0.58234304", "0.5814405", "0.5804097", "0.57938874" ]
0.76904076
11
3. Which player has the longest name? Call the method `player_with_longest_name`. Super Bonus: 1. Write a method that returns true if the player with the longest name had the most steals. Call the method `long_name_steals_a_ton?`. Returns player with the most points scored
def most_points_scored big_score_player = player_collection.reduce { |memo, next_player| memo[:points] > next_player[:points] ? memo : next_player; } big_score_player[:player_name]; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def long_name_steals_a_ton?\n player_with_most(:steals) == player_with_longest_name\nend", "def player_with_longest_name_also_had_most_steals?(game)\n player_longest_name(game) == most_steals(game)\nend", "def player_with_longest_name\n longestName.max_by(&:length)\nend", "def long_name_steals_a_ton?\n longest_name = player_with_longest_name()\n player_name_with_most_steals = player_with_most_steals()\n\n if longest_name == player_name_with_most_steals\n return true\n end\n false\nend", "def long_name_steals_a_ton?\n # find player with longest name\n # find player with most steals\n # are they the same? if so return true\n player_with_most_steals = players.max_by { |player| player[:steals]}\n player_with_longest_name == player_with_most_steals[:player_name] ? true : false\nend", "def long_name_steals_a_ton?()\n\n def most_steals()\n steals = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:steals] > steals\n steals = player[:steals]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\n end\n\n return player_with_longest_name() == most_steals()\nend", "def long_name_steals_a_ton?\n if player_with_longest_name == mostSteals[0]\n true\n else\n false\n end\nend", "def player_with_longest_name\n longest_name = 0\n the_player = \"\"\n\n game_hash.each do |location, team_data|\n team_data[:players].each do |name,stats|\n if (name.size > the_player.size)\n the_player = name\n end #if\n end #team_data\n end #game_hash\n the_player\n\nend", "def long_name_steals_a_ton?\n highest_number_steals = 0\n player_most_steals = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if highest_number_steals < player_stats[:steals]\n highest_number_steals = player_stats[:steals]\n player_most_steals = player_stats[:player_name]\n end\n end\n end\n if player_most_steals == player_with_longest_name\n true\n else\n false\n end\nend", "def player_with_longest_name\n longest_name = 0\n longest_player_name = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if longest_name < player_stats[:player_name].length\n longest_name = player_stats[:player_name].length\n longest_player_name = player_stats[:player_name]\n end\n end\n end\n longest_player_name\nend", "def long_name_steals_a_ton?\n steals = 0\n most_steals = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if steals < stats[:steals]\n steals = stats[:steals]\n most_steals = name\n end\n end\n end\n most_steals == player_with_longest_name\nend", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def long_name_steals_a_ton?\n max_steals = 0\n player_name = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |name|\n if game_hash[location][:players][name][:steals] > max_steals\n max_steals = game_hash[location][:players][name][:steals]\n player_name = name\n end\n end\n end\n player_name == player_with_longest_name\nend", "def player_with_longest_name\n longest = ''\n longest_length = 0\n game_hash.each do |home_away, keys|\n keys[:players].each do |player|\n name_length = player[:player_name].length\n longest, longest_length = player[:player_name], name_length if name_length > longest_length\n end\n end\n return longest\nend", "def long_name_steals_a_ton?\n most_steals = 0\n leading_stealer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:steals] > most_steals\n most_steals = player[:steals]\n leading_stealer = player[:player_name]\n end\n end\n end\n if leading_stealer == player_with_longest_name\n return true\n end\n end", "def longest_name(game)\nmax_length = 0\nmax_length_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:player_name].length > max_length\n max_length = player_contents[:player_name].length\n max_length_player = player_contents[:player_name]\n elsif player_contents[:player_name].length == max_length\n max_length_player += max_length_player \" and #{player_contents[:player_name]}\"\n end\n end\nend\nmax_length_player\nend", "def longestName\n players.collect do|name, stats|\n name\n end\nend", "def player_with_longest_name\n max_name = 0\n player_name = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |name|\n if name.length > max_name\n max_name = name.length\n player_name = name\n end\n end\n end\n player_name\nend", "def player_with_longest_name\n array = []\n array2 = []\n max_name = \"\"\n game_hash.collect do |location, team_data|\n team_data[:players].keys.collect do |name|\n array << name\n array2 << name.length\n end\n end\n\t max = array2.max\n array.collect do |name|\n if \tname.length == max\n max_name = name\n end\n end\n max_name\n end", "def player_with_longest_name\n players.keys.sort_by { |name| name.length }[-1]\nend", "def long_name_steals_a_ton \n long_name_player = player_collection.reduce { |longest_name, next_player|\n longest_name[:player_name].length > next_player[:player_name].length ? longest_name : next_player; \n }\n most_steals_player = player_collection.reduce { |most_steals, next_player|\n most_steals[:steals] > next_player[:steals] ? most_steals : next_player; \n }\n long_name_player === most_steals_player; \nend", "def long_name_steals_a_ton?\n\t # returns true if the player with the longest name had the most steals\n\tlongest_name_length = 0\n\tlongest_name_name = []\n\tmost_steals = 0\n\tmost_steals_name = []\n\tall_players = []\t\t\t\t# Is all players, home & away. Renamed! \n\tsteals_array = []\n\ttrue_flag = nil\n\n\n\t# OKAY, prints -- calculates max # of steals, currently array w 3 / was one name (winner or tie possible...)\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\tstats.each do |stat, stat_value|\n\t\t\t\t\tif game_hash[h_or_a][:players][stat][:steals] > most_steals\n\t\t\t\t\t\tmost_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\tmost_steals_name = stat\n\t\t\t\t\t\tputs(\"one players w Max steals name : #{most_steals_name}\")\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n# compare to each player's # / steals to the max steals and put all winner / (winners, if tie) to an array\n# Prev. version: put all players w a winning # steals in an array (to accomodate ties). \n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\t# stats.each do |stat, stat_value|\n\t\t\t\t# \t most_steals = game_hash[h_or_a][:players][stat][:steals].max_by {|stat2, statval2 | stat2.to_s.to_f <=> statval2 }\n\t\t\t\tall_players.each do |name| \t\t\t# ONLY HAS ONE ITEM IN PIPES! | |\n\t\t\t\t\tif game_hash[h_or_a][:players][name][:steals] = most_steals\n\t\t\t\t\t\tsteals_array << name\n\t\t\t\t\t\t#most_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\t# most_steals_name << stat\n\t\t\t\t\t\tputs(\"Most steals V2** name : #{steals_array}\")\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n\n\tgame_hash[:home][:players].each do |k, v|\n\t\t#puts (\"v.flatten is -- #{k.to_s}\")\n\t\tall_players << k.to_s \t\t\t#v.flatten \n\tend\n\tgame_hash[:away][:players].each do |k, v|\n\t\tall_players << k.to_s\n\tend\n\n\tputs (\"all_players is : #{all_players}\")\n\n\n# Attempt to get all max values of steals\n# max = my_hash.values.max\n# Hash[my_hash.select { |k, v| v == max}]\n\n\n# game_hash =\t{\n# \thome: {\n# \t\tteam_name: \"Brooklyn Nets\",\n# \t\tcolors: [\"Black\", \"White\"], \t\t\t#array of strings\n# \t\tplayers: {\n# \t\t\t\"Alan Anderson\": {\n# \t\t\t\tnumber: 0, \n# \t\t\t\tshoe: 16, \n\n\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, names|\n\t\t\tif (info_type == :players)\n\t\t\t\t# stats.each do |stat, stat_value|\n\t\t\t\t# \t most_steals = game_hash[h_or_a][:players][stat][:steals].max_by {|stat2, statval2 | stat2.to_s.to_f <=> statval2 }\n\t\t\t\tall_players.each do |name, stats| \n\t\t\t\t\tsteals_array = game_hash[h_or_a][:players][name][:steals].select { |stats, stat_val | stat_val == max }\t#undefined method `[]' for nil:NilClass\n\t\t\t\t\tputs(\"Most steals V3** array names : #{steals_array}\")\n\t\t\t\t\t#end\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\nhome_steals = game_hash[:home][:players][name][:steals].select { |stats, stat_val | stat_val == max }\n\n\n# ERROR - doesn't find away players, returns nil. // Create parallel array just holding each player's max # of steals. \n\n\tall_players.each do |name|\n\t\tputs(\"number of steals is #{game_hash[:home][:players][name.to_sym][:steals]}, name is- #{ name}\")\t\t\n\t\t\tsteals_array << game_hash[:home][:players][name.to_sym][:steals]\n\t\t\n\tend\n\n\n\n\tall_players.each do |name|\n\t\tputs(\"Name.length is #{name.length}, name is- #{name}\")\t\t\n\t\tif name.length > longest_name_length\n\t\t\tlongest_name_length = name.length\n\t\t\tlongest_name_name << name\n\t\tend\n\tend\n\n\n\t#### NEED TO DO SORT BY LENGTH, THEN CALC LENGTH OF EACH, RETURN ALL MAX TIES TO NEW ARRAY\n\tlongest_name_name = all_players.max(1) { |name, b| name.length <=> b.length}\n\tlongest_name_length = longest_name_name.length\n\n\tprint \"Longest Name Length Is : \"\n\tputs longest_name_length\n\n\tprint \"Final Longest Name Is : \"\n\tputs longest_name_name\n\n\tprint \" Most Steals Is : \"\n\tputs most_steals_name\n\n\tlongest_name_name.each do |name|\n\t\tif most_steals_name.include?(name)\n\t\t\ttrue_flag = true\n\n\t\tend\n\tend\n\tputs true_flag\n\treturn true_flag\nend", "def long_name_steals_a_ton?\n most_steal\n player_with_longest_name\n most_steal_player = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_steal == element[:steals]\n most_steal_player = element[:player_name]\n end\n end\n end\n player_with_longest_name.eql?(most_steal_player)\nend", "def player_with_longest_name\n long_name = \"\"\n name = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n name << element[:player_name]\n end\n end\n long_name = name.max\nend", "def long_name_steals_a_ton?\n\t # returns true if the player with the longest name had the most steals\n\tlongest_name_length = 0\n\tlongest_name_name = []\n\tmost_steals = 0\n\tmost_steals_name = []\n\tmy_array = []\n\ttrue_flag = nil\n\n\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\tstats.each do |stat, stat_value|\n\t\t\t\t\tif game_hash[h_or_a][:players][stat][:steals] > most_steals\n\t\t\t\t\t\tmost_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\tmost_steals_name << stat\n\t\t\t\t\t\tputs(\"Most steals name : #{most_steals_name}\")\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\tstats.each do |stat, stat_value|\n\t\t\t\t\t most_steals = game_hash[h_or_a][:players][stat][:steals].max_by {|stat2, statval2 | stat2.to_s.to_f <=> statval2 }\n\n\t\t\t\t\t\t#most_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\tmost_steals_name << stat\n\t\t\t\t\t\tputs(\"Most steals V2** name : #{most_steals_name}\")\n\t\t\t\t\t#end\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n\n\n\n\n\n\n\n\tgame_hash[:home][:players].each do |k, v|\n\t\t#puts (\"v.flatten is -- #{k.to_s}\")\n\t\tmy_array << k.to_s \t\t\t#v.flatten \n\tend\n\tgame_hash[:away][:players].each do |k, v|\n\t\tmy_array << k.to_s\n\tend\n\n\tputs (\"my_array is : #{my_array}\")\n\n\n\tmy_array.each do |name|\n\t\tputs(\"Name.length is #{name.length}, name is- #{name}\")\t\t\n\t\tif name.length > longest_name_length\n\t\t\tlongest_name_length = name.length\n\t\t\tlongest_name_name << name\n\t\tend\n\tend\n\n\n\t#### NEED TO DO SORT BY LENGTH, THEN CALC LENGTH OF EACH, RETURN ALL MAX TIES TO NEW ARRAY\n\tlongest_name_name = my_array.max(2) { |name, b| name.length <=> b.length}\n\tlongest_name_length = longest_name_name.length\n\n\tprint \"Longest Name Length Is : \"\n\tputs longest_name_length\n\n\tprint \"Final Longest Name Is : \"\n\tputs longest_name_name\n\n\tprint \" Most Steals Is : \"\n\tputs most_steals_name\n\n\tlongest_name_name.each do |name|\n\t\tif most_steals_name.include?(name)\n\t\t\ttrue_flag = true\n\n\t\tend\n\tend\n\tputs true_flag\n\treturn true_flag\nend", "def player_with_longest_name\n longest_name = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name].length > longest_name.length\n longest_name = e[:player_name]\n end\n end\n end\n longest_name\nend", "def player_with_longest_name()\ncount = 0\nresult = \"\"\n\ngame_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n\n if player[:player_name].length > count\n count = player[:player_name].length\n result = player[:player_name]\n\n end\n end\n end\n end\nend\nresult\nend", "def player_with_longest_name\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |i, j|\r\n result[i]=i.length\r\n end\r\n end\r\n end\r\n end\r\n result.max_by {|name, len| len}[0].to_s\r\n end", "def player_with_longest_name\n name_size = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if name_size < name.size\n result = name\n end\n end\n end\n result\nend", "def long_name_steals_a_ton?\n name_length = 0\n longest_name = \"\"\n steals = []\n top_stealer = \"\"\n\n game_hash.collect do |location, team_info|\n team_info[:players].collect do |name, stats|\n steals << stats[:steals]\n if stats[:steals] == steals.sort[-1]\n top_stealer = name\n end\n if name.length > name_length\n longest_name = name\n end\n end\n end\n\n if longest_name == top_stealer\n true\n else\n false\n end\n\nend", "def long_name_steals_a_ton? \n longest_name = \"\"\n player_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if longest_name == \"\" || player_index[:player_name] > longest_name \n longest_name = player_index[:player_name]\n longest_name = player_index[:player_name]\n player_steals = player_index[:steals]\n end\n end\n end\n end\n end\n end\n if player_steals > most_steals\n true\n else\n false\n end\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def player_with_most_of(statistic)\r\n player_name = \"\"\r\n amount_of_stat = 0\r\n\r\n game_hash.each do |team, stats|\r\n stats[:players].each do |players|\r\n if players[statistic].is_a? String\r\n if players[statistic].length > player_name.length\r\n player_name = players[:player_name]\r\n end\r\n elsif players[statistic] > amount_of_stat\r\n amount_of_stat = players[statistic]\r\n player_name = players[:player_name]\r\n end\r\n end\r\n end\r\n\r\n player_name\r\nend", "def player_with_longest_name\nlongest_name = \"\"\ngame_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if longest_name == \"\" || player_index[:player_name] > longest_name \n longest_name = player_index[:player_name]\n longest_name = player_index[:player_name]\n end\n end\n end\n end\n end\nend\nlongest_name\nend", "def player_with_longest_name\n player_collection.reduce { |longest_name, next_player|\n longest_name[:player_name].length > next_player[:player_name].length ? longest_name : next_player; \n }[:player_name]; \n #probably easier to read to declare variable, however, good to know this works. \nend", "def player_with_most_of(statistic)\n player_name = nil\n amount_of_stat = 0\n\n game_hash.each do |team, game_data|\n game_data[:players].each do |player|\n if player[statistic].is_a? String\n if player[statistic].length > amount_of_stat\n amount_of_stat = player[statistic].length\n player_name = player[:player_name]\n end\n elsif player[statistic] > amount_of_stat\n amount_of_stat = player[statistic]\n player_name = player[:player_name]\n end\n end\n end\n\n player_name\nend", "def most_points_scored\nplayer_with_most(:points)\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def largest_shoes(game)\nmax_shoes = 0\nrebounds = 0\nmax_shoes_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:shoe_size] == max_shoes\n max_shoes_player = max_shoes_player + \" and #{player_contents[:player_name]}\"\n rebounds = player_contents[:rebounds]\n elsif player_contents[:shoe_size] > max_shoes\n max_shoes = player_contents[:shoe_size]\n max_shoes_player = player_contents[:player_name]\n rebounds = player_contents[:rebounds]\n end\n end\nend\nputs \"#{max_shoes_player} has size #{max_shoes} shoes and #{rebounds} rebounds\"\nend", "def winner\n @players.each do |current_player|\n if current_player.position >= length\n #puts \"#{current_player.name} JUST WON!!!\"\n return \"#{current_player.name}\"\n end\n end\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def most_points_scored\n most_points_scored_helper\n most_point_player = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n most_point_player = element[:player_name]\n binding.pry\n end\n end\n end\n most_point_player\nend", "def most_rebound(player_name)\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n value.each do |player, detail|\r\n if player == player_name\r\n return detail[:rebounds]\r\n end\r\n end\r\n end\r\n end\r\n end\r\nend", "def num_points_scored(player_name)\n # if you were trying to explain this to someone in prework\n # who's stuck in hashketball, how would you explain how to do this?\n\n # find the num points scored as it relates to the name\n # we have all_players array\n # each value in all players has a smaller value that is the name of the player\n # that is also connected to the number of points they scored\n # find a way to sort the method / just find the value of points attributed to that name\n\n # hash of teams\n # visit each team\n # ask them for the player name list\n # check the list for the name\n # if i find it, then I have their points\n # I would return their points\n\n # argument pass in each player\n # try to return the amount of points associated with that player\n\n # pseudocode\n\n # i want all the players first <= simplify it ideally\n # home_players = game_hash[:home][:players]\n # away_players = game_hash[:away][:players]\n # all_players = home_players + away_players\n\n # so i can look through them\n # .each with an if\n # search, find, gofish\n # array of hashes\n # found_player = all_players.find do |player| # Hash\n # # find the player that matches the name\n # # binding.pry\n # # if player[:player_name] == player_name\n # # true\n # # else\n # # false\n # # end\n # player[:player_name] == player_name\n # end\n\n # get the points for that player\n found_player(player_name)[:points]\nend", "def most_points_scored\n most_points = 0 \n name = nil\n game_hash.each { |keys, values|\n i = 0\n while i < game_hash[keys][:players].length do \n if game_hash[keys][:players][i][:points] > most_points\n most_points = game_hash[keys][:players][i][:points]\n name = game_hash[keys][:players][i][:player_name]\n end\n i += 1\n end\n }\n name\n # binding.pry\nend", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def enough_human_players?\n players.length >= needed_players\n end", "def score\n p1_score = players.first.score \n p2_score = players[1].score\n\n if p1_score == p2_score\n score_word = SCORE_NUMBER_TO_WORD_MAP[0..-2][p1_score]\n return score_word ? score_word + \"-All\" : \"Deuce\"\n elsif p1_score <= 3 && p2_score <= 3\n return players.map{|player| SCORE_NUMBER_TO_WORD_MAP[player.score] }.join(\"-\")\n else\n winning_player = players.sort{|a, b| a.score <=> b.score}.last\n return (p1_score - p2_score).abs == 1 ? \"Advantage #{winning_player.name}\" : \"Win for #{winning_player.name}\"\n end\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def winner\n\t\ts = {}\n\t\[email protected] {|player|\n\t\t\ts[player.name.to_s] = player.score.totalScore\n\t\t}\n\t\tmax = s.values.max\n\t\tname = s.select{|k, v| v == max}.keys\n\t\tscore = s.select{|k, v| v == max}.values\n\t\t\n\t\tprint \"The winner is \" + name[0].to_s + \" with a total score of \" + score[0].to_s\n\t\tputs \"\",\"\"\n\t\t\n\tend", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def winner\n tie_string = \"\"\n @players.each do |player|\n if @position[player] == @length\n tie_string << \"#{player}\"\n end\n end\n\n if tie_string.length > 1\n return \"no one\"\n else\n return tie_string[0]\n end\n\n end", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def possessive(player_name)\n if player_name.downcase.ends_with?('s')\n player_name + \"'\"\n else\n player_name + \"'s\"\n end\n end", "def rebounds_for_player_with_largest_shoe_size(game)\n shoe_sizes_with_player_names = []\n game[:home_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n game[:away_team][:players].each do |player_hash|\n shoe_sizes_with_player_names << {player_hash[:player_name] => player_hash[:shoe_size]}\n end\n biggest_shoe_size = {\"test\" => 0}\n shoe_sizes_with_player_names.each do |shoe_size_and_name_hash|\n biggest_shoe_size = shoe_size_and_name_hash if shoe_size_and_name_hash.values[0] > biggest_shoe_size.values[0]\n end\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:rebounds] if player_hash[:player_name] == biggest_shoe_size.keys[0]\n end\nend", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def maximum_of_two_players\n # TODO implement\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def isBestPlayer(player,stats,gl)\n if stats[\"Value\"].to_f > @dropValue\n @dropValue = stats[\"Value\"].to_f\n @dropRec = \"#{player[\"name\"][\"first\"]} #{player[\"name\"][\"last\"]}\"\n end\n if stats[\"Value\"].to_f*gl > @dropValueW\n @dropValueW = stats[\"Value\"].to_f*gl\n @dropRecW = \"#{player[\"name\"][\"first\"]} #{player[\"name\"][\"last\"]}\"\n end\nend", "def get_player_name(name)\n return prompt(\"Player Name? [Player #{name}]\",\"Player #{name}\")\n end", "def winner\n @players.max_by{ |player| player.score}\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def most_expensive_player_on_team \n\n the_club = choose_club #user chooses club they want to see most expensive player for\n my_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n club_players = my_club.players.sort_by do |player| #loops through instance of club and sorts the players by their market value (remember to change market_value from string to integer)\n player.market_value.to_i\n end\n\n most_expensive_player = club_players.last #in ascending order the last item of the sorted array is the player with the highest market value\n puts \"#{the_club}'s most expensive player is #{most_expensive_player.name}. He is worth £#{most_expensive_player.market_value}M\"\n #the_club --> user choice of club name\n #most_expensive_player.name --> use the_club name to find the specific instance of Club class. \n #Use \".players\" method to find all player instances of that specifc club (the instances of players that \n #belong to that instance of club). Use \".name\" method to retrieve attribute \"name\" of player instance. \n #Use \".market_value\" to retrieve attribute \"market_value\" of the player instance. \n\nend", "def winner\n @players.max_by do |player|\n player.score\n end\n end", "def winner\n @player_positions.max_by{|player, position| position}[0]\n end", "def num_points_scored(name)\n # given an array of player data (hashes), find the one whose name matches\n # What is a player?\n\n ## iterate over the list of players\n ## Find the one whose `player_name` matches the name that we're looking for\n\n #binding.pry\n player = find_player(name)\n # find the number of points scored for that player\n #puts player[:points]\n player[:points]\nend", "def max_player\n return 1\n end", "def human_and_human_player(size)\n\t@player1 = \"player\"\n @player2 = \"player\"\nend", "def player_with_most(stat)\n value = nil\n owner = nil\n players.each do |player, stats|\n if value == nil || stats[stat] > value\n value = stats[stat]\n owner = player\n end\n end\n owner\nend", "def num_points_scored (player_name)\n lookup_by_player(player_name)[:points]; \nend", "def naming\n puts (\"Hello player #{@@player_count}. Please choose a name.\").blue\n name = gets.chomp\n @@player_count += 1\n return name\n end", "def num_points_scored(player_name)\n if !game_hash.keys.include?(:players)\n game_hash.each do |location, team_info|\n if team_info.keys.include?(:players)\n team_info.each do |attribute, quanity|\n if attribute == :players\n quanity.each do |name, stats|\n if name == player_name\n stats.each do |stat, quanity|\n if stat == :points\n return quanity\n end\n end\n end\n end\n end\n end\n end\n end\n end\nend", "def player_names(n)\n puts \"Player \" + n.to_s + \"! What is your name?\"\n return gets.chomp\n end", "def end_of_game (player)\n \"#{player_name(player)} loses! #{second_player_name(player)} is the winner (and may now gloat)!\"\nend", "def biggest_shoe(hashketball)\r\n player_number_with_biggest_shoe = \"\"\r\n biggest_shoe_size = 0\r\n \r\n hashketball[:home][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n hashketball[:away][:players].each do |name, player|\r\n if player[:shoe_size] > biggest_shoe_size\r\n player_number_with_biggest_shoe = name\r\n biggest_shoe_size = player[:shoe_size]\r\n end\r\n end\r\n \r\n \" #{player_number_with_biggest_shoe} : #{biggest_shoe_size} \"\r\nend", "def most_interesting_man_in_the_world; end", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def highestRemainLetterOf word\n word.gsub!('*','.').downcase!\n @incorrectWord = @missingWord - word.chars\n getHighestAbilityLetterFrom(Regexp.compile('^'+word+'$')).pop[0]\nend", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def num_points_scored_alt(name)\n if game_hash[:home][:players][name] != nil\n return game_hash[:home][:players][name][:points]\n elsif game_hash[:away][:players][name] != nil\n return game_hash[:away][:players][name][:points]\n else\n puts \"enter a valid name, yo!\"\n end\nend", "def won?\n longest_row(@player) >= 5\n end", "def num_points_scored(name)\n ## Version 2.0 ##\n\n # 1. get all of the player hashes\n players = get_all_players\n # 2. get the player's data who matches the given name\n player_data = players[name]\n # 3. get the points from that data\n player_data[:points]\nend", "def get_player_name(count)\n begin\n puts \"\"\n puts \"Enter Player #{count}'s name:\"\n\n temp = gets.chomp\n\n raise InvalidName if temp == \"\"\n\n self.name = temp\n\n rescue InvalidName\n puts \"You need to enter a player name.\"\n get_player_name(count)\n\n end\n end", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end" ]
[ "0.8404898", "0.8081119", "0.8045302", "0.79781646", "0.79124814", "0.77866083", "0.77182883", "0.76244104", "0.75691086", "0.754592", "0.75295967", "0.75148463", "0.7497775", "0.74806464", "0.74708986", "0.7452582", "0.7443772", "0.74157697", "0.74079156", "0.7401228", "0.7394187", "0.73245394", "0.73243165", "0.7303879", "0.7297082", "0.7294791", "0.7258293", "0.72264105", "0.7217096", "0.7201755", "0.6963965", "0.6962117", "0.68902105", "0.6872655", "0.68558764", "0.67803675", "0.6755673", "0.67048484", "0.66951585", "0.6625073", "0.6620985", "0.6508843", "0.64834064", "0.6448213", "0.6440433", "0.6405946", "0.637168", "0.636754", "0.6328712", "0.6261871", "0.62394667", "0.6238158", "0.6237609", "0.62171644", "0.61804354", "0.6174633", "0.6149588", "0.6148753", "0.61446", "0.61427456", "0.6138125", "0.6136393", "0.61330944", "0.611038", "0.6108144", "0.6081839", "0.60813135", "0.6079775", "0.60730726", "0.6072537", "0.60708493", "0.6062292", "0.6050199", "0.60478956", "0.6047748", "0.60373676", "0.60292584", "0.6020841", "0.6007221", "0.5999138", "0.59808487", "0.5979288", "0.5978886", "0.5936283", "0.5928484", "0.59237874", "0.59202665", "0.5907798", "0.590686", "0.58990866", "0.5884473", "0.58832073", "0.587616", "0.5867004", "0.5854505", "0.58540934", "0.58428717", "0.5838093", "0.5833309", "0.58225286" ]
0.66086143
41
=> "Ben Gordon" Returns team name which scored the most cumulative points
def winning_team final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player| case when next_player[:location] === :away teams_points[:away] += next_player[:points]; when next_player[:location] === :home teams_points[:home] += next_player[:points]; end teams_points; } winner = final_scores.reduce { |highest_points, team_points| highest_points[1] > team_points[1] ? highest_points : team_points; } game_hash[winner[0]][:team_name]; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def best_offense\n @teams.max_by { |team| team.average_goals_scored }.team_name\n end", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def most_points_scored\n most_points = 0\n most_points_player = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if most_points < player_stats[:points]\n most_points = player_stats[:points]\n most_points_player = player_stats[:player_name]\n end\n end\n end\n most_points_player\nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend", "def most_points_scored\n most_points_scored = 0\n player_with_the_most_points_scored = \"\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if most_points_scored == 0 || player_index[:points] > most_points_scored \n most_points_scored = player_index[:points]\n player_with_the_most_points_scored = player_index[:player_name]\n end\n end\n end\n end\n end\n end\n player_with_the_most_points_scored\nend", "def worst_offense\n @teams.min_by { |team| team.average_goals_scored }.team_name\n end", "def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend", "def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def most_points_scored\n most_points = 0 \n name = nil\n game_hash.each { |keys, values|\n i = 0\n while i < game_hash[keys][:players].length do \n if game_hash[keys][:players][i][:points] > most_points\n most_points = game_hash[keys][:players][i][:points]\n name = game_hash[keys][:players][i][:player_name]\n end\n i += 1\n end\n }\n name\n # binding.pry\nend", "def most_points_scored\n\tpoints_array = []\n\tgame_hash.each do |location, team_data|\n\t\tteam_data[:players].each do |attribute, data|\t\n\t\t\tdata.each do |type, amount|\n\t\t\t\tif type == :points\n\t\t\t\t\tpoints_array << amount\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend\n\tgame_hash.each do |l, data|\n\t\tdata[:players].each do |a, d|\n\t\t\td.each do |t, amt|\n\t\t\t\tif t == :points && points_array.max == amt\n\t\t\t\t\treturn a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def most_accurate_team(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season - given by arg\n #use above list to sum all shots across all games in season\n #divide above by goals made across all games in season\n #find highest percentage\n #return team name as found in 127\n end", "def most_points_scored\nplayer_with_most(:points)\nend", "def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end", "def best_fans\n @teams.max_by { |team| team.home_minus_away_percentage }.team_name\n end", "def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.max\n end", "def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def most_hits(seasonasstring) # shots in game team stats\n #get a list of all teams that played in that season\n #use above list to sum all shots across all games in season\n #find highest across list\n #return team name as found in 139\n end", "def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end", "def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end", "def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end", "def player_with_most_of(statistic)\r\n player_name = \"\"\r\n amount_of_stat = 0\r\n\r\n game_hash.each do |team, stats|\r\n stats[:players].each do |players|\r\n if players[statistic].is_a? String\r\n if players[statistic].length > player_name.length\r\n player_name = players[:player_name]\r\n end\r\n elsif players[statistic] > amount_of_stat\r\n amount_of_stat = players[statistic]\r\n player_name = players[:player_name]\r\n end\r\n end\r\n end\r\n\r\n player_name\r\nend", "def biggest_surprise(season)\n season = season.to_i\n @teams.max_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def player_with_most_of(statistic)\n player_name = nil\n amount_of_stat = 0\n\n game_hash.each do |team, game_data|\n game_data[:players].each do |player|\n if player[statistic].is_a? String\n if player[statistic].length > amount_of_stat\n amount_of_stat = player[statistic].length\n player_name = player[:player_name]\n end\n elsif player[statistic] > amount_of_stat\n amount_of_stat = player[statistic]\n player_name = player[:player_name]\n end\n end\n end\n\n player_name\nend", "def most_points(game)\n player_name_with_points = []\n game[:home_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n game[:away_team][:players].each do |player_hash|\n player_name_with_points << {player_hash[:player_name] => player_hash[:stats][:points]}\n end\n player_most_points = {\"test\" => 0}\n player_name_with_points.each do |name_and_points_hash|\n player_most_points = name_and_points_hash if name_and_points_hash.values[0] > player_most_points.values[0]\n end\n player_most_points.keys[0]\nend", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def lowest_scoring_visitor\n @teams.min_by { |team| team.average_away_goals }.team_name\n end", "def most_points_scored\n mostPoints[0]\nend", "def num_points_scored(str)\n # get number of points for named player\n game_hash.values.map do |teams|\n if teams[:players].include?(str)\n teams[:players][str][:points]\n end\n end.compact.join.to_i\nend", "def num_points_scored(player_name)\n # if you were trying to explain this to someone in prework\n # who's stuck in hashketball, how would you explain how to do this?\n\n # find the num points scored as it relates to the name\n # we have all_players array\n # each value in all players has a smaller value that is the name of the player\n # that is also connected to the number of points they scored\n # find a way to sort the method / just find the value of points attributed to that name\n\n # hash of teams\n # visit each team\n # ask them for the player name list\n # check the list for the name\n # if i find it, then I have their points\n # I would return their points\n\n # argument pass in each player\n # try to return the amount of points associated with that player\n\n # pseudocode\n\n # i want all the players first <= simplify it ideally\n # home_players = game_hash[:home][:players]\n # away_players = game_hash[:away][:players]\n # all_players = home_players + away_players\n\n # so i can look through them\n # .each with an if\n # search, find, gofish\n # array of hashes\n # found_player = all_players.find do |player| # Hash\n # # find the player that matches the name\n # # binding.pry\n # # if player[:player_name] == player_name\n # # true\n # # else\n # # false\n # # end\n # player[:player_name] == player_name\n # end\n\n # get the points for that player\n found_player(player_name)[:points]\nend", "def most_points_scored_helper\n point_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n point_array << element[:point]\n end\n end\n point_array.max\nend", "def highest_total_score\n total_goals.max\n end", "def winning_team\n most_points_scored_helper\n winning_team = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n winning_team = value[:team_name]\n end\n end\n end\n winning_team\nend", "def player_with_longest_name\n longest_name = 0\n longest_player_name = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if longest_name < player_stats[:player_name].length\n longest_name = player_stats[:player_name].length\n longest_player_name = player_stats[:player_name]\n end\n end\n end\n longest_player_name\nend", "def biggest_bust(seasonasstring)\n #get all teams in data\n #find all games played by team in season - given by arg\n #get subset of 95 where p is in season marker\n #count games won in subset on 95 / total games in subset on 95\n #get subset of 85 where r is in season marker\n #count games won in subset on 98 / total games in subset on 98\n #result of line 97 - line 99\n #find highest number\n #return team name of result of line 101\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def num_points_scored (name)\n gh=game_hash\n gh.each do |team, stats|\n stats[:players].each_key do |nameval|\n if (nameval==name)\n return gh[team][:players][nameval][:points]\n end\n end\n end\nend", "def best_offense\n offense_suite\n best_offense_id = @average_goals_by_id.invert.max[1]\n @team_name_by_id[best_offense_id]\n end", "def most_points_scored\n most_points_scored_helper\n most_point_player = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_points_scored_helper == element[:points]\n most_point_player = element[:player_name]\n binding.pry\n end\n end\n end\n most_point_player\nend", "def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend", "def ranked_teams_string(a_ranked_teams)\n\n ranked_string = ''\n rank = 1\n previous_team_points = a_ranked_teams[0].points\n a_ranked_teams.each do |team|\n if team.points < previous_team_points\n # This team isn't tied. Advance rank.\n # After ties, increment by more than 1 e.g. 1, 2, 3, 3, 5 not 1, 2, 3, 3, 4\n # add 1 because array index starts at 0, rank starts at 1.\n rank = a_ranked_teams.index(team) + 1\n end\n\n points_abbreviation = 'pts'\n if 1 == team.points\n points_abbreviation = 'pt'\n end\n\n # Assume we want to use newline \\n at end of each line as specified in expected-output.txt\n # Alternatively could use File write line to get system dependent line ending.\n ranked_string.concat(\"#{rank}. #{team.name}, #{team.points} #{points_abbreviation}\\n\")\n\n previous_team_points = team.points\n end\n\n ranked_string\n end", "def fewest_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.min\n end", "def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end", "def player_with_most_steals\n name = \"\"\n most_steals = 0\n\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n players_array.each do | player_details_hash |\n if player_details_hash[:steals] > most_steals\n most_steals = player_details_hash[:steals]\n name = player_details_hash[:player_name]\n end\n end\n end\n name\nend", "def num_points_scored(player_name)\n if !game_hash.keys.include?(:players)\n game_hash.each do |location, team_info|\n if team_info.keys.include?(:players)\n team_info.each do |attribute, quanity|\n if attribute == :players\n quanity.each do |name, stats|\n if name == player_name\n stats.each do |stat, quanity|\n if stat == :points\n return quanity\n end\n end\n end\n end\n end\n end\n end\n end\n end\nend", "def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.team_name\n end", "def num_points_scored(name)\n game_hash.each do | team, team_data_hash |\n team_data_hash.each do | attribute, data |\n if attribute == :players\n data.each do | player, player_data_hash |\n if player == name\n return game_hash[team][attribute][player][:points]\n end\n end\n end\n end\n end\nend", "def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend", "def winning_team\n self.teams.order('score DESC').first\n end", "def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend", "def num_points_scored(player_name)\n player_points = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if player_stats[:player_name] == player_name\n player_points = player_stats[:points]\n end\n end\n end\n player_points\nend", "def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend", "def num_points_scored(name)\n game_hash().each do |location, team_data|\n team_data[:players].each do |player_name, player_stat|\n if name == player_name\n return player_stat[:points]\n end\n end\n end\nend", "def num_points_scored(name)\n game_hash.each do |team, attributes|\n game_hash[team][:players].each do |player, stats|\n if name == player \n return game_hash[team][:players][name][:points]\n end\n end\n end\nend", "def long_name_steals_a_ton?()\n\n def most_steals()\n steals = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:steals] > steals\n steals = player[:steals]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\n end\n\n return player_with_longest_name() == most_steals()\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def worst_offense\n teams_total_goals = total_goals_helper\n teams_total_games = total_games_helper\n\n worst_team_goals_avg = 1000\n worst_offense_team_id = 0\n this_team_goals_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_avg = (goals_value / games_value.to_f)\n if this_team_goals_avg < worst_team_goals_avg\n worst_team_goals_avg = this_team_goals_avg\n worst_offense_team_id = games_key\n end\n end\n end\n end\n\n team_with_worst_offense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == worst_offense_team_id\n team_with_worst_offense = team_obj.team_name\n end\n end\n team_with_worst_offense\n end", "def most_expensive_player_on_team \n\n the_club = choose_club #user chooses club they want to see most expensive player for\n my_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n club_players = my_club.players.sort_by do |player| #loops through instance of club and sorts the players by their market value (remember to change market_value from string to integer)\n player.market_value.to_i\n end\n\n most_expensive_player = club_players.last #in ascending order the last item of the sorted array is the player with the highest market value\n puts \"#{the_club}'s most expensive player is #{most_expensive_player.name}. He is worth £#{most_expensive_player.market_value}M\"\n #the_club --> user choice of club name\n #most_expensive_player.name --> use the_club name to find the specific instance of Club class. \n #Use \".players\" method to find all player instances of that specifc club (the instances of players that \n #belong to that instance of club). Use \".name\" method to retrieve attribute \"name\" of player instance. \n #Use \".market_value\" to retrieve attribute \"market_value\" of the player instance. \n\nend", "def num_points_scored(players_name)\n game_hash.each do |place, team|\n team.each do |attr, data|\n if attr == :players\n data.each do |player|\n if player[:player_name] == players_name\n return player[:points]\n end\n end\n end\n end\n end\nend", "def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend", "def num_points_scored (player_name)\n points_scored = nil\n\n game_hash.each do |team, team_information_hash|\n players_array = team_information_hash[:players]\n players_array.each do |player_information_hash|\n if player_information_hash[:player_name] == player_name\n points_scored = player_information_hash[:points]\n end\n end\n end\n points_scored\nend", "def winner(game)\nwinner = \"\"\nwinner_points = 0\n game.each do |team, team_contents|\n total = 0\n team_contents[:roster].each do |player, player_contents| \n total += player_contents[:points]\n end\n if total > winner_points\n winner = team_contents[:team_name]\n winner_points = total\n elsif total == winner_points\n winner = \"tie\"\n end\n end\n\n if winner == \"tie\"\n puts \"The game was a tie, with each team scoring #{winner_points} points\"\n else\n puts \"#{winner} scored #{winner_points} points and won the game\"\n end\nend", "def rank_top_teams # DO NOT USE THIS METHOD, outdated, slow\n @top_teams = {}\n @top_teams = Score.in_challenge(self.id).teams_in_all_divisions.limit(5).\n order(\"sum_points DESC, MAX(#{Score.table_name}.\n earned_at) DESC\").sum(:points) \n return @top_teams\n end", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\nend", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def num_points_scored(name)\n answer = nil\n game_hash.each do |team_key,team_value|#iterate down one level\n players_stats = team_value[:players]#set the \"value\" for players to a variable\n players_stats.each do |players_details|\n if players_details[:name] == name #compares the value at \"key:name\" to the argument name\n answer = players_details[:points]#selects value at \"key:points\" to variable answer\n end\n end\n end\n answer\nend", "def num_points_scored(player_name)\n points_scored = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if player_name == element[:player_name]\n points_scored = element[:points]\n end\n end\n end\n points_scored\nend", "def score_for_team(team)\n team ||= winner_team\n winner_team?(team) ? score : scores.reverse.join(':')\n end", "def highest_scoring_word\n Scrabble::Scoring.highest_score_from(@plays_array)\n end", "def num_points_scored (name)\n points_scored = 0\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n\n players_array.each do | player_details_hash |\n\n if player_details_hash[:player_name] == name\n points_scored = player_details_hash[:points]\n end\n end\n end\n points_scored\nend", "def highest_score\n sorted_all_scores = self.leaderboard_entries.order(score: :DESC)\n sorted_all_scores[0]\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def num_points_scored(player_name)\n result = nil\n game_hash.each do |team, about|\n about[:players].each do |name, stats|\n if player_name == name\n result = stats[:points]\n end\n end\n end\n result\nend", "def best_defense\n teams_total_goals_allowed = total_goals_allowed_helper\n teams_total_games = total_games_helper\n\n best_team_goals_allowed_avg = 100\n best_defense_team_id = 0\n this_team_goals_allowed_avg = 0\n\n teams_total_games.each do |games_key, games_value|\n teams_total_goals_allowed.each do |goals_key, goals_value|\n if goals_key == games_key\n this_team_goals_allowed_avg = (goals_value / games_value.to_f)\n if this_team_goals_allowed_avg < best_team_goals_allowed_avg\n best_team_goals_allowed_avg = this_team_goals_allowed_avg\n best_defense_team_id = games_key\n end\n end\n end\n end\n\n team_with_best_defense = nil\n self.teams.each_value do |team_obj|\n if team_obj.team_id. == best_defense_team_id\n team_with_best_defense = team_obj.team_name\n end\n end\n team_with_best_defense\n end", "def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def long_name_steals_a_ton?\n highest_number_steals = 0\n player_most_steals = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if highest_number_steals < player_stats[:steals]\n highest_number_steals = player_stats[:steals]\n player_most_steals = player_stats[:player_name]\n end\n end\n end\n if player_most_steals == player_with_longest_name\n true\n else\n false\n end\nend", "def long_name_steals_a_ton?\n steals = 0\n most_steals = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if steals < stats[:steals]\n steals = stats[:steals]\n most_steals = name\n end\n end\n end\n most_steals == player_with_longest_name\nend", "def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend", "def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\n\n nba_match\nend", "def worst_coach(seasonasstring) # coach name in game team stats\n #inverse of above\n end", "def get_full_name\n \"#{get_team_name}: #{total_individual_points} + #{total_relay_points}\"\n end", "def num_points_scored(player_name)\n\n game_hash.each do |team, team_data|\n team_data[:players].each do |player|\n if player[:player_name] == player_name\n return player[:points]\n end\n end\n end\n\n # SOLUTION 3\n # get a list of all the players\n # all_players = game_hash.values.collect do |team|\n # team[:players]\n # end.flatten\n\n # find the player whose name matches the argument 'player_name'\n # return that player's points\n # all_players.each do |player|\n # return player[:points] if player[:player_name] == player_name\n # end\nend", "def winning_team\n nets = []\n hornets = []\n\n game_hash.values.each do |nets_stats|\n if nets_stats[:team_name] == \"Brooklyn Nets\"\n nets_stats[:players].each do |bk|\n nets << bk[:points]\n end\n end\n end\n\n game_hash.values.each do |hornets_stats|\n if hornets_stats[:team_name] == \"Charlotte Hornets\"\n hornets_stats[:players].each do |ch|\n hornets << ch[:points]\n end\n end\n end\n\n if nets.reduce(:+) > hornets.reduce(:+)\n return \"Brooklyn Nets\"\n else\n return \"Charlotte Hornets\"\n end\nend", "def num_points_scored(player_name)\n points = nil\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n binding.pry\n if name == player_name\n points = team_data[:players][player_name][:points]\n end\n end\n end\n points\n end", "def num_points_scored(player_name)\npoints_scored = 0\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player, stats|\n if player == player_name\n points_scored = stats[:points]\n end\n end\n end\n end\nend\npoints_scored\nend", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def num_points_scored(name)\n # given an array of player data (hashes), find the one whose name matches\n # What is a player?\n\n ## iterate over the list of players\n ## Find the one whose `player_name` matches the name that we're looking for\n\n #binding.pry\n player = find_player(name)\n # find the number of points scored for that player\n #puts player[:points]\n player[:points]\nend", "def num_points_scored(player_name)\n this_player = player_name\n game_hash.each do |team, team_data|\n team_data[:players].each do |player_name, player_data|\n if player_name == this_player\n return player_data[:points]\n #over thought it, got stuck too long.\n end\n end\n end\n end", "def this_teams_top_players(number_of_players)\n \tnfl_players.order(:points).last(number_of_players)\n end", "def get_max_past_teammates(participant)\n past_team_associations = TeamsUser.find_all_by_user_id(participant.user_id)\n past_team_associations -= TeamsUser.find_all_by_team_id(id)\n past_team_ids = past_team_associations.map{|association| association.team_id}\n past_teams = past_team_ids.map{|team_id| Team.find_by_id(team_id)}\n past_assignments = past_teams.map{|team| Assignment.find_by_id(team.parent_id)}\n past_assignments.delete_if {|assignment| assignment.course_id != Assignment.find_by_id(parent_id).course_id}\n return past_assignments.inject(0) {|sum, assignment| sum += assignment.team_count - 1}\n end", "def num_points_scored(name)\n # 1. write out what I want to do here\n # 2. write out the ideal code for this\n\n ## Version 2.0 ##\n\n # 1. get all of the player hashes\n players = get_all_players\n # some imaginary method that will give us all the players from both teams\n\n # 2. get the player's data who matches the given name\n player_data = players[name]\n # since the keys are the player names, we can get the player's data\n # out of the hash by accessing it like this\n\n # 3. get the points from that data\n player_data[:points]\n # finally, with the player_data, we can grab out just the value we want\n # and return it (points)\nend", "def num_points_scored(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n if data.keys.include?(player_name)\n return data[player_name][:points]\n end\n end\n end\n end\nend" ]
[ "0.7706059", "0.7685398", "0.7620051", "0.76162976", "0.76155096", "0.758842", "0.7455333", "0.74161637", "0.73677474", "0.7350155", "0.7310132", "0.7277706", "0.72298926", "0.72163904", "0.718598", "0.7174886", "0.71062326", "0.7043164", "0.7004782", "0.6985479", "0.6944278", "0.6930221", "0.688383", "0.68576956", "0.685744", "0.6846494", "0.6825529", "0.6808837", "0.67957294", "0.6704427", "0.66811323", "0.6677108", "0.66590905", "0.664598", "0.6618714", "0.659258", "0.65448385", "0.6535173", "0.6502716", "0.6489214", "0.64855844", "0.6470365", "0.6469884", "0.6452574", "0.64525557", "0.645208", "0.6447896", "0.64291686", "0.640496", "0.6395329", "0.63941", "0.6393183", "0.6380371", "0.63757724", "0.6375738", "0.6347957", "0.63474536", "0.634372", "0.63176376", "0.6313529", "0.63062215", "0.62990326", "0.6283973", "0.62754315", "0.6262467", "0.6254348", "0.62517047", "0.6245997", "0.62362725", "0.6235862", "0.6232559", "0.6231674", "0.6222102", "0.62155634", "0.6210624", "0.6203397", "0.61899084", "0.6187381", "0.6187163", "0.61813915", "0.6178814", "0.6172034", "0.6171281", "0.61661917", "0.6139354", "0.61371434", "0.6134768", "0.6134522", "0.61272293", "0.61242974", "0.61241835", "0.6123957", "0.6117186", "0.61150736", "0.6114202", "0.6111252", "0.6109179", "0.61023176", "0.6097757", "0.6093574" ]
0.6311421
60
Returns name of player with the most characters
def player_with_longest_name player_collection.reduce { |longest_name, next_player| longest_name[:player_name].length > next_player[:player_name].length ? longest_name : next_player; }[:player_name]; #probably easier to read to declare variable, however, good to know this works. end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player_with_longest_name\n players.keys.sort_by { |name| name.length }[-1]\nend", "def player_with_longest_name\n longestName.max_by(&:length)\nend", "def player_with_longest_name\n max_name = 0\n player_name = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |name|\n if name.length > max_name\n max_name = name.length\n player_name = name\n end\n end\n end\n player_name\nend", "def longestName\n players.collect do|name, stats|\n name\n end\nend", "def player_with_longest_name\n array = []\n array2 = []\n max_name = \"\"\n game_hash.collect do |location, team_data|\n team_data[:players].keys.collect do |name|\n array << name\n array2 << name.length\n end\n end\n\t max = array2.max\n array.collect do |name|\n if \tname.length == max\n max_name = name\n end\n end\n max_name\n end", "def player_with_longest_name\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |i, j|\r\n result[i]=i.length\r\n end\r\n end\r\n end\r\n end\r\n result.max_by {|name, len| len}[0].to_s\r\n end", "def player_with_longest_name\n name_size = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if name_size < name.size\n result = name\n end\n end\n end\n result\nend", "def player_with_longest_name\n long_name = \"\"\n name = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n name << element[:player_name]\n end\n end\n long_name = name.max\nend", "def player_with_longest_name\n longest_name = 0\n longest_player_name = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if longest_name < player_stats[:player_name].length\n longest_name = player_stats[:player_name].length\n longest_player_name = player_stats[:player_name]\n end\n end\n end\n longest_player_name\nend", "def player_with_longest_name\n longest = ''\n longest_length = 0\n game_hash.each do |home_away, keys|\n keys[:players].each do |player|\n name_length = player[:player_name].length\n longest, longest_length = player[:player_name], name_length if name_length > longest_length\n end\n end\n return longest\nend", "def player_with_longest_name()\ncount = 0\nresult = \"\"\n\ngame_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n\n if player[:player_name].length > count\n count = player[:player_name].length\n result = player[:player_name]\n\n end\n end\n end\n end\nend\nresult\nend", "def player_with_longest_name\n longest_name = 0\n the_player = \"\"\n\n game_hash.each do |location, team_data|\n team_data[:players].each do |name,stats|\n if (name.size > the_player.size)\n the_player = name\n end #if\n end #team_data\n end #game_hash\n the_player\n\nend", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def player_with_longest_name\n longest_name = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name].length > longest_name.length\n longest_name = e[:player_name]\n end\n end\n end\n longest_name\nend", "def longest_name(game)\nmax_length = 0\nmax_length_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:player_name].length > max_length\n max_length = player_contents[:player_name].length\n max_length_player = player_contents[:player_name]\n elsif player_contents[:player_name].length == max_length\n max_length_player += max_length_player \" and #{player_contents[:player_name]}\"\n end\n end\nend\nmax_length_player\nend", "def long_name_steals_a_ton?\n player_with_most(:steals) == player_with_longest_name\nend", "def player_with_most_of(statistic)\r\n player_name = \"\"\r\n amount_of_stat = 0\r\n\r\n game_hash.each do |team, stats|\r\n stats[:players].each do |players|\r\n if players[statistic].is_a? String\r\n if players[statistic].length > player_name.length\r\n player_name = players[:player_name]\r\n end\r\n elsif players[statistic] > amount_of_stat\r\n amount_of_stat = players[statistic]\r\n player_name = players[:player_name]\r\n end\r\n end\r\n end\r\n\r\n player_name\r\nend", "def get_longest_snp_name\n name = \"\"\n\t\tmax_length = 0\n chromhash.each_value do |chrom|\n if chrom.get_max_snp_name > max_length\n max_length = chrom.get_max_snp_name\n\t\t\t\tname = chrom.get_longest_snp_name\n end\n end\n return name\t\t\n\tend", "def long_name_steals_a_ton?()\n\n def most_steals()\n steals = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:steals] > steals\n steals = player[:steals]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\n end\n\n return player_with_longest_name() == most_steals()\nend", "def select_name_and_motto_of_char_with_longest_motto\n \"SELECT characters.name, characters.motto\n FROM characters\n ORDER BY LENGTH(characters.motto) DESC LIMIT 1;\"\nend", "def player_with_most_of(statistic)\n player_name = nil\n amount_of_stat = 0\n\n game_hash.each do |team, game_data|\n game_data[:players].each do |player|\n if player[statistic].is_a? String\n if player[statistic].length > amount_of_stat\n amount_of_stat = player[statistic].length\n player_name = player[:player_name]\n end\n elsif player[statistic] > amount_of_stat\n amount_of_stat = player[statistic]\n player_name = player[:player_name]\n end\n end\n end\n\n player_name\nend", "def max_player\n return 1\n end", "def long_name_steals_a_ton?\n # find player with longest name\n # find player with most steals\n # are they the same? if so return true\n player_with_most_steals = players.max_by { |player| player[:steals]}\n player_with_longest_name == player_with_most_steals[:player_name] ? true : false\nend", "def name_length\n name.length\n end", "def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend", "def num_chars\n @name.split('').count\n end", "def long_name_steals_a_ton?\n max_steals = 0\n player_name = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |name|\n if game_hash[location][:players][name][:steals] > max_steals\n max_steals = game_hash[location][:players][name][:steals]\n player_name = name\n end\n end\n end\n player_name == player_with_longest_name\nend", "def long_name_steals_a_ton?\n steals = 0\n most_steals = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if steals < stats[:steals]\n steals = stats[:steals]\n most_steals = name\n end\n end\n end\n most_steals == player_with_longest_name\nend", "def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend", "def long_name_steals_a_ton \n long_name_player = player_collection.reduce { |longest_name, next_player|\n longest_name[:player_name].length > next_player[:player_name].length ? longest_name : next_player; \n }\n most_steals_player = player_collection.reduce { |most_steals, next_player|\n most_steals[:steals] > next_player[:steals] ? most_steals : next_player; \n }\n long_name_player === most_steals_player; \nend", "def get_max_snp_name\n max_name = 0\n chromhash.each_value do |chrom|\n if chrom.get_max_snp_name > max_name\n max_name = chrom.get_max_snp_name\n end\n end\n return max_name\n end", "def most_frequent_letter(string)\nend", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def player_with_longest_name\nlongest_name = \"\"\ngame_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if longest_name == \"\" || player_index[:player_name] > longest_name \n longest_name = player_index[:player_name]\n longest_name = player_index[:player_name]\n end\n end\n end\n end\n end\nend\nlongest_name\nend", "def select_series_title_with_most_human_characters\n \"SELECT series.title FROM characters INNER JOIN series ON series.id = characters.series_id GROUP BY(characters.species) ORDER BY(COUNT(characters.species)) LIMIT 1;\"\nend", "def highest_scoring_word\n word = Scrabble::Scoring.highest_score_from(plays)\n return word\n end", "def max_position\n @words.first[1].length\n end", "def item_max\n $game_party.battle_members.size\n end", "def long_name_steals_a_ton?\n most_steals = 0\n leading_stealer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:steals] > most_steals\n most_steals = player[:steals]\n leading_stealer = player[:player_name]\n end\n end\n end\n if leading_stealer == player_with_longest_name\n return true\n end\n end", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def most_points_scored\nplayer_with_most(:points)\nend", "def select_series_title_with_most_human_characters\n \"SELECT series.title\n FROM series\n JOIN characters\n ON series.id = characters.series_id\n WHERE characters.species = 'human'\n GROUP BY series.title\n ORDER BY COUNT(characters.species) DESC LIMIT 1;\"\nend", "def long_name_steals_a_ton?\n most_steal\n player_with_longest_name\n most_steal_player = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_steal == element[:steals]\n most_steal_player = element[:player_name]\n end\n end\n end\n player_with_longest_name.eql?(most_steal_player)\nend", "def winner\n @players.each do |current_player|\n if current_player.position >= length\n #puts \"#{current_player.name} JUST WON!!!\"\n return \"#{current_player.name}\"\n end\n end\n end", "def highest_scoring_word\n return Scrabble::Scoring.highest_score_from(@plays)\n end", "def highestRemainLetterOf word\n word.gsub!('*','.').downcase!\n @incorrectWord = @missingWord - word.chars\n getHighestAbilityLetterFrom(Regexp.compile('^'+word+'$')).pop[0]\nend", "def item_max\r\n $game_troop.alive_members.size\r\n end", "def player_with_longest_name_also_had_most_steals?(game)\n player_longest_name(game) == most_steals(game)\nend", "def long_name_steals_a_ton?\n highest_number_steals = 0\n player_most_steals = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if highest_number_steals < player_stats[:steals]\n highest_number_steals = player_stats[:steals]\n player_most_steals = player_stats[:player_name]\n end\n end\n end\n if player_most_steals == player_with_longest_name\n true\n else\n false\n end\nend", "def biggest()\n @size = 0\n @name = \"\"\n\n # this is faster than doing it in Ruby\n this_dir = `du -x --max-depth 1`\n # break into lines\n dir_lines = this_dir.split(\"\\n\")\n # break into size/name pair\n dir_lines.each do |y|\n s,n = y.split(\"./\")\n s = s.to_i\n # avoid current directory. only look at subs\n if n\n if (s > @size)\n @size = s\n @name = n\n end\n end\n end\nreturn @name\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend", "def maxchar (str)\n var = str.split(\"\")\n\n empty = {}\n\n var.each do |key|\n if empty[key.to_sym].nil?\n empty[key.to_sym] = 1\n else\n empty[key.to_sym] = empty[key.to_sym] + 1\n end\n end\n\n test_value = 0\n @most_char = []\n empty.each do |key, value|\n if value > test_value\n test_value = value\n @most_char = key.to_s\n elsif value == test_value #if they are multiple chars with same number of occurence\n test_value = value\n @most_char << \" and \" + key.to_s\n end\n end\n \n return @most_char\nend", "def get_most_used_letter(word)\n\t\tletter_counts = Hash.new(0)\n\t\tword.each do |letter|\n\t\t\tletter_counts[letter] += 1\n\t\tend\n\n\t\tmax_letter = \"\"\n\t\tmax_letter_count = 0\n\t\tletter_counts.each do |letter, count| \n\t\t\tif(count > max_letter_count)\n\t\t\t\tmax_letter_count = count\n\t\t\t\tmax_letter = letter\n\t\t\tend\n\t\tend\n\n\t\tmax_letter\t\t\n\tend", "def largest_property_name(properties)\n if properties.empty?\n 6 # we'll include \"action\" even without properties and it's 6 chars long\n else\n properties.max_by { |x| x[\"name\"].size }[\"name\"].size\n end\n end", "def select_series_title_with_most_human_characters\n \"\n SELECT series.title\n FROM series\n JOIN characters\n ON characters.series_id = series.id\n GROUP BY series.title, characters.species\n HAVING characters.species = 'human'\n ORDER BY COUNT(characters.species) DESC\n LIMIT 1\n \"\nend", "def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend", "def long_name_steals_a_ton?\n longest_name = player_with_longest_name()\n player_name_with_most_steals = player_with_most_steals()\n\n if longest_name == player_name_with_most_steals\n return true\n end\n false\nend", "def item_max\r\n $game_party.members.size\r\n end", "def item_max\n $game_party.members.size\n end", "def item_max\n $game_party.members.size\n end", "def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend", "def most_points_scored\n max = nil\n name = nil \n game_hash.each do |team, team_values|\n team_values[:players].each do |player|\n if max == nil || player[:points] > max\n max = player[:points]\n name = player[:player_name]\n end\n end\n end\n name\nend", "def most_points_scored\n most_points = 0\n player = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:points] > most_points\n most_points = e[:points]\n player = e[:player_name]\n end\n end\n end\n player\nend", "def std_player_names\n\t\tnames = []\n\t\tfor i in 1..Constants::MAX_PLAYERS\n\t\t\tnames << \"Player\" + i.to_s\n\t\tend\n\t\tnames\n\tend", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def num_characters\n Character.all.select {|character| character.actor == self}.size\n end", "def get_namecoin_name\n return @chunks[-10] if is_name_firstupdate?\n return @chunks[-9] if is_name_update?\n end", "def winner\n tie_string = \"\"\n @players.each do |player|\n if @position[player] == @length\n tie_string << \"#{player}\"\n end\n end\n\n if tie_string.length > 1\n return \"no one\"\n else\n return tie_string[0]\n end\n\n end", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def most_wrs\n @mode = params.fetch(:mode, -1).to_i\n @mode = -1 unless @mode.between?(0, 3)\n @players = WorldRecord.most_world_records @mode\n end", "def max_players\n config[:max_players].to_i\n end", "def long_name_steals_a_ton?\n name_length = 0\n longest_name = \"\"\n steals = []\n top_stealer = \"\"\n\n game_hash.collect do |location, team_info|\n team_info[:players].collect do |name, stats|\n steals << stats[:steals]\n if stats[:steals] == steals.sort[-1]\n top_stealer = name\n end\n if name.length > name_length\n longest_name = name\n end\n end\n end\n\n if longest_name == top_stealer\n true\n else\n false\n end\n\nend", "def highest_scoring_word\n Scrabble::Scoring.highest_score_from(@plays_array)\n end", "def get_last_character_please of_this_string\n return of_this_string[of_this_string.length - 1]\n end", "def get_player_name(count)\n begin\n puts \"\"\n puts \"Enter Player #{count}'s name:\"\n\n temp = gets.chomp\n\n raise InvalidName if temp == \"\"\n\n self.name = temp\n\n rescue InvalidName\n puts \"You need to enter a player name.\"\n get_player_name(count)\n\n end\n end", "def find_the_most_letter_a(array)\n most_as = 0\n most_as_string = \"\"\n array.each_with_index do |string,i|\n a = 0\n string.each_char do |char|\n if char.downcase == \"a\"\n a +=1\n end\n end\n if a > most_as\n most_as = a\n most_as_string = array[i]\n end\n\n end\n most_as_string\nend", "def max_suffix_value\n related_names_in_use.map { |match| match.captures.first.to_i }.max\n end", "def naming\n puts (\"Hello player #{@@player_count}. Please choose a name.\").blue\n name = gets.chomp\n @@player_count += 1\n return name\n end", "def last_position\n self.players.maximum(:position)\n end", "def full_name_length(length)\n \n full = \"#{self.name} #{self.last_name}\"\n \n if full.length <= length.to_i\n full\n else\n full[0,length.to_i]+\"...\"\n end\n end", "def most_points_scored\n most_points = 0 \n name = nil\n game_hash.each { |keys, values|\n i = 0\n while i < game_hash[keys][:players].length do \n if game_hash[keys][:players][i][:points] > most_points\n most_points = game_hash[keys][:players][i][:points]\n name = game_hash[keys][:players][i][:player_name]\n end\n i += 1\n end\n }\n name\n # binding.pry\nend", "def name_too_long\n name.length > Account::DISPLAY_NAME_LIMIT\n end", "def higher_chars(char)\n ROMAN_CHARS.split(char)[1]\n end", "def highest_word_score\n Scrabble::Scoring.score(Scrabble::Scoring.highest_score_from(@plays_array))\n end", "def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end", "def player_with_most(stat)\n value = nil\n owner = nil\n players.each do |player, stats|\n if value == nil || stats[stat] > value\n value = stats[stat]\n owner = player\n end\n end\n owner\nend", "def longest_entry(words)\n return words.max_by(&:length)\n end", "def longest_pause(sentence)\n longest_pause = nil\n sentence.delete!(\",'.\")\n sentence.split.each do |word|\n if word.include?(\"um\")\n if longest_pause == nil || word.length > longest_pause.length\n longest_pause = word\n end\n end\n end\n longest_pause.length\nend", "def name\n \"Player#{@ix}\"\n end", "def max_battle_members\n [MAX_BATTLE_MEMBERS_VARIABLE == -1 ? MAX_BATTLE_MEMBERS : $game_variables[MAX_BATTLE_MEMBERS_VARIABLE], 1].max\n end", "def select_series_title_with_most_human_characters\n \"SELECT series.title\n FROM series\n INNER JOIN characters\n ON series.id = characters.series_id\n GROUP BY series.title\n HAVING characters.species = \\'human\\'\"\nend", "def highest_scoring_word\n Scoring.highest_score_from(plays)\n end", "def account_card_title\n name_too_long ? name[0..Account::DISPLAY_NAME_LIMIT] + '...' : name\n end", "def highest_player_score\n players.max_by{|player| player.score}.score\n end", "def most_chars(str)\n hash = Hash.new(0)\n str.each_char { |chr| hash[chr] += 1 if chr != ' ' }\n \n hi_chr = ''\n count = 0\n hash.each do |k, v|\n if v > count\n hi_chr, count = k, v\n end\n end\n \n hi_chr\nend", "def biggest_bust(season)\n season = season.to_i\n @teams.min_by{ |team| team.preseason_to_regular_increase[season] }.team_name\n end", "def largest_shoes(game)\nmax_shoes = 0\nrebounds = 0\nmax_shoes_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:shoe_size] == max_shoes\n max_shoes_player = max_shoes_player + \" and #{player_contents[:player_name]}\"\n rebounds = player_contents[:rebounds]\n elsif player_contents[:shoe_size] > max_shoes\n max_shoes = player_contents[:shoe_size]\n max_shoes_player = player_contents[:player_name]\n rebounds = player_contents[:rebounds]\n end\n end\nend\nputs \"#{max_shoes_player} has size #{max_shoes} shoes and #{rebounds} rebounds\"\nend", "def print_short_names(names, max_letters=12)\n\n puts \"All names shorter than %i characters\" % max_letters\n names.select {|anyname| anyname[:name].length < max_letters}.each_with_index do |name, index|\n print_name(name, index)\n end\nend", "def enough_human_players?\n players.length >= needed_players\n end" ]
[ "0.7885582", "0.7850679", "0.7775609", "0.74523056", "0.7401727", "0.73853225", "0.7381373", "0.73366386", "0.72873074", "0.7276021", "0.7271516", "0.72666633", "0.7263492", "0.7138735", "0.7015085", "0.6884869", "0.67687607", "0.6742015", "0.65812135", "0.6554715", "0.65330356", "0.6530767", "0.6526611", "0.6436696", "0.6398992", "0.6370286", "0.6361189", "0.63420576", "0.6332359", "0.6315407", "0.6309922", "0.6245437", "0.6231451", "0.6220874", "0.62139684", "0.6204407", "0.61762744", "0.61693573", "0.6153493", "0.61463475", "0.61107", "0.6110426", "0.6108788", "0.6091436", "0.60857993", "0.60734063", "0.607067", "0.60616714", "0.6054185", "0.6053705", "0.6047933", "0.60453343", "0.6043421", "0.60430914", "0.60394114", "0.6038429", "0.60355765", "0.6034953", "0.6032382", "0.60293984", "0.60293984", "0.60162413", "0.6008246", "0.59951174", "0.5987567", "0.5984746", "0.5976777", "0.5952319", "0.59228635", "0.5920461", "0.5914161", "0.58858645", "0.58630323", "0.5861819", "0.5855825", "0.5853632", "0.58488935", "0.5848866", "0.58401597", "0.5840153", "0.5838296", "0.5831408", "0.58245707", "0.582144", "0.5808732", "0.58000517", "0.5797704", "0.57935846", "0.5791885", "0.5789291", "0.57873935", "0.5782879", "0.5781563", "0.5774926", "0.5765943", "0.57579213", "0.5745561", "0.5743731", "0.57428694", "0.5740281" ]
0.6557617
19
Returns true if the player with the longest name, steals a lot.
def long_name_steals_a_ton long_name_player = player_collection.reduce { |longest_name, next_player| longest_name[:player_name].length > next_player[:player_name].length ? longest_name : next_player; } most_steals_player = player_collection.reduce { |most_steals, next_player| most_steals[:steals] > next_player[:steals] ? most_steals : next_player; } long_name_player === most_steals_player; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def long_name_steals_a_ton?\n longest_name = player_with_longest_name()\n player_name_with_most_steals = player_with_most_steals()\n\n if longest_name == player_name_with_most_steals\n return true\n end\n false\nend", "def long_name_steals_a_ton?\n if player_with_longest_name == mostSteals[0]\n true\n else\n false\n end\nend", "def long_name_steals_a_ton?\n # find player with longest name\n # find player with most steals\n # are they the same? if so return true\n player_with_most_steals = players.max_by { |player| player[:steals]}\n player_with_longest_name == player_with_most_steals[:player_name] ? true : false\nend", "def long_name_steals_a_ton?\n player_with_most(:steals) == player_with_longest_name\nend", "def player_with_longest_name_also_had_most_steals?(game)\n player_longest_name(game) == most_steals(game)\nend", "def long_name_steals_a_ton?\n most_steals = 0\n leading_stealer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:steals] > most_steals\n most_steals = player[:steals]\n leading_stealer = player[:player_name]\n end\n end\n end\n if leading_stealer == player_with_longest_name\n return true\n end\n end", "def long_name_steals_a_ton?\n max_steals = 0\n player_name = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |name|\n if game_hash[location][:players][name][:steals] > max_steals\n max_steals = game_hash[location][:players][name][:steals]\n player_name = name\n end\n end\n end\n player_name == player_with_longest_name\nend", "def long_name_steals_a_ton?\n highest_number_steals = 0\n player_most_steals = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if highest_number_steals < player_stats[:steals]\n highest_number_steals = player_stats[:steals]\n player_most_steals = player_stats[:player_name]\n end\n end\n end\n if player_most_steals == player_with_longest_name\n true\n else\n false\n end\nend", "def long_name_steals_a_ton?\n steals = 0\n most_steals = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if steals < stats[:steals]\n steals = stats[:steals]\n most_steals = name\n end\n end\n end\n most_steals == player_with_longest_name\nend", "def player_with_longest_name\n longestName.max_by(&:length)\nend", "def long_name_steals_a_ton?\n name_length = 0\n longest_name = \"\"\n steals = []\n top_stealer = \"\"\n\n game_hash.collect do |location, team_info|\n team_info[:players].collect do |name, stats|\n steals << stats[:steals]\n if stats[:steals] == steals.sort[-1]\n top_stealer = name\n end\n if name.length > name_length\n longest_name = name\n end\n end\n end\n\n if longest_name == top_stealer\n true\n else\n false\n end\n\nend", "def long_name_steals_a_ton?\n most_steal\n player_with_longest_name\n most_steal_player = \"\"\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n if most_steal == element[:steals]\n most_steal_player = element[:player_name]\n end\n end\n end\n player_with_longest_name.eql?(most_steal_player)\nend", "def long_name_steals_a_ton?()\n\n def most_steals()\n steals = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:steals] > steals\n steals = player[:steals]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\n end\n\n return player_with_longest_name() == most_steals()\nend", "def enough_human_players?\n players.length >= needed_players\n end", "def player_with_longest_name\n players.keys.sort_by { |name| name.length }[-1]\nend", "def player_with_longest_name\n max_name = 0\n player_name = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |name|\n if name.length > max_name\n max_name = name.length\n player_name = name\n end\n end\n end\n player_name\nend", "def long_name_steals_a_ton? \n longest_name = \"\"\n player_steals = 0\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if longest_name == \"\" || player_index[:player_name] > longest_name \n longest_name = player_index[:player_name]\n longest_name = player_index[:player_name]\n player_steals = player_index[:steals]\n end\n end\n end\n end\n end\n end\n if player_steals > most_steals\n true\n else\n false\n end\nend", "def full?\n players.length >= max_players\n end", "def player_with_longest_name\n longest_name = 0\n the_player = \"\"\n\n game_hash.each do |location, team_data|\n team_data[:players].each do |name,stats|\n if (name.size > the_player.size)\n the_player = name\n end #if\n end #team_data\n end #game_hash\n the_player\n\nend", "def player_with_longest_name\n longest_name = \"\"\n game_hash.each do |k, team|\n team[:players].each do |e|\n if e[:player_name].length > longest_name.length\n longest_name = e[:player_name]\n end\n end\n end\n longest_name\nend", "def longest_name(game)\nmax_length = 0\nmax_length_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:player_name].length > max_length\n max_length = player_contents[:player_name].length\n max_length_player = player_contents[:player_name]\n elsif player_contents[:player_name].length == max_length\n max_length_player += max_length_player \" and #{player_contents[:player_name]}\"\n end\n end\nend\nmax_length_player\nend", "def player_with_longest_name\n array = []\n array2 = []\n max_name = \"\"\n game_hash.collect do |location, team_data|\n team_data[:players].keys.collect do |name|\n array << name\n array2 << name.length\n end\n end\n\t max = array2.max\n array.collect do |name|\n if \tname.length == max\n max_name = name\n end\n end\n max_name\n end", "def at_max_players?\n self.player_count == MAX_PLAYERS\n end", "def maximum_players?\n self.players.count == MAX_PLAYERS\n end", "def player_with_longest_name\n longest = ''\n longest_length = 0\n game_hash.each do |home_away, keys|\n keys[:players].each do |player|\n name_length = player[:player_name].length\n longest, longest_length = player[:player_name], name_length if name_length > longest_length\n end\n end\n return longest\nend", "def player_with_longest_name\n longest_name = 0\n longest_player_name = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if longest_name < player_stats[:player_name].length\n longest_name = player_stats[:player_name].length\n longest_player_name = player_stats[:player_name]\n end\n end\n end\n longest_player_name\nend", "def is_long_pressed_name(name, typed)\n typed_stack = typed.chars\n name_stack = name.chars\n last_popped = ''\n \n while !typed_stack.empty?\n if typed_stack.last == name_stack.last\n typed_stack.pop\n last_popped = name_stack.pop\n elsif last_popped != typed_stack.last\n return false\n else\n typed_stack.pop\n end\n end\n \n name_stack.empty?\nend", "def player_longest_name(game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name]\n end\n longest_name = player_names.max_by { |name| name.length }\nend", "def player_with_longest_name()\ncount = 0\nresult = \"\"\n\ngame_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n\n if player[:player_name].length > count\n count = player[:player_name].length\n result = player[:player_name]\n\n end\n end\n end\n end\nend\nresult\nend", "def long?\n @name.length >= 15\n end", "def finished?\n\n @players.each do |current_player|\n return true if current_player.position >= @length\n end\n\n return false\n\n end", "def lost?\n longest_row(opponent) >= 5\n end", "def player_with_longest_name\n name_size = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if name_size < name.size\n result = name\n end\n end\n end\n result\nend", "def long_name_steals_a_ton?\n\t # returns true if the player with the longest name had the most steals\n\tlongest_name_length = 0\n\tlongest_name_name = []\n\tmost_steals = 0\n\tmost_steals_name = []\n\tall_players = []\t\t\t\t# Is all players, home & away. Renamed! \n\tsteals_array = []\n\ttrue_flag = nil\n\n\n\t# OKAY, prints -- calculates max # of steals, currently array w 3 / was one name (winner or tie possible...)\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\tstats.each do |stat, stat_value|\n\t\t\t\t\tif game_hash[h_or_a][:players][stat][:steals] > most_steals\n\t\t\t\t\t\tmost_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\tmost_steals_name = stat\n\t\t\t\t\t\tputs(\"one players w Max steals name : #{most_steals_name}\")\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n# compare to each player's # / steals to the max steals and put all winner / (winners, if tie) to an array\n# Prev. version: put all players w a winning # steals in an array (to accomodate ties). \n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\t# stats.each do |stat, stat_value|\n\t\t\t\t# \t most_steals = game_hash[h_or_a][:players][stat][:steals].max_by {|stat2, statval2 | stat2.to_s.to_f <=> statval2 }\n\t\t\t\tall_players.each do |name| \t\t\t# ONLY HAS ONE ITEM IN PIPES! | |\n\t\t\t\t\tif game_hash[h_or_a][:players][name][:steals] = most_steals\n\t\t\t\t\t\tsteals_array << name\n\t\t\t\t\t\t#most_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\t# most_steals_name << stat\n\t\t\t\t\t\tputs(\"Most steals V2** name : #{steals_array}\")\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n\n\tgame_hash[:home][:players].each do |k, v|\n\t\t#puts (\"v.flatten is -- #{k.to_s}\")\n\t\tall_players << k.to_s \t\t\t#v.flatten \n\tend\n\tgame_hash[:away][:players].each do |k, v|\n\t\tall_players << k.to_s\n\tend\n\n\tputs (\"all_players is : #{all_players}\")\n\n\n# Attempt to get all max values of steals\n# max = my_hash.values.max\n# Hash[my_hash.select { |k, v| v == max}]\n\n\n# game_hash =\t{\n# \thome: {\n# \t\tteam_name: \"Brooklyn Nets\",\n# \t\tcolors: [\"Black\", \"White\"], \t\t\t#array of strings\n# \t\tplayers: {\n# \t\t\t\"Alan Anderson\": {\n# \t\t\t\tnumber: 0, \n# \t\t\t\tshoe: 16, \n\n\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, names|\n\t\t\tif (info_type == :players)\n\t\t\t\t# stats.each do |stat, stat_value|\n\t\t\t\t# \t most_steals = game_hash[h_or_a][:players][stat][:steals].max_by {|stat2, statval2 | stat2.to_s.to_f <=> statval2 }\n\t\t\t\tall_players.each do |name, stats| \n\t\t\t\t\tsteals_array = game_hash[h_or_a][:players][name][:steals].select { |stats, stat_val | stat_val == max }\t#undefined method `[]' for nil:NilClass\n\t\t\t\t\tputs(\"Most steals V3** array names : #{steals_array}\")\n\t\t\t\t\t#end\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\nhome_steals = game_hash[:home][:players][name][:steals].select { |stats, stat_val | stat_val == max }\n\n\n# ERROR - doesn't find away players, returns nil. // Create parallel array just holding each player's max # of steals. \n\n\tall_players.each do |name|\n\t\tputs(\"number of steals is #{game_hash[:home][:players][name.to_sym][:steals]}, name is- #{ name}\")\t\t\n\t\t\tsteals_array << game_hash[:home][:players][name.to_sym][:steals]\n\t\t\n\tend\n\n\n\n\tall_players.each do |name|\n\t\tputs(\"Name.length is #{name.length}, name is- #{name}\")\t\t\n\t\tif name.length > longest_name_length\n\t\t\tlongest_name_length = name.length\n\t\t\tlongest_name_name << name\n\t\tend\n\tend\n\n\n\t#### NEED TO DO SORT BY LENGTH, THEN CALC LENGTH OF EACH, RETURN ALL MAX TIES TO NEW ARRAY\n\tlongest_name_name = all_players.max(1) { |name, b| name.length <=> b.length}\n\tlongest_name_length = longest_name_name.length\n\n\tprint \"Longest Name Length Is : \"\n\tputs longest_name_length\n\n\tprint \"Final Longest Name Is : \"\n\tputs longest_name_name\n\n\tprint \" Most Steals Is : \"\n\tputs most_steals_name\n\n\tlongest_name_name.each do |name|\n\t\tif most_steals_name.include?(name)\n\t\t\ttrue_flag = true\n\n\t\tend\n\tend\n\tputs true_flag\n\treturn true_flag\nend", "def long_planeteer_calls(names)\n names.any? {|name| name.length > 4}\n \nend", "def won?\n longest_row(@player) >= 5\n end", "def long_name_steals_a_ton?\n\t # returns true if the player with the longest name had the most steals\n\tlongest_name_length = 0\n\tlongest_name_name = []\n\tmost_steals = 0\n\tmost_steals_name = []\n\tmy_array = []\n\ttrue_flag = nil\n\n\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\tstats.each do |stat, stat_value|\n\t\t\t\t\tif game_hash[h_or_a][:players][stat][:steals] > most_steals\n\t\t\t\t\t\tmost_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\tmost_steals_name << stat\n\t\t\t\t\t\tputs(\"Most steals name : #{most_steals_name}\")\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n\tgame_hash.each do |h_or_a, team_infos|\n\t\tteam_infos.collect do |info_type, stats|\n\t\t\tif (info_type == :players)\n\t\t\t\tstats.each do |stat, stat_value|\n\t\t\t\t\t most_steals = game_hash[h_or_a][:players][stat][:steals].max_by {|stat2, statval2 | stat2.to_s.to_f <=> statval2 }\n\n\t\t\t\t\t\t#most_steals = game_hash[h_or_a][:players][stat][:steals]\n\t\t\t\t\t\t#most_steals_name = game_hash[h_or_a][:players].keys \t#> [:\"Alan Anderson\", :\"Reggie Evans\", :\"Brook Lopez\", :\"Mason Plumlee\", :\"Jason Terry\"]\n\t\t\t\t\t\tmost_steals_name << stat\n\t\t\t\t\t\tputs(\"Most steals V2** name : #{most_steals_name}\")\n\t\t\t\t\t#end\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\n\n\n\n\n\n\n\n\tgame_hash[:home][:players].each do |k, v|\n\t\t#puts (\"v.flatten is -- #{k.to_s}\")\n\t\tmy_array << k.to_s \t\t\t#v.flatten \n\tend\n\tgame_hash[:away][:players].each do |k, v|\n\t\tmy_array << k.to_s\n\tend\n\n\tputs (\"my_array is : #{my_array}\")\n\n\n\tmy_array.each do |name|\n\t\tputs(\"Name.length is #{name.length}, name is- #{name}\")\t\t\n\t\tif name.length > longest_name_length\n\t\t\tlongest_name_length = name.length\n\t\t\tlongest_name_name << name\n\t\tend\n\tend\n\n\n\t#### NEED TO DO SORT BY LENGTH, THEN CALC LENGTH OF EACH, RETURN ALL MAX TIES TO NEW ARRAY\n\tlongest_name_name = my_array.max(2) { |name, b| name.length <=> b.length}\n\tlongest_name_length = longest_name_name.length\n\n\tprint \"Longest Name Length Is : \"\n\tputs longest_name_length\n\n\tprint \"Final Longest Name Is : \"\n\tputs longest_name_name\n\n\tprint \" Most Steals Is : \"\n\tputs most_steals_name\n\n\tlongest_name_name.each do |name|\n\t\tif most_steals_name.include?(name)\n\t\t\ttrue_flag = true\n\n\t\tend\n\tend\n\tputs true_flag\n\treturn true_flag\nend", "def player_with_longest_name\n long_name = \"\"\n name = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n name << element[:player_name]\n end\n end\n long_name = name.max\nend", "def is_last_player\n self.current_turn > self.players.size\n end", "def full?\n if match_type.include?(\"Doubles\") and players.length < 4\n return false\n elsif match_type.include?(\"Singles\") and players.length < 2\n return false\n else\n return true\n end\n end", "def finished?\n @players.times do |this_player|\n # winner(this_player) if @current_location[this_player] == @length-1\n return this_player if @current_location[this_player] == @length-1\n end\n return nil\n end", "def player_with_longest_name\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |i, j|\r\n result[i]=i.length\r\n end\r\n end\r\n end\r\n end\r\n result.max_by {|name, len| len}[0].to_s\r\n end", "def team_full?(team)\n if team.characters.length == 6\n true\n else false\n end\n end", "def full?\n without_locking { players.size >= technology.max_players }\n end", "def finished?\n if @player_positions.include?(@length)\n return true\n else\n return false\n end\n end", "def trainer_battle?\n !@names[1].empty?\n end", "def play_again?\n if @players.empty?\n false\n else\n player_names = @players.map{ |p| p.name }.join(\", \")\n print \"#{player_names}, one more game (y/n)? \"\n gets.strip.downcase.take(1) == \"y\"\n end\n end", "def game_over?\n alive_players = @players.select {|player| player.alive? == true }\n if alive_players.length > 1\n false\n else\n true\n end\n end", "def finished?\n player_positions.any? { |player, position| position >= length}\n end", "def name_too_long\n name.length > Account::DISPLAY_NAME_LIMIT\n end", "def player_with_longest_name\nlongest_name = \"\"\ngame_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n team_data.each do |player_index|\n if longest_name == \"\" || player_index[:player_name] > longest_name \n longest_name = player_index[:player_name]\n longest_name = player_index[:player_name]\n end\n end\n end\n end\n end\nend\nlongest_name\nend", "def longestName\n players.collect do|name, stats|\n name\n end\nend", "def finished?\n @players.values.each do|num|\n if num.sum >=@length\n return true\n end\n end\n false\n\n end", "def player_with_longest_name\n player_collection.reduce { |longest_name, next_player|\n longest_name[:player_name].length > next_player[:player_name].length ? longest_name : next_player; \n }[:player_name]; \n #probably easier to read to declare variable, however, good to know this works. \nend", "def game_over?\n remaining_players == 1\n end", "def valid?\n return false if [email protected]? && @name.to_s.length > 250\n true\n end", "def lose?\n\t\t@wrong_letters.length == 6 \n\tend", "def finished?\n @players.any? do |player|\n @position[player] == @length\n end\n end", "def minimum_players?\n self.players.count == MIN_PLAYERS\n end", "def game_over?\n alive_players.count == 1\n end", "def is_great(name)\n if name == \"Bill\"\n return true\n elsif name.length > 6\n return true\n end\n false\n end", "def longest_pause(sentence)\n longest_pause = nil\n sentence.delete!(\",'.\")\n sentence.split.each do |word|\n if word.include?(\"um\")\n if longest_pause == nil || word.length > longest_pause.length\n longest_pause = word\n end\n end\n end\n longest_pause.length\nend", "def game_over?\n @players.all? {|p| p.last_turn == \"skipped turn\"} || (@letter_bank.empty? && current_player.rack_empty?)\n end", "def full?\n players.length == @map.player_capacity\n end", "def longest_fishie(fishies)\n longest_fish = \"\"\n\n fishies.each do |fish|\n longest_fish = fish if fish.length > longest_fish.length\n end\n\n longest_fish\nend", "def reached_permutation_threshold?\n Robot.taken_names.size >= permutation_threshold\n end", "def winner\n @players.each do |current_player|\n if current_player.position >= length\n #puts \"#{current_player.name} JUST WON!!!\"\n return \"#{current_player.name}\"\n end\n end\n end", "def finished?\n if @player_positions [\"b\"] > 80 \n return winner(@player[1])\n elsif @player_positions[\"a\"] > 80\n return winner(@player[0])\n end\n end", "def long_planeteer_calls(calls)\n calls.each do |word|\n if word.length > 4\n return true\n else\n return false\n end\n end\nend", "def game_over\n remaining_player.count == 1\n end", "def split?\n file.bytesize > MAXIMUM_NAME_LENGTH\n end", "def longer_first_name\n first_name.length > last_name.length\n end", "def round_over? \n\t\tplayers.one?{ |player| !player.folded? }\n\tend", "def player_exist?(name)\n open_store \"players\" do |gd|\n gd.has_key? name.downcase\n end\n end", "def long_planeteer_calls(words)\n words.any? { |word| word.length>4}\nend", "def played_by?(username)\n @first_player.name == username || @second_player.name == username\n end", "def long_planeteer_calls(calls)\n calls.any? { |word| word.length > 4 }\nend", "def full?\n return false if self.parent_id.nil? # course team, does not max_team_size\n max_team_members = Assignment.find(self.parent_id).max_team_size\n curr_team_size = Team.size(self.id)\n (curr_team_size >= max_team_members)\n end", "def ready_to_begin?\n @game.players.size == @limit\n end", "def winner?\n self.user_wordcount.to_i >= Nanowrimo::GOAL\n end", "def game_over?\n players_found_phrase = @states.select { |s| s.found_phrase }\n if players_found_phrase.size == 1\n @renderer.output \"We have a winner! #{players_found_phrase.first.player.name} found the phrase!\"\n return true \n elsif players_found_phrase.size > 1\n drawn_player_names = players_found_phrase.map { |s| s.player.name }\n @renderer.output \"We have a draw between #{drawn_player_names.join(' and ')}\"\n return true\n else\n dead_players = @states.select { |s| s.incorrect_guesses.count >= Gallows.stages.count - 1 }\n if dead_players.count > 0\n dead_player_names = dead_players.map { |s| s.player.name }\n @renderer.output \"#{dead_player_names.join(' and ')} is dead.\"\n if dead_players.count == @states.count\n @renderer.output \"It's a draw, all players are dead.\"\n else\n surviving_players = @states.select { |s| dead_players.index(s).nil? }\n surviving_player_names = surviving_players.map { |s| s.player.name }\n @renderer.output \"We have a winner! #{surviving_player_names.join(' and ')} survived longer!\"\n end\n return true\n end\n end\n return false\n end", "def check_name_in_players(player_name)\n return true if @players.include?(player_name)\nend", "def long_planeteer_calls(words)\n words.any? {|word| word.length > 4}\nend", "def validate_name(value)\n return false if(value.to_s.length >= MAX_NAME_LENGTH)\n return true\n end", "def check_end_of_game\n return has_this_player_won?(COMPUTER) ? COMPUTER : (has_this_player_won?(HUMAN) ? HUMAN : false)\n end", "def is_game_over?\n players.count < 2 ||\n @state == 'stop' ||\n @cards_on_table.count >= Deck.num_cards ||\n (players.map{|p| p.num_cards_remaining == Deck.num_cards}.include? true)\n end", "def is_name_new?\n return false if @chunks.size < 8\n [-8, -6, -5, -4, -2, -1].map {|i| @chunks[i] } ==\n [OP_1, OP_2DROP, OP_DUP, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG]\n end", "def check_twolast_include name_array, letters\n if name_array.length < 2 # If the name lenght is inferior to two,\n return false # return a negative answer,\n else # or else,\n return name_array.last(2).all? { |char| letters.include? char } # return if the two last characters of the name are from the same group or not.\n end\nend", "def validate_name(value)\n return false if(value.to_s.length >= MAX_NAME_LENGTH)\n return true\n end", "def tie?\n if @taken.length >= @board.length\n puts \"It's a tie! Game over.\"\n return true\n end\n return false\n end", "def winner?\n horses.each do |horse|\n if horse.position + horse.length >= self.length\n return horse\n end\n end\n # ...otherwise no horse is the winner\n return nil\n end", "def has_middle_name\n @full_name.split(' ').length >= 3\n end", "def is_name_firstupdate?\n return false if @chunks.size < 11\n [-11, -7, -6, -5, -4, -2, -1].map {|i| @chunks[i] } ==\n [82, OP_2DROP, OP_2DROP, OP_DUP, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG]\n end", "def check_win_or_lose\n # if guessed letters are 7 then lose\n if self.wrong_guesses.length >= 7\n :lose\n elsif all_letters_in_word_in_guesses?\n :win\n else\n :play\n end\n end", "def any_player_other_than?(player)\n @players.length > 1 || (@players.length == 1 && @players.first != player)\n end", "def check_maximum_people\n self.people == self.maximum_people ? false : true\n end", "def end_game?\n @game = Game.find(game_id)\n count = game.player_ids.count > 3 ? 3 : 1\n @game.winners && @game.winners.count == count ? true : false\n end", "def end?\n players.any?(&:bankrupt?)\n end", "def won?\n if @board.last == @board.last.sort && @board.last.length == @towers\n return true\n else\n return false\n end\n end", "def full?(player1, player2) \n full = @field.all? {|f| f == player1.symbol || f == player2.symbol }\n return full\n end" ]
[ "0.838977", "0.81737137", "0.8119735", "0.8091636", "0.8068787", "0.7639363", "0.76026756", "0.7258259", "0.7220508", "0.7209721", "0.7173911", "0.7050161", "0.7033831", "0.6816754", "0.68075556", "0.6780254", "0.6764679", "0.675441", "0.6709574", "0.6663305", "0.6660415", "0.66542953", "0.66115", "0.6594042", "0.6549514", "0.6475621", "0.6453996", "0.6428061", "0.6425298", "0.6416417", "0.6391137", "0.63816875", "0.6376013", "0.6344462", "0.63311285", "0.6324459", "0.63182706", "0.6266649", "0.62483275", "0.61777574", "0.6159929", "0.61503655", "0.6149973", "0.61453414", "0.61063963", "0.6106285", "0.60946465", "0.6085713", "0.60806113", "0.60697615", "0.600403", "0.59888405", "0.59749794", "0.59680575", "0.5962572", "0.5956523", "0.5952153", "0.59252715", "0.59234625", "0.59127975", "0.5907151", "0.58916575", "0.58901596", "0.58858377", "0.5883143", "0.5878636", "0.5871275", "0.5867429", "0.5862083", "0.5829254", "0.5823349", "0.57978886", "0.5793502", "0.57695735", "0.57644224", "0.5740346", "0.5703411", "0.5702701", "0.5702268", "0.56991243", "0.5697936", "0.56884366", "0.5679903", "0.5679715", "0.56779975", "0.5673521", "0.5660252", "0.5657339", "0.56572694", "0.5639345", "0.5622086", "0.56177974", "0.56124395", "0.56116796", "0.5608625", "0.5606875", "0.5598665", "0.5596768", "0.55900234", "0.55893725" ]
0.6467735
26
From the page 651 Range.new(start, end, exclusive=false) > rng Constructs a range using the given start and end. If the third parameter is omitted or is false, the range will include the end object; otherwise, it will be excluded.
def test_Range_ClassMethods_new a = Range.new(-1, -5); assert_equal('Range', a.class.name) b = Range.new(-5, -1); assert_equal('Range', b.class.name) c = Range.new('a', 'e'); assert_equal('Range', c.class.name) d = Range.new('a', 'e', false); assert_equal('Range', d.class.name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exclusive\n if exclude_end?\n self\n else\n Range.new(self.begin, self.end + 1, true)\n end\n end", "def initialize(first, last, exclude_end = false)\n raise NameError, \"`initialize' called twice\" if @begin\n \n unless first.kind_of?(Fixnum) && last.kind_of?(Fixnum)\n begin\n raise ArgumentError, \"bad value for range\" unless first <=> last\n rescue\n raise ArgumentError, \"bad value for range\"\n end\n end\n \n @begin = first\n @end = last\n @excl = exclude_end\n end", "def range\n (start_date...end_date) #exclusive date range\n end", "def day_range(rng=self)\n if rng.respond_to?(:exclude_end?) && rng.exclude_end?\n Range.new(rng.begin.to_date, rng.end.to_date, true)\n else\n Range.new(rng.begin.to_date, rng.end.to_date + 1, true)\n end\n end", "def range \n Range.new(@first, @last)\n end", "def unbounded\n ::Unbounded::Range.new(self.min, self.max, exclude_end?)\n end", "def to_range\n Range.new(self.start, self.end)\n end", "def range\n\t\t\t#(@end > @start) ? (@start .. @end) : (@end .. @start)\n\t\t\t(start .. self.end)\n\t\tend", "def range(start_num, end_num)\n # one line version\n # (start_num...end_num).to_a\n\n # version 2\n exclusive_range = []\n (start_num...end_num).each do |num|\n exclusive_range << num\n end\n exclusive_range\nend", "def for_date_range(beginning:, ending:)\n new_with_date_range(beginning, ending)\n end", "def range(range)\n opts[:min] = range.begin\n opts[:max] = range.end\n end", "def date_range\n @date_range ||= start_at..end_at\n end", "def create_range_data( rng, minrng=0, type=0, direction=2 )\n return Handlers::Range.createRange( rng, minrng, type, direction )\n end", "def upto(end_key)\n unless partition_specified?\n raise IllegalQuery,\n \"Can't construct exclusive range on partition key #{range_key_name}\"\n end\n scoped(upper_bound: bound(false, true, end_key))\n end", "def range(range_start, range_end, end_reached_cb=nil)\n if range_start == nil\n result = XML.new(name, attrs)\n else\n result = nil\n end\n @contents.each {|c|\n # end reached !\n if range_end and c.object_id == range_end.object_id\n end_reached_cb.call if end_reached_cb\n break\n end\n # start reached !\n if range_start and c.object_id == range_start.object_id\n result = XML.new(name, attrs)\n next\n end\n if result # We already started\n if c.is_a? XML\n break_me = false\n result.add! c.range(nil, range_end, lambda{ break_me = true })\n if break_me\n end_reached_cb.call if end_reached_cb\n break\n end\n else # String/XML_PI/XML_Comment\n result.add! c\n end\n else\n # Strings/XML_PI/XML_Comment obviously cannot start a range\n if c.is_a? XML\n break_me = false\n r = c.range(range_start, range_end, lambda{ break_me = true })\n if r\n # start reached !\n result = XML.new(name, attrs, r)\n end\n if break_me\n # end reached !\n end_reached_cb.call if end_reached_cb\n break\n end\n end\n end\n }\n return result\n end", "def test_Range_InstanceMethods_exclude_end?\n\t\t# TODO, need add some testcases.\n\tend", "def to_range\n (@start_date..@end_date)\n end", "def test_Range_InstanceMethods_excludes\n\t\tassert_equal(true, (1..10) === 5)\n\t\tassert_equal(false, (1..10) === 15)\n\t\tassert_equal(true, (1..10) === 3.14159)\n\t\tassert_equal(true, ('a'..'j') === 'c')\n\t\tassert_equal(false, ('a'..'j') === 'z')\n\tend", "def to_range\n start_date..end_date\n end", "def initialize(ranges, string, exclude_end = false)\n unless ranges.is_a?(Array)\n lb = GtEqRange.new(ranges)\n if exclude_end\n ub = LtRange.new(string)\n string = \">=#{string} <#{ranges}\"\n else\n ub = LtEqRange.new(string)\n string = \"#{string} - #{ranges}\"\n end\n ranges = [MinMaxRange.create(lb, ub)]\n end\n ranges.compact!\n\n merge_happened = true\n while ranges.size > 1 && merge_happened\n # merge ranges if possible\n merge_happened = false\n result = []\n until ranges.empty?\n unmerged = []\n x = ranges.pop\n result << ranges.reduce(x) do |memo, y|\n merged = memo.merge(y)\n if merged.nil?\n unmerged << y\n else\n merge_happened = true\n memo = merged\n end\n memo\n end\n ranges = unmerged\n end\n ranges = result.reverse!\n end\n\n ranges = [LtRange::MATCH_NOTHING] if ranges.empty?\n @ranges = ranges\n @string = string.nil? ? ranges.join(' || ') : string\n end", "def to_range\n case\n when open?, unknown?\n nil\n else\n Range.new(unknown_start? ? Date.new : @from, max)\n end\n end", "def new_with_date_range(begin_date, end_date)\n report = new\n report.set_date_range(begin_date, end_date)\n report\n end", "def &(range)\n return nil unless overlaps?(range) || touching?(range)\n PosRange.new [@start, range.start].max, [@end, range.end].min\n end", "def range(start_num, end_num)\n return [] if end_num =< start_num\n range(start_num, end_num - 1) << end_num - 1\nend", "def exclusive!\n @inclusive = false\n end", "def range\n @range ||= set_range\n end", "def build_range(key, val, negate)\n if val.exclude_end?\n # begin...end range\n if negate\n \"#{key} < #{quoted(val.begin, key)} or #{key} >= #{quoted(val.end, key)}\"\n else\n \"#{key} >= #{quoted(val.begin, key)} and #{key} < #{quoted(val.end, key)}\"\n end\n else\n # begin..end range\n if negate\n \"#{key} < #{quoted(val.begin, key)} or #{key} > #{quoted(val.end, key)}\"\n else\n \"#{key} >= #{quoted(val.begin, key)} and #{key} <= #{quoted(val.end, key)}\"\n end\n end\n end", "def time_range(rng=self,utc_offset=nil)\n if rng.begin.respond_to?(:sec) && rng.end.respond_to?(:sec)\n utc_offset ||= rng.begin.utc_offset\n Range.new( rng.begin.getlocal(utc_offset),\n rng.end.getlocal(utc_offset),\n rng.respond_to?(:exclude_end?) && rng.exclude_end?\n )\n else\n adj_rng = day_range(rng)\n b,e = adj_rng.begin, adj_rng.end\n Range.new( Time.new(b.year,b.month,b.day,0,0,0,utc_offset), \n Time.new(e.year,e.month,e.day,0,0,0,utc_offset), \n true\n )\n end\n end", "def between(a, b = nil)\n Between.new(a.kind_of?(Range) ? a : a..b)\n end", "def range(start,ending)\r\n return [] if ending <= start\r\n\r\n range(start, ending-1) << ending -1\r\nend", "def test_Range_InstanceMethods_compare\n\t\tassert_equal(true, (1..3) == Range.new(1,3))\n\t\tassert_equal(false, (1..3) == (2..4))\n\tend", "def booked_date_range\n { from: :start_date, to: :end_date }\n end", "def not_in(*args)\n if args.size == 1 && (range = args.first).is_a?(Range)\n return NotBetween.new(self, range)\n end\n\n NotIn.new(self, *args)\n end", "def from(start_key)\n unless partition_specified?\n raise IllegalQuery,\n \"Can't construct exclusive range on partition key #{range_key_name}\"\n end\n scoped(lower_bound: bound(true, true, start_key))\n end", "def check_range(rng)\n new(rng).results\n end", "def inclusive!\n @inclusive = true\n end", "def initialize(min, max=min)\n @begin, @end = coerce(min), coerce(max)\n end", "def tt_range\n ARange.new(ttstart_at, ttend_at)\n end", "def range(start, last)\n return [] if last < start\n range(start, last - 1) << last - 1\nend", "def range( first_cell, last_cell=nil )\n addr = to_range_address( first_cell, last_cell )\n addr.include?(':') ? Range.new( self, addr ) : Cell.new( self, addr )\n end", "def range\n min, max = span\n min..max\n end", "def range(from, to)\n from_query(raw_range(from, to))\n end", "def test_ranges\r\n assert_equal(@range.begin.to_f, @p2.to_f)\r\n assert(@range.cover?(@p5))\r\n assert(@range.end == @p8)\r\n assert(@range2.exclude_end?)\r\n assert_false(@range.exclude_end?)\r\n assert(@range.include?(@p3))\r\n assert(@range.max == @p8)\r\n assert(@range2.max == @p7)\r\n assert(@range.last(3) == [@p6, @p7, @p8])\r\n assert(@range.size == nil)\r\n end", "def populate!(range)\n method = caller[0][/`.*'/][1..-2].to_sym\n if method == :new\n unless range.class == Range\n raise TypeError.new(\"expected Range\")\n end\n range.end.downto(range.begin) do |e|\n unshift(e)\n end\n else\n raise NoMethodError.new(\n \"private method 'populate!' called for #{self}:#{self.class}\"\n )\n end\n end", "def one_index_range(range)\n Range.new(one_index_number(range.begin), one_index_number(range.end))\n end", "def one_index_range(range)\n Range.new(one_index_number(range.begin), one_index_number(range.end))\n end", "def exclude_ip_range(from, to)\n from_ip = IPAddr.new(from)\n to_ip = IPAddr.new(to)\n (from_ip..to_ip)\n raise 'Invalid IP range specified' if (from_ip..to_ip).to_a.size.zero?\n @excluded_scan_targets[:addresses] << IPRange.new(from, to)\n rescue ArgumentError => e\n raise \"#{e.message} in given IP range\"\n end", "def range\n (@from..@to)\n end", "def outside(a, b = nil)\n Outside.new(a.kind_of?(Range) ? a : a..b)\n end", "def range(start, ending)\n return [] if start >= ending - 1\n retu_arr = range(start, ending - 1)\n retu_arr << ending - 1\nend", "def range\n @from..@to\n end", "def rand_in_range(from, to); end", "def random_within_range\n\t\t\trand(self.start_num..self.end_num)\n\t\tend", "def range(range)\n assert_range range\n schema do |s|\n s.type range.begin.is_a?(Integer) ? 'integer' : 'number'\n s.minimum range.begin\n s.maximum range.end, exclusive: range.exclude_end? unless range.end.nil?\n end\n end", "def compose_not_range_node(node, value)\n validate_node_or_attribute(node)\n range_info = parse_range(value)\n\n # build using gt, lt, gteq, lteq\n if range_info[:start_include]\n start_condition = node.lt(range_info[:start_value])\n else\n start_condition = node.lteq(range_info[:start_value])\n end\n\n if range_info[:end_include]\n end_condition = node.gt(range_info[:end_value])\n else\n end_condition = node.gteq(range_info[:end_value])\n end\n\n start_condition.or(end_condition)\n end", "def range\n [@from, @to]\n end", "def to_range\n min .. max\n end", "def range\n DEFAULT_RANGE\n end", "def range\n DEFAULT_RANGE\n end", "def range\n DEFAULT_RANGE\n end", "def rng\n \"#{first}..#{last}\"\n end", "def between(start_line, end_line=nil)\n return self unless start_line\n\n if start_line.is_a? Range\n end_line = start_line.last\n end_line -= 1 if start_line.exclude_end?\n\n start_line = start_line.first\n else\n end_line ||= start_line\n end\n\n if start_line > 0\n start_idx = @lines.index { |l| l.last >= start_line } || @lines.length\n else\n start_idx = start_line\n end\n\n if end_line > 0\n end_idx = (@lines.index { |l| l.last > end_line } || 0) - 1\n else\n end_idx = end_line\n end\n\n alter do\n @lines = @lines[start_idx..end_idx] || []\n end\n end", "def range(start, ending)\n return [] if start >= ending\n\n return [start] + range(start + 1, ending)\nend", "def split_range(range)\n start, finish = range.begin, range.end\n start += length if start < 0\n finish += length if finish < 0\n \n [start, finish - start - (range.exclude_end? ? 1 : 0)]\n end", "def range(range_start, range_end)\n return [] if range_end < range_start\n return [range_end] if range_end == range_start\n result = [range_end]\n range(range_start, range_end - 1) + result\nend", "def arel_exclude(start_column, end_column, start_or_instant_or_range=nil, range_end=nil)\n table = self.arel_table\n if range_end\n table[start_column].gteq(range_end).or(table[end_column].lteq(start_or_instant_or_range))\n elsif Range === start_or_instant_or_range\n table[start_column].gteq(start_or_instant_or_range.db_end).or(table[end_column].lteq(start_or_instant_or_range.db_begin))\n else\n start_or_instant_or_range ||= InfinityLiteral\n table[start_column].gt(start_or_instant_or_range).or(table[end_column].lteq(start_or_instant_or_range))\n end\n end", "def in_range(*args)\n opts = args.last.kind_of?(Hash) ? args.pop : {}\n limit = opts[:limit]\n count = 1\n t_start, t_end = args.first.kind_of?(Range) ? [args.first.first, args.first.last] : [args.first,args.last]\n\n raise ArgumentError, \"must be a range or two date/time objects\" unless t_start and t_end\n\n self.start = t_start\n\n @in_range ||= begin\n result = []\n loop do\n next!\n break if count > limit if limit\n break if to_date > t_end\n result << to_date\n count += 1\n end\n\n result\n end\n end", "def vt_range\n ARange.new(vtstart_at, vtend_at)\n end", "def between(from:, to:); end", "def range\n @cached_range ||= get_range\n end", "def union(range)\n # Return self if nil (nothing new to add) or if it matches the other range (they are equivalent)\n return self.clone if range.nil?\n return self.clone if eql?(range)\n\n # Figure out which range starts earlier (to capture the most time)\n if low <= range.low\n earlier_start = self\n later_start = range\n else\n earlier_start = range\n later_start = self\n end\n \n # Figure out which ranges ends earlier (the more restrictive one)\n if high >= range.high\n earlier_end = self\n later_end = range\n else\n earlier_end = range\n later_end = self\n end\n \n result = []\n # We have continuous Ranges so we can return one Range to encapsulate both\n if earlier_start.contains?(later_start.low)\n result << Range.new(\"TS\", earlier_start.low.clone, later_end.high.clone, nil)\n else\n # The Ranges are disjoint, so we'll need to return two arrays to capture all of the potential times\n result << Range.new(\"TS\", earlier_start.low.clone, earlier_start.high.clone, nil)\n result << Range.new(\"TS\", later_start.low.clone, later_start.high.clone, nil)\n end\n end", "def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend", "def to_range\n\t\tIP.parse(self.start_ip)..IP.parse(self.end_ip)\n\tend", "def range=(range)\n @range = Range.new(range)\n end", "def in(*args)\n if args.size == 1 && (range = args.first).is_a?(Range)\n return Between.new(self, range)\n end\n\n In.new(self, *args)\n end", "def end(end_key)\n self.class.new(collection, range.merge({end: end_key, end_inclusive: true}))\n end", "def sample_range(range, seed=nil)\n srand seed if seed\n rand * (range.end - range.begin) + range.begin\n end", "def add_range(left, right)\n \n end", "def add_range(left, right)\n \n end", "def to_range_within(range)\n nb_weeks_offset = self.weekly_recurring ? ((range.end - self.starts_at.to_datetime) / 7).to_i : 0\n r = Range.new(self.starts_at + nb_weeks_offset.week, self.ends_at + nb_weeks_offset.week)\n range.cover?(r.begin)&&range.cover?(r.end) ? r : nil\n end", "def range(start, stop)\n fetch(key.call(\"LRANGE\", start, stop))\n end", "def conjunctionRangeExtd(r1, r2)\n\n [r1, r2].each do |er|\n return er if er.is_none?\n end\n\n r = *( sort_ranges_core([RangeExtd(r1), RangeExtd(r2)]) )\t# => Rangeary.sort_ranges\n\n ## Note: the end product will be (cBeg(:stBeg), cEnd(:stEnd))\n # where :stBeg and :stEnd mean exclude_(begin|end)?\n\n # Set the candidate begin value.\n cBeg = r[1].begin\n if r[0].begin == r[1].begin\n stBeg = (r[1].exclude_begin? || r[0].exclude_begin?)\n else\n stBeg = r[1].exclude_begin?\n end\n\n # Set the candidate end value. (Rangeary.comparable_end() for Ruby-2.6 Endless Range)\n # Note: this comparison ignores @infinities even if set,\n # because @infinities may not be defined in the arguments!\n # Anyway, nothing should be larger than the upper limit\n # and so this should be fine.\n if comparable_beginend_core(r[0]).end == comparable_beginend_core(r[1]).end\n cEndOrig = r[1].end\n cEnd = comparable_beginend_core(r[1]).end\n stEnd = (r[0].exclude_end? || r[1].exclude_end?)\n else\n a = [[comparable_beginend_core(r[0]).end, 0, r[0].end], [comparable_beginend_core(r[1]).end, 1, r[1].end]].min\n cEnd = a[0]\n cEndIndex = a[1]\t# r[cEndIndex] == RangeExtd obj that gives the end of the resultant range.\n cEndOrig = a[2]\n stEnd = nil\n end\n\n case cBeg <=> cEnd\n when 1\t# cBeg > cEnd\n RangeExtd::NONE\n\n when 0\t# cBeg == cEnd\n stEnd = r[0].exclude_end?\n if (!stBeg) && (!stEnd)\n RangeExtd(cBeg..cBeg)\t# Point range\n else\n RangeExtd::NONE\n end\n\n when -1\t# cBeg < cEnd\n # Now, the range must be (cBeg, cEnd). May need adjustment of the exclude status.\n if stEnd.nil?\n stEnd = r[cEndIndex].exclude_end?\n # else\n # # Already defined.\n end\t# if stEnd.nil?\n\n RangeExtd(cBeg, cEndOrig, :exclude_begin => stBeg, :exclude_end => stEnd)\n else\n raise\n end\t\t# case cBeg <=> cEnd\n\n end", "def range(min, max)\n return max if max < min\n range(min, max) << max\nend", "def <=>(other) range_start <=> other.range_start end", "def initialize(pos_start, pos_end)\n @start = pos_start\n @end = pos_end\n end", "def range(*args)\n value = \"[\"\n args.each_slice(2) do |from, to|\n from = sanitize(from)\n to = sanitize(to)\n value += \"#{from}-#{to}\"\n end\n value += \"]\"\n append value\n end", "def range=(range)\n @range = range\n end", "def make_room_reservation(test_range, room)\n overlapping = self.list_room_reservations(room, test_range)\n if overlapping.length != 0\n raise ArgumentError.new(\"room not available in that date range\")\n else\n new_res = Reservation.new(date_range: test_range, room: room)\n @reservations << new_res\n return new_res\n end\n end", "def initialize(date_range:, room_number:)\n @date_range = date_range\n @room_number = room_number\n end", "def range_rc(start_num, end_num)\n\n return [] if end_num <= start_num\n range_rc(start_num, end_num - 1) + [end_num - 1]\nend", "def test_Range_InstanceMethods_end\n\t\tassert_equal(10, (1..10).end)\n\t\tassert_equal(10, (1...10).end)\n\tend", "def between(date_range)\n merge(between: date_range)\n end", "def between(date_range)\n merge(between: date_range)\n end", "def range=(range)\n @range = range\n end", "def range(min, max)\n # # return [] if end < start\n # if its the last one, 1, using start and end\n\n return [] if max <= min\n\n range(min, max - 1) << max - 1\n # ^ treat it like it is the same data type as base case, so treat it like an array, <<, .map\n\n # [min] + range(min + 1, max - 1)\n # ^ num ^ same data type our base case\nend", "def add_range!(range, ranges)\n # Make sure the arguments are correct\n return nil if range.nil? || ranges.nil?\n\n # Ignore the range if there is an existing one which is bigger\n return nil unless ranges[range.startLine].nil? || ranges[range.startLine].endLine < range.endLine\n ranges[range.startLine] = range\n nil\n end", "def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend", "def intersection(range)\n cmp = self.begin <=> range.end\n if cmp > 0\n nil\n elsif cmp == 0\n exclude_begin? || range.exclude_end? ? nil : EqRange.new(self.begin)\n else\n cmp = range.begin <=> self.end\n if cmp > 0\n nil\n elsif cmp == 0\n range.exclude_begin? || exclude_end? ? nil : EqRange.new(range.begin)\n else\n cmp = self.begin <=> range.begin\n min = if cmp < 0\n range\n elsif cmp > 0\n self\n else\n self.exclude_begin? ? self : range\n end\n\n cmp = self.end <=> range.end\n max = if cmp > 0\n range\n elsif cmp < 0\n self\n else\n self.exclude_end? ? self : range\n end\n\n if !max.upper_bound?\n min\n elsif !min.lower_bound?\n max\n else\n MinMaxRange.new(min, max)\n end\n end\n end\n end", "def range; end", "def range; end" ]
[ "0.7046357", "0.69521165", "0.6402998", "0.63936335", "0.63243616", "0.621054", "0.6176177", "0.61249894", "0.59327364", "0.59201485", "0.5901909", "0.5821596", "0.5810652", "0.5774134", "0.5770379", "0.57551026", "0.5750545", "0.57398516", "0.5734298", "0.57305247", "0.5721361", "0.57071143", "0.5666751", "0.5663342", "0.56610835", "0.56129915", "0.55203855", "0.55100775", "0.5500372", "0.5499068", "0.5447859", "0.5434262", "0.54315615", "0.54238194", "0.5399838", "0.5391781", "0.537767", "0.5370735", "0.53672373", "0.53433764", "0.53396916", "0.53378284", "0.53197306", "0.53165305", "0.5306183", "0.5304795", "0.530417", "0.5301863", "0.5298668", "0.5292618", "0.52907336", "0.52863336", "0.5284359", "0.52364486", "0.5206177", "0.51953536", "0.51948893", "0.51877445", "0.51877445", "0.51877445", "0.51862025", "0.51801765", "0.5174935", "0.51713336", "0.5169327", "0.5145117", "0.51431763", "0.5141932", "0.512467", "0.5122268", "0.5117549", "0.5114434", "0.51120996", "0.5111861", "0.5105955", "0.50995594", "0.5099526", "0.5092836", "0.5092836", "0.50922996", "0.5090849", "0.5090187", "0.5085157", "0.50796163", "0.5063505", "0.50585365", "0.5057579", "0.50538087", "0.50537485", "0.50530213", "0.5046997", "0.503886", "0.503886", "0.50365525", "0.50349504", "0.5031943", "0.5022238", "0.5014572", "0.5010188", "0.5010188" ]
0.5543395
26
From the page 651 rng obj > true or false Returns true if obj is a range whose beginning and end the same as those in rng (compared using ==) and whose exclusive flg is the same as rng.
def test_Range_InstanceMethods_compare assert_equal(true, (1..3) == Range.new(1,3)) assert_equal(false, (1..3) == (2..4)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def meets?(*args)\n other = coerce_range(*args)\n self.begin == other.end or other.begin == self.end\n end", "def touching?(range)\n range.end == self.start || self.end == range.start\n end", "def is_winner_on_range?(range)\n return false unless range.uniq.size == 1 && !range.first.nil?\n\n @winner = range.first\n return true\n end", "def test_Range_InstanceMethods_eql?\n\t\tassert_equal(true , (1..10).eql?(Range.new(1,10)))\n\t\tassert_equal(false, (1..10).eql?([1..10]))\n\tend", "def check_range(rng)\n new(rng).results\n end", "def ==(other)\n return true if equal? other\n\n other.kind_of?(Range) and\n self.first == other.first and\n self.last == other.last and\n self.exclude_end? == other.exclude_end?\n \n end", "def ==(other)\r\n @range == other.range\r\n end", "def covers?(*args)\n other = coerce_range(*args)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n self.begin <= other.begin and other.end <= self.end\n end\n end", "def range1d?(o)\n o.int_range?\nend", "def ===(value)\r\n @range === value\r\n end", "def include_range? other_range\n case other_range\n when Range\n if other_range.first >= self.first && other_range.last <= self.last\n return true\n else\n return false\n end\n else\n raise \"unsupported type\"\n end\n end", "def in_range?\n self > LOWER_BOUND && self <= UPPER_BOUND\n end", "def in_range?\n return self.range.include?([@x, @y])\n end", "def overlap? range\n !(self & range).nil?\n end", "def valid?(range)\n range[0] < range[1]\nend", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n range_start_index == o.range_start_index &&\n range_end_index == o.range_end_index &&\n fallback_font_list == o.fallback_font_list\n end", "def <=>(other) range_start <=> other.range_start end", "def is_a_3_dot_range?(range)\n a = range.first\n b = range.last\n range != (a..b)\nend", "def eql?(range)\n return false if range.nil? || low.nil? || range.low.nil? || high.nil? || range.high.nil?\n \n return low.value == range.low.value && low.inclusive? == range.low.inclusive? &&\n high.value == range.high.value && high.inclusive? == range.high.inclusive?\n end", "def ==(obj)\n self.base == obj.base && self.range == obj.range && self.pointer == obj.pointer\n end", "def verify_range(value)\n a = (20...30) === value\n if a != true\n puts \"#{value} is not in range of 20 to 30\"\n else\n puts \"#{value} is in range of to 20 to 30\"\n end\nend", "def other_offense_in_same_range?(node); end", "def valid?\n return false if @range_start_index.nil?\n return false if @range_end_index.nil?\n true\n end", "def range_include?(zelf, other)\n # 1...10 includes 1..9 but it does not include 1..10.\n operator = zelf.exclude_end? && !other.exclude_end? ? :< : :<=\n zelf.include?(other.first) && other.last.send(operator, zelf.last)\nend", "def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend", "def overlaps?(range)\n !(completely_left_of?(range) || completely_right_of?(range))\n end", "def price_range?\n !(price_range.first == price_range.last)\n end", "def price_range?\n !(price_range.first == price_range.last)\n end", "def range_cover?(outer, inner)\n outer.cover?(inner.begin) && outer.cover?(inner.end)\nend", "def in_range?( answer_object )\n (@above.nil? or answer_object > @above) and\n (@below.nil? or answer_object < @below) and\n (@in.nil? or @in.include?(answer_object))\n end", "def overlap?(self_range, other_range)\n return true if self_range == other_range \n overlap_helper(self_range, other_range) || overlap_helper(other_range, self_range)\n end", "def range_includes_item?(range, item)\n range.begin <= item && item <= range.end\n end", "def test_ranges\r\n assert_equal(@range.begin.to_f, @p2.to_f)\r\n assert(@range.cover?(@p5))\r\n assert(@range.end == @p8)\r\n assert(@range2.exclude_end?)\r\n assert_false(@range.exclude_end?)\r\n assert(@range.include?(@p3))\r\n assert(@range.max == @p8)\r\n assert(@range2.max == @p7)\r\n assert(@range.last(3) == [@p6, @p7, @p8])\r\n assert(@range.size == nil)\r\n end", "def has_range?\n !self.domain_ranges.nil?\n end", "def in_range\n\t\trange = Set[1, 2, 3, 4, 5,\n\t\t\t\t\t\t\t\t6, 7, 8, 9, 10,\n\t\t\t\t\t\t\t 11, 12, 13, 14, 15,\n\t\t\t\t\t\t\t\t16, 17, 18, 19, 20,\n\t\t\t\t\t\t\t\t21, 22, 23, 24, 25,\n\t\t\t\t\t\t\t\t26, 27, 28, 29, 30]\n\n\t\tif @landmarks.subset?(range)\n\t\t\treturn true\n\t\tend\n\n\t\treturn false\n\tend", "def range_precedes(rng,oth)\n r1, r2 = matched_range_types(rng,oth)\n diff = if r1.respond_to?(:exclude_end?) && r1.exclude_end?\n 0\n else\n 1\n end\n (r1.end + diff) == r2.begin\n end", "def between?(min, max)\n #This is a stub, used for indexing\n end", "def viewing_ranges\n if @ranges == [] then $spriteset.show_ranges(false) end\n return (@ranges == [] ? false : true)\n end", "def same?(other)\n (from_end == other.from_end and\n to_end == other.to_end and\n overlap == other.overlap)\n end", "def same?(other)\n (from_end == other.from_end and\n to_end == other.to_end and\n overlap == other.overlap)\n end", "def _index_in_range?(i, max, min)\n !((i > max) || (i < min))\n end", "def all_in_ranges?(nums, ranges)\n if nums.empty?\n return false\n end\n nums.each do |num|\n if !in_ranges?(num, ranges)\n return false\n end\n end\n true\nend", "def intersects?(*args)\n other = coerce_range(*args)\n raise ArgumentError, \"#{self.begin.class} expected, received #{other.begin.class}\" unless other.begin.kind_of?(self.begin.class)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n other.begin < self.end and self.begin < other.end\n end\n end", "def in_range?(val, range)\n return true unless range\n\n if range.is_a?(Hash)\n result = true\n result &= ( val < range[:before] ) if range[:before]\n result &= ( val > range[:after] ) if range[:after]\n result &= ( val <= range[:max] ) if range[:max]\n result &= ( val >= range[:min] ) if range[:min]\n result &= ( val < range[:less_than] ) if range[:less_than]\n result &= ( val <= range[:less_than_or_equal_to] ) if range[:less_than_or_equal_to]\n result &= ( val > range[:greater_than] ) if range[:greater_than]\n result &= ( val >= range[:greater_than_or_equal_to] ) if range[:greater_than_or_equal_to]\n result\n else\n range = [range] unless range.respond_to?(:include?)\n range.include?(val)\n end\n end", "def test_identical\n x = IntegerRange.new(1, 5)\n y = IntegerRange.new(1, 5)\n\n assert_equal(x.mergeable?(y), true)\n assert_equal(y.mergeable?(x), true)\n end", "def matched_by_extended_range?(range)\n recompose\n subtags = @composition.split(Const::HYPHEN)\n subranges = range.downcase.split(Const::HYPHEN)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == Const::WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def matched_by_extended_range?(range)\n\n subtags = decomposition.dup\n subranges = range.to_str.downcase.split(HYPHEN_SPLITTER)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def valid_low_qual_region?(quals,rstart,rend,min_region_size)\n # puts [rstart,rend,0,quals.length,(rend-rstart+1)].join(';')\n # res =((rstart==0) || (rend==quals.length-1) || ((rend-rstart+1)>=min_region_size))\n # if res\n # puts \"VALID\"\n # end\n return ((rstart==0) || (rend==quals.length-1) || ((rend-rstart+1)>=min_region_size))\n end", "def start_and_end_set?\n [start, self.end].map(&:present?).uniq.length == 1\n end", "def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend", "def test_range(r)\n yield [r.min-1, false]\n yield [r.min, true]\n yield [r.max, true]\n yield [r.max+1, false]\nend", "def within?(other)\n range_within_other?(self,other)\n end", "def not_within_hypothetical_range?(dest)\n\t(dest[0] < 0 || dest[1] < 0) || (dest[0] > 7 || dest[1] > 7)\nend", "def book(start_at, end_at)\n i = @array.bsearch_index { |s1, e1| e1 > start_at}\n if i && (@array[i] + [start_at, end_at]).sort != ([start_at, end_at] + @array[i]) && (@array[i] + [start_at, end_at]).sort != ( @array[i] + [start_at, end_at])\n false\n else\n @array.insert(i || -1, [start_at, end_at])\n true\n end\n end", "def intersect?(o)\n self.class == o.class && !(@to < o.numeric_from || o.numeric_to < @from)\n end", "def include?(object)\n object.start >= @start && object.end <= @end\n end", "def in_ranged_array?(ranged_ary, num)\n !!ranged_ary.find {|n| n === num }\n end", "def valid_range?\n (0..@max_num).cover?(@number)\n end", "def is_effective?(value)\n @range_lower <= value && value <= @range_upper\n end", "def target_oor?()\n return @homing_range == -1 ? false : (@target.distance_from( self ) > @homing_range)\n end", "def b_include?(obj) # assumes the array is sorted\n range = bsearch_range { |x| x <=> obj } # returned range excludes its last element\n (self[range.first] == obj or self[range.last - 1] == obj)\n end", "def overlaps?(other)\n # overlap == start < finish' AND start' < finish\n self.first <= other.actual_last and other.first <= self.actual_last\n end", "def empty?\n return false if @upper_bound.nil?\n @lower_bound > @upper_bound\n end", "def unique_val?\n @lower == @upper\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_range?(key)\n (key>=range_start) && (range_end==LAST_POSSIBLE_KEY || key < range_end)\n end", "def between?(min, max)\n self >= min and self <= max\n end", "def ==(other)\n (other.is_a? Interval) && (@start == other.start && @end == other.end)\n end", "def want?(vm, range, groups)\n if vm.nil?\n @log.warn('Obtained nil vm from vm pool.')\n return false\n end\n # range restriction\n unless range.nil? || range.empty?\n return false if range[:from] && vm['STATE'] == STATE_DONE && vm['ETIME'].to_i < range[:from].to_i\n return false if range[:to] && vm['STIME'].to_i > range[:to].to_i\n end\n\n # groups restriction\n unless groups.nil? || groups.empty?\n return false if groups[:include] && !groups[:include].include?(vm['GNAME'])\n return false if groups[:exclude] && groups[:exclude].include?(vm['GNAME'])\n end\n\n true\n end", "def in_range?(index)\n index >= 0 and index < size\n end", "def range\n\t\t\t#(@end > @start) ? (@start .. @end) : (@end .. @start)\n\t\t\t(start .. self.end)\n\t\tend", "def is_a_3_dot_range?(range)\n range.exclude_end?\nend", "def nearly?(other); end", "def contains?(other)\n (other.begin_pos <=> @begin_pos) + (@end_pos <=> other.end_pos) >= (other.empty? ? 2 : 1)\n end", "def inclusive!\n @inclusive = true\n end", "def check_bounds(value)\n return value >= self.bound.lower_bound && value <= self.bound.upper_bound\n end", "def between?(x,y) end", "def intersect? (range1,range2)\n if range1.begin < range2.begin\n if range1.end < range2.begin\n nil\n else\n (range2.begin..range1.end)\n end\n else\n if range2.end < range1.begin\n nil\n else\n (range1.begin..range2.end)\n end\n end\nend", "def between?(p0, p1) end", "def matched_by_basic_range?(range)\n if range.kind_of?(self.class)\n s = range.recompose.tag\n elsif range.respond_to?(:to_str)\n return true if range.to_str == Const::WILDCARD\n s = self.class.parse(range).tag\n else\n return false\n end\n recompose\n @tag == s || @tag.index(s + Const::HYPHEN) == 0\n rescue\n false\n end", "def date_in_range?(first, date, last)\n first <= date && date <= last\n end", "def in_move_range?(v)\n (20..500).include? v\n end", "def OverlappingRanges(arr)\n intersection = (arr[0]..arr[1]).to_a & (arr[2]..arr[3]).to_a\n intersection.size >= arr[4] ? 'true' : 'false'\nend", "def angenehm?(in_temp)\n\tcheck_pre((in_temp.int?))\n#\tANGENEHM_RANGE === in_temp\n in_temp.in?(ANGENEHM_RANGE)\nend", "def test_Range_InstanceMethods_exclude_end?\n\t\t# TODO, need add some testcases.\n\tend", "def check(range, value)\n result = true\n unless range.nil?\n if range.class == Range\n result = (range === value)\n elsif range.class == Fixnum\n result = (value >= range)\n end\n end\n result\n end", "def valid_start_and_end_dates?\n return false unless start.present? && self.end.present?\n start <= self.end\n end", "def overlap?(input_range)\n a = self.start_date >= input_range.end_date\n b = self.end_date <= input_range.start_date\n return a || b ? false : true \n end", "def correct?\n starts_at < ends_at && starts_at.to_date == ends_at.to_date\n end", "def OverlappingRanges(arr)\n first_num = arr[0]\n second_num = arr[1]\n third_num = arr[2]\n forth_num = arr[3]\n first_arr = (first_num..second_num).to_a\n second_arr = (third_num..forth_num).to_a\n merged_array = first_arr.concat(second_arr)\n (merged_array.size - merged_array.uniq.size == arr[4]) ? true : false\nend", "def satisfy?( o )\n as_range = o[:as] || (0..MAX_NUM) # doc. freq. for relation\n ps_range = o[:ps] || (0..MAX_NUM)\n (as_range === @as && ps_range === @ps)\n true\n end", "def open_ended?\n OPEN_ENDED =~ range\n end", "def interval?() triangulated? and complement.comparability?; end", "def test_overlaping\n x = IntegerRange.new(1, 5)\n y = IntegerRange.new(3, 10)\n\n assert_equal(x.mergeable?(y), true)\n assert_equal(y.mergeable?(x), true)\n end", "def ends_before_it_begins?\n end_on? && end_on <= start_on\n end", "def is_date_range?\n start_time.present? && end_time.present?\n end", "def include?(i)\n @range.include?(i)\n end", "def ===(ts)\n ts >= start && ts < finish\n end", "def succeeds?(other)\n range_precedes(other, self)\n end" ]
[ "0.6977244", "0.6929778", "0.67731416", "0.674858", "0.67211276", "0.67209524", "0.66546834", "0.6573191", "0.6429114", "0.6391341", "0.6363969", "0.6352874", "0.6332498", "0.6322249", "0.62675065", "0.6162777", "0.6158347", "0.6155119", "0.61278677", "0.6119522", "0.607159", "0.6068949", "0.6067392", "0.6027233", "0.60175574", "0.60108364", "0.5981414", "0.5981414", "0.59752625", "0.59724647", "0.59667623", "0.5960882", "0.59150076", "0.5901621", "0.5874174", "0.5870297", "0.5858478", "0.58479154", "0.58373386", "0.58373386", "0.58271205", "0.5819753", "0.5803482", "0.57736695", "0.5771595", "0.5769649", "0.57619584", "0.5755745", "0.5750966", "0.5742789", "0.57395893", "0.57332313", "0.5731805", "0.57222813", "0.5722244", "0.57108325", "0.5681323", "0.56796134", "0.56790894", "0.5666991", "0.56562865", "0.5634119", "0.56297106", "0.56288743", "0.5627839", "0.5627839", "0.5611733", "0.5598176", "0.5583488", "0.5569107", "0.5537444", "0.5533781", "0.5523888", "0.5523399", "0.5522708", "0.5520824", "0.55103093", "0.55082387", "0.550178", "0.5486462", "0.547345", "0.5473445", "0.5467065", "0.5456365", "0.5455955", "0.54548585", "0.5451881", "0.54499197", "0.5445901", "0.5442251", "0.54411066", "0.5440093", "0.54389787", "0.54384035", "0.543712", "0.54348683", "0.54341525", "0.54222476", "0.5418941", "0.54060847" ]
0.63622123
11
From the page 651 rng === val > true or false If rng excludes its end, returns rng.start <= val <rng.end. If rng is inclusive, returns rng.start <= val <= rng.end. Note that this implies that val need not be a member of the range itself (for example, a float fall between the start and end values of a range of integers). Implemented by calling include? Conveniently, the === operator is used by case statements.
def test_Range_InstanceMethods_excludes assert_equal(true, (1..10) === 5) assert_equal(false, (1..10) === 15) assert_equal(true, (1..10) === 3.14159) assert_equal(true, ('a'..'j') === 'c') assert_equal(false, ('a'..'j') === 'z') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_range?(val, range)\n return true unless range\n\n if range.is_a?(Hash)\n result = true\n result &= ( val < range[:before] ) if range[:before]\n result &= ( val > range[:after] ) if range[:after]\n result &= ( val <= range[:max] ) if range[:max]\n result &= ( val >= range[:min] ) if range[:min]\n result &= ( val < range[:less_than] ) if range[:less_than]\n result &= ( val <= range[:less_than_or_equal_to] ) if range[:less_than_or_equal_to]\n result &= ( val > range[:greater_than] ) if range[:greater_than]\n result &= ( val >= range[:greater_than_or_equal_to] ) if range[:greater_than_or_equal_to]\n result\n else\n range = [range] unless range.respond_to?(:include?)\n range.include?(val)\n end\n end", "def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend", "def covers?(*args)\n other = coerce_range(*args)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n self.begin <= other.begin and other.end <= self.end\n end\n end", "def include_with_range?(value)\n if value.is_a?(::Range)\n operator = exclude_end? ? :< : :<=\n end_value = value.exclude_end? ? last.succ : last\n include?(value.first) && (value.last <=> end_value).send(operator, 0)\n else\n include_without_range?(value)\n end\n end", "def in_range?\n self > LOWER_BOUND && self <= UPPER_BOUND\n end", "def range_include?(zelf, other)\n # 1...10 includes 1..9 but it does not include 1..10.\n operator = zelf.exclude_end? && !other.exclude_end? ? :< : :<=\n zelf.include?(other.first) && other.last.send(operator, zelf.last)\nend", "def include_range? other_range\n case other_range\n when Range\n if other_range.first >= self.first && other_range.last <= self.last\n return true\n else\n return false\n end\n else\n raise \"unsupported type\"\n end\n end", "def within?(value)\n value >= @lower and value <= @upper\n end", "def meets?(*args)\n other = coerce_range(*args)\n self.begin == other.end or other.begin == self.end\n end", "def within?(val,lower,upper)\n\n check_pre((\n (val.nat?) and\n (lower.nat?) and\n (upper.nat?)\n ))\n\n (val >= lower) and (val <= upper)\n\n end", "def within?(in_val, in_lower, in_upper)\n\tcheck_pre(((in_val.int?) and (in_lower.int?) and (in_upper.int?)))\n\t(in_lower..in_upper) === in_val\nend", "def within?(val, lower, upper)\n check_pre((\n (val.int?) and\n (lower.int?) and\n (upper.int?)\n ))\n\n ((val >= lower) and (val <= upper))\nend", "def in_range?\n return self.range.include?([@x, @y])\n end", "def <=>(other) range_start <=> other.range_start end", "def range_includes_item?(range, item)\n range.begin <= item && item <= range.end\n end", "def between?(min, max)\n #This is a stub, used for indexing\n end", "def ranges_include?(value)\n any? { |range| Array(range).include?(value) }\n end", "def is_effective?(value)\n @range_lower <= value && value <= @range_upper\n end", "def valid?(range)\n range[0] < range[1]\nend", "def between?(min, max)\n self >= min and self <= max\n end", "def test_bounds(val, min, max)\n val >= min && val <= max\n end", "def include?(value)\n candidate = intervals\n .find { |min, max| max >= value }\n candidate && (candidate[0] <= value)\n end", "def between?(x,y) end", "def between?(p0, p1) end", "def between(num, min, max)\n if min <= num && max >= num\n return true\n else \n return false\n end\nend", "def between?(value, min = nil, max = nil)\n if min and value < min\n return false\n elsif max and value > max\n return false\n end\n return true\n end", "def touching?(range)\n range.end == self.start || self.end == range.start\n end", "def verify_range(value)\n a = (20...30) === value\n if a != true\n puts \"#{value} is not in range of 20 to 30\"\n else\n puts \"#{value} is in range of to 20 to 30\"\n end\nend", "def ==(other)\n return true if equal? other\n\n other.kind_of?(Range) and\n self.first == other.first and\n self.last == other.last and\n self.exclude_end? == other.exclude_end?\n \n end", "def check(range, value)\n result = true\n unless range.nil?\n if range.class == Range\n result = (range === value)\n elsif range.class == Fixnum\n result = (value >= range)\n end\n end\n result\n end", "def between(numb, lower, higher)\n return true if numb >= lower && numb <= higher\n return false\nend", "def test_Range_InstanceMethods_eql?\n\t\tassert_equal(true , (1..10).eql?(Range.new(1,10)))\n\t\tassert_equal(false, (1..10).eql?([1..10]))\n\tend", "def in_range?(key)\n (key>=range_start) && (range_end==LAST_POSSIBLE_KEY || key < range_end)\n end", "def in_ranges?(num, ranges)\n result = false\n ranges.each do |range|\n if range.include?(num)\n result = true\n end\n end\n return result\nend", "def _index_in_range?(i, max, min)\n !((i > max) || (i < min))\n end", "def eql?(range)\n return false if range.nil? || low.nil? || range.low.nil? || high.nil? || range.high.nil?\n \n return low.value == range.low.value && low.inclusive? == range.low.inclusive? &&\n high.value == range.high.value && high.inclusive? == range.high.inclusive?\n end", "def out_of_bound?(value, min, max)\n return value > max || value < min\n end", "def check_bounds(value)\n return value >= self.bound.lower_bound && value <= self.bound.upper_bound\n end", "def is_a_3_dot_range?(range)\n a = range.first\n b = range.last\n range != (a..b)\nend", "def range(c_begin, c_end, alphabet = DEFAULT_ALPHABET)\n any((c_begin..c_end).to_a, alphabet)\n end", "def between_min_max?(value, min, max) # TODO Repetido en concern/Methods\n return true if value >= min and value <= max\n return false\n end", "def ===(value)\r\n @range === value\r\n end", "def check_range(rng)\n new(rng).results\n end", "def in_range(a, b)\n return ((a >= 20 && a <= 30) || (b >= 20 && b <= 30));\t\nend", "def intersects?(*args)\n other = coerce_range(*args)\n raise ArgumentError, \"#{self.begin.class} expected, received #{other.begin.class}\" unless other.begin.kind_of?(self.begin.class)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n other.begin < self.end and self.begin < other.end\n end\n end", "def is_between_strict(num,first,second)\n if num > first && num < second || num < first && num > second\n return true\n end\n return false\nend", "def overlaps?(range)\n !(completely_left_of?(range) || completely_right_of?(range))\n end", "def test_Range_InstanceMethods_include?\n\t\tr = 1..10\n\t\tassert_equal(true, r.include?(5))\n\t\tassert_equal(true, r.include?(5.5))\n\t\tassert_equal(true, r.include?(10))\n\n\t\tr = 1...10\n\t\tassert_equal(false, r.include?(10))\n\n\t\tr = 'a'..'z'\n\t\tassert_equal(true, r.include?('b'))\n\t\tassert_equal(false, r.include?('ruby'))\n\tend", "def between(lower, upper)\n (self >= lower) & (self <= upper)\n end", "def include?(i)\n @range.include?(i)\n end", "def between_min_max?(value, min, max)\n return true if value >= min and value <= max\n return false\n end", "def is_winner_on_range?(range)\n return false unless range.uniq.size == 1 && !range.first.nil?\n\n @winner = range.first\n return true\n end", "def matched_by_extended_range?(range)\n recompose\n subtags = @composition.split(Const::HYPHEN)\n subranges = range.downcase.split(Const::HYPHEN)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == Const::WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def ===(value)\n # MRI uses <=> to compare, so must we.\n\n beg_compare = (@begin <=> value)\n return false unless beg_compare\n\n if Comparable.compare_int(beg_compare) <= 0\n end_compare = (value <=> @end)\n if @excl\n return true if Comparable.compare_int(end_compare) < 0\n else\n return true if Comparable.compare_int(end_compare) <= 0\n end\n end\n\n return false\n end", "def test_ranges\r\n assert_equal(@range.begin.to_f, @p2.to_f)\r\n assert(@range.cover?(@p5))\r\n assert(@range.end == @p8)\r\n assert(@range2.exclude_end?)\r\n assert_false(@range.exclude_end?)\r\n assert(@range.include?(@p3))\r\n assert(@range.max == @p8)\r\n assert(@range2.max == @p7)\r\n assert(@range.last(3) == [@p6, @p7, @p8])\r\n assert(@range.size == nil)\r\n end", "def within?(other)\n range_within_other?(self,other)\n end", "def overlap? range\n !(self & range).nil?\n end", "def build_range(key, val, negate)\n if val.exclude_end?\n # begin...end range\n if negate\n \"#{key} < #{quoted(val.begin, key)} or #{key} >= #{quoted(val.end, key)}\"\n else\n \"#{key} >= #{quoted(val.begin, key)} and #{key} < #{quoted(val.end, key)}\"\n end\n else\n # begin..end range\n if negate\n \"#{key} < #{quoted(val.begin, key)} or #{key} > #{quoted(val.end, key)}\"\n else\n \"#{key} >= #{quoted(val.begin, key)} and #{key} <= #{quoted(val.end, key)}\"\n end\n end\n end", "def check_range(a,b)\n if (20..30).include?(a)\n puts \"a is in the range (20..30).\"\n else\n puts \"a is not in the range (20..30).\"\n end\n if (20..30).include?(b)\n puts \"b is in the range (20..30).\"\n else\n puts \"b is not in the range (20..30).\"\n end\nend", "def range\n\t\t\t#(@end > @start) ? (@start .. @end) : (@end .. @start)\n\t\t\t(start .. self.end)\n\t\tend", "def test_Range_InstanceMethods_compare\n\t\tassert_equal(true, (1..3) == Range.new(1,3))\n\t\tassert_equal(false, (1..3) == (2..4))\n\tend", "def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend", "def between?(inclusive, start, stop, event)\n ((after?(inclusive, start, event)) &&\n (before?(inclusive, stop, event)))\nend", "def between(middle, first, last)\n if first < middle and middle < last\n return true\n else\n return false\n end\nend", "def between(min, max, &block)\n return false unless (1..min).all? { try(&block) }\n (min..max).all? { try(&block) } # only using all?'s shortcut property\n true\n end", "def valid_range?\n (0..@max_num).cover?(@number)\n end", "def between?(num, x, y)\n\nend", "def in_ranged_array?(ranged_ary, num)\n !!ranged_ary.find {|n| n === num }\n end", "def range_cover?(outer, inner)\n outer.cover?(inner.begin) && outer.cover?(inner.end)\nend", "def between_strict(checked,number1,number2)\n if checked >= number2\n return false\n end\n if checked <= number1\n return false\n end\n return true\nend", "def matched_by_extended_range?(range)\n\n subtags = decomposition.dup\n subranges = range.to_str.downcase.split(HYPHEN_SPLITTER)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def values_between? a, b\n is_ok = self.start_value.between?(a,b)\n \n if is_ok\n self.value_changes.each do |offset, setting|\n setting.value.between?(a,b)\n end\n end\n return is_ok\n end", "def between_strict(n1, n2, n3)\n if n1 > n2 && n1 < n3\n return true\n else\n return false\n end\nend", "def in_range\n\t\trange = Set[1, 2, 3, 4, 5,\n\t\t\t\t\t\t\t\t6, 7, 8, 9, 10,\n\t\t\t\t\t\t\t 11, 12, 13, 14, 15,\n\t\t\t\t\t\t\t\t16, 17, 18, 19, 20,\n\t\t\t\t\t\t\t\t21, 22, 23, 24, 25,\n\t\t\t\t\t\t\t\t26, 27, 28, 29, 30]\n\n\t\tif @landmarks.subset?(range)\n\t\t\treturn true\n\t\tend\n\n\t\treturn false\n\tend", "def lower_bound_inclusive\n lower_bound\n end", "def is_a_3_dot_range?(range)\n range.exclude_end?\nend", "def all_in_ranges?(nums, ranges)\n if nums.empty?\n return false\n end\n nums.each do |num|\n if !in_ranges?(num, ranges)\n return false\n end\n end\n true\nend", "def between(val)\n if val <= 9.95 && val >= 4.45\n puts \"Value #{val} is between 4.45 and 9.95\"\n else puts \"Value #{val} is not between 4.45 and 9.95\"\n end\nend", "def range1d?(o)\n o.int_range?\nend", "def checkcondition(min, max, num)\n if(min<=num and max >= num)\n return true\n else\n return false\n end\n end", "def between_strict(num1, num2, num3)\n if num1 > num2 and num1 < num3\n return true\n end\n return false\nend", "def range_intersect?(s1, s2)\n s1range = s1.to_a.min..s1.to_a.max\n s2range = s2.to_a.min..s2.to_a.max\n return s1range.include?(s2range.first) || s2range.include?(s1range.first)\nend", "def <=>(other)\n case cmp = @range.begin <=> other.range.begin\n when 0 then @range.end <=> other.range.end\n else cmp\n end\n end", "def <=>(other)\n case cmp = @range.begin <=> other.range.begin\n when 0 then @range.end <=> other.range.end\n else cmp\n end\n end", "def between_strict(num1, num2, num3)\n if num1 > num2\n if num1 < num3\n return true\n else return false\n end\n else return false\n end\nend", "def page_in_range external_start_page, external_end_page, internal_start_page, internal_end_page\n\n # start_page = page_hash[:start_page]\n # end_page = page_hash[:end_page]\n # the antcat page ranges, ok.\n unless external_start_page.nil? || internal_start_page.nil?\n if external_start_page > internal_start_page\n # puts (\"Page start range mismatch. Existing range: \" +\n # internal_start_page.to_s +\n # \"-\" +\n # external_end_page.to_s +\n # \" This range: \" +\n # internal_start_page.to_s +\n # \"-\" + internal_end_page.to_s)\n return false\n end\n end\n unless internal_end_page.nil? || external_end_page.nil?\n if external_end_page < internal_end_page\n # puts (\"Page end range mismatch Existing range: \" +\n # internal_start_page.to_s +\n # \"-\" +\n # external_end_page.to_s +\n # \" This range: \" +\n # internal_start_page.to_s +\n # \"-\" + internal_end_page.to_s)\n return false\n end\n end\n true\n end", "def between_strict(num1,num2,num3)\n if num2 > num3\n if num1>num3 && num1<num2\n return true\n end\n return false\n end\n \n if num1>num2 && num1<num3\n return true\n end\n return false\nend", "def price_range?\n !(price_range.first == price_range.last)\n end", "def price_range?\n !(price_range.first == price_range.last)\n end", "def between(num1, num2, num3)\n if num1 >= num2 && num1 <= num3\n return true\n else\n return false\n end\nend", "def between(num1, num2, num3)\n if num1 >= num2 && num1 <= num3\n return true\n else\n return false\n end\nend", "def limitcheck(num, lower, upper)\n (num >= lower and num <= upper) && num\n end", "def limitcheck(num, lower, upper)\n (num >= lower and num <= upper) && num\n end", "def not_within_hypothetical_range?(dest)\n\t(dest[0] < 0 || dest[1] < 0) || (dest[0] > 7 || dest[1] > 7)\nend", "def <=(value)\n self < value or self == value\n end", "def ==(other)\r\n @range == other.range\r\n end", "def inclusive!\n @inclusive = true\n end", "def is_within(number, lower, upper)\n RangeAssertion.new(number, lower, upper)\n end", "def in_range?( answer_object )\n (@above.nil? or answer_object > @above) and\n (@below.nil? or answer_object < @below) and\n (@in.nil? or @in.include?(answer_object))\n end" ]
[ "0.7339574", "0.7339574", "0.72782993", "0.7275126", "0.709013", "0.7085354", "0.6924308", "0.6886121", "0.68578357", "0.6772248", "0.6740891", "0.6678802", "0.66721594", "0.6670432", "0.6660282", "0.663764", "0.6587948", "0.65817", "0.655895", "0.6540969", "0.6527654", "0.65094155", "0.6437357", "0.6418791", "0.6415297", "0.6395366", "0.6395239", "0.6385948", "0.6381844", "0.63593245", "0.6326502", "0.63163525", "0.63049656", "0.63033134", "0.62850946", "0.6270105", "0.6264478", "0.6248447", "0.6246838", "0.6233012", "0.62305546", "0.6205458", "0.61870164", "0.6182863", "0.6181972", "0.6181332", "0.61728674", "0.61505437", "0.61434877", "0.614292", "0.61427313", "0.6135539", "0.6133185", "0.61316556", "0.6058755", "0.60511094", "0.604558", "0.6042878", "0.604229", "0.59981006", "0.5992916", "0.5991586", "0.59820336", "0.5980442", "0.59518194", "0.5951222", "0.59415334", "0.5941123", "0.5939449", "0.5906311", "0.5900569", "0.58952534", "0.5895081", "0.5894271", "0.589291", "0.58887327", "0.5886072", "0.587406", "0.5866433", "0.58599627", "0.5847086", "0.58459693", "0.58309954", "0.5814447", "0.58124673", "0.58124673", "0.5800209", "0.57987756", "0.57979923", "0.57908154", "0.57908154", "0.5781237", "0.5781237", "0.5780198", "0.5780198", "0.5773407", "0.57718027", "0.5764596", "0.5763248", "0.5758875", "0.57577395" ]
0.0
-1
From the page 651 rng.begin > obj Returns the first object of rng.
def test_Range_InstanceMethods_begin assert_equal('a', ('a'..'b').begin) assert_equal('a', ('a'...'b').begin) assert_equal(1, (1..100).begin) assert_equal(1, (1...100).begin) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first\n @range.first\n end", "def begin\n @ranges.size == 1 ? @ranges[0].begin : nil\n end", "def range_start; range.first; end", "def get_next_object\n unless( @next_object )\n @next_object = reserve\n get_more\n end\n get_head\n end", "def first() end", "def get_rng \n end", "def head(obj); end", "def begin() end", "def first\n @cursor_instance.jump( nil )\n return current\n end", "def first; self.objects.first end", "def first\n @enumerable.first\n end", "def min\n @range.begin\n end", "def start\n @range.start\n end", "def begin\n empty? ? 0 : first.begin\n end", "def begin_pos; end", "def rng\n \"#{first}..#{last}\"\n end", "def first\n @head\n end", "def first; end", "def first; end", "def rassoc obj\n @array.each do |elem|\n if elem.respond_to? :at and elem.at(1) == obj\n return elem\n end\n end\n\n nil\n end", "def first\n enumerator(:limit => 1).first \n end", "def begin_pos=(_); end", "def end; self.begin + self.size - 1; end", "def test_Range_InstanceMethods_first\n\t\tassert_equal('aa', ('aa'..'bb').first)\n\t\tassert_equal(['aa','ab','ac','ad','ae'], ('aa'..'bb').first(5))\n\tend", "def first_offset; end", "def first_offset; end", "def next(object)\n elements[elements.index(object) + 1]\n end", "def range \n Range.new(@first, @last)\n end", "def get_head\n nekst = @next_object\n @next_object = get_next_for(nekst)\n return nekst\n end", "def first\n find.limit(1).next_document\n end", "def begin(p0) end", "def begin_iterator\n ListIterator.new @head, self\n end", "def next\n self.offset(1)\n end", "def object\n first.object\n end", "def bsearch_first (range = 0 ... self.length, &block)\r\n boundary = bsearch_lower_boundary(range, &block)\r\n if boundary >= self.length || yield(self[boundary]) != 0\r\n return nil\r\n else \r\n return boundary\r\n end\r\n end", "def first?; end", "def bsearch_first (range = 0 ... self.length, &block)\n boundary = bsearch_lower_boundary(range, &block)\n if boundary >= self.length || yield(self[boundary]) != 0\n return nil\n else \n return boundary\n end\n end", "def get_next_raw( object )\n sys_mem( object.get_type , 1)\n end", "def first\n end", "def outidx\n @index_range.begin\n end", "def next(pointer); end", "def next(pointer); end", "def index(object)\n\t\treturn nil if empty? # edgecase\n\t\tfound = first_index(object)\n\t\treturn found[0] ? found[1] : nil\n\tend", "def next() end", "def next() end", "def object\n first.object\n end", "def first\r\n self[0]\r\n end", "def iterator?() end", "def start; @sequence[0]; end", "def first\n self.slice(0)\n end", "def get_object(iter)\n raise \"depricated - please use iter[OBJECT]\"\n iter[ self.class.column_id[:object] ]\n end", "def first\n self[0]\n end", "def first\n self[0]\n end", "def normal\n first\n end", "def [](i); self.objects.ith(i) end", "def bsearch_first(range = 0...length, &block)\n boundary = bsearch_lower_boundary(range, &block)\n if boundary >= length || yield(self[boundary]) != 0\n return nil\n else\n return boundary\n end\n\n end", "def first\n @head.val\n end", "def first\n self[0]\n end", "def first\n @head.lru_next\n end", "def first_line_only(range); end", "def first_line_only(range); end", "def first_line_only(range); end", "def range_start\n @character_range[0]\n end", "def range; end", "def range; end", "def range; end", "def first(n = T.unsafe(nil)); end", "def first(n = T.unsafe(nil)); end", "def caar; first.first end", "def start\n\t\t\t@start < @end ? @start : @end\n\t\tend", "def first\n to_a.first\n end", "def first\n all[0]\n end", "def next\n at(position + 1)\n end", "def next\r\n next_values[0]\r\n end", "def first\n self.take(1)[0]\n end", "def first\n @poss[0]\n end", "def current_iteration\n iterations.first\n end", "def head\n if @head.nil?\n nil\n else\n at_index(0)\n end\n end", "def first_index(object, min=0, max=length-1)\n\t\treturn [nil, nil] if empty?\n\t\tobject, found = @sort_by ? @sort_by.call(object) : object, nil\n\t\treturn [nil, max] if cmp2(at(max), object) == -1\n\t\treturn [nil, nil] if cmp2(at(min), object) == 1\n\t\tleft,right = min,max\n\t\twhile(left<right)\n\t\t\tcase cmp2(at(index=left+(right-left).div(2)), object)\n\t\t\t\twhen -1: left = index+1\n\t\t\t\twhen 0: right = index-1; found = true\n\t\t\t\twhen 1: right = index-1\n\t\t\t\telse raise \"Inalid returnvalue\"\n\t\t\tend\n\t\tend\n\t\tright = min if right < min\n\t\tcase cmp2(at(index=left+(right-left).div(2)), object)\n\t\t\twhen -1: found ? [found, index+1] : [found, index]\n\t\t\twhen 0: [true, index]\n\t\t\twhen 1: [found, index-1]\n\t\t\telse raise \"Inalid returnvalue\"\n\t\tend\n\tend", "def first\n limit(1).to_a.first\n end", "def next!() end", "def starting_position; end", "def ==(obj)\n self.base == obj.base && self.range == obj.range && self.pointer == obj.pointer\n end", "def each_identity; end", "def next\n last? ? nil : @collection[index + 1]\n end", "def find(obj)\n @vertices.find { |v| v.obj == obj }\n end", "def at(offset)\n if loaded? || (offset >= 0 ? lazy_possible?(head, offset + 1) : lazy_possible?(tail, offset.abs))\n super\n elsif offset >= 0\n first(:offset => offset)\n else\n last(:offset => offset.abs - 1)\n end\n end", "def get_first\n return @head.data if @head\n return @head\n end", "def afind_one(spec_or_object_id=nil, opts={})\n spec = case spec_or_object_id\n when nil\n {}\n when BSON::ObjectId\n {:_id => spec_or_object_id}\n when Hash\n spec_or_object_id\n else\n raise TypeError, \"spec_or_object_id must be an instance of ObjectId or Hash, or nil\"\n end\n afind(spec, opts.merge(:limit => -1)).next_document\n end", "def get_iterator\n\t\tend", "def next()\n idx = @curridx\n idx += 1 unless full?\n return @defs[idx]\n end", "def lookup(obj, pos); end", "def peek\n @first.val\n end", "def each\n if @length > 0\n item = @head\n begin\n yield item.object\n item = item.next\n end until item.nil?\n end\n end", "def bound_first(first)\n if first < 1 then 1 else first end\n end", "def last\n @range.last\n end", "def intend_next\n intend_with :first, :next\n end", "def intend_next\n intend_with :first, :next\n end", "def peek\n raise StopIteration if @enumerators.empty?\n minimum_enumrator.peek\n end", "def rng\n box_muller\n end" ]
[ "0.6471917", "0.64614993", "0.63639176", "0.60616535", "0.60181355", "0.5943039", "0.59360266", "0.580613", "0.57939255", "0.5789423", "0.5752141", "0.5746536", "0.57435054", "0.57434285", "0.5620421", "0.5593492", "0.559294", "0.5541309", "0.5541309", "0.5528023", "0.5501722", "0.5495846", "0.54861397", "0.5471405", "0.5461906", "0.5461906", "0.5442643", "0.542002", "0.5397507", "0.5386011", "0.5376057", "0.53670806", "0.53478396", "0.52963746", "0.5293643", "0.5253987", "0.52483356", "0.5205099", "0.5204006", "0.52021295", "0.5201514", "0.5201514", "0.51924664", "0.5182361", "0.5182361", "0.5181938", "0.5154396", "0.51411813", "0.5135214", "0.51348954", "0.5129563", "0.5127371", "0.5127371", "0.51263887", "0.5117332", "0.51173013", "0.5106373", "0.5100532", "0.50981194", "0.5097474", "0.5097474", "0.5097474", "0.50773126", "0.5074083", "0.5074083", "0.5074083", "0.5056714", "0.5056714", "0.5054257", "0.5052462", "0.50192237", "0.5016237", "0.5006252", "0.49849397", "0.49789956", "0.49740392", "0.49718994", "0.49678102", "0.49659607", "0.4955423", "0.4947506", "0.4947022", "0.49411815", "0.49408716", "0.49402508", "0.49392074", "0.49350524", "0.4926596", "0.4919405", "0.49116802", "0.49021977", "0.4898313", "0.48877424", "0.48801288", "0.48744163", "0.48668087", "0.48664388", "0.48664388", "0.48648497", "0.48606038" ]
0.536386
32
From the page 652 rng.end > obj Returns the object that defines the end of rng.
def test_Range_InstanceMethods_end assert_equal(10, (1..10).end) assert_equal(10, (1...10).end) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def end; self.begin + self.size - 1; end", "def end\n @range.end\n end", "def end\n @ranges.size == 1 ? @ranges[0].end : nil\n end", "def last\n @range.last\n end", "def range_end\n @character_range[1]\n end", "def end_pos; end", "def end_pos; end", "def end(end_key)\n self.class.new(collection, range.merge({end: end_key, end_inclusive: true}))\n end", "def end\n empty? ? 0 : last.end\n end", "def end\n @history.objects.find { |o| o.name == \"end\" }.val\n end", "def end_pos=(_); end", "def end_row\n strict_position.end_row\n end", "def end\n attributes.fetch(:end)\n end", "def tail(obj); end", "def end\n j_instance.getEnd\n end", "def max\n @range.end\n end", "def outidx\n @index_range.begin\n end", "def rng\n \"#{first}..#{last}\"\n end", "def end\n regions.max.end\n end", "def last\n at(-1)\n end", "def last\n @tail\n end", "def rindex(object)\n\t\treturn nil if empty? # edgecase\n\t\tfound = last_index(object)\n\t\treturn found[0] ? found[1] : nil\n\tend", "def reset_end!\n @end = nil\n end", "def last\n @enumerable.last\n end", "def test_Range_InstanceMethods_last\n\t\tassert_equal('bb', ('aa'..'bb').last)\n\t\tassert_equal(['ax','ay','az','ba','bb'], ('aa'..'bb').last(5))\n\tend", "def range\n\t\t\t#(@end > @start) ? (@start .. @end) : (@end .. @start)\n\t\t\t(start .. self.end)\n\t\tend", "def range \n Range.new(@first, @last)\n end", "def end_at\n I18n.l(object.end_at)\n end", "def last() end", "def test_Range_InstanceMethods_exclude_end?\n\t\t# TODO, need add some testcases.\n\tend", "def end_iterator\n ListIterator.new @tail, self\n end", "def bottom\n scoped_all.size + start - 1\n end", "def end=(new_end)\n @end = new_end ? new_end.to_i : nil\n end", "def inclusive_ending\n self.exclude_end? ? ending - 1 : ending\n end", "def end_at\n @attributes[:end_at]\n end", "def end_at\n @attributes[:end_at]\n end", "def increment_upper\n Range.new(self.begin, self.end + 1)\n end", "def last; end", "def last; end", "def last; end", "def stop\n return self.seq_region_end\n end", "def end_date\n\t\tself.next.start_date - 1\n\tend", "def last\n out = nil\n\n each {|i| out = i }\n\n out\n end", "def zero_end\n @chr_end\n end", "def get_last\n return @position\n end", "def end?()\n END_MARKER.equal? _next_element\n end", "def get_upper_limit_of(range)\n range.end\nend", "def get_rng \n end", "def range_start; range.first; end", "def getEndPoint()\n geoObject().lastPoint() ;\n end", "def set_end(t)\n @end_t = t\n end", "def last\n @tail.val\n end", "def last_index\n @last_index\n end", "def tail\n @values[1..-1]\n end", "def _end!; end", "def length\n @end - @start + 1\n end", "def last\n self[-1]\n end", "def find_page_end\n \n end", "def bsearch_last (range = 0 ... self.length, &block)\r\n # `- 1' for canceling `lower + 1' in bsearch_upper_boundary.\r\n boundary = bsearch_upper_boundary(range, &block) - 1\r\n\r\n if (boundary <= -1 || yield(self[boundary]) != 0)\r\n return nil\r\n else\r\n return boundary\r\n end\r\n end", "def end?(i = nil)\n if i.nil?\n @gens.detect { |g| g.end? } ? true : false\n else\n @gens[i].end?\n end\n end", "def upper_bound; end", "def last_arg_range(node); end", "def tail\n return @tail\n end", "def last\r\n self[-1]\r\n end", "def last\n left = @left_generator.last\n right = @right_generator.last\n\n if right.nil?\n left\n else\n right\n end\n end", "def coding_region_genomic_end\n strand = self.translation.start_exon.seq_region_strand\n if strand == 1\n return self.translation.end_exon.seq_region_start + ( self.translation.seq_end - 1 )\n else\n return self.translation.start_exon.seq_region_end - ( self.translation.seq_start - 1 )\n end\n end", "def end_time\n eval(self.end) if self.end.present?\n end", "def is_end?(cell)\n @end_cell.eql?(cell)\n end", "def nontrivial_end_line\n if successor\n successor.line_numbers.begin - 1\n else\n @document.last_non_empty_line\n end\n end", "def source_end\n default_result = children.select { |child| Sexp === child }.\n map(&:source_end).compact.last\n case type\n when :@ident, :@int, :@kw, :@float, :@tstring_content, :@regexp_end,\n :@ivar, :@cvar, :@gvar, :@const, :@label, :@CHAR, :@op\n text, location = children\n source_end = location.dup\n source_end[1] += text.size\n source_end\n when :string_literal\n if source_begin\n result = default_result.dup\n result[1] += 1\n result\n end\n when :string_embexpr, :dyna_symbol\n if default_result\n result = default_result.dup\n result[1] += 1\n result\n end\n when :hash\n forwardtrack_searching(default_result, '}') if default_result\n when :array\n forwardtrack_searching(default_result, ']') if default_result\n else\n default_result\n end\n end", "def last\n self[-1]\n end", "def range; end", "def range; end", "def range; end", "def tail\n \t@array[-1]\n end", "def last_line_only(range); end", "def last_line_only(range); end", "def last_line_only(range); end", "def end_node\n if !tss.empty?\n return self\n else\n return snd.first.end_node\n end\nend", "def tail\n\t\treturn @tail\n\tend", "def last\n end", "def end_index\n ei = self.current_page * self.results_per_page\n return (ei < self.total_results ? ei : self.total_results)\n end", "def max\n if @end.nil?\n ::Kernel.raise ::RangeError, 'cannot get the maximum of endless range'\n elsif block_given?\n super\n elsif [email protected]? && (@begin > @end ||\n @excl && @begin == @end)\n nil\n else\n `#{@excl} ? #{@end} - 1 : #{@end}`\n end\n end", "def end_line\n attributes.fetch(:endLine)\n end", "def get_upper_limit_of(range)\n range.last\nend", "def max\n [self.begin, self.end].max\n end", "def end(end_key)\n KeyValueList.new(self).end(end_key)\n end", "def last\n self.slice(self.size - 1)\n end", "def end_date\n\t \tTime.at(self.end_time) rescue nil\n\t end", "def last\n\t\t\t@last\n\t\tend", "def exclude_end?\n @ranges.size == 1 ? @ranges[0].exclude_end? : nil\n end", "def removeEnd\n @indices.delete(@content[-1])\n @content.pop\n end", "def intend_next\n intend_with :first, :next\n end", "def intend_next\n intend_with :first, :next\n end", "def get_next_object\n unless( @next_object )\n @next_object = reserve\n get_more\n end\n get_head\n end", "def last\n return each\n end", "def last\n tail.data\n end", "def last_rut; end", "def end_date\n @raw.last.date\n end", "def last_i\n size - 1\n end" ]
[ "0.7237669", "0.69368935", "0.67486405", "0.6460771", "0.6437915", "0.6182963", "0.6182963", "0.61781067", "0.6131008", "0.61212075", "0.6050402", "0.5983753", "0.5875641", "0.5874183", "0.5869698", "0.5856579", "0.58346933", "0.5810682", "0.58041155", "0.57766855", "0.5760665", "0.5735816", "0.57181615", "0.568204", "0.5680488", "0.56747246", "0.56559515", "0.56534296", "0.56236285", "0.56085145", "0.56047237", "0.55973065", "0.55892295", "0.5579078", "0.55199355", "0.55199355", "0.55087996", "0.5505928", "0.5505928", "0.5505928", "0.5497249", "0.5494239", "0.54879403", "0.54868335", "0.5468741", "0.5444855", "0.5425346", "0.5412991", "0.54106885", "0.5409289", "0.54068416", "0.5385298", "0.5381244", "0.53651875", "0.5362248", "0.53572005", "0.5349098", "0.53461105", "0.5344473", "0.53416574", "0.5330491", "0.53296757", "0.5325346", "0.5321728", "0.53164274", "0.5303136", "0.53028333", "0.5300723", "0.5299564", "0.5296718", "0.52894676", "0.52871776", "0.52871776", "0.52871776", "0.5285784", "0.5284782", "0.5284782", "0.5284782", "0.528388", "0.5281631", "0.5279658", "0.5254856", "0.52533734", "0.52501214", "0.52429247", "0.5242838", "0.5227079", "0.5225318", "0.5223996", "0.5216609", "0.5209619", "0.5201594", "0.51844627", "0.51844627", "0.5180732", "0.51775277", "0.51634985", "0.5162988", "0.515907", "0.51573473" ]
0.6355115
5
From the page 653 rng.eql?(obj) > true or false Returns true if obj is a range whose beginning and end are the the same as those in rng (compared using eql?) and whose exclusive flag is the same as rng.
def test_Range_InstanceMethods_eql? assert_equal(true , (1..10).eql?(Range.new(1,10))) assert_equal(false, (1..10).eql?([1..10])) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n return true if equal? other\n\n other.kind_of?(Range) and\n self.first == other.first and\n self.last == other.last and\n self.exclude_end? == other.exclude_end?\n \n end", "def meets?(*args)\n other = coerce_range(*args)\n self.begin == other.end or other.begin == self.end\n end", "def ==(other)\r\n @range == other.range\r\n end", "def touching?(range)\n range.end == self.start || self.end == range.start\n end", "def ==(obj)\n self.base == obj.base && self.range == obj.range && self.pointer == obj.pointer\n end", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n range_start_index == o.range_start_index &&\n range_end_index == o.range_end_index &&\n fallback_font_list == o.fallback_font_list\n end", "def eql?(range)\n return false if range.nil? || low.nil? || range.low.nil? || high.nil? || range.high.nil?\n \n return low.value == range.low.value && low.inclusive? == range.low.inclusive? &&\n high.value == range.high.value && high.inclusive? == range.high.inclusive?\n end", "def ===(value)\r\n @range === value\r\n end", "def is_winner_on_range?(range)\n return false unless range.uniq.size == 1 && !range.first.nil?\n\n @winner = range.first\n return true\n end", "def test_Range_InstanceMethods_compare\n\t\tassert_equal(true, (1..3) == Range.new(1,3))\n\t\tassert_equal(false, (1..3) == (2..4))\n\tend", "def covers?(*args)\n other = coerce_range(*args)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n self.begin <= other.begin and other.end <= self.end\n end\n end", "def include_range? other_range\n case other_range\n when Range\n if other_range.first >= self.first && other_range.last <= self.last\n return true\n else\n return false\n end\n else\n raise \"unsupported type\"\n end\n end", "def test_identical\n x = IntegerRange.new(1, 5)\n y = IntegerRange.new(1, 5)\n\n assert_equal(x.mergeable?(y), true)\n assert_equal(y.mergeable?(x), true)\n end", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n first_row_index == o.first_row_index &&\n first_cell_index == o.first_cell_index &&\n last_row_index == o.last_row_index &&\n last_cell_index == o.last_cell_index &&\n allow_splitting == o.allow_splitting\n end", "def in_range?\n return self.range.include?([@x, @y])\n end", "def in_range?( answer_object )\n (@above.nil? or answer_object > @above) and\n (@below.nil? or answer_object < @below) and\n (@in.nil? or @in.include?(answer_object))\n end", "def range1d?(o)\n o.int_range?\nend", "def check_range(rng)\n new(rng).results\n end", "def intersects?(*args)\n other = coerce_range(*args)\n raise ArgumentError, \"#{self.begin.class} expected, received #{other.begin.class}\" unless other.begin.kind_of?(self.begin.class)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n other.begin < self.end and self.begin < other.end\n end\n end", "def ==(other)\n self.begin == other.begin && self.end == other.end\n rescue NoMethodError\n false\n end", "def overlap? range\n !(self & range).nil?\n end", "def same?(other)\n (from_end == other.from_end and\n to_end == other.to_end and\n overlap == other.overlap)\n end", "def same?(other)\n (from_end == other.from_end and\n to_end == other.to_end and\n overlap == other.overlap)\n end", "def <=>(other) range_start <=> other.range_start end", "def in_range?\n self > LOWER_BOUND && self <= UPPER_BOUND\n end", "def ==(other)\n (other.is_a? Interval) && (@start == other.start && @end == other.end)\n end", "def intersect?(o)\n self.class == o.class && !(@to < o.numeric_from || o.numeric_to < @from)\n end", "def other_offense_in_same_range?(node); end", "def is_a_3_dot_range?(range)\n a = range.first\n b = range.last\n range != (a..b)\nend", "def overlap?(self_range, other_range)\n return true if self_range == other_range \n overlap_helper(self_range, other_range) || overlap_helper(other_range, self_range)\n end", "def eql?(obj)\n self == obj\n end", "def valid?\n return false if @range_start_index.nil?\n return false if @range_end_index.nil?\n true\n end", "def ===(value)\n # MRI uses <=> to compare, so must we.\n\n beg_compare = (@begin <=> value)\n return false unless beg_compare\n\n if Comparable.compare_int(beg_compare) <= 0\n end_compare = (value <=> @end)\n if @excl\n return true if Comparable.compare_int(end_compare) < 0\n else\n return true if Comparable.compare_int(end_compare) <= 0\n end\n end\n\n return false\n end", "def test_overlaping\n x = IntegerRange.new(1, 5)\n y = IntegerRange.new(3, 10)\n\n assert_equal(x.mergeable?(y), true)\n assert_equal(y.mergeable?(x), true)\n end", "def b_include?(obj) # assumes the array is sorted\n range = bsearch_range { |x| x <=> obj } # returned range excludes its last element\n (self[range.first] == obj or self[range.last - 1] == obj)\n end", "def test_ranges\r\n assert_equal(@range.begin.to_f, @p2.to_f)\r\n assert(@range.cover?(@p5))\r\n assert(@range.end == @p8)\r\n assert(@range2.exclude_end?)\r\n assert_false(@range.exclude_end?)\r\n assert(@range.include?(@p3))\r\n assert(@range.max == @p8)\r\n assert(@range2.max == @p7)\r\n assert(@range.last(3) == [@p6, @p7, @p8])\r\n assert(@range.size == nil)\r\n end", "def overlaps?(range)\n !(completely_left_of?(range) || completely_right_of?(range))\n end", "def include?(object)\n object.start >= @start && object.end <= @end\n end", "def verify_range(value)\n a = (20...30) === value\n if a != true\n puts \"#{value} is not in range of 20 to 30\"\n else\n puts \"#{value} is in range of to 20 to 30\"\n end\nend", "def price_range?\n !(price_range.first == price_range.last)\n end", "def price_range?\n !(price_range.first == price_range.last)\n end", "def valid?(range)\n range[0] < range[1]\nend", "def range_include?(zelf, other)\n # 1...10 includes 1..9 but it does not include 1..10.\n operator = zelf.exclude_end? && !other.exclude_end? ? :< : :<=\n zelf.include?(other.first) && other.last.send(operator, zelf.last)\nend", "def range_includes_item?(range, item)\n range.begin <= item && item <= range.end\n end", "def test_disjoint\n x = IntegerRange.new(1, 2)\n y = IntegerRange.new(4, 5)\n\n assert_equal(x.mergeable?(y), false)\n assert_equal(y.mergeable?(x), false)\n end", "def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend", "def range_cover?(outer, inner)\n outer.cover?(inner.begin) && outer.cover?(inner.end)\nend", "def in_range?(val, range)\n return true unless range\n\n if range.is_a?(Hash)\n result = true\n result &= ( val < range[:before] ) if range[:before]\n result &= ( val > range[:after] ) if range[:after]\n result &= ( val <= range[:max] ) if range[:max]\n result &= ( val >= range[:min] ) if range[:min]\n result &= ( val < range[:less_than] ) if range[:less_than]\n result &= ( val <= range[:less_than_or_equal_to] ) if range[:less_than_or_equal_to]\n result &= ( val > range[:greater_than] ) if range[:greater_than]\n result &= ( val >= range[:greater_than_or_equal_to] ) if range[:greater_than_or_equal_to]\n result\n else\n range = [range] unless range.respond_to?(:include?)\n range.include?(val)\n end\n end", "def eql?(obj)\n return false unless obj.is_a?(self.class)\n fields.each do |tag, _|\n if value_for_tag?(tag)\n return false unless (obj.value_for_tag?(tag) && value_for_tag(tag).eql?(obj.value_for_tag(tag)))\n else\n return false if obj.value_for_tag?(tag)\n end\n end\n return true\n end", "def matched_by_extended_range?(range)\n\n subtags = decomposition.dup\n subranges = range.to_str.downcase.split(HYPHEN_SPLITTER)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def test_Range_InstanceMethods_exclude_end?\n\t\t# TODO, need add some testcases.\n\tend", "def test_abutting\n x = IntegerRange.new(1, 2)\n y = IntegerRange.new(3, 4)\n\n assert_equal(x.mergeable?(y), true)\n assert_equal(y.mergeable?(x), true)\n end", "def within?(other)\n range_within_other?(self,other)\n end", "def _index_in_range?(i, max, min)\n !((i > max) || (i < min))\n end", "def eql?(obj_)\n if obj_.kind_of?(::String)\n obj_ = @_format.parse(obj_) rescue nil\n end\n return false unless obj_.kind_of?(Value)\n index_ = 0\n obj_.each_field_object do |field_, value_|\n return false if field_ != @_field_path[index_] || value_ != @_values[field_.name]\n index_ += 1\n end\n true\n end", "def ==(other)\n if self.class.identity_map_on?\n super\n else\n return false if other.nil?\n other.is_a?(Dynamoid::Document) && hash_key == other.hash_key && range_value == other.range_value\n end\n end", "def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend", "def eql?(obj)\n return true if obj.equal?(self)\n obj.eql?(__getobj__)\n end", "def ==(other)\n if self.class.identity_map_on?\n super\n else\n return false if other.nil?\n\n other.is_a?(Dynamoid::Document) && hash_key == other.hash_key && range_value == other.range_value\n end\n end", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n current_value == o.current_value &&\n incremental_change == o.incremental_change &&\n is_horizontal == o.is_horizontal &&\n max == o.max &&\n min == o.min &&\n page_change == o.page_change &&\n shadow == o.shadow &&\n name == o.name &&\n mso_drawing_type == o.mso_drawing_type &&\n auto_shape_type == o.auto_shape_type &&\n placement == o.placement &&\n upper_left_row == o.upper_left_row &&\n top == o.top &&\n upper_left_column == o.upper_left_column &&\n left == o.left &&\n lower_right_row == o.lower_right_row &&\n bottom == o.bottom &&\n lower_right_column == o.lower_right_column &&\n right == o.right &&\n width == o.width &&\n height == o.height &&\n x == o.x &&\n y == o.y &&\n rotation_angle == o.rotation_angle &&\n html_text == o.html_text &&\n text == o.text &&\n alternative_text == o.alternative_text &&\n text_horizontal_alignment == o.text_horizontal_alignment &&\n text_horizontal_overflow == o.text_horizontal_overflow &&\n text_orientation_type == o.text_orientation_type &&\n text_vertical_alignment == o.text_vertical_alignment &&\n text_vertical_overflow == o.text_vertical_overflow &&\n is_group == o.is_group &&\n is_hidden == o.is_hidden &&\n is_lock_aspect_ratio == o.is_lock_aspect_ratio &&\n is_locked == o.is_locked &&\n is_printable == o.is_printable &&\n is_text_wrapped == o.is_text_wrapped &&\n is_word_art == o.is_word_art &&\n linked_cell == o.linked_cell &&\n z_order_position == o.z_order_position &&\n font == o.font &&\n hyperlink == o.hyperlink &&\n link == o.link \n std_dev == o.std_dev\n end", "def range_precedes(rng,oth)\n r1, r2 = matched_range_types(rng,oth)\n diff = if r1.respond_to?(:exclude_end?) && r1.exclude_end?\n 0\n else\n 1\n end\n (r1.end + diff) == r2.begin\n end", "def unique_val?\n @lower == @upper\n end", "def overlap?(input_range)\n a = self.start_date >= input_range.end_date\n b = self.end_date <= input_range.start_date\n return a || b ? false : true \n end", "def ==(obj)\n if (klass = self.class) == obj.class\n klass.mappings.inject(true) do |result, to_from|\n to = to_from.last || to_from.first\n result &&= (obj.send(to) == self.send(to))\n end\n else\n super\n end\n end", "def viewing_ranges\n if @ranges == [] then $spriteset.show_ranges(false) end\n return (@ranges == [] ? false : true)\n end", "def matched_by_extended_range?(range)\n recompose\n subtags = @composition.split(Const::HYPHEN)\n subranges = range.downcase.split(Const::HYPHEN)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == Const::WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def overlaps?(other)\n # overlap == start < finish' AND start' < finish\n self.first <= other.actual_last and other.first <= self.actual_last\n end", "def in_range?(key)\n (key>=range_start) && (range_end==LAST_POSSIBLE_KEY || key < range_end)\n end", "def in_range\n\t\trange = Set[1, 2, 3, 4, 5,\n\t\t\t\t\t\t\t\t6, 7, 8, 9, 10,\n\t\t\t\t\t\t\t 11, 12, 13, 14, 15,\n\t\t\t\t\t\t\t\t16, 17, 18, 19, 20,\n\t\t\t\t\t\t\t\t21, 22, 23, 24, 25,\n\t\t\t\t\t\t\t\t26, 27, 28, 29, 30]\n\n\t\tif @landmarks.subset?(range)\n\t\t\treturn true\n\t\tend\n\n\t\treturn false\n\tend", "def between?(min, max)\n #This is a stub, used for indexing\n end", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n include_zero == o.include_zero &&\n max == o.max &&\n min == o.min &&\n scale == o.scale\n end", "def eql?(*) end", "def eql?(obj)\n super || (Spontaneous::PagePiece === obj && obj.target.eql?(self))\n end", "def contains?(other)\n (other.begin_pos <=> @begin_pos) + (@end_pos <=> other.end_pos) >= (other.empty? ? 2 : 1)\n end", "def book(start_at, end_at)\n i = @array.bsearch_index { |s1, e1| e1 > start_at}\n if i && (@array[i] + [start_at, end_at]).sort != ([start_at, end_at] + @array[i]) && (@array[i] + [start_at, end_at]).sort != ( @array[i] + [start_at, end_at])\n false\n else\n @array.insert(i || -1, [start_at, end_at])\n true\n end\n end", "def has_range?\n !self.domain_ranges.nil?\n end", "def reverse?(other)\n (from_end == other.to_end and\n to_end == other.from_end and\n overlap == other.reverse_overlap)\n end", "def test_enclosed\n x = IntegerRange.new(1, 10)\n y = IntegerRange.new(3, 5)\n\n assert_equal(x.mergeable?(y), true)\n assert_equal(y.mergeable?(x), true)\n end", "def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n mean == o.mean &&\n median == o.median &&\n count == o.count &&\n high == o.high &&\n low == o.low &&\n std_dev == o.std_dev &&\n revisions_upward == o.revisions_upward &&\n revisions_downward == o.revisions_downward &&\n mean_7_days_ago == o.mean_7_days_ago &&\n mean_30_days_ago == o.mean_30_days_ago &&\n mean_60_days_ago == o.mean_60_days_ago &&\n mean_90_days_ago == o.mean_90_days_ago &&\n revisions_upward_last_7_days == o.revisions_upward_last_7_days &&\n revisions_downward_last_7_days == o.revisions_downward_last_7_days &&\n revisions_upward_last_30_days == o.revisions_upward_last_30_days &&\n revisions_downward_last_30_days == o.revisions_downward_last_30_days &&\n revisions_upward_last_60_days == o.revisions_upward_last_60_days &&\n revisions_downward_last_60_days == o.revisions_downward_last_60_days &&\n revisions_upward_last_90_days == o.revisions_upward_last_90_days &&\n revisions_downward_last_90_days == o.revisions_downward_last_90_days &&\n revisions_upward_last_120_days == o.revisions_upward_last_120_days &&\n revisions_downward_last_120_days == o.revisions_downward_last_120_days &&\n revisions_upward_last_150_days == o.revisions_upward_last_150_days &&\n revisions_downward_last_150_days == o.revisions_downward_last_150_days &&\n security == o.security\n end", "def eql?(o)\n return (o.is_a? Document and (o.boost == @boost) and\n (self.keys == o.keys) and (self.values == o.values))\n end", "def start_and_end_set?\n [start, self.end].map(&:present?).uniq.length == 1\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def eql?(other); end", "def eql?(other); end", "def eql?(other); end", "def eql?(other); end", "def eql?(other); end", "def eql?(other); end", "def eql?(other); end", "def test_Range_InstanceMethods_excludes\n\t\tassert_equal(true, (1..10) === 5)\n\t\tassert_equal(false, (1..10) === 15)\n\t\tassert_equal(true, (1..10) === 3.14159)\n\t\tassert_equal(true, ('a'..'j') === 'c')\n\t\tassert_equal(false, ('a'..'j') === 'z')\n\tend", "def check_non_overlapping?(indexes, range)\n return true if indexes.empty?\n\n indexes.each do |val|\n return false if val.cover?(range.begin) || val.cover?(range.end)\n end\n true\n end", "def matched_by_basic_range?(range)\n if range.kind_of?(self.class)\n s = range.recompose.tag\n elsif range.respond_to?(:to_str)\n return true if range.to_str == Const::WILDCARD\n s = self.class.parse(range).tag\n else\n return false\n end\n recompose\n @tag == s || @tag.index(s + Const::HYPHEN) == 0\n rescue\n false\n end", "def intersect? (range1,range2)\n if range1.begin < range2.begin\n if range1.end < range2.begin\n nil\n else\n (range2.begin..range1.end)\n end\n else\n if range2.end < range1.begin\n nil\n else\n (range1.begin..range2.end)\n end\n end\nend", "def test_Range_InstanceMethods_end\n\t\tassert_equal(10, (1..10).end)\n\t\tassert_equal(10, (1...10).end)\n\tend", "def eql?(ct); end", "def eql?(ct); end", "def matched_by_basic_range?(range)\n if range.kind_of?(Composition)\n s = range.composition\n elsif range.respond_to?(:to_str)\n s = range.to_str.downcase\n return true if s == WILDCARD\n else\n return false\n end\n\n composition == s ||\n composition.index(s + HYPHEN) == 0\n end", "def overlaps?(other); end", "def overlaps?(other); end" ]
[ "0.73438793", "0.7283759", "0.710202", "0.6937217", "0.69319475", "0.6856036", "0.6800224", "0.6717256", "0.6631819", "0.6568318", "0.6553385", "0.6368419", "0.6334689", "0.6302752", "0.6270239", "0.6229716", "0.62163496", "0.61921597", "0.6173244", "0.6151612", "0.61438686", "0.6123733", "0.6123733", "0.611651", "0.6082751", "0.60309184", "0.6016065", "0.6006277", "0.59849316", "0.5983614", "0.59371066", "0.59325486", "0.5912594", "0.5888384", "0.5875247", "0.5866376", "0.5852992", "0.583106", "0.58189285", "0.5810295", "0.5810295", "0.5808595", "0.5800857", "0.57960063", "0.579147", "0.5744911", "0.5738601", "0.57316077", "0.57170886", "0.57101107", "0.5707548", "0.5707337", "0.5690861", "0.56775707", "0.5671739", "0.5657028", "0.5639433", "0.56386495", "0.5637762", "0.5626967", "0.5624363", "0.56165457", "0.560991", "0.56084955", "0.5595283", "0.5566048", "0.555995", "0.5559553", "0.5551518", "0.55481774", "0.5534538", "0.55249417", "0.552295", "0.5516265", "0.5512221", "0.55074066", "0.54919314", "0.54772735", "0.5475644", "0.54671127", "0.5458271", "0.5450593", "0.5450593", "0.54480356", "0.54480356", "0.54480356", "0.54480356", "0.54480356", "0.54480356", "0.54480356", "0.5447501", "0.54427457", "0.54348344", "0.541799", "0.54139835", "0.5408744", "0.5408744", "0.54082686", "0.5408117", "0.5408117" ]
0.73148656
1
From the page 653 rng.exclude_end? > true or false Returns true if rng excludes its and value.
def test_Range_InstanceMethods_exclude_end? # TODO, need add some testcases. end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exclude_end?\n @ranges.size == 1 ? @ranges[0].exclude_end? : nil\n end", "def exclude_end?\n @exclude_end\n end", "def exclude_end?\n false\n end", "def exclude_end?() end", "def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend", "def exclude_begin?\n @ranges.size == 1 ? @ranges[0].exclude_begin? : nil\n end", "def is_a_3_dot_range?(range)\n range.exclude_end?\nend", "def exclusive\n if exclude_end?\n self\n else\n Range.new(self.begin, self.end + 1, true)\n end\n end", "def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend", "def exclude_begin?\n @exclude_begin\n end", "def range_precedes(rng,oth)\n r1, r2 = matched_range_types(rng,oth)\n diff = if r1.respond_to?(:exclude_end?) && r1.exclude_end?\n 0\n else\n 1\n end\n (r1.end + diff) == r2.begin\n end", "def inclusive_ending\n self.exclude_end? ? ending - 1 : ending\n end", "def empty?\n if exclude_end?\n self.end <= self.begin\n else\n self.end < self.begin\n end\n end", "def arel_exclude(start_column, end_column, start_or_instant_or_range=nil, range_end=nil)\n table = self.arel_table\n if range_end\n table[start_column].gteq(range_end).or(table[end_column].lteq(start_or_instant_or_range))\n elsif Range === start_or_instant_or_range\n table[start_column].gteq(start_or_instant_or_range.db_end).or(table[end_column].lteq(start_or_instant_or_range.db_begin))\n else\n start_or_instant_or_range ||= InfinityLiteral\n table[start_column].gt(start_or_instant_or_range).or(table[end_column].lteq(start_or_instant_or_range))\n end\n end", "def exclusive!\n @inclusive = false\n end", "def arel_tt_exclude(instant, range_end)\n arel_exclude(:ttstart_at, :ttend_at, instant, range_end)\n end", "def exclude?\n self.exclude == true || self.class.excluded_accounts.include?(self.account_number)\n end", "def vt_exclude(instant=Time.zone.now, range_end=nil)\n where(arel_vt_exclude(instant, range_end))\n end", "def arel_vt_exclude(instant, range_end)\n arel_exclude(:vtstart_at, :vtend_at, instant, range_end)\n end", "def test_Range_InstanceMethods_excludes\n\t\tassert_equal(true, (1..10) === 5)\n\t\tassert_equal(false, (1..10) === 15)\n\t\tassert_equal(true, (1..10) === 3.14159)\n\t\tassert_equal(true, ('a'..'j') === 'c')\n\t\tassert_equal(false, ('a'..'j') === 'z')\n\tend", "def empty?\n\t interval.first == interval.last && interval.exclude_end?\n end", "def price_range?\n !(price_range.first == price_range.last)\n end", "def price_range?\n !(price_range.first == price_range.last)\n end", "def skip_value?(value); end", "def ==(other)\n return true if equal? other\n\n other.kind_of?(Range) and\n self.first == other.first and\n self.last == other.last and\n self.exclude_end? == other.exclude_end?\n \n end", "def exclude?(fn)\n calculate_exclude_regexp unless @exclude_re\n fn =~ @exclude_re\n end", "def reject?\r\n\t\tprediction(0) < @domainLowerBound || prediction(0) > @domainUpperBound\r\n\tend", "def exclude?(fn)\n calculate_exclude_regexp unless @exclude_re\n fn =~ @exclude_re\n end", "def not_within_hypothetical_range?(dest)\n\t(dest[0] < 0 || dest[1] < 0) || (dest[0] > 7 || dest[1] > 7)\nend", "def exclude(num)\n return true if !filled? && @possible.delete(num)\n false\n end", "def has_range?\n !self.domain_ranges.nil?\n end", "def test_ranges\r\n assert_equal(@range.begin.to_f, @p2.to_f)\r\n assert(@range.cover?(@p5))\r\n assert(@range.end == @p8)\r\n assert(@range2.exclude_end?)\r\n assert_false(@range.exclude_end?)\r\n assert(@range.include?(@p3))\r\n assert(@range.max == @p8)\r\n assert(@range2.max == @p7)\r\n assert(@range.last(3) == [@p6, @p7, @p8])\r\n assert(@range.size == nil)\r\n end", "def exclude\n if @exclude.nil? or Regexp === @exclude then\n # done, #finish is being re-run\n @exclude\n elsif @exclude.empty? then\n nil\n else\n Regexp.new(@exclude.join(\"|\"))\n end\n end", "def exclusive?\n @exclusive\n end", "def exclude(num)\n return true if !filled? && @possible.delete(num)\n\n false\n end", "def hide_end_times?\n @hide_end_times\n end", "def is_a_3_dot_range?(range)\n a = range.first\n b = range.last\n range != (a..b)\nend", "def valid_result_range\n self.result && self.result > -2 ? true : false\n end", "def empty?\n return false if @upper_bound.nil?\n @lower_bound > @upper_bound\n end", "def valid?\n return false if @range_start_index.nil?\n return false if @range_end_index.nil?\n true\n end", "def out_of_range?\n value < 1 || value > 12\n end", "def include_range? other_range\n case other_range\n when Range\n if other_range.first >= self.first && other_range.last <= self.last\n return true\n else\n return false\n end\n else\n raise \"unsupported type\"\n end\n end", "def covers?(*args)\n other = coerce_range(*args)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n self.begin <= other.begin and other.end <= self.end\n end\n end", "def complement?(other)\n (from_end == other.to_end and\n to_end == other.from_end and\n overlap == other.complement_overlap)\n end", "def skip?\n !value_of(entity.only_if)\n end", "def include_with_range?(value)\n if value.is_a?(::Range)\n operator = exclude_end? ? :< : :<=\n end_value = value.exclude_end? ? last.succ : last\n include?(value.first) && (value.last <=> end_value).send(operator, 0)\n else\n include_without_range?(value)\n end\n end", "def inclusive!\n @inclusive = true\n end", "def start_and_end_set?\n [start, self.end].map(&:present?).uniq.length == 1\n end", "def supports_exclusion_constraints?\n false\n end", "def interval?() triangulated? and complement.comparability?; end", "def missing_one_at_either_end\n [2,3].each { |i|\n return true if @counts[i]>0 && @counts[i+1]>0 && @counts[i+2]>0\n }\n return false\n end", "def is_end?(cell)\n @end_cell.eql?(cell)\n end", "def exclude_ends list\n list[1..-2]\nend", "def range_include?(zelf, other)\n # 1...10 includes 1..9 but it does not include 1..10.\n operator = zelf.exclude_end? && !other.exclude_end? ? :< : :<=\n zelf.include?(other.first) && other.last.send(operator, zelf.last)\nend", "def valid_range?\n (0..@max_num).cover?(@number)\n end", "def stop?\n\t\t\t\tunless @marked\n\t\t\t\t\[email protected]\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend", "def valid_end_date\n self.end_date - self.start_date > 0 ? true : false\n end", "def infinite?\n !ends_at && !length\n end", "def compose_not_range_node(node, value)\n validate_node_or_attribute(node)\n range_info = parse_range(value)\n\n # build using gt, lt, gteq, lteq\n if range_info[:start_include]\n start_condition = node.lt(range_info[:start_value])\n else\n start_condition = node.lteq(range_info[:start_value])\n end\n\n if range_info[:end_include]\n end_condition = node.gt(range_info[:end_value])\n else\n end_condition = node.gteq(range_info[:end_value])\n end\n\n start_condition.or(end_condition)\n end", "def check_non_overlapping?(indexes, range)\n return true if indexes.empty?\n\n indexes.each do |val|\n return false if val.cover?(range.begin) || val.cover?(range.end)\n end\n true\n end", "def auto_exclude?\n @auto_exclude\n end", "def valid_start_and_end_dates?\n return false unless start.present? && self.end.present?\n start <= self.end\n end", "def overlap? range\n !(self & range).nil?\n end", "def exclude_ends potato\n potato [1..-2]\nend", "def auto_exclude\n self.exclude ||= true if !!(address.to_s.match(/p\\.?\\s?o\\.?\\sbox/i)) || # PO Boxes\n !!(self.del_flag.to_s.match(/\\W/)) ||\n !!(self.del_block.to_s.match(/\\W/)) ||\n !!(self.order_block.to_s.match(/\\W/)) ||\n #account_number.split(/\\-/).first.to_i > 700000 || # distributors, internal accounts\n marked_for_deletion? || # those which have deleted-type words in the name\n self.class.excluded_accounts.include?(self.account_number) # those which are flagged in the yaml file\n end", "def within_bounds?\n !exceeded?\n end", "def ends_before_it_begins?\n end_on? && end_on <= start_on\n end", "def descending_between?(start_point, end_point)\n (elevation_between(end_point, start_point) / distance_between(start_point, end_point)) > 0.003\n end", "def only_evens range\n range.select do |value|\n value.even?\n end\nend", "def only_evens range\n range.select do |value|\n value.even?\n end\nend", "def exclude(sub_string)\n puts \"Is substring excluded?\"\n val = [email protected]?(sub_string)\n end", "def in_range?\n return self.range.include?([@x, @y])\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def matched_by_extended_range?(range)\n recompose\n subtags = @composition.split(Const::HYPHEN)\n subranges = range.downcase.split(Const::HYPHEN)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == Const::WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def should_hit?\n hit = true\n @values.each { |val| hit &= !(val >= 17 && val <= 21) }\n hit\n end", "def between?(min, max)\n #This is a stub, used for indexing\n end", "def enemy_in_melee_range?(source, exclude = [], source_pos: nil)\n objects_around_me = map.look(source)\n\n objects_around_me.detect do |object, _|\n next if exclude.include?(object)\n\n state = entity_state_for(object)\n next unless state\n next unless object.conscious?\n\n return true if opposing?(source, object) && (map.distance(source,\n object, entity_1_pos: source_pos) <= (object.melee_distance / map.feet_per_grid))\n end\n\n false\n end", "def degenerate?\n @floor == @ceiling\n end", "def is_effective?(value)\n @range_lower <= value && value <= @range_upper\n end", "def matched_by_extended_range?(range)\n\n subtags = decomposition.dup\n subranges = range.to_str.downcase.split(HYPHEN_SPLITTER)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def excludes\n @excludes ||= []\n end", "def reverse?(other)\n (from_end == other.to_end and\n to_end == other.from_end and\n overlap == other.reverse_overlap)\n end", "def meets?(*args)\n other = coerce_range(*args)\n self.begin == other.end or other.begin == self.end\n end", "def excluded; end", "def was_excluded(date)\n if @schedule.days_month == 'specific'\n return false if bitmask(@schedule.days)[date.day] == '1'\n\n if @schedule.exclusion_met_day\n return date.wday == @schedule.exclusion_met_day\n end\n elsif @schedule.days_month == 'last' \n if @schedule.days_month_day == nil\n return date.at_end_of_month != date\n else\n return date.wday != @schedule.days_month_day\n end\n elsif @schedule.days_month_day == nil\n values = ['first', 'second', 'third', 'fourth']\n return date.day != (values.index(@schedule.days_month) + 1)\n else\n weekdays = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']\n return date.wday != weekdays.index(@schedule.days_month_day)\n end\n\n return false\n end", "def disjoint?(other)\n if empty? && other.empty?\n @begin_pos != other.begin_pos\n else\n @begin_pos >= other.end_pos || other.begin_pos >= @end_pos\n end\n end", "def skip?\n return false unless has_group?\n return true if group.any_true?(skip_if)\n return true unless group.all_true?(only_if)\n false\n end", "def is_excluded(date)\n return false if @schedule.days_exclude == 0\n\n days_bitmask_exclude = bitmask(@schedule.days_exclude)\n if @schedule.days_month == 'specific' || (@schedule.days_month != 'specific' && @schedule.days_month_day == nil)\n day_idx = (date.wday) % 7\n else\n day_idx = date.day\n end\n\n return days_bitmask_exclude[day_idx] == '1'\n end", "def conjunctionRangeExtd(r1, r2)\n\n [r1, r2].each do |er|\n return er if er.is_none?\n end\n\n r = *( sort_ranges_core([RangeExtd(r1), RangeExtd(r2)]) )\t# => Rangeary.sort_ranges\n\n ## Note: the end product will be (cBeg(:stBeg), cEnd(:stEnd))\n # where :stBeg and :stEnd mean exclude_(begin|end)?\n\n # Set the candidate begin value.\n cBeg = r[1].begin\n if r[0].begin == r[1].begin\n stBeg = (r[1].exclude_begin? || r[0].exclude_begin?)\n else\n stBeg = r[1].exclude_begin?\n end\n\n # Set the candidate end value. (Rangeary.comparable_end() for Ruby-2.6 Endless Range)\n # Note: this comparison ignores @infinities even if set,\n # because @infinities may not be defined in the arguments!\n # Anyway, nothing should be larger than the upper limit\n # and so this should be fine.\n if comparable_beginend_core(r[0]).end == comparable_beginend_core(r[1]).end\n cEndOrig = r[1].end\n cEnd = comparable_beginend_core(r[1]).end\n stEnd = (r[0].exclude_end? || r[1].exclude_end?)\n else\n a = [[comparable_beginend_core(r[0]).end, 0, r[0].end], [comparable_beginend_core(r[1]).end, 1, r[1].end]].min\n cEnd = a[0]\n cEndIndex = a[1]\t# r[cEndIndex] == RangeExtd obj that gives the end of the resultant range.\n cEndOrig = a[2]\n stEnd = nil\n end\n\n case cBeg <=> cEnd\n when 1\t# cBeg > cEnd\n RangeExtd::NONE\n\n when 0\t# cBeg == cEnd\n stEnd = r[0].exclude_end?\n if (!stBeg) && (!stEnd)\n RangeExtd(cBeg..cBeg)\t# Point range\n else\n RangeExtd::NONE\n end\n\n when -1\t# cBeg < cEnd\n # Now, the range must be (cBeg, cEnd). May need adjustment of the exclude status.\n if stEnd.nil?\n stEnd = r[cEndIndex].exclude_end?\n # else\n # # Already defined.\n end\t# if stEnd.nil?\n\n RangeExtd(cBeg, cEndOrig, :exclude_begin => stBeg, :exclude_end => stEnd)\n else\n raise\n end\t\t# case cBeg <=> cEnd\n\n end", "def verify_range(value)\n a = (20...30) === value\n if a != true\n puts \"#{value} is not in range of 20 to 30\"\n else\n puts \"#{value} is in range of to 20 to 30\"\n end\nend", "def EXCLUDE(first, last)\n first.flatten - last.flatten\n end", "def thetvdb_missing_range(season, season_first, episode, episode_first)\n missing = true\n \n # for now we are only interested in episodes greater than our first one and \n # inclusive of the whole season\n if season.to_i < season_first.to_i \n missing = false\n end\n \n if $config[\"missing\"][\"start_at_first_found\"]\n if episode_first.to_i > episode.to_i \n missing = false \n end\n end\n \n missing\nend", "def excluded?(serializer)\n case condition_type\n when :if\n !evaluate_condition(serializer)\n when :unless\n evaluate_condition(serializer)\n else\n false\n end\n end", "def range\n (start_date...end_date) #exclusive date range\n end", "def upper_gap?\n near_pages.last < last_page\n end", "def among_validate_in_values?\n vs = @cfg.valid_values\n !vs || vs.include?(@value)\n end", "def out_of_range?(v)\n v < 1 || v > 12\n end", "def overlaps?(range)\n !(completely_left_of?(range) || completely_right_of?(range))\n end", "def vt_forever?\n vtend_at == InfinityValue\n end" ]
[ "0.78446496", "0.7428057", "0.7289669", "0.68370533", "0.67327553", "0.67320293", "0.6677454", "0.6375281", "0.6320449", "0.6171066", "0.61512977", "0.6137421", "0.61352247", "0.6039115", "0.6019044", "0.60181", "0.6007065", "0.5970629", "0.5908297", "0.5882339", "0.5864835", "0.58625305", "0.58625305", "0.57944405", "0.577715", "0.5737191", "0.5720421", "0.57174337", "0.56204104", "0.55625427", "0.5546002", "0.5540776", "0.5534379", "0.5522185", "0.5520549", "0.55091023", "0.5499367", "0.5498392", "0.54877985", "0.5483518", "0.547769", "0.5464394", "0.5452271", "0.54512197", "0.5450047", "0.54302084", "0.5422985", "0.5411883", "0.54090714", "0.5385148", "0.535672", "0.53518945", "0.53361326", "0.53339005", "0.53318447", "0.5319577", "0.5308161", "0.53041124", "0.5293741", "0.52853197", "0.5277407", "0.5273709", "0.5273461", "0.52667236", "0.5250949", "0.52509046", "0.5242966", "0.5236703", "0.5215427", "0.521409", "0.5211299", "0.5209456", "0.5207541", "0.5207541", "0.51818234", "0.51760286", "0.51750153", "0.5174103", "0.51659465", "0.51616645", "0.5156807", "0.5155881", "0.51532024", "0.5149719", "0.51439786", "0.51437926", "0.51417774", "0.5129001", "0.5127109", "0.51248413", "0.51133764", "0.5113349", "0.5101183", "0.50870633", "0.50744313", "0.5074176", "0.50647414", "0.5057785", "0.5057477", "0.5046376" ]
0.6669949
7
From the page 653 rng.first(n=1) > obj or array Returns the first (or first n) elements of rng.
def test_Range_InstanceMethods_first assert_equal('aa', ('aa'..'bb').first) assert_equal(['aa','ab','ac','ad','ae'], ('aa'..'bb').first(5)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first(*n) end", "def first(n = 1)\n return self.clone if n >= self.size\n return self[0] if n == 1\n return self[0...n]\n end", "def first(n = nil)\n if n\n self[0,n]\n else\n self[0]\n end\n end", "def first(n = 1)\n if n > 1\n (ds = Array(min)).empty? ? ds : ds.concat(ds[0].next(n - 1))\n else\n min\n end\n end", "def first(n = nil)\n if n\n apply_scope(:first, n)\n else\n self[0]\n end\n end", "def using_first(array)\narray.first\nend", "def first(n = T.unsafe(nil)); end", "def first(n = T.unsafe(nil)); end", "def first\n limit(1).to_a.first\n end", "def using_first(array)\n first_element=array.first\nend", "def using_first(array)\n array.first\nend", "def using_first(array)\n array.first\nend", "def using_first(array)\n array.first\nend", "def using_first(array)\n array.first\nend", "def first\n all[0]\n end", "def first(numbers, int)\n numbers.first(int)\nend", "def custom_first(arr, num_of_elements = 0)\n return arr[0] if num_of_elements == 0\n arr[0, num_of_elements]\nend", "def first\n @range.first\n end", "def first_of(array)\n return array[0]\nend", "def first_of(array)\n return array[0]\nend", "def first_of(array)\n output = array[0]\n return output\nend", "def custom_first(arr,num=0)\n return arr[0] if num==0\n arr[0...num]\nend", "def first(arr)\n return arr[0]\nend", "def get_first_element(arr)\n return arr.first()\nend", "def first\n self.take(1)[0]\n end", "def first_of(arr)\n return arr[0]\nend", "def first_of(arr)\n return arr[0]\nend", "def first_of(arr)\n return arr[0]\nend", "def first() end", "def array_first\n golf_scores=[75,76,78,77,79,74,72] # this is the orignal array\n golf_scores.first(3) #this example return the first 3 scores\n # from the golf_scores array\nend", "def custom_first(arr, num= 0)\n arr[0..num]\nend", "def first(limit = 1)\n take(limit)\n end", "def first\n to_a.first\n end", "def first\n @enumerable.first\n end", "def first_element(array)\n array[0]\nend", "def first(*several_variants)\n #This is a stub, used for indexing\nend", "def first(n=1)\n return values[0] if self.class == BaseRelation && loaded && n == 1\n result = limit(n).load\n result.length == 1 ? result[0] : result\n end", "def first list, n = 1\n n == 1 ? list.first : list.first(n)\nend", "def custom_first(arr,num=0)\n l = arr.length\n if num==0\n arr[0]\n else\n (num<l)? arr[0...num] : arr[0...l]\n end\nend", "def get_first_element(arr)\n arr.first\nend", "def retrieve_first_element_from_array(array)\n array.first\nend", "def first list, n=nil\n n ? list.first(n) : list.first\nend", "def first\n self.slice(0)\n end", "def nth_from_array_or_range\n C.curry.(\n ->(xs, n) {\n xs.is_a?(Range) ? xs.first(n) : S.take.(xs, n)\n }\n )\n end", "def first(*args)\n find_first_or_last(:first, *args)\n end", "def first(*args)\n all.send(:first, *args)\n end", "def first\r\n self[0]\r\n end", "def custom_first(arr, num=0)\n return arr[0] if num == 0\n arr[0, num]\nend", "def retrieve_first_element_from_array(array)\n array[0]\nend", "def first n\n @b.byteslice 0, n\n end", "def first! n\n slice = @b.byteslice 0, n\n @b = @b.byteslice n, -1\n slice\n end", "def retrieve_first_element_from_array(array)\n return array[0]\nend", "def test_first_three\n array = [1,2,3,4,5]\n array = array.first(3)\n assert_equal [1,2,3], array\n end", "def first(*args)\n find(:first, *args)\n end", "def custom_first(arr, num = 0)\n return arr[0] if num == 0\n arr[0, num]\nend", "def first(*args)\n find(:first, *args)\n end", "def first(*args)\n find(:first, *args)\n end", "def first\n enumerator(:limit => 1).first \n end", "def first\n self[0]\n end", "def first\n self[0]\n end", "def first\n self[0]\n end", "def first\n all.first\n end", "def first\n all.first\n end", "def first\n all.first\n end", "def first\n all.first\n end", "def first(*vars)\n result = Query.get params(:size => 1), *vars\n docs = result.get_docs\n docs.is_a?(Array) ? docs.first : docs\n end", "def first(n=nil)\n to_recv = n || 1\n received = []\n each do |m|\n received << m\n break if received.size == to_recv\n end\n n ? received : received.first\n end", "def first(limit = 1)\n self[0..(limit - 1)]\n end", "def first\n @head.val\n end", "def first\n @head\n end", "def first\n @values.first\n end", "def first\n all.first\n end", "def first\n all.first\n end", "def first\n all.first\n end", "def first(count=MaglevUndefined)\n if count._equal?(MaglevUndefined)\n return self.first()\n end\n # return Array of first count elements of the enumeration\n cnt = Maglev::Type.coerce_to(count, Fixnum, :to_int)\n if cnt <= 0\n if cnt._equal?(0)\n return []\n end\n raise ArgumentError, 'negative count'\n end\n arr = []\n n = 0\n self.each { |o| \n arr << o\n n += 1\n if n >= cnt\n return arr\n end\n }\n return arr\n end", "def first\n @elements.empty? ? nil : @elements[0]\n end", "def first(*args)\n if args.size >= 2\n raise ArgumentError, \"wrong number of arguments (#{args.size + 1} for 1..2)\"\n end\n\n if args.size == 1\n width = args[0]\n width = [width, size].min if has_size?\n\n return self[0...width]\n else\n return at(0)\n end\n end", "def bound_first(first)\n if first < 1 then 1 else first end\n end", "def first\n all.first\n end", "def first_item(elective_array)\n return elective_array[0]\nend", "def head\n \t@array[0]\n end", "def first_value\r\n get(@first_index)\r\n end", "def find_first(*args)\n id = get_range(:count => 1, *args).first\n id && find_one(id, *args)\n end", "def first_element_with_array_methods(array)\n array.first\nend", "def first_element_with_array_methods(array)\n array.first\nend", "def getFirst_array_rand( selection, query, args )\n # Double our args since we are querying twice\n \n args = [ args ] if not args.is_a? Array\n\n nargs = Array.new args\n args.each do |a|\n nargs << a \n end\n\n args = nargs\n \n r = self.getArray( \"SELECT \" + selection + \" FROM \" + query + \" OFFSET floor(RANDOM() * (SELECT count(*) FROM \" + query + \")) LIMIT 1\", args ) \n \n r = r[0] if r.is_a? Array and r.size == 1\n\n r\n end", "def first; end", "def first; end", "def first_element_with_array_methods(array)\n return array.first\nend", "def first_only\n lambda do |rec, acc|\n # kind of esoteric, but slice used this way does mutating first, yep\n acc.slice!(1, acc.length)\n end\n end", "def first(count = nil)\n if count.nil?\n @collection.first\n else\n out = []\n @collection.first(count).each do |item|\n out << item\n end\n out\n end\n end", "def caar; first.first end", "def first\n find.limit(1).next_document\n end", "def first\n result ? all.first : limit(1).all.first\n end", "def first_n_smallest(arr, n)\n arr.each_with_index.min(n).sort_by(&:last).map(&:first)\nend", "def first\n @poss[0]\n end", "def sample(array)\n return nil if array.empty?\n array[int(array.size)]\n end", "def first\n\t\t\tarray = pop\n\t\t\traise ArgumentError, \"FIRST: first element is not an Array.\" unless array.is_a? Array\n\t\t\traise ArgumentError, \"FIRST: empty array.\" if array.length == 0\n\t\t\tpush array.first\n\t\tend", "def first_index(arr, &prc)\n arr.each.with_index do |ele, idx| \n return idx if prc.call(ele)\n end\n nil\nend", "def first(amount = nil)\n objects = all.first(amount || 1)\n amount.nil? ? objects.first : objects\n end", "def first\n\n wi(fetch_all({}).first)\n end" ]
[ "0.76450205", "0.7486319", "0.7150061", "0.70670307", "0.7042806", "0.69239825", "0.6910762", "0.6910762", "0.6880357", "0.68759686", "0.6862687", "0.6862687", "0.6862687", "0.6862687", "0.68303907", "0.6780862", "0.67580646", "0.6724696", "0.6692148", "0.6692148", "0.6670999", "0.6659448", "0.66183996", "0.6617717", "0.66145587", "0.65879047", "0.65879047", "0.65879047", "0.6586071", "0.65823233", "0.6567139", "0.65420556", "0.6532351", "0.64432293", "0.6434171", "0.64178926", "0.64025134", "0.6402172", "0.6394118", "0.63719463", "0.6364362", "0.63557625", "0.63509804", "0.63506687", "0.6329743", "0.6302554", "0.62621105", "0.62543947", "0.6238533", "0.6230539", "0.62215865", "0.6210127", "0.6206554", "0.6193355", "0.6182518", "0.617538", "0.617538", "0.6161109", "0.6147675", "0.6142405", "0.6142405", "0.6123919", "0.6123919", "0.6123919", "0.6123919", "0.61192155", "0.61046046", "0.6103695", "0.60518587", "0.60465205", "0.60442996", "0.60259646", "0.60259646", "0.60259646", "0.60216385", "0.6016623", "0.60106444", "0.59961116", "0.59748274", "0.59683394", "0.593691", "0.591376", "0.58991796", "0.58934057", "0.58934057", "0.5876263", "0.58627844", "0.58627844", "0.5860163", "0.5850829", "0.5847187", "0.5843016", "0.58415294", "0.5828226", "0.58203864", "0.5818738", "0.58151144", "0.5810591", "0.5805164", "0.5804635", "0.5791659" ]
0.0
-1
From the page 653 rng.include?(val) > true or false Returns true if val is one of the values in rng (that is, is Rangeeach would return val at some point). If the range is defined to span numbers, this method returns true if value lies between the start and end of the range, even if it is not actually a member ( that is, it has the same behavior as Rangecover?). Otherwise, the parameter must be a member of the range.
def test_Range_InstanceMethods_include? r = 1..10 assert_equal(true, r.include?(5)) assert_equal(true, r.include?(5.5)) assert_equal(true, r.include?(10)) r = 1...10 assert_equal(false, r.include?(10)) r = 'a'..'z' assert_equal(true, r.include?('b')) assert_equal(false, r.include?('ruby')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ranges_include?(value)\n any? { |range| Array(range).include?(value) }\n end", "def in_range?(val, range)\n return true unless range\n\n if range.is_a?(Hash)\n result = true\n result &= ( val < range[:before] ) if range[:before]\n result &= ( val > range[:after] ) if range[:after]\n result &= ( val <= range[:max] ) if range[:max]\n result &= ( val >= range[:min] ) if range[:min]\n result &= ( val < range[:less_than] ) if range[:less_than]\n result &= ( val <= range[:less_than_or_equal_to] ) if range[:less_than_or_equal_to]\n result &= ( val > range[:greater_than] ) if range[:greater_than]\n result &= ( val >= range[:greater_than_or_equal_to] ) if range[:greater_than_or_equal_to]\n result\n else\n range = [range] unless range.respond_to?(:include?)\n range.include?(val)\n end\n end", "def in_range?\n return self.range.include?([@x, @y])\n end", "def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_ranges?(num, ranges)\n result = false\n ranges.each do |range|\n if range.include?(num)\n result = true\n end\n end\n return result\nend", "def include_with_range?(value)\n if value.is_a?(::Range)\n operator = exclude_end? ? :< : :<=\n end_value = value.exclude_end? ? last.succ : last\n include?(value.first) && (value.last <=> end_value).send(operator, 0)\n else\n include_without_range?(value)\n end\n end", "def within?(value)\n value >= @lower and value <= @upper\n end", "def include?(i)\n @range.include?(i)\n end", "def covers?(*args)\n other = coerce_range(*args)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n self.begin <= other.begin and other.end <= self.end\n end\n end", "def range_includes_item?(range, item)\n range.begin <= item && item <= range.end\n end", "def include_range? other_range\n case other_range\n when Range\n if other_range.first >= self.first && other_range.last <= self.last\n return true\n else\n return false\n end\n else\n raise \"unsupported type\"\n end\n end", "def within?(val, lower, upper)\n check_pre((\n (val.int?) and\n (lower.int?) and\n (upper.int?)\n ))\n\n ((val >= lower) and (val <= upper))\nend", "def range_include?(ranges, addr)\n\t\t\tranges.each do |range|\n\t\t\t\treturn true if range.include? addr\n\t\t\tend\n\t\t\tfalse\n\t\tend", "def within?(val,lower,upper)\n\n check_pre((\n (val.nat?) and\n (lower.nat?) and\n (upper.nat?)\n ))\n\n (val >= lower) and (val <= upper)\n\n end", "def within?(in_val, in_lower, in_upper)\n\tcheck_pre(((in_val.int?) and (in_lower.int?) and (in_upper.int?)))\n\t(in_lower..in_upper) === in_val\nend", "def in_range?\n self > LOWER_BOUND && self <= UPPER_BOUND\n end", "def in_range\n\t\trange = Set[1, 2, 3, 4, 5,\n\t\t\t\t\t\t\t\t6, 7, 8, 9, 10,\n\t\t\t\t\t\t\t 11, 12, 13, 14, 15,\n\t\t\t\t\t\t\t\t16, 17, 18, 19, 20,\n\t\t\t\t\t\t\t\t21, 22, 23, 24, 25,\n\t\t\t\t\t\t\t\t26, 27, 28, 29, 30]\n\n\t\tif @landmarks.subset?(range)\n\t\t\treturn true\n\t\tend\n\n\t\treturn false\n\tend", "def between?(x,y) end", "def meets?(*args)\n other = coerce_range(*args)\n self.begin == other.end or other.begin == self.end\n end", "def range_cover?(outer, inner)\n outer.cover?(inner.begin) && outer.cover?(inner.end)\nend", "def include?(value)\n candidate = intervals\n .find { |min, max| max >= value }\n candidate && (candidate[0] <= value)\n end", "def between?(p0, p1) end", "def range_include?(zelf, other)\n # 1...10 includes 1..9 but it does not include 1..10.\n operator = zelf.exclude_end? && !other.exclude_end? ? :< : :<=\n zelf.include?(other.first) && other.last.send(operator, zelf.last)\nend", "def check_range(rng)\n new(rng).results\n end", "def check_include(value)\n (1..10).include?(value)\nend", "def is_winner_on_range?(range)\n return false unless range.uniq.size == 1 && !range.first.nil?\n\n @winner = range.first\n return true\n end", "def integer?(range: (1..))\n proc do |o|\n o.is_a? String and o.is_i? and range.include?(o.to_i)\n end\n end", "def touching?(range)\n range.end == self.start || self.end == range.start\n end", "def overlap? range\n !(self & range).nil?\n end", "def is_within(number, lower, upper)\n RangeAssertion.new(number, lower, upper)\n end", "def between?(min, max)\n #This is a stub, used for indexing\n end", "def include?(addr)\n\t\treturn false if not @ranges\n\t\tif (addr.is_a? String)\n\t\t\taddr = Rex::Socket.addr_atoi(addr)\n\t\tend\n\t\[email protected] { |r| \n\t\t\tif r.start <= addr and addr <= r.stop\n\t\t\t\treturn true\n\t\t\tend\n\t\t}\n\t\treturn false\n\tend", "def check(range, value)\n result = true\n unless range.nil?\n if range.class == Range\n result = (range === value)\n elsif range.class == Fixnum\n result = (value >= range)\n end\n end\n result\n end", "def between?(num, x, y)\n\nend", "def within?(other)\n range_within_other?(self,other)\n end", "def in_ranged_array?(ranged_ary, num)\n !!ranged_ary.find {|n| n === num }\n end", "def all_in_ranges?(nums, ranges)\n if nums.empty?\n return false\n end\n nums.each do |num|\n if !in_ranges?(num, ranges)\n return false\n end\n end\n true\nend", "def include?(chr, start = nil, stop = nil)\n if start.nil?\n chromosomes.include?(chr)\n elsif stop.nil?\n chromosomes.include?(chr) and start >= chr_start(chr) and start <= chr_stop(chr)\n else\n chromosomes.include?(chr) and start >= chr_start(chr) and stop <= chr_stop(chr)\n end\n end", "def intersects?(*args)\n other = coerce_range(*args)\n raise ArgumentError, \"#{self.begin.class} expected, received #{other.begin.class}\" unless other.begin.kind_of?(self.begin.class)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n other.begin < self.end and self.begin < other.end\n end\n end", "def include?(row, col)\n @range.include?(row) && @range.include?(col)\n end", "def check_range(name, range, value, unit = '')\n grace = (-0.00001..0.00001)\n str = value.to_s\n value = value.value if value.is_a?(Sass::Script::Value::Number)\n return value if range.include?(value)\n return range.first if grace.include?(value - range.first)\n return range.last if grace.include?(value - range.last)\n raise ArgumentError.new(\n \"#{name} #{str} must be between #{range.first}#{unit} and #{range.last}#{unit}\")\n end", "def valid?(range)\n range[0] < range[1]\nend", "def is_effective?(value)\n @range_lower <= value && value <= @range_upper\n end", "def valid_range?\n (0..@max_num).cover?(@number)\n end", "def check_bounds(value)\n return value >= self.bound.lower_bound && value <= self.bound.upper_bound\n end", "def is_a_3_dot_range?(range)\n a = range.first\n b = range.last\n range != (a..b)\nend", "def include?(low, high = nil)\n return @data.include?(low) if high.nil?\n (low..high).each { |i| return false if get(i).nil? }\n return true\n end", "def inclusion_method(enumerable)\n enumerable.is_a?(Range) ? :cover? : :include?\n end", "def check_range(a,b)\n if (20..30).include?(a)\n puts \"a is in the range (20..30).\"\n else\n puts \"a is not in the range (20..30).\"\n end\n if (20..30).include?(b)\n puts \"b is in the range (20..30).\"\n else\n puts \"b is not in the range (20..30).\"\n end\nend", "def include?(object)\n object.start >= @start && object.end <= @end\n end", "def between(middle, first, last)\n if first < middle and middle < last\n return true\n else\n return false\n end\nend", "def between(numb, lower, higher)\n return true if numb >= lower && numb <= higher\n return false\nend", "def overlaps?(range)\n !(completely_left_of?(range) || completely_right_of?(range))\n end", "def passed?\n if expected_value.is_a?(Range)\n expected_value.include?(after_value)\n else\n expected_value == after_value\n end\n end", "def in_range?(key)\n (key>=range_start) && (range_end==LAST_POSSIBLE_KEY || key < range_end)\n end", "def test_bounds(val, min, max)\n val >= min && val <= max\n end", "def between?(min, max)\n self >= min and self <= max\n end", "def between(num, min, max)\n if min <= num && max >= num\n return true\n else \n return false\n end\nend", "def in_range?( answer_object )\n (@above.nil? or answer_object > @above) and\n (@below.nil? or answer_object < @below) and\n (@in.nil? or @in.include?(answer_object))\n end", "def between?(value, min = nil, max = nil)\n if min and value < min\n return false\n elsif max and value > max\n return false\n end\n return true\n end", "def in_range(a, b)\n return ((a >= 20 && a <= 30) || (b >= 20 && b <= 30));\t\nend", "def value_in_range(range)\n case range.first\n when Integer then number_in_range(range)\n when Time then time_in_range(range)\n when Date then date_in_range(range)\n else range.to_a.rand\n end\n end", "def verify_range(value)\n a = (20...30) === value\n if a != true\n puts \"#{value} is not in range of 20 to 30\"\n else\n puts \"#{value} is in range of to 20 to 30\"\n end\nend", "def range(c_begin, c_end, alphabet = DEFAULT_ALPHABET)\n any((c_begin..c_end).to_a, alphabet)\n end", "def between?(inclusive, start, stop, event)\n ((after?(inclusive, start, event)) &&\n (before?(inclusive, stop, event)))\nend", "def range1d?(o)\n o.int_range?\nend", "def in_move_range?(v)\n (20..500).include? v\n end", "def host_in_range?(ip, ip_address_start, ip_address_end)\n ip >= ip_address_start && ip <= ip_address_end\n end", "def contains?(value)\n start_time = low.to_time_object\n end_time = high.to_time_object\n time = value.to_time_object\n \n time.between?(start_time, end_time)\n end", "def out_of_bound?(value, min, max)\n return value > max || value < min\n end", "def between(min, max, &block)\n return false unless (1..min).all? { try(&block) }\n (min..max).all? { try(&block) } # only using all?'s shortcut property\n true\n end", "def matched_by_extended_range?(range)\n recompose\n subtags = @composition.split(Const::HYPHEN)\n subranges = range.downcase.split(Const::HYPHEN)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == Const::WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def test_ranges\r\n assert_equal(@range.begin.to_f, @p2.to_f)\r\n assert(@range.cover?(@p5))\r\n assert(@range.end == @p8)\r\n assert(@range2.exclude_end?)\r\n assert_false(@range.exclude_end?)\r\n assert(@range.include?(@p3))\r\n assert(@range.max == @p8)\r\n assert(@range2.max == @p7)\r\n assert(@range.last(3) == [@p6, @p7, @p8])\r\n assert(@range.size == nil)\r\n end", "def between(lower, upper)\n (self >= lower) & (self <= upper)\n end", "def include?(v)\n case v\n when Range\n include_range?(v)\n when RangeSet\n include_rangeset?(v)\n else\n include_scalar?(v)\n end\n end", "def include?(x)\n inf <= x && x <= sup\n end", "def _index_in_range?(i, max, min)\n !((i > max) || (i < min))\n end", "def within(range: 1.00..5000.00)\n between(from: range.min, to: range.max)\n end", "def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend", "def range_intersect?(s1, s2)\n s1range = s1.to_a.min..s1.to_a.max\n s2range = s2.to_a.min..s2.to_a.max\n return s1range.include?(s2range.first) || s2range.include?(s1range.first)\nend", "def values_between? a, b\n is_ok = self.start_value.between?(a,b)\n \n if is_ok\n self.value_changes.each do |offset, setting|\n setting.value.between?(a,b)\n end\n end\n return is_ok\n end", "def cover?(low, high = @max)\n return false if coverage == 0 or low.nil?\n @min <= low and low <= @max and high >= @min and high <= @max\n end", "def in_range_for_type?\n case @cfg.type_name\n when :positive_int\n value > 0\n when :unsigned_int\n value >= 0\n when :positive_int_array\n value.all? {|i| i > 0 }\n when :unsigned_int_array\n value.all? {|i| i >= 0 }\n else\n true\n end\n end", "def between(num1, num2, num3)\n if num1 >= num2 && num1 <= num3\n return true\n else\n return false\n end\nend", "def between(num1, num2, num3)\n if num1 >= num2 && num1 <= num3\n return true\n else\n return false\n end\nend", "def matched_by_extended_range?(range)\n\n subtags = decomposition.dup\n subranges = range.to_str.downcase.split(HYPHEN_SPLITTER)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def should_ensure_value_in_range(attribute, range, opts = {})\n message, low_message, high_message = get_options!([opts],\n :message,\n :low_message,\n :high_message)\n matcher = ensure_inclusion_of(attribute).\n in_range(range).\n with_message(message).\n with_low_message(low_message).\n with_high_message(high_message)\n should matcher.description do\n assert_accepts matcher, subject\n end\n end", "def test_Range_InstanceMethods_eql?\n\t\tassert_equal(true , (1..10).eql?(Range.new(1,10)))\n\t\tassert_equal(false, (1..10).eql?([1..10]))\n\tend", "def is_between_strict(num,first,second)\n if num > first && num < second || num < first && num > second\n return true\n end\n return false\nend", "def ===(value)\r\n @range === value\r\n end", "def within?(other_slice)\r\n if ! other_slice.class == Slice\r\n raise RuntimeError, \"The Slice#overlaps? method takes a Slice object as its arguments.\"\r\n end\r\n if self.seq_region.coord_system != other_slice.seq_region.coord_system\r\n raise RuntimeError, \"The argument slice of Slice#overlaps? has to be in the same coordinate system, but were \" + self.seq_region.coord_system.name + \" and \" + other_slice.seq_region.coord_system.name\r\n end\r\n\r\n self_range = self.start .. self.stop\r\n other_range = other_slice.start .. other_slice.stop\r\n\r\n if other_range.include?(self.start) and other_range.include?(self.stop)\r\n return true\r\n else\r\n return false\r\n end\r\n end", "def in_range(a, b, c)\n return ((a >= 1 && a <= 10) || (b >= 1 && b <= 10) || (c >= 1 && c <= 10));\t\nend", "def intersect? (range1,range2)\n if range1.begin < range2.begin\n if range1.end < range2.begin\n nil\n else\n (range2.begin..range1.end)\n end\n else\n if range2.end < range1.begin\n nil\n else\n (range1.begin..range2.end)\n end\n end\nend", "def overlap?(self_range, other_range)\n return true if self_range == other_range \n overlap_helper(self_range, other_range) || overlap_helper(other_range, self_range)\n end", "def contains?(x, y)\n x > bounds.x && x < bounds.x+bounds.width && y > bounds.y && y < bounds.y+bounds.height\n end", "def eql?(range)\n return false if range.nil? || low.nil? || range.low.nil? || high.nil? || range.high.nil?\n \n return low.value == range.low.value && low.inclusive? == range.low.inclusive? &&\n high.value == range.high.value && high.inclusive? == range.high.inclusive?\n end", "def between(n1, n2, n3)\n if n1 >= n2 && n1 <= n3\n return true\n else\n return false\n end\nend", "def check_num(number)\n if (1..10).include? number\n puts \"Valid\"\n else\n puts \"Invalid\"\n end\nend" ]
[ "0.7557789", "0.7422679", "0.7395845", "0.73809433", "0.7292925", "0.7292925", "0.72008795", "0.71961576", "0.7136108", "0.7100964", "0.7053803", "0.70510894", "0.70145833", "0.69458646", "0.6921536", "0.6864503", "0.6855867", "0.67644507", "0.6739863", "0.6738579", "0.6661776", "0.66488796", "0.6635991", "0.6621033", "0.6599818", "0.65889794", "0.6565271", "0.6544301", "0.6491859", "0.6489528", "0.6485093", "0.6471003", "0.6467191", "0.6455533", "0.6439019", "0.64352214", "0.64204085", "0.6387858", "0.63872397", "0.6385556", "0.63827056", "0.637801", "0.6369498", "0.6360426", "0.63479495", "0.6342723", "0.6333497", "0.6315508", "0.6289533", "0.6285028", "0.62816787", "0.62807024", "0.626654", "0.6266503", "0.62648535", "0.62549233", "0.62523645", "0.6238404", "0.6206907", "0.6206873", "0.619117", "0.61724854", "0.6171104", "0.61628014", "0.6143841", "0.614287", "0.6113358", "0.61041516", "0.60889614", "0.606877", "0.6032977", "0.6023024", "0.6019634", "0.6012201", "0.60077924", "0.60073304", "0.60042423", "0.6001954", "0.6000082", "0.5953509", "0.5939208", "0.59347636", "0.5925523", "0.592283", "0.59194493", "0.59130937", "0.59130937", "0.58869654", "0.5886565", "0.5876423", "0.5867542", "0.58540523", "0.5827948", "0.58272123", "0.5824039", "0.5822767", "0.5816918", "0.58087546", "0.5802912", "0.58025277" ]
0.65081936
28
From the page 653 rng.last(n=1) > obj or array Returns the last (or last n) elements of rng.
def test_Range_InstanceMethods_last assert_equal('bb', ('aa'..'bb').last) assert_equal(['ax','ay','az','ba','bb'], ('aa'..'bb').last(5)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last(*n) end", "def last(n=nil)\n return self[-1] if n.nil?\n \n start = length-n\n start = 0 if start < 0\n self[start, n]\n end", "def last(n = 1)\n return self.clone if n >= self.size\n return self[-1] if n == 1\n return self.reverse[0...n].reverse\n end", "def last\n all[all.size - 1]\n end", "def last(n = 1)\n if n > 1\n (ds = Array(max)).empty? ? ds : ds.concat(ds[0].prev(n - 1))\n else\n max\n end\n end", "def last(n = nil)\n if n\n self[-n..-1]\n else\n self[-1]\n end\n end", "def last_of(array)\n return array[-1]\nend", "def last(array)\n array[-1]\nend", "def last\n self.slice(self.size - 1)\n end", "def last_of(array)\n return array[array.length - 1]\nend", "def last_of(array)\n return array[array.length - 1]\nend", "def last\n out = nil\n\n each {|i| out = i }\n\n out\n end", "def last\n @rarray.reverse.first \n end", "def last_of(arr)\n return arr[arr.length-1]\nend", "def last\n @range.last\n end", "def using_last(array)\narray.last\nend", "def using_last(array)\n last_element=array.last\nend", "def last_of(arr)\n output = arr[-1]\n return output\nend", "def using_last(array)\n array.last\n# returns last item in array \nend", "def last_element(array)\n array[-1]\nend", "def retrieve_last_element_from_array(array)\n array[array.length-1]\nend", "def last_of(arr)\n return arr[-1]\nend", "def using_last(array)\n array.last\nend", "def using_last(array)\n array.last\nend", "def last\n at(-1)\n end", "def retrieve_last_element_from_array(array)\n return array[-1]\nend", "def last\n to_a.last\n end", "def last(n = 1)\n return @history[-n] ;\n end", "def lastof(arr)\n return arr[arr.length - 1]\nend", "def last\n self[*Array.new(self.dim, -1)]\n end", "def tail\n \t@array[-1]\n end", "def last_of(arr)\n index = arr.length\n return arr[index -1]\nend", "def last\r\n self[-1]\r\n end", "def last\n @tail\n end", "def lastElement(arr)\n return arr[arr.length - 1]\nend", "def get_last_item(arr)\n\treturn arr[-1]\nend", "def last\n self[-1]\n end", "def last n=nil\n if n.nil? or n == 1\n return the_last\n elsif n <= 0\n return Cons[]\n else\n return nthcdr length-n\n end\n end", "def last\n self[-1]\n end", "def last(*args)\n find_first_or_last(:last, *args)\n end", "def retrieve_last_element_from_array(array)\n array.last\nend", "def last\n @tail.val\n end", "def last(*args)\n find(:last, *args)\n end", "def tail\n @values[1..-1]\n end", "def last_item(elective_array)\n return elective_array[-1]\nend", "def last(*args)\n find(:last, *args)\n end", "def last(*args)\n find(:last, *args)\n end", "def last\n @enumerable.last\n end", "def my_but_last(array)\n\tarray.size - 1\nend", "def last(numbers, int)\n numbers.last(int)\nend", "def last_i\n size - 1\n end", "def last_two(array)\n array.last(2)\nend", "def last(*args)\n all.send(:last, *args)\n end", "def last(options={})\r\n find(:last, options)\r\n end", "def last(list)\n list[-1]\nend", "def last(*vars)\n result = Query.get params(:from => count-1, :size => 1), *vars\n docs = result.get_docs\n docs.is_a?(Array) ? docs.first : docs\n end", "def butlast\n if self.empty?\n []\n else\n self[0..-2]\n end\n end", "def last\n return each\n end", "def last\n @values.last\n end", "def last(num = nil)\n return @all.last num if num\n @all.last\n end", "def last() end", "def last?\n self.index == (self.array.length - 1)\n end", "def last(limit = 1)\n reverse.take(limit).reverse\n end", "def lastElement\n return @stk[@count]\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last(options={})\n get(\"last\", options)\n end", "def last_element_with_array_methods(array)\n array.last\nend", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n @collection.size - 1\n end", "def last; end", "def last; end", "def last; end", "def get_last\n if length == 0\n return nil?\n elsif length == 1\n return @head.data\n else\n current = @head\n (length - 1).times do\n current = current.next\n end\n return current.data\n end\n end", "def get_last\n return @tail ? @tail.data : nil\n end", "def last\n return [] unless @init\n @init.last\n end", "def exclude_last (array)\n array[0..-2]\nend", "def last\n end", "def test_last_three\n array = [1,2,3,4,5]\n array = array.last(3)\n assert_equal [3,4,5], array\n end", "def last(n)\n @queue.last(n)\n end", "def last_ids(number)\n (1 + size - number..size).to_a\n end", "def last\n all.last\n end", "def exclude_last(arr)\n arr[0..-2]\n end", "def last(series, control, count=1)\n slice(series, control, count * -1, -1)\n end", "def second_last\n return nil if (size-2) < 0\n self[size-2]\n end", "def last\n list = self\n list = list.tail until list.tail.empty?\n list.head\n end", "def last_row\n row( maxrow )\n end", "def get_last\r\n return unless @head\r\n \r\n last = @head\r\n last = last.next until last.next.nil?\r\n last.data\r\n end", "def last(limit = 1)\n from(-limit) || self\n end", "def last\n tail.data\n end", "def last\n\t\t\t@last\n\t\tend", "def last\n result ? all.last : limit(1).descending.all.last\n end", "def last_index\n @last_index\n end", "def exclude_last(arr)\n arr.slice!(arr.length-1,1)\n return arr\n end", "def last_output\n return @output_array[-1]\n end", "def last_output\n return @output_array[-1]\n end", "def last_output\n return @output_array[-1]\n end" ]
[ "0.76323164", "0.7443199", "0.74066764", "0.7318788", "0.73128283", "0.72899467", "0.71919453", "0.7143601", "0.71191245", "0.7098221", "0.7098221", "0.70971173", "0.70961624", "0.70566154", "0.70369387", "0.7035263", "0.70233727", "0.7019156", "0.7001647", "0.6987939", "0.6977832", "0.6972202", "0.6951566", "0.6951566", "0.693073", "0.6926356", "0.6924908", "0.691952", "0.69182396", "0.6915685", "0.68458843", "0.68449634", "0.6835022", "0.68316", "0.68135875", "0.6801518", "0.6785333", "0.67699474", "0.6741499", "0.67376965", "0.6718771", "0.67165506", "0.67024463", "0.6702254", "0.6695514", "0.666613", "0.666613", "0.6664171", "0.663981", "0.66239446", "0.65947044", "0.6525", "0.651727", "0.64981663", "0.64966434", "0.64917743", "0.6490392", "0.64693815", "0.6459516", "0.6458034", "0.6448402", "0.64426756", "0.6421649", "0.64015424", "0.63939184", "0.63939184", "0.63939184", "0.63939184", "0.63897216", "0.6380848", "0.6368121", "0.6352276", "0.6352276", "0.6339371", "0.6338658", "0.6338658", "0.6338658", "0.63385797", "0.6337976", "0.63309544", "0.6307117", "0.6305104", "0.63042986", "0.63006896", "0.62993497", "0.62943935", "0.62942225", "0.6267828", "0.6258994", "0.62573445", "0.6237803", "0.623607", "0.62318903", "0.62305844", "0.62185407", "0.62177235", "0.62006855", "0.6198989", "0.6197103", "0.6197103", "0.6197103" ]
0.0
-1
From the page 653 rng.member?(val) > true or false Synonym for Rangeinclude?.
def test_Range_InstanceMethods_member? r = 1..10 assert_equal(true, r.member?(5)) assert_equal(true, r.member?(5.5)) assert_equal(true, r.member?(10)) r = 1...10 assert_equal(false, r.member?(10)) r = 'a'..'z' assert_equal(true, r.member?('b')) assert_equal(false, r.member?('ruby')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def include?(i)\n @range.include?(i)\n end", "def ranges_include?(value)\n any? { |range| Array(range).include?(value) }\n end", "def range_include?(ranges, addr)\n\t\t\tranges.each do |range|\n\t\t\t\treturn true if range.include? addr\n\t\t\tend\n\t\t\tfalse\n\t\tend", "def check_include(value)\n (1..10).include?(value)\nend", "def include?(x)\n inf <= x && x <= sup\n end", "def range_include?(zelf, other)\n # 1...10 includes 1..9 but it does not include 1..10.\n operator = zelf.exclude_end? && !other.exclude_end? ? :< : :<=\n zelf.include?(other.first) && other.last.send(operator, zelf.last)\nend", "def test_Range_InstanceMethods_include?\n\t\tr = 1..10\n\t\tassert_equal(true, r.include?(5))\n\t\tassert_equal(true, r.include?(5.5))\n\t\tassert_equal(true, r.include?(10))\n\n\t\tr = 1...10\n\t\tassert_equal(false, r.include?(10))\n\n\t\tr = 'a'..'z'\n\t\tassert_equal(true, r.include?('b'))\n\t\tassert_equal(false, r.include?('ruby'))\n\tend", "def include?(row, col)\n @range.include?(row) && @range.include?(col)\n end", "def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend", "def in_range?\n return self.range.include?([@x, @y])\n end", "def include?(*args_)\n _offset_for_args(args_) ? true : false\n end", "def include?(low, high = nil)\n return @data.include?(low) if high.nil?\n (low..high).each { |i| return false if get(i).nil? }\n return true\n end", "def include_with_range?(value)\n if value.is_a?(::Range)\n operator = exclude_end? ? :< : :<=\n end_value = value.exclude_end? ? last.succ : last\n include?(value.first) && (value.last <=> end_value).send(operator, 0)\n else\n include_without_range?(value)\n end\n end", "def overlap? range\n !(self & range).nil?\n end", "def include?(member)\n `self.hasOwnProperty(member)`\n end", "def range_includes_item?(range, item)\n range.begin <= item && item <= range.end\n end", "def include?(v)\n case v\n when Range\n include_range?(v)\n when RangeSet\n include_rangeset?(v)\n else\n include_scalar?(v)\n end\n end", "def inclusion_method(enumerable)\n enumerable.is_a?(Range) ? :cover? : :include?\n end", "def in_ranged_array?(ranged_ary, num)\n !!ranged_ary.find {|n| n === num }\n end", "def include?(o)\n return false unless valid_member?(o)\n @val[o] != 0\n end", "def in_ranges?(num, ranges)\n result = false\n ranges.each do |range|\n if range.include?(num)\n result = true\n end\n end\n return result\nend", "def in_range\n\t\trange = Set[1, 2, 3, 4, 5,\n\t\t\t\t\t\t\t\t6, 7, 8, 9, 10,\n\t\t\t\t\t\t\t 11, 12, 13, 14, 15,\n\t\t\t\t\t\t\t\t16, 17, 18, 19, 20,\n\t\t\t\t\t\t\t\t21, 22, 23, 24, 25,\n\t\t\t\t\t\t\t\t26, 27, 28, 29, 30]\n\n\t\tif @landmarks.subset?(range)\n\t\t\treturn true\n\t\tend\n\n\t\treturn false\n\tend", "def has_range?\n !self.domain_ranges.nil?\n end", "def include?(p0) end", "def include?(p0) end", "def include?(p0) end", "def include?(p0) end", "def include?(p0) end", "def include?(p0) end", "def include?(flag)\n return ( @val & flag ) == flag\n end", "def include?(x)\n @indices[x] # huh\n end", "def include?(addr)\n\t\treturn false if not @ranges\n\t\tif (addr.is_a? String)\n\t\t\taddr = Rex::Socket.addr_atoi(addr)\n\t\tend\n\t\[email protected] { |r| \n\t\t\tif r.start <= addr and addr <= r.stop\n\t\t\t\treturn true\n\t\t\tend\n\t\t}\n\t\treturn false\n\tend", "def include?(arr, target)\n arr.any?{ |ele| ele == target} ? true : false\nend", "def include?(array, arg)\n boolean_return = false\n array.each {|value| return boolean_return = true if value == arg}\n boolean_return\nend", "def include?(chr, start = nil, stop = nil)\n if start.nil?\n chromosomes.include?(chr)\n elsif stop.nil?\n chromosomes.include?(chr) and start >= chr_start(chr) and start <= chr_stop(chr)\n else\n chromosomes.include?(chr) and start >= chr_start(chr) and stop <= chr_stop(chr)\n end\n end", "def include?(arr, val)\n arr.each { |el| return el == val if el == val }\n false\nend", "def contains\n \t\tfalse\n\tend", "def within?(val,lower,upper)\n\n check_pre((\n (val.nat?) and\n (lower.nat?) and\n (upper.nat?)\n ))\n\n (val >= lower) and (val <= upper)\n\n end", "def matched_by_extended_range?(range)\n recompose\n subtags = @composition.split(Const::HYPHEN)\n subranges = range.downcase.split(Const::HYPHEN)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == Const::WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def include?(position); end", "def contains(value)\n end", "def member?(p0) end", "def member?(p0) end", "def member?(p0) end", "def include?(ary, target)\n !ary.select { |value| value == target }.empty?\nend", "def include?(array, value)\n array.any?(value)\nend", "def member_of?(key, value)\n val = get(key)\n val and val.include?(value)\n end", "def include?(arr, search_value)\n arr.each do |num|\n if num == search_value\n return true\n end\n end\n false\nend", "def inclusive!\n @inclusive = true\n end", "def within(range: T.unsafe(nil)); end", "def include?(arr, value)\n includes = false\n arr.each { |n| includes = true if n == value }\n includes\nend", "def include?(arr, num)\n arr.each{ |element| return true if element == num}\n return false\nend", "def contain?(position); end", "def include?(array, value)\n array.each do |integer|\n return true if integer == value\n end\n return false\nend", "def include?(ary, value)\n !!ary.index(value)\nend", "def covers?(*args)\n other = coerce_range(*args)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n self.begin <= other.begin and other.end <= self.end\n end\n end", "def in_range?(val, range)\n return true unless range\n\n if range.is_a?(Hash)\n result = true\n result &= ( val < range[:before] ) if range[:before]\n result &= ( val > range[:after] ) if range[:after]\n result &= ( val <= range[:max] ) if range[:max]\n result &= ( val >= range[:min] ) if range[:min]\n result &= ( val < range[:less_than] ) if range[:less_than]\n result &= ( val <= range[:less_than_or_equal_to] ) if range[:less_than_or_equal_to]\n result &= ( val > range[:greater_than] ) if range[:greater_than]\n result &= ( val >= range[:greater_than_or_equal_to] ) if range[:greater_than_or_equal_to]\n result\n else\n range = [range] unless range.respond_to?(:include?)\n range.include?(val)\n end\n end", "def include_range? other_range\n case other_range\n when Range\n if other_range.first >= self.first && other_range.last <= self.last\n return true\n else\n return false\n end\n else\n raise \"unsupported type\"\n end\n end", "def include?(array, value)\n array.each do |elem|\n return true if elem == value\n end\n false\nend", "def include?(arr, val)\n arr.any? { |element| element == val }\nend", "def include?(array, value)\n array.each { |element| return true if value == element }\n false\nend", "def rinclude\n -> v, x { x.include?(v) }.curry\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end", "def matched_by_basic_range?(range)\n if range.kind_of?(self.class)\n s = range.recompose.tag\n elsif range.respond_to?(:to_str)\n return true if range.to_str == Const::WILDCARD\n s = self.class.parse(range).tag\n else\n return false\n end\n recompose\n @tag == s || @tag.index(s + Const::HYPHEN) == 0\n rescue\n false\n end", "def matched_by_extended_range?(range)\n\n subtags = decomposition.dup\n subranges = range.to_str.downcase.split(HYPHEN_SPLITTER)\n\n subrange = subranges.shift\n subtag = subtags.shift\n\n while subrange\n if subrange == WILDCARD\n subrange = subranges.shift\n elsif subtag == nil\n return false\n elsif subtag == subrange\n subtag = subtags.shift\n subrange = subranges.shift\n elsif subtag.size == 1\n return false\n else\n subtag = subtags.shift\n end\n end\n true\n rescue\n false\n end", "def in_move_range?(v)\n (20..500).include? v\n end", "def include?(array, search)\n array.each do |value|\n return true if value == search\n end\n false\nend", "def include?(num)\n self[num].include?(num)\n end", "def b_include?(obj) # assumes the array is sorted\n range = bsearch_range { |x| x <=> obj } # returned range excludes its last element\n (self[range.first] == obj or self[range.last - 1] == obj)\n end", "def include?(array, value)\n # method A\n array.any? { |element| element == value }\n \n # method B\n # for item in array\n # return true if item == value\n # end\n \n # false\nend", "def all_in_ranges?(nums, ranges)\n if nums.empty?\n return false\n end\n nums.each do |num|\n if !in_ranges?(num, ranges)\n return false\n end\n end\n true\nend", "def include?(arr, search)\n result = false\n arr.each { |num| result = true if num == search }\n result\nend", "def range_cover?(outer, inner)\n outer.cover?(inner.begin) && outer.cover?(inner.end)\nend", "def valid?(range)\n range[0] < range[1]\nend", "def include?(arr, number)\n arr.any? { |num| num == number }\nend", "def include\n -> x, v { x.include?(v) }.curry\n end", "def include?(arr, search_val)\n # arr.each { |e| return true if e == search_val }\n # false\n arr.count(search_val) > 0\n # or:\n # arr.any? { |i| i == val }\nend", "def include?(something); end", "def check_range(rng)\n new(rng).results\n end", "def value? value\n include? value\n end", "def include?(*args)\n args.inject(true) {|val, x| val = self.single_include?(x)}\n end", "def include?(other)\n `return self.indexOf(other) == -1 ? Qfalse : Qtrue;`\n end", "def include?(other)\n `return self.indexOf(other) == -1 ? Qfalse : Qtrue;`\n end", "def in_range?(key)\n (key>=range_start) && (range_end==LAST_POSSIBLE_KEY || key < range_end)\n end", "def contains?(number)\n @numbers.include?(number)\n end", "def includeColumn? (col)\n return @cols.nil? ? true : @cols.member?(col)\nend", "def include?(value)\n candidate = intervals\n .find { |min, max| max >= value }\n candidate && (candidate[0] <= value)\n end", "def hasArg?(arg); argSet.member?(arg) end", "def include?(array, query)\n array.each do |el|\n return true if el == query\n end\n false\nend", "def include?(value)\n each do |index, list_value|\n return true if list_value == value\n end\n return false\n end", "def within?(value)\n value >= @lower and value <= @upper\n end", "def includes?(array, target)\n return false if array.empty?\n return true if array.first == target\n includes?(array[1..-1])\nend", "def array_42(z)\n if z.include? 42\n return true\n else\n return false\n end\n\nend", "def my_include?(array, target)\n return false if array.empty?\n return true if array.first == target\n my_include?(array.drop(1), target)\nend", "def include?(array, search_value)\n # array.each do |element|\n # return true if element == search_value\n # end\n # false\n array.count(search_value) > 0\nend", "def include?(array, value)\n !!array.find_index(value)\nend", "def include?(array, value)\n !!array.find_index(value)\nend", "def unique_val?\n @lower == @upper\n end", "def should_hit?\n hit = true\n @values.each { |val| hit &= !(val >= 17 && val <= 21) }\n hit\n end" ]
[ "0.67694825", "0.6643983", "0.64987695", "0.64606565", "0.63851225", "0.63162804", "0.6306146", "0.6281779", "0.6269659", "0.61950886", "0.61744666", "0.6146276", "0.6143199", "0.6096666", "0.6062473", "0.60531837", "0.6021256", "0.60050917", "0.5996035", "0.5964964", "0.5946816", "0.59121066", "0.58469015", "0.5831969", "0.58306766", "0.58306766", "0.58306766", "0.58306766", "0.58306766", "0.5828247", "0.5813269", "0.580763", "0.5802339", "0.57985044", "0.5784222", "0.5782318", "0.5736929", "0.57352304", "0.5735206", "0.5726691", "0.5723715", "0.5719324", "0.5719324", "0.5719324", "0.5718554", "0.5714779", "0.57124823", "0.57060564", "0.56988937", "0.56942356", "0.568916", "0.5685252", "0.5679713", "0.5678545", "0.56723046", "0.5662038", "0.56571865", "0.56524837", "0.5644912", "0.5642701", "0.55982304", "0.55979806", "0.5593866", "0.5593866", "0.5580169", "0.5577736", "0.5576809", "0.5571424", "0.5562116", "0.5560863", "0.5559714", "0.55577093", "0.55541456", "0.5553343", "0.55518", "0.5547831", "0.5539433", "0.55372775", "0.55351603", "0.55301315", "0.5529372", "0.5528705", "0.5525451", "0.5525451", "0.55231607", "0.5516571", "0.55098313", "0.5509633", "0.55095017", "0.5495517", "0.5494465", "0.5493773", "0.5493585", "0.5483973", "0.54746187", "0.5470627", "0.5467686", "0.5467686", "0.5467045", "0.5460234" ]
0.6109425
13
From the page 653 rng.size > int or nil Returns the number of elements in rng. In ruby 2.0 only works for ranges of integers
def test_Range_InstanceMethods_size # New in 2.0! # assert_equal(26, (1..26).size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_between(list_of_integers,lower_bound,upper_bound)\nr = Range.new(lower_bound,upper_bound)\nnew_array=[]\nlist_of_integers.each do |x|\n if r.include?(x)\n new_array.push(x)\n end\n\nend\n\nreturn new_array.length\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\nnew_array=Array.new\nlist_of_integers.each {|x|\n if x >= lower_bound.to_i && x <= upper_bound.to_i\n new_array << x\n end}\n return new_array.length\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\nin_bounds = []\n\n list_of_integers.each do |num|\n if num >= lower_bound && num <= upper_bound\n in_bounds << num\n else\n \"out of bounds\"\n end\n end\n\n p in_bounds.length\n\nend", "def check_range(rng)\n new(rng).results\n end", "def size\n @range.size\n end", "def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\n end\n new_array = list_of_integers.select { |x| x >= lower_bound && x <= upper_bound }\n new_array.length\nend", "def size_range(range)\n return [1,1] if range.nil?\n from = range.from\n to = range.to\n x = from.nil? ? 1 : from\n y = to.nil? ? TheInfinity : to\n [x, y]\n end", "def count_between(list_of_integers, lower_bound, upper_bound)\n new_array = []\n \n list_of_integers.each do |num|\n if num >= lower_bound && num <= upper_bound\n new_array.push(num)\n end\n end\n new_array.length\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n #find numbers less than or equal to upper bound\n #find numbers greater than or equal to lower bound\n # how many there are\n counter = []\n list_of_integers.each do |num|\n if num >= lower_bound && num <= upper_bound\n counter.push(num)\n else\n end\n end\n return counter.length\nend", "def length_in(range)\n (self & range)&.length || 0\n end", "def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\nelsif upper_bound < lower_bound\n return 0\nend\n# sum = 0\n# sum = list_of_integers[lower_bound..upper_bound].each\n# for integer in lower_bound..upper_bound\n# p integer\n# if list_of_integers.each >= lower_bound && list_of_integers.each <= upper_bound\nnew_array = []\nlist_of_integers.each do |number| if number >= lower_bound && number <= upper_bound\nnew_array.push(number)\nend\nend\nsum = new_array.length\nsum\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n if (list_of_integers.size != 0) && (upper_bound >= lower_bound)\n #puts \"Array size greater than 0 and upper_bound is greater than lower_bound!\"\n i = 0\n nums_between = 0\n #puts \"size of array: \" + list_of_integers.size.to_s\n for i in 0...list_of_integers.size\n num = list_of_integers[i]\n #puts \"array at index #{i} is #{num}\"\n if (lower_bound <= num) && (num <= upper_bound)\n nums_between += 1\n #puts nums_between\n end\n i += 1\n end\n return nums_between\n else\n #puts \"Array empty\"\n return 0\n end\nend", "def size_from_range(range)\n size = range.end - range.begin + 1\n raise NegativeRangeSpan, \"The resulting size for range #{range} is negative\" if size < 0\n size\n end", "def find_range(arr,low,high)\n arr.find_all{|item| item >=low && item <= high}.length\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\ncount = 0\nrange_array = *(lower_bound..upper_bound)\nlist_of_integers.each do |i|\nif range_array.include?(i) == true\ncount += 1\nend\nend\nreturn count\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n return 0 if list_of_integers.empty?\n return 0 if upper_bound < lower_bound\n\n test_num = list_of_integers.pop\n out_of_bounds = []\n solution = []\n\n if test_num > upper_bound || test_num < lower_bound\n out_of_bounds << test_num\n else\n solution << test_num\n end\n\n list_of_integers.each do |num|\n if num > upper_bound || num < lower_bound\n out_of_bounds << num\n else\n solution << num\n end\n end\n\n return solution.length\n\n # OR USE delete_if METHOD:\n # new_list = list_of_integers.delete_if {|num| num > upper_bound || num < lower_bound}\n # return new_list.length\n\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\n end\n\n counter = 0\n list_of_integers.each { |x|\n if (x >= lower_bound) && (x <= upper_bound)\n counter += 1\n elsif\n counter += 0\n end\n }\n p counter\nend", "def within(range: T.unsafe(nil)); end", "def count_between(list_of_integers, lower_bound, upper_bound)\n # Your code goes here!\n return 0 if list_of_integers.length == 0 || upper_bound < lower_bound\n\n numbers_between = 0\n\n list_of_integers.each { |this_integer| \n if this_integer >= lower_bound && this_integer <= upper_bound\n numbers_between += 1\n end\n }\n\n return numbers_between\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers.nil?\n return 0\n end\n list_of_integers.count do |integer|\n (lower_bound..upper_bound).include?(integer)\n end\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n\treturn 0 if list_of_integers.length == 0 || upper_bound<lower_bound\n\trange = (lower_bound..upper_bound).to_a\n\tlist_of_integers.count {|v| (lower_bound..upper_bound).include? (v)}\n\n # Your code goes here!\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n\treturn list_of_integers.count {|x| x >= lower_bound && x <= upper_bound}\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n\n list_of_integers.each do |n|\n answer = 0\n if n >= lower_bound && n <= upper_bound\n answer = answer + 1\n else\n end\n\n end\nend", "def in_range?(index)\n index >= 0 and index < size\n end", "def count_between(array, lower_bound, upper_bound)\n\tcounter = 0\n\tnumbers = 0\n\twhile counter < array.length\n\t\tif ((array[counter] <= upper_bound) && (array[counter] >= lower_bound))\n\t\tnumbers += 1\n\t\tcounter += 1\n\t\telse\n\t\t\tcounter += 1\n\t\tend\n\tend\n\treturn numbers\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n # Your code goes here!\n return 0 if list_of_integers.length == 0\n\n flag = false\n con\n # iter array\n list_of_integers.each do |x|\n\n if x >= lower_bound || x <= upper_bound\n #flag = !flag\n new_array.push(x)\n end\n if flag == false\n list_of_integers.delete(x)\n end\n end\n return list_of_integers\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n count = 0\n list_of_integers.each do |int|\n if (lower_bound..upper_bound).include? int\n count = count + 1\n end\n end\n return count\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n\tarray_length = list_of_integers.sort!.length\n\tcounter = 0\n\tlist_of_integers.each {|element| counter += 1 if element >= lower_bound && element <= upper_bound}\n\tcounter\nend", "def dont_give_me_five(start_,end_)\n array = (start_..end_).to_a\n\n array.delete_if {|x| x.to_s.include?(\"5\")}\n n = array.count\n return n\nend", "def count_range(column_family, options = {})\n get_range_keys(column_family, options).length\n end", "def count_between(list_of_integers, lower_bound, upper_bound)\n list_of_integers.count {|x| x>= lower_bound && x <= upper_bound}\nend", "def length\n timevec[index_range].length\n end", "def count_between(list_of_integers, lower_bound, upper_bound)\n\nend", "def _num_bits_in_range(bits, max, min)\n upper = bits.position + bits.size - 1\n lower = bits.position\n [upper, max].min - [lower, min].max + 1\n end", "def length(array)\n length = 0\n while !(array[length].nil?)\n length += 1\n end\n return length\n # raise NotImplementedError\nend", "def length_of_lis(nums)\n len = []\n (0...nums.size).map { |i|\n len[i] = (0...i)\n .select { |j| nums[j] < nums[i] }\n .map { |j| len[j] + 1 }.max || 1\n }.max || 0\nend", "def length(array)\n array_length = 0\n 20.times do |i|\n if array[i] != nil\n array_length += 1\n elsif array[i] == nil\n break\n end\n end\n return array_length\n # raise NotImplementedError\nend", "def length(array)\n count = 0\n\n until array[count].nil?\n count +=1\n end\n return count\nend", "def rand_in_range(from, to); end", "def get_num(arr)\n case rand(100) + 1\n when 1..5\n check_if_nil(arr,0)\n when 6..65\n check_if_nil(arr,1)\n when 66..100\n check_if_nil(arr,2)\n end\n end", "def length(array)\n count = 0\n until array[count] == nil\n count = count + 1\n end\n return count\nend", "def range; end", "def range; end", "def range; end", "def number_of_values\n Integer((@upper - @lower) / @step) + 1\n end", "def range1d?(o)\n o.int_range?\nend", "def missing_ranges(array, lower = 0, upper = 99)\n ranges = []\n\n i = 0\n prev = lower - 1\n\n while i <= array.size\n curr = (i == array.size) ? upper + 1 : array[i]\n\n if curr - prev > 1\n ranges << get_range(prev + 1, curr - 1)\n end\n\n prev = curr\n i += 1\n end\n\n ranges\nend", "def in_range (n)\n\tif n <1 || n> 10 \n\t\tfalse\n\telse\n\t\ttrue\n\tend\nend", "def length(array)\n count = 0\n\n until array[count] == nil\n count += 1\n end\n\n return count\nend", "def dont_give_me_five(start, end )\n (start..end).count{|i| not i.to_s.include? '5'}\nend", "def test_ranges\r\n assert_equal(@range.begin.to_f, @p2.to_f)\r\n assert(@range.cover?(@p5))\r\n assert(@range.end == @p8)\r\n assert(@range2.exclude_end?)\r\n assert_false(@range.exclude_end?)\r\n assert(@range.include?(@p3))\r\n assert(@range.max == @p8)\r\n assert(@range2.max == @p7)\r\n assert(@range.last(3) == [@p6, @p7, @p8])\r\n assert(@range.size == nil)\r\n end", "def number_of_groups\n empty? ? 0 : boundaries.size\n end", "def length(array)\n array_length = 0\n while array[array_length] != nil\n array_length += 1\n end\n return array_length # raise NotImplementedError\nend", "def size\n Integer.new.tap do |count|\n each { |element| count += 1 }\n end\n end", "def range_distribution\n nil_values_count = values.count(nil)\n values_without_nils = values.reject(&:nil?)\n\n distr = ranges.map do |range|\n freq = values_without_nils.select{|value| value >= range}.length\n values_without_nils.reject!{|value| value >= range}\n\n [range, freq]\n end.to_h\n\n distr.merge!({nil => nil_values_count}) if nil_values_count > 0\n distr\n end", "def length(array)\n i = 0\n until array[i] == nil\n i += 1\n end\n return i\nend", "def size\n\t\tlast - first + (exclude_end? ? 0 : 1)\n\tend", "def valid_range?\n (0..@max_num).cover?(@number)\n end", "def find_index num\n return if num > size\n\n low = 1\n high = @bounds.count\n\n while low!=high do\n mid = (low+high)/2\n if @bounds[mid] <= num then\n low = mid+1\n else\n high = mid\n end\n end\n\n low\n end", "def dont_give_me_five(start_,end_)\n (start_..end_).count { |n| n.to_s !~ /5/ }\nend", "def length(range)\n range = range..range if range.is_a?(Integer)\n assert_range range\n min_length range.min\n max_length range.max unless range.end.nil?\n self\n end", "def how_many_missing(arr)\n arr.count > 0 ? (arr.first..arr.last).count - arr.count : 0\nend", "def upper_bound; end", "def simber_count(n)\n lower_range = 10**(n - 1)\n upper_range = (10**n) - 1\n count = 0\n (lower_range..upper_range).each do |i|\n count += 1 if simber_check(i)\n end\n count\nend", "def empty?\n return false if @upper_bound.nil?\n @lower_bound > @upper_bound\n end", "def check_in_count()\n return @guests.length #guests array length\n end", "def get_upper_limit_of(range)\n\tn = 1..20\n\tn.last\nend", "def range(arr)\n\nend", "def length\n @length.kind_of?(Range) ? @length.max : @length\n end", "def get_upper_limit_of(range)\n range.end\nend", "def search_range(nums, target)\n range_helper(nums, target, 0, nums.length)\nend", "def has5?(a)\n return 5<=a.size\nend", "def ubound(arr,value)\r\n\tng,ok=-1,arr.size\r\n\twhile((ng-ok).abs>1) do\r\n\t\tmid=(ng+ok)/2\r\n\t\tif(arr[mid]>value)\r\n\t\t\tok=mid\r\n\t\telse\r\n\t\t\tng=mid\r\n\t\tend\r\n\tend\r\n\treturn ok\r\nend", "def length\n reduce(0) {|sum,_| sum + 1 }\n end", "def generatePossibleCombinationsCount(low, high)\n count = 0\n for number in (low..high)\n count += 1 if testNumber(number)\n end\n count\nend", "def span\r\n if @range.none?\r\n 0\r\n else\r\n @range.max - @range.min + 1\r\n end\r\n end", "def range\n @range ||= 0.upto(@limit)\n end", "def basic_8 (array_iterate, eval_int)\n total = 0\n array_iterate.each { |n| total += 1 if n > eval_int}\n return total\nend", "def naive_range(arr, window)\n\tcurrent_max_range = nil\n\treturn arr if arr.length < window + 1\n\n # arr.each do |ele|\n # \twindowed_range = \n\n # end\n\n left = arr.take(window)\n\tright = arr.drop(window)\n\t# p left\n\t# p right\n left_range = left.max - left.min\n # debugger\n\tright_range = right.max - right.min\n\tif left_range > right_range\n\t\treturn left\n\telse\n\t\tnaive_range(right, window)\n\tend\n\nend", "def length(prec = 100, dec = toDigArray(prec))\n (prec/2).times{dec.shift}\n for len in 1...(dec.length/2)\n ret = true\n for x in 0...len\n value = dec[x]\n for iter in 1...(dec.length/len)\n ret = false if value != dec[iter*len+x]\n end\n end\n return len if ret\n end\n return length(prec*2)\n end", "def out_of_bound?(value, min, max)\n return value > max || value < min\n end", "def length\n stop - start + 1 unless coverage == 0\n end", "def size?() end", "def size\n return 1 if @to.nil?\n from = IPAddr.new(@from)\n to = IPAddr.new(@to)\n (from..to).to_a.size\n end", "def bound(length)\n 0 <= self && self < length\n end", "def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend", "def repeated_number_ranges(arr)\n\n\nend", "def length(array)\n index = 0\n while array[index] != nil\n index += 1\n end\n return index\nend", "def rand_num(range)\n num = @rng.rand(range) + 1\n num\n end", "def search_upper_boundary(array, range=nil, &block)\n range = 0 ... array.length if range == nil\n \n lower = range.first() -1\n upper = if range.exclude_end? then range.last else range.last + 1 end\n while lower + 1 != upper\n mid = ((lower + upper) / 2).to_i # for working with mathn.rb (Rational)\n if yield(array[mid]) <= 0\n lower = mid\n else \n upper = mid\n end\n end\n return lower + 1 # outside of the matching range.\n end", "def test_top_bottom\n x = IntegerRange.new(1000, 1)\n\n assert_equal(x.bottom, 1)\n assert_equal(x.top, 1000)\n assert_equal(x.to_a, (1..1000).to_a)\n\n a = each_to_a(x)\n\n assert_equal(a, (1..1000).to_a)\n end", "def length(int_or_range)\n case int_or_range\n when Integer\n min_length(int_or_range)\n max_length(int_or_range)\n when Range\n min_length(int_or_range.min)\n max_length(int_or_range.max)\n else\n fail ArgumentError, \"Argument must be an Integer or a Range\"\n end\n self\n end", "def small_enough(arr, limit)\n arr.all? { |num|\n num <= limit\n }\nend", "def my_count n = nil\n if block_given?\n truths = 0\n self.my_each {|o| truths += 1 if yield(o)}\n truths\n elsif n.nil?\n self.length\n else\n my_count {|x| x==n}\n end\n end", "def nitems\n count = 0\n i = 0\n lim = self.__size\n while i < lim\n count += 1 unless self.__at(i)._equal?(nil)\n i += 1\n end\n count\n end", "def target_len; seq2.len; end", "def range(input); end", "def __beg_len(len)\n beg = Maglev::Type.coerce_to(@_st_from, Fixnum, :to_int)\n the_end = Maglev::Type.coerce_to(@_st_to, Fixnum, :to_int)\n\n if (beg < 0)\n beg += len\n return nil if (beg < 0)\n end\n\n return nil if (beg > len)\n the_end = len if (the_end > len)\n\n the_end += len if (the_end < 0)\n the_end += 1 unless @_st_excludeEnd\n len = the_end - beg\n len = 0 if (len < 0)\n return [beg, len]\n end", "def if_range(node); end", "def get_upper_limit_of(range)\n range.max\nend" ]
[ "0.66657025", "0.65354204", "0.6525089", "0.6522534", "0.6476154", "0.64604956", "0.63427526", "0.63277805", "0.6322742", "0.63173044", "0.6316268", "0.6289644", "0.62690246", "0.62558174", "0.6239591", "0.61385345", "0.61141354", "0.609874", "0.60566884", "0.6044494", "0.59501773", "0.59448105", "0.59066236", "0.5892413", "0.5888742", "0.5881603", "0.5871368", "0.5870008", "0.5864814", "0.58325946", "0.5823807", "0.5782397", "0.5717839", "0.56722224", "0.5666518", "0.5659251", "0.5652537", "0.5604644", "0.55915415", "0.5577662", "0.5576796", "0.55649", "0.55649", "0.55649", "0.5555206", "0.55489945", "0.55461526", "0.5534534", "0.5510646", "0.5504624", "0.5500711", "0.54966366", "0.5470598", "0.54701746", "0.5460879", "0.5454379", "0.5441898", "0.5429817", "0.54287654", "0.54070896", "0.54034406", "0.5394294", "0.539406", "0.5382564", "0.53815925", "0.5373018", "0.5371034", "0.5365977", "0.5364301", "0.5338253", "0.5328919", "0.53271383", "0.5320614", "0.5285058", "0.5282438", "0.52789956", "0.52579755", "0.5256736", "0.52523625", "0.524198", "0.5233279", "0.523173", "0.5231413", "0.52287483", "0.52215016", "0.5220542", "0.52177197", "0.5216075", "0.5212748", "0.52111787", "0.52090645", "0.5204205", "0.51986355", "0.519666", "0.51919866", "0.51896083", "0.5178071", "0.5168875", "0.5164283", "0.5156631" ]
0.61979157
15
gray Boom City tiles available in supply, plus how many will be made available by resolving pending upgrades to gray Double Boom City tiles
def gray_boomcity_tile_potential_count gray_boomcity_tile_count + [gray_double_boomcity_tile_count, @pending_gray_boom_tile_lays[:double_boom].size].min end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tiles_remaining\n # still not sure why or how this is working. TODO: may take out later\n total_num_tiles = @default_set.inject(0) { |letter, letter_quantity| letter += letter_quantity[1] }\n p \"++++TEST++++\"\n p total_num_tiles\n return total_num_tiles\n end", "def tiles_remaining\n @default_tiles.values.inject(0, :+)\n end", "def tiles_remaining\n return @tiles\n end", "def reachable_tiles\n @tiles\n end", "def score\n self.tiles.inject(0){|sum,num| sum+=TileBag.points_for(num)}\n end", "def continent_size world, x, y\nif world[y][x] != 'land' # => false, true, true, true, false, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true\n# Either it's water or we already counted it,\n# but either way, we don't want to count it now.\nreturn 0 # => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\nend\n# So first we count this tile...\nsize = 1 # => 1, 1, 1\nworld[y][x] = 'counted land' # => \"counted land\", \"counted land\", \"counted land\"\n# Each time the program his a tile marked 'land' it updates that tile\n# so it is no longer 'land' but 'counted land', meaning the next time the\n# program hits that tile it will no longer be equal to 'land' and therefore\n# is not double counted.\n\n# ...then we count all of the neighboring eight tiles\n# (and, of course, their neighbors by way of the recursion).\n#\n# The best way to think of this is that each time the program hits a land tile\n# it starts spiraling around that tile until it finds another land tile and\n# each time it finds another land tile it starts again from that second land tile\n# and so on and son on until it has counted all the land tiles and their neighbors\n# that joined the starting tile.\n#\nsize = size + continent_size(world, x-1, y-1) # => 1, 1, 1\nsize = size + continent_size(world, x , y-1) # => 1, 1, 1\nsize = size + continent_size(world, x+1, y-1) # => 1, 1, 1\nsize = size + continent_size(world, x-1, y ) # => 1, 1, 3\nsize = size + continent_size(world, x+1, y ) # => 1, 1, 3\nsize = size + continent_size(world, x-1, y+1) # => 1, 1, 3\nsize = size + continent_size(world, x , y+1) # => 1, 2, 3\nsize = size + continent_size(world, x+1, y+1) # => 1, 2, 3\nsize # => 1, 2, 3\nend", "def availability_summary #This should be changed to availability_summary_count\n unavailable = 0\n available = 0\n awaiting = 0\n\n self.cached_teamsheet_entries.each do |tse|\n if tse.response_status == 0\n unavailable += 1\n elsif tse.response_status == 1\n available += 1\n elsif tse.response_status == 2\n awaiting += 1\n end\n end\n\n { unavailable: unavailable, available: available, awaiting: awaiting }\n end", "def count_ai_battler\n count = -1\n @battle_info.parties.each do |bank|\n count += bank.size\n end\n log_debug(\"Found #{count} AI\")\n return count\n end", "def num_ships\n @grid.reduce(0) { |acc, el| acc + el.count(:S) }\n end", "def mine_count\n grid.flatten.count { |space| space.mine }\n end", "def handle_gray_booms!\n return if @pending_gray_boom_tile_lays.values.flatten.empty?\n\n # clear gray double boom city actions, no tiles remain\n if (num_double_boom_tiles = gray_double_boomcity_tile_count).zero?\n @pending_gray_boom_tile_lays[:double_boom].clear\n\n # there are enough gray double boom city tiles, automatically lay them\n elsif num_double_boom_tiles >= @pending_gray_boom_tile_lays[:double_boom].size\n @pending_gray_boom_tile_lays[:double_boom].each do |hex|\n boomcity_to_double_boomcity!(hex, gray_checked: true)\n end\n end\n\n # clear pending gray boom city tile lays, no tiles remain\n if gray_boomcity_tile_potential_count.zero?\n @pending_gray_boom_tile_lays[:boom].clear\n\n # there are enough gray boom city tiles, automatically lay them\n elsif gray_boomcity_tile_count >= @pending_gray_boom_tile_lays[:boom].size\n @pending_gray_boom_tile_lays[:boom].each do |hex|\n boomtown_to_boomcity!(hex, gray_checked: true)\n end\n end\n end", "def count_black_tiles_around(in_tiles, tile_x, tile_y)\n black_tile_count = 0\n MOVE.each do |dir, deltas|\n other_tile_x = tile_x + deltas[0]\n other_tile_y = tile_y + deltas[1]\n hash_key = \"#{other_tile_x}_#{other_tile_y}\"\n black_tile_count += 1 if (in_tiles[hash_key] % 2 == 1)\n end\n black_tile_count\nend", "def calc_gpus_unallocated\n @gpus_unallocated = 0\n #if @cluster_title.eql?('Owens')\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node|\n # !node.include?(\"dedicated_threads = 28\") && node.include?(\"Unallocated\") }.size\n # elsif @cluster_title.eql?('Pitzer')\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node| !node.include?(\"dedicated_threads = 40\") }.to_s.scan(/gpu_state=Unallocated/).size\n # else @cluster_title.eql?('Ruby')\n # # See line 62. Excluding the two debug nodes from the calculation.\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"Unallocated\") && !node.include?(\"dedicated_threads = 20\") && node.include?(\"np = 20\") }.size\n # @oodClustersAdapter.info_all_each { |job| p job}\n #end\n end", "def num_tankoubon; end", "def additional_z\n return 0 if [:idle, :hurt, :covered].include?(battle_phase) \n return 1 if covering\n return 2\n # Active battler displayed above another (increment by 2)\n end", "def total_cost_for_stay\n number_of_nights? * 200\n end", "def tiles_remaining\n return @collection.length\n end", "def num_ships \n @grid.flatten.count(:S)\n end", "def chip_total(chips)\n\t\tchips = chips.to_i\n\t\t# sum each value in total\n\t\t# return chips WON/lost\n\t\tchips_won_or_lost = chips.to_i\n\t\treturn chips_won_or_lost\n\tend", "def total_branches\n covered_branches + missed_branches\n end", "def return_beds(population, beds)\n beds.each do |from_location|\n @beds[from_location][:available] += 1\n if from_location==population.name\n @beds[from_location][:used_locally] += 1\n end\n raise \"Too many beds returned\" if @beds[from_location][:available]>@beds[from_location][:max]\n end\n beds.count\n end", "def grows_fruits\n return @orange_count = @tree_years * 100\n end", "def count_available(reload_variant = true)\n self.reload if reload_variant\n count_on_hand - count_pending_to_customer\n end", "def used\n @state.sum do |row|\n row.count { |square| square == USED }\n end\n end", "def water_tiles\n puts @area.select { |_, v| '~|'.include?(v) }.keys.select { |_, y| y <= @max_y }.count\n puts @area.select { |_, v| v == '~' }.keys.select { |_, y| y <= @max_y }.count\n end", "def number_of_units\n return 0.0 if demand.zero?\n return super unless full_load_hours&.positive?\n\n if input_capacity&.positive?\n demand / (input_capacity * full_load_hours)\n elsif output_capacity&.positive?\n (demand - output_of_loss) / (output_capacity * full_load_hours)\n else\n super\n end\n end", "def compute_occupied_places\n application_letters.where(status: true).count\n end", "def calc_full_nodes_avail\n @full_nodes_available = 0\n #if @cluster_title.eql?(\"Ruby\")\n # # See line 62\n #@full_nodes_available = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"dedicated_threads = 0\") && node.include?(\"np = 20\") && node.include?(\"gpu_state=Unallocated\")}.size\n #else\n #@full_nodes_available = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"dedicated_threads = 0\") && node.include?(\"gpu_state=Unallocated\") }.size\n #end\n end", "def count_road_networks(cities:)\n result = cities\n result % 663_224_321\nend", "def pending_boom_tile_lays\n @pending_boom_tile_lays.merge(\n @pending_gray_boom_tile_lays[:boom].to_h { |h| [h, boomcity_tiles(h.tile.name)] }\n ).merge(\n @pending_gray_boom_tile_lays[:double_boom].to_h { |h| [h, [double_boomcity_tile(h.tile.name)]] }\n )\n end", "def ship_count\n count = []\n @rows.each do |row|\n count << row.count('s')\n end\n count.reduce(:+)\n end", "def battlers_number\n return @battlers_number.sum\n end", "def collecting_areas\n @open_counts = Admin::DigitizationQueueItem.open_status.group(:collecting_area).count\n end", "def nights\n checkout - checkin\n end", "def number_of_free_gigabytes\n if plan_id == 'pro'\n 100\n elsif plan_id == 'basic'\n 10\n else\n 1\n end\n end", "def test_tile_rack_with_several_tiles_should_need_some_tiles\n [:A,:B,:C].each{|x| @newTileRack.append(x)}\n assert_equal(4,@newTileRack.number_of_tiles_needed)\n end", "def moneys_total\n moneys_total = 0\n mini_map_cells.each do |cell|\n moneys_total += cell.terrain.money\n moneys_total += cell.sp_resource.money unless cell.sp_resource.blank?\n moneys_total += cell.construction.money unless cell.construction.blank?\n end\n return moneys_total\n end", "def available_units\n return 0 if status == NO_SPACE\n\n 999\n end", "def count_available(reload_variant = true)\n self.reload if reload_variant\n count_on_hand - count_pending_to_customer\n end", "def update_heights\n\t\t@height = @tile.attributes[\"height\"]\n\t\t@waterlevel = @tile.agents.length * HEIGHT_MOD \n\tend", "def total_charged\n return self.trips.sum(&:cost)\n end", "def count_tiles(type)\n count = 0\n @screen.each do |row|\n row.each do |tile_id|\n next if tile_id.nil?\n\n count += 1 if tile_id == type\n end\n end\n count\n end", "def productions_total\n productions_total = 0\n mini_map_cells.each do |cell|\n productions_total += cell.terrain.production\n productions_total += cell.sp_resource.production unless cell.sp_resource.blank?\n productions_total += cell.construction.production unless cell.construction.blank?\n end\n return productions_total\n end", "def available_cards\n (@deck.size + board.size)\n end", "def calculateAdjacent\r\n #Loops through every tile in the grid.\r\n (0..@rows-1).each do |row|\r\n (0..@columns-1).each do |col|\r\n count = getTier(col+1, row+1) + getTier(col+1, row) + getTier(col+1, row-1)\r\n count += getTier(col, row+1) + getTier(col, row-1) + getTier(col-1, row+1)\r\n count += getTier(col-1, row) + getTier(col-1, row-1)\r\n @tile[col][row].adjacent = count #Totals the tier number in the adjacent tiles.\r\n end\r\n end\r\nend", "def number_of_bettors\n if defined? @recent_goal.bets.count\n @recent_goal.bets.count\n else\n 0\n end \n end", "def cost_of_stay\n num_of_nights * 200.00\n end", "def bc_count\n \[email protected] + @initial.size + @final.size + @cyclic.size\n end", "def house_capacity\n has_reserved_seating? ? seatmap.seat_count : attributes['house_capacity']\n end", "def getNbRecompense\n return 0\n end", "def available_tables(sets_of_dishes, places_per_table)\n# dishes / seats\n return sets_of_dishes / places_per_table\nend", "def gift_cost gift_counts, costs\n black_count, white_count = gift_counts\n black_cost, white_cost, conversion_cost = costs\n \n if conversion_cost + [black_cost, white_cost].min >= [black_cost, white_cost].max \n # just buy what we need, dont do any converting\n return (black_count * black_cost) + (white_count * white_cost)\n else\n # its better to buy all cheapest and convert what we need to the other\n cost = [black_cost, white_cost].min * gift_counts.reduce(&:+)\n if black_cost < white_cost\n cost += white_count * conversion_cost\n else\n cost += black_count * conversion_cost\n end\n return cost\n end\n \nend", "def user_gold\n self.tickets.all_gold.unused.count\n end", "def offensive_row_for_ai(board)\n offensive_play = {}\n WINNING_COMBINATIONS.each { |offense| offensive_play[offense] = 0 }\n WINNING_COMBINATIONS.each do |offense|\n offense.each do |is_x|\n offensive_play[offense] += 1 if board[is_x] == COMPUTER_MARKER\n if board[is_x] == PLAYER_MARKER\n offensive_play[offense] = 0\n break\n end\n end\n end\n offensive_play\nend", "def measure map, x, y \n if map[x][y] != 'land' || x >= 6 || y >= 6 #Ensures water, counted land, and coordinates\n return 0 #off the grid aren't counted.\n end\n \n size = 1\n map[x][y] = 'counted land' #Marks the starting tile as something bedsides Land. Every tile surrounding the starting tile becomes the \"new starting tile\" as the the recursion happens.\n \n size = size + measure(map, x-1, y-1) #Each of these lines is run again and again until\n size = size + measure(map, x, y-1) #a non-land square is encountered. \n size = size + measure(map, x+1, y-1) #That's the recursive part.\n size = size + measure(map, x-1, y)\n size = size + measure(map, x+1, y)\n size = size + measure(map, x-1, y+1)\n size = size + measure(map, x, y+1)\n size = size + measure(map, x+1, y+1)\n \n size\nend", "def moneys_total\n moneys_total = 0\n mini_maps.each do |map|\n moneys_total += map.moneys_total\n end\n return moneys_total\n end", "def coin_available_after_sweep_needs\n available = {}\n\n # Make the assumption that if hidden irregulars exist in Locations\n # with hidden pavn, the hidden irregulars will be activated to sweep:\n modified_hidden_guerrilla_count = hidden_guerrilla_count\n if us_irregular_count > 0 && hidden_guerrilla_count > 0\n modified_hidden_guerrilla_count = hidden_guerrilla_count - us_irregular_count\n end\n\n if us_troop > modified_hidden_guerrilla_count && us_troop <= coin_control_excess\n available[:us_troop] = us_troop - modified_hidden_guerrilla_count\n end\n\n if us_irregular_count > 0\n if coin_control_excess - us_troop > 0\n available[:us_irregular_hidden] = us_irregular_hidden\n available[:us_irregular_activated] = us_irregular_activated\n end\n end\n available\n end", "def sitting_costs\n [cost_per_night, remote_price].compact\n end", "def count_pieces(color)\n color == \"red\" ? whites_count : reds_count\n end", "def get_allocated_cells\n\t\tallocated_cells = 0.0;\n\t\[email protected] { |i| i.each { |j| allocated_cells += 1 if j.type != Cell::BLOCKED } }\n\t\treturn (allocated_cells*Dungeon::ROOM_ALLOCATION_WEIGHT).floor\n\tend", "def collect_treasure\n @gold_coins += 1\n if @gold_coins % 10 == 0\n level_up\n end\n end", "def cards_needed\n [@size, 5].min\n end", "def calories_per_liter\n 672\n end", "def tile_size level\n\t\t\t2 ** level\n\t\tend", "def carbs_consumed\n\t\t@snack_carbs.values.reduce(0, :+)\n\tend", "def remaining_slots\n @count = 0\n self.booked_customers.each do |booked_customer|\n @count += booked_customer.number_students.to_i\n end\n return self.cap - @count\n\n end", "def living_neighbors(cell)\n count = 0\n cell.neighborhood.each { |k, v|\n count += 1 if @community[v].state == true\n }\n count\n end", "def living_neighbors(cell)\n count = 0\n cell.neighborhood.each { |k, v|\n count += 1 if @community[v].state == true\n }\n count\n end", "def available_slots\n # Doit regarder le board et renvoyer un array avec les slots restants\n slots = []\n @board.each do |k,v|\n v.each_with_index { |num,i| slots << k + (i+1).to_s if num.zero?}\n end\n slots\n end", "def total_orbit_count(orbit_map)\n count = 0\n orbit_map.each{|satellite, _|\n central_objects = orbit_count(orbit_map, satellite)\n # puts \"Satellite %s orbits %d objects\" % [satellite, central_objects]\n count += central_objects\n }\n count\nend", "def amount_of_chocolate_chips(perfect_10_recipe)\n return perfect_10_recipe[:mini_dark_chocolate_chips]\nend", "def productions_total\n productions_total = 0\n mini_maps.each do |map|\n productions_total += map.productions_total\n end\n return productions_total\n end", "def covered_strength; end", "def amount_of_ships(user, unit_id)\n \n return @attacker_fleet.ship_groups.find_by(unit_id: unit_id).number\n end", "def unit_counts\n # No raiders if apocalypse and planet is not occupied.\n return [] if apocalypse? && @planet.player_id.nil?\n\n units = {}\n max_flanks = Cfg.max_flanks\n\n raid_arg = apocalypse? ? apocalypse_raid_arg : @planet.raid_arg\n\n params = {'arg' => raid_arg}\n calc = lambda do |formula, round=true|\n begin\n value = CONFIG.safe_eval(formula, params)\n # If we went to complex numbers, that means we did something strange and\n # the result is bad.\n return 0 if value.is_a?(Complex)\n [0, round ? value.round : value].max\n rescue FloatDomainError; 0; end\n end\n\n Cfg.raiding_config(key).each do\n |type, (from_formula, to_formula, chance_formula)|\n\n units[type] = {}\n max_flanks.times { |flank| units[type][flank] = 0 }\n\n from = calc[from_formula]\n to = calc[to_formula]\n # Do NOT round chance, as it is in [0, 1] range.\n chance = [calc[chance_formula, false], 1.0].min\n\n # Add the minimum.\n from.times do\n flank = rand(max_flanks)\n units[type][flank] += 1\n end\n\n # Add additional ones.\n (to - from).times do\n if rand <= chance\n flank = rand(max_flanks)\n units[type][flank] += 1\n end\n end\n end\n\n raiders = []\n units.each do |type, flanks|\n flanks.each do |index, count|\n raiders.push [type, count, index] unless count == 0\n end\n end\n\n raiders\n end", "def found_blocks\n shares.where(:upstream_result => \"Y\").count + blocks.count\n end", "def foods_total\n foods_total = 0\n mini_map_cells.each do |cell|\n foods_total += cell.terrain.food\n foods_total += cell.sp_resource.food unless cell.sp_resource.blank?\n foods_total += cell.construction.food unless cell.construction.blank?\n end\n return foods_total\n end", "def disgems_count\n Recommendable.config.ratable_classes.inject(0) do |sum, klass|\n sum + disgemd_count_for(klass)\n end\n end", "def fast_ready_bonus\n [100, features_sum(:fast_ready)].min / 100.0\n end", "def bank_count\n return @battlers.size\n end", "def part1(grid)\n grid.conflicts.size\nend", "def total_resources\n self.balance + self.fuel_reserve\n end", "def count_layer_check_files\n %w[01 02 03].map do |number|\n folder = File.join('data', 'layer_check', \"build-#{number}\")\n puts \"CHECK #{folder}\"\n num_states = 0\n LayerPartInfoName.glob(folder).each do |layer_part_info|\n info_string = File.read(File.join(folder, layer_part_info.to_s))\n info = JSON.parse(info_string)\n num_states += info['num_states'].to_i\n end\n puts number_with_comma(num_states)\n puts num_states / (30.0 * 24 * 3600)\n num_states\n end\nend", "def test_that_full_tile_rack_doesnt_need_any_tiles\n 7.times{|num| @newTileRack.append(:A)}\n assert_equal(0,@newTileRack.number_of_tiles_needed)\n end", "def pool_acts_equip_mod\n return 0 if battler.nil? || !battler.is_a?(Game_Actor)\n battler.equips.inject(0) do |sum,e| \n mod = e.nil? ? 0 : (e.pool_acts_mod ||= 0)\n sum += mod\n end\n end", "def worth\n Chip.value_of(all_chips)\n end", "def amount_of_chocolate_chips(recipe_hash)\n \"#{recipe_hash[:mini_dark_chocolate_chips]} of mini dark chocolate chips\"\nend", "def hits_requested\n return BlacklightBrowseNearby::Engine.config.default_hits.to_i if @opts[:number].blank?\n @opts[:number].to_i\n end", "def battler_hue\n return 0\n end", "def get_allocated_cells\n allocated_cells = 0.0;\n @cells.each { |i| i.each { |j| allocated_cells += 1 if j.type != Cell::BLOCKED } }\n (allocated_cells*Dungeon::ROOM_ALLOCATION_WEIGHT).floor\n end", "def number_of_bottles\n bottles = self.line_items.inject(0) {|bottles, line_item| bottles + line_item.quantity}\n end", "def number_of_bottles\n bottles = self.line_items.inject(0) {|bottles, line_item| bottles + line_item.quantity}\n end", "def num_possible\n @possible\n end", "def test_empty_tile_rack_should_need_max_tiles\n assert_equal(7,@newTileRack.number_of_tiles_needed)\n end", "def prayer_requests_qty\n Rails.cache.fetch(\"prayer_requests-qty-#{id}\") do\n content_prayers.pending.count\n end\n end", "def output_of_heat_carriers\n fetch(:output_of_heat_carriers) do\n output_of_useable_heat + output_of_steam_hot_water\n end\n end", "def fleet\n @all_ships.each_with_index.map { |x, i| [i, x.len] }\n end", "def test_tile_rack_with_one_tile_should_need_max_minus_one_tiles\n @newTileRack.append(:A)\n assert_equal(6,@newTileRack.number_of_tiles_needed)\n end", "def hit_count()\n #This is a stub, used for indexing\n end", "def baller_count\n active.count\n end" ]
[ "0.6707476", "0.6505464", "0.6171981", "0.6090379", "0.5993909", "0.59258765", "0.5882051", "0.58278006", "0.5783641", "0.57422876", "0.57153195", "0.57030356", "0.56827545", "0.56681496", "0.56669766", "0.5665383", "0.5653407", "0.56423277", "0.55822384", "0.5565164", "0.556423", "0.5562963", "0.5562308", "0.55454856", "0.5539645", "0.55247974", "0.5522817", "0.55209273", "0.55163926", "0.54925686", "0.5472928", "0.5472247", "0.546965", "0.5467329", "0.54571706", "0.54544646", "0.54502106", "0.5445869", "0.5428283", "0.54204667", "0.5419131", "0.5419032", "0.54188794", "0.5413496", "0.5405273", "0.5393864", "0.5393605", "0.53809905", "0.53733057", "0.536431", "0.5358493", "0.53509927", "0.5345433", "0.53423357", "0.53336257", "0.53301334", "0.5326027", "0.532428", "0.5323197", "0.5322355", "0.5311269", "0.5309157", "0.5302759", "0.53025895", "0.53007793", "0.5299016", "0.52961296", "0.52961296", "0.5293716", "0.52934885", "0.5285792", "0.52739793", "0.5271196", "0.52705044", "0.52593243", "0.5257267", "0.5250999", "0.5250458", "0.5242795", "0.5238824", "0.52347183", "0.52314234", "0.5231294", "0.52278596", "0.5226993", "0.5222388", "0.5220237", "0.5213425", "0.5209331", "0.5207883", "0.5204764", "0.5204764", "0.520009", "0.5198446", "0.51939493", "0.51933277", "0.51926583", "0.51916057", "0.5191389", "0.5189408" ]
0.7152191
0
because gray tiles are limited, their counts could affect pending tile lays, so track them separately
def pending_boom_tile_lays @pending_boom_tile_lays.merge( @pending_gray_boom_tile_lays[:boom].to_h { |h| [h, boomcity_tiles(h.tile.name)] } ).merge( @pending_gray_boom_tile_lays[:double_boom].to_h { |h| [h, [double_boomcity_tile(h.tile.name)]] } ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gray_boomcity_tile_potential_count\n gray_boomcity_tile_count +\n [gray_double_boomcity_tile_count, @pending_gray_boom_tile_lays[:double_boom].size].min\n end", "def count_black_tiles_around(in_tiles, tile_x, tile_y)\n black_tile_count = 0\n MOVE.each do |dir, deltas|\n other_tile_x = tile_x + deltas[0]\n other_tile_y = tile_y + deltas[1]\n hash_key = \"#{other_tile_x}_#{other_tile_y}\"\n black_tile_count += 1 if (in_tiles[hash_key] % 2 == 1)\n end\n black_tile_count\nend", "def tiles_remaining\n @default_tiles.values.inject(0, :+)\n end", "def tiles_remaining\n return @tiles\n end", "def count_tiles(type)\n count = 0\n @screen.each do |row|\n row.each do |tile_id|\n next if tile_id.nil?\n\n count += 1 if tile_id == type\n end\n end\n count\n end", "def tiles_remaining\n # still not sure why or how this is working. TODO: may take out later\n total_num_tiles = @default_set.inject(0) { |letter, letter_quantity| letter += letter_quantity[1] }\n p \"++++TEST++++\"\n p total_num_tiles\n return total_num_tiles\n end", "def reachable_tiles\n @tiles\n end", "def water_tiles\n puts @area.select { |_, v| '~|'.include?(v) }.keys.select { |_, y| y <= @max_y }.count\n puts @area.select { |_, v| v == '~' }.keys.select { |_, y| y <= @max_y }.count\n end", "def tiles_remaining\n return @collection.length\n end", "def measure map, x, y \n if map[x][y] != 'land' || x >= 6 || y >= 6 #Ensures water, counted land, and coordinates\n return 0 #off the grid aren't counted.\n end\n \n size = 1\n map[x][y] = 'counted land' #Marks the starting tile as something bedsides Land. Every tile surrounding the starting tile becomes the \"new starting tile\" as the the recursion happens.\n \n size = size + measure(map, x-1, y-1) #Each of these lines is run again and again until\n size = size + measure(map, x, y-1) #a non-land square is encountered. \n size = size + measure(map, x+1, y-1) #That's the recursive part.\n size = size + measure(map, x-1, y)\n size = size + measure(map, x+1, y)\n size = size + measure(map, x-1, y+1)\n size = size + measure(map, x, y+1)\n size = size + measure(map, x+1, y+1)\n \n size\nend", "def continent_size world, x, y\nif world[y][x] != 'land' # => false, true, true, true, false, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true\n# Either it's water or we already counted it,\n# but either way, we don't want to count it now.\nreturn 0 # => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\nend\n# So first we count this tile...\nsize = 1 # => 1, 1, 1\nworld[y][x] = 'counted land' # => \"counted land\", \"counted land\", \"counted land\"\n# Each time the program his a tile marked 'land' it updates that tile\n# so it is no longer 'land' but 'counted land', meaning the next time the\n# program hits that tile it will no longer be equal to 'land' and therefore\n# is not double counted.\n\n# ...then we count all of the neighboring eight tiles\n# (and, of course, their neighbors by way of the recursion).\n#\n# The best way to think of this is that each time the program hits a land tile\n# it starts spiraling around that tile until it finds another land tile and\n# each time it finds another land tile it starts again from that second land tile\n# and so on and son on until it has counted all the land tiles and their neighbors\n# that joined the starting tile.\n#\nsize = size + continent_size(world, x-1, y-1) # => 1, 1, 1\nsize = size + continent_size(world, x , y-1) # => 1, 1, 1\nsize = size + continent_size(world, x+1, y-1) # => 1, 1, 1\nsize = size + continent_size(world, x-1, y ) # => 1, 1, 3\nsize = size + continent_size(world, x+1, y ) # => 1, 1, 3\nsize = size + continent_size(world, x-1, y+1) # => 1, 1, 3\nsize = size + continent_size(world, x , y+1) # => 1, 2, 3\nsize = size + continent_size(world, x+1, y+1) # => 1, 2, 3\nsize # => 1, 2, 3\nend", "def test_has_proper_number_of_tiles\n\t98.times { @pd.draw_tile } \t\n \n\tassert_equal true, @pd.empty?\n end", "def tile_size level\n\t\t\t2 ** level\n\t\tend", "def count_painted_panels\n count = 0\n @hull.each do |row|\n row.each do |panel|\n next if panel.nil?\n\n count += 1\n end\n end\n count\n end", "def check_pungs\n @tmp_count_group_by_tile.each do |tile, count|\n next if count < 3\n if block_given?\n yield(tile, count)\n else\n @tmp_count_group_by_tile[tile] -= 3\n @tmp_win_hand << Array.new(3, tile)\n end\n end\n end", "def count\n @bitmap.count\n end", "def place_mine_indicators\n @board.each_with_index do |r, row|\n r.each_with_index do |_c, col|\n unless @board[row][col].is_a_mine\n count = 0\n if row - 1 >= 0\n count += 1 if col - 1 >= 0 && @board[row - 1][col - 1].is_a_mine\n count += 1 if @board[row - 1][col].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row - 1][col + 1].is_a_mine\n end\n count += 1 if col - 1 >= 0 && @board[row][col - 1].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row][col + 1].is_a_mine\n if row + 1 < @board.size\n count += 1 if col - 1 >= 0 && @board[row + 1][col - 1].is_a_mine\n count += 1 if @board[row + 1][col].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row + 1][col + 1].is_a_mine\n end\n @board[row][col].set_value(count)\n end\n end\n end\n end", "def tile_number_generator(board)\n count_hash = {\n 0 => 0,\n 1 => 0,\n 2 => 0,\n 3 => 0,\n 4 => 0,\n 5 => 0,\n 6 => 0,\n 7 => 0,\n 8 => 0,\n 9 => 1\n }\n \n y_pos = 1\n self.height.times do\n x_pos = 0\n \n column1 = count_hash[board[y_pos-1][x_pos-1]] + count_hash[board[y_pos][x_pos-1]] + count_hash[board[y_pos+1][x_pos-1]]\n column2 = count_hash[board[y_pos-1][x_pos]] + count_hash[board[y_pos][x_pos]] + count_hash[board[y_pos+1][x_pos]]\n column3 = count_hash[board[y_pos-1][x_pos+1]] + count_hash[board[y_pos][x_pos+1]] + count_hash[board[y_pos+1][x_pos+1]]\n \n self.width.times do\n x_pos += 1\n \n column1 = column2\n column2 = column3\n column3 = count_hash[board[y_pos-1][x_pos+1]] + count_hash[board[y_pos][x_pos+1]] + count_hash[board[y_pos+1][x_pos+1]]\n if board[y_pos][x_pos] != 9\n board[y_pos][x_pos] = column1 + column2 + column3\n end\n end\n y_pos += 1\n end\n \n return board\n end", "def test_that_full_tile_rack_doesnt_need_any_tiles\n 7.times{|num| @newTileRack.append(:A)}\n assert_equal(0,@newTileRack.number_of_tiles_needed)\n end", "def draw_tiles(num)\n if num <= tiles_remaining\n our_tiles = display_all_tiles.sample(num)\n tile_removal(our_tiles)\n return our_tiles\n else\n print \"Sorry, there are only #{tiles_remaining} left.\"\n our_tiles = display_all_tiles.sample(tiles_remaining)\n tile_removal(our_tiles)\n return our_tiles\n end\n end", "def test_tile_rack_with_several_tiles_should_need_some_tiles\n [:A,:B,:C].each{|x| @newTileRack.append(x)}\n assert_equal(4,@newTileRack.number_of_tiles_needed)\n end", "def score\n self.tiles.inject(0){|sum,num| sum+=TileBag.points_for(num)}\n end", "def draw_tiles (num)\n tiles_drawn = @bag_of_tiles.sample(num)\n tiles_drawn.each do | tile |\n @bag_of_tiles.slice!(@bag_of_tiles.index(tile))\n end\n return tiles_drawn\n end", "def calculateAdjacent\r\n #Loops through every tile in the grid.\r\n (0..@rows-1).each do |row|\r\n (0..@columns-1).each do |col|\r\n count = getTier(col+1, row+1) + getTier(col+1, row) + getTier(col+1, row-1)\r\n count += getTier(col, row+1) + getTier(col, row-1) + getTier(col-1, row+1)\r\n count += getTier(col-1, row) + getTier(col-1, row-1)\r\n @tile[col][row].adjacent = count #Totals the tier number in the adjacent tiles.\r\n end\r\n end\r\nend", "def mine_count\n grid.flatten.count { |space| space.mine }\n end", "def countBoxes(backGround,pixColors,totalBoxes)\r\n \r\n rows = @image.file.rows\r\n cols = @image.file.cols\r\n \r\n # initialize working variables\r\n \r\n boxCounts = {}\r\n boxMasses = {}\r\n pixColors.each do | pixColor |\r\n boxCounts[pixColor] = {}\r\n boxMasses[pixColor] = {}\r\n @steps.each do | stepSize |\r\n totBoxes = (rows-stepSize+1) * (cols-stepSize+1)\r\n boxCounts[pixColor][stepSize] = {}\r\n boxMasses[pixColor][stepSize] = Array.new(totBoxes,0)\r\n totalBoxes[stepSize] = totBoxes\r\n end\r\n end\r\n\r\n # now figure box masses\r\n \r\n rows.times do | row |\r\n cols.times do | col |\r\n pixColor = @image.file.getCell(row,col)\r\n if (backGround == -1) or (pixColor != backGround)\r\n @steps.each do | stepSize |\r\n boxesPresent = enumerateBoxes(stepSize, row, col, rows, cols)\r\n boxesPresent.each do | boxNumber |\r\n boxMasses[pixColor][stepSize][boxNumber] += 1\r\n end\r\n end\r\n end\r\n end\r\n end\r\n \r\n # calculate boxCounts from boxMasses\r\n \r\n boxMasses.each_pair do | pixColor, byPixHash |\r\n byPixHash.each_pair do | stepSize, boxMassArray |\r\n boxMassArray.each do | boxMass |\r\n if (boxMass > 0)\r\n # boxCounts[pixColor][stepSize][boxMass] += 1 if boxMass > 0\r\n boxMassHash = boxCounts[pixColor][stepSize]\r\n if boxMassHash[boxMass]\r\n boxMassHash[boxMass] += 1\r\n else\r\n boxMassHash[boxMass] = 1\r\n end\r\n end\r\n end\r\n end\r\n end\r\n\r\n # debugging aid: dump box counts\r\n if false\r\n boxCounts.each_pair do | pixColor, byPixHash |\r\n byPixHash.each_pair do | stepSize, boxCountHash |\r\n boxCountHash.each_pair do | boxMass, boxCount |\r\n print \"boxCounts[#{pixColor}][#{stepSize}][#{boxMass}] = #{boxCount}\\n\"\r\n end\r\n end\r\n end\r\n end\r\n\r\n # return values\r\n boxCounts\r\n end", "def pixel_counter?(x, y)\n # no counter if map ID is invalid\n return false if @map_id == 0\n # get pixel movement rate and initialize result\n pix, result = $BlizzABS.pixel, false\n # iterate through all layers and check each modified tile (pixel movement)\n BlizzABS::Cache::MapLayers.each {|i| (0...pix).each {|j| (0...pix).each {|k|\n # if tile is not valid ID\n if data[(x+j)/pix, (y+k)/pix, i] == nil\n # no counter\n return false\n # if counter bit is set\n elsif @passages[data[(x+j)/pix, (y+k)/pix, i]] & 0x80 == 0x80\n # counter\n result = true\n else\n # no counter\n return false\n end}}\n # return the result\n return result}\n # no counter\n return false\n end", "def refresh_tiles\n return if empty?\n xdiff = @array[0].real_x.round / -32 - 1\n ydiff = @array[0].real_y.round / -32 - 1\n if ydiff > 0\n ydiff.times do\n move_up do |sprite|\n sprite.mapy += YSIZE\n sprite.real_y += 32 * YSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n elsif ydiff < 0\n ydiff.abs.times do\n move_down do |sprite|\n sprite.mapy -= YSIZE\n sprite.real_y -= 32 * YSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n end\n if xdiff > 0\n xdiff.times do\n move_left do |sprite|\n sprite.mapx += XSIZE\n sprite.real_x += 32 * XSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n elsif xdiff < 0\n xdiff.abs.times do\n move_right do |sprite|\n sprite.mapx -= XSIZE\n sprite.real_x -= 32 * XSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n temp_bitmaps = nil\n end\n end", "def width\n TILE_WIDTH\n end", "def test_tile_rack_with_one_tile_should_need_max_minus_one_tiles\n @newTileRack.append(:A)\n assert_equal(6,@newTileRack.number_of_tiles_needed)\n end", "def handle_gray_booms!\n return if @pending_gray_boom_tile_lays.values.flatten.empty?\n\n # clear gray double boom city actions, no tiles remain\n if (num_double_boom_tiles = gray_double_boomcity_tile_count).zero?\n @pending_gray_boom_tile_lays[:double_boom].clear\n\n # there are enough gray double boom city tiles, automatically lay them\n elsif num_double_boom_tiles >= @pending_gray_boom_tile_lays[:double_boom].size\n @pending_gray_boom_tile_lays[:double_boom].each do |hex|\n boomcity_to_double_boomcity!(hex, gray_checked: true)\n end\n end\n\n # clear pending gray boom city tile lays, no tiles remain\n if gray_boomcity_tile_potential_count.zero?\n @pending_gray_boom_tile_lays[:boom].clear\n\n # there are enough gray boom city tiles, automatically lay them\n elsif gray_boomcity_tile_count >= @pending_gray_boom_tile_lays[:boom].size\n @pending_gray_boom_tile_lays[:boom].each do |hex|\n boomtown_to_boomcity!(hex, gray_checked: true)\n end\n end\n end", "def flat_counts\n count_hash = Hash.new { |h,k| h[k] = 0 }\n\n @board.each_with_object(count_hash) do |row, counts|\n row.each do |cell|\n counts[:white] += 1 if cell.last == 'w'\n counts[:black] += 1 if cell.last == 'b'\n end\n end\n end", "def layers\n pixdem = [image.width, image.height].max\n ((Math.log(pixdem) / Math.log(2)) - (Math.log(96) / Math.log(2))).ceil + 1\n end", "def load_cutters tiles\r\n i = 0\r\n height = tiles.length\r\n width = tiles[i].length\r\n cutters = Array.new()\r\n\r\n while i < height\r\n j=0\r\n while j < width\r\n if(tiles[i][j]==2)\r\n tiles[i][j]=0\r\n cutters << Cutter.new(j*20,i*20)\r\n end\r\n j+=1\r\n end\r\n i+=1\r\n end\r\n\r\n puts \"total cutters : \" + cutters.length.to_s\r\n cutters\r\nend", "def test_board_should_have_9_tiles\n assert_equal(9, @board.number_of_tiles)\n end", "def test_empty_tile_rack_should_need_max_tiles\n assert_equal(7,@newTileRack.number_of_tiles_needed)\n end", "def bush_depth\n # タイルの場合、または最前面に表示フラグが ON の場合\n if @tile_id > 0 or @always_on_top\n return 0\n end\n # return 12 if @in_swamp #> Ajout des marais\n if @jump_count == 0 and $game_map.bush?(@x, @y)\n return 12\n else\n return 0\n end\n end", "def count_traps(x, y)\n total = 0\n total += 1 if within_boundaries?(x-1,y-1) && @board[x-1][y-1].value == \"O\"\n total += 1 if within_boundaries?(x-1,y) && @board[x-1][y].value == \"O\"\n total += 1 if within_boundaries?(x-1,y+1) && @board[x-1][y+1].value == \"O\"\n total += 1 if within_boundaries?(x,y+1) && @board[x][y+1].value == \"O\"\n total += 1 if within_boundaries?(x+1,y+1) && @board[x+1][y+1].value == \"O\"\n total += 1 if within_boundaries?(x+1,y) && @board[x+1][y].value == \"O\"\n total += 1 if within_boundaries?(x+1,y-1) && @board[x+1][y-1].value == \"O\"\n total += 1 if within_boundaries?(x,y-1) && @board[x][y-1].value == \"O\"\n total\n end", "def counter?(x, y)\r\n if @map_id != 0\r\n for i in [2, 1, 0]\r\n tile_id = data[x, y, i]\r\n if tile_id == nil\r\n return false\r\n elsif @passages[tile_id] & 0x80 == 0x80\r\n return true\r\n end\r\n end\r\n end\r\n return false\r\n end", "def test_has_proper_tile_distribution\r\n dist = {:A => 0,\r\n :B => 0,\r\n :C => 0,\r\n :D => 0,\r\n :E => 0,\r\n :F => 0,\r\n :G => 0,\r\n :H => 0,\r\n :I => 0,\r\n :J => 0,\r\n :K => 0,\r\n :L => 0,\r\n :M => 0,\r\n :N => 0,\r\n :O => 0,\r\n :P => 0,\r\n :Q => 0,\r\n :R => 0,\r\n :S => 0,\r\n :T => 0,\r\n :U => 0,\r\n :V => 0,\r\n :W => 0,\r\n :X => 0,\r\n :Y => 0,\r\n :Z => 0}\r\n\r\n bag = TileBag.new\r\n 98.times {\r\n tile = bag.draw_tile\r\n dist[tile] += 1\r\n }\r\n\r\n assert_equal 9, dist[:A]\r\n assert_equal 2, dist[:B]\r\n assert_equal 2, dist[:C]\r\n assert_equal 4, dist[:D]\r\n assert_equal 12, dist[:E]\r\n assert_equal 2, dist[:F]\r\n assert_equal 3, dist[:G]\r\n assert_equal 2, dist[:H]\r\n assert_equal 9, dist[:I]\r\n assert_equal 1, dist[:J]\r\n assert_equal 1, dist[:K]\r\n assert_equal 4, dist[:L]\r\n assert_equal 2, dist[:M]\r\n assert_equal 6, dist[:N]\r\n assert_equal 8, dist[:O]\r\n assert_equal 2, dist[:P]\r\n assert_equal 1, dist[:Q]\r\n assert_equal 6, dist[:R]\r\n assert_equal 4, dist[:S]\r\n assert_equal 6, dist[:T]\r\n assert_equal 4, dist[:U]\r\n assert_equal 2, dist[:V]\r\n assert_equal 2, dist[:W]\r\n assert_equal 1, dist[:X]\r\n assert_equal 2, dist[:Y]\r\n assert_equal 1, dist[:Z]\r\n\r\n end", "def assign_mines_touching\n @tiles.flatten.each do |tile|\n neighbors = get_neighbors(tile)\n tile.mines_touching = count_mines_from_neighbors(neighbors)\n end\n end", "def game_over \n # all the grid's cells are full and different numbers \n end", "def verify_tiles\n end", "def initialize_tiles\n return if @ready\n\n cur_y, cur_x = @progress.divmod @map.logical_width\n puts \"Game#initialize_tiles: #{@progress}/#{@finished_at} = #{(initialization_percent * 100).floor}%\"\n\n start_t = Time.now\n\n cur_y.upto(@map.logical_height - 1) do |y|\n cur_x.upto(@map.logical_width - 1) do |x|\n cur_tile = @tileset.sprite_for(@tileset.random_floor)\n\n # Let's give them a little color\n cur_tile.merge!(\n {\n r: rand(35) + 220 * (x / @map.logical_width),\n g: rand(35) + 220 * (y / @map.logical_height),\n b: rand(35) + 220 * (x / @map.logical_width) * (y / @map.logical_height)\n }\n )\n\n @map.add_tile(x, y, cur_tile)\n @progress += 1\n\n # Allow this to execute for 8ms (half a tick at 60fps).\n return if (Time.now - start_t) >= 0.008 # rubocop:disable Lint/NonLocalExitFromIterator\n end\n cur_x = 0\n end\n finish_initialization\n end", "def generate_possible_areas_for_all_numbered_tiles\n t = Time.now\n puts 'Start: Generate possible areas for all numbered tiles'\n all_possible_areas = {}\n\n # @b_nl.each_with_value do |value, i, j|\n # if value != 0 then\n # restricted_board = create_restricted_board [i,j]\n # t_area = Time.now\n # next if [i,j] == [7,1]\n # puts \"Summoning for [#{i},#{j}]\"\n # a = summon_areas([i,j], value, restricted_board)\n\n # puts \"Summoned area for [#{i},#{j}], time: \" + (Time.now - t_area).to_i.to_s + 's size ' + a.count.to_s\n # all_possible_areas[\"#{i}-#{j}\"] = a\n # end\n (0..@row_count-1).to_a.each do |i|\n (0..@col_count-1).to_a.each do |j|\n # Summon for each numbered tile(non zero)\n if @b_nl[i,j] != 0 then\n restricted_board = create_restricted_board [i,j]\n t_area = Time.now\n next if [i,j] == [7,1]\n puts \"Summoning for [#{i},#{j}]\"\n a = summon_areas([i,j],@b_nl[i,j], restricted_board)\n\n puts \"Summoned area for [#{i},#{j}], time: \" + (Time.now - t_area).to_i.to_s + 's size ' + a.count.to_s\n all_possible_areas[\"#{i}-#{j}\"] = a\n end\n end\n end\n puts 'Finish: Generate possible areas for all numbered tiles, time: ' + (Time.now - t).to_i.to_s + 'seconds'\n all_possible_areas[\"7-1\"] = [[[]]]\n all_possible_areas\n end", "def countClouds(skyMap)\n marker = 0\n \n row = 0\n queue = []\n while row < skyMap.size\n col = 0\n \n while col < skyMap[row].size\n \n if skyMap[row][col] && skyMap[row][col] == \"1\"\n marker += 1\n skyMap[row][col] = marker\n queue << [row, col] \n end\n \n until queue.empty?\n coord = queue.shift\n \n left_child = [coord[0], coord[1] - 1] if coord[1] - 1 >= 0\n right_child = [coord[0], coord[1] + 1] if coord[1] + 1 < skyMap[row].size\n top_child = [coord[0] - 1, coord[1]] if coord[0] - 1 >= 0\n bottom_child = [coord[0] + 1, coord[1]] if coord[0] + 1 < skyMap.size\n \n if left_child && skyMap[left_child[0]][left_child[1]] == \"1\"\n queue << left_child\n skyMap[left_child[0]][left_child[1]] = marker\n end\n if right_child && skyMap[right_child[0]][right_child[1]] == \"1\"\n queue << right_child \n skyMap[right_child[0]][right_child[1]] = marker\n end\n \n if top_child && skyMap[top_child[0]][top_child[1]] == \"1\"\n queue << top_child \n skyMap[top_child[0]][top_child[1]] = marker\n end\n \n if bottom_child && skyMap[bottom_child[0]][bottom_child[1]] == \"1\"\n queue << bottom_child \n skyMap[bottom_child[0]][bottom_child[1]] = marker\n end\n end\n col += 1\n end\n row += 1\n end\n \n marker\nend", "def test_neighbour_count\n # Empty\n @game.state=[[0,0,0],[0,0,0],[0,0,0]]\n assert_equal 0,@game.neighbour_count(0,0)\n assert_equal 0,@game.neighbour_count(1,1)\n\n # One cell, check all neighbours, check proper edge wrapping\n @game.state=[[0,0,0],[0,1,0],[0,0,0]]\n assert_equal 1,@game.neighbour_count(0,2),'0,2'\n assert_equal 1,@game.neighbour_count(0,0),'0,0'\n assert_equal 1,@game.neighbour_count(0,1),'0,1'\n assert_equal 1,@game.neighbour_count(1,0),'1,0'\n assert_equal 0,@game.neighbour_count(1,1),'1,1' # Don't count self\n assert_equal 1,@game.neighbour_count(1,2),'1,2'\n assert_equal 1,@game.neighbour_count(2,0),'2,0'\n assert_equal 1,@game.neighbour_count(2,1),'2,1'\n assert_equal 1,@game.neighbour_count(2,2),'2,2'\n\n # Eight cells, check all neighbours, check proper edge wrapping\n @game.state=[[1,1,1],[1,0,1],[1,1,1]]\n assert_equal 7,@game.neighbour_count(0,2),'0,2'\n assert_equal 7,@game.neighbour_count(0,0),'0,0'\n assert_equal 7,@game.neighbour_count(0,1),'0,1'\n assert_equal 7,@game.neighbour_count(1,0),'1,0'\n assert_equal 8,@game.neighbour_count(1,1),'1,1' # Only cell with 8\n assert_equal 7,@game.neighbour_count(1,2),'1,2'\n assert_equal 7,@game.neighbour_count(2,0),'2,0'\n assert_equal 7,@game.neighbour_count(2,1),'2,1'\n assert_equal 7,@game.neighbour_count(2,2),'2,2'\n end", "def tiles\n @tiles\n end", "def draw_tiles(num)\n\n # puts \"Length of default_tiles: \" + @tile_bag.length.to_s\n # print @tile_bag\n #\n # puts\n if num > 7\n raise ArgumentError\n end\n\n letters_picked = @tile_bag.sample(num)\n\n letters_picked.each do |tile|\n @tile_bag.delete_at(@tile_bag.index(tile))\n end\n\n # print \"Letters picked: \" + letters_picked.to_s + \"\\n\"\n #\n # puts \"NEW Length of default_tiles: \" + @tile_bag.length.to_s\n # print @tile_bag\n #\n # puts\n\n return letters_picked\n\n end", "def draw_tiles(num)\n player_hand = []\n # array will return tiles to player. Needs much refactoring.\n return nil if num > tiles_remaining\n #to account for test, returns nil if more tiles are drawn than tiles remain.\n while player_hand.length != num\n new_tile = rand(@default_set.size)\n starting_hand = 0\n\n @default_set.each do |letter, letter_quantity|\n #Need to continue working on, this is becoming harder to read. TODO: REFACTOR!\n # if the amount of tiles drawn(starting at 0) is the same as the amount of new tiles drawn,\n if starting_hand == new_tile && letter_quantity != 0\n #if the condition above, and the total tiles isnt 0, add the new tile (letter), to all of the tiles (player_hand array)\n # if letter_quantity != 0\n player_hand << letter\n #Then subtract the letter from the tilebag, reducing the total amount of tiles by 1, and reducing the letter by one specifically from the letters.\n @default_set[letter] = letter_quantity - 1\n else\n new_tile = rand(@default_set.size)\n \n end\n #increases the amount of tiles had by player plus one, each time a tile is drawn\n starting_hand += 1\n end\n end\n #returns array of all tiles to player\n return player_hand\n end", "def get_tile_type(x, y)\n :tile\n end", "def visible_tiles\n frame_x = (((@width - Config::TileWidth) / Config::TileWidth) ).to_i\n frame_y = (((@height - Config::TileHeight) / Config::TileHeight) ).to_i\n \n \n start_x = player.location.x - (frame_x / 2).to_i\n start_y = player.location.y - (frame_y / 2).to_i\n \n if start_x < 0\n start_x = 0\n end\n if start_y < 0\n start_y = 0\n end\n \n tiles = Array.new\n \n frame_x.times do |i|\n frame_y.times do |j|\n if (start_x + i < game.map.width ) && (start_y + j < game.map.height )\n # puts(\"start_x is #{start_x} and start_y is #{start_y} and i is #{i} and j is #{j}\")\n tiles << game.map.locations[start_x + i, start_y + j]\n end\n end\n end\n \n tiles\n \n end", "def initialize\n @tiles = []\n 1.upto(15) { |i| @tiles[i] = Array.new }\n end", "def draw_map game_map\r\n tiles = game_map.tiles # 2d array of the tiles set!\r\n wooden_plank_image = game_map.wooden_plank # image of the wooden plank \r\n i = 0\r\n j = 0\r\n unit_width = 20\r\n unit_height = 20\r\n\r\n # drawing the background image of the game map\r\n #game_map.background.draw(0,0,0) # 0: for x position, 0: for y position, 0: for ZOrder\r\n\r\n height = tiles.length\r\n width = tiles[0].length\r\n\r\n while i < height\r\n j = 0\r\n while j < width\r\n if(tiles[i][j]==1 || tiles[i][j]==3)\r\n x = j * unit_width\r\n y = i * unit_height\r\n draw_plank(x, y, wooden_plank_image)\r\n j+=4 # increment the value of the j by 4 to skip the next 4 blocks\r\n end\r\n j+=1\r\n end\r\n i+=1\r\n end\r\n\r\nend", "def layered_tiles(x, y)\n newTilePoint = map_tile_adjust_xy(x, y)\n [2, 1, 0].collect {|z| tile_id(newTilePoint.x, newTilePoint.y, z) }\n end", "def actuMap()\n 0.upto(@map.rows-1) do |x|\n 0.upto(@map.cols-1) do |y|\n\n if (@map.accessAt(x,y).value == 1)\n\n if @map.accessAt(x,y).color != nil\n if (@map.accessAt(x,y).color == @nbHypo + 1)\n @timePress[x][y] = 1\n @map.accessAt(x,y).color = @nbHypo\n end\n changeImage(@buttonTab[x][y],@tabCase[@map.accessAt(x,y).color])\n else\n changeImage(@buttonTab[x][y],\"../images/cases/blanc.png\" )\n @timePress[x][y] = 0\n end\n elsif @map.accessAt(x,y).value == 2\n changeImage(@buttonTab[x][y],\"../images/cases/croix.png\" )\n @timePress[x][y] = 0\n\n else\n ajoutLimitation(x,y)\n\n end\n\n end\n\n end\n end", "def sub_tile_index(sub_face_left)\n\t\tif sub_face_left\n\t\t\t0\n\t\telse\n\t\t\t1\n\t\tend\n\tend", "def init_tiles\n # Determine how many frames of animation this autotile has\n for i in 0..6\n bm = @autotiles[i]\n if bm.nil?\n @total_frames = 1\n elsif bm.height > 32\n @total_frames[i] = bm.width / 256\n else\n @total_frames[i] = bm.width / 32\n end\n @current_frame[i] = 0\n end\n # Turn on flag that the tilemap sprites have been initialized\n @tilemap_drawn = true\n \n @animating_tiles.clear\n # Create a sprite and viewport to use for each priority level.\n (0...((SCREEN[0]/32+2) * (SCREEN[1]/32+2))*3).each{|i|\n @tile_sprites[i/3] = [] if @tile_sprites[i/3].nil?\n @tile_sprites[i/3][i%3] = Sprite.new(@viewport) unless @tile_sprites[i/3][i%3].is_a?(Sprite)\n # Rename to something shorter and easier to work with for below\n tile = @tile_sprites[i/3][i%3]\n # Assign tile's respective ID value\n tile.tile_sprite_id = i\n # Draw sprite at index location (ex. ID 0 should always be the top-left sprite)\n tile.x = (i % ((SCREEN[0]/32+2)*3) / 3 * 32) - 32 + (@ox % 32)\n tile.y = (i / ((SCREEN[0]/32+2)*3) * 32) - 32 + (@oy % 32)\n\n map_x, map_y = (tile.x+@ox)/32, (tile.y+@oy)/32\n @corner_tile_loc = [map_x, map_y] if i == 0\n # If the tile happens to be drawn along the outside borders of the map\n if map_x < 0 || map_x >= $game_map.width || map_y < 0 || map_y >= $game_map.height\n tile.z = 0\n tile.bitmap = RPG::Cache.picture('')\n tile.src_rect.set(0,0,0,0)\n else # Tile is actually on the map\n tile_id = @map_data[map_x,map_y,i%3]\n if @priorities[tile_id] == 0\n tile.z = 0\n else\n tile.z = tile.y + @priorities[tile_id] * 32 + 32\n end\n # No tile exists here\n if tile_id == 0\n tile.bitmap = RPG::Cache.picture('')#@tileset\n tile.src_rect.set(0,0,0,0)\n elsif tile_id >= 384 # non-autotile\n tile.bitmap = @tileset\n tile.src_rect.set(((tile_id - 384) % 8)*32,((tile_id - 384) / 8)*32, 32, 32)\n else # autotile\n tile.bitmap = @autotiles[tile_id/48-1]\n tile.src_rect.set(((tile_id % 48) % 8)*32,((tile_id % 48) / 8)*32, 32, 32)\n @animating_tiles[i] = tile if tile.bitmap.width > 256\n end\n end\n }\n # Sprite ID located at top left corner (ranges from 0..map_width * map_height\n @corner_index = 0\n end", "def get_tile_color(x, y)\n 0xffffffff\n end", "def _minimap_autotile\n b = Bitmap.new(24, 32)\n c1 = Color.new(191, 191, 191)\n c2 = Color.new(255, 255, 255)\n b.fill_rect(2, 0, 4, 1, c2)\n b.set_pixel(1, 1, c2)\n b.fill_rect(2, 1, 4, 6, c1)\n b.set_pixel(6, 1, c2)\n b.fill_rect(0, 2, 1, 4, c2)\n b.fill_rect(1, 2, 1, 4, c1)\n b.fill_rect(6, 2, 1, 4, c1)\n b.fill_rect(7, 2, 1, 4, c2)\n b.set_pixel(1, 6, c2)\n b.set_pixel(6, 6, c2)\n b.fill_rect(2, 7, 4, 1, c2)\n b.fill_rect(7, 8, 10, 1, c2)\n b.set_pixel(6, 9, c2)\n b.fill_rect(7, 9, 10, 22, c1)\n b.set_pixel(17, 9, c2)\n b.set_pixel(5, 10, c2)\n b.fill_rect(6, 10, 1, 20, c1)\n b.fill_rect(17, 10, 1, 20, c1)\n b.set_pixel(18, 10, c2)\n b.set_pixel(4, 11, c2)\n b.fill_rect(5, 11, 1, 18, c1)\n b.fill_rect(18, 11, 1, 18, c1)\n b.set_pixel(19, 11, c2)\n b.set_pixel(3, 12, c2)\n b.fill_rect(4, 12, 1, 16, c1)\n b.fill_rect(19, 12, 1, 16, c1)\n b.set_pixel(20, 12, c2)\n b.set_pixel(2, 13, c2)\n b.fill_rect(3, 13, 1, 14, c1)\n b.fill_rect(20, 13, 1, 14, c1)\n b.set_pixel(21, 13, c2)\n b.set_pixel(1, 14, c2)\n b.fill_rect(2, 14, 1, 12, c1)\n b.fill_rect(21, 14, 1, 12, c1)\n b.set_pixel(22, 14, c2)\n b.fill_rect(0, 15, 1, 10, c2)\n b.fill_rect(1, 15, 1, 10, c1)\n b.fill_rect(22, 15, 1, 10, c1)\n b.fill_rect(23, 15, 1, 10, c2)\n b.set_pixel(1, 25, c2)\n b.set_pixel(22, 25, c2)\n b.set_pixel(2, 26, c2)\n b.set_pixel(21, 26, c2)\n b.set_pixel(3, 27, c2)\n b.set_pixel(20, 27, c2)\n b.set_pixel(4, 28, c2)\n b.set_pixel(19, 28, c2)\n b.set_pixel(5, 29, c2)\n b.set_pixel(18, 29, c2)\n b.set_pixel(6, 30, c2)\n b.set_pixel(17, 30, c2)\n b.fill_rect(7, 31, 10, 1, c2)\n return b\n end", "def draw_tiles(tile_bag)\n until tiles.length == 7\n tiles.concat(tile_bag.draw_tiles(1)) #because draw_tiles returns an array\n\n end\n end", "def slow_dance(target, tiles_array)\r\n count = 0 \r\n tiles_array.each do |ele|\r\n if ele == target\r\n return count\r\n else\r\n count +=1\r\n end\r\n end\r\nend", "def test_elementsNumber\n temp = []\n for e in @elements\n temp.push(e)\n end\n while temp.size > 3\n [@window, @sprite, @bitmap].each{|container|\n uc = UCGraph.new(container, 100 + 200*(temp.size%3.to_i), 180 + 120*(temp.size%2.to_i), 50, temp, nil, 100, -100, Font.normal_font,\n Color.hp_gauge_color1, Color.hp_gauge_color2,\n Color.mp_gauge_color1, Color.mp_gauge_color2, nil,\n 1, Color.normal_color)\n uc.draw()\n }\n temp.delete_at(temp.size-1)\n end\n return true\n end", "def update_next_state\n # Maybe if I do this it won't query for this game's tiles every time? ¯\\_(ツ)_/¯\n tiles = self.tiles \n players = self.players \n voids = tiles.where(\"height < 1\")\n\n # Pick random tiles to raise\n raiseTiles = voids.sample((voids.length/2).ceil)\n dropCounter = (players.length/2).ceil\n dropTiles = []\n\n # Drop tiles players were on\n players.each do |player|\n dropTiles << player.tile\n end \n\n # Pick random tiles to drop\n while dropCounter > 0\n randTile = tiles.sample\n\n if (!dropTiles.include?(randTile) && randTile.height > 0)\n dropTiles << randTile \n dropCounter -= 1\n end\n end\n\n tiles.each do |tile| \n if (dropTiles.include?(tile))\n tile.update(height: tile.height-1)\n elsif (raiseTiles.include?(tile))\n tile.update(height: [2, 1, 1, 1].sample)\n end\n end\n end", "def draw_tiles(num)\n random_tiles = @tiles.sample(num)\n random_tiles.each do |letter|\n @tiles.slice!(@tiles.index(letter))\n end\n return random_tiles\n end", "def convert_tiles_to_numbers(cells)\n tiles_info = []\n cells.each do |cell|\n tiles_info << convert_tile_to_number({'row' => cell[0], 'column' => cell[1], 'current_color' => cell[2]})\n end\n\n tiles_info\n end", "def generateBoard(row, col, num_mines)\n# Step 1 create board\n board = Array.new(row) { Array.new(col) {-1}}\n# Step 2 place random mines on board\n until num_mines < 1\n temp_x = rand(row)\n temp_y = rand(col)\n \n if board[temp_x][temp_y] != \"*\"\n board[temp_x][temp_y] = \"*\" \n num_mines -= 1 \n end\n end\n \n# Step 3 Iterate each tile skipping mines\n board.each_index do |x|\n board.each_index do |y|\n next if board[x][y] == \"*\"\n count = 0\n \n # Step 3a\n # check within bounds and count mines\n min_x = x - 1\n max_x = x + 1\n min_y = y - 1\n max_y = y + 1\n \n (min_x..max_x).each do |x|\n (min_y..max_y).each do |y|\n if (x >= 0 && x < row) && (y >= 0 && y < col)\n count += 1 if board[x][y] == \"*\"\n end\n end\n end\n \n board[x][y] = count\n end\n end\n \n # return board\n board\nend", "def show_ranges(data)\n if data\n data.each{|tile| @tiletype_table[tile.x, tile.y] = 1}\n else\n @tiletype_table = Array2D.new($game_map.width, $game_map.height, 0)\n end\n end", "def setup_region_tile_mapping\n @region_tile_mapping = {}\n (0..63).each {|i| @region_tile_mapping[i] = []}\n for x in 0..data.xsize\n for y in 0..data.ysize\n @region_tile_mapping[region_id(x, y)] << [x,y]\n end\n end\n end", "def find_lonely_pixel(picture)\n height = picture.length\n width = picture[0].length\n lonely_counter = 0\n row = {}\n column = {}\n i = 0\n j = 0\n \n while i < height\n while j < width\n if picture[i][j] == \"B\"\n column[i] ? column[i] += 1 : column[i] = 1\n row[j] ? row[j] += 1 : row[j] = 1\n end\n j += 1\n end\n j = 0\n i += 1\n end\n \n i = 0\n j = 0\n\n while i < height\n while j < width\n lonely_counter += 1 if picture[i][j] == \"B\" && row[j] == 1 && column[i] == 1\n j += 1\n end\n j = 0\n i += 1\n end\n \n lonely_counter\nend", "def levels_for(max_pixel_length)\n return 0 if max_pixel_length < 192\n max_tiles = (max_pixel_length.to_f / 96)\n log2(max_tiles).floor\n end", "def split_tile_set_into_tiles\n number_of_tiles = @tile_set[0].columns/32\n\n number_of_tiles.times do |i|\n image = @tile_set[0].crop((i*32), 0, 32, 32)\n image.write(\"media/tmp/tile#{i}.png\")\n end\n end", "def game_started?\n [email protected]? # count_tiles(WALL) >= 45 + 23 + 23\n end", "def generate_tile()\n @i = do_generate_tile(@i)\n end", "def tile_removal(array_of_tiles)\n array_of_tiles.each do |letter|\n if @default_tiles.keys.include?(letter)\n @default_tiles[letter] -= 1\n end\n @default_tiles.delete_if {|key, value| value == 0 }\n end\n end", "def count_human_marker(squares)\n squares.map(&:marker).count(TTTPlay::HUMAN_MARKER)\n end", "def area_span_for_numbered_tile tile\n area_span = create_general_area_span_for_numbered @b_nl[tile[0],tile[1]]\n area_span.map!{|x,y| [(x+tile[0]), (y+tile[1])] }\n area_span.reject!{|x,y| x < 0 || y < 0 || x > (@row_count-1) || y > (@col_count-1)}\n area_span\n end", "def increment_swim_tile_index\n\t\tanimation_frames = 2\n\n\t\tif face_left?\n\t\t\tpost_adj = 1\n\t\t\t@tile_idx = (@tile_idx % animation_frames) + post_adj\n\t\telse\n\t\t\tpost_adj = 4\n\t\t\tpre_adj = post_adj - 1 \n\t\t\t@tile_idx = ((@tile_idx - pre_adj) % animation_frames) + post_adj\n\t\tend\n\tend", "def compute_down_cache\n collection = Array.new(@row_ct) { Array.new(@col_ct) { 0 }}\n c_idx = 0\n while (c_idx < @col_ct) do\n r_idx = 0 # LESSON: whenever doing these nested loops, make sure to double check that values get properly reset...\n counter = 0\n while (r_idx < @row_ct) do\n val = @grid[r_idx][c_idx]\n if val == 1\n counter += 1\n else\n counter = 0\n end\n collection[r_idx][c_idx] = counter\n r_idx += 1\n end\n c_idx += 1\n end\n return collection\n end", "def turn_count(board)\n\n\toccupied_spaces = 0\n\n\tcounter = 0\n\twhile counter < board.size\n\t if position_taken?(board, counter)\n\t\t occupied_spaces += 1\t\t \nend \ncounter += 1\nend\noccupied_spaces\nend", "def height\n TILE_BASE_HEIGHT\n end", "def number_cells\n n = 1\n for row in 0...height\n for col in 0...width\n cell = self[row, col]\n west, north, east, south = DIRS.map{|dx, dy| self[row + dx, col + dy] and self[row + dx, col + dy].empty }\n if cell.empty and ((!west and east) or (!north and south))\n cell.number = n\n n += 1\n end\n end\n end\n end", "def count_evaluate(player) # true for white player, false for black\n if player\n RState.hamming(@white_positions) - RState.hamming(@black_positions)\n else\n RState.hamming(@black_positions) - RState.hamming(@white_positions)\n end\n end", "def pixels; end", "def next_tile_img\n next_tile_img = @current_tile_indx + 1\n case @current_move\n when Direction::Up\n next_tile_img = 9 if next_tile_img > 11\n when Direction::Down\n next_tile_img = 0 if next_tile_img > 2\n when Direction::Left\n next_tile_img = 3 if next_tile_img > 5\n when Direction::Right\n next_tile_img = 6 if next_tile_img > 8\n end\n @current_tile_indx = next_tile_img\n end", "def green_bin_space\n green_bin_space = 0\n @bins.each do |bin|\n if bin.type == 'Green'\n green_bin_space = bin.bin_level.to_i + green_bin_space\n end \n end\n green_bin_space\n end", "def estimate_layer_counts(board_size, max_exponent)\n num_cells = board_size**2\n i_max = max_exponent - 2\n max_sum = num_cells * 2**i_max\n table = count_compositions(max_sum, num_cells, 0, i_max)\n table.map.with_index do |row, index|\n sum = (index + 1) * 2\n counts = row.map.with_index do |count_k, i|\n k = i + 1\n count_k * choose(num_cells, k)\n end\n [sum, counts.sum]\n end\nend", "def count_neighbors(space, x_in, y_in, z_in, w_in, x_size, y_size, z_size, w_size)\n# count the number of active neighbors to (x, y, z, w)\ncount = 0\n[w_in-1, w_in, w_in+1].each do |w|\n\t[z_in-1, z_in, z_in+1].each do |z|\n\t\t[y_in-1, y_in, y_in+1].each do |y|\n\t\t\t[x_in-1, x_in, x_in+1].each do |x|\n\t\t\t\tif x==x_in and y==y_in and z==z_in and w==w_in\n\t\t\t\t\t# we do not consider ourself\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif x>=0 and x<x_size and y>=0 and y<y_size and z>=0 and z<z_size and w>=0 and w<w_size and space[x][y][z][w] == '#'\n\t\t\t\t\tcount+=1\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend\nreturn count\n#\nend", "def create_tilemap\n @tilemap = Tilemap.new(@viewport1)\n @tilemap2 = Tilemap.new(@viewport4)\n @tilemap.map_data = $game_map.data.clone\n @tilemap2.map_data = $game_map.data.clone\n result = []\n for i in [email protected]_data.xsize\n for j in [email protected]_data.ysize\n for k in [email protected]_data.zsize\n if ($game_map.region_id(i,j) - @etage) <= 1\n @tilemap2.map_data[i,j,k] = 0\n else\n unless Etage::MAP.include?($game_map.map_id)\n @tilemap2.map_data[i,j,k] = 0\n end\n end\n end\n end\n end\n load_tileset\n end", "def hole_count\n holes.count\n end", "def analyze_moves(tiles)\n horis = analyze_horis(tiles)\n vert = analyze_vert(tiles)\n if horis > vert\n puts \"1 --> #{horis}, #{vert}\"\n [:arrow_right, :left].sample\n elsif horis < vert\n puts \"2 --> #{horis}, #{vert}\"\n [:arrow_down, :arrow_up].sample\n elsif (horis == vert) && (vert != 0)\n puts \"3 --> #{horis}, #{vert}\"\n [:arrow_down, :arrow_up].sample\n else\n sample = [:arrow_left, :arrow_up, :arrow_right, :arrow_down].sample\n puts \"sample --> #{sample}\"\n sample\n end\n end", "def tiles\n @shape.values.map { |v| v.values }.flatten.select {|x| x != :empty}\n end", "def tiles\n return @tiles\n end", "def tiles\n return @tiles\n end", "def painting_count\n self.paintings.length\n end", "def count\n @map.count\n end", "def rev_count; @rev_map.count; end", "def getAreas\n self.removeInfinites\n totals = Hash.new(0)\n self.dims[0].times do |i|\n self.dims[1].times do |j|\n totals[@grid[i][j]] += 1\n end\n end\n totals[-1] = 0\n totals\n end", "def size \n\n\t\t# Set the basic metrics\n\t\tcase @board_size\n\t\twhen :small \t\t\t\t# A 20x20 grid\n\t\t\t@width = 30\n\t\t\t@height = 20\n\t\t\t@dragon_count = 50 * @board_level\n\t\t\t@cell_size = 30\n\t\t\t@cover_png = 'sprites/cover_30.png'\n\t\t\t@dragon_png = 'sprites/dragon_30.png'\n\t\t\t@gold_png = 'sprites/gold_30.png'\n\t\t\t@cell_png = [ 'sprites/cell0_30.png', 'sprites/cell1_30.png', 'sprites/cell2_30.png', \n\t\t\t\t\t\t 'sprites/cell3_30.png', 'sprites/cell4_30.png', 'sprites/cell5_30.png',\n\t\t\t\t\t\t 'sprites/cell6_30.png', 'sprites/cell7_30.png', 'sprites/cell8_30.png' ]\n\t\tend\n\n\t\t# Clear and resize the board array\n\t\t@spawned = false\n\t\t@victorious = false\n\t\t@burniation = -1\n\t\t@burn_size = 1\n\t\t@dragons = Array.new( @width * @height, 0 )\n\t\t@cell_status = Array.new( @width * @height, :status_covered )\n\n\t\t# Decide how big the stuff on the right hand side should be\n\t\t@label_size = -2.5\n\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size )\n\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size )\n\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size )\n\n\t\twhile [ @size_restart.x, @size_dragon.x, @size_time.x ].max < ( $gtk.args.grid.w - ( ( @width + 6 ) * @cell_size ) )\n\n\t\t\t# Try some slightly bigger sizes then\n\t\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size+0.1 )\n\t\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size+0.1 )\n\t\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size+0.1 )\n\n\t\t\t# And nudge up the label size\n\t\t\t@label_size += 0.1\n\t\tend \n\n\t\t@label_size -= 0.1\n\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size )\n\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size )\n\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size )\n\t\t\n\t\t# Lastly, work out some sensible offsets\n\t\t@board_w = @width * @cell_size\n\t\t@board_h = @height * @cell_size\n\t\t@board_x = 2 * @cell_size \n\t\t@board_y = $gtk.args.grid.center_y - ( @board_h / 2 )\n\n\t\t@label_x = @board_x + @board_w + ( 2 * @cell_size )\n\t\t@label_time_y = $gtk.args.grid.center_y + ( @size_time.y + 20 ) * 1.5\n\t\t@label_dragon_y = @label_time_y - 20 - @size_dragon.y - 20\n\t\t@label_restart_y = @label_dragon_y - 20 - @size_restart.y - 20\n\n\t\t@label_width = [ @size_restart.x, @size_dragon.x, @size_time.x ].max + 20\n\n\tend", "def create_region_display_tilemap\n # Create Region Tileset\n Cache.create_region_tileset_bitmap \n # Create Region Tilemap\n @region_tilemap = Tilemap.new(@viewport1)\n @region_tilemap.map_data = $game_map.data.dup\n @region_tilemap.flags = Table.new(8192)\n # Make Region Tilemap Invisible\n @region_tilemap.visible = false\n # Set Region Tilemap Flags (Over Character [?])\n 64.upto(128) {|n| @region_tilemap.flags[n] = 0x10} \n # Go Through Game Map Tiles\n $game_map.data.xsize.times {|x|\n $game_map.data.ysize.times {|y|\n # Clear Region Tilemap Info\n 4.times {|z| @region_tilemap.map_data[x, y, z] = 0}\n # Get Region ID\n region_id = $game_map.region_id(x, y)\n # Get Passability Flags\n flag1 = $game_map.tileset.flags[$game_map.data[x, y, 2]] \n # If Region ID is 0 or more\n if region_id > 0\n next @region_tilemap.map_data[x, y, 2] = 64 + region_id if flag1 > 16 and flag1 & 0x10 != 0\n @region_tilemap.map_data[x, y, 2] = region_id \n else \n next @region_tilemap.map_data[x, y, 2] = 64 if flag1 > 16 and flag1 & 0x10 != 0\n next @region_tilemap.map_data[x, y, 1] = 64 \n end \n }\n }\n # Set Region Tilemap Bitmap (Tile B)\n @region_tilemap.bitmaps[5] = Cache.region_tileset_bitmap\n # Update Region Tilemap\n update_region_tilemap\n end" ]
[ "0.7308935", "0.69810325", "0.68227607", "0.67577446", "0.67008567", "0.65787137", "0.6547141", "0.641404", "0.6386406", "0.6383767", "0.6361345", "0.63573515", "0.63160497", "0.6299499", "0.62970245", "0.6273948", "0.62636185", "0.6249431", "0.62161463", "0.6198146", "0.61543864", "0.61438143", "0.6137102", "0.6124487", "0.60840946", "0.608026", "0.6072859", "0.6066854", "0.60562396", "0.60512525", "0.5987506", "0.597078", "0.59700584", "0.5954087", "0.5953466", "0.59475327", "0.59296775", "0.59288156", "0.59067386", "0.59039205", "0.58942896", "0.58910495", "0.58837044", "0.584892", "0.5833925", "0.5826785", "0.5816882", "0.580632", "0.5800965", "0.57975", "0.57973474", "0.5786164", "0.5783586", "0.5780893", "0.5757165", "0.5756345", "0.57554466", "0.5753745", "0.57467425", "0.57379013", "0.5724437", "0.57136476", "0.570563", "0.5699845", "0.5699057", "0.56874275", "0.5685529", "0.5683405", "0.5675021", "0.56596255", "0.5644652", "0.5643734", "0.56429964", "0.56371844", "0.56283003", "0.5620611", "0.5614036", "0.5596381", "0.5584124", "0.5583197", "0.55594367", "0.5559428", "0.55534506", "0.55267274", "0.5521927", "0.55160475", "0.5512022", "0.55050784", "0.54991305", "0.5496091", "0.54858756", "0.5484941", "0.54804206", "0.54804206", "0.54803205", "0.54799646", "0.54758847", "0.5469087", "0.54667324", "0.54632515" ]
0.5664489
69
automatically lay gray Boom upgrades if enough tiles remain if no such tiles remain, remove the pending gray lays from the list of pending lays if some such tiles remain, but not enough for all of the Booming hexes, then they will be manually resolved by the BoomTrack step
def handle_gray_booms! return if @pending_gray_boom_tile_lays.values.flatten.empty? # clear gray double boom city actions, no tiles remain if (num_double_boom_tiles = gray_double_boomcity_tile_count).zero? @pending_gray_boom_tile_lays[:double_boom].clear # there are enough gray double boom city tiles, automatically lay them elsif num_double_boom_tiles >= @pending_gray_boom_tile_lays[:double_boom].size @pending_gray_boom_tile_lays[:double_boom].each do |hex| boomcity_to_double_boomcity!(hex, gray_checked: true) end end # clear pending gray boom city tile lays, no tiles remain if gray_boomcity_tile_potential_count.zero? @pending_gray_boom_tile_lays[:boom].clear # there are enough gray boom city tiles, automatically lay them elsif gray_boomcity_tile_count >= @pending_gray_boom_tile_lays[:boom].size @pending_gray_boom_tile_lays[:boom].each do |hex| boomtown_to_boomcity!(hex, gray_checked: true) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pending_boom_tile_lays\n @pending_boom_tile_lays.merge(\n @pending_gray_boom_tile_lays[:boom].to_h { |h| [h, boomcity_tiles(h.tile.name)] }\n ).merge(\n @pending_gray_boom_tile_lays[:double_boom].to_h { |h| [h, [double_boomcity_tile(h.tile.name)]] }\n )\n end", "def gray_boomcity_tile_potential_count\n gray_boomcity_tile_count +\n [gray_double_boomcity_tile_count, @pending_gray_boom_tile_lays[:double_boom].size].min\n end", "def big_merger(placed_sur_tiles, placed_tile)\n other_tiles = []\n hotel_name1 = placed_sur_tiles[0].hotel\n hotel_name2 = placed_sur_tiles[1].hotel\n hotel_name3 = placed_sur_tiles[2].hotel\n game_hotel1 = self.game_hotels.where(name: hotel_name1).first\n game_hotel2 = self.game_hotels.where(name: hotel_name2).first\n game_hotel3 = self.game_hotels.where(name: hotel_name3).first\n if (game_hotel1.chain_size >= game_hotel2.chain_size) && (game_hotel1.chain_size >= game_hotel3.chain_size)\n dominant_hotel = game_hotel1.hotel\n acquired_hotel1 = game_hotel2\n acquired_hotel2 = game_hotel3\n color = dominant_hotel.color\n c2 = game_hotel2.hotel.color\n c3 = game_hotel3.hotel.color\n game_tiles2 = self.game_tiles.where(hotel: hotel_name2)\n game_tiles2.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c2]\n other_tiles << temp\n end\n game_tiles3 = self.game_tiles.where(hotel: hotel_name3)\n game_tiles3.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c3]\n other_tiles << temp\n end\n game_hotel1.chain_size += game_tiles2.length + game_tiles3.length\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel2.chain_size = 0\n game_hotel2.save\n game_hotel2.update_share_price\n game_hotel3.chain_size = 0\n game_hotel3.save\n game_hotel3.update_share_price\n elsif (game_hotel2.chain_size >= game_hotel1.chain_size) && (game_hotel2.chain_size >= game_hotel3.chain_size)\n dominant_hotel = game_hotel2.hotel\n acquired_hotel1 = game_hotel1\n acquired_hotel2 = game_hotel3\n color = dominant_hotel.color\n c1 = game_hotel1.hotel.color\n c3 = game_hotel3.hotel.color\n game_tiles1 = self.game_tiles.where(hotel: hotel_name1)\n game_tiles1.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c1]\n other_tiles << temp\n end\n game_tiles3 = self.game_tiles.where(hotel: hotel_name3)\n game_tiles3.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c3]\n other_tiles << temp\n end\n game_hotel2.chain_size += game_tiles1.length + game_tiles3.length\n game_hotel2.save\n game_hotel2.update_share_price\n game_hotel1.chain_size = 0\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel3.chain_size = 0\n game_hotel3.save\n game_hotel3.update_share_price\n elsif (game_hotel3.chain_size >= game_hotel1.chain_size) && (game_hotel3.chain_size >= game_hotel2.chain_size)\n dominant_hotel = game_hotel3.hotel\n acquired_hotel1 = game_hotel1\n acquired_hotel2 = game_hotel2\n color = dominant_hotel.color\n c1 = game_hotel1.hotel.color\n c2 = game_hotel2.hotel.color\n game_tiles1 = self.game_tiles.where(hotel: hotel_name1)\n game_tiles1.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c1]\n other_tiles << temp\n end\n game_tiles2 = self.game_tiles.where(hotel: hotel_name2)\n game_tiles2.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c2]\n other_tiles << temp\n end\n game_hotel3.chain_size += game_tiles1.length + game_tiles2.length\n game_hotel3.save\n game_hotel3.update_share_price\n game_hotel1.chain_size = 0\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel2.chain_size = 0\n game_hotel2.save\n game_hotel2.update_share_price\n end \n\n [color, other_tiles, acquired_hotel1, acquired_hotel1_size, acquired_hotel2, acquired_hotel2_size] \n end", "def revert_conflicts\r\n self.update_conflicts(-1)\r\n #@tile.hit()\r\n end", "def compact_pieces\n @recheck = false\n for i in (0..@width-1)\n for j in (0..@height-1)\n if @board[i][j] and @board[i][j+1].nil? #drop pieces down\n @recheck = true\n @board[i][j+1] = @board[i][j]\n @board[i][j] = nil \n elsif j == 0 and @board[i][j].nil? #replace pieces at top\n @recheck = true\n @board[i][j] = Piece.new\n end\n end\n end\n if @startup and @recheck #fast setup of board before update + anim loops start\n compact_pieces\n clear_matches\n end \n end", "def render_unvisited\n outputs.solids << scale_up(grid.rect).merge(unvisited_color)\n outputs.solids << move_and_scale_up(grid.rect).merge(unvisited_color)\n end", "def check_pungs\n @tmp_count_group_by_tile.each do |tile, count|\n next if count < 3\n if block_given?\n yield(tile, count)\n else\n @tmp_count_group_by_tile[tile] -= 3\n @tmp_win_hand << Array.new(3, tile)\n end\n end\n end", "def check_encompassed_area\n @set_upper_area_sprite = false\n top_left, bot_right = get_edge_corner_dis\n last_x, last_y, copy_region = nil, nil, 0\n map_xd, map_yd = $game_map.display_x * 32, $game_map.display_y * 32\n ##total_height = (self.height + @character.jump_height).round\n total_height = (self.oy).round\n self.width.times do |x|\n xp = map_xd.to_i + top_left[0] + x\n unless xp / 32 == last_x\n last_x = xp / 32\n last_y, copy_region = nil, 0\n total_height.times do |y|\n yp = map_yd.to_i + bot_right[1] + @character.jump_height - y\n next if yp.to_i / 32 == last_y\n last_y = yp.to_i / 32\n if last_y == (@character.screen_y + map_yd).to_i / 32\n#~ if last_y == (@character.screen_y + @character.jump_height +\n#~ map_yd).to_i / 32\n break if $game_map.terrain_tag(last_x, last_y) == UpperTerrain\n next\n end\n next if $game_map.terrain_tag(last_x, last_y) != UpperTerrain\n copy_region = [self.height, total_height - y + 1].min\n set_upper_sprite\n break\n end\n end\n next if copy_region == 0\n rect = Rect.new(src_rect.x + x, src_rect.y, 1, copy_region)\n @upper_area_sprite.bitmap.blt(x, 0, self.bitmap, rect)\n self.bitmap.clear_rect(rect)\n end\n if !@set_upper_area_sprite && @upper_area_sprite\n @upper_area_sprite.visible = false\n end\n end", "def tempMissingBackSprite\n bmp = pbBitmap(\"Graphics/EBDX/Battlers/000\")\n rbmp = Bitmap.new(bmp.width*5*2, bmp.height*2)\n for i in 0...5\n rbmp.stretch_blt(Rect.new(i*2*bmp.width, 0, bmp.width*2, bmp.height*2), bmp, bmp.rect)\n end\n bmp.dispose\n return rbmp\n end", "def rebalance_unit_sizes\n units = @data[\"units\"][:data]\n unit_stats = @data[\"unit_stats\"][:data]\n by_composion = unit_stats[2..-1].group_by{|row| row[1,3] }\n by_composion.each do |comp, units|\n replace = case comp\n when [24, 0, 4] # art\n [36, 0, 6]\n when [80, 80, 0] # dragoon\n [100, 100, 0]\n when [100, 100, 0] # swedish dragoons\n [120, 120, 0]\n when [60, 60, 0] # cav\n [80, 80, 0]\n when [40, 20, 0] # elephant cav\n [60, 30, 0]\n when [60, 0, 0] # airguns\n [80, 0, 0]\n when [80, 0, 0] # light inf, grenadiers, and such\n [120, 0, 0]\n when [120, 0, 0] # mostly NAN, but also a few elite units\n [140, 0, 0]\n # No upgrades\n when [50, 0, 1] # ottoman great cannon\n when [160, 0, 0], [200, 0, 0] # line inf\n when [32, 32, 0] # generals\n [60, 60, 0]\n when [32, 16, 0] # elephant generals\n [60, 30, 0]\n when [48, 0, 4], [30, 30, 0], [100, 0, 0], [180, 0, 0], [1, 0, 0], [10, 0, 0], [20, 0, 4] # episodic and test\n when [24, 0, 6] # 12_lber_ship_fort_cannon / 18_lber_ship_fort_cannon ???\n else\n binding.pry\n end\n next unless replace\n units.each do |row|\n unless row[1,3] == replace\n a = row[1,3][0]\n b = replace[0]\n p [\"#{row[0]}\", \"#{a}/#{a}\", \"#{b}/#{b}\"]\n end\n row[1,3] = replace\n end\n end\n end", "def setup_blueprint_pastures\n want = 36\n @fort_entrance.maptile.spiral_search(df.world.map.x_count, 12, 12) { |_t|\n next unless sf = surface_tile_at(_t)\n grasstile = 0\n if (-5..5).all? { |dx| (-5..5).all? { |dy|\n if tt = sf.offset(dx, dy) and tt.shape_basic == :Floor and\n tt.designation.flow_size == 0 and tt.tilemat != :FROZEN_LIQUID\n grasstile += 1 if tt.mapblock.block_events.find { |be|\n be.kind_of?(DFHack::BlockSquareEventGrassst) and be.amount[tt.dx][tt.dy] > 0\n }\n true\n end\n } } and grasstile >= 70\n @rooms << Room.new(:pasture, nil, sf.x-5, sf.x+5, sf.y-5, sf.y+5, sf.z)\n @rooms.last.misc[:users] = []\n want -= 1\n true if want == 0\n end\n }\n end", "def break_plates_in_blocks(plates)\n\tn_plates = number_of_plates(plates)\n\tplaque_index=0\n\twhile plaque_index<n_plates\n\t\tlog \"breaking plate #{plaque_index}\"\n\t\tall_points = points_of_the_plate(plates,plaque_index)\n\t\tif all_points.count>0\n\t\t\tstart_point = all_points[0]\n\t\t\tmain_block = []\n\t\t\texpand_block(plates,main_block,start_point,plaque_index)\n\t\t\ttoremove = all_points.select {|p| not main_block.include? p}\t\t\t\n\t\t\tif toremove.count>0\n\t\t\t\tlog \"plate to be broken, #{toremove.count} points removed, #{main_block.count} kept\"\n\t\t\t\ttoremove.each {|p| x,y=p; plates.set(x,y,n_plates)}\n\t\t\t\tn_plates += 1\t\t\t\t\n\t\t\tend\t\t\t\n\t\tend\n\t\tplaque_index += 1\n\tend\nend", "def setup_blueprint_pastures\n want = 36\n @fort_entrance.maptile.spiral_search([df.world.map.x_count, df.world.map.y_count].max, 12, 12) { |_t|\n next unless sf = surface_tile_at(_t)\n grasstile = 0\n if (-5..5).all? { |dx| (-5..5).all? { |dy|\n if tt = sf.offset(dx, dy) and (tt.shape_basic == :Floor or tt.tilemat == :TREE) and\n tt.designation.flow_size == 0 and tt.tilemat != :FROZEN_LIQUID\n grasstile += 1 if tt.mapblock.block_events.find { |be|\n be.kind_of?(DFHack::BlockSquareEventGrassst) and be.amount[tt.dx][tt.dy] > 0\n }\n true\n end\n } } and grasstile >= 70\n @rooms << Room.new(:pasture, nil, sf.x-5, sf.x+5, sf.y-5, sf.y+5, sf.z)\n @rooms.last.misc[:users] = []\n want -= 1\n true if want == 0\n end\n }\n end", "def eliminate_coliding_areas all_possible_areas\n puts 'All areas initial: ' + all_possible_areas.values.map{|areas| areas.count }.inspect\n\n all_possible_areas_reduced = {}\n\n # Reduce areas by eliminiting the ones which touch on another\n # numbered tile\n all_possible_areas.keys.each do |numbered_tile|\n x,y = numbered_tile.split('-').map(&:to_i)\n # Create board with compased tiles on all numbered tiles minus the\n # numbered tile\n restricted_board = create_restricted_board([x,y]).to_a\n all_compased_numbered_tiles = []\n (0..(@row_count-1)).to_a.each do |i|\n (0..(@col_count-1)).to_a.each do |j|\n all_compased_numbered_tiles << [i,j] if restricted_board[i][j] == 1\n end\n end\n\n all_areas_for_numbered_tile = all_possible_areas[numbered_tile].dup\n\n all_possible_areas_reduced[numbered_tile] = all_areas_for_numbered_tile.delete_if do |area|\n next if area.count == 1\n # Skip area, hmm do I need this bellow\n # next if (@b_nl[x,y] == 1)\n # Remove area if colinding\n area & all_compased_numbered_tiles != []\n end\n end #for each numbered_tile,area_span\n\n puts 'All numbered tile areas reduced(not coliding other numbered tiles)' + all_possible_areas_reduced.values.map{|areas| areas.count }.inspect\n all_possible_areas_reduced\n end", "def update_next_state\n # Maybe if I do this it won't query for this game's tiles every time? ¯\\_(ツ)_/¯\n tiles = self.tiles \n players = self.players \n voids = tiles.where(\"height < 1\")\n\n # Pick random tiles to raise\n raiseTiles = voids.sample((voids.length/2).ceil)\n dropCounter = (players.length/2).ceil\n dropTiles = []\n\n # Drop tiles players were on\n players.each do |player|\n dropTiles << player.tile\n end \n\n # Pick random tiles to drop\n while dropCounter > 0\n randTile = tiles.sample\n\n if (!dropTiles.include?(randTile) && randTile.height > 0)\n dropTiles << randTile \n dropCounter -= 1\n end\n end\n\n tiles.each do |tile| \n if (dropTiles.include?(tile))\n tile.update(height: tile.height-1)\n elsif (raiseTiles.include?(tile))\n tile.update(height: [2, 1, 1, 1].sample)\n end\n end\n end", "def tile_removal(array_of_tiles)\n array_of_tiles.each do |letter|\n if @default_tiles.keys.include?(letter)\n @default_tiles[letter] -= 1\n end\n @default_tiles.delete_if {|key, value| value == 0 }\n end\n end", "def stabilize(grid, empty_if_greater, occupied_counter)\n while (changes = calculate_changes(grid, empty_if_greater, occupied_counter)) && changes.any?\n changes.each {|coordinate, change| grid.set(coordinate, :state, change)}\n end\n grid.select(:state, State::OCCUPIED).length\nend", "def remove_pieces\n CHECKERS_HEIGHT.times do |x|\n CHECKERS_WIDTH.times do |y|\n @pieces[x][y].remove unless @pieces[x][y].nil?\n end\n end\nend", "def define_adyacent_bombs\n @board.length.times do |i|\n @board[i][:value] = get_total_adyacent_bombs(i) unless @board[i][:value] == @bomb\n end\n end", "def draw_pieces\n CHECKERS_HEIGHT.times do |x|\n CHECKERS_WIDTH.times do |y|\n @pieces[x][y].remove unless @pieces[x][y].nil?\n @pieces[x][y] = draw_piece(x,y,@board.state[x][y]) unless @board.state[x][y].nil?\n end\n end\nend", "def clean_up\n show do\n title 'Store pellets on ice'\n note temp_instructions(ON_ICE)\n\n note 'Keep the labeled cell pellets, in the 24-well aluminum block, on ice until you are ready for FACS.'\n end\n\n buffers = operations.map { |op| op.inputs.select { |i| ALL_BUFFERS.include?(i.name) } }.flatten\n buffers.map! { |b| b.child_item }.uniq!\n\n release(buffers, interactive: true)\n\n show do\n title 'Clean up'\n\n check 'Any items that remain on the bench (other than the labeled cell pellets) can be discarded.'\n check \"Set the refigerated centrifuge back to 25 #{DEGREES_C}.\"\n end\n end", "def execute_merger(placed_sur_tiles, orphan, placed_tile)\n other_tiles = []\n if orphan\n num = 1\n else\n num = 0\n end\n hotel_name1 = placed_sur_tiles[0].hotel\n hotel_name2 = placed_sur_tiles[1].hotel\n game_hotel1 = self.game_hotels.where(name: hotel_name1).first\n game_hotel2 = self.game_hotels.where(name: hotel_name2).first\n if game_hotel1.chain_size > game_hotel2.chain_size || game_hotel1.chain_size == game_hotel2.chain_size\n dominant_hotel = game_hotel1.hotel\n acquired_hotel = game_hotel2\n self.acquired_hotel = game_hotel2.name\n self.dominant_hotel = game_hotel1.name\n self.save\n color = dominant_hotel.color\n c = game_hotel2.hotel.color\n game_tiles = self.game_tiles.where(hotel: hotel_name2)\n game_tiles.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c]\n other_tiles << temp\n end\n placed_tile.hotel = dominant_hotel.name\n placed_tile.save\n acquired_hotel_size = game_hotel2.chain_size\n game_hotel1.chain_size += game_tiles.length + num + 1\n game_hotel1.save\n game_hotel1.update_share_price\n game_hotel2.chain_size = 0\n game_hotel2.save\n game_hotel2.update_share_price\n elsif game_hotel2.chain_size > game_hotel1.chain_size\n dominant_hotel = game_hotel2.hotel\n acquired_hotel = game_hotel1\n self.acquired_hotel = game_hotel1.name\n self.dominant_hotel = game_hotel2.name\n self.save\n color = dominant_hotel.color\n c = game_hotel1.hotel.color\n game_tiles = self.game_tiles.where(hotel: hotel_name1)\n game_tiles.each do |tile|\n tile.hotel = dominant_hotel.name\n tile.save\n temp = [tile.tile.row, tile.tile.column, c]\n other_tiles << temp\n end\n placed_tile.hotel = dominant_hotel.name\n placed_tile.save\n acquired_hotel_size = game_hotel1.chain_size\n game_hotel2.chain_size += game_tiles.length + num + 1\n game_hotel2.save\n game_hotel2.update_share_price\n game_hotel1.chain_size = 0\n game_hotel1.save\n game_hotel1.update_share_price\n end\n\n [color, other_tiles, dominant_hotel, acquired_hotel, acquired_hotel_size]\n end", "def board_updates\n if under_populated? \n dead\n elsif over_populated?\n dead\n elsif to_be_reproduced?\n rebirth\n end \n end", "def reset_board_variables\n @color_on_turn = :white\n @fifty_counter = 0\n @pieces = {:white => [], :black => []} \n @last_moved_item = BoardInfoItem.new(0,0)\n @infosquare.each do |row_square|\n row_square.each do |cell|\n cell.clear\n end\n end\n #p @infosquare\n end", "def update_possible!()\r\n\r\n #falls es keine Hits gibt, werden ale Tipps geloescht, die eine der Ziffern enthalten\r\n if (@last_hits == [0,0])\r\n @digits.times do |i|\r\n\r\n @left.delete_if{ |x|\r\n x.include?(@last_guess[i])\r\n }\r\n\r\n end\r\n\r\n end\r\n\r\n #falls es keine Black Hits gibt, werden alle Tipps mit einer identischen Stelle geloescht\r\n if @last_hits[0]==0\r\n\r\n @digits.times do |i|\r\n\r\n @left.delete_if { |x|\r\n x[i]==@last_guess[i]\r\n }\r\n end\r\n\r\n end\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Black Hits entspricht\r\n @left.delete_if { |x|\r\n @last_hits[0] != @mastermind.hits(@last_guess,x)[0]\r\n }\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Total Hits entspricht\r\n @left.delete_if { |x|\r\n (@last_hits[0] + @last_hits[1]) != (@mastermind.hits(@last_guess,x)[0][email protected](@last_guess,x)[1])\r\n }\r\n\r\n end", "def test_that_full_tile_rack_doesnt_need_any_tiles\n 7.times{|num| @newTileRack.append(:A)}\n assert_equal(0,@newTileRack.number_of_tiles_needed)\n end", "def merger_and_orphan(placed_sur_tiles, placed_tile)\n if placed_sur_tiles[0].hotel == 'none'\n response = execute_merger([placed_sur_tiles[1], placed_sur_tiles[2]], true, placed_tile)\n other_tiles = response[1]\n other_tiles << [placed_sur_tiles[0].tile.row, placed_sur_tiles[0].tile.column, 'grey']\n color = response[0]\n placed_sur_tiles[0].hotel = Hotel.where(color: color).first.name\n dominant_hotel = response[2]\n acquired_hotel = response[3]\n acquired_hotel_size = response[4]\n elsif placed_sur_tiles[1].hotel == 'none'\n response = execute_merger([placed_sur_tiles[0], placed_sur_tiles[2]], true, placed_tile)\n other_tiles = response[1]\n other_tiles << [placed_sur_tiles[1].tile.row, placed_sur_tiles[1].tile.column, 'grey']\n color = response[0]\n placed_sur_tiles[1].hotel = Hotel.where(color: color).first.name\n dominant_hotel = response[2]\n acquired_hotel = response[3]\n acquired_hotel_size = response[4]\n elsif placed_sur_tiles[2].hotel == 'none'\n response = execute_merger([placed_sur_tiles[0], placed_sur_tiles[1]], true, placed_tile)\n other_tiles = response[1]\n other_tiles << [placed_sur_tiles[2].tile.row, placed_sur_tiles[2].tile.column, 'grey']\n color = response[0]\n placed_sur_tiles[2].hotel = Hotel.where(color: color).first.name\n dominant_hotel = response[2]\n acquired_hotel = response[3]\n acquired_hotel_size = response[4]\n end \n\n [color, other_tiles, dominant_hotel, acquired_hotel, acquired_hotel_size]\n end", "def apply_rules_part2(grid)\n new_grid = deep_copy_grid(grid)\n (0..(grid.length - 1)).each do |row|\n (0..(grid[0].length - 1)).each do |col|\n\n if grid[row][col] == 'L' && num_visible_occupied(grid, row, col) == 0\n new_grid[row][col] = '#'\n elsif grid[row][col] == '#' && num_visible_occupied(grid, row, col) >= 5\n new_grid[row][col] = 'L'\n end\n\n end\n end\n\n new_grid\n end", "def remove_marked\n for i in (0..@width-1)\n for j in (0..@height-1)\n if @board[i][j] and @board[i][j].marked\n @board[i][j] = nil\n @pieces_removed += 1\n end\n end\n end\n end", "def mark_not_possible_solutions_after_black guess\n @code.each_with_index do |e, i|\n unless e\n not_possible_colors_for_pos = @not_possible_colors[i]\n unless not_possible_colors_for_pos\n not_possible_colors_for_pos = Array.new\n @not_possible_colors[i] = not_possible_colors_for_pos\n end\n not_possible_colors_for_pos << guess[i]\n end\n end\n end", "def place_figures(fill_board)\n @rows = Array.new(8) { Array.new(8) { EmptyPlace.instance } }\n return unless fill_board\n\n place_second_color_rows\n place_pawn_first_rows\n end", "def reset_board_variables\r\n @color_on_turn = :white\r\n @pieces = {:white => [], :black => []} \r\n @last_moved_item = BoardInfoItem.new(0,0)\r\n @infosquare.each do |row_square|\r\n row_square.each do |cell|\r\n cell.clear\r\n end\r\n end\r\n #p @infosquare\r\n end", "def avoid_roads(width, height, bad)\n\n routes = Array.new(height + 1) { Array.new(width + 1) { 0 } } # how many routes to a block?\n\n routes.each_with_index do |row, i|\n row.each_index do |j|\n if (i == 0 && j == 0)\n routes[0][0] = 1\n elsif i == 0\n routes[i][j] = routes[0][j - 1] unless is_obstructed?(i, j, i, j - 1, bad)\n elsif j == 0\n routes[i][j] = routes[i - 1][0] unless is_obstructed?(i, j, i - 1, j, bad)\n else\n top = (is_obstructed?(i, j, i - 1, j, bad) ? 0 : routes[i - 1][j])\n left = (is_obstructed?(i, j, i, j - 1, bad) ? 0 : routes[i][j - 1])\n routes[i][j] = top + left\n end\n end\n end\n\n return routes[height][width]\nend", "def prepare_GTBS\n @ATB_Active = ($game_system.cust_battle == \"ATB\")#(GTBS::MODE == 0)\n $game_system.clear_battlers #clears battler hashs stored in game_system\n setup_map\n change_music\n setup_temp_info\n create_events\n create_battlers\n create_spriteset\n setup_mini_scene_variables\n start_center\n setup_victory_fail_events\n end", "def refresh_tiles\n return if empty?\n xdiff = @array[0].real_x.round / -32 - 1\n ydiff = @array[0].real_y.round / -32 - 1\n if ydiff > 0\n ydiff.times do\n move_up do |sprite|\n sprite.mapy += YSIZE\n sprite.real_y += 32 * YSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n elsif ydiff < 0\n ydiff.abs.times do\n move_down do |sprite|\n sprite.mapy -= YSIZE\n sprite.real_y -= 32 * YSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n end\n if xdiff > 0\n xdiff.times do\n move_left do |sprite|\n sprite.mapx += XSIZE\n sprite.real_x += 32 * XSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n $temp_bitmaps = nil\n elsif xdiff < 0\n xdiff.abs.times do\n move_right do |sprite|\n sprite.mapx -= XSIZE\n sprite.real_x -= 32 * XSIZE\n draw_tile(sprite, sprite.mapx, sprite.mapy)\n end\n end\n temp_bitmaps = nil\n end\n end", "def strategy_of_binary_colors(cell, zone_ids)\n peer_ids = zone_ids - [cell.id]\n run_loop = false\n \n peer_ids.each do |buddy_id|\n buddy = self.cells[buddy_id]\n binary_colors = cell.possible_colors & buddy.possible_colors\n\n if binary_colors.count == 2\n # determine if these colors are unique to the zone\n remainder_peer_ids = peer_ids - [buddy_id]\n remainder_possible_colors = get_zone_possible_colors(remainder_peer_ids).uniq\n\n if (binary_colors & remainder_possible_colors).count == 0\n\n # the binary colors are unique?\n if cell.possible_colors != binary_colors || buddy.possible_colors != binary_colors\n # #debugging code\n # if cell.id == CELL_BEING_OBSERVED\n # puts \"STRATEGY 4: changing #{cell.possible_colors} to #{binary_colors}\"\n # end\n\n cell.possible_colors = binary_colors\n\n # #debugging code\n # if buddy.id == CELL_BEING_OBSERVED\n # puts \"STRATEGY 4: changing #{buddy.possible_colors} to #{binary_colors}\"\n # end\n\n buddy.possible_colors = binary_colors\n run_loop = true\n end\n end\n end\n end\n \n run_loop\n end", "def place_bombs\n range = ([email protected]).to_a\n total_bombs = (@grid.length ** 2) / 4\n @grid[range.sample][range.sample].value = BOMB until @grid.flatten.map(&:value).count(BOMB) == total_bombs\n end", "def make_board\n @grid = Array.new(9) { | row | Array.new(9) { | col | Tile.new(self, [row, col]) } }\n self.place_bombs\n @grid.map.with_index do | row, rowIndx |\n row.map.with_index { | tile, colIndx | tile.neighbors_bomb_count if !(self.is_a_bomb?([rowIndx, colIndx])) }\n end\n end", "def _empty_enemy_bar\n b = Bitmap.new(1, 6)\n (1..3).each {|i| b.fill_rect(0, i-1, 1, 8-i*2, Color.new(0, 80*i/3, 0))}\n return b\n end", "def rebalance_artillery\n tech = @data[\"tech\"][:data]\n tech.delete [\"military_ordnance_canister_shot\", \"enable_canister_shot\", 1]\n tech.delete [\"military_ordnance_shrapnel_shot\", \"enable_shrapnel_shot\", 1]\n tech << [\"military_ordnance_canister_shot\", \"enable_shrapnel_shot\", 1]\n tech << [\"military_ordnance_shrapnel_shot\", \"enable_canister_shot\", 1]\n end", "def update_conflicts(amt=1)\r\n\r\n # for ease\r\n pos = [@mapx, @mapy]\r\n\r\n # left to right\r\n i = 0\r\n j = @mapy\r\n loop do\r\n # stop if border reached\r\n if i == @board.w+1\r\n break\r\n end\r\n if i != @mapx\r\n @board.at(i,j).hit(amt)\r\n end\r\n i += 1\r\n end\r\n\r\n # top to bottom\r\n i = @mapx\r\n j = 0\r\n loop do\r\n # stop if border reached\r\n if j == @board.h+1\r\n break\r\n end\r\n if j != @mapy\r\n @board.at(i,j).hit(amt)\r\n end\r\n j += 1\r\n end\r\n\r\n # negative diagonal\r\n # (start from topleft)\r\n max = pos.max\r\n min = pos.min\r\n dif = max - min\r\n\r\n if @mapx == max\r\n dx = dif\r\n dy = 0\r\n else\r\n dx = 0\r\n dy = dif\r\n end\r\n\r\n # top -> bottom\r\n # left -> right\r\n i = dx\r\n j = dy\r\n loop do\r\n # stop if border reached\r\n if i == @board.w+1 || j == @board.h+1\r\n break\r\n end\r\n if i != @mapx && j != @mapy\r\n @board.at(i,j).hit(amt)\r\n end\r\n i += 1\r\n j += 1\r\n end\r\n\r\n # positive diagonal\r\n # (start from bottomleft)\r\n ht = @board.h\r\n y = ht - @mapy\r\n x = @mapx\r\n max = [x,y].max\r\n min = [x,y].min\r\n dif = max - min\r\n\r\n if x == max\r\n dx = dif\r\n dy = ht\r\n else\r\n dx = 0\r\n dy = ht - dif\r\n end\r\n\r\n # bottom -> top\r\n # left -> right\r\n i = dx\r\n j = dy\r\n loop do\r\n # stop if border reached\r\n if i == @board.w+1 || j < 0\r\n break\r\n end\r\n if i != @mapx && j != @mapy\r\n @board.at(i,j).hit(amt)\r\n end\r\n i += 1\r\n j -= 1\r\n end\r\n\r\n end", "def game_over \n # all the grid's cells are full and different numbers \n end", "def uncover (i,j)\t\t\t\n\t\tx_array = [i] \t\t\t\t\t\t\t\t\t\t\t#array containing x-indexes of clicked button which have 0 mines in the sorrounding\n\t\ty_array = [j]\t\t\t\t\t\t\t\t\t\t\t\t\t#y-index of clicked button \" \" \" \" \" \" \" \" \" \" \"\n\t\tx_array.each_with_index do |n,index|\t\n\t\t\ti = n\n\t\t\tj = y_array[index]\n\t\t\tfor x in i-1..i+1\n\t\t\t \tfor y in j-1..j+1\n\t\t\t\t\tif x>=0 && y >=0 && x < @rows && y < @cols\n\t\t\t\t\t\tnext if @buttons[x][y].state == \"insensitive\"\t# next iteration if this array index(button) has already been uncovered\n\t\t\t\t\t\t@buttons[x][y].label = @board[x][y].to_s\t\t\t\t\t\n\t\t\t\t\t\t@buttons[x][y].sensitive = false\n\t\t\t\t\t\t@clicks = @clicks + 1 \t\t\t\t\t#click count will be updated for every array index traversed\n\t\t\t\t\t\t@builder[\"window1\"].title = @clicks.to_s\n\t\t\t\t\t\tif @board[x][y] == 0 \t\t\t\t\t#if neighbours of the clicked button contain another 0 valued button,we will add that to our array\n\t\t\t\t\t\t\t@board[x][y] = \"-\"\t\t\t\t\t\t\n\t\t\t\t\t \t\tx_array << x\t\t\t\t\t\t\t\t#if another 0 is found in the neighbours, insert it in to uncover array\n\t\t\t\t\t\t\ty_array << y \t\t\t\t# same as above, saving y-index \n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t end \n\t\tend\n\tend", "def render\n game_over = false\n game.grid.each do |row|\n row_output = []\n row.each do |el|\n if el.revealed\n if el.has_bomb\n el_output = \"X\"\n game_over = true\n else\n el_output = \"_\"\n el.total_num_neighbor_bombs\n #has to be changed\n #find positions of neighbors\n #ask each neighbor if has bomb\n #count total number of bombs\n #output that integer instead of flag, star, or _\n\n\n\n\n end\n else\n el_output = el.has_flag ? \"F\" : \"*\"\n end\n row_output << el_output\n end\n p row_output.join(\" \")\n end\n # call game_over method if game_over == true\n end", "def calculate_changes(grid, empty_if_greater, occupied_counter)\n grid.points.keys.each_with_object({}) do |coordinate, changes|\n seat_state = grid.at(coordinate)[:state]\n if seat_state != State::FLOOR\n occupied_count = occupied_counter.call(grid, coordinate)\n changes[coordinate] = State::OCCUPIED if occupied_count == 0 && seat_state == State::EMPTY\n changes[coordinate] = State::EMPTY if occupied_count >= empty_if_greater && seat_state == State::OCCUPIED\n end\n end\nend", "def refresh_magic_chests\n @map.events.each_value do |event|\n if event.name =~ Chest_Service::CHEST_REGX\n chest_state = Chest_Service.get_online_state_chest($1)\n case chest_state\n when Chest_Service::CHEST_EMPTY\n local_a = true\n local_b = false\n when Chest_Service::CHEST_FULL\n local_a = false\n local_b = false\n when Chest_Service::DATA_ERROR\n local_a = false\n local_b = true\n else\n local_a = false\n local_b = true\n end\n sw_a = [@map_id, event.id, 'A']\n sw_b = [@map_id, event.id, 'B']\n $game_self_switches[sw_a] = local_a\n $game_self_switches[sw_b] = local_b\n end\n end\n end", "def deduce\n while true\n stuck, guess, count = true, nil, 0\n # fill in any spots determined by direct conflicts\n allowed = board.allowed_numbers\n (0..80).each do |index|\n if board.board[index].nil?\n numbers = bits_to_numbers(allowed[index])\n if numbers.size == 0\n return [] # Return nothing if no possibilitie E\n elsif numbers.size == 1\n board.board[index] = numbers[0]\n stuck = false\n break\n elsif stuck\n new_guesses = numbers.map { |n| [index, n] }\n guess, count = pickbetter(guess, count, new_guesses)\n end\n end\n end\n\n if !stuck\n allowed = board.allowed_numbers\n end\n needed = board.needed_numbers\n\n # fill in any spots determined by elimination of other locations.\n # For any given column, find which numbers it is missing,\n # And figure out which positions allow those numbers - if only\n # one position allows it, the number goes there.\n #\n # If more than one spot is available, add to the guesses.\n board.coordinate_systems.each do |axis|\n (0..8).each do |x|\n numbers = bits_to_numbers(needed[axis_index(x, axis)])\n numbers.each do |n|\n bit = 1 << n\n # spots =for this number & col, all positions that allow the needed\n # numbers\n spots = []\n\n (0..8).each do |y|\n index = board.index_for(x, y, axis)\n # if this position allows the needed number, add it to spots\n if allowed[index] & bit\n spots << index\n end\n end\n\n if spots.length == 0\n return []\n elsif spots.length == 1\n board.board[spots[0]] = n\n stuck = False\n break\n elsif stuck\n new_guesses = spots.map { |index| [index, n] }\n guess, count = pickbetter(guess, count, new_guesses)\n end\n end\n end\n end\n\n if stuck\n guess.shuffle! unless guess.nil?\n return guess\n end\n end\n end", "def update_state!(new_board, ships_remaining)\n if (hit = detect_hit(@last_board, new_board))\n @hunting = false\n @last_hit = hit\n end\n unless ships_remaining.sort == @opponents_ships.sort\n @hunting, @opponents_ships = [true, ships_remaining]\n end\n @last_board = new_board\n end", "def checked_fill_down(srcy:, srcx:, done:)\n # Originally, I didn't have this check,\n # and the last iteration set off a huge chain of recursive calls.\n # (called this function 282k times)\n return if done[[srcy, srcx]]\n done[[srcy, srcx].freeze] = true\n\n obstacle_below = (srcy..@ymax).find { |y|\n # The code is still correct if we remove the resting water check,\n # but it would have to redo work it already did.\n # So we will consider resting water an obstacle for dropping water.\n @clay.dig(y, srcx) || @water[y][srcx] == :rest\n }\n\n unless obstacle_below\n puts \"Water falls from #{srcy} #{srcx} off screen\" if VERBOSE\n (srcy..@ymax).each { |y| @water[y][srcx] = :flow }\n return\n end\n\n (srcy...obstacle_below).each { |y| @water[y][srcx] = :flow }\n\n # Start filling upwards, starting from one above that obstacle.\n (obstacle_below - 1).step(by: -1) { |current|\n left_type, leftx = scout(srcy: current, srcx: srcx, dir: -1)\n right_type, rightx = scout(srcy: current, srcx: srcx, dir: 1)\n range = (leftx + 1)...rightx\n\n if left_type == :wall && right_type == :wall\n # Walls on either side.\n # Water rests, we move up and do it again.\n range.each { |x| @water[current][x] = :rest }\n else\n # One or both sides lacks a wall.\n # Water flows on this level, and drops on any side lacking a wall.\n range.each { |x| @water[current][x] = :flow }\n puts [\n \"Water falls from #{srcy} #{srcx} to #{obstacle_below - 1}\",\n \"filled up to #{current}\",\n \"left[#{left_type}@#{leftx}]\",\n \"right[#{right_type}@#{rightx}]\",\n ].join(', ') if VERBOSE\n checked_fill_down(srcy: current, srcx: leftx, done: done) if left_type == :drop\n checked_fill_down(srcy: current, srcx: rightx, done: done) if right_type == :drop\n break\n end\n }\n end", "def bush_depth\n # タイルの場合、または最前面に表示フラグが ON の場合\n if @tile_id > 0 or @always_on_top\n return 0\n end\n # return 12 if @in_swamp #> Ajout des marais\n if @jump_count == 0 and $game_map.bush?(@x, @y)\n return 12\n else\n return 0\n end\n end", "def bc_remove_layout_1(bc, path, barclamp, options={})\n options = {:debug => false}.merge! options\n debug = options[:debug] or ENV['DEBUG'] === \"true\"\n filelist = File.join BARCLAMP_PATH, \"#{bc}-filelist.txt\"\n if File.exist? filelist \n files = [ filelist ]\n File.open(filelist, 'r') do |f|\n f.each_line { |line| files << line }\n end\n FileUtils.rm files\n merge_nav barclamp, false\n merge_sass barclamp, bc, path, false\n puts \"DEBUG: Barclamp #{bc} UNinstalled\" if debug\n end\nend", "def tiles_remaining\n @default_tiles.values.inject(0, :+)\n end", "def cleanup_board(board)\n for y in (0...9)\n for x in (0...9)\n assign = 0\n for p in (1...10)\n if board[y][x][p] != 0 \n if assign == 0\n assign = board[y][x][p]\n else\n assign = 0\n break\n end\n end\n end\n if assign != 0 and board[y][x][0] == 0\n board[y][x][0] = assign\n for p in (1...10)\n board[y][x][p] = 0\n end\n end\n end\n end\n return\n end", "def size \n\n\t\t# Set the basic metrics\n\t\tcase @board_size\n\t\twhen :small \t\t\t\t# A 20x20 grid\n\t\t\t@width = 30\n\t\t\t@height = 20\n\t\t\t@dragon_count = 50 * @board_level\n\t\t\t@cell_size = 30\n\t\t\t@cover_png = 'sprites/cover_30.png'\n\t\t\t@dragon_png = 'sprites/dragon_30.png'\n\t\t\t@gold_png = 'sprites/gold_30.png'\n\t\t\t@cell_png = [ 'sprites/cell0_30.png', 'sprites/cell1_30.png', 'sprites/cell2_30.png', \n\t\t\t\t\t\t 'sprites/cell3_30.png', 'sprites/cell4_30.png', 'sprites/cell5_30.png',\n\t\t\t\t\t\t 'sprites/cell6_30.png', 'sprites/cell7_30.png', 'sprites/cell8_30.png' ]\n\t\tend\n\n\t\t# Clear and resize the board array\n\t\t@spawned = false\n\t\t@victorious = false\n\t\t@burniation = -1\n\t\t@burn_size = 1\n\t\t@dragons = Array.new( @width * @height, 0 )\n\t\t@cell_status = Array.new( @width * @height, :status_covered )\n\n\t\t# Decide how big the stuff on the right hand side should be\n\t\t@label_size = -2.5\n\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size )\n\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size )\n\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size )\n\n\t\twhile [ @size_restart.x, @size_dragon.x, @size_time.x ].max < ( $gtk.args.grid.w - ( ( @width + 6 ) * @cell_size ) )\n\n\t\t\t# Try some slightly bigger sizes then\n\t\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size+0.1 )\n\t\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size+0.1 )\n\t\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size+0.1 )\n\n\t\t\t# And nudge up the label size\n\t\t\t@label_size += 0.1\n\t\tend \n\n\t\t@label_size -= 0.1\n\t\t@size_restart = $gtk.calcstringbox( \"Restart\", @label_size )\n\t\t@size_dragon = $gtk.calcstringbox( \"888 Dragons To Find\", @label_size )\n\t\t@size_time = $gtk.calcstringbox( \"88:88:88\", @label_size )\n\t\t\n\t\t# Lastly, work out some sensible offsets\n\t\t@board_w = @width * @cell_size\n\t\t@board_h = @height * @cell_size\n\t\t@board_x = 2 * @cell_size \n\t\t@board_y = $gtk.args.grid.center_y - ( @board_h / 2 )\n\n\t\t@label_x = @board_x + @board_w + ( 2 * @cell_size )\n\t\t@label_time_y = $gtk.args.grid.center_y + ( @size_time.y + 20 ) * 1.5\n\t\t@label_dragon_y = @label_time_y - 20 - @size_dragon.y - 20\n\t\t@label_restart_y = @label_dragon_y - 20 - @size_restart.y - 20\n\n\t\t@label_width = [ @size_restart.x, @size_dragon.x, @size_time.x ].max + 20\n\n\tend", "def finalize\r\n drop_chopsticks\r\n end", "def should_collect_broken_bikes?(container)\n !self.full? && container.broken_bikes.count >= 1 \n end", "def process_dead_neighbors\n\n @dead_neighbors.each do |dn|\n row, col = dn.split('_') \n dead_cell = Cell.new(row.to_i, col.to_i, false)\n\n dead_cell.neighbors.each do |n_cell|\n if @current_state.include?(n_cell)\n dead_cell.inc_alive_neighbors\n end\n end\n\n if reproduces?(dead_cell)\n dead_cell.alive = true\n future_state[dn] = dead_cell \n end\n end\n end", "def check_out_of_world # swap size\n # y\n if @y < 0\n die\n elsif @y > WINDOW_SIZE_Y\n die\n end\n # x ( comment me out to add the glitch feature agian )\n if @x < 0\n @x = WINDOW_SIZE_X - TILE_SIZE - 2\n elsif @x > WINDOW_SIZE_X - TILE_SIZE - 1\n @x = 0\n end\n end", "def cpu_progress\n remove_array = []\n (0..3).each do |_i|\n (0..6).each do |c|\n token_placed = board_place_token(c)\n if game_result != NO_RESULT_YET\n remove_array.reverse_each do |r| # remove moves from our array 'stack'\n board_remove_token(r)\n end\n return true\n end\n remove_array.push(c) if token_placed # add move for later deletion\n end\n end\n end", "def full_game_board\n\t\trows = []\n\t\t(0...$dimensions[:y]).each do |y|\n\t\t\tcols = []\n\t\t\t(0...$dimensions[:x]).each do |x|\n\t\t\t\tcols << board_status({:x => x, :y => y})\n\t\t\tend\n\t\t\trows << cols\n\t\tend\n\t\thunter_blob = captured_points\n\t\thunter_blob.each do |point|\n\t\t\trows[point[:y]][point[:x]] = \"-\" if rows[point[:y]][point[:x]] == '.'\n\t\tend\n\t\trows\n\tend", "def generate_possible_areas_for_all_numbered_tiles\n t = Time.now\n puts 'Start: Generate possible areas for all numbered tiles'\n all_possible_areas = {}\n\n # @b_nl.each_with_value do |value, i, j|\n # if value != 0 then\n # restricted_board = create_restricted_board [i,j]\n # t_area = Time.now\n # next if [i,j] == [7,1]\n # puts \"Summoning for [#{i},#{j}]\"\n # a = summon_areas([i,j], value, restricted_board)\n\n # puts \"Summoned area for [#{i},#{j}], time: \" + (Time.now - t_area).to_i.to_s + 's size ' + a.count.to_s\n # all_possible_areas[\"#{i}-#{j}\"] = a\n # end\n (0..@row_count-1).to_a.each do |i|\n (0..@col_count-1).to_a.each do |j|\n # Summon for each numbered tile(non zero)\n if @b_nl[i,j] != 0 then\n restricted_board = create_restricted_board [i,j]\n t_area = Time.now\n next if [i,j] == [7,1]\n puts \"Summoning for [#{i},#{j}]\"\n a = summon_areas([i,j],@b_nl[i,j], restricted_board)\n\n puts \"Summoned area for [#{i},#{j}], time: \" + (Time.now - t_area).to_i.to_s + 's size ' + a.count.to_s\n all_possible_areas[\"#{i}-#{j}\"] = a\n end\n end\n end\n puts 'Finish: Generate possible areas for all numbered tiles, time: ' + (Time.now - t).to_i.to_s + 'seconds'\n all_possible_areas[\"7-1\"] = [[[]]]\n all_possible_areas\n end", "def updateCells\n \tfor y in 0...5 do\n \t\tfor x in 0...5 do\n \t\t\tif @cells[y][x] == KILL\n \t\t\t\t@cells[y][x] = DEAD\n \t\t\tend\n \t\t\tif @cells[y][x] == SPAWN\n \t\t\t\t@cells[y][x] = ALIVE\n \t\t\tend\n \t\tend\n \tend\n end", "def update_map\n @win_flag = false\n @lose_flag = false\n @eliminate_flag = false\n @my_planets = {}\n @max_rearness = 0\n\n nil_planets_ratio = @info['holds'].select { |h| h[0].nil? }.size\n nil_planets_ratio /= @info['holds'].size.to_f\n if nil_planets_ratio > 0.618\n @aggresion = AGGRESSION_START\n puts \"Aggression: #@aggresion\"\n else\n @aggresion = AGGRESSION_MID\n end\n\n @map['planets'].each_with_index do | p, ind |\n # Check whether it is owned by me\n if @info['holds'][ind][0] == @me['seq']\n # my_planet:\n # - targets: enemy planet candidates to attack if a front line planet, or next planet of the shortest path to the nearest front line planet if a rear planet\n # - rearness: how far away from the front line, 0 for planet on the front line\n my_planet = {}\n\n # Check whether on the front line\n targets = p['neighbors'].select { |n| @info['holds'][n[0]][0] != @me['seq'] }\n if targets.size > 0 # On the front line\n my_planet[:targets] = targets\n my_planet[:rearness] = 0\n end\n\n my_neighbors = p['neighbors'].select { |n| @info['holds'][n[0]][0] == @me['seq'] }\n my_planet[:my_neighbors] = my_neighbors\n\n @my_planets[ind] = my_planet\n end\n end\n\n # Compute rearness and path of my rear planets iteratively\n my_planets = @my_planets\n left_planets = @my_planets.select { |id, p| p[:rearness].nil? }\n\n if @my_planets.empty?\n @lose_flag = true\n puts \"We lose! (planets #: #{left_planets.size} / #{@my_planets.size})\"\n return\n elsif left_planets.size == @my_planets.size\n # Check whether moving enemies exist\n moving_enemies = @info['moves'].select { |m| m[0] != @me['seq'] }\n if ! moving_enemies.empty?\n puts \"Eliminating left enemies! (planets #: #{left_planets.size} / #{@my_planets.size})\"\n @eliminate_flag = true\n moving_enemies.each do |m|\n @my_planets[m[2]][:rearness] = 0\n @my_planets[m[2]][:targets] = []\n left_planets = @my_planets.select { |id, p| p[:rearness].nil? }\n end\n else\n @win_flag = true\n puts \"We win! (planets #: #{left_planets.size} / #{@my_planets.size})\"\n return\n end\n end\n\n while ! left_planets.empty?\n left_planets.each do |id, p|\n neighbors = @map['planets'][id]['neighbors'].reject { |n| my_planets[n[0]][:rearness].nil? }\n next if neighbors.empty? # Very important! Used to be a bug!!!\n nearest_neighbor = neighbors.map { |n| [ n[0], my_planets[n[0]][:rearness] + n[1] ] }.min_by { |n| n[1] }\n @my_planets[id][:targets] = nearest_neighbor[0]\n @my_planets[id][:rearness] = nearest_neighbor[1]\n @max_rearness = [@max_rearness, nearest_neighbor[1]].max\n end\n\n my_planets = @my_planets\n left_planets = @my_planets.select { |id, p| p[:rearness].nil? }\n # puts \"# of my planets: #{left_planets.size} / #{@my_planets.size}\"\n end\n end", "def set_chamber_done(grid, chamber)\n (0..chamber.height - 1).each do |j|\n (0..chamber.width - 1).each do |i|\n grid[chamber.grid_y + j][chamber.grid_x + i].show_base_background = true\n end\n end\nend", "def loadWildBitmaps\n if @battle.wildBattle?\n # wild battle bitmaps\n @battle.pbParty(1).each_with_index do |pkmn, i|\n next if !@sprites[\"pokemon_#{i*2 + 1}\"]\n @sprites[\"pokemon_#{i*2 + 1}\"].setPokemonBitmap(pkmn, false)\n @sprites[\"pokemon_#{i*2 + 1}\"].tone = Tone.new(-255, -255, -255, -255)\n @sprites[\"pokemon_#{i*2 + 1}\"].visible = true\n end\n # renders databoxes\n for m in [email protected](1).length\n next if !@sprites[\"dataBox_#{m*2 + 1}\"]\n @sprites[\"dataBox_#{m*2 + 1}\"].render\n end\n end\n # initialize Player battler 0 when follower enabled\n if !EliteBattle.follower(@battle).nil? && !@safaribattle\n pkmn = @battlers[EliteBattle.follower(@battle)].pokemon\n @sprites[\"pokemon_#{EliteBattle.follower(@battle)}\"].setPokemonBitmap(pkmn, true)\n @sprites[\"pokemon_#{EliteBattle.follower(@battle)}\"].tone = Tone.new(-255, -255, -255, -255)\n @sprites[\"pokemon_#{EliteBattle.follower(@battle)}\"].visible = true\n @sprites[\"dataBox_#{EliteBattle.follower(@battle)}\"].render\n end\n end", "def clear_small_wall\n for row_i in 1...@height - 1\n for column_i in 1...@width - 1\n total_wall = count_adjacent_wall(row_i, column_i)\n\n if @map[row_i][column_i] == @WALL\n if total_wall < 2\n @map[row_i][column_i] = @FLOOR\n next\n end\n end\n end\n end\n end", "def dont_be_in_check(final_spots,current_king)\n invalid = []\n final_spots.each do |spot|\n y = spot[0]\n x = spot[1]\n\n play_board = Marshal.load(Marshal.dump(@board))\n play_board[@piece.y_position][@piece.x_position] = 0\n play_board[y][x] = @piece.player_id\n\n if @piece.type == \"King\"\n invalid << spot if current_king.if_king_move_in_check?(play_board,y,x).length > 0\n else\n invalid << spot if current_king.if_check?(play_board).length > 0\n end\n end\n return final_spots - invalid\n end", "def initialize_board\n # Building out white pieces\n (0..7).each do |x|\n Pawn.create(is_black: false, x_position: x, y_position: 1, game_id: id, user_id: user_id_white, status: 'active')\n end\n\n Rook.create(is_black: false, x_position: 0, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Rook.create(is_black: false, x_position: 7, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Knight.create(is_black: false, x_position: 1, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Knight.create(is_black: false, x_position: 6, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Bishop.create(is_black: false, x_position: 2, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Bishop.create(is_black: false, x_position: 5, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n King.create(is_black: false, x_position: 4, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Queen.create(is_black: false, x_position: 3, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n # Building out the black pieces\n (0..7).each do |x|\n Pawn.create(is_black: true, x_position: x, y_position: 6, game_id: id, user_id: user_id_black, status: 'active')\n end\n\n Rook.create(is_black: true, x_position: 0, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Rook.create(is_black: true, x_position: 7, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Knight.create(is_black: true, x_position: 1, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Knight.create(is_black: true, x_position: 6, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Bishop.create(is_black: true, x_position: 2, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Bishop.create(is_black: true, x_position: 5, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n King.create(is_black: true, x_position: 4, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Queen.create(is_black: true, x_position: 3, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n end", "def try_to_mark_sunk\n matches = {}\n @sunk.each do |sz|\n @known.each do |x,y,v|\n next unless v == :hit\n matches[sz] ||= []\n would_ship_fit_in_location?(x, y, :across, sz, 0).eql?(sz) and\n matches[sz].push([x, y, :across])\n would_ship_fit_in_location?(x, y, :down, sz, 0).eql?(sz) and\n matches[sz].push([x, y, :down])\n end\n end\n\n matches.each do |sz, q|\n if q.size == @sunk.select { |s| s == sz }.size\n q.each do |entry|\n mark_sunk(sz, *entry)\n end\n @sunk -= [sz]\n end\n end\n end", "def _empty_hud_white_bar\n b = Bitmap.new(1, 12)\n (1..6).each {|i| b.fill_rect(0, i-1, 1, 14-i*2, Color.new(40*i/3, 40*i/3, 40*i/3))}\n return b\n end", "def setup_board\n (1..64).each do |location|\n @@piece_locations[location] = {\"type\" => \" \", \"number\" => nil, \"color\" => nil}\n end\n\n # Black Pieces\n @@piece_locations[1] = {\"type\" => \"rook\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[2] = {\"type\" => \"knight\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[3] = {\"type\" => \"bishop\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[4] = {\"type\" => \"queen\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[5] = {\"type\" => \"king\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[6] = {\"type\" => \"bishop\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[7] = {\"type\" => \"knight\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[8] = {\"type\" => \"rook\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n (1..8).each do |col|\n @@piece_locations[col + 8] = {\"type\" => \"pawn\", \"number\" => col, \"color\" => \"black\", \"moved\" => false}\n end\n\n # White Pieces\n @@piece_locations[57] = {\"type\" => \"rook\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[58] = {\"type\" => \"knight\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[59] = {\"type\" => \"bishop\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[60] = {\"type\" => \"queen\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[61] = {\"type\" => \"king\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[62] = {\"type\" => \"bishop\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[63] = {\"type\" => \"knight\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[64] = {\"type\" => \"rook\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n (1..8).each do |col|\n @@piece_locations[col + 48] = {\"type\" => \"pawn\", \"number\" => col, \"color\" => \"red\", \"moved\" => false}\n end\n end", "def clear\n 1.upto(@gsize) do |j|\n 1.upto(@gsize) do |i|\n stone = @ban[j][i]\n stone.group.clear if stone.group\n end\n end\n # Collect all the groups and put them into @garbage_groups\n @killed_groups.shift # removes @@sentinel\n @merged_groups.shift # removes @@sentinel\n @garbage_groups.concat(@killed_groups)\n @garbage_groups.concat(@merged_groups)\n @killed_groups.clear\n @killed_groups.push(@@sentinel)\n @merged_groups.clear\n @merged_groups.push(@@sentinel)\n @num_groups = 0\n @history.clear\n end", "def computer_places_piece!(brd)\n danger = danger_line(brd)\n\n if danger\n sub_hash = brd.select { |key, value| danger.include? key }\n square = sub_hash.select { |key, value| value == INITIAL_MARKER }.keys.first\n brd[square] = COMPUTER_MARKER\n else\n square = empty_squares(brd).sample\n brd[square] = COMPUTER_MARKER\n end\nend", "def prune_free_list\n i = 0\n while i < @free_rectangles.size\n j = i + 1\n while j < @free_rectangles.size\n if is_contained_in?(@free_rectangles[i], @free_rectangles[j])\n @free_rectangles.delete_at(i)\n i -= 1\n break\n end\n if is_contained_in?(@free_rectangles[j], @free_rectangles[i])\n @free_rectangles.delete_at(j)\n else\n j += 1\n end\n end\n i += 1\n end\n end", "def bleach_empty_uvhp()\n plates = find_all_uvhp.select{|plate| plate.empty?}\n show do\n title \"Bleach Unverified Hydra #{\"Plate\".pluralize(plates.size)}\"\n plates.each do |plate|\n note \"Bleach plate #{plate.id} with 10% dissociation medium\"\n plate.mark_as_deleted\n end\n end if plates.any?\n end", "def draw_tiles(tile_bag)\n until tiles.length == 7\n tiles.concat(tile_bag.draw_tiles(1)) #because draw_tiles returns an array\n\n end\n end", "def setup_rem_state\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n c = @acts[2] || 100\n c = c/100.0 if c.integer?\n if area_flag\n target_array.each do |t|\n if chance(c)\n t.remove_state(@acts[1])\n get_scene.tsbs_redraw_status(t)\n end\n end\n return\n end\n return unless target\n if chance(c)\n target.remove_state(@acts[1])\n get_scene.tsbs_redraw_status(target)\n end\n end", "def drop_all_the_way\n if @game.is_running?\n ran = @current_block.drop_by_one\n ran2 = @current_block2.drop_by_one\n @current_pos1.each{|block| block.remove}\n @current_pos2.each{|block| block.remove}\n while ran\n @score += 1\n ran = @current_block.drop_by_one\n end\n while ran2\n @score += 1\n ran2 = @current_block2.drop_by_one\n end\n draw\n store_current\n if !game_over?\n next_piece\n next_piece2\n end\n @game.update_score\n draw\n end\n end", "def update_player_map\n @map.tiles[@location.first][location.second].seen = true\n #corners\n @map.tiles[@location.first + 1][@location.second - 1].seen = true\n @map.tiles[@location.first - 1][@location.second - 1].seen = true\n @map.tiles[@location.first + 1][@location.second + 1].seen = true\n @map.tiles[@location.first - 1][@location.second + 1].seen = true\n #cardinal directions\n @map.tiles[@location.first][@location.second + 1].seen = true\n @map.tiles[@location.first][@location.second - 1].seen = true\n @map.tiles[@location.first - 1][@location.second].seen = true\n @map.tiles[@location.first + 1][@location.second].seen = true\n\n #TODO Uncomment\n if !(@map.tiles[@location.first][location.second].monsters.empty?)\n here = @map.tiles[@location.first][location.second]\n #20% chance of monster appearing\n monster_outcome = Random.rand(here.monsters.size * 5)\n if (monster_outcome < here.monsters.size)\n system(\"clear\")\n battle(self, here.monsters[monster_outcome])\n end\n end\n end", "def bc_remove_layout_1(bc, path, barclamp)\n filelist = File.join BARCLAMP_PATH, \"#{bc}-filelist.txt\"\n if File.exist? filelist \n files = [ filelist ]\n File.open(filelist, 'r') do |f|\n f.each_line { |line| files << line }\n end\n FileUtils.rm files\n merge_nav barclamp, false\n merge_sass barclamp, bc, path, false\n puts \"Barclamp #{bc} UNinstalled\" if DEBUG\n end\n end", "def update_backdrops\n $game_temp.backdrop.looping_position_check(@back1_sprite.bitmap, true)\n $game_temp.backdrop.looping_position_check(@back2_sprite.bitmap, false)\n if TSBS::Looping_Background\n @back1_sprite.ox = -$game_temp.backdrop.screen_x1 \n @back2_sprite.ox = -$game_temp.backdrop.screen_x2 \n @back1_sprite.oy = -$game_temp.backdrop.screen_y1 \n @back2_sprite.oy = -$game_temp.backdrop.screen_y2\n else\n @back1_sprite.x = $game_temp.backdrop.screen_x1\n @back2_sprite.x = $game_temp.backdrop.screen_x2\n @back1_sprite.y = $game_temp.backdrop.screen_y1\n @back2_sprite.y = $game_temp.backdrop.screen_y2\n end\n @back1_sprite.zoom_x = @back1_sprite.zoom_y = $game_temp.backdrop.zoom_1\n @back2_sprite.zoom_x = @back2_sprite.zoom_y = $game_temp.backdrop.zoom_2\n if backdrop_changed?\n Graphics.freeze if $game_temp.backdrop.trans_flag\n @backdrop_name1 = $game_temp.backdrop.name_1\n @backdrop_name2 = $game_temp.backdrop.name_2\n @back1_sprite.bitmap = Cache.battleback1(@backdrop_name1)\n @back2_sprite.bitmap = Cache.battleback2(@backdrop_name2)\n if TSBS::Looping_Background\n $game_temp.backdrop.looping_position_check(@back1_sprite.bitmap, true)\n $game_temp.backdrop.looping_position_check(@back2_sprite.bitmap, false)\n @back1_sprite.ox = -$game_temp.backdrop.screen_x1 \n @back1_sprite.oy = -$game_temp.backdrop.screen_y1 \n @back2_sprite.ox = -$game_temp.backdrop.screen_x2 \n @back2_sprite.oy = -$game_temp.backdrop.screen_y2\n else\n center_sprite(@back1_sprite)\n center_sprite(@back2_sprite)\n end\n name = $game_temp.backdrop.transition\n name = \"Graphics/System/\" + name unless name.empty?\n if $game_temp.backdrop.trans_flag\n Graphics.transition($game_temp.backdrop.duration,name,\n $game_temp.backdrop.trans_vague) \n end\n $game_system.backdecor_refresh[:notrans] = false if \n $imported[:TSBS_BattleDecor]\n end\n end", "def check_for_stuck_jobs\n Job.incomplete.each do |job|\n if job.stuck_chunks?\n job.priority = 50\n job.save!\n job.resend_stuck_chunks \n elsif job.stuck_packing?\n job.send_pack_request\n end\n end\n end", "def set_pieces\n\t\t(0..7).each do |row|\n\t\t\tcase row\n\t\t\twhen 0\n\t\t\t\tplace_special_pieces(row, :white)\n\t\t\twhen 1\n\t\t\t\tplace_pawns(row, :white)\n\t\t\twhen 6\n\t\t\t\tplace_pawns(row, :black)\n\t\t\twhen 7\n\t\t\t\tplace_special_pieces(row, :black)\n\t\t\tend\n\t\tend\n\tend", "def tick!\n to_die = []\n to_live = []\n\n @cells.each do |row|\n row.each do |cell|\n\n # Add up the number of 'alive' neighbouring cells\n live_neighbour_count = neighbours(cell.x, cell.y).select { |n| n.alive? }.count\n\n if cell.alive? and (live_neighbour_count < 2 || live_neighbour_count > 3)\n to_die << cell\n elsif cell.dead? and live_neighbour_count == 3\n to_live << cell\n end\n end\n end\n\n to_die.each { |cell| cell.die! }\n to_live.each { |cell| cell.live! }\n end", "def draw_board_start\n #Places the pawns\n 8.times do |x|\n @b[x][1] = @WP\n @b[x][6] = @BP\n end\n #white, on bottom, the opaque pieces\n @b[0][0] = @WR; @b[7][0] = @WR\n @b[1][0] = @WK; @b[6][0] = @WK\n @b[2][0] = @WB; @b[5][0] = @WB\n @b[3][0] = @WQ\n @b[4][0] = @WKg\n #black, on top, the filled in pieces\n @b[0][7] = @BR; @b[7][7] = @BR\n @b[1][7] = @BK; @b[6][7] = @BK\n @b[2][7] = @BB; @b[5][7] = @BB\n @b[3][7] = @BQ\n @b[4][7] = @BKg\n \n #TESTING PIECES HERE\n\n\n draw_board\n end", "def refresh\n # test on changes in the inner structure of $game_party.actors\n if $BlizzABS.actors.any? {|actor|\n actor.battler(true) == nil && $game_party.actors[actor.index] != nil ||\n actor.battler(true) != $game_party.actors[actor.index]}\n # if caterpillar is on\n if $game_system.caterpillar\n # store old array, create 2 new arrays\n old, tmp, $BlizzABS.actors = $BlizzABS.actors, [], []\n # for each old actor\n old.each {|a|\n # if battler exists and in party\n if a.battler(true) != nil && a.battler(true).index != nil &&\n a.battler(true).index < BlizzABS::Config::MAX_PARTY\n # add actor on position\n $BlizzABS.actors[a.battler(true).index] = a\n end}\n # for the rest of the old actors\n (old - $BlizzABS.actors).each {|a|\n # if not in party\n if a.battler(true) != nil && (a.battler(true).index == nil ||\n a.battler(true).index >= BlizzABS::Config::MAX_PARTY)\n # remove battler\n a.battler = nil\n end\n # add actor\n tmp.push(a)}\n # fill the empty places between\n $BlizzABS.actors.each_index {|i|\n $BlizzABS.actors[i] = tmp.shift if $BlizzABS.actors[i] == nil}\n # add rest of actors\n $BlizzABS.actors += tmp\n # for each actor\n $BlizzABS.actors.each {|a|\n # if no battler assigned, but in the party is a battler\n if a.battler(true) == nil && $game_party.actors[a.index] != nil\n # assign battler\n a.battler = $game_party.actors[a.index]\n end}\n else\n # set the correct battlers\n $BlizzABS.actors.each_index {|i|\n $BlizzABS.actors[i].battler = $game_party.actors[i]}\n end\n end\n # each actor\n $BlizzABS.battlers.each {|actor|\n # refresh spriteset\n actor.refresh(true)\n # set to return to caterpillar for convenience\n actor.ai.state = AI::Return\n # if actor not valid\n unless actor.valid?\n # reset action\n actor.ai.target = nil\n actor.ai.act.set\n end}\n # set new $game_player character\n $game_player = player\n end", "def initial_piece_placements\n self.grid.each_with_index do |row, row_idx|\n row.each_with_index do |cell, cell_idx|\n pos = [row_idx, cell_idx]\n if pos.all? {|coord| coord.even?} || pos.all? {|coord| coord.odd?}\n if row_idx < 3\n self[pos] = Piece.new(self, pos, :white)\n elsif row_idx >= 5\n self[pos] = Piece.new(self, pos, :black)\n end\n end\n end\n end\n end", "def check_horizontal_bingos\n @horizontal.each do |k, v|\n if size == v\n @num_bingos += 1\n circles.each do |circle|\n if circle.position_y == k\n update_circle(circle)\n end\n end\n end\n end\n end", "def map_tile_nocavern(tile)\n (-1..1).all? { |dx| (-1..1).all? { |dy|\n next if not t = tile.offset(dx, dy)\n tm = t.tilemat\n if !t.designation.hidden\n t.designation.flow_size < 4 and tm != :FROZEN_LIQUID\n else\n t.shape_basic == :Wall and (tm == :STONE or tm == :MINERAL or tm == :SOIL or tm == :ROOT)\n end\n } }\n end", "def check_vertical_bingos\n @vertical.each do |k, v|\n if size == v\n @num_bingos += 1\n circles.each do |circle|\n if circle.position_x == k\n update_circle(circle)\n end\n end\n end\n end\n end", "def placehuman(boat, row, col, grid) \n\t\tif grid == 1\n\t\t\tgrid = $shot_at\n\t\telse\n\t\t\tgrid = $comp\n\t\tend\n\n\t\tcount = 0\n\t\thold = 0\n\t\tdone = 0\n\t\trow = row -1\n\t\tcol = col -1\n\t\t$error = 0\n\t\tuntil done == 1\n\t\t\thold = 0\n\t\t\tif $vert == true\n\t\t\t\tif row + boat > 9\n\t\t\t\t\t$error = 1\n\t\t\t\telse\n\t\t\t\t\tboat.times do |x|\n\t\t\t\t\t\thold = hold + grid[row + x][col]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tif col + boat > 9\n\t\t\t\t\t$error = 1\n\t\t\t\telse\t\n\t\t\t\t\tboat.times do |x|\n\t\t\t\t\t\thold = hold + grid[row][col + x]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif hold == 0 && $error == 0\n\t\t\t\tif $vert == true\n\t\t\t\t\tboat.times do |x|\n\t\t\t\t\t\tgrid[row + x][col] = 1\n\t\t\t\t\tend\n\t\t\t\telse \n\t\t\t\t\tboat.times do |x|\n\t\t\t\t\t\tgrid[row][col + x] = 1\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tdone = 1\n\t\t\telse\n\t\t\t\tdone = 1\n\t\t\t\t$error =1\n\t\t\tend\n\t\tend\n\tend", "def water_tiles\n puts @area.select { |_, v| '~|'.include?(v) }.keys.select { |_, y| y <= @max_y }.count\n puts @area.select { |_, v| v == '~' }.keys.select { |_, y| y <= @max_y }.count\n end", "def draw_board\n @board = stack do\n fill rgb(210,105,30)\n rect BOARD_SQUARE_POS[:board_start], BOARD_SQUARE_POS[:board_start], BLOCK_DIMENTION*CHECKERS_WIDTH , BLOCK_DIMENTION*CHECKERS_HEIGHT\n fill rgb(245,222,179)\n CHECKERS_HEIGHT.times do |x|\n CHECKERS_WIDTH.times do |y|\n rect BOARD_SQUARE_POS[:board_start] + BLOCK_DIMENTION*x, BOARD_SQUARE_POS[:board_start] + BLOCK_DIMENTION*y, BLOCK_DIMENTION,BLOCK_DIMENTION if x.even? && y.even?\n rect BOARD_SQUARE_POS[:board_start] + BLOCK_DIMENTION*x, BOARD_SQUARE_POS[:board_start] + BLOCK_DIMENTION*y, BLOCK_DIMENTION,BLOCK_DIMENTION if !x.even? && !y.even?\n end\n end\n end\nend", "def process(num_blacks, num_whites) \r\n if (!@zero_response_code_found)\r\n # we can only get blacks during this phase of all 4's same color however we will count them later during mask phase\r\n # keep track of number of exact matches\r\n if num_blacks > 0\r\n # save for later processing when we go to half/half mode\r\n @safe_array << @current_color\r\n #puts \"color_count[#{@current_color}] = #{@color_count[@current_color]}\"\r\n #puts \"AA\"\r\n else\r\n @zero_response_code_found = true\r\n @half_half_color = @current_color\r\n #puts \"BB\"\r\n end # if num_blacks\r\n else\r\n if @num_correct_colors_found < 4\r\n #puts \"SEARCHING FOR FINAL 4\"\r\n if @three_of_a_kind_check\r\n# need to worry about 3 and 4 of a kind scenario\r\n# during find zero-response phase - if we encounter 3 or 4 of a kind, we need to set a flag, perhaps my hash is doing that\r\n# or modify the hash.\r\n# but then the problem comes about after finding the zero-response, during the finding the half-half phase. during this\r\n# phase it is not possible to determine if there are 3 or 4 of a kind due to the arrangemnet of the pattern.\r\n# one way to solve this for both zero-response phase and half-half phase is by having another 3 of a kind safe array\r\n# if during zero-response phase, we encounter 4 of a kind. game will auto end?\r\n# if during zero-response phase, we encounter 3 of a kind, then submit color into three_of_a_kind array and into safe_array\r\n# to be used later by guess method. guess will normally count the 2 on the right side, but not count the left. the \r\n# three_of_a_kind array and the half_half_left mode will count the 1 remaining color of a three of a kind\r\n# if during half-half phase, we encounter 2 of a kind(specifically, 2 blacks, or 1 black/1 white, but not 2 whites, process\r\n# will normally count the 2 colors. However there is a chance that there is a 3rd occurrence of the color that we can not see\r\n# due to the half-half-right pattern. Therefore we need to add the color to the three_of_a_kind array which causes guess to\r\n# change the pattern to\r\n# [color, color, no-response-color, no-response-color]\r\n\r\n# process needs to compensate for double counting whites (only count blacks) during 3_of_a_kind_check and for double\r\n# counting doubles. (only count blacks when blacks+whites=3, whites have already been counted, and when blacks+whites==2,\r\n# this scenario has already been counted)\r\n\r\n# I need to save the state of the initial three_of_a_kind compare in order to determine how to count the three of a kind\r\n# correctly.\r\n #puts \"THREE OF A KIND CHECK IN PROCESS method\"\r\n previous_num_blacks, previous_num_whites = @half_half_result[@current_color]\r\n if previous_num_blacks == 2\r\n #puts \"PREVIOUS_NUM_BLACKS == 2\"\r\n @num_correct_colors_found += num_blacks\r\n num_blacks.times { @match_left << @current_color }\r\n elsif previous_num_blacks == 1 && previous_num_whites == 1\r\n # for this case we need to make sure we don't double count\r\n #puts \"PREV BLACKS==1 && PREV WHITES==1\"\r\n if num_blacks == 2\r\n @num_correct_colors_found += 1\r\n @match_left << @current_color\r\n end\r\n end\r\n #puts \"Num of blacks = #{num_blacks} Previous num blacks = #{previous_num_blacks}\"\r\n #puts \"Num of whites = #{num_whites} Previous num whites = #{previous_num_whites}\"\r\n # always get out of three of a kind mode\r\n @three_of_a_kind_check = false\r\n\r\n else # if @three_of_a_kind_check\r\n # add to running total of found numbers so we can get to next phase of algo\r\n @num_correct_colors_found += (num_blacks + num_whites) ##### THIS WILL NEED TO CHANGE WHEN THREE OF A KIND LOGIC ADDED\r\n\r\n # following section is used in half-half section either by processing\r\n # new colors or by processing old colors from the safe array\r\n # if found blacks we found it on the right and update color_count for current_color\r\n # officially counting blacks and whites are only done while in half-half mode\r\n # note that safe_array take dequeue priority when it is not empty. see guess above\r\n if num_blacks > 0\r\n num_blacks.times { @match_right << @current_color } \r\n end\r\n # if found whites we found it on the left and update color_count for current_color \r\n if num_whites > 0\r\n num_whites.times { @match_left << @current_color } \r\n end \r\n # this info is necessary when doing the reverse half_half compare to see if there are three/four of a kind\r\n @half_half_result[@current_color] = [num_blacks, num_whites]\r\n # during this phase we can't know if there are 2 or 3 of the current color, so we need to do a reverse_half_half\r\n # check if there are 2 blacks or (1 black + 1 white)\r\n @three_of_a_kind_check_array << @current_color if (num_blacks == 2 || (num_blacks==1 && num_whites==1))\r\n #puts \"CC\"\r\n end # if @three_of_a_kind_mode else\r\n else\r\n # Scenarios are as follows for final code\r\n # L1,L2,R1,R2 \r\n # (4W) -> L2,L1,R2,R1\r\n # (2W2B) -> L1,L2,R2,R1 or L2,L1,R1,R2\r\n # (0W) -> pattern found\r\n #puts \"DD\"\r\n @final_four_whites = num_whites # used by guess\r\n\r\n end\r\n\r\n end # if !@zero_response...\r\n\r\n end", "def mineTile(col, row)\r\n\r\n @endGame && return #Returns if the games has already been lost.\r\n @tile[col][row].revealed && return #Returns if the tile is already revealed.\r\n\r\n #Checks if the tile is not an ore.\r\n if (@tile[col][row].tier == 0)\r\n adjacent = @tile[col][row].adjacent\r\n\r\n if (adjacent == 0)\r\n floodFill(col,row) #If the tile has an adjacent value of 0, performs a flood fill to uncover the surrounding tiles.\r\n else\r\n @tile[col][row].revealed = true #Marks the tile as revealed.\r\n @hiddenCount-=1\r\n\r\n #Re-renders the button so it displays the new text.\r\n old = @tile[col][row].btn\r\n newStyle = old.style.dup\r\n old.parent.before(old) do\r\n @tile[col][row].btn = button adjacent.to_s, newStyle###\r\n end\r\n old.remove\r\n end\r\n else #Tile is an ore.\r\n @tile[col][row].revealed = true #Marks the tile as revealed.\r\n @hiddenCount -= 1\r\n tileTier = @tile[col][row].tier\r\n\r\n #Updates the experience\r\n @experienceInt += 2**(tileTier-1)\r\n @experience.clear { para(\"EXP: \" + @experienceInt.to_s, @style_stats) }\r\n\r\n #Gets the amount of experience needed to reach the next tier.\r\n if (@tierInt < @tiers)\r\n if (@tierInt == @tiers - 1)\r\n required = 1 #If the player is on the penultimate tier then 100% of previous ores need to be uncovered.\r\n else\r\n #Interpolates the upper and lower bound to get the required percentage for the next tier.\r\n required = @expLowerBound + (@tierInt * ((@expUpperBound - @expLowerBound) / @tiers))\r\n end\r\n\r\n\r\n #Gets the total amount of available experience for the player's current tier.\r\n expCount = 0\r\n (0..@tierInt-1).each do |tier|\r\n expCount += @tierExp[tier]\r\n end\r\n requiredExperience = (required * expCount).to_i\r\n\r\n #f the player's experience is greaster or equal to the required experience for the next tier, then the player advances a tier.\r\n if (@experienceInt >= requiredExperience)\r\n @tierInt+=1\r\n @tier.clear{ para(\"TIER: \" + @tierInt.to_s, @style_stats) }\r\n end\r\n\r\n end\r\n\r\n #If the ore is a higher tier than the player's tier then the durability decreases depending on the difference in tier values.\r\n if (tileTier > @tierInt)\r\n @durabilityInt -= 2 * (tileTier - @tierInt)\r\n #If the durability is 0 or less then the player loses.\r\n if (@durabilityInt <= 0)\r\n @durabilityInt = 0\r\n @endState.clear { subtitle(\"You Lose!\", @style_endgame) }\r\n @endGame = true\r\n end\r\n @durability.clear { para(\"DUR: \" + @durabilityInt.to_s, @style_stats) }\r\n end\r\n\r\n #Updates the ore count for the mined ore.\r\n reduceOreCount(tileTier-1)\r\n\r\n #Re-renders the button to displays the ore.\r\n old = @tile[col][row].btn\r\n newStyle = old.style.dup\r\n old.parent.before(old) do\r\n @tile[col][row].btn = button(@ore[tileTier-1].to_s, newStyle)###\r\n end\r\n old.remove\r\n\r\n end\r\n\r\n #Checks if all tiles have been uncovered. If so gthe game was been won.\r\n if (@hiddenCount <= 0)\r\n @endState.clear { subtitle(\"You Win!\", @style_endgame) }\r\n @endGame = true\r\n end\r\n\r\nend", "def pbSurfacing\n return if !$PokemonGlobal.diving\n return false if $game_player.pbFacingEvent\n surface_map_id = nil\n GameData::MapMetadata.each do |map_data|\n next if !map_data.dive_map_id || map_data.dive_map_id != $game_map.map_id\n surface_map_id = map_data.id\n break\n end\n return if !surface_map_id\n move = :DIVE\n movefinder = $Trainer.get_pokemon_with_move(move)\n if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_DIVE,false) || (!$DEBUG && !movefinder)\n pbMessage(_INTL(\"Light is filtering down from above. A Pokémon may be able to surface here.\"))\n return false\n end\n if pbConfirmMessage(_INTL(\"Light is filtering down from above. Would you like to use Dive?\"))\n speciesname = (movefinder) ? movefinder.name : $Trainer.name\n pbMessage(_INTL(\"{1} used {2}!\",speciesname,GameData::Move.get(move).name))\n pbHiddenMoveAnimation(movefinder,false)\n $PokemonGlobal.current_diving = nil\n pbFadeOutIn {\n $game_temp.player_new_map_id = surface_map_id\n $game_temp.player_new_x = $game_player.x\n $game_temp.player_new_y = $game_player.y\n $game_temp.player_new_direction = $game_player.direction\n $PokemonGlobal.surfing = true\n $PokemonGlobal.diving = false\n pbUpdateVehicle\n $scene.transfer_player(false)\n surfbgm = GameData::Metadata.get.surf_BGM\n (surfbgm) ? pbBGMPlay(surfbgm) : $game_map.autoplayAsCue\n $game_map.refresh\n }\n\n return true\n end\n return false\nend", "def lost?\n all_bombs = @grid.flatten.select { | tile | tile.value == BOMB }\n all_bombs.all? { | tile | tile.revealed }\n end", "def insert_garbage!(cnt)\n @board.insert_garbage!(cnt)\n end", "def grid\n if 1 <= poster_slot && poster_slot <= 66\n offset = 1\n number_per_row = 11\n total_rows = 6\n group = 1\n row = total_rows - 1 - (poster_slot - offset).div(number_per_row)\n col = (poster_slot - offset).modulo(number_per_row)\n col = number_per_row - 1 - col if row.even? # invert\n elsif 67 <= poster_slot && poster_slot <= 96\n offset = 67\n number_per_row = 15\n group = 2\n total_rows = 2\n row = total_rows - 1 - (poster_slot - offset).div(number_per_row)\n col = (poster_slot - offset).modulo(number_per_row)\n col = number_per_row - 1 - col if row.even? # invert\n elsif 97 <= poster_slot && poster_slot <= 144\n offset = 97\n number_per_row = 6\n group = 3\n total_rows = 8\n row = total_rows - 1 - (poster_slot - offset).div(number_per_row)\n col = (poster_slot - offset).modulo(number_per_row)\n col = number_per_row - 1 - col if row.odd? # invert\n elsif 145 <= poster_slot && poster_slot <= 184\n offset = 145\n number_per_row = 20\n group = 4\n total_rows = 2\n row = total_rows - 1 - (poster_slot - offset).div(number_per_row)\n col = (poster_slot - offset).modulo(number_per_row)\n col = number_per_row - 1 - col if row.even? # invert\n elsif 185 <= poster_slot && poster_slot <= 284\n offset = 185\n number_per_row = 25\n group = 5\n total_rows = 4\n row = total_rows - 1 - (poster_slot - offset).div(number_per_row)\n col = (poster_slot - offset).modulo(number_per_row)\n col = number_per_row - 1 - col if row.even? # invert\n elsif 285 <= poster_slot && poster_slot <= 314\n offset = 285\n number_per_row = 5\n group = 6\n total_rows = 6\n row = (poster_slot - offset).div(number_per_row)\n col = (poster_slot - offset).modulo(number_per_row)\n col = number_per_row - 1 - col if row.even? # invert\n else\n return nil\n end\n Grid.new(col, row, group)\n end", "def remove_test_bugs\n [Hive::Color[:white],Hive::Color[:black]].collect.each{|color|\n $game.bugs[color].each{|bug| \n bug.sides.each{|side|\n # Make any bugs that touched the Hive::Tester forget it ever existed.\n side.bug = false if side.bug.class.name == 'Hive::Tester'\n }\n # Delete the Hive::Tester bug itself.\n bug = false if bug.class.name == 'Hive::Tester'\n }\n }\n end" ]
[ "0.68826956", "0.6176632", "0.60074663", "0.5950315", "0.59274405", "0.56083107", "0.5607654", "0.5589487", "0.55878806", "0.5583212", "0.557387", "0.5555022", "0.5516676", "0.54984146", "0.5469843", "0.5462013", "0.5425392", "0.5418034", "0.54143566", "0.5407485", "0.54019773", "0.5384945", "0.5362752", "0.535043", "0.53476804", "0.5329099", "0.5312854", "0.53088766", "0.53032863", "0.52877456", "0.52832943", "0.52725357", "0.52690697", "0.5267921", "0.5266563", "0.52654016", "0.52632123", "0.5262752", "0.5253391", "0.52491534", "0.52360815", "0.52346134", "0.520673", "0.51845914", "0.5178333", "0.51737607", "0.5170664", "0.51661015", "0.5164159", "0.5152661", "0.5137808", "0.51336014", "0.5132171", "0.51299125", "0.5126388", "0.51194906", "0.51151854", "0.5113619", "0.51020414", "0.5100395", "0.5098012", "0.5093691", "0.5085923", "0.50814104", "0.50810707", "0.5072898", "0.50698316", "0.5068763", "0.5060968", "0.506092", "0.50470454", "0.503695", "0.5032785", "0.50251776", "0.5024925", "0.5024259", "0.50235486", "0.50222486", "0.50118726", "0.50107723", "0.5002125", "0.4993804", "0.49929386", "0.4991398", "0.4987657", "0.4985693", "0.4983804", "0.49836853", "0.4982561", "0.4974734", "0.49737936", "0.4972982", "0.49720848", "0.4969472", "0.4966618", "0.49653623", "0.49630013", "0.49618483", "0.4957883", "0.4957136" ]
0.72770035
0
add_suffix "somefile.xml", "_1234" => somefile_1234.xml""
def add_suffix filename, suffix parts = filename.split("\.") base = parts[0..-2] parts2 = base << suffix << parts[-1] fn = parts2.join(".") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_suffix\n file_name.split('.').last \n end", "def suffix(num)\n namespace + '_suffix_' + num.to_s\n end", "def suffix; end", "def suffix; end", "def suffix; end", "def suffix; end", "def suffix; end", "def formatted_filename(name, version, suffix, extension)\n name.gsub(\"#{version}_\", \"\").chomp(File.extname(name)) + \"_#{suffix}.#{extension}\"\n end", "def add_filename_suffix(filename, suffix)\n f = filename.split(File::SEPARATOR)\n # If the filename is '.' or '..' add the suffix to the parent path,\n # otherwise add it to the basename\n i = %w[. ..].include?(f[-1]) ? -2 : -1\n # Split the basename around the file extension and prepend the suffix\n # to the extension\n if f[i]\n file_ext = f[i].rpartition(File.extname(f[i]))\n file_ext[1] = \"#{suffix}#{file_ext[1]}\"\n f[i] = file_ext.join\n end\n # Reconstruct the filename, preserving any trailing path separator\n f.push('') if filename.end_with?(File::SEPARATOR)\n File.join(f)\n end", "def changeFileExtensionTo(filename, extension)\n return \"#{File.basename(filename, File.extname(filename))}.#{extension}\"\nend", "def prefix_suffix\n ext = extname\n [basename(ext), ext]\n end", "def make_file_name aExtension, *aWords #:nodoc:\n aWords.join(' ').to_file_name.ext(aExtension)\n end", "def add_filename_prefix(filename, prefix)\n filename = filename.rpartition(File.basename(filename))\n filename[1] = \"#{prefix}#{filename[1]}\"\n filename.join\n end", "def archive_file_suffix\n raise NotImplementedError\n end", "def safe_filename(id, suffix = \"\")\n filename = \"#{id}_#{Time.now.getutc}_#{suffix}\"\n filename.gsub(/\\s+/, '_').gsub(/[^0-9A-Za-z_\\.]/, '')\n end", "def processed_filename(filename, extension = nil)\n suffix = \"_#{model.filename_token}\"\n max_processed_filename_size = max_processed_filename_size(suffix)\n filename_without_suffix = filename.slice 0, max_processed_filename_size\n \"#{filename_without_suffix.parameterize}#{suffix}\".tap { |s| s << \".#{extension}\" if extension }\n end", "def make_identifier_suffix( url )\n\t\treturn url.to_s.gsub( /\\W+/, '-' )\n\tend", "def create_file_name(ext = nil)\n ext ||= self.ext\n return name unless ext\n \"#{unique_key}.#{ext}\"\n end", "def create_unique_filename( text_value, suffix = DateTime.now.strftime(\"_%Y%m%d_%H%M\") )\n text_value.gsub(/[òàèùçé\\^\\!\\\"\\'£\\$%&?\\.\\,;:§°<>]/,'').gsub(/[\\s|]/,'_').gsub(/[\\\\\\/=]/,'-') + suffix\n end", "def append(suffix)\n lambda do |rec, acc|\n acc.collect! { |v| v + suffix }\n end\n end", "def file_name(name)\n name.to_s.gsub(/-/, \"_\").underscore\n end", "def changeExt(filename, newext) \n\tuseme = filename.dup\n\treturn useme if ['.', '..'].include? filename\n\tif newext != ''\n\t\tnewext = (newext =~ /^\\./) ? newext : (\".\" + newext)\n\tend\n\tuseme.sub!(%r(([^/\\\\])\\.[^./\\\\]*$)) { $1 + newext } || useme + newext\nend", "def new_ending(sourcefile, type)\n #sourcefile.sub(/\\.[^.]+$/, \".#{type.to_s}\")\n \"#{sourcefile}.#{type.to_s}\"\nend", "def suffixize(lang)\n lang.blank? ? \"\" : \"_#{lang}\"\n end", "def proper_filename(file)\n file.gsub(/[^\\w]/,'_')\n end", "def suffix(str) # 'str' points to the same string, \"John\", as 'name' does (at he start of this method).\n str << \"son\" # Ruby Docs: \"str << obj → str\".\nend", "def rename_out fileName\r\n name = fileName.split('/')[-1]\r\n name = name.split('\\\\')[-1]\r\n return \"Code_From_#{name.gsub(/\\./,'_')}.html\"\r\n end", "def archive_file_suffix\n case @roll_period\n when :weekly\n @file_date.strftime(\"week-of-%Y-%m-%d\").to_s\n when :monthly\n @file_date.strftime(\"%Y-%m\").to_s\n else\n @file_date.strftime(\"%Y-%m-%d\").to_s\n end\n end", "def full_filename_fu(filename)\n version_prefix = \"#{version_name}_\"\n filename = filename.gsub(version_prefix, \"\")\n ext = nil\n basename = filename.gsub /\\.\\w+$/ do |s|\n ext = s; ''\n end\n \"#{basename}_#{version_name}#{ext}\"\n end", "def make_filename(file_index)\n return SAVE_PATH + SAVE_FILE_NAME.gsub(/\\{ID\\}/i) { (file_index + 1).to_s }\n end", "def basename_without_ext; end", "def filename(record, file)\n original = \"#{file.basename}.#{file.extension}\"\n write_attribute(:original_filename, original)\n ext = file.suffix.nil? || file.suffix == :original ? file.extension : file.suffix\n \"#{application_for_offering.id.to_s}-#{title.gsub(/[\\s,\\.\\\\\\/\\*\\?\\%\\:\\|\\\"\\'\\<\\>]?/,'')}.#{ext}\"\n end", "def genfilename(ext, time = Time.now)\n time.strftime(\"%Y-%m-%d\") + ext\n end", "def suffix\n @suffix || parse_and_return(:@suffix)\n end", "def underscore_filename_for(path)\n File.basename(path, '.*').\n gsub(/[^a-zA-Z0-9]/, '_').\n concat(File.extname(path))\n end", "def versioned_filename(base, first_suffix='.00')\n suffix = nil\n filename = base\n while File.exists?(filename)\n suffix = (suffix ? suffix.succ : first_suffix)\n filename = base + suffix\n end\n return filename\n end", "def add_csv_suffix_if_needed(filename)\n filename += (filename.end_with? '.csv') ? '' : '.csv'\n end", "def create_filename(prev_name)\n prev_name[/\\d+$/] ? prev_name.next : prev_name + '02'\n end", "def filename\n \"#{original_filename_without_extension.parameterize}_#{model.filename_token}#{original_extension}\" if original_filename\n end", "def basename(suffix = T.unsafe(nil)); end", "def cmd_suffix(cmd)\n if cmd =~ VALID_NAME\n cmd\n else\n mod = cmd.gsub(/\\W+/,'_')\n mod.gsub!(/^_+/, '')\n mod.gsub!(/_+$/, '')\n mod\n end\n end", "def add_underscore_to(file)\n f = Pathname.new(file)\n if f.basename.to_s =~ /^_/\n file\n else\n \"#{f.dirname}/_#{f.basename}\"\n end\n end", "def build_filename\n \"%s/%s_%06d.json\" % [dir, prefix, index]\n end", "def add_directional_suffix key, dir\n\n # Nothing to do if the direction isn't provided.\n return key if dir.blank?\n\n # Need to convert the key to a string since it is likely\n # a symbol that has been provided.\n dir_key = ''\n dir_key << key.to_s\n dir_key << '-'\n dir_key << dir.to_s\n dir_key.to_sym\n end", "def file_name\n \"#{@file_name}.#{extension}\"\n end", "def make_filename(file_index)\r\n return \"Save#{file_index + 1}.rxdata\"\r\n end", "def sub_ext(ext); end", "def f(prefix, suffix)\r\n \r\n end", "def add_ext(str,ext)\n ( str.strip=~/\\.#{ext}$/ ) ? str.strip : \"#{str.strip}.#{ext}\"\n end", "def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end", "def ext_name(name)\r\n return name.to_s if name.kind_of?(Symbol)\r\n return name.gsub(/\\s/, '_')\r\n end", "def add_extension(path); end", "def export_file_name(extension)\n \"CompSage Report on #{@survey.job_title.gsub(/[\\\\\\/:\\*\\?\"<>\\|]/,' ')}.#{extension}\"\n end", "def add_permalink_suffix(template, permalink_style); end", "def extension_with_delimiter\n File.extname @filename\n end", "def strip_filename_suffix(filename, suffix)\n f = filename.rpartition(File.extname(filename))\n f[0] = strip_suffix(f[0], suffix)\n f.join\n end", "def name_attribute(suffix = nil)\n extra = suffix ? \"_#{suffix}\" : ''\n %(name=\"#{name_base}#{extra}\")\n end", "def +(suffix)\n suffix = suffix.to_s\n\n call + (suffix.start_with?(' ') ? '' : ' ') + suffix\n end", "def with_file_extension(name, entry_type)\n return name unless File.extname(name.to_s).empty?\n\n extension = extension_for_type(entry_type)\n extension ? \"#{ name }.#{ extension }\" : name\n end", "def filename(count = 0)\n \"_paypal_#{count.to_s.rjust(4, '0')}.iif\"\nend", "def suffix\n nil\n end", "def add_extension(extension)\n @parts[-1] += extension\n self\n end", "def make_filename(filename)\n ### Making the filename\n bname=File.basename(filename,\".xml\")\n dname=File.dirname(filename)\n part=Array.new\n part=dname.split(\"/\")\n tmp1=String.new\n if (!(part.empty?)) then \n part.each{|ex| if (ex=~/^[0-9]/) then tmp1=ex end}\n end\n if (!(tmp1.empty?)) then \n newfilename=bname+\"_\"+tmp1\n else \n newfilename = bname\n end\n return newfilename\n end", "def make_filename(index)\n return sprintf(\"Save%02d.rvdata2\", index + 1) if index.is_a?(Fixnum)\n \"#{index}.rvdata2\"\n end", "def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present? \n end", "def valid_new_filename(file)\n new_file = file\n counter = 0\n while File.exist?(new_file) do\n counter += 1\n ext = File.extname(file)\n basename = file.split(ext).first\n new_file = \"#{basename}_#{counter}#{ext}\"\n end\n new_file\n end", "def rename_file\n\n end", "def to_name\n basename.to_s.sub extname, ''\n end", "def filename\n \"#{secure_token(10)+File.extname(original_filename)}\" if original_filename.present?\n end", "def base file, ext; return File.basename file, ext end", "def base file, ext; return File.basename file, ext end", "def bundle_resouce_file_name\n self.title.gsub(/\\s/,\"_\")\n end", "def filename\n @filename = \"#{secure_token}_#{split_extension(original_filename)}.#{file.extension}\" if original_filename.present?\n end", "def change_extension(file, new_extension)\n file.sub(/\\.[a-zA-Z0-9]+\\z/, new_extension)\n end", "def save_filename(id, ext=\"SAV\")\n \"CHRDAT#{id}.#{ext}\"\n end", "def file_name(s)\n s.gsub(/[\\s\\\\\\/]/, '_')\n end", "def add_suffixes(possible_id, suffix, iterations) # :nodoc:\n ids_with_suffixes = []\n iterations.to_i.times do\n ids_with_suffixes << possible_id + suffix.to_s\n suffix.succ!\n end\n\n ids_with_suffixes\n end", "def chop_extension filename\n filename.sub %r{\\.\\w+$}, \"\"\n end", "def source_suffix\n options[:source_suffix]\n end", "def filename\n \"#{folder_id}#{File.extname(super)}\"\n end", "def get_unique_file_name fname\n 100.times do |i|\n suffix = \"%03d\" % i\n extn = File.extname(fname)\n base = File.basename(fname, extn)\n # f = fname + '.' + suffix\n f = base + suffix + extn\n return f unless File.exist?(f)\n end\n\n timestamp = Time.now.strftime('%Y%m%d-%H%M%S')\n return fname + '.' + timestamp\nend", "def remove_suffix_to(piece_name)\n piece_name.tr(\"0-9\", \"\")\n end", "def original_filename(filename)\n /\\d+_\\d+_(.+)?/.match(filename.to_s)&.captures&.first\n end", "def original_filename(filename)\n /\\d+_\\d+_(.+)?/.match(filename.to_s)&.captures&.first\n end", "def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end", "def suffix\n Spree::Config.events.suffix\n end", "def rename_with_file_type(ori, nam)\n s = ori.split('.')\n nam + '.' + s[s.length - 1]\n end", "def file_name\n name.underscore\n end", "def replace_extname(path, extension)\n path.sub(/#{File.extname(path)[1..-1]}$/, extension)\n end", "def build_converted_file_name(source, from_lang, to_lang)\n # Get components of filename\n dirname = File.dirname(source)\n basename = File.basename(source, \".*\")\n extname = File.extname(source)\n\n # Blank out the from language\n basename.sub! Regexp.new(\"_#{from_lang}\", \"i\"), \"\"\n \n \"#{dirname}/#{basename}_#{to_lang}#{extname}\"\n end", "def generate_intended_filename_regex conf\n prefix = \"#{ conf['local_hostname'] }-\\\\d{4}_\\\\d{2}_\\\\d{2}\"\n case conf['type']\n when /dir/\n dir_part = conf['path'].sub(/\\//,'').gsub(/\\//,\"-\")\n return \"#{ prefix }-#{ dir_part }\\\\.tar\\\\.gz\"\n when /mys/\n db_part = conf['database']\n return \"#{ prefix }-#{ db_part }\\\\.sql\\\\.gz\"\n end\nend", "def unique_resource_name(build_option_name, suffix)\n normalised_name = build_option_name.downcase.gsub(/[^a-z]+/, '-')\n \"#{normalised_name}##{suffix}\"\n end", "def suffix\n name.scan(MetaDep::TEMPLATE_SUFFIX).flatten.first\n end", "def create_suffix(longurl,flag)\n ascii_value = ascii_value(longurl)\n if(flag == 1)\n ascii_value = ascii_value + rand(100..1000)\n end\n suffix = \"\"\n map_hash = \"ABCDEFGHIJKLMNO%PQRSTUVWXYZ0123&456789abcdefghi$jklmnopqrstuvwx*yz\" #base(66)\n while ascii_value!=0\n suffix += map_hash[ascii_value % 66]\n ascii_value = ascii_value/10\n end\n return suffix\n end", "def file_name_for(*args)\n \"%s.%s\" % [args.compact.join(self.class.thumbnail_separator), extension]\n end", "def extname( fn )\n ::File.extname(fn).tr('.', '')\n end", "def filename\n if original_filename\n uuid = UUIDTools::UUID.md5_create(UUIDTools::UUID_DNS_NAMESPACE, original_filename)\n extname = File.extname(original_filename)\n return \"#{uuid}#{extname}\"\n end\n end", "def append_without_prefix(string); end", "def java_file_name(prepend_path = false, append_extension = false)\n\t\tjfile_name = file_name\n\t\tjfile_name += \".java\" if append_extension\n\t\tjfile_name = JAVA_PATH + jfile_name if prepend_path\n\t\treturn jfile_name\n\tend" ]
[ "0.70290285", "0.69593513", "0.690518", "0.690518", "0.690518", "0.690518", "0.690518", "0.6796579", "0.6610421", "0.6555351", "0.65308225", "0.6454237", "0.6397575", "0.63385963", "0.63100404", "0.61908066", "0.61215705", "0.6119859", "0.60992366", "0.5972121", "0.5951897", "0.59469855", "0.59404993", "0.5937837", "0.59310275", "0.5926968", "0.59226406", "0.5913087", "0.59037757", "0.59033644", "0.5895481", "0.5874707", "0.58709705", "0.5855257", "0.5843084", "0.5838428", "0.5828941", "0.5826478", "0.58261126", "0.5803231", "0.5796818", "0.57707274", "0.5770607", "0.57573414", "0.57432306", "0.5741053", "0.5739388", "0.5723508", "0.5709967", "0.5703445", "0.5689605", "0.5686467", "0.567269", "0.56701624", "0.5667171", "0.56637657", "0.5661286", "0.56539524", "0.5644031", "0.5628684", "0.5618456", "0.5618294", "0.55991274", "0.5581855", "0.55643123", "0.5555092", "0.5549434", "0.5542496", "0.55421513", "0.5540422", "0.5540422", "0.5533431", "0.55290836", "0.5519236", "0.5518265", "0.55127054", "0.55119586", "0.5504202", "0.55035675", "0.54972637", "0.548951", "0.54855466", "0.54822147", "0.54822147", "0.5482046", "0.5472213", "0.546823", "0.54652345", "0.54598254", "0.5457887", "0.5454794", "0.5453573", "0.54522765", "0.5450786", "0.54454637", "0.5441761", "0.54390347", "0.54385257", "0.5419867" ]
0.76750684
1
hash defines key => value for updating template
def replace_strings(str, rhash) s = str.to_s return s if ! (s && rhash) rhash.each do |k,v| s.gsub!(k.to_s, v.to_s) end s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\n end", "def hash_template\n template = {}\n \n info.each do | key, value |\n template[key] = generate_structure( value )\n end\n \n template\n end", "def update_template(key, value)\n t = { key => value }\n raw = read_attribute(\"template\") \n d = raw.nil? ? {} : JSON.parse(raw) \n merged = d.deep_merge(t)\n self.template = JSON.generate(merged)\n self.save!\n end", "def hash(key); end", "def update(hash); end", "def hash\n model.hash + key.hash\n end", "def hash\n [fully_qualified_rel,\n tmpl.pattern,\n templated?].hash\n end", "def template_map\n \n end", "def key=(value); end", "def update_hash\n { :id => @id,\n :email => @email,\n :api_key => @api_key,\n :password => @password,\n :first_name => @first_name,\n :last_name => @last_name,\n :phone => @phone,\n :authority => ADMIN,\n :password_reset_key => @password_reset_key,\n :password_reset_sent_at => @password_reset_sent_at,\n :created_at => @created_at, :verified => @verified }\n end", "def hash_for(expression)\n\n end", "def key_template\n @key_template ||= [*name.downcase.split(\"::\"), \"%<id>d\"].join(\":\")\n end", "def update_item(hash, key, value)\n hash[key] = value\n p hash\nend", "def hash\n [fully_qualified_rel,\n raw_href,\n templated?].hash\n end", "def push(key, template)\n self[key.first][key.last] = template\n end", "def push(key, template)\n self[key.first][key.last] = template\n end", "def key=(key); end", "def change(hash); end", "def update\n @p.transaction do\n @p['hash'] = @hash\n end\n end", "def hash=(_arg0); end", "def hash\n @hash || @hash = (value.hash * -1)\n end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash\n end", "def hash\n end", "def hash\n end", "def test_hash_behavior\n t = DocTemplate.new fixture('test.docx')\n\n assert_equal 0, t.size\n\n t['key'] = 'value'\n assert_equal 'value', t['key']\n\n t.merge!({'another_key' => 'another_value'})\n assert_equal 'another_value', t['another_key']\n\n assert_equal 2, t.size\n t.clear\n assert_equal 0, t.size\n end", "def update\n return unless @hash\n begin\n lockf = File.open(@path+\".lock\", File::CREAT|File::RDWR, 0600)\n lockf.flock File::LOCK_EX\n f = File.open(@path+\".new\", File::CREAT|File::TRUNC|File::WRONLY, 0600)\n for k,v in @hash\n #f.printf \"%s=%s\\n\", CGI::escape(k), CGI::escape(String(Marshal.dump(v)))\n # Just supports bools and strings\n if v == true\n valueString = 'BT'\n elsif v == false\n valueString = 'BF'\n else\n valueString = 'S' + v.to_s\n end\n f.printf \"%s=%s\\n\", CGI::escape(k), CGI::escape(valueString)\n end\n f.close\n File.rename @path+\".new\", @path\n ensure\n f.close if f and !f.closed?\n lockf.close if lockf\n end\n end", "def shave_value(template)\n Mustache.render(template, binding)\n end", "def hash\n self.class.name.hash ^ @key.hash\n end", "def hash\n\t\tvalue.hash\n\tend", "def hash\r\n @_hash ||= _hash\r\n end", "def format(key, template)\n template.result(binding)\n end", "def update(item, new_q, hash)\n hash[item]=new_q\n puts hash\nend", "def key_map\r\n hash = {}\r\n hash['footer'] = footer\r\n hash['clicktrack'] = clicktrack\r\n hash['opentrack'] = opentrack\r\n hash['unsubscribe'] = unsubscribe\r\n hash['bcc'] = bcc\r\n hash['attachmentid'] = attachmentid\r\n hash['template'] = template\r\n hash\r\n end", "def order!(hash, template)\n ordered = ActiveSupport::OrderedHash.new\n\n template.each do |key|\n if hash[key]\n ordered[key] = hash[key]\n end\n end\n\n ordered\n end", "def rehash() end", "def hash()\n #This is a stub, used for indexing\n end", "def update(hash, item, qty)\n hash[item] = qty\nend", "def update(hash, item, qty)\n hash[item] = qty\nend", "def hvals(key); end", "def hvals(key); end", "def it_renders_template_to_hash(template,hash)\n tpl = Bldr::Template.new {template}\n result = tpl.render(Bldr::Node.new)\n result.should == jsonify(hash)\n end", "def will_create_new_hash(**hash)\n hash[:x] = 10 # Change\n p hash\n p hash.object_id \nend", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def render_function_hash(input_pair_array)\n hash = {};\n hash[:partial] = input_pair_array[0].to_s;\n if(!input_pair_array.empty?) #if this partial has inputs\n hash[:locals] = input_pair_array[1]; #put in hash\n end\n return hash;\n end", "def hash\n [fully_qualified_rel, raw_href, templated?].hash\n end", "def hash\n value.hash\n end", "def params=(hash); end", "def params=(hash); end", "def hash_key(*args, block)\n # TODO: can't be nested\n def_args = extract_definition_args_nameless(args)\n\n return unless check_when(def_args, @current_source)\n return unless version_wanted(def_args)\n\n @hash_key = field_value(def_args, block)\n # puts \"hash_key = #{@hash_key}\"\n end", "def update_quantity(input_hash, item, qty)\n# steps: use input item as key and input quantity as value\n# output: hash \n input_hash[item] = qty\n \nreturn input_hash\nend", "def autovivify( hash, key )\n\t\t\thash[ key ] = Hash.new( &Assemblage::DataUtilities.method(:autovivify) )\n\t\tend", "def update\n return unless @hash\n begin\n lockf = File.open(@path+\".lock\", File::CREAT|File::RDWR, 0600)\n lockf.flock File::LOCK_EX\n f = File.open(@path+\".new\", File::CREAT|File::TRUNC|File::WRONLY, 0600)\n for k,v in @hash\n f.printf \"%s=%s\\n\", CGI.escape(k), CGI.escape(String(Marshal.dump(v)))\n end\n f.close\n File.rename @path+\".new\", @path\n ensure\n f&.close\n lockf&.close\n end\n end", "def hash(*) end", "def output_hash; end", "def _key(*args); args.hash; end", "def create_hash(&block); end", "def create_hash(&block); end", "def template(value)\n keys = map.split('/')\n raise \"Cannot deal with an empty map!\" if keys.empty?\n res = value\n while !keys.empty? do\n res = {keys.pop => res}\n end\n res\n end", "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def hash\n self.class.hash ^ key_attributes.hash\n end", "def hash_key(name); end", "def hash\n @hash\n end", "def template(data = {})\n str = dup\n\n data.each do |key, value|\n str.gsub!(\":#{key}\", value.to_s)\n end\n\n str\n end", "def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end", "def put_static_value(key, value)\n\t\t\tput_section_value(TEMPLATE_DATA_KEY, key, value)\n\t\tend", "def hash\n swap\n scatter\n completed_string\n end", "def key_for(data)\n data.hash\n end", "def key=(_); end", "def key=(_); end", "def hash\n { hash: @hash, hashType: @hash_type }\n end", "def assign_hash(hash)\n super hash\n create_if_exists hash, 'title', 'de', name: :t_title\n create_if_exists hash, 'title', 'en', name: :t_title unless hash.key?('t_title')\n create_if_exists hash, 'title', name: :t_title unless hash.key?('t_title')\n\n create_if_exists hash, 'short', name: :t_short\n create_if_exists hash, 'keywords', 'de', name: :t_short\n create_if_exists hash, 'thesisType', name: :t_thesis_type\n create_if_exists hash, 'instituteName', 'de', name: :t_institute_name\n create_if_exists hash, 'instituteCode', name: :t_institute_code\n create_if_exists hash, 'facultyName', 'de', name: :t_faculty_name\n create_if_exists hash, 'facultyCode', name: :t_faculty_code\n create_if_exists hash, 'url', name: :detail_url\n\n create_if_exists hash, 'advisor', 'oid', name: :t_advisor_oid\n create_if_exists hash, 'advisor', 'familyName', name: :t_advisor_family_name\n create_if_exists hash, 'advisor', 'givenName', name: :t_advisor_given_name\n create_if_exists hash, 'advisor', 'prefixTitle', name: :t_advisor_prefix_title\n create_if_exists hash, 'advisor', 'postfixTitle', name: :t_advisor_postfix_title\n\n create_if_exists hash, 'assistant', 'oid', name: :t_assistant_oid\n create_if_exists hash, 'assistant', 'familyName', name: :t_assistant_family_name\n create_if_exists hash, 'assistant', 'givenName', name: :t_assistant_given_name\n create_if_exists hash, 'assistant', 'prefixTitle', name: :t_assistant_prefix_title\n create_if_exists hash, 'assistant', 'postfixTitle', name: :t_assistant_postfix_title\n end", "def put(key, value)\n \n end", "def build_template_params_hash(hash)\n @template_params.each_with_parent do |parent, key, value|\n next if value.blank? || key.blank?\n parent_name = set_fieldset_key(hash, parent, 'system_info')\n hash[parent_name][key] = value\n end\n end", "def hash\n @hash || calculate_hash!\n end", "def update_item(hash, item, qty)\n hash[ item ] = qty\nend", "def geohash(key, member); end", "def update\n # don't need to update; hash is shared\n end", "def update(item, new_q, hash)\n hash[item]=new_q\nend", "def hash\n @hash.hash\n end", "def add_item(hash, new_key, new_value)\n hash[new_key] = new_value\n p hash\nend", "def hash()\n #This is a stub, used for indexing\nend", "def template_cache_key\n context[:template_cache_key]\n end", "def key_map\r\n hash = {}\r\n hash['status'] = status\r\n hash['value'] = value\r\n hash['updatedAt'] = updated_at\r\n hash\r\n end", "def store_template_to_redis( template_body )\n return self.redis_connector.set( redis_key, template_body )\n end" ]
[ "0.69471455", "0.6941039", "0.6740843", "0.6571374", "0.6505845", "0.63546234", "0.6279233", "0.6157564", "0.61505085", "0.6125955", "0.61016256", "0.6077773", "0.60672235", "0.60131186", "0.5999108", "0.5999108", "0.594819", "0.59454894", "0.594437", "0.59335303", "0.59194696", "0.5912368", "0.5912368", "0.5912368", "0.5912368", "0.5912368", "0.5912368", "0.5912368", "0.5912368", "0.5912368", "0.5912368", "0.58986163", "0.58986163", "0.58986163", "0.58983713", "0.5886178", "0.587603", "0.5871308", "0.58694243", "0.5866512", "0.5857054", "0.58391", "0.58342326", "0.58330876", "0.58284444", "0.582012", "0.5818926", "0.5818926", "0.5817748", "0.5817748", "0.58134323", "0.580554", "0.57964385", "0.57964385", "0.57964385", "0.57964385", "0.57964385", "0.57964385", "0.57964385", "0.5794734", "0.57893467", "0.57879895", "0.57790184", "0.57790184", "0.5762225", "0.57517093", "0.5751596", "0.57235986", "0.5723166", "0.57200134", "0.5716454", "0.57146186", "0.57146186", "0.5709797", "0.57040894", "0.57040894", "0.5692008", "0.56899416", "0.5688315", "0.5685815", "0.56823754", "0.5681358", "0.5670696", "0.56644267", "0.5656937", "0.5656937", "0.5655981", "0.5647082", "0.5639795", "0.5634142", "0.5632647", "0.56292325", "0.56267405", "0.5624635", "0.5618452", "0.56120616", "0.5588904", "0.558353", "0.5575542", "0.55709743", "0.5563056" ]
0.0
-1
deberia haber seguido convencion REST (create x los 2)
def like choosed = User.find(params[:choosed]) Interaction.create(user_id: current_user.id, choosed: choosed.id, like: true) choosed.interactions.each do |interaction| if interaction.choosed == current_user.id Match.create(user_one_id: current_user.id, user_two_id: choosed.id) redirect_to match_path return end end redirect_to search_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end", "def enviar_transaccion(trx,idfactura)\n begin\n logger.debug(\"...Inicio enviar transaccion\")\n info = InfoGrupo.where('id_banco= ?',trx['destino']).first\n url = 'http://integra'+info[:numero].to_s+'.ing.puc.cl/api/pagos/recibir/'+trx[0]['_id'].to_s\n #url = 'http://localhost:3000/api/pagos/recibir/'+trx['_id'].to_s\n request = Typhoeus::Request.new(\n url,\n method: :get,\n params:{\n idfactura: idfactura\n },\n headers: { ContentType: \"application/json\"})\n response = request.run\n logger.debug(\"...Fin enviar transaccion\")\n return {:validado => true, :trx => trx}\n rescue => ex\n Applog.debug(ex.message,'enviar_transaccion')\n return {:validado => false, :trx => trx}\nend\nend", "def create\n params.permit(:intitule, :estObligatoire, :nombreDeCaractere, :ordre, :sondage_id)\n ajout = QuestionOuverteService.instance.creerQuestionOuverte(params[:intitule], params[:estObligatoire], params[:nombreDeCaractere], params[:ordre], params[:sondage_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def enviar_factura(factura)\n begin\n logger.debug(\"...Iniciar enviar factura\")\n info = InfoGrupo.where('id_grupo = ?',factura['cliente']).first\n url = 'http://integra'+info[:numero].to_s+'.ing.puc.cl/api/facturas/recibir/'+factura['_id'].to_s\n #url = 'http://localhost:3000/api/facturas/recibir/'+factura['_id'].to_s\n request = Typhoeus::Request.new(\n url,\n method: :get,\n headers: { ContentType: \"application/json\"})\n response = request.run \n logger.debug(\"...Fin enviar factura\")\n return {:validado => true, :factura => factura}\n rescue => ex\n Applog.debug(ex.message,'enviar_factura')\n return {:validado => false, :factura => factura}\n end\nend", "def create\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n \n #Cobro en el banco\n client = Savon::Client.new(\"http://localhost:3001/servicios/wsdl\")\n tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n total_pagar = params[:orden][:total]\n pago = '<Message>\n <Request>\n <numero_tdc>'+tdc.numero+'</numero_tdc>\n <nombre_tarjetahabiente>'+tdc.tarjetahabiente+'</nombre_tarjetahabiente>\n <fecha_vencimiento>'+tdc.mes_vencimiento+'/'+tdc.ano_vencimiento+'</fecha_vencimiento>\n <codigo_seguridad>'+tdc.codigo+'</codigo_seguridad>\n <tipo_tarjeta>'+tdc.tipo+'</tipo_tarjeta>\n <direccion_cobro>'+tdc.direccion+'</direccion_cobro>\n <total_pagar>'+total_pagar+'</total_pagar>\n <cuenta_receptora>'+cuenta_receptora+'</cuenta_receptora>\n </Request>\n </Message>'\n #response = client.request :verificar_pago, body: { \"value\" => pago } \n #if response.success?\n # data = response.to_hash[:verificar_pago_response][:value][:response].first\n # @respuesta = XmlSimple.xml_in(data)\n #end\n\n #NAMESPACE = 'pagotdc'\n #URL = 'http://localhost:8080/'\n #banco = SOAP::RPC::Driver.new(URL, NAMESPACE)\n #banco.add_method('verificar_pago', 'numero_tdc', 'nombre_tarjetahabiente', 'fecha_vencimiento', 'codigo_seguridad', 'tipo_tarjeta', 'direccion_cobro', 'total_pagar', 'cuenta_receptora')\n #\n \n #respuesta = banco.verificar_pago(tdc.numero, tdc.tarjetahabiente, tdc.mes_vencimiento.to_s+'/'+tdc.ano_vencimiento.to_s, tdc.codigo, tdc.tipo, params[:orden][:total], tdc.direccion)\n \n if true #respuesta.ack.eql?(0)\n params[:orden][:cliente_id] = usuario_actual.id\n params[:orden][:total] = Seleccion.precio_total(usuario_actual.id)\n params[:orden][:fecha_entrega] = \"0000-00-00\"\n @orden = Orden.new(params[:orden])\n \n if @orden.save\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n @venta = Venta.new(:producto_id=>p.id, \n :orden_id=>@orden.id,\n :categoria_id=>p.categoria_id, \n :cantidad=>seleccion.cantidad,\n :costo=>p.precio)\n @venta.save\n end\n \n Seleccion.vaciar_carro(usuario_actual.id)\n respond_to do |format|\n format.html { redirect_to ver_ordenes_path, notice: 'Orden generada correctamente.' }\n end\n else\n respond_to do |format|\n format.html { render action: \"new\" }\n end\n end\n else\n respond_to do |format|\n format.html { render action: \"new\", notice: respuesta.mensaje }\n end\n end\n end", "def create\n\n puts request.body.string\n\n if request.body.string.include? %q[\"id\"]\n render json: %q[{\"error\": \"No se puede crear usuario con id\"}], status: 400\n else\n @usuario = Usuario.new(usuario_params)\n #Tuve que hacerlo asi, pq por alguna razon no me dejaba de la forma tradicional!\n #@usuario = Usuario.new\n #@usuario.usuario = params[:usuario]\n #@usuario.nombre = params[:nombre]\n #@usuario.apellido = params[:apellido]\n #@usuario.twitter = params[:twitter]\n\n\n respond_to do |format|\n if @usuario.save\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n #format.html { render :new }\n format.json { render json: @usuario.errors, status: 404}# status: :unprocessable_entity }\n end\n end\n end\n end", "def enviar_despacho(idfactura,cliente)\n begin \n logger.debug(\"...Inicio enviar despacho\")\n info = InfoGrupo.where('id_grupo = ?',cliente).first\n url = 'http://integra'+info[:numero].to_s+'.ing.puc.cl/api/despachos/recibir/'+idfactura.to_s\n #url = 'http://localhost:3000/api/despachos/recibir/'+idfactura.to_s\n request = Typhoeus::Request.new(\n url,\n method: :get,\n headers: { ContentType: \"application/json\"})\n response = request.run\n logger.debug(\"...Fin enviar despacho\")\n return {:validado => true}\n rescue => ex\n Applog.debug(ex.message,'enviar_despacho')\n return {:validado => false}\n end\nend", "def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end", "def recibir\n #obtener la orden de compra con el id que nos envía el otro grupo.\n id = params[:id]\n id_store_reception = JSON.parse(request.body.read.to_s)\n id_store_reception = id_store_reception[\"id_store_reception\"]\n @result = HTTParty.get(OC_URI + 'obtener/' + id, :query => {}, :header => OPT)\n puts @result\n #Reviso si el id ingresado es valido para que oc no tire error\n if !@result[0]['created_at'].nil? then\n oc = @result[0]\n cliente = oc[\"cliente\"]\n cliente = IDS[cliente].to_s\n #una vez recibida la orden de compra hay que ver si la aceptamos o no\n #de momento no me preocuparía de ver si podemos comprar otras materias primas para producir y cumplir ordenes de comora\n if accept_general?(oc)\n accept(id, cliente)#esto le avisa a la api del profe y al otro grupo que aceptamos la oc\n @purchase_order = PurchaseOrder.new(oc) #si aceptamos la OC la guardamos en nuestro modelo.\n @purchase_order.save\n fact = createInvoice(oc[\"_id\"])\n #se le manda al grupo comprador la factura que acabamos de crear y nuestra cuenta de banco\n HTTParty.put(GURI + cliente + \".ing.puc.cl/invoices/\" + fact[0][\"_id\"], headers: GOPT, body:{\"bank_account\" => CTA})\n #poner en cola\n order = Order.new(oc:oc['_id'], total:Integer(oc['cantidad']), sku:oc['sku'], due_date:oc['fechaEntrega'], client:oc['cliente'], price:Integer(oc['precioUnitario']), destination: id_store_reception, state:\"accepted\")\n order.save\n render json: {'Message': \"Orden creada, aceptada y facturada\"}\n\n else\n reject(id, '', cliente)\n render json: {'Message': \"Orden rechazada\"}\n end\n else\n render status: 500, json:{\n Message: 'Declined: failed to process order, we need more details'\n }\n end\n end", "def create\n params.permit(:intituleSondage, :descriptionSondage, :categorie_id, :administrateur_id)\n ajout = SondageService.instance.creerNouveauSondage(params[:intituleSondage], params[:descriptionSondage], params[:categorie_id], params[:administrateur_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\nend", "def update_gen\n respond_to do |format|\n # En etiquetas pone usuario actual por omision\n if (!params[:caso][:caso_etiqueta_attributes].nil?)\n params[:caso][:caso_etiqueta_attributes].each do |k,v|\n if (v[:usuario_id].nil? || v[:usuario_id] == \"\")\n v[:usuario_id] = current_usuario.id\n end\n end\n end\n\n # En familiares si falta crear trelacion_persona para personas\n # autocompletadas los crea\n if caso_params[:victima_attributes]\n caso_params[:victima_attributes].each do |iv, v|\n if v[:persona_attributes] &&\n v[:persona_attributes][:persona_trelacion1_attributes]\n v[:persona_attributes][:persona_trelacion1_attributes].each do |it, t|\n if t && (!t[:id] || t[:id] == '') &&\n t[:personados_attributes] &&\n t[:personados_attributes][:id] &&\n t[:personados_attributes][:id].to_i > 0 &&\n Msip::Persona.where(\n id: t[:personados_attributes][:id].to_i).count == 1\n pt_e = Msip::PersonaTrelacion.where(\n persona1: v[:persona_attributes][:id],\n persona2: t[:personados_attributes][:id]\n )\n if !pt_e\n pt = Msip::PersonaTrelacion.create({\n persona1: v[:persona_attributes][:id],\n persona2: t[:personados_attributes][:id]\n })\n pt.save!(validate: false)\n params[:caso][:victima_attributes][iv][:persona_attributes][:persona_trelacion1_attributes][it][:id] = pt.id\n else\n params[:caso][:victima_attributes][iv][:persona_attributes][:persona_trelacion1_attributes][it][:id] = pt_e[0].id\n end\n end\n end\n end\n end\n end\n\n if params[:_msip_enviarautomatico] == \"1\"\n params_finales = caso_params.except(\n :caso_etiqueta_attributes,\n :caso_anexo_attributes,\n :caso_fuenteprensa_attributes,\n :caso_fotra_attributes,\n :caso_presponsable_attributes\n )\n else\n params_finales = caso_params\n end\n\n if @caso.update(params_finales)\n\n\n if registrar_en_bitacora\n Msip::Bitacora.agregar_actualizar(\n request, :caso, :bitacora_cambio, \n current_usuario.id, params, 'Sivel2Gen::Caso',\n @caso.id\n )\n end\n\n #if request.params[:enviarFichaCaso] == '1'\n # head :no_content\n # return\n #end\n\n notificacion = 'Caso actualizado.'\n if Sivel2Gen::Caso.count > MAX_CASOS_REFRESCA_AUTOMATICO\n notificacion += \" Por la cantidad de casos \"+\n \" debe Refrescar para notar \" +\n \" el cambio en el listado de casos\"\n end\n format.html {\n redirect_to @caso,\n notice: notificacion\n }\n format.json { head :no_content }\n format.js { head :no_content }\n else\n format.html {\n if session[:capturacaso_acordeon]\n render 'editv', layout: 'application'\n else\n render 'edit', layout: 'application'\n end\n }\n format.json { render json: @caso.errors,\n status: :unprocessable_entity }\n format.js { render json: @caso.errors,\n status: :unprocessable_entity }\n end\n end\n begin\n @conscasocount = Conscaso.count\n if @conscasocount <= MAX_CASOS_REFRESCA_AUTOMATICO\n puts Conscaso.refresca_conscaso\n end\n rescue\n puts Conscaso.refresca_conscaso\n @conscasocount = Conscaso.count\n end\n end", "def createResouce(doc, msg_from)\n\n begin\n \n puts \"Creating\"\n \n path = \"\"\n params = {}\n headers = {}\n \n \n context, path = findContext(doc, path)\n \n # Adding the actual parameters according the context\n if context\n\n # if device context is not given -> creating new user\n if context == :userdevice \n params = parseUserData(doc, params)\n \n # if user-group -context and name for the group is given -> creating new group\n elsif context == :user_group\n params = {}\n \n # if user-group-member -context and name for member is given -> adding new member to group\n elsif context == :user_group_member\n params = {}\n \n # if device-context and name for the device is given -> creating new device\n elsif not doc.find_first('//xmpp2rest/user/device/files') and devicename\n params = parseDeviceData(doc, params)\n \n # If files element was given -> sending filelist\n elsif doc.find_first('//xmpp2rest/user/device/files')\n puts \"..files\"\n params, path = parseFileslist(doc, params, path)\n \n # Error\n else\n raise Exception.new(\"Context was not found!\")\n end\n \n \n \n # System-based context\n else\n puts \"System context:\"\n if doc.find_first('//xmpp2rest/metadata')\n puts \"..metadata\"\n metadata_type = (doc.find_first('//xmpp2rest/metadata').attributes.get_attribute(\"metadata_type\")) ? doc.find_first('//xmpp2rest/metadata').attributes.get_attribute(\"metadata_type\").value : nil\n puts metadata_type.to_s\n if not metadata_type\n raise Exception.new(\"Malformed path: metadata-element must contain metadata_type -attribute!\")\n else\n path += \"/metadatatype/#{metadata_type}\"\n end\n end\n end\n\n\n httpAndNotify(path, params, msg_from, :put)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n\n end", "def create\n @payment = Payment.new(payment_params)\n url = 'http://localhost/servicio/Despachador.php'\n parametros = {params: {\n \"servicio\" => 8,\n \"numtarjeta\" => payment_params[:card_number],\n \"cedtitular\" => \"V#{payment_params[:identification]}\",\n \"mesexpiracion\" => payment_params[:expiration_month],\n \"annoexpiracion\" => payment_params[:expiration_year],\n \"codseguridad\" => payment_params[:security_code],\n \"monto\" => payment_params[:amount]\n }}\n\n # \"servicio\" => 4,\n # \"numtarjeta\" => 1234567898765432,\n # \"cedtitular\" => 20296530,\n # \"mesexpiracion\" => 8,\n # \"annoexpiracion\" => 17,\n # \"codseguridad\" => 301,\n # \"monto\" => 3000\n # }}\n resultado = ActiveSupport::JSON.decode(RestClient.get(url, parametros))\n respond_to do |format|\n if resultado[\"exito\"] == \"true\"\n\n if @payment.save\n puts \"entro al save\"\n format.html { redirect_to new_organization_path, notice: 'Su pago ha sido procesado satisfactoriamente' }\n format.json { render :show, status: :created, location: @payment }\n else\n format.html { render :new }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n\n else\n format.html { render :new , notice: 'Hubo un problema con su solicitud, consulte a su banco para mas informacion'}\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create_api\n\n @url = Url.new(:url => params[:url])\n\n if @url.save\n url_hash = Hash.new\n\n url_hash[:short_url] = root_url.to_s() + \"urls_api/\" + (@url.id).to_s(36)\n url_hash[:url] = @url.url\n\n render :json => url_hash.to_json\n end\n\n end", "def create\n @something = Something.new(params[:something])\n\n respond_to do |format|\n if @something.save\n \n @user = @something.username\n @passw = @something.password\n @from = ActiveSupport::Base64.encode64(@something.from)\n @to = ActiveSupport::Base64.encode64(@something.to)\n @amount = @something.amount\n @info = ActiveSupport::Base64.encode64(@something.info)\n\n @image = Net::HTTP.get_response(URI.parse(URI.encode(\"http://unbank.jelastic.dogado.eu/bank/ibank/api/b2b/doTransaction?from=#{@from}&to=#{@to}&amount=#{@amount}&details=#{@info}&user=#{@user}&password=#{@passw}\"))).body\n \n format.html { render action: \"index\", notice: 'Something was successfully updated.' }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @something.errors, status: :unprocessable_entity }\n\n end\n\n end\n\n end", "def create\n #Parámetros permitidos.\n pago_params\n\n #Asignación de variables.\n fact = params[:pago][:factura_id]\n fecha = params[:pago][:fechapago]\n factura = Factura.find_by(id: fact)\n\n #Editar pago.\n @pago = Pago.new\n @pago.factura_id = fact\n @pago.fechapago = fecha\n @pago.monto = factura.total\n\n respond_to do |format|\n if @pago.save\n #Inserción en la cuenta corriente cliente por el haber.\n ctactecli = Ctactecli.find_by(cliente_id: factura.cliente_id)\n detallectactecli = Detallectactecli.new\n detallectactecli.ctactecli_id = factura.cliente_id\n detallectactecli.fechadetalle = Date.today\n detallectactecli.tipodetalle = 'Crédito por factura'\n detallectactecli.haber = factura.total\n detallectactecli.save\n ctactecli.saldo = ctactecli.saldo - factura.total\n ctactecli.save\n\n format.json { render :show, status: :created, location: @pago }\n puts'Pago guardado'\n #format.html { redirect_to @pago, notice: 'Pago was successfully created.' }\n else\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n puts'Pago no guardado'\n #format.html { render :new }\n end\n end\n end", "def new\n \n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n respond_to do |format|\n unless @selecciones.empty?\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n @orden = Orden.new(:direccion_entrega=>usuario_actual.direccion)\n t = Time.now\n fecha = t.strftime(\"%Y-%m-%d\")\n client = Savon::Client.new(\"http://192.168.1.121/DistribuidorFIF/webservices/servicio.php?wsdl\")\n preorden = \"<solicitud_pedido>\n <num_orden>001</num_orden>\n <nombre_comercio>Tukiosquito</nombre_comercio>\n <fecha_solicitud>\"+fecha.to_s+\"</fecha_solicitud>\n <nombre_cliente>\"+usuario_actual.nombre+\" \"+usuario_actual.apellido+\"</nombre_cliente>\n <direccion_comercio>\n <avenida>Sucre</avenida>\n <calle>-</calle>\n <edificio_casa>CC Millenium</edificio_casa>\n <local_apt>C1-15</local_apt>\n <parroquia>Leoncio Martinez</parroquia>\n <municipio>Sucre</municipio>\n <ciudad>Caracas</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_comercio>\n <direccion_destino>\n <avenida>Santa Rosa</avenida>\n <calle>Tierras Rojas</calle>\n <edificio_casa>Villa Magica</edificio_casa>\n <local_apt>69</local_apt>\n <parroquia> </parroquia>\n <municipio>Zamora</municipio>\n <ciudad>Cua</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_destino>\"\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n preorden = preorden+\"\n <articulo>\n <id>\"+p.id.to_s+\"</id>\n <descripcion>\"+p.descripcion+\"</descripcion>\n <peso>\"+p.peso.to_s+\"</peso>\n <cantidad>\"+seleccion.cantidad.to_s+\"</cantidad>\n <precio>\"+p.precio.to_s+\"</precio>\n </articulo>\"\n end\n preorden = preorden+\"</solicitud_pedido>\"\n response = client.request :ejemplo, body: { \"value\" => preorden } \n if response.success? \n respuesta = response.to_hash[:ejemplo_response][:return]\n datos = XmlSimple.xml_in(respuesta)\n end\n\n @precio_envio = datos[\"num_orden\"][0]\n #@arreglo = XmlSimple.xml_in('')\n #@xml = XmlSimple.xml_out(@arreglo, { 'RootName' => 'solicitud_pedido' })\n #url = 'http://192.168.1.101/Antonio/tukyosquito/proyecto/servicio/servicio.php'\n #cotizacion = SOAP::RPC::Driver.new(url)\n #cotizacion.add_method('obtener','asd')\n #tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n #@respuesta = cotizacion.obtener('123')\n format.html # new.html.erb\n else\n format.html { redirect_to carrito_path, notice: 'No tiene productos agregados al carro de compras para generar una orden.' }\n end\n end\n end", "def create\n\n @respuestum = Respuestum.new(respuestum_params)\n # @comentario = Comentario.find(params[:id])\n #nombre = params[:nombre]\n #correo = params[:correo]\n #comentario = params[:comentario]\n\n #@respuestum = Respuestum.create(:nombre => string, :correo => string, :descripcion => text,:comentario_id => @comentario.id)\n\n respond_to do |format|\n if @respuestum.save\n format.html { redirect_to comentarios_url}\n format.json { render :show, status: :created, location: @respuestum }\n else\n format.html { render :new }\n format.json { render json: @respuestum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def putFactura(oc)\n\n facturax= JSON.parse(HTTP.headers(:\"Content-Type\" => \"application/json\").put(\"http://\"+ $url +\"/facturas/\", :json => {:oc => oc}).to_s, :symbolize_names => true)\n return facturax\n end", "def POST; end", "def create\n @recurso_servidor = RecursoServidor.new(recurso_servidor_params)\n\n respond_to do |format|\n if @recurso_servidor.save\n format.html { redirect_to @recurso_servidor, notice: 'Recurso solicitado com sucesso.' }\n format.json { render :show, status: :created, location: @recurso_servidor }\n else\n format.html { render :new }\n format.json { render json: @recurso_servidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n params[:descuento_b] == \"1\" ? @descuento = params[:pago][:precio].to_f*Estudio.find(params[:pago][:tipo_id]).descuento : @descuento = 0\n \n subtotal = params[:pago][:precio].to_f - @descuento\n @pago = Pago.create(\n :forma_pago => params[:pago][:forma_pago],:factura => params[:pago][:factura],\n :folio_factura => params[:pago][:folio_factura],:total => subtotal ,:precio => params[:pago][:precio],\n :descuento => @descuento)\n \n respond_to do |format|\n if @pago.save\n operation = Operation.find(params[:pago][:operation_id])\n operation.update_attributes(:pago_id => @pago.id)\n cita = Cita.find_by_operation_id(params[:pago][:operation_id])\n cita.pagar_estudio_pago!\n flash[:notice] = 'Pago was successfully created.'\n format.html { redirect_to(:action => 'show', :id => @pago.id ,:paciente_id => params[:pago][:paciente_id],\n :operation_id => params[:pago][:operation_id]) }\n format.xml { render :xml => @pago, :status => :created, :location => @pago }\n\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pago.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @recursorevision = @solicitud.recursosrevision.new(params[:recursorevision])\n @recursorevision.institucion_id = current_user.institucion_id\n @recursorevision.solicitud_id = @solicitud.id\n @recursorevision.usuario_id = current_user.id\n\n #limpiamos fecha pasandola a formato MM/DD/YYYY\n @recursorevision.fecha_presentacion = fix_date(params[:recursorevision][:fecha_presentacion])\n\n respond_to do |format|\n if @recursorevision.save\n format.html { redirect_to([@solicitud, @recursorevision], :notice => 'Recurso revision creado con exito.') }\n format.xml { render :xml => @recursorevision, :status => :created, :location => @recursorevision }\n else\n logger.debug { \"Error: #{@recursorevision.errors}\" }\n flash[:error] = 'No fue posible generar el recurso de revisión.'\n format.html { render :action => 'new' } \n format.xml { render :xml => @recursorevision.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n linea_id = nil\n recoleccions = Array.new\n all_recoleccion_valid = true\n numero_secuencia = nil\n linea_inicial = params[:linea]\n codigo_paradero_inicial=params[:paradero_inicial]\n secuencia_paraderos = nil\n \n begin \n # Buscar todas las lineas para encontrar el id\n lineas = JSON.parse(open(\"http://citppuc.cloudapp.net/api/lineas\").read)\n #Accion para encontra el id\n lineas.each do |linea|\n linea_id = linea[\"linea_id\"] if linea[\"codigo_linea\"] == linea_inicial\n end\n #fetch secuencia y encontrar la sequencia donde parte\n if linea_id\n secuencias = JSON.parse(open(\"http://citppuc.cloudapp.net/api/lineas/\"+linea_id.to_s).read)\n end\n #Aqui cambiar la logica para los distintos horarios\n \n tr = DateTime.parse(params[:recoleccion][0][\"llegada_paradero\"])\n \n secuencias[\"secuencias\"].each do |secuencia|\n secuencia[\"horarios\"].each do |horario|\n if Recoleccion.cmp_wday horario[\"dias\"], tr\n if( tr.strftime(horario[\"hora_inicio\"]) < tr.strftime('%H:%M:%S') and tr.strftime('%H:%M:%S') < tr.strftime(horario[\"hora_termino\"]) )\n secuencia[\"secuencia_paraderos\"][0..-2].each do |paradero|\n if paradero[\"codigo_paradero\"].casecmp(codigo_paradero_inicial) == 0\n secuencia_paraderos = secuencia[\"secuencia_paraderos\"]\n end\n end\n end\n end\n end\n end\n # secuencia_paraderos[0] -> primer paradero de la sequencia\n #Encuentra el numero de la sequencia a la que pertenece el paradero inicial\n secuencia_paraderos.each do |paradero|\n if paradero[\"codigo_paradero\"].casecmp(codigo_paradero_inicial) == 0\n numero_secuencia = paradero[\"numero_secuencia\"].to_i \n break\n end\n end\n #incializa las recolecciones\n params[:recoleccion].each do |recoleccion|\n #revisar cual es mas cercano\n sqr_error = 1000\n for i in 0..10\n i -= secuencia_paraderos.count+1 if numero_secuencia-5+i > secuencia_paraderos.count\n if secuencia_paraderos[numero_secuencia-5+i]\n sqr_error_act = (recoleccion[\"latitude\"].to_f - secuencia_paraderos[numero_secuencia-5+i][\"gps_latitud\"].to_f)**2 +\n (recoleccion[\"longitude\"].to_f - secuencia_paraderos[numero_secuencia-5+i][\"gps_longitud\"].to_f)**2\n #puts sqr_error_act\n if (sqr_error >= sqr_error_act)\n sqr_error = sqr_error_act\n paradero = secuencia_paraderos[numero_secuencia-5+i][\"codigo_paradero\"]\n end\n end\n end\n #Setear datos genericos\n recoleccion[\"paradero\"] = paradero \n recoleccion[\"recorrido\"] = linea_inicial\n recoleccion[\"patente\"] = params[:patente]\n recoleccion[\"puerta\"] = params[:puerta]\n recoleccion[\"nombre\"] = params[:nombre]\n \n new_recoleccion = Recoleccion.new(recoleccion)\n recoleccions << new_recoleccion\n unless new_recoleccion.valid?\n all_recoleccion_valid = false\n invalid_recoleccion = recoleccion\n end\n end\n puts \"Paradero ecnontrado\"\n rescue\n puts \"Error al encontrar el paradero\"\n params[:recoleccion].each do |recoleccion|\n recoleccion[\"patente\"] = params[:patente]\n recoleccion[\"puerta\"] = params[:puerta]\n recoleccion[\"nombre\"] = params[:nombre]\n recoleccion[\"recorrido\"] = params[:linea]\n recoleccion[\"paradero\"] = \"error\"+params[:paradero_inicial]\n new_recoleccion = Recoleccion.new(recoleccion)\n recoleccions << new_recoleccion\n unless new_recoleccion.valid?\n all_recoleccion_valid = false\n invalid_recoleccion = recoleccion\n end\n end\n end\n \n respond_to do |format|\n if all_recoleccion_valid\n @recoleccions = []\n recoleccions.each do |recoleccion|\n recoleccion.save\n @recoleccions << recoleccion\n end\n format.html { redirect_to @recoleccions.first, notice: 'Recoleccion was successfully created.' }\n format.json { render json: @recoleccions, status: :created }\n else\n format.html { render action: \"new\" }\n format.json { render json: invalid_recoleccion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @server = Server.new(server_params)\n @neo = Neography::Rest.new\n\n respond_to do |format|\n if @server.save && n = Neography::Node.create(\"name\" => server_params[:name])\n n.add_to_index('servers', 'name', server_params[:name])\n n.id = n.neo_id # this construct should be improved..\n format.html { redirect_to @server, notice: 'Server was successfully created.' }\n format.json { render :show, status: :created, location: @server }\n else\n format.html { render :new }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def create\n @concepto_de_pago = ConceptoDePago.new(concepto_de_pago_params)\n #@plazo = @concepto_de_pago.diferencia \n # @concepto_de_pago.plazoRecordatorio = Chronic.parse(@concepto_de_pago.diferencia, :now => @concepto_de_pago.fechaVencimiento)\n\n respond_to do |format|\n if @concepto_de_pago.save\n format.html { redirect_to @concepto_de_pago, notice: 'Concepto de pago fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @concepto_de_pago }\n else\n format.html { render :new }\n format.json { render json: @concepto_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_create(path, options={}, &blk)\n # Create\n post path do\n @object = yield\n rest_params.each { |k, v| @object.send :\"#{k}=\", v }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object.to_hash\n end\n end", "def create\n @solicitudlabexa = Solicitudlabexa.new(params[:solicitudlabexa])\n @solicitudlabexa.usuario_id = @usuario_actual.id\n @solicitudlabexa.asignatura_id = params[:asignatura][:id].to_i unless params[:asignatura].nil?\n @solicitudlabexa.fechasol=Date.today\n @solicitudlabexa.npuestos=params[:npuestos]\n @solicitudlabexa.curso=params[:nivel].to_s == \"0\" ? \"optativa\" : params[:nivel].to_s\n @solicitudlabexa.comentarios=Iconv.conv('ascii//translit//ignore', 'utf-8', params[:comentarios].to_s)\n @solicitudlabexa.horaini=params[:horaini][:comienzo]\n @solicitudlabexa.horafin=params[:horafin][:fin]\n @solicitudlabexa.asignado=false\n \n if params[:fecha]=~ /[0-3]?[0-9]\\-[0-1]?[0-9]\\-[0-9]{4}/\n nfecha=formato_europeo(params[:fecha])\n #nfechaini=params[:fechaini].to_s.split('-')\n #nfechaini=fecha[2]+\"-\"+fecha[1]+\"-\"+fecha[0]\n @solicitudlabexa.fecha=nfecha.to_date\n else\n @solicitudlabexa.fecha=nil\n end\n\n pref=\"\"\n @especiales=Laboratorio.where('especial=?',\"t\").to_a\n for especial in @especiales do\n nombre=especial.ssoo.to_s\n if params[:\"#{nombre}\"].to_s!='in'\n pref+=especial.nombre_lab.to_s+'-'+nombre+'-'+params[:\"#{nombre}\"]+\";\"\n end\n end\n @solicitudlabexa.preferencias=pref\n @solicitudlabexa.tipo=\"P\"\n \n respond_to do |format|\n\n if @solicitudlabexa.save \n CorreoTecnicos::emitesolicitudexamen(@solicitudlabexa,params[:fecha],\"\",\"Nueva \").deliver_later \n @solicitudlabexas = Solicitudlabexa.where(\"usuario_id = ? \",@usuario_actual.id).to_a\n format.html { redirect_to :action => \"index\" }\n format.xml { render :xml => @solicitudlabexas, :status => :created, :location => @solicitudlabexas }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @solicitudlabexas.errors, :status => :unprocessable_entity }\n end\n \n end\n \n end", "def create\n @recurso = Recurso.new(recurso_params)\n\n respond_to do |format|\n if @recurso.save\n # flash.now[:notice] = 'El recurso fue creado con &eacute;xito.'\n @recursos = Recurso.order(\"descripcion\").to_a \n format.html { redirect_to :action => \"index\" }\n format.xml { render :xml => @recurso, :status => :created, :location => @recurso }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @recurso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @recurso = Recurso.new(params[:recurso])\n\n respond_to do |format|\n if @recurso.save\n format.html { redirect_to @recurso, notice: 'O recurso de auto de infração foi criado com sucesso.' }\n format.json { render json: @recurso, status: :created, location: @recurso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recurso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n origin = params[:fare][:origin]\n destination = params[:fare][:destination]\n\n \tuber = calculate_uber(origin, destination)\n lyft = calculate_lyft(origin, destination)\n\n if uber and lyft\n render json: [\n {\n company: 'uber', \n id: 1, \n price: uber, \n image: '/assets/uber.png'\n },\n {\n company: 'lyft',\n id: 2,\n price: lyft,\n image: '/assets/lyft.png'\n }], status: 200\n else\n render status: 500\n end\n\n end", "def url2json(method, url, params)\n if method == :GET\n url << \"?\" + params.map{|k,v| \"#{k}=#{v}\"}.join(\"&\")\n end\n\t\t\turl = URI.parse url\n\t\t\thttp = Net::HTTP.new(url.host, url.port)\n\t\t\thttp.use_ssl = (url.scheme == 'https')\n\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\t\thttp.verify_depth = 5\n request = nil\n if method == :GET\n request = Net::HTTP::Get.new(url.request_uri)\n elsif method == :GET_DATA\n request = Net::HTTP::Get.new(url.request_uri)\n form_data = params.to_json\n request.content_type = 'application/json'\n request.body = form_data\n elsif method == :POST\n request = Net::HTTP::Post.new(url.request_uri)\n form_data = params.to_json\n request.content_type = 'application/json'\n request.body = form_data\n elsif method == :DELETE\n request = Net::HTTP::Delete.new(url.request_uri)\n form_data = params.to_json\n request.content_type = 'application/json'\n request.body = form_data\n elsif method == :HEAD\n request = Net::HTTP::Head.new(url.request_uri)\n request.set_form_data(params)\n elsif method == :PUT\n request = Net::HTTP::Put.new(url.request_uri)\n request.set_form_data(params)\n end\n request.basic_auth(@username, @apikey)\n request.add_field(\"User-Agent\", \"Ruby/#{RUBY_VERSION} passivetotal rubygem v#{PassiveTotal::VERSION}\")\n\t\t\tt1 = Time.now\n\t\t\tresponse = http.request(request)\n\t\t\tdelta = (Time.now - t1).to_f\n data = JSON.parse(response.body)\n\n obj = Transaction.new(\n Query.new(method, params['query'], params[method] || params['tag'], url, params),\n Response.new(response.body, response.code == '200', data),\n delta\n )\n\n case response.code\n when \"401\"\n raise InvalidAPIKeyError.new(obj)\n when \"429\"\n raise ExceededQuotaError.new(obj)\n else\n raise APIUsageError.new(obj)\n end\n\n return obj\n end", "def create\n @pagos_servicio = PagosServicio.new(pagos_servicio_params)\n respond_to do |format|\n if @pagos_servicio.save\n @caja = Caja.where(estado: 0).last\n @mov_caja = MovCaja.create!(caja_id: @caja.id, concepto: @pagos_servicio.servicio, ingreso: 0, egreso: @pagos_servicio.monto, saldo: @caja.cierre.to_i - @pagos_servicio.monto.to_i)\n @caja.update(cierre: @caja.cierre.to_i - @pagos_servicio.monto.to_i, salida: @caja.salida.to_i + @pagos_servicio.monto.to_i)\n format.html { redirect_to @pagos_servicio, notice: 'Se ha registrado el pago correctamente.' }\n format.json { render :show, status: :created, location: @pagos_servicio }\n else\n format.html { render :new }\n format.json { render json: @pagos_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_tags\n uri = URI.parse(\"https://api.thomsonreuters.com/permid/calais\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n post_body = []\n post_body << \"<Document><Body>\"\n # stip html\n post_body << ActionView::Base.full_sanitizer.sanitize(params[:desc])\n # no strip\n # post_body << params[:desc]\n post_body << \"</Body></Document>\"\n request = Net::HTTP::Post.new(uri.request_uri)\n request.add_field(\"Content-Type\",\"text/xml\")\n request.add_field(\"outputFormat\",\"application/json\")\n #request.add_field(\"outputFormat\",\"text/n3\") \n request.add_field(\"x-ag-access-token\",\"fY7WUM3GGCXHm9ATOhtzhrvlWX8oPo5X\")\n request.body = post_body.join\n # request[\"Content-Type\"] = \"multipart/form-data, boundary=#{BOUNDARY}\"\n\n render :json => http.request(request).body\n end", "def create_private_pos_account\n @pos_account_type = PosAccountType.where(\"token = '57d3c9d284c0'\")\n @pos_account = User.find_by_certified_agent_id(params[:certified_agent_id])\n\n init_form\n\n pos_account_type = PosAccountType.find_by_id(params[:user][:pos_account_type_id])\n\n build_resource(params[:user].merge({profile_id: Profile.find_by_name(pos_account_type.name).id, pos_account_type_id: pos_account_type.id, company: params[:user][:company], rib: params[:user][:rib], bank_code: params[:user][:bank_code], wicket_code: params[:user][:wicket_code], account_number: params[:user][:account_number], activities_description: params[:user][:activities_description], certified_agent_id: params[:certified_agent_id], sub_certified_agent_id: SecureRandom.hex(9), identification_token: Digest::SHA1.hexdigest([DateTime.now.iso8601(6), rand].join), password: \"password\", password_confirmation: \"password\"}))\n\n if resource.save\n=begin\n # Création de lid agent agréé sur paymoney\n if (pos_account_type.name rescue nil) == \"POS marchand\"\n account_type = \"OTpPcVxO\"\n else\n account_type = \"jVUdVQBK\"\n end\n\n request = Typhoeus::Request.new(URI.escape(\"#{Parameter.first.paymoney_url}/PAYMONEY_WALLET/rest/create_compte_pariculier/#{account_type}/#{resource.firstname}/#{resource.lastname}/#{Date.today}/#{resource.email}/#{resource.identification_token}/#{resource.mobile_number}/nulll/nulll/nullllllllll/nu/#{@pos_account.paymoney_token}/#{resource.country.name}\"), followlocation: true, method: :get)\n\n clown = resource.clone\n\n request.on_complete do |response|\n if response.success?\n response = JSON.parse(response.body) #rescue nil\n if response.blank?\n resource.errors.add(:id, \"Une erreur s'est produite, veuillez contacter l'administrateur.\")\n else\n case (response[\"status\"][\"idStatus\"].to_s rescue \"\")\n when \"1\"\n resource.update_attributes(created_on_paymoney_wallet: true, paymoney_account_number: response[\"compteNumero\"], paymoney_password: response[\"comptePassword\"], paymoney_token: response[\"compteLibelle\"])\n when \"4\"\n resource.errors.add(:id, \"Ce compte existe déjà.\")\n\n clown.delete\n else\n resource.errors.add(:id, \"Une erreur inconnue s'est produite, veuillez contacter l'administrateur. Statut: #{response[\"status\"][\"idStatus\"].to_s rescue \"\"} Message: #{response[\"status\"][\"idStatus\"].to_s rescue \"\"}\")\n clown.delete\n end\n end\n else\n clown.delete\n resource.errors.add(:id, \"La ressource n'est pas disponible, veuillez contacter l'administrateur.\")\n end\n end\n\n request.run\n=end\n\n # Création de lid agent agréé sur paymoney wallet pour les marchands\n if ((pos_account_type.name rescue nil) == \"POS particulier\" ) && (resource.created_on_paymoney_wallet rescue nil) == true\n request = Typhoeus::Request.new(\"#{Parameter.first.paymoney_wallet_url}/api/86d138798bc43ed59e5207c68e864564/#{resource.certified_agent_id}/#{resource.sub_certified_agent_id}/#{resource.paymoney_account_number}/#{resource.paymoney_token}\", followlocation: true, method: :get)\n\n request.on_complete do |response|\n if response.success?\n if (request.response.body rescue nil) == \"1\"\n resource.update_attribute(:created_on_paymoney_wallet, true)\n flash.now[:success] = \"Le compte a été correctement créé. \"\n build_resource({})\n else\n end\n end\n end\n\n request.run\n end\n else\n clean_up_passwords resource\n end\n\n\n #render text: \"#{Parameter.first.paymoney_url}/PAYMONEY_WALLET/rest/create_compte/#{account_type}/#{resource.firstname}/#{resource.lastname}/null/#{resource.email}/#{resource.identification_token}/#{resource.mobile_number}/#{resource.bank_code}/#{resource.wicket_code}/#{resource.account_number}/#{resource.rib}/#{resource.country.name}\"\n render :new_private_pos_account\n end", "def create\n client= Client.new\n client.cedula= params[:cedula]\n client.sector= params[:sector]\n client.nombre= params[:nombre]\n client.telefono= params[:telefono]\n client.pagina= params[:pagina]\n client.direccion= params[:direccion]\n if client.save\n render(json: client, status: 201 , location: client)\n else \n render(json: client.errors, status: 422)\n end\n end", "def comprar sku, cantidad, fechaEntrega\n begin\n #sku = (params[:sku]).to_i\n #cantidad = (params[:cantidad]).to_i\n #fechaEntrega = (params[:fechaEntrega]).to_time\n if sku != nil\n ## Debemos preguntar si el grupo tiene la cantidad del producto que necesitamos\n proveedor = (Proveedor.find_by skuMateriaPrima: sku)\n grupoProveedor = proveedor.grupoProveedor\n ## Nos conectamos a la API para consultar el stock que tienen\n respuestaStock = RestClient.get 'http://integra'+grupoProveedor.to_s+'.ing.puc.cl/api/consultar/'+sku.to_s ,{:Content_Type => 'application/json'}\n hashRespuesStock = JSON.parse respuestaStock\n ## Si el stock que tienen es suficiente creamos la orden de compra\n if hashRespuesStock['stock'] >= cantidad\n ## Buscamos el id del grupo proveedor\n idGrupo = (IdGrupoProduccion.find_by numeroGrupo: grupoProveedor).idGrupo\n ## Creamos la orden de compra\n ## Fecha en el formato pedido!\n fechaEnFormato = (fechaEntrega.to_i) * 1000\n precio = proveedor.precio\n ## En produccion\n ordenCompra=RestClient.put 'http://moto.ing.puc.cl/oc/crear/', {:cliente => '572aac69bdb6d403005fb042', :proveedor => idGrupo, :sku => sku, :fechaEntrega => fechaEnFormato, :cantidad => cantidad, :precioUnitario => precio, :canal => 'b2b'}.to_json, :content_type => 'application/json'#ambiente\n ## En desarrollo\n ##ordenCompra=RestClient.put 'http://moto.ing.puc.cl/oc/crear/', {:cliente => '572aac69bdb6d403005fb042', :proveedor => idGrupo, :sku => sku, :fechaEntrega => fechaEnFormato, :cantidad => cantidad, :precioUnitario => precio, :canal => 'b2b'}.to_json, :content_type => 'application/json'\n ## Ya creada la orden de compra tenemos que ir a la aplicacion del grupo proveedor y exigir dicha cantidad\n hashOrdenCompra = JSON.parse ordenCompra\n ## Enviamos al grupo proveedor la orden de compra\n respuestaEnvioOC = RestClient.get 'http://integra'+grupoProveedor.to_s+'.ing.puc.cl/api/oc/recibir/'+hashOrdenCompra['_id'] ,{:Content_Type => 'application/json'}\n hashEnvioOC = JSON.parse respuestaEnvioOC\n ## Esperamos la respuesta y si es positiva tendriamos que guardarla en una base de datos y esperar que nos llegue la factura, que generara el pago automaticamente\n if hashEnvioOC['aceptado'] == true || hashEnvioOC['aceptado'] == 'true' ## ACA SE CAMBIO\n ## Deberiamos guardar en la base de datos que tenemos una orden aceptada\n puts 'se acepto la orden'\n ## Ver bien la insercion!\n Pedido.create(idPedido: hashOrdenCompra['_id'] , creacion: Time.now , proveedor: idGrupo , cantidad: cantidad.to_i , despachado: 0 , fechaEntrega: fechaEntrega.to_i , estado: 'Aceptada' , transaccion: false)\n else\n ## \n puts 'no me lee que la acepto'\n Pedido.create(idPedido: hashOrdenCompra['_id'] , creacion: Time.now , proveedor: idGrupo , cantidad: cantidad.to_i , despachado: 0 , fechaEntrega: fechaEntrega.to_i , estado: 'Rechazada' , transaccion: false)\n end\n ## Luego hay que esperar que el cliente nos despache\n else\n\n end\n end\n rescue\n ## No compra si se cae, deberia alomejor guardar en el log la informacion por la que se cayo\n end\n\n end", "def create\n\n client = Cliente.new\n\n client.nombre = params[:nombre]\n client.cedula = params[:cedula]\n client.pagina = params[:pagina]\n\n client.dirrecion = params[:dirrecion]\n client.telefono = params[:telefono]\n \n client.sector = params[:sector]\n \n\n if client.save\n \n\n render(json: client,status: 201 ,location: client)\n else\n\n render(json: client.errors,status: 422 )\n\n end\n end", "def new\n @service = params[:service]\n @subscription = Subscription.new\n @proxies = Proxy.all\n\n @service = params[:service]\n uid = @service[:uid]\n @webs = Webservicetolisten.find_all_by_nuxeouid(uid)\n\n @user = User.find(session[:user_id])\n @nuxeo_token = @user.nuxeotoken\n @accesstoken = OAuth::AccessToken.new(@@consumer, @nuxeo_token.token, @nuxeo_token.secret)\n @request_list_nuxeo_services = \"SELECT * FROM Document WHERE ecm:primaryType = 'Service'\"\n @result = @@consumer.request(:post,\n \"/site/automation/Document.Query\", #url to query\n @accesstoken, #accesstoken\n {},\n '{\"params\":{\"query\": \"SELECT * FROM Document WHERE ecm:primaryType = \\'Service\\'\"}}', # request or nuxeo services\n {'Content-Type' => 'application/json+nxrequest; charset=UTF-8',\n 'Accept' => 'application/json+nxentity, */*',\n 'X-NXDocumentProperties' => '*'}\n )\n @service1 = ActiveSupport::JSON.decode(@result.body)\n @services = @service1[\"entries\"]\n\n @myTab = []\n for serv in @services\n # Do whatever you want to ‘object’ (your iterator)\n if (serv['uid']!=uid)\n val =[]\n val[0]= serv['uid']\n val[1]= serv['title']\n @myTab << val\n end\n end\n\n if @webs.empty?\n @serv = Webservicetolisten.new\n @serv.nuxeouid = @service[:uid]\n @serv.title = @service[:title]\n @serv.archipath = @service['properties']['soa:archiPath']\n @serv.url = @service['properties']['serv:url']\n @serv.save\n end\n\n @webs = Webservicetolisten.find_all_by_nuxeouid(uid)\n session[:servicetolisten] = @webs[0].id\n\n session[:myTabLength] = @myTab.length\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @service }\n format.json { render json: @myTab }\n format.json { render json: @proxies }\n format.json { render json: @subscription }\n end\n end", "def index\n #@users = User.all\n @respuesta = Consulta.new(300,params[0])\n\n respond_to do |format|\n format.json { render json: @respuesta }\n \n end\n end", "def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end", "def troca\n @remetente = Sobrevivente.where(id: params[:de]).first\n @destinatario = Sobrevivente.where(id: params[:para]).first\n\n enviar = {agua: 1, comida: 2, medicamento: 3, municao: 4}\n receber = {agua: 0, comida: 2, medicamento: 3, municao: 8}\n\n trocou = @remetente.troca(@destinatario, enviar, receber)\n\n render json: { status: trocou }\n end", "def create\n @activite = Activite.new(params[:activite])\n @activite.dossier_id = params[:dossier]\n @activite.save\n render :json => {\"success\"=>true,\"data\"=>@activite}\n \n end", "def new\n @dispositivo = Dispositivo.new\n\n chars = 'ABCDEFGHJKLMNOPQRSTUVWXYZ'\n number='0123456789'\n @codigodevice = ''\n 3.times { |i| @codigodevice << chars[rand(7)] }\n 3.times { |i| @codigodevice << number[rand(7)] }\n @codigodevice\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dispositivo }\n end\n end", "def create\n @terme = params[\"terme\"]\n @typeProduit = params[\"typeProduit\"]\n @region = params[\"region\"]\n @codePostal = params[\"codePostal\"]\n @url = \"http://www.leboncoin.fr/#{@typeProduit.downcase}/offres/#{@region.downcase}/?f=a&th=1&q=#{@terme.downcase}&location=#{@codePostal}\"\n @newAnnonce = {\n :titre => params[\"annonce\"][\"titre\"],\n :urlRecherche => @url,\n user_id: current_user.id\n }\n @annonce = Annonce.new(@newAnnonce)\n if (Annonce.validate_zip_code(@codePostal))\n respond_to do |format|\n if @annonce.save\n format.html { redirect_to @annonce, notice: 'Annonce was successfully created.' }\n format.json { render :show, status: :created, location: @annonce }\n # puts \"http://www.leboncoin.fr/#{@typeProduit.downcase}/offres/#{@region.downcase}/?f=a&th=1&location=#{@codePostal}\"\n # HardWorker.perform_async(\"http://www.leboncoin.fr/#{@annonce.typeProduit.downcase}/offres/#{@annonce.region.downcase}/?f=a&th=1&location=#{@annonce.codePostal}\")\n else\n format.html { render :new }\n format.json { render json: @annonce.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:error] = \"Le champ code postal doit être vide ou comporter exactement 5 chiffres\"\n render :new\n end\n end", "def create\n @realiza = Realiza.new(params[:realiza])\n\n respond_to do |format|\n if @realiza.save\n @pagamento=Pagamento.new(:servico_id=>@realiza.servico_id,:cliente_id=>@realiza.cliente_id,:valor=>@realiza.servico.preco,\n :formapagamentoe_id=>params[:pagamento],:realiza_id=>@realiza.id)\n @pagamento.save\n format.html { redirect_to @realiza, notice: 'Realiza was successfully created.' }\n format.json { render json: @realiza, status: :created, location: @realiza }\n else\n format.html { render action: \"new\" }\n format.json { render json: @realiza.errors, status: :unprocessable_entity }\n end\n end\n end", "def resource_way\n # TODO: make json default format?\n\n # try resource style\n #resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", \n #'[email protected]', 'please') #, :accept => :json)\n resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", 'b4j5qBqzYx5EukCM3Vri') #token\n # \n response = resources.get(:accept => :json)\n all_hosts = JSON.parse(response)\n puts \"EXISTING HOSTS: \" + all_hosts.inspect\n\n new_opts = {\n \"host_name\" => \"damian.np.dc1.eharmony.com\",\n \"alias\" => \"damian.np.dc1.eharmony.com\",\n \"address\" => \"damian.np.dc1.eharmony.com\",\n \"max_check_attempts\" => 3,\n \"notification_interval\" => 5,\n # 24x7\n \"notification_period\" => \"24x7\",\n #\"notification_period_id\" => \"5050cb9ebfa68e0903000001\",\n # 24x7\n \"check_period\" => \"24x7\",\n #\"check_period_id\" => \"5050cb9ebfa68e0903000001\",\n # just using first contact\n #\"contacts\" => [\"pat-obrien\"],\n \"contacts\" => [\"damian\"],\n #\"contact_ids\" => [\"5051283ebfa68e5757000002\"],\n }\n\n\n #puts resources['new'].post(NEW_OPTS.to_json, :content_type => :json, :accept \n #=> :json )\n # NOTE: even though this works and creates a new Host in DB - i still get 406 \n # Not Acceptable response\n #puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts}, :accept => \n #:json )\n begin\n puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts})\n rescue Exception => e\n puts \"ERROR: #{e} = #{e.inspect}\"\n end\n\n \n\n # now edit the resource ...\nend", "def create\n @dossier = Dossier.new(params[:dossier])\n @dossier.parametres_cabinet_id = current_user.parametres_cabinet_id\n respond_to do |format|\n if @dossier.save\n format.html { redirect_to(@dossier, :notice => 'Le dossier a bien été créé') }\n format.xml { render :xml => @dossier, :status => :created, :location => @dossier }\n format.json { render :json => { :success => true, :message => \"Updated Dossier #{@dossier.id}\", :data => @dossier.attributes.merge(:institution_nom => @dossier.institution.nom, :type_etat_dossier_description => @dossier.type_etat_dossier.try(:description), :juge_mission_id => @dossier.juge_mission.try(:contact_id), :juge_controlleur_id => @dossier.juge_controlleur.try(:contact_id))}}\n \n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dossier.errors, :status => :unprocessable_entity }\n end\n end\n end", "def creacion\n fiesta = Fiesta.new (params[:id])\n if Fiesta.save\n puts \"su fiesta a sido registrada\"\n else \n puts \"su fiesta no a sido registrada\"\n end\n render = json: fiesta \n end", "def create\r\n\r\n\r\n end", "def reserve_next_id_soce\n @account = MasterData::Account.new\n authorize @account, :create?\n @id_soce = MasterData::Account.next_id_soce_seq_value\n respond_to do |format|\n format.json { render json: { id_soce: @id_soce }, status: :created }\n end\n end", "def create_record(http)\n json = %|{\n \"kind\": \"Article\",\n \"title\": \"Sample\",\n \"text\": \"Just some random text.\"\n}|\n resp = http.send_request('PUT', '/v1/Article', json, { 'Content-Type' => 'application/json' })\n # Response should be an OK with a JSON body.\n assert_equal(Net::HTTPOK, resp.class, 'response not an OK')\n reply = Oj.strict_load(resp.body, symbol_keys: true)\n\n # Make sure the message has the correct fields and values.\n assert_equal(0, reply[:code], 'create reply.code should be 0 meaning no error')\n ref = reply[:ref]\n refute_equal(nil, ref, 'create reply record reference can not be nil')\n refute_equal(0, ref, 'create reply record reference can not be 0')\n ref\n end", "def create\n userID = session[:user_id]\n editionID = params[:edition_id]\n price = params[:price]\n\n uri = URI(\"http://107.170.7.58:4567/api/create/sell\")\n parameters = {\"ext\" => \"json\", \"user_id\" => userID, \"edition_id\" => editionID, \"price\" => price, \"start_date\" => Time.now, \"end_date\" => 90.days.from_now}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n @response = list[0][\"kind\"]\n end", "def create\n\t\tauthorize! :create, Presupuesto\n @presupuesto = Presupuesto.new(presupuesto_params)\n\n respond_to do |format|\n if @presupuesto.save\n sesion = Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n\n Transaccion.create!(descripcion: \"Creación del presupuesto del proyecto #{@presupuesto.proyecto.nombre}: #{@presupuesto.attributes}\",\n sesion_id: sesion.id, \n proyecto_id: @presupuesto.proyecto.id)\n\n\n# Transaccion.create!(\n# descripcion: 'Creacion del presupuesto del proyecto'[email protected],\n# ‪ sesion_id‬: sesion.id,\n# ‪ proyecto_id‬: @presupuesto.proyecto.id\n# )\n format.html { redirect_to gestionar_presupuesto_path(@presupuesto) }#, notice: 'El Presupuesto fue creado exitosamente.' }\n #format.json { render :show, status: :created, location: @presupuesto }\n else\n format.html { redirect_to proyectos_mis_proyectos_path }\n #render :new }\n #format.json { render json: @presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n\n require 'uri'\n require 'openssl'\n require 'net/http'\n\n url = URI(\"https://api.us.apiconnect.ibmcloud.com/portal-api-developers-desarrollo/sandbox/creditos_hipotecarios/12/simulaciones\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n\n request = Net::HTTP::Post.new(url)\n request[\"x-ibm-client-id\"] = ENV[\"ID_DEV_BCI\"]\n request[\"content-type\"] = 'application/json'\n request[\"accept\"] = 'application/json'\n\n parameters = {\n \"anosTasaFija\" => 2,\n \"codMesExclusion\" => 0,\n \"diaVencimiento\" => 10,\n \"indDfl2\" => false,\n \"indPAC\" => false,\n \"mesesGracia\" => 2,\n \"seguroHogarContenido\" => false,\n \"seguroCesantia\" => false,\n \"seguroEnfermedadGrave\" => false,\n \"seguroHospitalizacion\" => false,\n \"codeudor\" => false,\n \"codeudorConSeguroDesgravamen\" => false,\n \"seguroCesantiaServiu\" => 0,\n \"seguroCesantiaDobleProtecion\" => false,\n \"seguroDesgravamenTitular\" => false,\n \"fechaNacimientoTitular\" => \"\",\n \"fechaNacimientoCodeudor\" => \"\",\n \"plazo\" => 5,\n \"renta\" => 1200000,\n \"valorPropiedadUf\" => 10000,\n \"montoCreditoUf\" => 7037,\n \"codTipoBienRaiz\" => \"casa\",\n \"comuna\" => \"Santiago Centro\",\n \"nombreCliente\" => \"Juan\",\n \"apellidoCliente\" => \"Soto\",\n \"emailCliente\" => \"[email protected]\",\n \"fonoCliente\" => 93849284,\n \"ciudad\" => 320,\n \"rutCliente\" => 17307813,\n \"dvCliente\" => \"7\",\n \"region\" => \"8\",\n \"codProducto\" => 12,\n \"codSeguro\" => 1\n }\n\n\n params.each do |p|\n if parameters.key?(p)\n val = params[p]\n parameters[p] = val\n end\n end\n\n request.body = JSON[parameters]\n response = http.request(request)\n\n simulation_result = response.read_body\n\n c_request = CreditRequest.new\n c_request.data = parameters\n c_request.simulation_response = simulation_result\n c_request.save!\n\n respond_to do |format|\n format.json { render :json => simulation_result}\n end\n end", "def reserveNode(node_ids,account_name,valid_from,valid_until)\n cert_path = APP_CONFIG['cert_path']\n # resernation_name: we set a random name for every reservation constructing by the name of the slice and a random number ex user1/12341234 \n resernation_name =account_name+ \"/\" + (1000 + Random.rand(10000000)).to_s\n puts resernation_name\n \n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n\n node_ids.map!{|r| {uuid: r}}\n\n header = {\"Content-Type\" => \"application/json\"}\n options ={\n name: resernation_name,\n valid_from: valid_from,\n valid_until: valid_until,\n account: \n { \n name: account_name\n },\n components: node_ids\n }\n\n #puts options.to_json \n uri = URI.parse(broker_url+\"/resources/leases\")\n pem = File.read(cert_path)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.cert = OpenSSL::X509::Certificate.new(pem)\n http.key = OpenSSL::PKey::RSA.new(pem)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Post.new(uri.request_uri, header)\n request.body = options.to_json\n\n response = http.request(request)\n \n res = JSON.parse(response.body)\n \n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response \n puts res[\"exception\"][\"reason\"]\n return res[\"exception\"][\"reason\"]\n else\n return \"OK\"\n end\n \n end", "def create\n @relatestagiario = Relatestagiario.new(params[:relatestagiario])\n\n respond_to do |format|\n if @relatestagiario.save\n flash[:notice] = 'RELATÓRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatestagiario) }\n format.xml { render :xml => @relatestagiario, :status => :created, :location => @relatestagiario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @relatestagiario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n # services / get_nutrients.rb\n fetched_params = GetNutrients.new(params[:marmiton_url]).perform\n puts fetched_params\n @recipe = Recipe.new(fetched_params)\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to root_path, notice: 'La recette a été crée.' }\n else\n format.html { redirect_to root_path, notice: \"La recette n'a pas pu être ajoutée.\" }\n end\n end\n end", "def create\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n @relatorio_pedagogico = RelatorioPedagogico.new(relatorio_pedagogico_params)\n\n respond_to do |format|\n if @relatorio_pedagogico.save\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico criado com sucesso!' }\n format.json { render :show, status: :created, location: @relatorio_pedagogico }\n else\n format.html { render :new }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #TODO we need to look into the need for transactions in mongodb\n #Api::V1::Result.with_session do |session|\n #session.start_transaction\n @results = []\n result_params = params.fetch(:result, {})\n\n result_params.each do |rp|\n permitted_rp = rp.permit(*Api::V1::Result::STRONG_PARAMETERS)\n result = Api::V1::Result.new(permitted_rp)\n result.save!\n\n @results << result\n end\n\n #session.commit_transaction\n #end\n\n render json: @results\n end", "def rest_end_point; end", "def create\n authorize! :create, Concepto\n if params[:concepto][:tipo_ids]\n params[:concepto][:tipo_ids] = params[:concepto][:tipo_ids].map { |k, _v| k }\n else\n params[:concepto][:tipo_ids] = []\n end\n\n @concepto = Concepto.new(concepto_params)\n\n respond_to do |format|\n if @concepto.save\n\n\n format.html { redirect_to @concepto, notice: '<i class=\"fa fa-check-square fa-lg\"></i> El concepto fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @concepto }\n else\n format.html { render :new }\n format.json { render json: @concepto.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_request\r\n end", "def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend", "def create\n @os_tarefa = OsTarefa.new(os_tarefa_params)\n\n respond_to do |format|\n if @os_tarefa.save\n if @os_tarefa.ordem_servico.id!=nil\n format.html { redirect_to \"/ordem_servicos/\"+@os_tarefa.ordem_servico.id.to_s, notice: 'A Tarefa foi criado(a)' }\n format.json { head :no_content }\n else\n format.html { redirect_to @os_tarefa, notice: 'A Tarefa foi criado(a)' }\n format.json { render :show, status: :created, location: @os_tarefa }\n end\n else\n format.html { render :new }\n format.json { render json: @os_tarefa.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(params[:user])\n\n # RestClient.post(\"http://sms.ru/sms/send\", :api_id => \"9d3359eb-9224-2384-5d06-1118975a2cd2\", :to => \"79051916188\", :text => \"Ваш ID на велопробег #{@user.id}\")\n\n respond_to do |format|\n if @user.save\n\n \n\n format.html { redirect_to edit_user_path(@user), notice: 'Участник успешно создан!' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { redirect_to root_path,\n notice: 'Поздравляем! Вы подали заявку на регистрацию. Для подтверждения регистрации \n необходимо внести взнос.' }\n end\n end\n end", "def create\n @liga_blaz_blue = LigaBlazBlue.new(params[:liga_blaz_blue])\n respond_to do |format|\n if LigaBlazBlue.where(:id_cuenta => getUsuarioActual.id_cuenta).size==0\n @liga_blaz_blue.id_cuenta=getUsuarioActual.id_cuenta\n @liga_blaz_blue.puntos=500\n if @liga_blaz_blue.save\n format.html { redirect_to(@liga_blaz_blue, :notice => 'Liga blaz blue was successfully created.') }\n format.xml { render :xml => @liga_blaz_blue, :status => :created, :location => @liga_blaz_blue }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @liga_blaz_blue.errors, :status => :unprocessable_entity }\n end\n else\n format.html { redirect_to(@liga_blaz_blue, :notice => 'Error: Ya estas inscrito en la liga.') }\n format.xml { render :xml => @liga_blaz_blue.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @sesiune = Sesiune.new(sesiune_params)\n\n respond_to do |format|\n if @sesiune.save\n\n # duplic temele si domeniile din ultima sesiune si le adaug in baza de date cu sesiune_id asta pe care tocmai am creat-o\n @ultima_sesiune = Sesiune.where(este_deschisa: false).last\n Domeniu.where(sesiune_id: @ultima_sesiune.id).each do |dom|\n nou_dom = Domeniu.create(nume: dom.nume, descriere: dom.descriere, user_id: dom.user_id, sesiune_id: @sesiune.id)\n Tema.where(sesiune_id: @ultima_sesiune.id).where(domeniu_id: dom.id).each do |tema|\n Tema.create(nume: tema.nume, descriere: tema.descriere, domeniu_id: nou_dom.id, este_libera: true, user_id: tema.user_id, sesiune_id: @sesiune.id)\n # ce faci dc user_id-ul temei este un student care a terminat? si th i se desfiinteaza contul?\n end\n end\n\n format.html { redirect_to controlPanel_path, notice: 'Sesiune was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sesiune }\n else\n format.html { render action: 'new' }\n format.json { render json: controlPanel_path.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n\n\n\n #params[:request] = {\"partner_id\"=>\"1\", \"url\"=>\"\", \"parametres\"=>\"\"}\n\n @request = Request.where(params[:request]).first\n if @request\n @request.incr_count\n else \n @request = Request.new(params[:request])\n @request.save\n end \n\n @full_request = @request.get_full_request\n respond_to do |format|\n if @request\n\n session[:partner_id]=params[:request][:partner_id]\n session[:url] =params[:request][:url]\n session[:parametres]=params[:request][:parametres]\n\n format.html { redirect_to @request, notice: 'Request was successfully created.' }\n format.js {render :new}\n format.json { render json: @request, status: :created, location: @request }\n else\n\n format.html { render action: \"new\" }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n @lancamentorapido = Lancamentorapido.new(params[:lancamentorapido])\n \n #Validações padrão\n @lancamentorapido.tipo = :receita if @lancamentorapido.tipo.blank?\n @lancamentorapido.valor = 0 if @lancamentorapido.valor.blank? \n \n respond_to do |format|\n if @lancamentorapido.save\n format.html { redirect_to lancamentorapidos_path, notice: 'Lancamento was successfully created.' } \n# format.html { redirect_to '/lancamentorapidos'}\n format.json { render json: lancamentorapidos_path, status: :created, location: @lancamentorapido }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lancamentorapido.errors, status: :unprocessable_entity }\n end\n end\n end", "def grabar_concesionario\n # puts 'AQUI'\n @concesionario = Concesionario_vehiculos.new\n @usuario = Usuario.new\n @rif=params[:rif]\n @nombre=params[:nombre]\n @correo=params[:correo]\n @telefono=params[:telefono]\n @ciudad=params[:ciudad]\n @direccion=params[:direccion]\n @marca=params[:marca]\n #------\n @nombre_usuario=params[:nombre_usuario]\n @contrasena=params[:contrasena]\n # puts ''+@nombre_usuario+''\n @usuario.grabar_usuario_concesionario(@nombre_usuario, @contrasena);\n # puts '+++++++++++++++++++++++++++++++++++++++++++++++++++++++metio usuario'\n @concesionario.grabar_concesionario(@rif,@nombre,@correo,@telefono,@ciudad,@direccion,@marca,@nombre_usuario)\n render :text => $tirajson\n end", "def create; end", "def create; end", "def create; end", "def create; end", "def create_recipe_request(version, auth_headers, data = {})\n post \"/api/recipes\", params: data, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend", "def create\n @capitol = Capitol.new(capitol_params)\n\n if Licenta.find(@capitol.licenta_id).user_id == get_current_user.id\n respond_to do |format|\n if @capitol.save\n\n # actualizeaza numerele la restul capitolelor de dupa asta nou\n if Capitol.where(\"numar = ?\", \"#{@capitol.numar}\").count > 1\n @capitole = Capitol.where(\"numar >= ? and id != ?\", \"#{@capitol.numar}\", \"#{@capitol.id}\")\n @capitole.each do |cap|\n numar = cap.numar + 1\n cap.update_attributes(numar: numar)\n end\n end\n\n format.html { redirect_to root_path, notice: 'Capitol was successfully created.' }\n format.json { render action: 'show', status: :created, location: @capitol }\n else\n format.html { render action: 'new' }\n format.json { render json: @capitol.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to root_path\n end\n end", "def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, notice: 'Tecnico criado com sucesso.' }\n format.json { render json: @tecnico, status: :created, location: @tecnico }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:id] = resource.id if resource.save\n respond_with resource\n end", "def create(params, membership)\n # Send payload to blip\n data = {\n initials: (params[4].nil? ? params[5][0] : params[4].tr('^a-zA-Z', '')),\n firstname: (params[5].nil? ? params[4][0] : params[5]),\n lastname: [params[6], params[7]].reject{|e| e.nil? or e.empty?}.join(' '),\n email: (params[3].nil? ? '[email protected]' : params[3]),\n gender: params[9] == 'Vrouw' ? 'F' : 'M',\n phone: params[14],\n mobile: params[2],\n phone_parents: params[24],\n address: [params[10], params[11], params[12]].join(' '),\n membership: membership,\n }\n begin\n unless params[15].nil?\n data[:dateofbirth] = Date.strptime(params[15], '%d-%m-%Y').strftime('%Y-%m-%d')\n end\n rescue\n $problems.write \"#{$index}, #{data[:firstname]} #{data[:lastname]}, Birthdate ignored\\n\"\n end\n blip = post('https://people.i.bolkhuis.nl/persons', data)\n\n # Grab uid\n unless blip == nil\n uid = blip['uid']\n\n # Send payload to operculum\n put(\"https://operculum.i.bolkhuis.nl/person/#{uid}\", {\n nickname: params[8],\n study: params[16],\n alive: params[17].nil?,\n inauguration: params[25],\n resignation_letter: params[26],\n resignation: params[27],\n })\n end\nend", "def create\n retorno = {erro: \"107\", body: \" \"}\n @usuario = Usuario.new(valid_request?)\n @usuario.status = 1\n if @usuario.mac.blank? \n @usuario.nivel = \"usuario_adm\"\n @usuario.status = 0\n usuario = Usuario.select(:mac).where(\"nivel = 1\").last\n @usuario.mac = (usuario.mac.to_i + 1).to_s\n end\n\n if @usuario.valid?\n if @usuario.save\n retorno = {erro: \"000\", body: {usuario_id: @usuario.id, usuario_nome: @usuario.nome, status: true}}\n end\n end\n #verifica erros na inserção no banco\n if @usuario.errors.any?\n retorno = Usuario.verifica_erro(@usuario.errors.messages)\n end\n render json: retorno.to_json\n end", "def create\n @param = contribucion_params[:url]\n if @param == \"\" or !Contribucion.exists?(url: @param) #si es un text o url nou el guarda\n @contribucion = Contribucion.new(contribucion_params)\n @contribucion.user_id = current_user().id\n respond_to do |format|\n if addContribucio(@contribucion)\n format.html { redirect_to @contribucion, notice: 'Contribucion was successfully created.' }\n format.json { render :show, status: :created, location: @contribucion }\n else\n format.html { render :new } ## Specify the format in which you are rendering \"new\" page\n format.json { render json: @reservation.errors } ## You might want to specify a json format as well\n end\n end\n else #si url existeix fa el show\n respond_to do |format|\n @contribucion = getContribucioByUrl(@param)\n format.html { redirect_to @contribucion}\n format.json { render :show, status: :created, location: @contribucion}\n end\n end\n end", "def create\n\n respond_to do |format|\n if @especialidad.save\n format.html { redirect_to @especialidad, notice: 'Servicio creado exitosamente.' }\n format.json { render :show, status: :created, location: @especialidad }\n else\n format.html { render :new }\n format.json { render json: @especialidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.create(:user => current_user)\n \n # Creation from web form.\n if params[:room][:participant_attributes]\n @room.phonebrowser_service = PhonebrowserService.create(:room => @room)\n @room.video_service = VideoService.create(:room => @room)\n params[:room][:participant_attributes].each do |part|\n p = Participant.new\n if part[:phonebrowser_service] == '1'\n p.phonebrowser_service_id = Service.find_by_name('phonebrowser').id\n end\n if part[:video_service_id] == '1'\n p.video_service_id = Service.find_by_name('video').id\n end\n p.name = part[:name]\n p.phone = part[:phone]\n p.sip = part[:sip]\n p.browser = part[:browser]\n p.save\n @room.participants << p\n end\n @room.save\n redirect_to rooms_path\n \n # Creation from RESTful request\n elsif params[:room][:participant]\n participants_array = []\n if params[:room][:participant].class == Array\n participants_array = params[:room][:participant]\n else\n participants_array << params[:room][:participant]\n end\n participants_array.each do |part|\n p = Participant.new\n p.name = part[:name]\n p.phone = part[:phone]\n p.sip = part[:sip]\n p.browser = part[:browser]\n p.save\n @room.participants << p\n end\n @room.phonebrowser_service = PhonebrowserService.create(:room => @room)\n @room.video_service = VideoService.create(:room => @room)\n @room.save\n if params[:room][:start_now] and !params[:room][:start_now].nil? and params[:room][:start_now] == \"1\"\n @room.start\n end\n # @ltest.to_xml(:include => :sub_tests) \n respond_to do |format|\n format.html {redirect_to rooms_path}\n format.xml { render :xml => @room.to_xml(:include => [:phonebrowser_service, :participants]) } #.to_xml(:include => :phonebrowser_service)\n format.json {render :json => @room.to_json(:include => [:phonebrowser_service, :participants]) }\n end\n end\n end", "def create\n #Parámetros permitidos.\n lectura_params\n\n #Asignación de variables.\n numero = params[:lectura][:numero].upcase\n actual = params[:lectura][:actual].to_i\n medidor = Medidor.find_by(numero: numero)\n periodo = Periodo.last\n consumominimo = Servicio.find_by(id: 1)\n\n #Cálculos.\n consumototal = actual - medidor.medicion\n consumototal = actual - medidor.medicion\n if consumototal > consumominimo.m3 then\n consumoexceso = consumototal - consumominimo.m3\n else\n consumoexceso = 0\n end\n\n #Editar lectura.\n @lectura = Lectura.new\n @lectura.cliente_id = medidor.cliente_id\n @lectura.periodo_id = periodo.id\n @lectura.fecha = Date.today\n @lectura.numero = numero\n @lectura.actual = actual\n @lectura.consumo = consumototal\n @lectura.exceso = consumoexceso\n\n #Guardar lectura.\n respond_to do |format|\n if @lectura.save\n medidor.medicion = actual\n medidor.save\n puts'Lectura guardada'\n format.json { render :show, status: :created, location: @lectura }\n #format.html { redirect_to @lectura, notice: 'La lectura fue creada.' }\n #format.js { }\n else\n puts'Lectura no guardada'\n format.json { render json: @lectura.errors, status: :unprocessable_entity }\n #format.html { render :new }\n end\n end\n end", "def create\n # rp - request parameters\n rp = req_params\n\n # сюда будем собирать ошибки при проверке заявки\n errors = {}\n\n model_name(rp, errors)\n aas_names(rp, errors)\n check_human(rp, errors)\n\n if errors.empty?\n export(rp) if PSOFT_DB\n mail(rp)\n render json: { message: format(I18n.t('request.status.ok'), id: rp.id || ' -') }\n else\n render status: :unprocessable_entity, json: errors\n end\n end", "def create\n\n pessoa = SivicPessoa.find params[:sivic_discipulo][:sivic_pessoa_id] rescue nil\n\n\n # debugger\n if pessoa\n @sivic_discipulo = SivicDiscipulo.new(sivic_discipulo_params_normal)\n @sivic_discipulo.sivic_pessoa.sivic_situacaodiscipulo_id = params[:sivic_discipulo][:sivic_pessoa_attributes][:sivic_situacaodiscipulo_id]\n @sivic_discipulo.sivic_pessoa_id = pessoa.id\n else\n @sivic_discipulo = SivicDiscipulo.new(sivic_discipulo_params_netested) \n end\n \n #codigo = geracodigo(@sivic_discipulo.sivic_pessoa.sivic_igreja_id)\n #@sivic_discipulo.NUMR_Codigo = codigo \n \n respond_to do |format|\n\n # debugger\n\n if @sivic_discipulo.save \n format.html { redirect_to @sivic_discipulo, notice: 'Registro inserido com sucesso.' }\n format.json { render action: 'show', status: :created, location: @sivic_discipulo }\n else\n if @sivic_discipulo.sivic_pessoa_id\n @sivic_pessoa_evolucao = SivicPessoa.find(@sivic_discipulo.sivic_pessoa_id)\n else\n @sivic_pessoa_evolucao = SivicPessoa.new\n end\n\n format.html { render action: 'new' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity}\n \n end \n end\n\n end", "def create\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{order_params['email'].to_s}\")\n codeCustomer = res.code\n dataCustomer = res.parsed_response\n p res\n res = HTTParty.get(\"http://localhost:8082/items/#{order_params['itemid'].to_s}.json\")\n #res = HTTParty.get(\"http://localhost:8082/items/#{order_params['itemid'].to_s}.json\")\n codeItem = res.code\n dataItem = res.parsed_response\n p dataItem\n if codeCustomer != 404 && codeItem != 404\n newParams = order_params\n newParams[\"award\"] = dataCustomer[\"award\"] \n newParams[\"price\"] = dataItem[\"price\"]\n newParams[\"total\"] = dataItem[\"price\"] - dataCustomer[\"award\"]\n p newParams\n \n #HTTParty.put(\"http://localhost:8081/customers/order?award=#{newParams['award']}&total=#{newParams[\"total\"]}&customerId=#{newParams['customerid']}\")\n end\n if codeCustomer == 404 || codeItem == 404\n if codeCustomer == 404 and codeItem == 404\n render json: {error: \"Customer and Item do not exist\"}, status: 400\n return\n end\n if codeCustomer == 404 and codeItem != 404\n render json: {error: \"Customer does not exist\"}, status: 400\n return\n end\n if codeCustomer != 404 and codeItem == 404\n render json: {error: \"Item does not exist\"}, status: 400\n return\n end\n else\n @order = Order.new\n @order.customerid = dataCustomer[\"id\"]\n @order.email = dataCustomer[\"email\"]\n @order.itemid = order_params[:itemid]\n @order.description = dataItem[\"description\"]\n @order.award = newParams[\"award\"]\n @order.total = newParams[\"total\"]\n @order.price = newParams[\"price\"]\n \n orderResult = HTTParty.put('http://localhost:8081/customers/order', \n :body => @order.to_json,\n :headers => {'Content-Type' => 'application/json', 'ACCEPT' => 'application/json'}\n )\n\n res = HTTParty.put(\"http://localhost:8082/items/#{order_params[:itemid]}?stockQty=#{dataItem['stockQty']-1}&description=#{dataItem['description']}&price=#{dataItem['price']}&id=#{order_params[:id]}\")\n p res\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n \n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @liga_blaz_blue_general = LigaBlazBlueGeneral.new(params[:liga_blaz_blue_general])\n\n respond_to do |format|\n if LigaBlazBlueGeneral.where(:cuenta => getUsuarioActual.id_cuenta).size==0\n @liga_blaz_blue_general.cuenta=getUsuarioActual.id_cuenta\n @liga_blaz_blue_general.puntos=500\n if @liga_blaz_blue_general.save\n format.html { redirect_to(@liga_blaz_blue_general, :notice => 'Liga blaz blue general was successfully created.') }\n format.xml { render :xml => @liga_blaz_blue_general, :status => :created, :location => @liga_blaz_blue_general }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @liga_blaz_blue_general.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n log(\"Se ha creado la nomina #{@lt}\", 0)\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: 'La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @safra_verdoso = SafraVerdoso.new(params[:safra_verdoso])\n\n respond_to do |format|\n if @safra_verdoso.save\n format.html { redirect_to \"/safra_produtos/#{@safra_verdoso.safra_produto_id}/descontos\"}\n format.json { render json: @safra_verdoso, status: :created, location: @safra_verdoso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @safra_verdoso.errors, status: :unprocessable_entity }\n end\n end\n end", "def grabar_ensambladora\n # puts 'AQUI'\n @ensambladora = Ensambladora_vehiculos.new\n @usuario = Usuario.new\n @rif=params[:rif]\n @nombre=params[:nombre]\n @correo=params[:correo]\n @telefono=params[:telefono]\n @ciudad=params[:ciudad]\n @direccion=params[:direccion]\n @marca=params[:marca]\n #------\n @nombre_usuario=params[:nombre_usuario]\n @contrasena=params[:contrasena]\n # puts ''+@nombre_usuario+''\n @usuario.grabar_usuario_ensambladora(@nombre_usuario, @contrasena);\n # puts '+++++++++++++++++++++++++++++++++++++++++++++++++++++++metio usuario'\n @ensambladora.grabar_ensambladora(@rif,@nombre,@correo,@telefono,@ciudad,@direccion,@marca,@nombre_usuario)\n render :text => $tirajson\n end", "def create\n\t\tauthorize! :create, DetalleGasto\n @detalle_gasto = @informe_gastos.detalle_gastos.new(detalle_gasto_params)\n @detalle_gasto.voluntario_id = current_usuario.id\n respond_to do |format|\n if @detalle_gasto.save\n sesion = Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n Transaccion.create!(descripcion: \"Creación del detalle gasto #{@detalle_gasto.titulo}, descripcion: #{@detalle_gasto.descripcion}, con monto #{@detalle_gasto.monto}, concepto_gasto: #{@detalle_gasto.concepto_gasto.titulo}, voluntario: #{@detalle_gasto.voluntario.nombre}, comprobante: #{@detalle_gasto.comprobante.numero}\",\n sesion_id: sesion.id, \n proyecto_id: @detalle_gasto.informe_gasto.proyecto.id)\n #format.html { redirect_to gestionar_informe_gastos_path(@detalle_gasto.informe_gasto)} #@detalle_gasto, notice: 'Detalle gasto fue creado satisfactoriamente.' }\n format.html { redirect_to new_comprobante_path(:detalle_gasto_id => @detalle_gasto.id)}\n #format.json { render :show, status: :created, location: @detalle_gasto }\n else\n format.html { render :new }\n format.json { render json: @detalle_gasto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pago = Pago.new(pago_params)\n @pagoPendAplicar = @pago.pago_valor\n case @pago.pago_tipoProducto\n when \"RESERVA\"\n reserva = Reserva.where(\"rsrv_codigo = '#{@pago.pago_productoId}'\").take\n detallesReserva = DetalleReserva.where(\"reserva_id = ? AND detRsrv_estadoReserva IN ('I', 'P')\" ,reserva.id)\n @parentPath = \"/reservas/\" + reserva.id.to_s\n if reserva.rsrv_tipoProducto == \"VUELO\" then\n tarifasViaje = tarifas_viaje(reserva.rsrv_productoId, reserva.rsrv_trayectoViaje)\n if tarifasViaje.viaje_tarifas.blank?\n detallesReserva.each do |h|\n if @pagoPendAplicar > 0 then\n h.detRsrv_tarifaCodigo = \"BASE\"\n h.detRsrv_estadoReserva = \"C\"\n if @pagoPendAplicar > tarifasViaje.trf_base then\n h.detRsrv_valor = tarifasViaje.trf_base \n @pagoPendAplicar = @pagoPendAplicar - tarifasViaje.trf_base\n else\n h.detRsrv_valor = @pagoPendAplicar\n @pagoPendAplicar = 0\n end\n end\n h.save\n end\n else\n end\n end \n reserva.rsrv_estadoReserva = \"C\"\n reserva.save\n end\n\n respond_to do |format|\n if @pago.save\n format.html { redirect_to @parentPath, notice: 'Pago creado exitosamente.' }\n format.json { render :show, status: :created, location: @pago }\n else\n format.html { render :new }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, Solicitud\n @solicitante=Solicitante.find(params[:solicitante_id])\n @beneficiario=Beneficiario.find(params[:beneficiario_id])\n @solicitud = Solicitud.create(solicitud_params)\n @[email protected]\n @[email protected]\n\n respond_to do |format|\n if @solicitud.save\n format.html { redirect_to solicitante_beneficiario_path(@solicitante, @beneficiario), notice: 'Solicitud creada exitosamente.' }\n format.json { render :show, status: :created, location: solicitante_beneficiario_path(@solicitante, @beneficiario) }\n else\n format.html { render :new }\n format.json { render json: @solicitud.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n begin\n @resource = Relation.new(params[:relation])\n @resource.save!\n render :response => :POST\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n \n \n \n end", "def create\n @laboratorio = Laboratorio.new(laboratorio_params)\n get_responsavel\n puts \"O responsavel é: #{@laboratorio.responsavel_id}\"\n if (@responsavel != \"sem_responsavel\")\n @laboratorio.docentes << Docente.find(@laboratorio.responsavel_id)\n puts \"Add relação entre #{@laboratorio.nome} e #{Docente.find(@laboratorio.responsavel_id).user.nome}\"\n end\n respond_to do |format|\n if @laboratorio.save\n format.html { redirect_to @laboratorio, notice: 'Laboratorio was successfully created.' }\n format.json { render :show, status: :created, location: @laboratorio }\n else\n format.html { render :new }\n format.json { render json: @laboratorio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:post_exchange_user]\n sum = 0 - operation_params[:sum].to_f\n @operation1 = Operation.new(operation_params.merge(sum: sum))\n @operation2 = Operation.new(operation_params.merge(sum: operation_params[:sum].to_f, user_id: params[:post_exchange_user]))\n respond_to do |format|\n if @operation1.save && @operation2.save\n amount = User.find(@operation1.user_id).initAmount\n Operation.where(user_id: @operation1.user_id).find_each do |operation|\n amount = amount + operation.sum\n end\n User.find(@operation1.user_id).update_attribute(:amount, amount)\n amount = User.find(@operation2.user_id).initAmount\n Operation.where(user_id: @operation2.user_id).find_each do |operation|\n amount = amount + operation.sum\n end\n User.find(@operation2.user_id).update_attribute(:amount, amount)\n format.html { redirect_to User, notice: \"Opération prise en compte !\"}\n format.json { render :show, status: :created, location: @operation }\n else\n format.html { render :exchange }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n else \n if params[:post]\n drink_id = params[:post][:drink]\n drink_price = Drink.find(drink_id).price.to_f\n sum = 0 - operation_params[:numberDrink].to_f * drink_price\n else\n sum = operation_params[:sum].to_f\n end\n @operation = Operation.new(operation_params.merge(sum: sum, drink_id: drink_id))\n respond_to do |format|\n if @operation.save\n amount = User.find(operation_params[:user_id]).initAmount\n Operation.where(user_id: operation_params[:user_id]).find_each do |operation|\n amount = amount + operation.sum\n end\n User.find(operation_params[:user_id]).update_attribute(:amount, amount)\n if amount < 0\n UserNotifierMailer.send_negative_email(User.find(operation_params[:user_id])).deliver\n end\n format.html { redirect_to User, notice: \"Opération prise en compte !\"}\n format.json { render :show, status: :created, location: @operation }\n else\n format.html { render :new }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end\n end" ]
[ "0.6045054", "0.6023724", "0.5995838", "0.5969186", "0.59575576", "0.5883928", "0.58799845", "0.5864586", "0.58577114", "0.5837107", "0.58341557", "0.57930857", "0.57382125", "0.57330865", "0.5716331", "0.5695235", "0.56858706", "0.56694305", "0.5667942", "0.5661307", "0.56567425", "0.56456953", "0.56422156", "0.5637286", "0.56211567", "0.56205297", "0.562044", "0.5610494", "0.55970484", "0.5597017", "0.5594073", "0.5593773", "0.5590915", "0.55847853", "0.55764693", "0.5571711", "0.55606234", "0.5558222", "0.55576766", "0.5552834", "0.5550891", "0.5547829", "0.5539926", "0.55369455", "0.5525913", "0.5524196", "0.55236465", "0.5520255", "0.55174613", "0.5514644", "0.5514638", "0.5514232", "0.551166", "0.5504907", "0.5495041", "0.54939806", "0.54903686", "0.5490199", "0.54867494", "0.5486559", "0.54841137", "0.5478659", "0.5475536", "0.54688674", "0.54665476", "0.5461233", "0.5460228", "0.54588306", "0.5458753", "0.54586387", "0.5452586", "0.5451161", "0.54474044", "0.54469675", "0.5446941", "0.5446941", "0.5446941", "0.5446941", "0.5446145", "0.5445235", "0.54418504", "0.54402524", "0.54399455", "0.543873", "0.5438726", "0.54370576", "0.5434788", "0.54307425", "0.5426353", "0.5425151", "0.5417931", "0.541586", "0.54106045", "0.5409517", "0.54052556", "0.5404075", "0.5401199", "0.5399787", "0.5399252", "0.53992325", "0.5396475" ]
0.0
-1
Convert list interests to hash
def convert_interests_to_hash interests = Interest.all.map do |interest| [interest.id, interest.name.gsub(/'/, "''")] end interests.to_h end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash() end", "def to_hash\n @list\n end", "def hash\n lists.inject({}){ |hash, p| hash[p[0]] ||= []; hash[p[0]] << p[1]; hash }\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n [amount.hash, currency.hash].hash\n end", "def hash\n [amount.hash, currency.hash].hash\n end", "def hash_hash(h)\n require 'digest/md5'\n Digest::MD5.hexdigest(Marshal::dump(h.sort))\n end", "def convert_to_hash(iterable)\n iterable.inject([]) do |acc, ele|\n acc << convert_element(ele)\n end\n end", "def to_hash\n memoize(:to_hash) do\n _process_hashed(structures.inject({}) { |acc, elem| Utils.merge(acc, elem) })\n end\n end", "def hash\n [cents.hash, currency.hash].hash\n end", "def hash\n [cents.hash, currency.hash].hash\n end", "def _hash(obj)\n obj.transform_values { |v| _renc(v) }\n end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def hashed_input\n\t\tmd5_hex = Digest::MD5.hexdigest(@term)\n\t\tmd5_hex.scan(/../).map { |s| s.to_i(16) }\n\tend", "def hash\n [address1, address2, amount, business_description, business_type, corporate_number, email, end_date, prefecture, remark, representative_name, tel, url, zip_code].hash\n end", "def hash\n @data[:asin].to_s.hash\n end", "def hash\n [id, banco, agencia, conta_corrente, especie, numero_convenio, carteira, codigo_cedente, especie_tipo, especie_documento, aceite, instrucoes, local_pagamento1, local_pagamento2, endereco_cobranca_emissor, nome_beneficiario, cnpj_beneficiario, operador, data, maquina].hash\n end", "def hash(*) end", "def to_hash\n {:hashes => @hashes}\n end", "def hash\n [last_price, last_time, last_size, bid_price, bid_size, ask_price, ask_size, open_price, close_price, high_price, low_price, exchange_volume, market_volume, updated_on, source, listing_venue, sales_conditions, quote_conditions, market_center_code, is_darkpool, security].hash\n end", "def hash_hash(h)\n require 'digest/md5'\n\n ordered = h.sort.map { |i| i.class==Hash ? i.sort : i }\n return ordered.to_s\n Digest::MD5.hexdigest(Marshal::dump(ordered))\n end", "def hash\n [rank, suit].hash\n end", "def hash_transactions\n tx_ids = transactions.map do |tx|\n tx.id\n end\n Digest::SHA256.hexdigest(tx_ids.join(''))\n end", "def hash\n [id, alternate_id, type, first_name, surname, date_of_brith, date_of_birth, shipping_address, mailing_address, home_phone, mobile_phone, email_address, mailing_address_active, accounts, classifications, member_photo, gender, receive_email, receive_sms, password].hash\n end", "def hash\n [account, adjusted_equity_previous_close, equity, equity_previous_close, excess_maintenance, excess_maintenance_with_uncleared_deposits, excess_margin, excess_margin_with_uncleared_deposits, extended_hours_equity, extended_hours_market_value, last_core_equity, last_core_market_value, market_value, start_date, unwithdrawable_deposits, unwithdrawable_grants, url, withdrawable_amount].hash\n end", "def hash\n [first_name, last_name, address_one, address_two, city, state, zip, phone, email, country_code].hash\n end", "def hash\n [self[0], self[1]].hash\n end", "def hash\n [to_d.hash, currency.hash].hash\n end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def get_hashes(items)\n hashes = []\n items.each do |item|\n hashes.push((Digest::SHA2.new << item).to_s)\n end\n\n return hashes\n end", "def hash\r\n return to_s.hash\r\n end", "def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end", "def hash\n to_a.hash\n end", "def hash\n \"#{membership} #{formatted_price}\"\n end", "def hash\n [income_type, description, tax_rate, tax_amount, tax_amount_no_vat, withheld, total, vat_type].hash\n end", "def hash\n [date, intraperiod, frequency, open, high, low, close, volume, adj_open, adj_high, adj_low, adj_close, adj_volume, factor, split_ratio, dividend, change, percent_change, fifty_two_week_high, fifty_two_week_low, security].hash\n end", "def to_h\n Hash[all_entries]\n end", "def hash_encode(i)\n @hasher.encode i\n end", "def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end", "def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end", "def hash\n to_s.hash\n end", "def hash\n to_s.hash\n end", "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def hash\n to_s.hash\n end", "def hash\n self.to_f.hash\n end", "def create_list(list)\r\n\tlist = list.split(\" \")\r\n\thsh = {}\r\n\r\n\tlist.each{|i| hsh[i] = 1}\r\n\r\n\t###print hash\r\n\thsh\r\nend", "def list_as_hash solr_list\n # map\n if solr_list.values.first.is_a? Hash\n solr_list\n else\n solr_list.each_with_object({}) do |(key, values), hash|\n hash[key] = if values.first.is_a? Array\n # arrarr\n Hash[values]\n else\n # flat\n Hash[values.each_slice(2).to_a]\n end\n end\n end\n end", "def marr2hash(mps)\n mps.map{|e|[e[0], e[1].to_h, e[2]]}\n end", "def hash\n [article_number, name, quantity, unit_price, discount_percent, vat_percent, unit, temporary_reference, row_number, merchant_data].hash\n end", "def hash\n [id, numero_estabelecimento, flag_matriz, id_grupo_economico, numero_receita_federal, nome, descricao, nome_fantasia, cep, nome_logradouro, numero_endereco, bairro, cidade, complemento, uf, cep2, nome_logradouro2, numero_endereco2, bairro2, cidade2, complemento2, uf2, obs, contato, email, flag_arquivo_secr_fazenda, flag_cartao_digitado, inativo, id_moeda, id_pais, associado_spc_brasil, mcc, id_tipo_estabelecimento, correspondencia, cargo_contato, tipo_pagamento, consulta, consulta2, consulta3, terminal, data_cadastramento, usuario].hash\n end", "def hash\n return to_s.hash\n end", "def hash\n [id, name, ticker, figi_ticker, ric, isin, sedol, exchange_mic, sponsor, type, description, inception_date, data_change_date, close_date, is_live_listed, legal_structure, intraday_nav_ticker, primary_ticker, primary_ticker_country_code, primary_listing_region, net_expense_ratio, asset_class, other_asset_types, market_cap_range, holds_only_nyse_stocks, holds_only_nasdaq_stocks, growth_value_tilt, growth_type, value_type, sector, industry, sub_industry, cross_sector_theme, natural_resources_type, excludes_financials, excludes_technology, us_or_excludes_us, developed_emerging, specialized_region, continent, latin_america_sub_group, europe_sub_group, asia_sub_group, specific_country, china_listing_location, us_state, real_estate, index_weighting_scheme, market_cap_weighting_type, fundamental_weighting_type, dividend_weighting_type, bond_type, government_bond_types, municipal_bond_region, municipal_vrdo, mortgage_bond_types, bond_tax_status, credit_quality, average_maturity, specific_maturity_year, bond_currency_denomination, laddered, zero_coupon, floating_rate, build_america_bonds, commodity_types, energy_type, agricultural_type, metal_type, inverse_leveraged, target_date_multi_asset_type, currency_hedged, currency_pair, social_environmental_type, clean_energy_type, dividend_type, regular_dividend_payor_type, holds_ml_ps, holds_preferred_stock, holds_closed_end_funds, quant_strategies_type, other_quant_models, hedge_fund_type, derivatives_based, holds_ad_rs, index_linked, includes_short_exposure, index_name, parent_index, index_family, broader_index_family, index_provider, fund_family, index_ticker, etn_issuing_bank, etn_maturity_date, livestock, dynamic_futures_roll, index_provider_code, single_category_designation, registered_countries, issuing_entity_country_code, ucits, replication_structure, domicile, base_currency, listing_currency, fund_listing_date, listing_country_code, listing_region, smartvs_traditional_beta, smartvs_traditional_beta_level2, income_category, etp_structure_type, month_end_assets, etf_portfolio_turnover, firstbridge_id, firstbridge_parent_id, number_of_holdings].hash\n end", "def to_hash\n { :lists => lists.collect(&:to_hash) }\n end", "def hash\n [accounts_date, reporting_period, currency, consolidated_accounts, audit_qualification, number_of_employees, turnover, cost_of_sales, sga_plus_other_net_costs, operating_profit, interest_receivable, interest_payable, pre_tax_profit, taxation, post_tax_profit, dividends_payable, retained_profits, intangible_assets, tangible_assets, investments_and_other_assets, fixed_assets, stock, trade_debtors, other_debtors, miscellaneous_current_assets, cash, current_assets, total_assets, bank_loans_and_overdrafts, trade_creditors, miscellaneous_current_liabilities, other_short_term_finances, current_liabilities, contingent_liabilities, other_long_term_finances, total_long_term_liabilities, total_liabilities, net_assets, equity_paid_up, revaluation_reserve, sundry_reserves, profit_and_loss_account_reserve, shareholder_funds, depreciation, amortisation_of_intangibles, ebitda, working_capital, capital_employed, wages_and_salaries, directors_emoluments, audit_fees, bank_overdraft_and_long_term_loans, net_cash_flow_from_operations, net_cash_flow_before_financing, net_cash_flow_from_financing, increase_in_cash, debtor_days, exports, gross_margin_percentage, operating_profit_margin_percentage, ebitda_margin_percentage, pre_tax_profit_margin_percentage, net_margin_percentage, return_on_assets_percentage, return_on_capital_employed_percentage, return_on_equity, current_ratio, cash_to_current_liabilities_ratio, cash_to_total_assets_percentage, liquidity_ratio, gearing_percentage_on_liability_basis, gearing_percentage_on_gross_debt_basis, gearing_percentage_on_net_debt_basis, debt_to_capital_percentage, inventory_turnover_ratio, cash_to_turnover_ratio, cash_to_turnover_percentage, days_inventory_outstanding, days_sales_outstanding, days_payable_outstanding, cash_conversion_cycle, revenue_per_employee, human_capital_value_added, interest_coverage_ratio, net_debt_to_ebitda_ratio, cfo_to_sales_ratio, auditor, joint_auditor, solicitor, accountant].hash\n end", "def hash()\n #This is a stub, used for indexing\n end", "def to_hash\n to_a.hash\n end", "def to_hash()\n people_hash = @people.map{|person| person.to_hash()}\n return {:people => people_hash}\n end", "def hash( *strs )\n return Digest::MD5.hexdigest( strs.join )\n end", "def serializable_hash \n results.each.inject(empty_bins) do |histogram, result|\n histogram[result] = histogram[result] ? histogram[result] + 1 : 1; histogram\n end\n end", "def hash\n [cusip, ticker, security_name, security_type, title_of_class, stock_exchange, filing_date, value, amount, type, investment_discretion, other_manager, sole_voting_authority, shared_voting_authority, no_voting_authority].hash\n end", "def hash\n end", "def hash\n end", "def hash\n end", "def to_hash\n data.to_hash\n end", "def to_hash\n data.to_hash\n end", "def to_hash\n @summaries\n end", "def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end", "def hash\n\n self.h.fei.hash\n end", "def generate_hexdigest_indexed_list(size_indexed_list, head_size = nil)\n result = {}\n size_indexed_list.each_pair{|old_key, filename_arr|\n filename_arr.each{|filename|\n if head_size == nil\n $stdout.puts \"SHA512 hash calculation: #{filename}\"\n else\n $stdout.puts \"Header (#{head_size}) SHA512 hash calculation: #{filename}\"\n end\n\n hexdigest = get_file_header_sha512(filename, head_size)\n\n if result.has_key?(hexdigest) == false\n result[hexdigest] = []\n end\n result[hexdigest].push(filename)\n }\n }\n return result\nend", "def to_hash\n Hash[to_a]\n end", "def array_to_hash(array)\r\n array.map.each_with_index { |x, i| [i, x] }.to_h # For each value and index create array that has the index,value couple as values and convert it to hash.\r\nend", "def to_hash\n hash = {}\n each do |taxon|\n hash[taxon.taxon_id] = taxon\n end\n return hash\n end", "def hash() #:nodoc:\n prime = 31;\n result = 1;\n result = prime * result + @amount.to_i\n result = prime * result + @new_balance.to_i\n result = prime * result + (@date.nil? ? 0 : Bankjob.date_time_to_ofx(@date).hash);\n result = prime * result + (@raw_description.nil? ? 0 : @raw_description.hash);\n result = prime * result + (@type.nil? ? 0 : @type.hash);\n # don't use value date\n return result;\n end", "def to_hash(*a)\n as_hash(*a)\n end", "def to_hash(*a)\n as_hash(*a)\n end", "def to_h\n array_rounds = []\n\n rounds.each do |round|\n array_rounds << round.to_h\n end\n\n array_rounds\n end", "def list(items)\n split_list = items.split\n list_hash = Hash.new\n split_list.each do |x|\n list_hash[x] = 1\n end\n list_hash\nend" ]
[ "0.66141266", "0.6383351", "0.6350658", "0.6096092", "0.6096092", "0.6096092", "0.6096092", "0.6096092", "0.6096092", "0.6096092", "0.60880315", "0.60880315", "0.604204", "0.604204", "0.6016482", "0.60121477", "0.5893053", "0.5859914", "0.5859914", "0.58557", "0.5849732", "0.5849732", "0.5849732", "0.5849732", "0.5849732", "0.5849732", "0.58284366", "0.5828339", "0.58270234", "0.5809965", "0.5783068", "0.57761526", "0.57758725", "0.57719547", "0.5721186", "0.57142514", "0.5703446", "0.5693856", "0.56810534", "0.56767595", "0.5676098", "0.56647325", "0.56647325", "0.56647325", "0.56647325", "0.56647325", "0.56647325", "0.56647325", "0.56647325", "0.56647325", "0.56647325", "0.5661986", "0.5654222", "0.56318235", "0.56288373", "0.562036", "0.56039405", "0.5599256", "0.559621", "0.5595833", "0.55838716", "0.557952", "0.55733126", "0.55733126", "0.5570999", "0.5570999", "0.5570116", "0.5566762", "0.5562795", "0.5562643", "0.55623984", "0.55344445", "0.5533061", "0.5532313", "0.552773", "0.5521452", "0.55109257", "0.55048585", "0.5497441", "0.5495717", "0.5494285", "0.5490486", "0.5490459", "0.548659", "0.548659", "0.548659", "0.5484341", "0.5484341", "0.5480859", "0.5470764", "0.5455577", "0.5453197", "0.54472256", "0.54268473", "0.542515", "0.5425007", "0.54229254", "0.54229254", "0.54144245", "0.54102993" ]
0.74384373
0
Convert list regions to hash
def convert_regions_to_hash regions = Region.all.map do |region| [region.id, region.name.gsub(/'/, "''")] end regions.to_h end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n lists.inject({}){ |hash, p| hash[p[0]] ||= []; hash[p[0]] << p[1]; hash }\n end", "def to_hash\n @list\n end", "def to_hash() end", "def hash\n Zlib.crc32(to_a.map(&:to_s).sort.to_s)\n end", "def to_hashed(tile_data)\n tokenized = tile_data.split(\",\").map{|x| x.to_i}\n tiles = []\n i = 0\n while i < tokenized.length do\n x = x_coord(tokenized[i])\n y = y_coord(tokenized[i])\n index = tokenized[i+1]\n tiles << {x: x, y: y, index: index}\n i += 3\n end\n tiles\nend", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n from_end.hash + to_end.hash + overlap.hash + complement_overlap.to_s.hash\n end", "def hash\n [id, banco, agencia, conta_corrente, especie, numero_convenio, carteira, codigo_cedente, especie_tipo, especie_documento, aceite, instrucoes, local_pagamento1, local_pagamento2, endereco_cobranca_emissor, nome_beneficiario, cnpj_beneficiario, operador, data, maquina].hash\n end", "def hash\n from_end.hash + to_end.hash + overlap.hash + reverse_overlap.to_s.hash\n end", "def generate_hash\n @groups.flatten.inject([]) {|hash, stone| hash << stone.to_s}.sort.hash\n end", "def convert_regions_to_string(results)\n if results.is_a?(Hash)\n regions = results['regions']\n if regions\n if regions.is_a?(Array)\n results['regions'] = regions.map { |r| REGIONS_CODE.fetch(r.to_i, r) }\n else\n results['regions'] = REGIONS_CODE.fetch(regions.to_i, regions)\n end\n end\n elsif results.is_a?(Array)\n results = results.map { |r| convert_regions_to_string(r) }\n end\n\n results\n end", "def _hash(obj)\n obj.transform_values { |v| _renc(v) }\n end", "def to_hash\n Hash[sort_tuples(section_tuples)]\n end", "def hash_hash(h)\n require 'digest/md5'\n Digest::MD5.hexdigest(Marshal::dump(h.sort))\n end", "def hash\n [self[0], self[1]].hash\n end", "def region_code(region_name)\n region_string = self.name.to_s + region_name.to_s\n deterministic_hash(region_string)\n end", "def blocks_to_hash(blocks)\n blocks.each_with_object({}) do |block, hash|\n hash.merge!(block.to_hash)\n end\n end", "def hash\n [first_row_index, first_cell_index, last_row_index, last_cell_index, allow_splitting].hash\n end", "def get_hash(machines)\n branch = get_branch_id\n hash = Digest::SHA1.hexdigest(machines.sort.join)\n \"#{branch}__#{hash}\"\n end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def band_hash(vector, band)\n rows_per_band = @band_settings.rows\n sub_vector = vector[band * rows_per_band , rows_per_band]\n\n hash_values = sub_vector.each_with_index.map do |value, index| \n Zlib.crc32((value ** (index + 1)).to_s)\n end\n\n hash_values.inject(:+)\n end", "def hash(*) end", "def get_hashes(items)\n hashes = []\n items.each do |item|\n hashes.push((Digest::SHA2.new << item).to_s)\n end\n\n return hashes\n end", "def hash\n [is_bot, is_tor_node, is_threat, is_eu, location, currency_code, currency_name, region_area, subregion_area].hash\n end", "def to_hash\n {:hashes => @hashes}\n end", "def list_as_hash solr_list\n # map\n if solr_list.values.first.is_a? Hash\n solr_list\n else\n solr_list.each_with_object({}) do |(key, values), hash|\n hash[key] = if values.first.is_a? Array\n # arrarr\n Hash[values]\n else\n # flat\n Hash[values.each_slice(2).to_a]\n end\n end\n end\n end", "def all_chunk_hashes\n\t\t\n\t\tbegin\n\t\t\t@all_chunk_map = \"\"\n\t\t\t0.upto(num_chunks-1) { |i|\n\t\t\t\t@all_chunk_map += sha1_chunk(i)\n\t\t\t}\n\n\t\tend unless @all_chunk_map\n\t\t@all_chunk_map\n\tend", "def generate_hexdigest_indexed_list(size_indexed_list, head_size = nil)\n result = {}\n size_indexed_list.each_pair{|old_key, filename_arr|\n filename_arr.each{|filename|\n if head_size == nil\n $stdout.puts \"SHA512 hash calculation: #{filename}\"\n else\n $stdout.puts \"Header (#{head_size}) SHA512 hash calculation: #{filename}\"\n end\n\n hexdigest = get_file_header_sha512(filename, head_size)\n\n if result.has_key?(hexdigest) == false\n result[hexdigest] = []\n end\n result[hexdigest].push(filename)\n }\n }\n return result\nend", "def as_hash(clusters)\n\t\t\tclusters.inject({}){|hash, (key,value)|\n\t\t\t\thash[key]=value.flatten.map(&:items) unless value.flatten.empty?\n\t\t\t\thash\n\t\t\t}\n\t\tend", "def hash_hash(h)\n require 'digest/md5'\n\n ordered = h.sort.map { |i| i.class==Hash ? i.sort : i }\n return ordered.to_s\n Digest::MD5.hexdigest(Marshal::dump(ordered))\n end", "def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end", "def output_hash; end", "def get_regions()\n\t\t{\"include_regions\"=>@include_regions,\"exclude_regions\"=>@exclude_regions}\n\tend", "def hash\n [first_name, last_name, address_one, address_two, city, state, zip, phone, email, country_code].hash\n end", "def hash\n [address1, address2, amount, business_description, business_type, corporate_number, email, end_date, prefecture, remark, representative_name, tel, url, zip_code].hash\n end", "def hash\n [location_id, location_name, location_address, location_city, location_state, location_country, location_phone, location_zip, location_image, location_description, is_offsite_location, owning_location_id, region_id, location_email, city_supported_name, location_current_date_time, location_point, location_boundary1, location_boundary2, location_boundary3, location_boundary4].hash\n end", "def marr2hash(mps)\n mps.map{|e|[e[0], e[1].to_h, e[2]]}\n end", "def hash\n @data[:asin].to_s.hash\n end", "def create_list(list)\r\n\tlist = list.split(\" \")\r\n\thsh = {}\r\n\r\n\tlist.each{|i| hsh[i] = 1}\r\n\r\n\t###print hash\r\n\thsh\r\nend", "def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end", "def hash\n [self.start, self.end, self.label].hash\n end", "def convert_industries_to_hash\n industries = Cluster.all.map do |cluster|\n [cluster.id, cluster.name.gsub(/'/, \"''\")]\n end\n industries.to_h\n end", "def collection_hsh\n collections_hasherizer(source_collections)\n end", "def hash\n [id, numero_estabelecimento, flag_matriz, id_grupo_economico, numero_receita_federal, nome, descricao, nome_fantasia, cep, nome_logradouro, numero_endereco, bairro, cidade, complemento, uf, cep2, nome_logradouro2, numero_endereco2, bairro2, cidade2, complemento2, uf2, obs, contato, email, flag_arquivo_secr_fazenda, flag_cartao_digitado, inativo, id_moeda, id_pais, associado_spc_brasil, mcc, id_tipo_estabelecimento, correspondencia, cargo_contato, tipo_pagamento, consulta, consulta2, consulta3, terminal, data_cadastramento, usuario].hash\n end", "def hash\n @vbits.hash\n end", "def hash\n self.begin.hash ^ self.end.hash\n end", "def hash\n [monitor_tags].hash\n end", "def hash\n [host_list, total_matching, total_returned].hash\n end", "def hash\n [ max_cfvo , max_color , mid_cfvo , mid_color , min_cfvo , min_color ].hash\n end", "def hash\n [].hash\n end", "def hash()\n #This is a stub, used for indexing\n end", "def hash\n @vector\n end", "def to_hash\n memoize(:to_hash) do\n _process_hashed(structures.inject({}) { |acc, elem| Utils.merge(acc, elem) })\n end\n end", "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def to_hash\n list_load\n @log.info(\"Loaded #{(@list)?\"existing\":\"empty\"} id list.\")\n @list\n end", "def hash\n [mcc, uf, id_antecipacao_simulada, id_conta, id_compra, id_tipo_transacao, quantidade_parcelas_antecipaveis, valor_parcela, data_hora_simulacao, taxa_antecipacao_ano, nome_estabelecimento, status, data_compra, tipo_origem_transacao, cidade, pais, latitude, longitude, id_grupo_mcc, descricao_grupo_mcc, id_produto, descricao_produto, descricao_estabelecimento, nome_fantasia_estabelecimento, detalhes].hash\n end", "def hash\r\n return to_s.hash\r\n end", "def to_hash\n { :lists => lists.collect(&:to_hash) }\n end", "def hash(block)\n Digest::SHA256.hexdigest(block.to_s.encode)\n end", "def hash\n swap\n scatter\n completed_string\n end", "def list(items)\n\tsplit_list = items.split\n\tlist_hash = Hash.new(1)\n\tsplit_list.each do |x|\n\t\tlist_hash[x] =1\n\tend\n\tlist_hash\nend", "def hash\n end", "def hash\n end", "def hash\n end", "def hash\n to_a.hash\n end", "def list(items)\n\tsplit_list = items.split\n\tlist_hash = Hash.new(1)\n\tsplit_list.each do |x|\n\t\tlist_hash[x] = 1\n\tend\n\tlist_hash\nend", "def convert_interests_to_hash\n interests = Interest.all.map do |interest|\n [interest.id, interest.name.gsub(/'/, \"''\")]\n end\n interests.to_h\n end", "def hash_transactions\n tx_ids = transactions.map do |tx|\n tx.id\n end\n Digest::SHA256.hexdigest(tx_ids.join(''))\n end", "def hash\n return to_s.hash\n end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def hash\n [range_start_index, range_end_index, fallback_font_list].hash\n end", "def to_hash\n index_hash = Hash.new\n self.each do |organizations|\n index_hash[organizations.name] = organizations.to_s\n end\n index_hash\n end", "def hash\n [aws_elastic_block_store, azure_disk, azure_file, cephfs, cinder, config_map, downward_api, empty_dir, fc, flex_volume, flocker, gce_persistent_disk, git_repo, glusterfs, host_path, iscsi, name, nfs, persistent_volume_claim, photon_persistent_disk, portworx_volume, projected, quobyte, rbd, scale_io, secret, storageos, vsphere_volume].hash\n end", "def hash\n rows.hash\n end", "def hash\n shasum.hash\n end", "def hash\n shasum.hash\n end", "def hash\n shasum.hash\n end" ]
[ "0.64165616", "0.64165616", "0.6298657", "0.603345", "0.5978496", "0.58786464", "0.58479685", "0.5813349", "0.5813349", "0.5813349", "0.5813349", "0.5813349", "0.5813349", "0.5813349", "0.57483333", "0.5743186", "0.5722402", "0.5689771", "0.56876785", "0.5683516", "0.5655535", "0.5647458", "0.5580438", "0.55625343", "0.553166", "0.5525016", "0.55095786", "0.55043113", "0.55043113", "0.55043113", "0.55043113", "0.55043113", "0.55043113", "0.55043113", "0.55043113", "0.55043113", "0.55043113", "0.54943746", "0.5492373", "0.54911524", "0.54818416", "0.54769194", "0.5444619", "0.5441318", "0.54258245", "0.54127276", "0.54117984", "0.54053134", "0.5401797", "0.53924555", "0.53915757", "0.53872186", "0.53871125", "0.53718555", "0.5368512", "0.53658473", "0.5343922", "0.5342477", "0.5341235", "0.5337971", "0.53377753", "0.53373265", "0.53206", "0.5320349", "0.5318293", "0.5312341", "0.53079635", "0.5305651", "0.5301124", "0.52965826", "0.526707", "0.526707", "0.5246451", "0.5237348", "0.52327675", "0.5232178", "0.5228557", "0.5227453", "0.5215433", "0.52085537", "0.52085537", "0.52085537", "0.51880527", "0.51858693", "0.51849693", "0.51826704", "0.51810277", "0.51796687", "0.51796687", "0.51796687", "0.51796687", "0.51796687", "0.51796687", "0.5169779", "0.5161433", "0.51598656", "0.5156723", "0.51548535", "0.51548535", "0.51548535" ]
0.72250307
0
Convert list industries to hash
def convert_industries_to_hash industries = Cluster.all.map do |cluster| [cluster.id, cluster.name.gsub(/'/, "''")] end industries.to_h end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [company_id, company_type, compnay_name, company_name_en, company_address, company_address_en, company_zip_code, company_tax_id, company_branch, company_branch_en, company_branch_code, company_phone, company_mobile, company_fax, company_website].hash\n end", "def hash\n [ticker, company_name, industry_group_number, industry_group_name, fiscal_year_0, fiscal_year_1, fiscal_year_2, company_last_5_year_actual, company_fiscal_year_1_vs_fiscal_year_0, company_fiscal_year_2_vs_fiscal_year_1, company_long_term_growth_mean, company_fiscal_year_1_forward_price_to_earnings, industry_last_5_year_actual, industry_fiscal_year_1_vs_fiscal_year_0, industry_fiscal_year_2_vs_fiscal_year_1, industry_long_term_growth_mean, industry_fiscal_year_1_forward_price_to_earnings, sp500_last_5_year_actual, sp500_fiscal_year_1_vs_fiscal_year_0, sp500_fiscal_year_2_vs_fiscal_year_1, sp500_long_term_growth, sp500_fiscal_year_1_price_to_earnings, company].hash\n end", "def to_hash\n index_hash = Hash.new\n self.each do |organizations|\n index_hash[organizations.name] = organizations.to_s\n end\n index_hash\n end", "def to_hash\n @list\n end", "def hash\n lists.inject({}){ |hash, p| hash[p[0]] ||= []; hash[p[0]] << p[1]; hash }\n end", "def hash\n @data[:asin].to_s.hash\n end", "def to_hash() end", "def productslist_to_bayslist(ref_hash, list_of_items)\n bays_list = []\n for product in list_of_items\n bays_list.push(ref_hash.key(product))\n end\n return bays_list\nend", "def hash\n [accounts_date, reporting_period, currency, consolidated_accounts, audit_qualification, number_of_employees, turnover, cost_of_sales, sga_plus_other_net_costs, operating_profit, interest_receivable, interest_payable, pre_tax_profit, taxation, post_tax_profit, dividends_payable, retained_profits, intangible_assets, tangible_assets, investments_and_other_assets, fixed_assets, stock, trade_debtors, other_debtors, miscellaneous_current_assets, cash, current_assets, total_assets, bank_loans_and_overdrafts, trade_creditors, miscellaneous_current_liabilities, other_short_term_finances, current_liabilities, contingent_liabilities, other_long_term_finances, total_long_term_liabilities, total_liabilities, net_assets, equity_paid_up, revaluation_reserve, sundry_reserves, profit_and_loss_account_reserve, shareholder_funds, depreciation, amortisation_of_intangibles, ebitda, working_capital, capital_employed, wages_and_salaries, directors_emoluments, audit_fees, bank_overdraft_and_long_term_loans, net_cash_flow_from_operations, net_cash_flow_before_financing, net_cash_flow_from_financing, increase_in_cash, debtor_days, exports, gross_margin_percentage, operating_profit_margin_percentage, ebitda_margin_percentage, pre_tax_profit_margin_percentage, net_margin_percentage, return_on_assets_percentage, return_on_capital_employed_percentage, return_on_equity, current_ratio, cash_to_current_liabilities_ratio, cash_to_total_assets_percentage, liquidity_ratio, gearing_percentage_on_liability_basis, gearing_percentage_on_gross_debt_basis, gearing_percentage_on_net_debt_basis, debt_to_capital_percentage, inventory_turnover_ratio, cash_to_turnover_ratio, cash_to_turnover_percentage, days_inventory_outstanding, days_sales_outstanding, days_payable_outstanding, cash_conversion_cycle, revenue_per_employee, human_capital_value_added, interest_coverage_ratio, net_debt_to_ebitda_ratio, cfo_to_sales_ratio, auditor, joint_auditor, solicitor, accountant].hash\n end", "def hash\n [accounting_code, activation_codes, arbitrary_unit_cost, auto_order_last_rebill_dts, auto_order_schedule, barcode, channel_partner_item_id, cogs, component_unit_value, cost, country_code_of_origin, customs_description, description, discount, discount_quantity, discount_shipping_weight, distribution_center_code, edi, exclude_coupon, free_shipping, hazmat, height, item_index, item_reference_oid, kit, kit_component, length, manufacturer_sku, max_days_time_in_transit, merchant_item_id, mix_and_match_group_name, mix_and_match_group_oid, no_shipping_discount, options, packed_by_user, parent_item_index, parent_merchant_item_id, perishable_class, pricing_tier_name, properties, quantity, quantity_refunded, quickbooks_class, refund_reason, return_reason, ship_separately, shipped_by_user, shipped_dts, shipping_status, special_product_type, tags, tax_free, tax_product_type, taxable_cost, total_cost_with_discount, total_refunded, transmitted_to_distribution_center_dts, unit_cost_with_discount, upsell, weight, width].hash\n end", "def hash\n [actor, artist, aspect_ratio, audience_rating, author, back_finding, band_material_type, binding, bluray_region, brand, cero_age_rating, chain_type, clasp_type, color, cpu_manufacturer, cpu_speed, cpu_type, creator, department, director, display_size, edition, episode_sequence, esrb_age_rating, feature, flavor, format, gem_type, genre, golf_club_flex, golf_club_loft, hand_orientation, hard_disk_interface, hard_disk_size, hardware_platform, hazardous_material_type, item_dimensions, is_adult_product, is_autographed, is_eligible_for_trade_in, is_memorabilia, issues_per_year, item_part_number, label, languages, legal_disclaimer, list_price, manufacturer, manufacturer_maximum_age, manufacturer_minimum_age, manufacturer_parts_warranty_description, material_type, maximum_resolution, media_type, metal_stamp, metal_type, model, number_of_discs, number_of_issues, number_of_items, number_of_pages, number_of_tracks, operating_system, optical_zoom, package_dimensions, package_quantity, part_number, pegi_rating, platform, processor_count, product_group, product_type_name, product_type_subcategory, publication_date, publisher, region_code, release_date, ring_size, running_time, shaft_material, scent, season_sequence, seikodo_product_code, size, size_per_pearl, small_image, studio, subscription_length, system_memory_size, system_memory_type, theatrical_release_date, title, total_diamond_weight, total_gem_weight, warranty, weee_tax_value].hash\n end", "def to_jaxb_json_hash\n _h = super\n if !list.nil?\n _ha = Array.new\n list.each { | _item | _ha.push _item.to_jaxb_json_hash }\n _h['venue'] = _ha\n end\n return _h\n end", "def hash\n [id, type, state, country, street, postal_code, city, phone_country, phone_number, email, ip, address_description, identification_number, identification_type, lang, name, first_name, middle_name, last_name, birth_date, occupation, nationality, legal_entity_type, registration_date, registration_number, nature_of_business, source_of_funds, custom_source_of_funds, core_business_activity, purpose_of_opening_account, office_phone, vat_registration_number, financial_regulator, regulatory_licence_number, contact_person_email, trading_country, trading_address, trading_name, number_monthly_transactions, amount_monthly_transactions, documents, metadata, errors, onboarding_status, politically_exposed_people, external_id, city_of_birth, country_of_birth, gender, sales_lead_id, created_at, company_office_number, company_office_number_country, aml_officer_email, aml_officer_phone, aml_officer_phone_country, company_website_url, number_of_employees_in_company, list_of_countries_of_operation, estimated_annual_revenue_turnover, declaration].hash\n end", "def hash\n [id, name, ticker, figi_ticker, ric, isin, sedol, exchange_mic, sponsor, type, description, inception_date, data_change_date, close_date, is_live_listed, legal_structure, intraday_nav_ticker, primary_ticker, primary_ticker_country_code, primary_listing_region, net_expense_ratio, asset_class, other_asset_types, market_cap_range, holds_only_nyse_stocks, holds_only_nasdaq_stocks, growth_value_tilt, growth_type, value_type, sector, industry, sub_industry, cross_sector_theme, natural_resources_type, excludes_financials, excludes_technology, us_or_excludes_us, developed_emerging, specialized_region, continent, latin_america_sub_group, europe_sub_group, asia_sub_group, specific_country, china_listing_location, us_state, real_estate, index_weighting_scheme, market_cap_weighting_type, fundamental_weighting_type, dividend_weighting_type, bond_type, government_bond_types, municipal_bond_region, municipal_vrdo, mortgage_bond_types, bond_tax_status, credit_quality, average_maturity, specific_maturity_year, bond_currency_denomination, laddered, zero_coupon, floating_rate, build_america_bonds, commodity_types, energy_type, agricultural_type, metal_type, inverse_leveraged, target_date_multi_asset_type, currency_hedged, currency_pair, social_environmental_type, clean_energy_type, dividend_type, regular_dividend_payor_type, holds_ml_ps, holds_preferred_stock, holds_closed_end_funds, quant_strategies_type, other_quant_models, hedge_fund_type, derivatives_based, holds_ad_rs, index_linked, includes_short_exposure, index_name, parent_index, index_family, broader_index_family, index_provider, fund_family, index_ticker, etn_issuing_bank, etn_maturity_date, livestock, dynamic_futures_roll, index_provider_code, single_category_designation, registered_countries, issuing_entity_country_code, ucits, replication_structure, domicile, base_currency, listing_currency, fund_listing_date, listing_country_code, listing_region, smartvs_traditional_beta, smartvs_traditional_beta_level2, income_category, etp_structure_type, month_end_assets, etf_portfolio_turnover, firstbridge_id, firstbridge_parent_id, number_of_holdings].hash\n end", "def list_as_hash solr_list\n # map\n if solr_list.values.first.is_a? Hash\n solr_list\n else\n solr_list.each_with_object({}) do |(key, values), hash|\n hash[key] = if values.first.is_a? Array\n # arrarr\n Hash[values]\n else\n # flat\n Hash[values.each_slice(2).to_a]\n end\n end\n end\n end", "def hash\n [accounting, amember, auto_order, ccbill, channel_partner_item_mappings, chargeback, checkout, content, creation_dts, description, description_translated_text_instance_oid, digital_delivery, ebay, email_notifications, enrollment123, fulfillment_addons, gift_certificate, google_product_search, identifiers, inactive, instant_payment_notifications, internal, kit, kit_component_only, kit_definition, last_modified_dts, merchant_id, merchant_item_id, merchant_item_oid, options, parent_category_id, parent_category_path, payment_processing, physical, pricing, properties, realtime_pricing, recommend_replenishment_days, related, reporting, restriction, revguard, reviews, salesforce, shipping, tags, tax, third_party_email_marketing, variant_items, variations, wishlist_member].hash\n end", "def convert_regions_to_hash\n regions = Region.all.map do |region|\n [region.id, region.name.gsub(/'/, \"''\")]\n end\n regions.to_h\n end", "def to_hash\n { name => items.collect(&:to_hash) }\n end", "def convert_educations_to_hash\n educations = Education.all.map do |education|\n [education.id, education.name.gsub(/'/, \"''\")]\n end\n educations.to_h\n end", "def to_h\n Hash[items]\n end", "def hash\n [article_number, name, quantity, unit_price, discount_percent, vat_percent, unit, temporary_reference, row_number, merchant_data].hash\n end", "def hash\n [marketplace_technical_code, account_id, beez_up_order_id, beez_up_order_url, marketplace_business_code, order_marketplace_order_id, order_status_beez_up_order_status, order_status_marketplace_order_status, order_merchant_order_id, order_merchant_e_commerce_software_name, order_merchant_e_commerce_software_version, order_purchase_utc_date, order_last_modification_utc_date, order_marketplace_last_modification_utc_date, order_buyer_name, order_total_price, order_currency_code, processing, etag, links, order_market_place_channel, order_total_tax, order_total_commission, order_payment_method, order_paying_utc_date, order_comment, order_shipping_civility, order_shipping_company_name, order_shipping_address_name, order_shipping_email, order_shipping_address_line1, order_shipping_address_line2, order_shipping_address_line3, order_shipping_address_postal_code, order_shipping_address_city, order_shipping_address_state_or_region, order_shipping_address_country_name, order_shipping_address_country_iso_code_alpha2, order_shipping_phone, order_shipping_mobile_phone, order_shipping_price, order_shipping_method, order_shipping_shipping_tax, order_shipping_earliest_ship_utc_date, order_shipping_latest_ship_utc_date, order_buyer_identifier, order_buyer_civility, order_buyer_company_name, order_buyer_email, order_buyer_address_line1, order_buyer_address_line2, order_buyer_address_line3, order_buyer_address_postal_code, order_buyer_address_city, order_buyer_address_state_or_region, order_buyer_address_country_name, order_buyer_address_country_iso_code_alpha2, order_buyer_phone, order_buyer_mobile_phone, order_order_source_uri, order_order_items_source_uri, order_items, transition_links].hash\n end", "def build_vendors_hash(vendors_raw)\r\n\thash_map = Hash.new\r\n\r\n\tvendors_raw.each do |vendor|\r\n\t\tif(vendor['attributes']['bitsight_guid'] != nil)\r\n\t \thash_map[vendor['attributes']['bitsight_guid']] = vendor\r\n\t\tend\r\n\tend\r\n\thash_map\r\nend", "def food_list(list)\r\n\tfood_hash = {}\r\n\tfood_array = list.split(' ')\r\n\tfood_array.each do |food_item| \r\n\t\tfood_hash[food_item] = 1\r\n\tend\r\n\tfood_hash\r\nend", "def list(items)\n\tsplit_list = items.split\n\tlist_hash = Hash.new(1)\n\tsplit_list.each do |x|\n\t\tlist_hash[x] =1\n\tend\n\tlist_hash\nend", "def hash\n [bank_aba_code, bank_account_name, bank_account_number, bank_account_type, bank_name, bank_owner_type, customer_tax_id, drivers_license_dob, drivers_license_number, drivers_license_state].hash\n end", "def to_jaxb_json_hash\n _h = super\n if !list.nil?\n _ha = Array.new\n list.each { | _item | _ha.push _item.to_jaxb_json_hash }\n _h['country'] = _ha\n end\n return _h\n end", "def all_product_hash\n hash = {}\n items = @all_products\n for prod in items\n hash[prod] = {}\n end\n return hash\n end", "def hash\n [date, net_asset_value, beta_vs_spy, trailing_one_month_return_split_and_dividend, trailing_one_month_return_split_only, trailing_one_year_return_split_and_dividend, trailing_one_year_return_split_only, trailing_one_year_volatility_annualized, trailing_three_year_annualized_return_split_and_dividend, trailing_three_year_annualized_return_split_only, trailing_three_year_volatility_annualized, trailing_five_year_annualized_return_split_and_dividend, trailing_five_year_annualized_return_split_only, trailing_five_year_volatility_annualized, trailing_ten_year_annualized_return_split_and_dividend, trailing_ten_year_annualized_return_split_only, inception_annualized_return_split_and_dividend, inception_annualized_return_split_only, calendar_year_5_return_split_and_dividend, calendar_year_5_return_split_only, calendar_year_4_return_split_and_dividend, calendar_year_4_return_split_only, calendar_year_3_return_split_and_dividend, calendar_year_3_return_split_only, calendar_year_2_return_split_and_dividend, calendar_year_2_return_split_only, calendar_year_1_return_split_and_dividend, calendar_year_1_return_split_only, calendar_year_to_date_return_split_and_dividend, calendar_year_to_date_return_split_only, etf].hash\n end", "def convert_interests_to_hash\n interests = Interest.all.map do |interest|\n [interest.id, interest.name.gsub(/'/, \"''\")]\n end\n interests.to_h\n end", "def create_list(items)\r\n item_array = items.split\r\n grocery_hash = Hash.new\r\n item_array.each do |i|\r\n grocery_hash[i] = 1\r\n end\r\n p grocery_hash\r\nend", "def grocery_list\n puts \"What do you need to buy?\"\n list = gets.chomp\n listarray = list.split(\" \")\n listhash = Hash.new\n \n listarray.each do |item|\n \n listhash[item] = 1\n \n end\n listhash\nend", "def hash\n [additional_properties, currency_code, description, inventory, min_inventory_threshold, not_available, not_displayable, original_price, price, published, sale_id, sale_name, sku, start_date, stop_date].hash\n end", "def hash\n [title_code, _class, tenure, commonhold, addresses, is_not_main_title, is_scottish, purchase_register_entry_date, purchase_prices, purchase_dates].hash\n end", "def list(items)\n\tsplit_list = items.split\n\tlist_hash = Hash.new(1)\n\tsplit_list.each do |x|\n\t\tlist_hash[x] = 1\n\tend\n\tlist_hash\nend", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n [account, adjusted_equity_previous_close, equity, equity_previous_close, excess_maintenance, excess_maintenance_with_uncleared_deposits, excess_margin, excess_margin_with_uncleared_deposits, extended_hours_equity, extended_hours_market_value, last_core_equity, last_core_market_value, market_value, start_date, unwithdrawable_deposits, unwithdrawable_grants, url, withdrawable_amount].hash\n end", "def hash\n [id, banco, agencia, conta_corrente, especie, numero_convenio, carteira, codigo_cedente, especie_tipo, especie_documento, aceite, instrucoes, local_pagamento1, local_pagamento2, endereco_cobranca_emissor, nome_beneficiario, cnpj_beneficiario, operador, data, maquina].hash\n end", "def hash\n [beez_up_order_item_id, order_item_order_item_type, order_item_merchant_imported_product_id, order_item_merchant_imported_product_id_column_name, order_item_merchant_imported_product_url, order_item_merchant_product_id_column_name, order_item_beez_up_store_id, order_item_item_tax, order_item_title, order_item_image_url, order_item_merchant_product_id, order_item_market_place_product_id, order_item_item_price, order_item_quantity, order_item_total_price, order_item_shipping_price].hash\n end", "def webservice_item_to_hash(data_item)\n coa_code_descr_hash = split_code_description_at_first_hyphen(data_item['chartOfAccounts.codeAndDescription'][0])\n org_code_descr_hash = split_code_description_at_first_hyphen(data_item['organization.codeAndDescription'][0])\n sub_fund_code_descr_hash = split_code_description_at_first_hyphen(data_item['subFundGroup.codeAndDescription'][0])\n fin_higher_ed_code_descr_hash = split_code_description_at_first_hyphen(data_item['financialHigherEdFunction.codeAndDescription'][0])\n\n data_hash = {\n description: 'WebService provided data',\n chart_code: coa_code_descr_hash[:code],\n number: data_item['accountNumber'][0],\n name: data_item['accountName'][0],\n organization_code: org_code_descr_hash[:code],\n campus_code: data_item['accountPhysicalCampusCode'][0],\n effective_date: data_item['accountEffectiveDate'][0],\n postal_code: data_item['accountZipCode'][0],\n city: data_item['accountCityName'][0],\n state: data_item['accountStateCode'][0],\n address: data_item['accountStreetAddress'][0],\n type_code: data_item['accountTypeCode'][0],\n sub_fund_group_code: sub_fund_code_descr_hash[:code],\n higher_ed_funct_code: fin_higher_ed_code_descr_hash[:code],\n restricted_status_code: data_item['accountRestrictedStatusCode'][0],\n fo_principal_name: data_item['accountFiscalOfficerUser.principalName'][0],\n supervisor_principal_name: data_item['accountSupervisoryUser.principalName'][0],\n manager_principal_name: data_item['accountManagerUser.principalName'][0],\n budget_record_level_code: data_item['budgetRecordingLevelCode'][0],\n sufficient_funds_code: data_item['accountSufficientFundsCode'][0],\n expense_guideline_text: data_item['accountGuideline.accountExpenseGuidelineText'][0],\n income_guideline_txt: data_item['accountGuideline.accountIncomeGuidelineText'][0],\n purpose_text: data_item['accountGuideline.accountPurposeText'][0],\n labor_benefit_rate_cat_code: data_item['laborBenefitRateCategoryCode'][0],\n account_expiration_date: data_item['accountExpirationDate'][0],\n closed: data_item['closed'][0],\n income_stream_account_number: data_item['incomeStreamAccountNumber'][0],\n income_stream_financial_cost_code: data_item['incomeStreamFinancialCoaCode'][0]\n }.merge!(extended_webservice_item_to_hash(data_item))\n end", "def purchased_items\n @items.inject({}) do |hash, item|\n item = item.capitalize\n if PRODUCTS.include? item\n hash[item] = 0 unless hash[item.to_s]\n hash[item] += 1\n end\n hash\n end\n end", "def hash\n [cusip, ticker, security_name, security_type, title_of_class, stock_exchange, filing_date, value, amount, type, investment_discretion, other_manager, sole_voting_authority, shared_voting_authority, no_voting_authority].hash\n end", "def list(items)\n split_list = items.split\n list_hash = Hash.new\n split_list.each do |x|\n list_hash[x] = 1\n end\n list_hash\nend", "def to_jaxb_json_hash\n _h = super\n if !list.nil?\n _ha = Array.new\n list.each { | _item | _ha.push _item.to_jaxb_json_hash }\n _h['cities'] = _ha\n end\n return _h\n end", "def hash\n [admin_flag, allow_expenses_entered_against_companies_flag, allow_in_cell_entry_on_time_sheet, billable_forecast, calendar, calendar_sync_integration_flag, country, daily_capacity, days_tolerance, default_department_id, default_email, default_location_id, default_phone, disable_online_flag, enable_ldap_authentication_flag, enable_mobile_flag, enable_mobile_gps_flag, enter_time_against_company_flag, expense_approver, first_name, hide_member_in_dispatch_portal_flag, hire_date, home_email, home_extension, home_phone, hourly_cost, hourly_rate, id, identifier, inactive_date, inactive_flag, include_in_utilization_reporting_flag, last_login, last_name, license_class, mapi_name, middle_initial, minimum_hours, mobile_email, mobile_extension, mobile_phone, notes, office_email, office_extension, office_phone, project_default_board, project_default_department_id, project_default_location_id, reports_to, require_expense_entry_flag, require_start_and_end_time_on_time_entry_flag, require_time_sheet_entry_flag, restrict_default_sales_territory_flag, restrict_default_warehouse_bin_flag, restrict_default_warehouse_flag, restrict_department_flag, restrict_location_flag, restrict_project_default_department_flag, restrict_project_default_location_flag, restrict_schedule_flag, restrict_service_default_department_flag, restrict_service_default_location_flag, sales_default_location_id, schedule_capacity, schedule_default_department_id, schedule_default_location_id, security_level, security_location_id, security_role, service_default_board, service_default_department_id, service_default_location_id, service_location, service_teams, time_approver, time_reminder_email_flag, time_sheet_start_date, time_zone, title, type, vendor_number, warehouse, warehouse_bin, work_role, work_type, _info, system_flag].hash\n end", "def as_hash(clusters)\n\t\t\tclusters.inject({}){|hash, (key,value)|\n\t\t\t\thash[key]=value.flatten.map(&:items) unless value.flatten.empty?\n\t\t\t\thash\n\t\t\t}\n\t\tend", "def hash\n \"#{membership} #{formatted_price}\"\n end", "def create_list(items)\r\n list_array = items.split(' ')\r\n grocery_hash = { }\r\n list_array.each do |items|\r\n grocery_hash[items] = 1\r\n end\r\n grocery_hash\r\nend", "def create_list(list, grocery_hash={})\n\tlist_array = list.split(\" \")\n\tquantity = 0\n\tlist_array.each do |item|\n\t\tgrocery_hash[item]=quantity\n\tend\n\tprint_list(grocery_hash)\n\treturn grocery_hash\nend", "def hash\n [income_type, description, tax_rate, tax_amount, tax_amount_no_vat, withheld, total, vat_type].hash\n end", "def hash\n [address1, address2, amount, business_description, business_type, corporate_number, email, end_date, prefecture, remark, representative_name, tel, url, zip_code].hash\n end", "def hash\n [list_id, email, phone, gender, first_name, last_name, is_unsubscribed, is_blacklisted, _custom_attribute_].hash\n end", "def buy_fruit(list)\n list.to_h.map { |fruit, quantity| [fruit] * quantity }.flatten\nend", "def hash\n [id, identifier, password, first_name, middle_initial, last_name, title, report_card, license_class, disable_online_flag, enable_mobile_flag, type, employee_identifer, vendor_number, notes, time_zone, country, service_board_team_ids, enable_mobile_gps_flag, inactive_date, inactive_flag, last_login, photo, office_email, office_phone, office_extension, mobile_email, mobile_phone, mobile_extension, home_email, home_phone, home_extension, default_email, default_phone, security_role, admin_flag, structure_level, security_location, default_location, default_department, reports_to, restrict_location_flag, restrict_department_flag, work_role, work_type, time_approver, expense_approver, billable_forecast, daily_capacity, hourly_cost, hourly_rate, include_in_utilization_reporting_flag, require_expense_entry_flag, require_time_sheet_entry_flag, require_start_and_end_time_on_time_entry_flag, allow_in_cell_entry_on_time_sheet, enter_time_against_company_flag, allow_expenses_entered_against_companies_flag, time_reminder_email_flag, days_tolerance, minimum_hours, time_sheet_start_date, hire_date, service_default_location, service_default_department, service_default_board, restrict_service_default_location_flag, restrict_service_default_department_flag, excluded_service_board_ids, project_default_location, project_default_department, project_default_board, restrict_project_default_location_flag, restrict_project_default_department_flag, excluded_project_board_ids, schedule_default_location, schedule_default_department, schedule_capacity, service_location, restrict_schedule_flag, hide_member_in_dispatch_portal_flag, calendar, sales_default_location, restrict_default_sales_territory_flag, warehouse, warehouse_bin, restrict_default_warehouse_flag, restrict_default_warehouse_bin_flag, mapi_name, calendar_sync_integration_flag, enable_ldap_authentication_flag, ldap_configuration, ldap_user_name, company_activity_tab_format, invoice_time_tab_format, invoice_screen_default_tab_format, invoicing_display_options, agreement_invoicing_display_options, corelytics_username, corelytics_password, remote_package, remote_package_platform, remote_package_user_name, remote_package_password, remote_package_account, authentication_service_type, timebased_one_time_password_activated, _info].hash\n end", "def to_h\n h = {}\n @ledger.each do |name, libs|\n h[name] = (\n case libs\n when Array\n libs.map{ |lib| lib.to_h }\n else\n libs.to_h\n end\n )\n end\n h\n end", "def to_jaxb_json_hash\n _h = super\n if !list.nil?\n _ha = Array.new\n list.each { | _item | _ha.push _item.to_jaxb_json_hash }\n _h['setlist'] = _ha\n end\n return _h\n end", "def hash\n [description, filter, is_enabled, name, product_list].hash\n end", "def products_brands(products)\n products.map{|product| product['brand']}.uniq\nend", "def to_h\n features.group_by(&:postcode).map do |postcode, objects|\n Hash[\n postcode => objects.map do |object|\n {\n 'name' => object.name\n }\n end\n ]\n end.reduce(:merge)\n end", "def hash\n [status, area, days_on_market, originating_system_name].hash\n end", "def hash\n [dep_mgr_name, name, version, license].hash\n end", "def hash\n [name, product_ids_any, product_ids_all, quantity_exact, quantity_min, quantity_max, all_products].hash\n end", "def enrolled_hash\n result = []\n @insurance_coverage_hash[:enrolledCoverages].each do |enrolled_coverage|\n next if ['NONE', 'EMPLOYER_SPONSORED'].include?(enrolled_coverage[:insuranceMarketType])\n if enrolled_coverage[:insuranceMarketType] == \"INDIVIDUAL_INSURANCE\" && @medicaid_hash && @medicaid_hash[:insuranceCoverage]\n # TODO: what need to be done for EMPLOYER_SPONSORED for medicaid when \"INDIVIDUAL_INSURANCE\"\n @medicaid_hash[:insuranceCoverage].each do |medicaid_coverage|\n next unless medicaid_coverage[:insuranceMarketType]\n next if ['NONE', 'EMPLOYER_SPONSORED'].include?(medicaid_coverage[:insuranceMarketType])\n next unless @medicaid_hash[:enrolledInHealthCoverageIndicator]\n result << {\n kind: Ffe::Types::BenefitsKindMapping[medicaid_coverage[:insuranceMarketType].to_sym],\n status: 'is_enrolled',\n start_on: Date.parse('2021-01-01'), # default value\n end_on: medicaid_coverage[:medicaidEndIndicator] ? medicaid_coverage[:medicaidEndDate] : nil\n }\n end\n else\n next unless enrolled_coverage[:insuranceMarketType]\n next unless Ffe::Types::BenefitsKindMapping[enrolled_coverage[:insuranceMarketType].to_sym]\n result << {\n kind: Ffe::Types::BenefitsKindMapping[enrolled_coverage[:insuranceMarketType].to_sym],\n status: 'is_enrolled',\n start_on: Date.parse('2021-01-01'), # default value\n end_on: nil\n }\n end\n end\n result\n end", "def hash\n [last_price, last_time, last_size, bid_price, bid_size, ask_price, ask_size, open_price, close_price, high_price, low_price, exchange_volume, market_volume, updated_on, source, listing_venue, sales_conditions, quote_conditions, market_center_code, is_darkpool, security].hash\n end", "def hash\n [all_tags, any_tags, billing_city, billing_company, billing_country_code, billing_day_phone, billing_evening_phone, billing_first_name, billing_last_name, billing_postal_code, billing_state, email, last_modified_dts_end, last_modified_dts_start, pricing_tier_name, pricing_tier_oid, qb_class, quickbooks_code, shipping_city, shipping_company, shipping_country_code, shipping_day_phone, shipping_evening_phone, shipping_first_name, shipping_last_name, shipping_postal_code, shipping_state, signup_dts_end, signup_dts_start].hash\n end", "def hash\n [first_name, last_name, address_one, address_two, city, state, zip, phone, email, country_code].hash\n end", "def make_list(items)\n grocery_list = Hash.new(1)\n item_array = items.split\n item_array.each do |item|\n \tgrocery_list[item] = 1\n end\n return grocery_list\nend", "def create_shopping_list(list_param)\n list = Hash.new(0)\n array_list = list_param.split(\" \")\n array_list.each do |str|\n normalize_string(str)\n list[str] += 1\n end\n return list\nend", "def hash\n [id, merchant_id, capacity, area_id, date_time, order_id, extra_info, promo_code, credit_card_vault_settings_id, recurring_card_detail_id, deals].hash\n end", "def create_list(list)\r\n\tlist = list.split(\" \")\r\n\thsh = {}\r\n\r\n\tlist.each{|i| hsh[i] = 1}\r\n\r\n\t###print hash\r\n\thsh\r\nend", "def hash\n [to_d.hash, currency.hash].hash\n end", "def create_list(list_str)\n\t# declare initial list with empty hash\n\tgrocery_hash = {}\n\t# split string .split with ' ' (space) as argument\n\tlist_arr = list_str.split(' ')\n\t# store string elements in array\n\tlist_arr.each do |item|\n\t# iterate over array and add each item to a hash\n\t# set item to 1 if it's not already in the hash\n\t# if item already exists, don't add to hash\n\t\tif !grocery_hash.has_key?(item)\n\t\t\tgrocery_hash[item] = 1\n\t\telse\n\t\t\tgrocery_hash[item] += 1\n\t\tend\n\tend\n\t# output: return the hash\n\tgrocery_hash\nend", "def convert_skills_to_hash\n skills = Skill.all.map do |skill|\n [skill.id, skill.name.gsub(/'/, \"''\")]\n end\n skills.to_h\n end", "def bayslist_to_productslist(ref_hash, list_of_bays)\n list_of_items = []\n for bays in list_of_bays\n list_of_items.push(ref_hash[bays.to_sym])\n end\n return list_of_items\nend", "def hash\n [active, category_id, category_specifics, condition_description, condition_id, consecutive_failures, custom_category1, custom_category2, dispatch_time_max, domestic_1_additional_cost, domestic_1_first_cost, domestic_2_additional_cost, domestic_2_first_cost, domestic_3_additional_cost, domestic_3_first_cost, domestic_4_additional_cost, domestic_4_first_cost, ebay_auction_id, ebay_specific_inventory, ebay_template_name, ebay_template_oid, end_time, free_shipping, free_shipping_method, international_1_additional_cost, international_1_first_cost, international_2_additional_cost, international_2_first_cost, international_3_additional_cost, international_3_first_cost, international_4_additional_cost, international_4_first_cost, last_status_dts, listed_dispatch_time_max, listed_ebay_template_oid, listing_dts, listing_duration, listing_price, listing_price_override, listing_type, marketplace_analysis, marketplace_analysis_perform, marketplace_final_value_fee_percentage, marketplace_last_check_dts, marketplace_lowest, marketplace_map_violation, marketplace_multiplier, marketplace_other_price, marketplace_other_seller, marketplace_other_shipping, marketplace_other_total, marketplace_our_additional_profit_potential, marketplace_our_price, marketplace_our_profit, marketplace_our_shipping, marketplace_our_total, marketplace_overhead, marketplace_profitable, next_attempt_dts, next_listing_duration, no_promotional_shipping, packaging_handling_costs, previous_ebay_auction_id, quantity, reserve_price, send_dimensions_and_weight, start_time, status, target_dispatch_time_max].hash\n end", "def hash\n [id, rfc, legal_name, commercial_name, credit_days, credit_amount, payment_method, creation_date, status, sales_contact, credit_contact, loctaion, comments, price_list, payment_term_type, email, telephones, number, account_number, default_discount, client_source, account, addresses].hash\n end", "def hash\n [id, document_date, gl_class, gl_type_id, gl_item_id, sales_code, description, cost, memo, tax_note, vendor_number, account_number, cost_account_number, inventory_account_number, vendor_account_number, item, item_description, sales_description, taxable, item_price, item_cost, unit_of_measure, quantity, total, currency, serialized_flag, serial_numbers, drop_shipped_flag, line_number, warehouse_bin, warehouse_site, sub_category, shipment_method, item_type_xref, inventory_xref, cogs_xref, uom_schedule_xref, price_level_xref, location_xref, tax_code, purchase_header_tax_group, tax_code_xref, tax_rate, tax_agency_xref].hash\n end", "def hash\n [amount.hash, currency.hash].hash\n end", "def hash\n [amount.hash, currency.hash].hash\n end", "def build_driver_hash(all_rides, all_drivers)\n all_rides.each_pair do |driver, data|\n all_drivers[driver] = 0\n end\n return all_drivers\nend", "def create_list(new_items)\n\tshopping_list = new_items.split(\" \")\n\titems_hash = Hash.new\n\tshopping_list.each do |item| \n\titems_hash[item] = 1\n\tend\n\treturn items_hash\nend", "def to_hash(version = 1)\n h = nil\n if version == 1\n arr = []\n @items.each_with_index do |item, index|\n temp_h = item.to_hash(version)\n temp_h[:workflow_index] = index\n\n arr << temp_h\n end\n\n h = arr\n else\n raise \"Version #{version} not yet implemented for to_hash\"\n end\n\n h\n end", "def hash\n [client_id, secret, client_name, language, country_codes, user, products, additional_consented_products, required_if_supported_products, webhook, access_token, link_customization_name, redirect_uri, android_package_name, institution_data, account_filters, eu_config, institution_id, payment_initiation, deposit_switch, employment, income_verification, base_report, consumer_report_permissible_purpose, auth, transfer, update, identity_verification, statements, user_token, investments, investments_auth, hosted_link].hash\n end", "def hash\n [client_id, secret, company_name, is_diligence_attested, products, create_link_customization, logo, legal_entity_name, website, application_name, technical_contact, billing_contact, customer_support_info, address, is_bank_addendum_completed, assets_under_management, redirect_uris].hash\n end", "def hash\n [affiliate_rate, campaign_id, category, client_review, create_date, currency_code, description, document_id, fee_amount, fee_type, financial_rate, financial_rate_term, financial_rate_term_unit, financial_rate_type, id, image, institution_name, is_active, metadata, minimum_contribution, minimum_contribution_term, minimum_contribution_term_unit, name, node_map, offer_link, offer_term, offer_term_unit, prerequisite, prerequisite_type, rating, secondary_id, subcategory, update_date].hash\n end", "def hash\n [alliance_id, ancestry_id, birthday, bloodline_id, corporation_id, description, gender, name, race_id, security_status].hash\n end", "def get_hashes(items)\n hashes = []\n items.each do |item|\n hashes.push((Digest::SHA2.new << item).to_s)\n end\n\n return hashes\n end", "def hash\n [sequence_number, corporate_number, process, correct, update_date, change_date, name, name_image_id, kind, prefecture_name, city_name, street_number, address_image_id, prefecture_code, city_code, post_code, address_outside, address_outside_image_id, close_date, close_cause, successor_corporate_number, change_cause, assignment_date, latest, en_name, en_prefecture_name, en_city_name, en_address_outside, furigana, hihyoji].hash\n end", "def create_list(list)\n grocery_hash = Hash.new(1)\n list = list.split(' ')\n list.each do |x|\n grocery_hash[x]=1\n end\n p grocery_hash\nend", "def jde_seller_invoice_hashes_array\n jde_invoice_hashes_array('seller')\n end", "def to_hash\n list_load\n @log.info(\"Loaded #{(@list)?\"existing\":\"empty\"} id list.\")\n @list\n end", "def _brands_hash (brands,brand_stocks,brand_total_purchases,brand_total_sales)\n brand_ave_price = (brand_total_sales/brand_total_purchases).round(2)\n return {\n brand: brands,\n stock: brand_stocks.round(2),\n ave_price: brand_ave_price,\n sales: brand_total_sales.round(2)\n }\nend", "def list_creator(inputed_list)\r\n\r\n grocery_hash = {}\r\n grocery_list = inputed_list.split\r\n\r\n grocery_list.each do |item| \r\n grocery_hash[item] = $grocery_hash[item].to_i + 1\r\n end\r\n\r\n p grocery_hash\r\n return $grocery_hash\r\nend", "def brands_array\n ($products_hash['items'].map { |toy| toy['brand'] }).uniq\nend", "def create_list(items)\n\n\tgrocery_list_hash = {}\n\tlist_array = items.split(\" \")\n\n\tlist_array.each do |item|\n\t\tgrocery_list_hash.store(item.to_sym, 1)\n\tend\n\n\tgrocery_list_hash\nend", "def hash_hash(h)\n require 'digest/md5'\n Digest::MD5.hexdigest(Marshal::dump(h.sort))\n end", "def brand_name\n\tproducts_brand = ($products_hash[\"items\"].map {|each_brand| each_brand[\"brand\"]}).uniq\nend", "def stock_list(hash)\n \n # First build array of unique items\n stock=Array.new\n for key,value in hash\n unless stock.include?(value[:item]) \n stock << value[:item]\n end\n end\n \n\n # Then build array with each unique item and its count\n\n return_array = Array.new\n\n for stock_item in stock\n count_of_items = 0\n \n for key,value in hash\n\n if value[:item] == stock_item\n count_of_items += 1 \n end\n end\n\n return_array << [stock_item,count_of_items]\n\n end\n\n return return_array\n\nend", "def hash\n [airline_data, amount, avs_postcode_policy, bill_to, card_holder_name, cardnumber, csc, csc_policy, currency, duplicate_policy, expmonth, expyear, external_mpi, identifier, match_avsa, mcc6012, merchantid, sdk, ship_to, threedsecure, trans_info, trans_type].hash\n end" ]
[ "0.6187148", "0.6172327", "0.6170666", "0.59252983", "0.58345586", "0.58128846", "0.57879925", "0.5776287", "0.576923", "0.57294047", "0.57084894", "0.56902504", "0.5689507", "0.56777465", "0.56734854", "0.56700295", "0.56560326", "0.56513476", "0.5634995", "0.5628242", "0.5608039", "0.5606276", "0.55834377", "0.55827874", "0.5567179", "0.55487835", "0.5517606", "0.5514689", "0.54940665", "0.5483838", "0.54806596", "0.5468663", "0.5462038", "0.54608434", "0.5455417", "0.5445341", "0.5445341", "0.54364216", "0.5419996", "0.54116845", "0.54094124", "0.5406612", "0.5405559", "0.5400375", "0.54001784", "0.53926194", "0.5384913", "0.53820425", "0.53619266", "0.5357742", "0.53546715", "0.5348237", "0.5339621", "0.53320503", "0.5329781", "0.5327233", "0.53271013", "0.5318963", "0.5314261", "0.5306113", "0.53033215", "0.5302189", "0.5302006", "0.529767", "0.5295598", "0.52945614", "0.5285592", "0.52787447", "0.5276304", "0.5272712", "0.52651536", "0.52608925", "0.5256519", "0.52563584", "0.52536964", "0.5247113", "0.5245534", "0.5240877", "0.5235991", "0.5235991", "0.5233868", "0.5227333", "0.5225092", "0.52247655", "0.52239126", "0.5219215", "0.5216634", "0.5215067", "0.5211621", "0.5211148", "0.52031815", "0.5199828", "0.5198404", "0.51960266", "0.5192495", "0.5191046", "0.519006", "0.51888543", "0.5187193", "0.5185993" ]
0.76263624
0
Convert list skills to hash
def convert_skills_to_hash skills = Skill.all.map do |skill| [skill.id, skill.name.gsub(/'/, "''")] end skills.to_h end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [list_id, email, phone, gender, first_name, last_name, is_unsubscribed, is_blacklisted, _custom_attribute_].hash\n end", "def to_hash\n @list\n end", "def computed_skills\n skills_hash = Hash[skills_count] # {\"générosité\"=>1, \"passion\"=>2}\n wanted_skills_hash = Hash[wanted_skills.map { |s| [s.name, 0] }] # {\"jonglage\"=>0, \"passion\"=>0}\n wanted_skills_hash.merge(skills_hash).except(*unwanted_skills.map(&:name)) # {\"générosité\"=>1, \"jonglage\"=>0}\n end", "def hash\n lists.inject({}){ |hash, p| hash[p[0]] ||= []; hash[p[0]] << p[1]; hash }\n end", "def hash\n [actor, artist, aspect_ratio, audience_rating, author, back_finding, band_material_type, binding, bluray_region, brand, cero_age_rating, chain_type, clasp_type, color, cpu_manufacturer, cpu_speed, cpu_type, creator, department, director, display_size, edition, episode_sequence, esrb_age_rating, feature, flavor, format, gem_type, genre, golf_club_flex, golf_club_loft, hand_orientation, hard_disk_interface, hard_disk_size, hardware_platform, hazardous_material_type, item_dimensions, is_adult_product, is_autographed, is_eligible_for_trade_in, is_memorabilia, issues_per_year, item_part_number, label, languages, legal_disclaimer, list_price, manufacturer, manufacturer_maximum_age, manufacturer_minimum_age, manufacturer_parts_warranty_description, material_type, maximum_resolution, media_type, metal_stamp, metal_type, model, number_of_discs, number_of_issues, number_of_items, number_of_pages, number_of_tracks, operating_system, optical_zoom, package_dimensions, package_quantity, part_number, pegi_rating, platform, processor_count, product_group, product_type_name, product_type_subcategory, publication_date, publisher, region_code, release_date, ring_size, running_time, shaft_material, scent, season_sequence, seikodo_product_code, size, size_per_pearl, small_image, studio, subscription_length, system_memory_size, system_memory_type, theatrical_release_date, title, total_diamond_weight, total_gem_weight, warranty, weee_tax_value].hash\n end", "def add_skills(skill_hash)\n char_skill_levels = self.skill_levels\n \n update_hash = Hash.new\n \n # For each character skill_level, index the \n # skill_level object with the skill name\n char_skill_levels.each do |sk|\n update_hash[sk.skill.name] = sk\n end\n\n skill_hash.each do |name, value|\n begin\n update_hash[name].level = value\n rescue NoMethodError\n sk = Skill.find_by_name( name )\n sl = SkillLevel.new\n sl.level = value\n sl.skill = sk\n skill_levels << sl\n end\n end\n \n update_hash.each do |k,v|\n v.save if v.changed?\n end\n end", "def convert_educations_to_hash\n educations = Education.all.map do |education|\n [education.id, education.name.gsub(/'/, \"''\")]\n end\n educations.to_h\n end", "def convert_single_skill(skill)\n hash = {\n id: skill.id,\n db_symbol: skill.db_symbol,\n callCommonEvent: skill.map_use,\n battleEngineHandler: skill.be_method,\n type: skill.type,\n basePower: skill.power,\n baseAccuracy: skill.accuracy,\n ppCount: skill.pp_max,\n target: skill.target,\n class: skill.atk_class,\n criticalRateType: skill.critical_rate,\n priority: skill.priority,\n contact: skill.direct,\n effect_chance: skill.effect_chance,\n canBeBlocked: skill.blocable,\n isSnatchable: skill.snatchable,\n canBeMirrored: skill.mirror_move,\n canBeReflected: skill.magic_coat_affected,\n isFlyingMove: skill.gravity,\n isSoundMove: skill.sound_attack,\n canUnfreeze: skill.unfreeze,\n triggerKingRock: skill.king_rock_utility,\n stageIncrease: skill.battle_stage_mod\n }\n if skill.status && skill.status > 0\n hash[:inflict] = @no_symbol_conv ? skill.status : States.index(skill.status)\n end\n return hash\n end", "def convert_interests_to_hash\n interests = Interest.all.map do |interest|\n [interest.id, interest.name.gsub(/'/, \"''\")]\n end\n interests.to_h\n end", "def skills\n\t\t[]\n\tend", "def list_as_hash solr_list\n # map\n if solr_list.values.first.is_a? Hash\n solr_list\n else\n solr_list.each_with_object({}) do |(key, values), hash|\n hash[key] = if values.first.is_a? Array\n # arrarr\n Hash[values]\n else\n # flat\n Hash[values.each_slice(2).to_a]\n end\n end\n end\n end", "def hash\n [rank, suit].hash\n end", "def convert_all_skill\n item_json = @data.collect { |item| convert_single_skill(item) }\n return item_json\n end", "def all_skills_with_hashtags\n self.skills.map(&:name).collect{|name| '#' + name}.join(' ')\n end", "def all_skills_with_hashtags\n self.skills.map(&:name).collect{|name| '#' + name}.join(' ')\n end", "def create_list(user_list)\n# input: string of items separated by spaces (example: \"carrots apples cereal pizza\")\n# puts \"\"\n# steps:\n # [fill in any steps here]\n list_array = user_list.split(\",\")\n # set default quantity\n quanity = 1\n # print the list to the console [can you use one of your other methods here?]\n p list_array.collect { |item| [item, quanity] }\n $list_hash = Hash[list_array.collect { |item| [item, quanity] } ]\n# output: [what data type goes here, array or hash?] Print result in hash\n p $list_hash\n $list_hash\nend", "def create_list(list)\r\n\tlist = list.split(\" \")\r\n\thsh = {}\r\n\r\n\tlist.each{|i| hsh[i] = 1}\r\n\r\n\t###print hash\r\n\thsh\r\nend", "def skills\n pers_all = (!$game_persistent_skills[0].nil? ? $game_persistent_skills[0] : [])\n pers_class = (!$game_persistent_skills[@class_id].nil? ? $game_persistent_skills[@class_id] : [])\n pers_subclass = (!$game_persistent_skills[@subclass_id].nil? ? $game_persistent_skills[@subclass_id] : [])\n (@skills | added_skills | pers_all | pers_class | pers_subclass).uniq.sort.collect {|id| $data_skills[id] }\n end", "def hash\n [alliance_id, ancestry_id, birthday, bloodline_id, corporation_id, description, gender, name, race_id, security_status].hash\n end", "def to_hash\n list_load\n @log.info(\"Loaded #{(@list)?\"existing\":\"empty\"} id list.\")\n @list\n end", "def get_talents\n\n # skills = [ self.skill_mandatory1, self.skill_mandatory2, self.skill_mandatory3,\n # self.skill_elective1, self.skill_elective2, self.skill_elective3 ]\n\n talents = {}\n\n # skills.each do |skill|\n # # TODO CHECK FOR RANDOM/CAREER SKILL\n # talents[skill] = Talent.where( skill: skill ).find_each\n # end\n\n talents\n\n end", "def to_hash() end", "def to_hash\n build\n\n return @probabilities\n end", "def skillsNeeded\n\t\t[]\n\tend", "def to_hash()\n people_hash = @people.map{|person| person.to_hash()}\n return {:people => people_hash}\n end", "def get_skills_with_scores \n self.skills.map do |skill|\n score = skill.grades.find_by(user_id: self.id).score\n {skill: skill, score: score}\n end\n end", "def hash\n [queue_id, flow_id, provider, skill_ids, language_id, priority, attributes, to_address, to_name, from_address, from_name, subject, direction, html_body, text_body].hash\n end", "def to_hash\n memoize(:to_hash) do\n _process_hashed(structures.inject({}) { |acc, elem| Utils.merge(acc, elem) })\n end\n end", "def to_jaxb_json_hash\n _h = super\n if !list.nil?\n _ha = Array.new\n list.each { | _item | _ha.push _item.to_jaxb_json_hash }\n _h['setlist'] = _ha\n end\n return _h\n end", "def to_h\n Hash[items]\n end", "def to_h\n words.zip(spoonerize).to_h\n end", "def to_h\n\t\t{\n\t\t\t:name => @name,\n\t\t\t:intents => @intents.map { |i| i.to_h }\n\t\t}\n\tend", "def hash\n [lead_id, salutation, title, first_name, last_name, organization_name, phone_number, mobile_phone_number, fax_number, email_address, website_url, owner_user_id, date_created_utc, date_updated_utc, converted, converted_date_utc, converted_contact_id, converted_organization_id, converted_opportunity_id, visible_to, responsible_user_id, industry, lead_status_id, lead_source_id, visible_team_id, employee_count, lead_rating, lead_description, visible_user_ids, customfields, address_street, address_city, address_state, address_postcode, address_country, tags, image_url].hash\n end", "def to_hash()\n person_hash = {:id => @id, :name => @name, :faction => @faction, :faction_for_chapter => @faction_for_chapter,\n :allegiance => @allegiance.map{|allegiance_faction| allegiance_faction.to_hash()}}\n if (@style != \"\")\n person_hash.merge!(:style => @style)\n end\n if (@note != \"\")\n person_hash.merge!(:note => @note)\n end\n if (@wiki != \"\")\n person_hash.merge!(:wiki => @wiki)\n end\n if (@km != \"\")\n person_hash.merge!(:km => @km)\n end\n return person_hash\n end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def seed_mindleaps_skills(organization)\n Skill.create([\n { skill_name: 'Memorization', skill_description: 'Ability to learn and recall sequences or patterns of information.', organization: organization, grade_descriptors: GradeDescriptor.create([\n { mark: 1, grade_description: 'Student cannot recall a sequence of 4 steps even after prompted at least three times' },\n { mark: 2, grade_description: 'Student can recall a sequence of 4 steps with 1 or no prompts' },\n { mark: 3, grade_description: 'Student can recall at least 2 sections of the warm up from class to class' },\n { mark: 4, grade_description: 'Student can recall entire warm up sequence, moving in time with the teacher, and can repeat diagonal steps after one prompt from the teacher' },\n { mark: 5, grade_description: 'Student can recall entire warm up sequence without teacher guidance, at least four diagonal steps, and at least 16 counts of choreography without teacher prompts' },\n { mark: 6, grade_description: 'Student can recall entire warm up, at least eight diagonal steps, all of choreography and name at least 6 muscles without teacher prompts' },\n { mark: 7, grade_description: 'Student can memorize a new sequence of choreography given in one class and do all of the above' }\n ]) },\n { skill_name: 'Grit', skill_description: 'Perseverance and passion for long-term goals.', organization: organization, grade_descriptors: GradeDescriptor.create([\n { mark: 1, grade_description: 'Student arrives at the center but does not participate in dance class even with teacher or peer encouragement' },\n { mark: 2, grade_description: 'Student participates in less than half of the class' },\n { mark: 3, grade_description: 'Student is present but not actively trying throughout the entire class' },\n { mark: 4, grade_description: 'Student participates in warm up, recognizes change in directions, understands number repetitions, and completes at least 1/2 of diagonal or choreography sections of class' },\n { mark: 5, grade_description: 'Student participates in the entire class and noticeably demonstrates persistence when struggling' },\n { mark: 6, grade_description: 'All of the above and student asks or answers questions' },\n { mark: 7, grade_description: 'Student shows an extraordinary level of commitment by either practicing before/after class (self-initiated), asking questions that suggest a deeper analysis, or asking for more opportunities to practice' }\n ]) },\n { skill_name: 'Teamwork', skill_description: 'Ability to work and/or create with other students.', organization: organization, grade_descriptors: GradeDescriptor.create([\n { mark: 1, grade_description: 'Student refuses to hold hands or interact with partner in a required sequence across the floor' },\n { mark: 2, grade_description: 'Student will do above, but is unable to work or communicate with his/her peer in any piece of choreography or another part of class, even when encouraged by the teacher' },\n { mark: 3, grade_description: 'Student can work together with his/her peer in 2 or 3 simple steps in diagonal (two by two) or choreography when demonstrated/encouraged by the teacher with two verbal prompts' },\n { mark: 4, grade_description: 'Student can work together with his/her peer in a section of diagonal (two by two) and complete at least four partnered/group movements in choreography' },\n { mark: 5, grade_description: 'Student can work in a group to create a short choreographic piece with teacher coaching' },\n { mark: 6, grade_description: 'Student can work in a group to create a short choreographic piece without teacher coaching' },\n { mark: 7, grade_description: 'Student can work in a group to create a piece that is presented to the rest of class' }\n ]) },\n { skill_name: 'Discipline', skill_description: 'Ability to obey rules and/or a code of conduct.', organization: organization, grade_descriptors: GradeDescriptor.create([\n { mark: 1, grade_description: 'Student repeatedly talks back, fights, hits or argues with peers and teachers and does not stop even when asked repeatedly; student is sent out of the class for 5-10 minutes by the teacher' },\n { mark: 2, grade_description: 'Student has to be reminded at least twice by name to respect his peers and/or pay attention to the teacher' },\n { mark: 3, grade_description: 'Student has to be reminded once by name to respect his peers or pay attention to the teacher' },\n { mark: 4, grade_description: 'Student respects/pays attention to the teacher, but bothers his peers, or vice versa (with no comments/prompts by teacher)' },\n { mark: 5, grade_description: 'Student works well with others and no teacher intervention is needed' },\n { mark: 6, grade_description: 'Student actively encourages others to pay attention and improve their behavior' },\n { mark: 7, grade_description: 'Student actively becomes a role model of exceptional, respectful behavior to the others' }\n ]) },\n { skill_name: 'Self-Esteem', skill_description: 'Confidence in one’s own abilities.', organization: organization, grade_descriptors: GradeDescriptor.create([\n { mark: 1, grade_description: 'Student cannot perform any movement isolated (by himself)' },\n { mark: 2, grade_description: 'Student can perform a sequence of 2-4 steps on his own' },\n { mark: 3, grade_description: 'Student can continue through warm up sections and repetition of diagonal steps without encouragement from the teacher' },\n { mark: 4, grade_description: 'Student can demonstrate by himself steps of the diagonal and volunteer parts of the choreography when asked by the teacher' },\n { mark: 5, grade_description: 'Student can demonstrate the warm up, diagonal steps and all of the choreography by himself with confidence and no prompts' },\n { mark: 6, grade_description: 'Student can verbally explain movement in the warm up, diagonal and choreography' },\n { mark: 7, grade_description: 'Student demonstrates confidence as a person and dancer through extending full use of body in space ' }\n ]) },\n { skill_name: 'Creativity & Self-Expression', skill_description: 'Use of imagination.', organization: organization, grade_descriptors: GradeDescriptor.create([\n { mark: 1, grade_description: 'Student is unable to demonstrate personal creativity by making up any pose or movement of his own' },\n { mark: 2, grade_description: 'Student can only demontrate creative movement in a single step or movement with teacher\\'s prompts' },\n { mark: 3, grade_description: 'Student can make up his own arms for a sequence of steps' },\n { mark: 4, grade_description: 'Student can only demonstrate creative movement in a series of steps by copying the teacher or peer\\'s earlier demonstration' },\n { mark: 5, grade_description: 'Student can create his own movements that have not been taught before and differ from standard hip hop moves' },\n { mark: 6, grade_description: 'Student can create his own choreography' },\n { mark: 7, grade_description: 'Student can create his own choreography and present it' }\n ]) },\n { skill_name: 'Language', skill_description: 'The process to understand and communicate.', organization: organization, grade_descriptors: GradeDescriptor.create([\n { mark: 1, grade_description: 'Student is unable to count in a foreign language (eg English)' },\n { mark: 2, grade_description: 'Student can count with teacher prompting, and can recall some basic words with one prompt' },\n { mark: 3, grade_description: 'Student can count without prompts and recall some words' },\n { mark: 4, grade_description: 'Student can recite positions in the warm up, at least six of the diagonal steps\\' names and positions' },\n { mark: 5, grade_description: 'Student can recite positions in warm up, diagonal steps, and muscle names' },\n { mark: 6, grade_description: 'Student can recite simple phrases (minimum of 3 words)' },\n { mark: 7, grade_description: 'Student can make himself understood to ask questions or make comments' }\n ]) }\n ])\nend", "def to_h\n {}.tap do |result|\n self.class.each_attribute do |attribute|\n value = send(attribute.name)\n if value&.respond_to?(:to_h) && !value.is_a?(Array) && !value.is_a?(ConfigList)\n value = value.to_h\n elsif value&.respond_to?(:to_a)\n value = value.to_a\n end\n result[attribute.name.to_s] = value\n end\n end\n end", "def svm_words_to_hash\n Hash[svm_words.map.with_index.to_a]\n end", "def all_skills\n self.skills.map(&:name).join(\", \")\n end", "def hash\n [subject_property, proprietorship, surname, forename, middle_name, all_names, historical_match].hash\n end", "def hash\n [description, filter, is_enabled, name, product_list].hash\n end", "def list_hash(name)\n { list: { name: name } }\n end", "def hash\n [principals, relation].hash\n end", "def convert_industries_to_hash\n industries = Cluster.all.map do |cluster|\n [cluster.id, cluster.name.gsub(/'/, \"''\")]\n end\n industries.to_h\n end", "def get_skills_with_scores\n self.skills.map do |skill|\n #need to figure out how to get the score of the grade\n #grade user_id, skill_id, score\n score = skill.grades.find_by(user_id: self.id).score \n {skill: skill, score: score}\n end\n end", "def all_skills\n self.skills.map(&:name).join(', ')\n end", "def to_hash\n { :lists => lists.collect(&:to_hash) }\n end", "def hash_forbidden_pairs(list)\r\n # Adding the reversed pairs of students to the list\r\n (0..list.length - 1).each do |x|\r\n list.push([list[x][1], list[x][0]])\r\n end\r\n\r\n # Making all unique first elements of the pairs in the list keys of the Hash\r\n keys = list.map(&:first).uniq\r\n # Adding the corresponding values, specified by the second elements in the pairs\r\n @forbidden_pairs = keys.map do |k|\r\n {k => list.select { |a| a[0] == k }.compact.map(&:last)}\r\n end\r\n @forbidden_pairs = @forbidden_pairs.reduce({}, :merge)\r\n # Removing unique values for each key\r\n @forbidden_pairs.keys.each do |x|\r\n @forbidden_pairs[x] = @forbidden_pairs[x].uniq\r\n end\r\n end", "def hash\n [first_name, last_name, address_one, address_two, city, state, zip, phone, email, country_code].hash\n end", "def hash\n to_a.hash\n end", "def hash\n [name, product_ids_any, product_ids_all, quantity_exact, quantity_min, quantity_max, all_products].hash\n end", "def to_hash\n { name => items.collect(&:to_hash) }\n end", "def hash\n \"#{membership} #{formatted_price}\"\n end", "def hash\n [pay_slip_id, employee_id, pay_run_id, last_edited, first_name, last_name, total_earnings, gross_earnings, total_pay, total_employer_taxes, total_employee_taxes, total_deductions, total_reimbursements, total_court_orders, total_benefits, bacs_hash, payment_method, earnings_lines, leave_earnings_lines, timesheet_earnings_lines, deduction_lines, reimbursement_lines, leave_accrual_lines, benefit_lines, payment_lines, employee_tax_lines, employer_tax_lines, court_order_lines].hash\n end", "def hash\n [id, alternate_id, type, first_name, surname, date_of_brith, date_of_birth, shipping_address, mailing_address, home_phone, mobile_phone, email_address, mailing_address_active, accounts, classifications, member_photo, gender, receive_email, receive_sms, password].hash\n end", "def weapons_hash()\n return @weapons\n end", "def hash\n [mandate_id, title, legal_informations, unique_mandate_reference, mandate_status, user_id, debtor_name, debtor_address, debtor_city, debtor_zip_code, debtor_country, debtor_iban, debtor_bic, sequence_type, creditor_name, sepa_creditor_identifier, creditor_address, creditor_city, creditor_zip_code, creditor_country, signature_date, debtor_signature_ip, signed, debtor_identification_code, debtor_reference_party_name, debtor_reference_identification_code, creditor_reference_party_name, creditor_reference_identification_code, contract_identification_number, contract_description, is_paper, sdd_type, revocation_signature_date, created_ip, created_date, modified_date, user_id_ultimate_creditor].hash\n end", "def hashify\n emotions = {anger: anger, contempt: contempt, disgust: disgust, fear: fear,\n happiness: happiness, neutral: neutral, sadness: sadness, surprise: surprise}\n emotions.sort_by {|k, v| v}.reverse.to_h\n end", "def hash\n [id, id_account, webid, application_date, date, value, gross_value, nature, original_wording, simplified_wording, stemmed_wording, wording, id_category, state, date_scraped, rdate, vdate, bdate, coming, active, id_cluster, comment, last_update, deleted, original_value, original_gross_value, original_currency, commission, commission_currency, country, counterparty, card].hash\n end", "def skill_schools\r\n\t\t[\r\n\t\t\t'Tailoring', \r\n\t\t\t'Jewelcrafting', \r\n\t\t\t'Enchanting',\r\n\t\t\t'Blacksmithing',\r\n\t\t\t'Summoning',\r\n\t\t\t'Shadow',\r\n\t\t\t'Fire',\r\n\t\t\t'Holy',\r\n\t\t\t'Frost',\r\n\t\t\t'Melee',\r\n\t\t\t'Ranged'\r\n\t\t]\r\n\tend", "def hash\n [input, playback_policy, per_title_encode, passthrough, mp4_support, normalize_audio, master_access, test].hash\n end", "def hash\n [access_complexity, access_vector, authentication, availability_impact, confidentiality_impact, exploit_score, impact_score, integrity_impact, score, vector].hash\n end", "def xref_skills_and_team_members\n skills = {\n 'Languages' => Hash.new {|h,k| h[k] = Array.new},\n 'Technologies' => Hash.new {|h,k| h[k] = Array.new},\n 'Specialties' => Hash.new {|h,k| h[k] = Array.new},\n }\n\n @site_data['team'].each do |unused_name, member|\n skills.each do |category, category_xref|\n add_skill_xref_if_present(category.downcase, member, category_xref)\n end\n end\n\n skills.delete_if {|category,skill_xref| skill_xref.empty?}\n @site_data['skills'] = skills unless skills.empty?\n end", "def hash\n [sequence_number, corporate_number, process, correct, update_date, change_date, name, name_image_id, kind, prefecture_name, city_name, street_number, address_image_id, prefecture_code, city_code, post_code, address_outside, address_outside_image_id, close_date, close_cause, successor_corporate_number, change_cause, assignment_date, latest, en_name, en_prefecture_name, en_city_name, en_address_outside, furigana, hihyoji].hash\n end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def create_list(string_list)\n answer_hash = Hash.new(1)\n list_array = string_list.split(\" \")\n list_array.each do |item|\n answer_hash[item] = 1\n end\n return answer_hash\n print answer_hash\nend", "def marr2hash(mps)\n mps.map{|e|[e[0], e[1].to_h, e[2]]}\n end", "def hash\n [id, banco, agencia, conta_corrente, especie, numero_convenio, carteira, codigo_cedente, especie_tipo, especie_documento, aceite, instrucoes, local_pagamento1, local_pagamento2, endereco_cobranca_emissor, nome_beneficiario, cnpj_beneficiario, operador, data, maquina].hash\n end", "def hash\n [accounting, amember, auto_order, ccbill, channel_partner_item_mappings, chargeback, checkout, content, creation_dts, description, description_translated_text_instance_oid, digital_delivery, ebay, email_notifications, enrollment123, fulfillment_addons, gift_certificate, google_product_search, identifiers, inactive, instant_payment_notifications, internal, kit, kit_component_only, kit_definition, last_modified_dts, merchant_id, merchant_item_id, merchant_item_oid, options, parent_category_id, parent_category_path, payment_processing, physical, pricing, properties, realtime_pricing, recommend_replenishment_days, related, reporting, restriction, revguard, reviews, salesforce, shipping, tags, tax, third_party_email_marketing, variant_items, variations, wishlist_member].hash\n end", "def to_hash\n Hash[to_a]\n end", "def to_hash\n to_a.hash\n end", "def make_result_list(items)\r\n items.map do |item|\r\n {\r\n 'username' => item['username'],\r\n 'score' => item['score'].to_i\r\n }\r\n end\r\nend", "def list(items)\n\tsplit_list = items.split\n\tlist_hash = Hash.new(1)\n\tsplit_list.each do |x|\n\t\tlist_hash[x] =1\n\tend\n\tlist_hash\nend", "def to_mash; end", "def lands_hash\n []\n end", "def create_hash_class \n\t hash_class = {}\n\t @students_list.select do |student|\n\t\thash_class[student.name] = student.create_score_hash\n\t end\n\t puts \"Class's Hash: #{hash_class}\"\n\tend", "def name_and_role\n instructors.map do |instructors_hash|\n {instructors_hash[:name] => instructors_hash[:role]}\n end\nend", "def skill_list_params\n params.require(:skill_list).permit(:title, :experience_length, :user_rating, :admin_rating, :user_notes, :admin_notes, :date_rated, :link)\n end", "def create_list(string_list)\n answer_hash = Hash.new(0)\n list_array = string_list.split(\" \")\n list_array.each do |item|\n answer_hash[item] = 1\n end\n return answer_hash\nend", "def add_skills(skill_names,created_by_id)\r\n job_seeker = JobSeeker.find(created_by_id)\r\n JobSeekerProficiency.delete_all(\"job_seeker_id = '#{self.id}'\")\r\n \r\n for skill in skill_names\r\n\r\n skill_split = skill.split(\"__\");\r\n skill_obj = Proficiency.find_by_name(skill_split[0])\r\n if skill_obj.nil?\r\n skill_obj = Proficiency.create({:name=>skill_split[0],:created_by=>created_by_id,:activated=>\"0\"})\r\n end\r\n\r\n JobSeekerProficiency.create!(:job_seeker_id => created_by_id, :proficiency_id => skill_obj.id, :education_id => skill_split[1].split(\"_\")[0], :skill_id => skill_split[2].split(\"_\")[0])\r\n\r\n end\r\n end", "def list(items)\n split_list = items.split\n list_hash = Hash.new\n split_list.each do |x|\n list_hash[x] = 1\n end\n list_hash\nend", "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def hash\n [company_id, company_type, compnay_name, company_name_en, company_address, company_address_en, company_zip_code, company_tax_id, company_branch, company_branch_en, company_branch_code, company_phone, company_mobile, company_fax, company_website].hash\n end", "def hash\n [].hash\n end", "def hash\n @data[:asin].to_s.hash\n end", "def student_data_hash\n\n # turn data into 2 Dim array containing arrays of eles where delimiter is colon :\n clean_user_account_data = ruby_class_user_accounts.map { |x| x.split(/:/) }\n\n # turn data into a hash using 2 arrays for keys and values\n keys = %w[user_name password uid gid gcos_field home_directory login_shell]\n final_array_of_hashes = []\n\n clean_user_account_data.each do |account_data|\n hash = Hash.new\n keys.each_with_index { |item, index| hash[item] = account_data[index] }\n final_array_of_hashes << hash\n end\n final_array_of_hashes\n end", "def list(items)\n\tsplit_list = items.split\n\tlist_hash = Hash.new(1)\n\tsplit_list.each do |x|\n\t\tlist_hash[x] = 1\n\tend\n\tlist_hash\nend", "def getSpellHash\n\t\t# Neue Hashes\n\t\t@allSpells = Hash.new\n\t\tspellQ = Hash.new\n\t\tspellW = Hash.new\n\t\tspellE = Hash.new\n\t\tspellR = Hash.new\n\n\t\t# Arrays welche gebraucht werden\n\t\t@sant = Array.new\n\t\tsantEffect = Array.new\n\t\tarrayEffects = Array.new\n\t\tarrayName = Array.new\n\t\tarrayCooldown = Array.new\n\t\tarrayCostType = Array.new\n\t\tarrayCostBurn = Array.new\n\t\tarrayImageSpellUrl = Array.new\n\t\tarrayRange = Array.new\n\t\tarrayResourcePlain = Array.new\n\t\tarrayResource = Array.new\n\n\t\tarraySkillScale = Array.new\n\t\t$allchamps.each do |champ|\n\n\n\n\t\t\t@spells = champ.spells\n\t\t\tif champ[:name] == self[:name]\n\n\n\t\t\t\t# Schlauft durch alle spells und speichert die informationen die wir brauchen in arrays\n\t\t\t\[email protected] do |spell|\n\t\t\t\t\tputs spell\n\t\t\t\t\tspell.each do |key,value|\n\t\t\t\t\t\tif key == \"sanitizedTooltip\"\n\t\t\t\t\t\t\[email protected](value)\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif key == \"name\"\n\t\t\t\t\t\t\tarrayName.push(value)\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif key == \"cooldownBurn\"\n\t\t\t\t\t\t\tarrayCooldown.push(value)\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif key == \"costType\"\n\t\t\t\t\t\t\tarrayCostType.push(value)\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif key == \"costBurn\"\n\t\t\t\t\t\t\tarrayCostBurn.push(value)\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif key == \"rangeBurn\"\n\t\t\t\t\t\t\tarrayRange.push(value)\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif key == \"image\"\n\t\t\t\t\t\t\tvalue.each do |k,v|\n\t\t\t\t\t\t\t\tif k == \"full\"\n\t\t\t\t\t\t\t\t\t@img = v\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\turl = $apiurl + \"spell/\" + @img\n\t\t\t\t\t\t\tarrayImageSpellUrl.push(url)\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif key == \"resource\"\n\t\t\t\t\t\t\tarrayResourcePlain.push(value)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# TEIL FUER DIE RESSOURCEN\n\n\t\t\t\tcostCount = 0\n\t\t\t\tarrayResourcePlain.each do |res|\n\t\t\t\t\t# Wenn der String ein { enthaelt so ist es kein normaler mana typ und man muss die kosten richtig machen\n\t\t\t\t\tif !res.include? 'cost' and !res.include? 'No Cost'\n\t\t\t\t\t\tinhalt = res.scan(/\\{(.*?)\\}/)[0].to_s\n\t\t\t\t\t\tinhalt.delete! \"{[]\"\n\t\t\t\t\t\tinhalt.delete!(' ')\n\t\t\t\t\t\tputs inhalt\n\t\t\t\t\t\t# macht aus \"e1\" -> e1\n\t\t\t\t\t\trichtigInhalt = inhalt[1] + inhalt[2]\n\t\t\t\t\t\tputs richtigInhalt\n\n\t\t\t\t\t\t\t@spells[costCount].each do |key,value|\n\t\t\t\t\t\t\t\tif key == \"effectBurn\"\n\t\t\t\t\t\t\t\t\t# Speichert den gesuchten wert abs\n\t\t\t\t\t\t\t\t\twert = value[inhalt[2].to_i]\n\t\t\t\t\t\t\t\t\tputs wert\n\t\t\t\t\t\t\t\t\tnewText = res.dup\n\t\t\t\t\t\t\t\t\tnewText.sub! \"#{richtigInhalt}\", \"#{wert}\"\n\t\t\t\t\t\t\t\t\tnewText.delete! \"{}\"\n\t\t\t\t\t\t\t\t\tarrayResource.push(newText)\n\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t# Wenn die kosten in dem key cost zu suchen sind\n\t\t\t\t\telsif res.include? 'cost'\n\t\t\t\t\t\t@spells[costCount].each do |key,value|\n\t\t\t\t\t\t\tif key == \"costBurn\"\n\t\t\t\t\t\t\t\t# Speichert den gesuchten wert abs\n\t\t\t\t\t\t\t\twert = value\n\t\t\t\t\t\t\t\tnewText = res.dup\n\t\t\t\t\t\t\t\tnewText.sub! \"{{ cost }}\", \"#{wert}\"\n\t\t\t\t\t\t\t\tarrayResource.push(newText)\n\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\n\n\t\t\t\t\telsif res.include? 'No Cost'\n\t\t\t\t\t\tarrayResource.push(res)\n\t\t\t\t\tend\n\n\t\t\t\tcostCount += 1\n\t\t\tend\n\n\t\t\t# Weil die API bei maokai ult als einziges ein e4 drin hat wird dies einzeln gelöst sollte man aber nochaml überdenken\n\t\t\tif champ[:name] == \"Maokai\"\n\t\t\t\tnewMao = arrayResource[3].dup\n\t\t\t\tnewMao.sub! \"{{ e4 }}\",\"30\"\n\t\t\t\tarrayResource[3] = newMao\n\t\t\tend\n\n\t\t\t\t# TEIL FUER DIE DESCRIPTION\n\n\t\t\t\t# nimmt alle teile mit {{ }} im string raus und spechert den inhalt in ein array -> [\"e1\",\"a1\",\"e5\"]\n\t\t\t\[email protected] do |skill|\n\t\t\t\t\tsantEffect = []\n\t\t\t\t\tarrayBrackets = skill.scan(/\\{(.*?)\\}/)\n\n\t\t\t\t\tarrayBrackets.each do |ele|\n\n\t\t\t\t\t\twithoutBrackets = ele[0].delete! \"{}\"\n\t\t\t\t\t\t# löscht alle whitespaces\n\t\t\t\t\t\tsantEffect.push(withoutBrackets.strip)\n\n\t\t\t\t\tend\n\t\t\t\t\t# hat für alle abilities die richtigen effect und keys => [\"[\"e1\",\"a1\",\"e5\"]\",\"[\"e3\",\"e5\",\"a2\"]\".....]\n\t\t\t\t\tarrayEffects.push(santEffect)\n\t\t\t\tend\n\n\t\t\t\t#Array in dem die richtigen infos gespeichert wird\n\t\t\t\tarraySpellEffects = Array.new\n\n\t\t\t\tcount = 0\n\t\t\t\[email protected] do |spell|\n\t\t\t\t\tarrayEffects[count].each do |effect|\n\t\t\t\t\t\t# Wenn es sich um ein effect handelt = \"e\" dann muss man in der tabelle \"effectBurn\" suchen\n\t\t\t\t\t\tif effect[0] == \"e\"\n\t\t\t\t\t\t\t# Schlauft durch alle spells des champs\n\t\t\t\t\t\t\tspell.each do |key,value|\n\t\t\t\t\t\t\t\tif key == \"effectBurn\"\n\t\t\t\t\t\t\t\t\t# Speichert den gesuchten wert abs\n\t\t\t\t\t\t\t\t\twert = value[effect[1].to_i]\n\t\t\t\t\t\t\t\t\tarraySpellEffects.push(wert)\n\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t# Wenn es sich um ein coeff handelt = \"a\" so muss man diesen coeff in der tabelle \"vars\" suchen\n\t\t\t\t\t\telsif effect[0] == \"a\"\n\t\t\t\t\t\t\tbool = false\n\t\t\t\t\t\t\t# Schlauft durch alle spells des champs\n\t\t\t\t\t\t\tspell.each do |key,value|\n\t\t\t\t\t\t\t\tif key == \"vars\"\n\n\t\t\t\t\t\t\t\t\tvalue.each do |vars|\n\t\t\t\t\t\t\t\t\t\tvars.each do |key, value|\n\t\t\t\t\t\t\t\t\t\t\t# wenn der Key \"key\" so muss überprüft werden ob dieser den gelichen value hat wie effect\n\t\t\t\t\t\t\t\t\t\t\tif key == \"key\"\n\t\t\t\t\t\t\t\t\t\t\t\tif value == effect\n\t\t\t\t\t\t\t\t\t\t\t\t\tbool = true\n\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t# Stimmt der key überein so kann dieser wert genommen werden\n\t\t\t\t\t\t\t\t\t\t\tif bool\n\t\t\t\t\t\t\t\t\t\t\t\tif key == \"coeff\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t@coeff = value\n\n\n\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t# Fügt den dmg typ der skalierung dem array hinzus\n\t\t\t\t\t\t\t\t\t\t\t\tif key == \"link\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t@dmgType = value\n\n\t\t\t\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\tarraySpellEffects.push(@coeff.to_s + \" \" + @dmgType.to_s)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tcount += 1\n\t\t\t\tend\n\t\t\t\tputs arraySkillScale\n\n\t\t\t\t#Loop that replace the text with the correct values\n\t\t\t\tnewSkills = Array.new\n\t\t\t\tcount = 0\n\t\t\t\tarrayEffectCount = 0\n\t\t\t\tarrayScaleCount = 0\n\t\t @sant.each do |skill|\n\t\t\t\t\t# dup ist wichtig damit man den kopierten string bearbeitet und nicht den orignal den man von der api bekommt\n\t\t\t\t\tnewText = skill.dup\n\t\t\t\t\tarrayEffects[count].each do |effects|\n\t\t\t\t\t\tif skill.include?(effects)\n\t\t\t\t\t\t\t# Die f abfragen scheinen buggy zu sein bei der API\n\t\t\t\t\t\t\tif effects[0] != \"f\"\n\t\t\t\t\t\t\t\t\t# sub| erstellt einen neuen string aus dem vorherigen\n\t\t\t\t\t\t\t\t\t@text = newText.sub! \"#{effects}\", \"#{arraySpellEffects[arrayEffectCount]}\"\n\n\t\t\t\t\t\t\t\tarrayEffectCount += 1\n\t\t\t\t\t\t\t\tarrayScaleCount += 1\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\[email protected]! \"{}\"\n\t\t\t\t\[email protected]! \"[]\"\n\t\t\t\t\tnewSkills.push(@text)\n\t\t\t\t\tcount +=1\n\n\t\t\t\tend\n\n\t\t\t\t#added den Inhalt der Array dem richtigen Hash zu =>\tarrayName arrayCooldown arrayCostType arrayCostBurn\n\t\t\t\tspellCount = 0\n\t\t\t\t4.times do\n\t\t\t\t\tif spellCount == 0\n\t\t\t\t\t\tspellQ[\"description\"] = newSkills[0]\n\t\t\t\t\t\tspellQ[\"name\"] = arrayName[0]\n\t\t\t\t\t\tspellQ[\"cooldown\"] = arrayCooldown[0]\n\t\t\t\t\t\tspellQ[\"costType\"] = arrayCostType[0]\n\t\t\t\t\t\tspellQ[\"costBurn\"] = arrayCostBurn[0]\n\t\t\t\t\t\tspellQ[\"image\"] = arrayImageSpellUrl[0]\n\t\t\t\t\t\tspellQ[\"range\"] = arrayRange[0]\n\t\t\t\t\t\tspellQ[\"ressource\"] = arrayResource[0]\n\t\t\t\t\telsif spellCount == 1\n\t\t\t\t\t\tspellW[\"description\"] = newSkills[1]\n\t\t\t\t\t\tspellW[\"name\"] = arrayName[1]\n\t\t\t\t\t\tspellW[\"cooldown\"] = arrayCooldown[1]\n\t\t\t\t\t\tspellW[\"costType\"] = arrayCostType[1]\n\t\t\t\t\t\tspellW[\"costBurn\"] = arrayCostBurn[1]\n\t\t\t\t\t\tspellW[\"image\"] = arrayImageSpellUrl[1]\n\t\t\t\t\t\tspellW[\"range\"] = arrayRange[1]\n\t\t\t\t\t\tspellW[\"ressource\"] = arrayResource[1]\n\t\t\t\t\telsif spellCount == 2\n\t\t\t\t\t\tspellE[\"description\"] = newSkills[2]\n\t\t\t\t\t\tspellE[\"name\"] = arrayName[2]\n\t\t\t\t\t\tspellE[\"cooldown\"] = arrayCooldown[2]\n\t\t\t\t\t\tspellE[\"costType\"] = arrayCostType[2]\n\t\t\t\t\t\tspellE[\"costBurn\"] = arrayCostBurn[2]\n\t\t\t\t\t\tspellE[\"image\"] = arrayImageSpellUrl[2]\n\t\t\t\t\t\tspellE[\"range\"] = arrayRange[2]\n\t\t\t\t\t\tspellE[\"ressource\"] = arrayResource[2]\n\t\t\t\t\telsif spellCount == 3\n\t\t\t\t\t\tspellR[\"description\"] = newSkills[3]\n\t\t\t\t\t\tspellR[\"name\"] = arrayName[3]\n\t\t\t\t\t\tspellR[\"cooldown\"] = arrayCooldown[3]\n\t\t\t\t\t\tspellR[\"costType\"] = arrayCostType[3]\n\t\t\t\t\t\tspellR[\"costBurn\"] = arrayCostBurn[3]\n\t\t\t\t\t\tspellR[\"image\"] = arrayImageSpellUrl[3]\n\t\t\t\t\t\tspellR[\"range\"] = arrayRange[3]\n\t\t\t\t\t\tspellR[\"ressource\"] = arrayResource[3]\n\t\t\t\t\tend\n\t\t\t\t\tspellCount += 1\n\t\t\t\tend\n\t\t\t\t# Adde alle Hashes dem Hash mit allen spells\n\n\t\t\t\t@allSpells[\"Q\"] = spellQ\n\t\t\t\t@allSpells[\"W\"] = spellW\n\t\t\t\t@allSpells[\"E\"] = spellE\n\t\t\t\t@allSpells[\"R\"] = spellR\n\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tputs @allSpells\n\t\t\treturn @allSpells\n\t\tend", "def hash\n [id, first_name, last_name, type, company, site, address_line1, address_line2, city, state, zip, country, relationship, department, inactive_flag, default_merge_contact_id, security_identifier, manager_contact_id, assistant_contact_id, title, school, nick_name, married_flag, children_flag, significant_other, portal_password, portal_security_level, disable_portal_login_flag, unsubscribe_flag, gender, birth_day, anniversary, presence, mobile_guid, facebook_url, twitter_url, linked_in_url, communication_items, _info, custom_fields].hash\n end", "def skills_guard\n result = []\n states.each do |state|\n next unless state.skill_guard > 0\n result << [$data_skills[state.skill_guard], state.sg_range]\n end\n return result.uniq\n end", "def hash\n [sales_activity, service_team, company_team, workflow, status_workflow, service_template, opportunity, sales_team, project_manager, knowledge_baseb_article, my_company_president_role, my_company_coo_role, my_company_controller_role, my_company_dispatch_role, my_company_service_manager_role, my_company_duty_manager_role, department_manager, dispatch_member, service_manager, duty_manager, delete_open_time_sheets_flag].hash\n end", "def hashify(obj)\n JSON.parse(obj.to_json).with_indifferent_access\n end", "def to_hash\n @relations.each_with_object({}) do |(rel,val), obj|\n rel = rel.to_s\n\n hashed_val = val.map(&:to_hash)\n if val.length == 1 && !single_item_arrays?\n hashed_val = val.first.to_hash\n end\n\n obj[rel] = hashed_val\n end\n end" ]
[ "0.6141389", "0.60800886", "0.6002242", "0.58697593", "0.5759202", "0.57475084", "0.5733835", "0.57204074", "0.56981117", "0.56916", "0.56436944", "0.5584743", "0.5561509", "0.55539453", "0.55539453", "0.553916", "0.5510622", "0.5501273", "0.5482035", "0.54812753", "0.54800963", "0.5472975", "0.54553664", "0.54528636", "0.54462785", "0.5437986", "0.5422632", "0.5394672", "0.5394087", "0.5379719", "0.53763515", "0.53748584", "0.5339286", "0.532862", "0.53274065", "0.53274065", "0.5297299", "0.5292114", "0.5291176", "0.528525", "0.5280731", "0.5279881", "0.52734447", "0.52582794", "0.5250616", "0.52452236", "0.5243441", "0.52240807", "0.52238446", "0.5220005", "0.5218897", "0.52153164", "0.5203835", "0.52024144", "0.52005965", "0.5188655", "0.5187714", "0.5181779", "0.51805276", "0.51803964", "0.51774716", "0.5174258", "0.51731694", "0.51648754", "0.51607233", "0.5151049", "0.5151049", "0.5151049", "0.5151049", "0.5151049", "0.5151049", "0.5137332", "0.5137224", "0.5132383", "0.5128115", "0.512645", "0.5123568", "0.51226836", "0.51188546", "0.5118542", "0.5114842", "0.51115745", "0.5110108", "0.5107997", "0.5103092", "0.50921226", "0.50877047", "0.5086255", "0.5086255", "0.5084697", "0.508232", "0.50756085", "0.50714046", "0.50633574", "0.5061842", "0.5057693", "0.50564426", "0.5053437", "0.5050996", "0.50427276" ]
0.7976907
0
Convert list educations to hash
def convert_educations_to_hash educations = Education.all.map do |education| [education.id, education.name.gsub(/'/, "''")] end educations.to_h end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def to_hash() end", "def hash_hash(h)\n require 'digest/md5'\n Digest::MD5.hexdigest(Marshal::dump(h.sort))\n end", "def hash\n [id, alternate_id, type, first_name, surname, date_of_brith, date_of_birth, shipping_address, mailing_address, home_phone, mobile_phone, email_address, mailing_address_active, accounts, classifications, member_photo, gender, receive_email, receive_sms, password].hash\n end", "def hash\n digest = Digest::MD5.new\n digest << title.to_s\n digest << content.join('').to_s\n digest.to_s\n end", "def hash_hash(h)\n require 'digest/md5'\n\n ordered = h.sort.map { |i| i.class==Hash ? i.sort : i }\n return ordered.to_s\n Digest::MD5.hexdigest(Marshal::dump(ordered))\n end", "def hash\n lists.inject({}){ |hash, p| hash[p[0]] ||= []; hash[p[0]] << p[1]; hash }\n end", "def hashed_input\n\t\tmd5_hex = Digest::MD5.hexdigest(@term)\n\t\tmd5_hex.scan(/../).map { |s| s.to_i(16) }\n\tend", "def collection_hsh\n collections_hasherizer(source_collections)\n end", "def to_hash\n @list\n end", "def hash\n [actor, artist, aspect_ratio, audience_rating, author, back_finding, band_material_type, binding, bluray_region, brand, cero_age_rating, chain_type, clasp_type, color, cpu_manufacturer, cpu_speed, cpu_type, creator, department, director, display_size, edition, episode_sequence, esrb_age_rating, feature, flavor, format, gem_type, genre, golf_club_flex, golf_club_loft, hand_orientation, hard_disk_interface, hard_disk_size, hardware_platform, hazardous_material_type, item_dimensions, is_adult_product, is_autographed, is_eligible_for_trade_in, is_memorabilia, issues_per_year, item_part_number, label, languages, legal_disclaimer, list_price, manufacturer, manufacturer_maximum_age, manufacturer_minimum_age, manufacturer_parts_warranty_description, material_type, maximum_resolution, media_type, metal_stamp, metal_type, model, number_of_discs, number_of_issues, number_of_items, number_of_pages, number_of_tracks, operating_system, optical_zoom, package_dimensions, package_quantity, part_number, pegi_rating, platform, processor_count, product_group, product_type_name, product_type_subcategory, publication_date, publisher, region_code, release_date, ring_size, running_time, shaft_material, scent, season_sequence, seikodo_product_code, size, size_per_pearl, small_image, studio, subscription_length, system_memory_size, system_memory_type, theatrical_release_date, title, total_diamond_weight, total_gem_weight, warranty, weee_tax_value].hash\n end", "def hash\n [attachments, created_by_id, created_by_name, created_on, id, modified_by_id, modified_by_name, modified_on, name, owners, status_id, status_name, address_business_city, address_business_country, address_business_is_primary, address_business_line1, address_business_state, address_business_zip_code, address_home_city, address_home_country, address_home_is_primary, address_home_line1, address_home_state, address_home_zip_code, address_other_city, address_other_country, address_other_is_primary, address_other_line1, address_other_state, address_other_zip_code, current_position_company_id, current_position_company_name, current_position_title, current_position_when_end, current_position_when_start, description, education_accreditation_id, education_accreditation_name, education_honors, education_institution_id, education_institution_name, education_when_end, education_when_start, email_address_other, email_address_other_is_primary, email_address_personal, email_address_personal_is_primary, email_address_work, email_address_work_is_primary, ethnicity_id, ethnicity_name, external_primary_key, first_name, gender_id, gender_name, key_date_anniversary, key_date_birthday, key_date_other, last_name, middle_name, nick_name, phone_number_fax, phone_number_fax_extension, phone_number_fax_is_primary, phone_number_home, phone_number_home_extension, phone_number_home_is_primary, phone_number_mobile, phone_number_mobile_extension, phone_number_mobile_is_primary, phone_number_other, phone_number_other_extension, phone_number_other_is_primary, phone_number_skype, phone_number_skype_extension, phone_number_skype_is_primary, phone_number_work_direct, phone_number_work_direct_extension, phone_number_work_direct_is_primary, phone_number_work_main, phone_number_work_main_extension, phone_number_work_main_is_primary, preferred_contact_method_type_id, preferred_contact_method_type_name, record_type, related_contact_assistant_first_name, related_contact_assistant_id, related_contact_assistant_is_primary, related_contact_assistant_last_name, related_contact_client_first_name, related_contact_client_id, related_contact_client_is_primary, related_contact_client_last_name, related_contact_other_first_name, related_contact_other_id, related_contact_other_is_primary, related_contact_other_last_name, related_contact_referred_by_first_name, related_contact_referred_by_id, related_contact_referred_by_is_primary, related_contact_referred_by_last_name, related_contact_spouse_first_name, related_contact_spouse_id, related_contact_spouse_is_primary, related_contact_spouse_last_name, salary, salary_details, salutation_id, salutation_name, social_aim, social_aim_is_primary, social_facebook_chat, social_facebook_chat_is_primary, social_face_time, social_face_time_is_primary, social_google_talk, social_google_talk_is_primary, social_icq, social_icq_is_primary, social_other, social_other_is_primary, social_skype, social_skype_is_primary, social_twitter, social_twitter_is_primary, social_yahoo_msg, social_yahoo_msg_is_primary, source_id, source_name, suffix_id, suffix_name, tags, website_blog, website_blog_is_primary, website_business, website_business_is_primary, website_facebook, website_facebook_is_primary, website_linked_in, website_linked_in_is_primary, website_other, website_other_is_primary, website_personal, website_personal_is_primary].hash\n end", "def hash( *strs )\n return Digest::MD5.hexdigest( strs.join )\n end", "def hashes email\n text_with_hashes = \"\"\n entries = Entry.select(:text).uniq.where(:email => email).where(\"text LIKE ?\", \"%#%\")\n entries.each do |e|\n text_with_hashes += \" \" + e.text\n end\n\n return text_with_hashes.split(' ').delete_if {|a| !a.match('^#\\w+$') }.sort.uniq\n end", "def hash\n [mandate_id, title, legal_informations, unique_mandate_reference, mandate_status, user_id, debtor_name, debtor_address, debtor_city, debtor_zip_code, debtor_country, debtor_iban, debtor_bic, sequence_type, creditor_name, sepa_creditor_identifier, creditor_address, creditor_city, creditor_zip_code, creditor_country, signature_date, debtor_signature_ip, signed, debtor_identification_code, debtor_reference_party_name, debtor_reference_identification_code, creditor_reference_party_name, creditor_reference_identification_code, contract_identification_number, contract_description, is_paper, sdd_type, revocation_signature_date, created_ip, created_date, modified_date, user_id_ultimate_creditor].hash\n end", "def hash\n [address1, address2, amount, business_description, business_type, corporate_number, email, end_date, prefecture, remark, representative_name, tel, url, zip_code].hash\n end", "def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end", "def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end", "def get_hashes(items)\n hashes = []\n items.each do |item|\n hashes.push((Digest::SHA2.new << item).to_s)\n end\n\n return hashes\n end", "def hash\n [first_name, last_name, address_one, address_two, city, state, zip, phone, email, country_code].hash\n end", "def subscriber_hash(email)\n # Simple hash of the email address.\n Digest::MD5.hexdigest(email)\n end", "def hash\n [sequence_number, corporate_number, process, correct, update_date, change_date, name, name_image_id, kind, prefecture_name, city_name, street_number, address_image_id, prefecture_code, city_code, post_code, address_outside, address_outside_image_id, close_date, close_cause, successor_corporate_number, change_cause, assignment_date, latest, en_name, en_prefecture_name, en_city_name, en_address_outside, furigana, hihyoji].hash\n end", "def hash\r\n return to_s.hash\r\n end", "def hash(*) end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash\n [article_number, name, quantity, unit_price, discount_percent, vat_percent, unit, temporary_reference, row_number, merchant_data].hash\n end", "def hashify\n emotions = {anger: anger, contempt: contempt, disgust: disgust, fear: fear,\n happiness: happiness, neutral: neutral, sadness: sadness, surprise: surprise}\n emotions.sort_by {|k, v| v}.reverse.to_h\n end", "def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end", "def hash\n [id, rfc, legal_name, commercial_name, credit_days, credit_amount, payment_method, creation_date, status, sales_contact, credit_contact, loctaion, comments, price_list, payment_term_type, email, telephones, number, account_number, default_discount, client_source, account, addresses].hash\n end", "def hash!\n\t\t@@email.downcase!\n\t\thash = Digest::MD5.hexdigest(@@email)\n\t\treturn hash\n\tend", "def letter_hash s\n s.each_char.to_a.sort.join('')\nend", "def rehash() end", "def hash\n [id, numero_estabelecimento, flag_matriz, id_grupo_economico, numero_receita_federal, nome, descricao, nome_fantasia, cep, nome_logradouro, numero_endereco, bairro, cidade, complemento, uf, cep2, nome_logradouro2, numero_endereco2, bairro2, cidade2, complemento2, uf2, obs, contato, email, flag_arquivo_secr_fazenda, flag_cartao_digitado, inativo, id_moeda, id_pais, associado_spc_brasil, mcc, id_tipo_estabelecimento, correspondencia, cargo_contato, tipo_pagamento, consulta, consulta2, consulta3, terminal, data_cadastramento, usuario].hash\n end", "def hash\n [list_id, email, phone, gender, first_name, last_name, is_unsubscribed, is_blacklisted, _custom_attribute_].hash\n end", "def hash(key)\n\t\tascii_keys = [] \n\t\tkey.to_s.each_byte { |el| ascii_keys << el }\n\t\tascii_keys.map { |el| el.to_s }.join('')\n\tend", "def hash\n [id, banco, agencia, conta_corrente, especie, numero_convenio, carteira, codigo_cedente, especie_tipo, especie_documento, aceite, instrucoes, local_pagamento1, local_pagamento2, endereco_cobranca_emissor, nome_beneficiario, cnpj_beneficiario, operador, data, maquina].hash\n end", "def hash\n to_s.hash\n end", "def author_hash; end", "def create_list(list)\r\n\tlist = list.split(\" \")\r\n\thsh = {}\r\n\r\n\tlist.each{|i| hsh[i] = 1}\r\n\r\n\t###print hash\r\n\thsh\r\nend", "def hash\n return to_s.hash\n end", "def hash\n swap\n scatter\n completed_string\n end", "def combine_anagrams(list)\n hash_to_anagrams = Hash.new { |h,k| h[k] = Array.new }\n list.each { |word| hash_to_anagrams[hash_for(word)] << word }\n hash_to_anagrams.keys.map { |key| hash_to_anagrams[key] }\nend", "def hash\n [deleted, edited_by_user, email_communication_sequence_email_uuid, email_communication_sequence_uuid, email_container_cjson, email_container_cjson_last_modified_dts, email_template_vm_path, filter_profile_equation_json, individually_render, library_item_oid, magic_link, merchant_id, pending_review, preview_text, rejected, requires_review, screenshot_large_full_url, screenshot_large_viewport_url, screenshot_small_full_url, screenshot_small_viewport_url, smart_sending, storefront_oid, subject, suspended_for_spam, transactional_email, version].hash\n end", "def hash\n [id, id_account, webid, application_date, date, value, gross_value, nature, original_wording, simplified_wording, stemmed_wording, wording, id_category, state, date_scraped, rdate, vdate, bdate, coming, active, id_cluster, comment, last_update, deleted, original_value, original_gross_value, original_currency, commission, commission_currency, country, counterparty, card].hash\n end", "def generate_hexdigest_indexed_list(size_indexed_list, head_size = nil)\n result = {}\n size_indexed_list.each_pair{|old_key, filename_arr|\n filename_arr.each{|filename|\n if head_size == nil\n $stdout.puts \"SHA512 hash calculation: #{filename}\"\n else\n $stdout.puts \"Header (#{head_size}) SHA512 hash calculation: #{filename}\"\n end\n\n hexdigest = get_file_header_sha512(filename, head_size)\n\n if result.has_key?(hexdigest) == false\n result[hexdigest] = []\n end\n result[hexdigest].push(filename)\n }\n }\n return result\nend", "def hash\n [id, identifier, password, first_name, middle_initial, last_name, title, report_card, license_class, disable_online_flag, enable_mobile_flag, type, employee_identifer, vendor_number, notes, time_zone, country, service_board_team_ids, enable_mobile_gps_flag, inactive_date, inactive_flag, last_login, photo, office_email, office_phone, office_extension, mobile_email, mobile_phone, mobile_extension, home_email, home_phone, home_extension, default_email, default_phone, security_role, admin_flag, structure_level, security_location, default_location, default_department, reports_to, restrict_location_flag, restrict_department_flag, work_role, work_type, time_approver, expense_approver, billable_forecast, daily_capacity, hourly_cost, hourly_rate, include_in_utilization_reporting_flag, require_expense_entry_flag, require_time_sheet_entry_flag, require_start_and_end_time_on_time_entry_flag, allow_in_cell_entry_on_time_sheet, enter_time_against_company_flag, allow_expenses_entered_against_companies_flag, time_reminder_email_flag, days_tolerance, minimum_hours, time_sheet_start_date, hire_date, service_default_location, service_default_department, service_default_board, restrict_service_default_location_flag, restrict_service_default_department_flag, excluded_service_board_ids, project_default_location, project_default_department, project_default_board, restrict_project_default_location_flag, restrict_project_default_department_flag, excluded_project_board_ids, schedule_default_location, schedule_default_department, schedule_capacity, service_location, restrict_schedule_flag, hide_member_in_dispatch_portal_flag, calendar, sales_default_location, restrict_default_sales_territory_flag, warehouse, warehouse_bin, restrict_default_warehouse_flag, restrict_default_warehouse_bin_flag, mapi_name, calendar_sync_integration_flag, enable_ldap_authentication_flag, ldap_configuration, ldap_user_name, company_activity_tab_format, invoice_time_tab_format, invoice_screen_default_tab_format, invoicing_display_options, agreement_invoicing_display_options, corelytics_username, corelytics_password, remote_package, remote_package_platform, remote_package_user_name, remote_package_password, remote_package_account, authentication_service_type, timebased_one_time_password_activated, _info].hash\n end", "def hash\n [id, type, state, country, street, postal_code, city, phone_country, phone_number, email, ip, address_description, identification_number, identification_type, lang, name, first_name, middle_name, last_name, birth_date, occupation, nationality, legal_entity_type, registration_date, registration_number, nature_of_business, source_of_funds, custom_source_of_funds, core_business_activity, purpose_of_opening_account, office_phone, vat_registration_number, financial_regulator, regulatory_licence_number, contact_person_email, trading_country, trading_address, trading_name, number_monthly_transactions, amount_monthly_transactions, documents, metadata, errors, onboarding_status, politically_exposed_people, external_id, city_of_birth, country_of_birth, gender, sales_lead_id, created_at, company_office_number, company_office_number_country, aml_officer_email, aml_officer_phone, aml_officer_phone_country, company_website_url, number_of_employees_in_company, list_of_countries_of_operation, estimated_annual_revenue_turnover, declaration].hash\n end", "def test_hash_correct\n\t\n\t\tString test_array1 = '2|abb2|George>Amina(16):Henry>James(4):Henry>Cyrus(17):Henry>Kublai(4):George>Rana(1):SYSTEM>Wu(100)|1518892051.753197000|c72d'.split('|').map(&:chomp)\n\n\t\tx = test_array1[0].unpack('U*') + test_array1[1].unpack('U*') + test_array1[2].unpack('U*') + test_array1[3].unpack('U*')\n\t\tsum = 0\n\t\t# x.each { |i| puts x[i] }\n\t\t# x.delete(\"\")\n\t\tx.each { |i| sum += ((x[i].to_i ** 2000) * ((x[i].to_i + 2) ** 21) - ((x[i].to_i + 5) ** 3)) }\n\t\thash = (sum % 65536)\n\t\tputs hash.to_s(16)\n\t\t\n\t\ttest_array2 = '3|c72d|SYSTEM>Henry(100)|1518892051.764563000|7419'.split('|').map(&:chomp)\n\t\t\n\t\t# assert_equal test_str[2,2], '0|'\t\n\tend", "def hash\n \"#{membership} #{formatted_price}\"\n end", "def hash\n to_s.hash\n end", "def hash\n to_s.hash\n end", "def subscriber_hash(email)\n Digest::MD5.hexdigest(email.downcase) unless email.nil?\n end", "def hash\n end", "def hash\n end", "def hash\n end", "def hash_forbidden_pairs(list)\r\n # Adding the reversed pairs of students to the list\r\n (0..list.length - 1).each do |x|\r\n list.push([list[x][1], list[x][0]])\r\n end\r\n\r\n # Making all unique first elements of the pairs in the list keys of the Hash\r\n keys = list.map(&:first).uniq\r\n # Adding the corresponding values, specified by the second elements in the pairs\r\n @forbidden_pairs = keys.map do |k|\r\n {k => list.select { |a| a[0] == k }.compact.map(&:last)}\r\n end\r\n @forbidden_pairs = @forbidden_pairs.reduce({}, :merge)\r\n # Removing unique values for each key\r\n @forbidden_pairs.keys.each do |x|\r\n @forbidden_pairs[x] = @forbidden_pairs[x].uniq\r\n end\r\n end", "def random_reviews_hash\n\t\t[{title: \"Pretty decent, could have been better\", stars: 4, summary: \"This chair arrived well-packaged and protected with a lot of foam insulation around the wheels and metal components. Assembly was quick and simple, as I didn't even need the instructions. All you have to do is put the air lift on the base and place the seat on the air lift, then it's ready to go. The chair has great lumbar support and reaches all the way up to my head, allowing me to rest entirely against it. It's also fairly comfortable, having a few inches of padding, while not being too compliant so as to lack support, making for a pretty good balance that I particularly like. The air lift lever (for raising/lowering the height of the chair) is designed so that when pushed in the chair cannot recline, but if you pull it out slightly, it releases a mechanical lock and allows the chair to recline back about 20-30 degrees.\"},\n\t\t{title: \"Got exactly what I needed and more!\", stars: 5, summary: \"Customer Service: We often encounter a customer service rep who has had a bad day or just does not care or any of the negative phrases that make us some reps. This is absolutely NOT the case with the folks at BOSS. After opening the box and putting it together (a feat accomplished by anyone who can lift a sack of potatoes) I could not get the gas cylinder to raise the seat level. One of us is 5'6\\\" and the other is 6'3\\\" and the seat is either too high or too low unless the gas cylinder works. It did not. \n\n\t\t\t\tIt was too late to call and it was Thanksgiving eve. Even if anyone had been home I would have waited until Frantic Friday to call. So I emailed my concern and expected no reply until today or maybe tomorrow. On Friday, the 26th, the height adjustment absence was just too much to endure. A call was placed to BOSS and a woman told me exactly what to do and I did. Closed case. Wow! I did suggest that the instructions would benefit from her advice in future iterations. Regardless, my problem was settled in seconds and when I finally got to reviewing my email I saw a response from BOSS saying the same thing. Let's all give a big shout to BOSS for fantastic service.\"\n\t\t},\n\t\t{title: \"Quick, Easy, and Fast!\", stars: 4, summary: \"The chair leans back which is nice. Doesn't seem to have too much lean which i don't really like but it's enough to put my feet up on my sub woofer. The leather is very nice quality and it has a built-in lumbar support which feels nice. My only issue with the chair was the first chair i sat in it and a bolt sheered off. But i told amazon and they had my new chair their the next day (same as what i paid for to ship it originally) and they had a ups man there the next day to pick up the broken chair. After that the chair has been flawless and very comfortable. The leather feels less cheap then the leather on my old chair.\"\n\t\t\t},\n\t\t\t{title: \"Bad Overall Experience\", stars: 2 , summary: \"This chair is nicely built. It looks elegant and cool. It is easy to clean.\n\t\t\t\tThe problem for me is that this is too big.\n\t\t\t\tI am male, 170 cm, 56 kg, that is about 5 foot 7 inches and 123 pounds. I don't feel very comfortable in this chair especially due to the armrest. The armrest is just a few centimeters too high, it pushes my elbow up, and that's annoying.\n\t\t\t\tThe part where you sit on is very large, and I seem to \\\"sink\\\" inside it, which worsens the armrest problem.\n\t\t\t\tBut I think if you are taller, this should be good. It will be even better if you are both taller and fatter. Maybe if I were 180cm(5 foot 11 inches) 85kg(188 pounds), this chair would be perfect.\" },\n\t\t\t\t\t\t\t{title: \"Worse Lender In Dojo!\", stars: 1, summary: \"First the positives:\n\n\t\t\t\t* This is the easiest chair I've ever put together. Simply unfold the chair back and the seat, which come pre-attached along with the arms, until they lock together. Next, place the gas cylinder firmly into the chair base and snap the 5 wheels onto the bottom. Finally, slide the gas cylinder/base into the seat bottom. It's completely tool-less and takes minutes.\n\n\t\t\t\t* The chair itself is pretty comfortable. It fit my back perfectly and was firm enough to give support while being soft enough to sit for extended periods.\n\n\t\t\t\t* Contrary to what other reviewers say, this chair can lean back. Just slide the height adjustment lever in towards the chair to lock the back in place, or slide it out to allow the chair to lean backwards.\"\n\t\t},\n\t\t{title: \"The Best Lender In the Dojo!\", stars: 5, summary: \"Purchased this chair once before on July 26, 2012. Was happy with the chair and the material that was used. This time the material was totally different. Very Cheap, so called Leather Plus..................... Very Cheap. In the description it does say Leather Plus but in the details as this is how it is described, below. I copied and pasted the information. It is not Leather............. Don't be fooled and it feels and looks very cheap. This material is totally different from the purchase in the past. If it were the same as the first chair I bought, I would have been happy. It was discribe to be the exact same and was not............ I don't write many reviews and I shop a lot with Amazon and this time I am a very unhappy shopper. Beware of this cheap chair...........................................\"\n\t\t},\n\t\t{title: \"Very good experience\", stars: 4, summary: \"This chair was packed sufficiently, arrived quickly, and was easy to assemble (5mins, no tools). The chair is comfortable, but I'll have to either turn my A/C colder or wear a shirt (I work at home) because this material either makes me sweat a lot more, or it just shows up more.\"\n\t\t},\n\t\t{title: \"Experienced teach, but always late\", stars: 2, summary: \"Update: after less that 1 year of use, this chair's piston is giving out. It rises on it's own, and I have to lower the chair every time I sit in it. It even rises slowly while I am in it, causing me to have to constantly lower it again. CHEAP CRAP!!!\"\n\t\t}].sample\n\tend", "def anagram_hash(input)\n list = {} # empty hash\n input.each do |word| # iterates over each word in the array\n add_word = word.chars.sort.join # sorts the anagrams\n list[add_word] ||= []\n list[add_word] << word\n end\n # list of all anagrams and words\n list.values\nend", "def hash\n [accounting, amember, auto_order, ccbill, channel_partner_item_mappings, chargeback, checkout, content, creation_dts, description, description_translated_text_instance_oid, digital_delivery, ebay, email_notifications, enrollment123, fulfillment_addons, gift_certificate, google_product_search, identifiers, inactive, instant_payment_notifications, internal, kit, kit_component_only, kit_definition, last_modified_dts, merchant_id, merchant_item_id, merchant_item_oid, options, parent_category_id, parent_category_path, payment_processing, physical, pricing, properties, realtime_pricing, recommend_replenishment_days, related, reporting, restriction, revguard, reviews, salesforce, shipping, tags, tax, third_party_email_marketing, variant_items, variations, wishlist_member].hash\n end", "def hashit\n n = 0\n Chars.split(\"\").each do |x|\n @rotor_hash[x] = @rotor_array[n]\n n += 1\n end \n @rotor_hash\n end", "def _hash(obj)\n obj.transform_values { |v| _renc(v) }\n end", "def grades_to_hash(csv)\n csv.map { |r| r.to_hash }\n end", "def student_data_hash\n\n # turn data into 2 Dim array containing arrays of eles where delimiter is colon :\n clean_user_account_data = ruby_class_user_accounts.map { |x| x.split(/:/) }\n\n # turn data into a hash using 2 arrays for keys and values\n keys = %w[user_name password uid gid gcos_field home_directory login_shell]\n final_array_of_hashes = []\n\n clean_user_account_data.each do |account_data|\n hash = Hash.new\n keys.each_with_index { |item, index| hash[item] = account_data[index] }\n final_array_of_hashes << hash\n end\n final_array_of_hashes\n end", "def to_hash\n memoize(:to_hash) do\n _process_hashed(structures.inject({}) { |acc, elem| Utils.merge(acc, elem) })\n end\n end", "def create_list(string)\n list = {}\n string = string.split \n\n string.each { |item| \n list[item] = 1\n }\n\n printhash(list)\n\n list\nend", "def to_authoring_hash\n hash = to_hash\n hash[:id] = id\n hash[:linked_interactive_id] = linked_interactive_id\n hash[:linked_interactive_type] = linked_interactive_type\n hash[:aspect_ratio] = aspect_ratio\n hash[:interactive_item_id] = interactive_item_id\n hash[:linked_interactive_item_id] = linked_interactive_item_id\n # Note that linked_interactives is independent from linked_interactive_id and linked_interactive_type fields\n hash[:linked_interactives] = linked_interactives_list\n hash\n end", "def hashify(key)\n array = key.split('')\n count = array.count\n index = array.inject(0) do |object,char|\n object += char.ord ** count\n count -= 1\n object\n end\n index % 89\n end", "def hash\n [accounts_date, reporting_period, currency, consolidated_accounts, audit_qualification, number_of_employees, turnover, cost_of_sales, sga_plus_other_net_costs, operating_profit, interest_receivable, interest_payable, pre_tax_profit, taxation, post_tax_profit, dividends_payable, retained_profits, intangible_assets, tangible_assets, investments_and_other_assets, fixed_assets, stock, trade_debtors, other_debtors, miscellaneous_current_assets, cash, current_assets, total_assets, bank_loans_and_overdrafts, trade_creditors, miscellaneous_current_liabilities, other_short_term_finances, current_liabilities, contingent_liabilities, other_long_term_finances, total_long_term_liabilities, total_liabilities, net_assets, equity_paid_up, revaluation_reserve, sundry_reserves, profit_and_loss_account_reserve, shareholder_funds, depreciation, amortisation_of_intangibles, ebitda, working_capital, capital_employed, wages_and_salaries, directors_emoluments, audit_fees, bank_overdraft_and_long_term_loans, net_cash_flow_from_operations, net_cash_flow_before_financing, net_cash_flow_from_financing, increase_in_cash, debtor_days, exports, gross_margin_percentage, operating_profit_margin_percentage, ebitda_margin_percentage, pre_tax_profit_margin_percentage, net_margin_percentage, return_on_assets_percentage, return_on_capital_employed_percentage, return_on_equity, current_ratio, cash_to_current_liabilities_ratio, cash_to_total_assets_percentage, liquidity_ratio, gearing_percentage_on_liability_basis, gearing_percentage_on_gross_debt_basis, gearing_percentage_on_net_debt_basis, debt_to_capital_percentage, inventory_turnover_ratio, cash_to_turnover_ratio, cash_to_turnover_percentage, days_inventory_outstanding, days_sales_outstanding, days_payable_outstanding, cash_conversion_cycle, revenue_per_employee, human_capital_value_added, interest_coverage_ratio, net_debt_to_ebitda_ratio, cfo_to_sales_ratio, auditor, joint_auditor, solicitor, accountant].hash\n end", "def hash\n [id, url, external_id, first_name, last_name, middle_name, birth_date, gender, language, phone, allow_phone_contact, email, allow_email_contact, notes, date_created, date_modified, ext_date_created, ext_date_modified, doc_type, doc_issuer_info, doc_series, doc_number, department_code, department_name, doc_issue_date, doc_expiration_date, is_closed, merged_to, building_no, city, country_code, country_name, district, flat_no, house_no, region, room_no, settlement_type, street, raw_address, cards, view_url, preferences].hash\n end", "def hash\n [lead_id, salutation, title, first_name, last_name, organization_name, phone_number, mobile_phone_number, fax_number, email_address, website_url, owner_user_id, date_created_utc, date_updated_utc, converted, converted_date_utc, converted_contact_id, converted_organization_id, converted_opportunity_id, visible_to, responsible_user_id, industry, lead_status_id, lead_source_id, visible_team_id, employee_count, lead_rating, lead_description, visible_user_ids, customfields, address_street, address_city, address_state, address_postcode, address_country, tags, image_url].hash\n end", "def hash_code; end", "def calculate_hash!\n entry_hash = to_hash\n entry_hash['description']=nil\n @hash = entry_hash.hash\n end", "def final_letter_grades(grade_hash)\n averages = averages(grade_hash)\n\n final_grades = averages.map do |key, value|\n [key, letter_grade(value)]\n end\n\n final_grades.to_h\nend", "def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end", "def digest\n digest = ''\n @entries.each { |entry| digest << entry.digest << ' ' }\n digest\n end", "def md5_list\n @list + '_MD5'\n end", "def hash\n [id, token, tipo, id_cliente, id_fornitore, nome, indirizzo_via, indirizzo_cap, indirizzo_citta, indirizzo_provincia, indirizzo_extra, paese, lingua, piva, cf, numero, valuta, valuta_cambio, prezzi_ivati, importo_netto, importo_iva, importo_totale, rivalsa, importo_rivalsa, cassa, importo_cassa, rit_acconto, imponibile_ritenuta, importo_rit_acconto, rit_altra, importo_rit_altra, marca_bollo, oggetto_visibile, oggetto_interno, centro_ricavo, centro_costo, note, nascondi_scadenza, ddt, ftacc, id_template, ddt_id_template, ftacc_id_template, mostra_info_pagamento, metodo_pagamento, metodo_titolo_n, metodo_desc_n, mostra_totali, mostra_bottone_paypal, mostra_bottone_bonifico, mostra_bottone_notifica, lista_articoli, lista_pagamenti, ddt_numero, ddt_colli, ddt_peso, ddt_causale, ddt_luogo, ddt_trasportatore, ddt_annotazioni, link_doc, link_ddt, link_ftacc, link_allegato, bloccato, pa, pa_tipo_cliente, pa_tipo, pa_numero, pa_cup, pa_cig, pa_codice, pa_esigibilita, pa_modalita_pagamento, pa_istituto_credito, pa_iban, pa_beneficiario, pa_ts, pa_ts_stato, split_payment].hash\n end", "def hash\n [additional_contact_billing_id, additional_contact_billing_is_primary, additional_contact_billing_name, additional_contact_executive_sponsor_id, additional_contact_executive_sponsor_is_primary, additional_contact_executive_sponsor_name, additional_contact_hiring_manager_id, additional_contact_hiring_manager_is_primary, additional_contact_hiring_manager_name, additional_contact_internal_recruiter_id, additional_contact_internal_recruiter_is_primary, additional_contact_internal_recruiter_name, additional_contact_other_id, additional_contact_other_is_primary, additional_contact_other_name, attachments, created_by_id, created_by_name, created_on, expected_value, external_email_address, id, job_code, last_activity_date, last_engagement_date, modified_by_id, modified_by_name, modified_on, owners, status_id, status_name, time_to_close, actual_value, additional_contact_client_first_name, additional_contact_client_id, additional_contact_client_is_primary, additional_contact_client_last_name, address_business_city, address_business_country, address_business_is_primary, address_business_line1, address_business_state, address_business_zip_code, address_other_city, address_other_country, address_other_is_primary, address_other_line1, address_other_state, address_other_zip_code, bill_rate, bonus, commission, company_id, company_name, compensation, compensation_details, custom_field1, custom_field10, custom_field11, custom_field12, custom_field13, custom_field14, custom_field15, custom_field16, custom_field17, custom_field18, custom_field19, custom_field2, custom_field20, custom_field21, custom_field22, custom_field23, custom_field24, custom_field25, custom_field26, custom_field27, custom_field28, custom_field29, custom_field3, custom_field30, custom_field4, custom_field5, custom_field6, custom_field7, custom_field8, custom_field9, description, discount, estimated_close_date, external_primary_key, fee, fee_percent, hourly_rate, is_lead, is_on_hold, job_title_id, job_title_name, job_types, lead_source_id, lead_source_name, margin, name, number_of_openings, opportunity_type_id, opportunity_type_name, parent_job_id, parent_job_name, pay_rate, potential_value, priority_id, priority_name, probability, salary, start_date, tags, total_hours, website_description, website_description_is_primary, website_other, website_other_is_primary].hash\n end", "def hash\n [subject_property, proprietorship, surname, forename, middle_name, all_names, historical_match].hash\n end", "def hash\n simplified.hash\n end", "def to_md5\n self.collect { |a| [a[0] =~ /@/ ? Digest::MD5.hexdigest(a[0]) : a[0], a[0]] }\n end", "def table_digest(table)\n digest = Digest::MD5.new\n table.flatten.each do |cell|\n digest.update(unescape(cell))\n end\n return digest.to_s\n end", "def list_as_hash solr_list\n # map\n if solr_list.values.first.is_a? Hash\n solr_list\n else\n solr_list.each_with_object({}) do |(key, values), hash|\n hash[key] = if values.first.is_a? Array\n # arrarr\n Hash[values]\n else\n # flat\n Hash[values.each_slice(2).to_a]\n end\n end\n end\n end" ]
[ "0.60028434", "0.60028434", "0.60028434", "0.60028434", "0.60028434", "0.60028434", "0.60028434", "0.5958399", "0.5958399", "0.59075385", "0.58492905", "0.5841919", "0.58287346", "0.5819951", "0.57707435", "0.5703422", "0.5609427", "0.5605253", "0.5591435", "0.5576852", "0.5563512", "0.5557907", "0.5528775", "0.5514987", "0.54930997", "0.548706", "0.5477589", "0.54603845", "0.5451697", "0.5435286", "0.5431416", "0.54278725", "0.5424662", "0.5424662", "0.5424662", "0.5424662", "0.5424662", "0.5424662", "0.5424662", "0.5424662", "0.5424662", "0.5424662", "0.54094785", "0.54007447", "0.53953975", "0.5394551", "0.5379163", "0.5374865", "0.53496677", "0.5337988", "0.5321206", "0.53191566", "0.5301763", "0.5301421", "0.5288727", "0.5288687", "0.5287785", "0.5287064", "0.5275887", "0.5260603", "0.5255081", "0.5252696", "0.52406895", "0.5225531", "0.52066296", "0.52042204", "0.52003634", "0.52003634", "0.5194521", "0.519411", "0.519411", "0.519411", "0.5185732", "0.51685745", "0.51659167", "0.5162846", "0.51545906", "0.51535183", "0.5151141", "0.5128552", "0.51157856", "0.51097584", "0.5107969", "0.50932664", "0.5091599", "0.5087816", "0.50869596", "0.5084254", "0.5084155", "0.50799805", "0.50720686", "0.5053191", "0.5050796", "0.50446993", "0.5041637", "0.5040308", "0.50339407", "0.5030248", "0.5025135", "0.5023554" ]
0.66849023
0
Get industries query string
def industries_query_str(industry_ids) industry_ids = industry_ids.split(',') list_of_clusters = convert_industries_to_hash industries_q = ['('] industry_ids.each_with_index do |id, index| if index.zero? industries_q.push "industries like '%#{list_of_clusters[id.to_i]}%'" else industries_q.push " OR industries like '%#{list_of_clusters[id.to_i]}%'" end end industries_q.push ')' industries_q.join('') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_string\n end", "def query_string\n return nil if @request.query_string.nil?\n ignore_query_params = [\"no-cachely\", \"refresh-cachely\", Rack::Cachely.config.ignore_query_params].flatten\n query = @request.query_string.split(/[&;] */n).map { |p| unescape(p).split('=', 2) }.sort\n query = query.reject{|k,v| ignore_query_params.include?(k)}.map{ |k,v| \"#{escape(k)}=#{escape(v)}\" }\n\n query.join('&')\n end", "def query_string\n return @query_string\n end", "def query_string\n if method == \"GET\" && !request_parameters.empty?\n \"?#{request_parameters.to_query}\"\n end\n end", "def get_url\n\t\t\"http://unm-research.herokuapp.com/project_surveys?utf8=%E2%9C%93&q%5Bdepartment_cont%5D=#{self.name.strip.gsub(\" \", \"+\")}&commit=Search\"\n\tend", "def query_string\n @env['QUERY_STRING'].present? ? @env['QUERY_STRING'] : (@env['REQUEST_URI'].split('?', 2)[1] || '')\n end", "def query_string\n return @query_string if defined?(@query_string)\n @query_string = headers[PATH_KEY].index '?'\n return if @query_string.nil?\n @query_string = headers[PATH_KEY][(@query_string + 1)..-1]\n end", "def query_parameters_string\n request.filtered_env[\"rack.request.query_string\"]\n end", "def request_uri\n uri = URI.parse(Europeana::URL + \"/search.json\")\n request_params = params_with_authentication\n\n if request_params[:qf].is_a?(Hash)\n qf = request_params.delete(:qf)\n uri.query = request_params.to_query\n qf.each_pair do |name, criteria|\n [ criteria ].flatten.each do |criterion|\n uri.query = uri.query + \"&qf=\" + CGI::escape(name.to_s) + \":\" + CGI::escape(criterion)\n end\n end\n else\n uri.query = request_params.to_query\n end\n \n uri\n end", "def query_params\n URI.encode_www_form(\n {\n affiliate:,\n access_key:,\n module_code:,\n url:,\n query:,\n position:,\n user_agent:\n }\n )\n end", "def url\n endpoint+'?'+query_string\n end", "def query_string\n return nil if @request.query_string.nil?\n\n @request.query_string.split(/[&;] */n).\n map { |p| unescape(p).split('=', 2) }.\n sort.\n map { |k,v| \"#{escape(k)}=#{escape(v)}\" }.\n join('&')\n end", "def get_querystring\n request_object.querystring\n end", "def query_string\n nil\n end", "def search_url(term='')\n param = URI.encode_www_form('term' => term)\n \"http://api.urbandictionary.com/v0/define?#{param}\"\n end", "def query_string(options={})\n default_options.merge(options).delete_if{ |k, v| v.nil? || v == \"\" }.sort.map{ |arr| \"#{arr[0]}=#{arr[1]}\" }.join(\"&\")\n end", "def to_query_string\n query = @uri.query\n query ? Wgit::Url.new(\"?#{query}\") : nil\n end", "def query_string\n ''\n end", "def query_string\n \"\"\n end", "def unsigned_query_string\n (should_encode? ? RestClient::Payload.generate(query_params) : query_params).to_s\n end", "def query_string\n \"#{base_url}dmQuery/#{collection_alias}/#{searchstrings}/#{fields}/\" +\n \"#{sortby}/#{max_recs}/#{start}/#{suppress_pages}/#{docptr}/#{suggest}/\" +\n \"#{facets}/#{showunpub}/#{denormalize_facets}/#{response_format}\"\n end", "def query_string\n \"#{base_url}dmQuery/#{collection_alias}/#{searchstrings}/#{fields}/\" +\n \"#{sortby}/#{max_recs}/#{start}/#{suppress_pages}/#{docptr}/#{suggest}/\" +\n \"#{facets}/#{showunpub}/#{denormalize_facets}/#{response_format}\"\n end", "def query_string\n return nil if @request.query_string.to_s.empty?\n\n parts = @request.query_string.split(/[&;] */n)\n parts.map! { |p| p.split('=', 2).map!{ |s| unescape(s) } }\n parts.sort!\n parts.reject!(&self.class.query_string_ignore)\n parts.map! { |k,v| \"#{escape(k)}=#{escape(v)}\" }\n parts.empty? ? nil : parts.join('&')\n end", "def uri\n \"#{query_uri}?#{query_options.to_query}\"\n end", "def generate_next_url\n if eds_session.has_key? :query_string\n url = HTMLEntities.new.decode eds_session[:query_string]\n\n #blacklight expects the search term to be in the parameter 'q'.\n #q is moved back to 'query-1' in 'generate_api_query'\n #should probably pull from Info method to determine replacement strings\n #i could turn the query into a Hash, but available functions to do so delete duplicated params (Addressable)\n url.gsub!(\"query-1=AND,TI:\", \"q=\")\n url.gsub!(\"query-1=AND,AU:\", \"q=\")\n url.gsub!(\"query-1=AND,SU:\", \"q=\")\n url.gsub!(\"query-1=AND,\", \"q=\")\n\n #Rails framework doesn't allow repeated params. turning these into arrays fixes it.\n url.gsub!(\"facetfilter=\", \"facetfilter[]=\")\n url.gsub!(\"limiter=\", \"limiter[]=\")\n\n #i should probably pull this from the query, not the URL\n if (params[:search_field]).present?\n url << \"&search_field=\" << params[:search_field].to_s\n end\n return url\n else\n return ''\n end\n end", "def kitties_search( q )\r\n \"https://www.cryptokitties.co/search?include=sale,sire,other&search=#{q}\"\r\nend", "def get_query\n\t\t\tquery_string = request.query_string\n\t\t\t@query = Rack::Utils.parse_query(query_string)\n\t\t\t@shop_domain = @query['shop']\n\t\t\t@query\n\t\tend", "def query_string\n (authenticate? && authenticable?) ? signed_query_string : unsigned_query_string\n end", "def query_string(**params)\n params.map { |k, v| [k, v].join('=') }.join('&')\n end", "def getSearchURL itemName, itemType\n itemEncoded = URI.encode itemName\n if itemType == 'title'\n return ROOT_URL + 'find?q=' + itemEncoded + '&' + QPARAMS_TITLE_SEARCH\n end\nend", "def get_query_string\n qs = @req.env['QUERY_STRING']\n # Lighty's fcgi-bindings use its 404 handler and it doesn't provide QUERY_STRING\n if qs.blank? && @req.env['SERVER_SOFTWARE'] =~ /lighttpd/\n match = @req.env['REQUEST_URI'].match(/\\?(.*)/)\n qs = match[1] if match\n end \n qs\n end", "def query_string \n headers[\"QUERY_STRING\"]\n end", "def query\n params.sort.map { |k, v| \"#{k}=\" + escape(v) }.join('&')\n end", "def build_request_url(params)\n \"http://api.nytimes.com/svc/search/v2/articlesearch.json?\"+params\n end", "def qs\n if @r && @r['QUERY_STRING'] && !@r['QUERY_STRING'].empty?\n '?' + @r['QUERY_STRING']\n elsif query && !query.empty?\n '?' + query\n else\n ''\n end\n end", "def url\n \"#{@base_url}/s/search/air?#{compiled_params}\"\n end", "def url_with_query_string\n if query_string && query_string.size > 0\n base_url + \"?#{query_string}\"\n else\n base_url\n end\n end", "def query_string(term:, page: 1, filters: [])\n query_string = [\"query=#{term}\", \"page=#{page}\"]\n query_string << \"filter=#{filters.join(',')}\" if filters.any?\n query_string.join('&')\n end", "def query_string(term:, page: 1, filters: [])\n query_string = [\"query=#{term}\", \"page=#{page}\"]\n query_string << \"filter=#{filters.join(',')}\" if filters.any?\n query_string.join('&')\n end", "def url_query_string(leading_slash = true)\n (leading_slash ? \"/?\" : \"?\") << URI.escape(self.collect{|k,v| \"#{k}=#{v}\"}.join('&'))\n end", "def query_path\n query_string = env.fetch('QUERY_STRING')\n return '' if query_string.empty?\n\n query_hash = Rack::Utils.parse_query(query_string)\n query_hash.each_pair.with_object(['/query']) { |(key, val), result|\n result << \"/#{key}-is-#{val}\"\n }.join()\n end", "def query_string\n return nil if @request.query_string.nil?\n if whitelist_mode?\n whitelist(@request.query_string)\n else\n blacklist(@request.query_string)\n end\n end", "def query_string_params\n super + [\n :chtm, # region\n :chld, # countries/states\n ]\n end", "def request_string\n \"#{authentication_string}&\" + @request_parameters.\n reject{|k| self.send(k).blank?}.map(&:to_s).sort.map{|k|\n \"#{k.to_s.upcase}=#{escape(self.send(k))}\"\n }.flatten.join('&')\n end", "def request_url\n query_builder.request_string\n end", "def query_string(params)\n params = full_options params\n params[:sign] = sign params\n \"?\" + params.to_query\n end", "def build_query_string(options)\n\n q_str = \"#{API_KEY}\"\n return q_str if !options || options.empty?\n options.each do |key, value|\n q_str += \"&#{key}=#{value}&\"\n end\n\n q_str\n end", "def url\n \"#{GOOGLE_SEARCH_URL}/cse?#{@custom_params.merge(DEFAULT_PARAMS).merge(:q => query, :cx => @search_engine_id, :sort => @sort).delete_if{|k,v| v.nil?}.to_query}\" \n end", "def interal_query(query_value)\n \"_query_:\\\"#{query_value}\\\"\"\n end", "def all_items_url engine_id, query, format\n\n\n if engine_id == 'summon_bento'\n query = query.gsub('&', '%26')\n \"https://proxy.library.cornell.edu/login?url=http://cornell.summon.serialssolutions.com/search?s.fvf=ContentType,Newspaper+Article,t&s.q=#{query}\"\n elsif engine_id == 'summonArticles'\n query = query.gsub('&', '%26')\n \"https://proxy.library.cornell.edu/login?url=http://cornell.summon.serialssolutions.com/search?s.fvf=ContentType,Newspaper+Article&s.q=#{query}\"\n elsif engine_id == 'digitalCollections'\n query = query.gsub('&', '%26')\n \"https://digital.library.cornell.edu/catalog?utf8=%E2%9C%93&q=#{query}&search_field=all_fields\"\n elsif engine_id == 'institutionalRepositories'\n query = query.gsub('&', '%26')\n \"institutional_repositories/index?q=#{query}\"\n elsif engine_id =='libguides'\n query = query.gsub('&', '%26')\n \"http://guides.library.cornell.edu/srch.php?q=#{query}\"\n elsif engine_id == 'ebsco_eds'\n query = query.gsub('&', '%26')\n query = \"https://proxy.library.cornell.edu/login?url=https://discovery.ebsco.com/c/u2yil2/results?q=#{query}\"\n else\n # Need to pass pluses through as urlencoded characters in order to preserve\n # the Solr query format.\n path = '/'\n if format == 'all'\n escaped = { q: query }.to_param\n else\n escaped = { \"f[format][]\" => format, q: query, search_field: 'all_fields' }.to_param\n end\n escaped_search_url = path + '?' + escaped\n end\n end", "def query_string\n pairs = []\n @params.sort.each { | key, val | \n pairs.push( \"#{ percent_encode( key ) }=#{ percent_encode( val.to_s ) }\" )\n }\n pairs.join '&'\n end", "def query_params\n validate_params!\n \n qargs = {\n Ebay::Search::Api::OPERATION_NAME[:key] => Ebay::Search::Api::OPERATION_NAME[:value],\n Ebay::Search::Api::SERVICE_VERSION[:key] => Ebay::Search::Api::SERVICE_VERSION[:value],\n Ebay::Search::Api::SECURITY_APPNAME[:key] => self.app_name,\n Ebay::Search::Api::GLOBAL_ID[:key] => self.global_id,\n Ebay::Search::Api::RESPONSE_DATA_FORMAT[:key] => Ebay::Search::Api::RESPONSE_DATA_FORMAT[:value],\n Ebay::Search::Api::PER_PAGE[:key] => self.per_page,\n Ebay::Search::Api::KEYWORDS[:key] => self.keywords\n }\n \n query_formatter(qargs) do |params|\n params.join(\"&\")\n end\n end", "def request_authorized_query query_string\n query query_string\nend", "def query_param\n params[:q]\n end", "def query_param\n return unless search_query\n \"search=#{search_query}&phrase=true\"\n end", "def query_string\n pairs = []\n @params.sort.each { | key, val |\n pairs.push( \"#{ percent_encode( key ) }=#{ percent_encode( val.to_s ) }\" )\n }\n pairs.join '&'\n end", "def to_s\n \"#{@base_url}?#{query}\"\n end", "def path_with_query\n uri = URI.parse(page.current_url)\n [uri.path, uri.query].map{|s| s if s.present? }.compact.join('?')\n end", "def item_url(result)\n query = CGI.parse(env.url.query.to_s)\n url = \"#{env.url.scheme}://#{env.url.host}/officers/#{result['identifiers'][0]['identifier']}\"\n if query['api_token'].any?\n url += \"?api_token=#{CGI.escape(query['api_token'][0].to_s)}\"\n end\n url\n end", "def query_params\n ref_path = request.path_info;\n ref_query = URI.decode(request.query_string)\n query_options = ref_query.split('&').select{|r| !r.blank?}\n res = []\n query_path = []\n \n query_options[0..-2].each do |qo|\n qo.match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n condition = $2\n found = false\n res << link_to(\"#{attribute.humanize}: #{condition}\", ref_path+\"?\"+query_path.join(\"&\"))\n query_path << qo\n \n end\n \n query_options[-1].match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n condition = $2\n res << \"#{attribute.humanize}: #{condition}\"\n \n return res.join(' > ')\n end", "def api_url\n \"http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced\" +\n \"&SERVICE-VERSION=1.9.0\" +\n \"&SECURITY-APPNAME=#{Settings.ebay.app_id}\" +\n \"&RESPONSE-DATA-FORMAT=JSON\" +\n \"&REST-PAYLOAD\" +\n \"&keywords=#{query}\"\n end", "def query_string(name, language, page)\n \"https://api.github.com/search/repositories?q=#{name}+language:#{language}&page=#{page}&per_page=100\"\nend", "def url_with_params\n url + \"/?\" + URI.encode_www_form(@options[:request_params])\n end", "def build_query_url(q)\n escaped_query = clean_query_string q\n index = AssignFast.index_for_authority(subauthority)\n return_data = \"#{index}%2Cidroot%2Cauth%2Ctype\"\n num_rows = 20 # max allowed by the API\n \"http://fast.oclc.org/searchfast/fastsuggest?&query=#{escaped_query}&queryIndex=#{index}&queryReturn=#{return_data}&suggest=autoSubject&rows=#{num_rows}\"\n end", "def api_query_parameter\n \"?apiKey=#{api_key}&longUrl=#{url}\"\n end", "def get_full_url(req_params)\n full_url=self.url\n\n if self.input_params.size>0\n full_url+=\"?\"\n\n self.input_params.each do |param|\n #puts \"name:\"+param.name+\"->value:\"+param.value\n if req_params.has_key? param.name #this was a dynamic param -> overwrite\n value=req_params[param.name]\n else\n value=param.value\n end\n\n full_url+=encode(param.name)+\"=\"+encode(value)+\"&\"\n end\n full_url=full_url[0..-2] #remove last &\n end\n\n return full_url\n end", "def query_params\n ref_path = request.path_info;\n ref_query = URI.decode(request.query_string)\n query_options = ref_query.split('&').select{|r| !r.blank?}\n res = []\n query_path = []\n\n query_options[0..-2].each do |qo|\n qo.match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n condition = $2\n found = false\n res << link_to(\"#{attribute.humanize}: #{condition}\", ref_path+\"?\"+query_path.join(\"&\"))\n query_path << qo\n\n end\n\n query_options[-1].match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n condition = $2\n res << \"#{attribute.humanize}: #{condition}\"\n\n return res.join(' > ')\n end", "def get_search_url(verses)\n url = PASSAGES_API + '?&q[]=' + CGI.escape(verses.join(','))\n return url \nend", "def get_search_url(verses)\n url = PASSAGES_API + '?&q[]=' + CGI.escape(verses.join(','))\n return url \nend", "def industria_params\n params[:industria]\n end", "def search_web_page(base_url,company)\n @agent.get(\"#{base_url}#{CGI::escape(company)}\")\n end", "def build_query_string()\n unless parameters.nil? || parameters.empty?\n query_strings = parameters.keys.sort {|a,b|\n a.to_s <=> b.to_s\n }.inject([]) do |result, element|\n value = parameters[element]\n value = value.join(\";\") if value.class == Array\n result << \"#{element.to_s}-#{value.to_s}\"\n end\n query_strings.join('/')\n else\n nil\n end\n end", "def query_param\n ::Genghis::JSON.decode(params.fetch('q', '{}'))\n end", "def query_param\n ::Genghis::JSON.decode(params.fetch('q', '{}'))\n end", "def request_url input\n query = { \"appid\" => @token, \"input\" => \"#{input}\" }.merge @options\n\n RequestURI.dup.tap do |this|\n this.query = URI.encode_www_form query\n end\n end", "def interal_query(query_value)\n \"_query_:\\\"#{query_value}\\\"\"\n end", "def query_string\n (@query_string_with_qmark.blank? ? '' : @query_string_with_qmark)\n end", "def query_url\n user_dn = env['omniauth.params']['user_dn']\n build_query = \"#{options.cas_server}#{options.authentication_path}\"\n build_query += \"/#{user_dn}\"\n build_query += \"/#{options.return_field}.#{options.format}\"\n URI.encode(build_query)\n end", "def get_query_params(url)\n url_partitioned_at_question_mark = url.partition(\"?\")\n url_partitioned_at_question_mark[2]\nend", "def canonical_query_string\n params.sort\n .map { |key, value| \"#{uri_escape(key)}=#{uri_escape(value)}\" }\n .join('&')\n end", "def search_url(*args)\n options = args.extract_options!.stringify_keys!\n protocol = (options.delete('protocol') || self.protocol).to_s\n \n uri = search_uri\n uri.scheme = protocol\n uri.query = [\"key=#{api_key}\", \"q=#{URI.escape(args.join(','))}\", *options.map{ |k,v| \"#{k}=#{v}\" }].join('&')\n p uri.to_s if self.debug\n return uri\n end", "def build_all_expiring_query(country_code)\n \"q=get%3Aexp%3A#{country_code}&t=ns&st=adv&p=1\"\n end", "def querinize(hash)\n \"?\" + hash.map { |k, v| \"#{k}=#{URI.encode(v.to_s)}\" }.join(\"&\")\n end", "def query_params\n {\n affiliate:,\n access_key:,\n query:,\n offset:,\n limit:\n }\n end", "def generate_search_url\n begin\n if self.search_url.blank? && job.county.search_template_url.present?\n params = generate_search_params.to_s\n if job.county.search_method == \"GET\"\n self.search_url = job.county.search_template_url.gsub(/\\{\\{params\\}\\}/, \"?#{params}\")\n end\n end\n rescue\n # don't worry if something went wrong generating the url\n end\n end", "def generate_request_url\n # analytics base url\n analytics_url = \"https://api.ibmaspera.com/analytics/v2/organizations/#{ORGANIZATION_ID}/\"\n # resource within analytics application\n analytics_resource = 'transfers'\n # query parameters\n start_time = CGI.escape('2019-01-19T23:00:00Z')\n stop_time = CGI.escape('2019-01-26T23:00:00Z')\n limit = 3\n parameters = \"?start_time=#{start_time}&stop_time=#{stop_time}&limit=#{limit}\"\n # print what the request url will look like\n puts \"\\n\\nanalytics_url: #{analytics_url + analytics_resource + parameters}\"\n analytics_url + analytics_resource + parameters\nend", "def query_string(options)\n # Omit parameters which appear in the URI path.\n query_params = options.reject { |key, value| prefix_parameters.include?(key) }\n\n # Accumulate a list of escaped key=value pairs for the given parameters.\n pairs = []\n query_params.each do |key, value|\n key = CGI.escape(key.to_s)\n\n # a => b becomes a=b\n # a => [b, c] becomes a[]=b&a[]=c\n case value\n when Array\n value.each { |val| pairs << \"#{key}[]=#{CGI.escape(val.to_s)}\" }\n else\n pairs << \"#{key}=#{CGI.escape(value.to_s)}\"\n end\n end\n\n \"?#{pairs * '&'}\" unless pairs.empty?\n end", "def search_url(term, scope, per_page)\n [PRIMO_API_URL, '/search?q=any,contains,', clean_term(term), '&vid=',\n PRIMO_VID, '&tab=', PRIMO_TAB, '&scope=', scope, '&limit=',\n per_page, '&apikey=', PRIMO_API_KEY].join\n end", "def query_parameters\n request.GET\n end", "def _url path = request.path, options = {}\n\t\tstr = path\n\t\tunless options.empty?\n\t\t\tstr += '?'\n\t\t\toptions.each do | k, v |\n\t\t\t\tstr = str + k.to_s + '=' + v.to_s + '&'\n\t\t\tend\n\t\tend\n\t\tstr\n\tend", "def formulate_url_with_query_string(url: nil, attributes: nil, txn_no: nil)\n query_string = {\n attributes: attributes.join(','),\n client_id: @client_id,\n singpassEserviceId: @singpass_eservice_id,\n txnNo: txn_no\n }\n\n \"#{url}?#{URI.encode_www_form(query_string)}\"\n end", "def query_string_for(options)\n message = @env['warden'].try(:message) || options[:message] || default_message\n\n params = case message\n when Symbol\n { message => true }\n when String\n { :message => message }\n else\n {}\n end\n\n Rack::Utils.build_query(params)\n end", "def get_search_params_and_query_string\n if !params[:tire_model_id].blank?\n @tire_store.tire_model_id = params[:tire_model_id]\n @search_query = \"tire_model_id=#{params[:tire_model_id].to_i}\"\n else\n if !params[:auto_options_id].blank?\n option = AutoOption.find(params[:auto_options_id])\n @tire_store.tire_size_id = option.tire_size_id if option\n elsif !params[:width].blank? && !params[:ratio].blank? && !params[:wheeldiameter].blank?\n # check and make sure the size is valid\n ts = TireSize.find_by_sizestr(\"#{params[:width].to_i}/#{params[:ratio].to_i}R#{params[:wheeldiameter].to_i}\")\n @tire_store.tire_size_id = ts.id if ts\n end\n \n if @tire_store.tire_size_id\n @search_query = \"tire_size_id=#{@tire_store.tire_size_id}\"\n \n #Don't include the manufacturer filter unless we have a valid size search going\n if !params[:tire_manufacturer_id].blank?\n @tire_store.tire_manufacturer_id_filter = params[:tire_manufacturer_id]\n @search_query += \"&tire_manufacturer_id_filter=#{params[:tire_manufacturer_id].to_i}\"\n end\n end\n end\n end", "def parameters\n url_params = \"\"\n\n if @resource == :catalog\n url_params += \"&\" + \"offset=#{URI.escape(@offset.to_s)}\" if @offset\n url_params += \"&\" + \"size=#{URI.escape(@size.to_s)}\" if @size\n url_params += \"&\" + \"search=#{URI.escape(@search)}\" if @search\n url_params += \"&\" + \"filter=#{URI.escape(@filter)}\" if @filter\n url_params += \"&\" + \"state=#{URI.escape(@state)}\" if @state\n url_params += \"&\" + \"sort=#{URI.escape(@sort)}\" if @sort\n url_params += \"&\" + \"instock=#{@instock}\" if @instock\n elsif @resource == :categorymap\n url_params += \"&\" + \"filter=#{URI.escape(@filter)}\" if @filter\n url_params += \"&\" + \"search=#{URI.escape(@search)}\" if @search\n elsif @resource == :reference\n url_params += \"&\" + \"filter=#{URI.escape(@filter)}\" if @filter\n end\n\n return url_params\n end", "def query_string=(nqs)\n @query_string_with_qmark = nqs.gsub(/^([^\\?])/, '?\\1')\n @headers[\"REQUEST_URI\"] = @headers[\"REQUEST_URI\"].split(/\\?/).shift + @query_string_with_qmark\n if nqs.blank?\n @headers.delete \"QUERY_STRING\"\n else\n @headers[\"QUERY_STRING\"] = nqs.gsub(/^\\?/, '')\n end\n end", "def getQuery()\n return @uri.query\n end", "def clean_query_string(q)\n ERB::Util.url_encode(q.gsub(/-|\\(|\\)|:/, \"\"))\n end", "def path\n query_parts = []\n @query.each_pair { |key, value| query_parts << \"#{key}=#{URI.escape(value)}\" }\n query_parts.length > 0 ? \"#{@path}?#{query_parts.join('&')}\" : @path\n end", "def query_name\n if filters.one?\n filters.keys.first.to_s\n else\n filters.keys.join('_and_')\n end\n end", "def crawler_url\n \"http://www.ebay.com/sch/i.html?_nkw=#{query}\"\n end" ]
[ "0.67935437", "0.65269196", "0.6448713", "0.64261854", "0.6323839", "0.6293369", "0.62864363", "0.62228286", "0.6221806", "0.62193173", "0.6199676", "0.6172756", "0.61655116", "0.6156877", "0.61501676", "0.6129463", "0.611977", "0.6110325", "0.6098706", "0.60915345", "0.607112", "0.607112", "0.6066733", "0.60647315", "0.6063255", "0.6051176", "0.6034002", "0.600111", "0.59422094", "0.59355605", "0.59274554", "0.5906335", "0.58992594", "0.5891397", "0.58776057", "0.58593297", "0.58503515", "0.5833805", "0.5833805", "0.5828947", "0.5812806", "0.58038074", "0.57986194", "0.57970494", "0.5795144", "0.57877815", "0.57872903", "0.5778006", "0.57321775", "0.5727451", "0.57170856", "0.5713853", "0.5711772", "0.571006", "0.57077867", "0.56997836", "0.5688209", "0.56848145", "0.567824", "0.5674967", "0.5674603", "0.5660661", "0.5659585", "0.5655429", "0.5648946", "0.5642768", "0.56408083", "0.5638381", "0.5638381", "0.5635216", "0.56276095", "0.562367", "0.56221", "0.56221", "0.5589051", "0.5575886", "0.55741626", "0.55617607", "0.55444175", "0.55373603", "0.5521698", "0.5518964", "0.55184066", "0.55140376", "0.55129063", "0.5509164", "0.54857755", "0.547511", "0.54682475", "0.546023", "0.54566336", "0.54546666", "0.54520416", "0.5449499", "0.54447865", "0.5441991", "0.5440831", "0.5436641", "0.54349875", "0.54281825" ]
0.59295756
30
Get educations query string
def educations_query_str(education_ids) education_ids = education_ids.split(',') list_of_educations = convert_educations_to_hash edu_query = ['('] education_ids.each_with_index do |id, index| if index.zero? edu_query.push "education like '%#{list_of_educations[id.to_i]}%'" else edu_query.push " OR education like '%#{list_of_educations[id.to_i]}%'" end end edu_query.push ')' edu_query.join('') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_string\n end", "def query_string\n return @query_string\n end", "def query_string\n \"#{base_url}dmQuery/#{collection_alias}/#{searchstrings}/#{fields}/\" +\n \"#{sortby}/#{max_recs}/#{start}/#{suppress_pages}/#{docptr}/#{suggest}/\" +\n \"#{facets}/#{showunpub}/#{denormalize_facets}/#{response_format}\"\n end", "def query_string\n \"#{base_url}dmQuery/#{collection_alias}/#{searchstrings}/#{fields}/\" +\n \"#{sortby}/#{max_recs}/#{start}/#{suppress_pages}/#{docptr}/#{suggest}/\" +\n \"#{facets}/#{showunpub}/#{denormalize_facets}/#{response_format}\"\n end", "def generate_next_url\n if eds_session.has_key? :query_string\n url = HTMLEntities.new.decode eds_session[:query_string]\n\n #blacklight expects the search term to be in the parameter 'q'.\n #q is moved back to 'query-1' in 'generate_api_query'\n #should probably pull from Info method to determine replacement strings\n #i could turn the query into a Hash, but available functions to do so delete duplicated params (Addressable)\n url.gsub!(\"query-1=AND,TI:\", \"q=\")\n url.gsub!(\"query-1=AND,AU:\", \"q=\")\n url.gsub!(\"query-1=AND,SU:\", \"q=\")\n url.gsub!(\"query-1=AND,\", \"q=\")\n\n #Rails framework doesn't allow repeated params. turning these into arrays fixes it.\n url.gsub!(\"facetfilter=\", \"facetfilter[]=\")\n url.gsub!(\"limiter=\", \"limiter[]=\")\n\n #i should probably pull this from the query, not the URL\n if (params[:search_field]).present?\n url << \"&search_field=\" << params[:search_field].to_s\n end\n return url\n else\n return ''\n end\n end", "def query_string\n ''\n end", "def query_string\n \"\"\n end", "def query_string\n if method == \"GET\" && !request_parameters.empty?\n \"?#{request_parameters.to_query}\"\n end\n end", "def query_string\n return nil if @request.query_string.to_s.empty?\n\n parts = @request.query_string.split(/[&;] */n)\n parts.map! { |p| p.split('=', 2).map!{ |s| unescape(s) } }\n parts.sort!\n parts.reject!(&self.class.query_string_ignore)\n parts.map! { |k,v| \"#{escape(k)}=#{escape(v)}\" }\n parts.empty? ? nil : parts.join('&')\n end", "def query_string\n @env['QUERY_STRING'].present? ? @env['QUERY_STRING'] : (@env['REQUEST_URI'].split('?', 2)[1] || '')\n end", "def query_string\n return nil if @request.query_string.nil?\n\n @request.query_string.split(/[&;] */n).\n map { |p| unescape(p).split('=', 2) }.\n sort.\n map { |k,v| \"#{escape(k)}=#{escape(v)}\" }.\n join('&')\n end", "def query_string\n nil\n end", "def query_string\n return nil if @request.query_string.nil?\n ignore_query_params = [\"no-cachely\", \"refresh-cachely\", Rack::Cachely.config.ignore_query_params].flatten\n query = @request.query_string.split(/[&;] */n).map { |p| unescape(p).split('=', 2) }.sort\n query = query.reject{|k,v| ignore_query_params.include?(k)}.map{ |k,v| \"#{escape(k)}=#{escape(v)}\" }\n\n query.join('&')\n end", "def to_query_string\n query = @uri.query\n query ? Wgit::Url.new(\"?#{query}\") : nil\n end", "def get_querystring\n request_object.querystring\n end", "def query_string\n (authenticate? && authenticable?) ? signed_query_string : unsigned_query_string\n end", "def query_string\n return @query_string if defined?(@query_string)\n @query_string = headers[PATH_KEY].index '?'\n return if @query_string.nil?\n @query_string = headers[PATH_KEY][(@query_string + 1)..-1]\n end", "def qs\n if @r && @r['QUERY_STRING'] && !@r['QUERY_STRING'].empty?\n '?' + @r['QUERY_STRING']\n elsif query && !query.empty?\n '?' + query\n else\n ''\n end\n end", "def get_query_string\n qs = @req.env['QUERY_STRING']\n # Lighty's fcgi-bindings use its 404 handler and it doesn't provide QUERY_STRING\n if qs.blank? && @req.env['SERVER_SOFTWARE'] =~ /lighttpd/\n match = @req.env['REQUEST_URI'].match(/\\?(.*)/)\n qs = match[1] if match\n end \n qs\n end", "def query_params\n URI.encode_www_form(\n {\n affiliate:,\n access_key:,\n module_code:,\n url:,\n query:,\n position:,\n user_agent:\n }\n )\n end", "def query_string\n return nil if @request.query_string.nil?\n if whitelist_mode?\n whitelist(@request.query_string)\n else\n blacklist(@request.query_string)\n end\n end", "def query_string\n ast.to_query_string\n end", "def build_query_url(q)\n escaped_query = clean_query_string q\n index = AssignFast.index_for_authority(subauthority)\n return_data = \"#{index}%2Cidroot%2Cauth%2Ctype\"\n num_rows = 20 # max allowed by the API\n \"http://fast.oclc.org/searchfast/fastsuggest?&query=#{escaped_query}&queryIndex=#{index}&queryReturn=#{return_data}&suggest=autoSubject&rows=#{num_rows}\"\n end", "def query_string(**params)\n params.map { |k, v| [k, v].join('=') }.join('&')\n end", "def uri\n \"#{query_uri}?#{query_options.to_query}\"\n end", "def query_parameters_string\n request.filtered_env[\"rack.request.query_string\"]\n end", "def request_authorized_query query_string\n query query_string\nend", "def query\n params.sort.map { |k, v| \"#{k}=\" + escape(v) }.join('&')\n end", "def unsigned_query_string\n (should_encode? ? RestClient::Payload.generate(query_params) : query_params).to_s\n end", "def query_string\n (@query_string_with_qmark.blank? ? '' : @query_string_with_qmark)\n end", "def url\n endpoint+'?'+query_string\n end", "def query_string(action, params)\n payload = action + \"?\"\n params.each {|key, value| payload += \"&#{key}=#{value}\" }\n payload\n end", "def url\n query_url = \"#{@url}?q=#{@query}&locale=#{@locale}\"\n query_url << @topics.map { |t| \"&topic=#{t}\" }.join\n unless @css_classnames.nil?\n query_url << \"&css_classnames=#{@css_classnames}\"\n end\n unless @html_attributes.nil?\n query_url << \"&html_attributes=#{@html_attributes}\"\n end\n query_url << \"&highlight=#{@highlight}\" unless @highlight.nil?\n query_url\n end", "def conceptwiki_ep_search\n\t\tOPS_API_FREETEXT_SEARCH_URL\n\tend", "def query_string(options={})\n default_options.merge(options).delete_if{ |k, v| v.nil? || v == \"\" }.sort.map{ |arr| \"#{arr[0]}=#{arr[1]}\" }.join(\"&\")\n end", "def get_url\n\t\t\"http://unm-research.herokuapp.com/project_surveys?utf8=%E2%9C%93&q%5Bdepartment_cont%5D=#{self.name.strip.gsub(\" \", \"+\")}&commit=Search\"\n\tend", "def search_string\n params.fetch(:frag, session[:frag])\n end", "def request_string\n \"#{authentication_string}&\" + @request_parameters.\n reject{|k| self.send(k).blank?}.map(&:to_s).sort.map{|k|\n \"#{k.to_s.upcase}=#{escape(self.send(k))}\"\n }.flatten.join('&')\n end", "def getQuery()\n return @uri.query\n end", "def query_string(params)\n params = full_options params\n params[:sign] = sign params\n \"?\" + params.to_query\n end", "def query_string_params\n super + [:chls]\n end", "def get_full_url(req_params)\n full_url=self.url\n\n if self.input_params.size>0\n full_url+=\"?\"\n\n self.input_params.each do |param|\n #puts \"name:\"+param.name+\"->value:\"+param.value\n if req_params.has_key? param.name #this was a dynamic param -> overwrite\n value=req_params[param.name]\n else\n value=param.value\n end\n\n full_url+=encode(param.name)+\"=\"+encode(value)+\"&\"\n end\n full_url=full_url[0..-2] #remove last &\n end\n\n return full_url\n end", "def expedition_params\n params[:expedition]\n end", "def query_string\n pairs = []\n @params.sort.each { | key, val |\n pairs.push( \"#{ percent_encode( key ) }=#{ percent_encode( val.to_s ) }\" )\n }\n pairs.join '&'\n end", "def path_with_query\n uri = URI.parse(page.current_url)\n [uri.path, uri.query].map{|s| s if s.present? }.compact.join('?')\n end", "def build_query_string()\n unless parameters.nil? || parameters.empty?\n query_strings = parameters.keys.sort {|a,b|\n a.to_s <=> b.to_s\n }.inject([]) do |result, element|\n value = parameters[element]\n value = value.join(\";\") if value.class == Array\n result << \"#{element.to_s}-#{value.to_s}\"\n end\n query_strings.join('/')\n else\n nil\n end\n end", "def request_url\n query_builder.request_string\n end", "def query_param\n params[:q]\n end", "def query_string\n pairs = []\n @params.sort.each { | key, val | \n pairs.push( \"#{ percent_encode( key ) }=#{ percent_encode( val.to_s ) }\" )\n }\n pairs.join '&'\n end", "def url_with_query_string\n if query_string && query_string.size > 0\n base_url + \"?#{query_string}\"\n else\n base_url\n end\n end", "def query\n\t\t\treturn @query if @query\n\n\t\t\t@query = CGI.parse(request.query_string)\n\t\t\[email protected] = nil # ruby/lib/cgi/core.rb:340 = den of iniquity.\n\t\t\t@query\n\t\tend", "def query_params\n ref_path = request.path_info;\n ref_query = URI.decode(request.query_string)\n query_options = ref_query.split('&').select{|r| !r.blank?}\n res = []\n query_path = []\n \n query_options[0..-2].each do |qo|\n qo.match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n condition = $2\n found = false\n res << link_to(\"#{attribute.humanize}: #{condition}\", ref_path+\"?\"+query_path.join(\"&\"))\n query_path << qo\n \n end\n \n query_options[-1].match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n condition = $2\n res << \"#{attribute.humanize}: #{condition}\"\n \n return res.join(' > ')\n end", "def query_param\n return unless search_query\n \"search=#{search_query}&phrase=true\"\n end", "def query_params; end", "def query_params\n ref_path = request.path_info;\n ref_query = URI.decode(request.query_string)\n query_options = ref_query.split('&').select{|r| !r.blank?}\n res = []\n query_path = []\n\n query_options[0..-2].each do |qo|\n qo.match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n condition = $2\n found = false\n res << link_to(\"#{attribute.humanize}: #{condition}\", ref_path+\"?\"+query_path.join(\"&\"))\n query_path << qo\n\n end\n\n query_options[-1].match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n condition = $2\n res << \"#{attribute.humanize}: #{condition}\"\n\n return res.join(' > ')\n end", "def query_string=(value)\n @query_string = value\n end", "def query_params\n params[:query]\n end", "def canonical_query_string\n params.sort\n .map { |key, value| \"#{uri_escape(key)}=#{uri_escape(value)}\" }\n .join('&')\n end", "def manipulate_url(options = {})\n params_to_remove = options[:remove_query_param]\n page = options[:page]\n l_d_exp = options[:l_d_exp]\n me_d_exp = options[:me_d_exp]\n escape = options[:escape]\n path = options[:path] || request.path\n query_params = request.query_parameters.deep_dup\n if params_to_remove && query_params.present?\n params_to_remove.each do |param|\n query_params.delete(param.to_s)\n end\n end\n query_params[:page] = page if page\n query_params[:lessons_expanded] = l_d_exp if l_d_exp\n query_params[:media_elements_expanded] = me_d_exp if me_d_exp\n query_string = get_recursive_array_from_params(query_params).join('&')\n return path if query_string.blank?\n url = \"#{path}?#{query_string}\"\n url = URI.escape(url)\n escape ? CGI.escape(url) : url\n end", "def append_to_query_string(piece)\n new_qs = '?' + [self.query_string.gsub(/^\\?/, ''), piece].reject{|e| e.blank? }.join('&')\n self.query_string = new_qs\n end", "def query\n sanitize search_params['query']\n end", "def extra_query_param\n return \"\" unless env['omniauth.params']\n env['omniauth.params'].map{|k,v| \"&#{k}=#{Rack::Utils.escape(v)}\"}.join\n end", "def query_string\n _f = @params.fields.include?(:full_text) ? [:full_text] : fields\n # byebug\n a = query.gsub('/', '').scan( /\"[^\"]+\"|[^ ]+/ ).map do |word|\n if word[0] === '\"'\n m = word.match( /^\"(.*)\"$/ );\n word = m ? m[1] : word;\n end\n Unicode.downcase(word.gsub('\"', ''))\n end\n _q = '(' + a.join('* AND ') + '*)'\n # _q = '/(?=.*?'+a.join( ')(?=.*?' )+').*/';\n #byebug\n index.filter{ ~q(query_string: {fields: _f, query: \"#{_q}\", default_operator: 'or'}) } if _q.present? && _f.present?\n\n #index.query(multi_match: {query: \"#{_q}*\", fields: _f}) if _q.present? && _f.present\n end", "def query_parameters; end", "def clean_query_string(q)\n ERB::Util.url_encode(q.gsub(/-|\\(|\\)|:/, \"\"))\n end", "def query_string \n headers[\"QUERY_STRING\"]\n end", "def url_query_string(leading_slash = true)\n (leading_slash ? \"/?\" : \"?\") << URI.escape(self.collect{|k,v| \"#{k}=#{v}\"}.join('&'))\n end", "def query_uri\n session ? session.query_uri : Wac.query_uri\n end", "def query_string=(nqs)\n @query_string_with_qmark = nqs.gsub(/^([^\\?])/, '?\\1')\n @headers[\"REQUEST_URI\"] = @headers[\"REQUEST_URI\"].split(/\\?/).shift + @query_string_with_qmark\n if nqs.blank?\n @headers.delete \"QUERY_STRING\"\n else\n @headers[\"QUERY_STRING\"] = nqs.gsub(/^\\?/, '')\n end\n end", "def eds_action_url eds_action\n search_action_url + '?' + generate_next_url + '&eds_action=' + eds_action\n end", "def http_query_string\n <<-END_POST\nbody=%5B%22KOSE%E9%AB%98%E4%B8%9D%E9%9B%AA%E8%82%8C%E7%B2%BE%E6%B4%97%E9%A2%9C%E4%B9%B3%22%5D&buyer_email=18611543280&buyer_id=2088902582208882&exterface=create_direct_pay_by_user&is_success=T&notify_id=RqPnCoPT3K9%252Fvwbh3InQ8703uAICbLI7SGaz7f3Qe96t7vC6a1YKnYuOZTls2t9kw%252F6z&notify_time=2014-11-11+17%3A59%3A28&notify_type=trade_status_sync&out_trade_no=R990240665&payment_type=1&seller_email=acct-ali%40shiguangcaibei.com&seller_id=2088611493982911&subject=%E8%AE%A2%E5%8D%95%E7%BC%96%E5%8F%B7%3AR990240665&total_fee=1.43&trade_no=2014111159601788&trade_status=TRADE_SUCCESS&sign=1c3e7b66a6a7e704f0ad2ed0bc25ee04&sign_type=MD5\n END_POST\n .chomp!\n end", "def query_parameters\n end", "def request_uri\n uri = URI.parse(Europeana::URL + \"/search.json\")\n request_params = params_with_authentication\n\n if request_params[:qf].is_a?(Hash)\n qf = request_params.delete(:qf)\n uri.query = request_params.to_query\n qf.each_pair do |name, criteria|\n [ criteria ].flatten.each do |criterion|\n uri.query = uri.query + \"&qf=\" + CGI::escape(name.to_s) + \":\" + CGI::escape(criterion)\n end\n end\n else\n uri.query = request_params.to_query\n end\n \n uri\n end", "def query_path\n query_string = env.fetch('QUERY_STRING')\n return '' if query_string.empty?\n\n query_hash = Rack::Utils.parse_query(query_string)\n query_hash.each_pair.with_object(['/query']) { |(key, val), result|\n result << \"/#{key}-is-#{val}\"\n }.join()\n end", "def build_request_url(params)\n \"http://api.nytimes.com/svc/search/v2/articlesearch.json?\"+params\n end", "def q\n @q ||= HTTP.parseQs qs[1..-1]\n end", "def get_query_params(url)\n url_partitioned_at_question_mark = url.partition(\"?\")\n url_partitioned_at_question_mark[2]\nend", "def interal_query(query_value)\n \"_query_:\\\"#{query_value}\\\"\"\n end", "def params\n params = +'ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article'\n params << \"&rft_id=info:doi%2F#{CGI.escape(@doc.doi)}\" if @doc.doi\n params << \"&rft.atitle=#{CGI.escape(@doc.title)}\" if @doc.title\n params << \"&rft.title=#{CGI.escape(@doc.journal)}\" if @doc.journal\n params << \"&rft.date=#{CGI.escape(@doc.year)}\" if @doc.year\n params << \"&rft.volume=#{CGI.escape(@doc.volume)}\" if @doc.volume\n params << \"&rft.issue=#{CGI.escape(@doc.number)}\" if @doc.number\n params << \"&rft.spage=#{CGI.escape(@doc.start_page)}\" if @doc.start_page\n params << \"&rft.epage=#{CGI.escape(@doc.end_page)}\" if @doc.end_page\n unless @doc.authors.empty?\n au = @doc.authors[0]\n params << \"&rft.aufirst=#{CGI.escape(au.first)}\" if au.first\n params << \"&rft.aulast=#{CGI.escape(au.last)}\" if au.last\n end\n if @doc.authors.size > 1\n @doc.authors[[email protected]].each do |a|\n params << \"&rft.au=#{CGI.escape(a.full)}\"\n end\n end\n params\n end", "def _url path = request.path, options = {}\n\t\tstr = path\n\t\tunless options.empty?\n\t\t\tstr += '?'\n\t\t\toptions.each do | k, v |\n\t\t\t\tstr = str + k.to_s + '=' + v.to_s + '&'\n\t\t\tend\n\t\tend\n\t\tstr\n\tend", "def unsigned_query_string_stripped\n @query_params_text ||= obj_to_stripped_string(query_params)\n end", "def query_string_for(options)\n message = @env['warden'].try(:message) || options[:message] || default_message\n\n params = case message\n when Symbol\n { message => true }\n when String\n { :message => message }\n else\n {}\n end\n\n Rack::Utils.build_query(params)\n end", "def url_with_params\n url + \"/?\" + URI.encode_www_form(@options[:request_params])\n end", "def query_parameters\n request.GET\n end", "def build_query_string(hash)\n elements = []\n query_string = \"\"\n\n hash.each do |key, value|\n\t key = CGI.escape key\n\t key += '[]' if value.class == Array\n\t value = [ value ] unless value.class == Array\n\t value.each { |val| elements << \"#{key}=#{CGI.escape(val.to_s)}\" }\n\tend\n unless elements.empty? then query_string << (\"?\" + elements.join(\"&\")) end\n \n return query_string\n end", "def redirection_to\n URI(\"#{ENV['DOMAIN_URL']}/deposits/?#{query_params}\").to_s\n end", "def generate_query_string_params(payload)\n payload.delete(:client_secret) if payload.has_key? :client_secret\n\n signed_token = sign(payload)\n payload[:client_id] = @client_id\n payload[:stoken] = signed_token\n qsa = []\n\n payload.keys.sort.each do | key |\n qsa.push sprintf(\"%s=%s\", key, payload[key])\n end\n\n qsa.join(\"&\")\n end", "def compile_query_url(endpoint, query)\n \"#{REPLICA_TOOL_URL}#{endpoint}?#{project_database_params}&#{query}\"\n end", "def build_query_string(fields)\n return nil if fields.nil?\n tmp = []\n fields.each{|k,v|\n tmp << \"#{k.to_s}=#{CGI::escape(v.to_s)}\"\n }\n tmp.join(\"&\")\n end", "def to_s\n \"#{@base_url}?#{query}\"\n end", "def to_query\n query = @uri.query\n query ? Wgit::Url.new(query) : nil\n end", "def build_query_string(options)\n\n q_str = \"#{API_KEY}\"\n return q_str if !options || options.empty?\n options.each do |key, value|\n q_str += \"&#{key}=#{value}&\"\n end\n\n q_str\n end", "def query_url\n user_dn = env['omniauth.params']['user_dn']\n build_query = \"#{options.cas_server}#{options.authentication_path}\"\n build_query += \"/#{user_dn}\"\n build_query += \"/#{options.return_field}.#{options.format}\"\n URI.encode(build_query)\n end", "def extract_request_query_string\n \n result = {}\n\n if request.query_string.length > 0\n result.store(:params, Hash[request.query_string.split('&').map {|x| x.split('=')}])\n end\n\n return result\n\n end", "def path\n query_parts = []\n @query.each_pair { |key, value| query_parts << \"#{key}=#{URI.escape(value)}\" }\n query_parts.length > 0 ? \"#{@path}?#{query_parts.join('&')}\" : @path\n end", "def params\n @params||=Addressable::URI.parse(\"?#{@http_query_string}\").query_values\n end", "def auth_values_as_query_string( parsed_url )\n \n @params = {\n 'oauth_version' => @oauth_version,\n 'oauth_consumer_key' => @consumer_key,\n 'oauth_token' => @token,\n 'oauth_timestamp' => Time.now.to_i.to_s,\n 'oauth_nonce' => nonce,\n 'oauth_signature_method' => @sig_method,\n }\n\n # if url has query, merge key/values into params obj overwriting defaults\n if parsed_url.query\n CGI.parse( parsed_url.query ).each do |k,v|\n if v.is_a?(Array) && v.count == 1\n @params[k] = v.first\n else\n @params[k] = v\n end\n end\n end\n \n # @ref http://oauth.net/core/1.0/#rfc.section.9.1.2\n @req_url = parsed_url.scheme + '://' + parsed_url.host + parsed_url.path\n \n # create base str. make it an object attr for ez debugging\n # ref http://oauth.net/core/1.0/#anchor14\n @base_str = [ \n @req_method, \n percent_encode( req_url ), \n \n # normalization is just x-www-form-urlencoded\n percent_encode( query_string ) \n \n ].join( '&' )\n\n # add signature\n @params[ 'oauth_signature' ] = signature\n \n percent_encode(@params.to_json)\n # return self\n end", "def query_string(params)\n params.map do |k, v|\n \"#{CGI::escape(k)}=#{CGI::escape(v)}\"\n end.join(\"&\")\n end", "def query_string(term:, page: 1, filters: [])\n query_string = [\"query=#{term}\", \"page=#{page}\"]\n query_string << \"filter=#{filters.join(',')}\" if filters.any?\n query_string.join('&')\n end", "def query_string(term:, page: 1, filters: [])\n query_string = [\"query=#{term}\", \"page=#{page}\"]\n query_string << \"filter=#{filters.join(',')}\" if filters.any?\n query_string.join('&')\n end" ]
[ "0.7206758", "0.7026792", "0.6618598", "0.6618598", "0.65273887", "0.6515375", "0.6489365", "0.6470043", "0.64572954", "0.6367679", "0.6365427", "0.6332162", "0.632026", "0.6225295", "0.6145192", "0.6122958", "0.6101451", "0.6101064", "0.6064199", "0.5996661", "0.5965971", "0.59653836", "0.5964549", "0.5942309", "0.5924666", "0.5921067", "0.5903098", "0.5890819", "0.5876156", "0.58701754", "0.5868796", "0.58259374", "0.5803517", "0.577759", "0.5773093", "0.5767312", "0.57195216", "0.5717417", "0.5694956", "0.5656408", "0.5655263", "0.5653661", "0.5646929", "0.5629107", "0.5619723", "0.56151545", "0.5611334", "0.5602993", "0.5602468", "0.5597688", "0.55706596", "0.55643344", "0.55589694", "0.55531776", "0.55514574", "0.5551329", "0.55389214", "0.55239874", "0.5522043", "0.5517381", "0.55158854", "0.55046684", "0.54952794", "0.54740196", "0.54654497", "0.5461317", "0.5437091", "0.54333115", "0.54248494", "0.5410685", "0.5404704", "0.54020166", "0.5397889", "0.53957474", "0.5380666", "0.53527236", "0.5348092", "0.53479767", "0.53467655", "0.53442836", "0.5341548", "0.5335572", "0.5333179", "0.5331935", "0.5320998", "0.53096396", "0.5308166", "0.5303637", "0.5296459", "0.5295863", "0.5294758", "0.52891076", "0.52817345", "0.527977", "0.52740484", "0.52668667", "0.5265963", "0.5261333", "0.52607846", "0.52607846" ]
0.5705435
38
scrape the front end of CLUTCH for company name and url
def company_name(position) "#block-system-main > div > div > div > section > div > div.row > div > div.service-page-rows > ul > li:nth-child(#{position}) > div > div.col-xs-12.col-md-10.bordered-right.provider-base-info > div.row.provider-row-header > div > h3 > a" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getCompanyInfo(url)\n\tdoc = Nokogiri::HTML(open(url))\n\tarticle = doc.css('article.company_detail')\n\n\t# top details\n\n\ttopDiv = article.css('div.top_company_detail')\n\n\tnameDiv = topDiv.css('div.com_name')\n\tname = nameDiv.css('h2').text\n\tsubName = nameDiv.css('p').text\n\tlogo = nameDiv.css('a img').first['src']\n\taddress = topDiv.css('div.row.com_address p span').text\n\tputs name, subName, logo, address\n\n\ta = topDiv.css('div.com_social a').first\n\tif a != nil\n\t\tfacebook = a['href']\n\t\tputs facebook\n\tend\n\n\tinfoDiv = topDiv.css('div.row.com_info div').first\n\telements = infoDiv.elements\n\ti = 0\n\twhile i < elements.length do\n\t\tlbl = elements[i].css('label').text.strip\n\t\tcase lbl\n\t\twhen \"Telephone :\", \"Fax :\"\n\t\t\tdata = elements[i=i+1]\n\t\t\tdata = data.css('> text()').text.strip + data['data-last'].strip\n\t\twhen \"Email :\"\n\t\t\tdataCfEmail = elements[i].css('span.__cf_email__').first['data-cfemail']\n\t\t\tdata = getEmail(dataCfEmail)\n\t\twhen \"Website:\"\n\t\t\tdata = elements[i].css('a').text\n\t\twhen \"Catalogue Link :\"\n\t\t\tdata = elements[i].css('a.com_catelogue').first['href']\n\t\telse\n\t\t\tSTDERR.puts \"label: \" + lbl\n\t\tend\n\t\ti += 1\n\t\t\n\t\tputs lbl\n\t\tputs data\n\tend\n\n\tcategories = []\n\telements = topDiv.css('div div.line_share_social p.row.com_cat a')\n\telements.each do |element|\n\t\tcategories.push(element.text)\n\tend\n\tputs 'Categories: ', categories\n\n\ttextNodes = topDiv.css('div div.left.com_description text()')\n\tdescription = textNodes.map {|textNode| textNode.text.strip }.join(\"\\n\")\n\tputs description\n\n\tparagraphs = topDiv.css('div div.com_person_contact p')\n\tparagraphs.each do |paragraph|\n\t\tlbl = paragraph.css('label').text.strip\n\t\tcase lbl\n\t\twhen \"Main Contact :\", \"Designation :\", \"Websites :\", \"Tel :\", \"Payment Method :\", \"Market Coverage :\", \"Opening hours :\", \"Staff Strength :\", \"Year Established :\"\n\t\t\ttextNodes = paragraph.css('span text()')\n\t\t\tdata = textNodes.map {|textNode| textNode.text.strip }.join(\"\\n\")\n\t\twhen \"Email :\"\n\t\t\tdataCfEmail = paragraph.css('a.__cf_email__').first['data-cfemail']\n\t\t\tdata = getEmail(dataCfEmail)\n\t\telse\n\t\t\tSTDERR.puts \"label: \" + lbl\n\t\tend\n\t\tputs lbl, data\n\tend\n\n\t# middle details\n\n\tmiddleDiv = article.css('div.company_detail_middle')\n\n\tproducts = middleDiv.css('#product div a').map {|a| a['title']}\n\tputs 'Products: ', products\n\n\tdisplayAd = middleDiv.css('#iframeDisplayAd').first['src']\n\tputs displayAd\n\n\tiframe = middleDiv.css('#catalogue div.company_tab_content iframe').first\n\tif iframe != nil\n\t\tcatalogue = iframe['src']\n\t\tputs catalogue\n\tend\n\n\t# listingName = middleDiv.css('#comp_detail_all_listing p').text\n\t# middleDiv.css('#comp_detail_all_listing div').each do|listingDiv| {\n\t# \tdivs = listingDiv.css('div div')\n\t# }\nend", "def getCompanyInfo(company)\n url = \"http://api.crunchbase.com/v/1/company/#{company}.js?api_key=#{@api_key}\"\n #page_contents = Nokogiri::HTML(open(@site_url))\n \n page_contents = Net::HTTP.get(URI.parse(url))\n \n data = JSON.parse(page_contents)\n\n output = Hash.new\n output[:name] = data[\"name\"]\n output[:homepage_url] = data[\"homepage_url\"]\n output[:founded_year] = data[\"founded_year\"].to_s\n output[:category_code] = data[\"category_code\"]\n output[:tag_list] = data[\"tag_list\"]\n output[:description] = data[\"description\"]\n output[:overview] = data[\"overview\"].nil? ? \"\" : data[\"overview\"].gsub(\"\\n\", \" \")\n output[:raised_amount] = data[\"investments\"][0][\"funding_round\"][\"raised_amount\"].to_s rescue \"\"\n output[:raised_currency_code] = data[\"investments\"][0][\"funding_round\"][\"raised_currency_code\"] rescue \"\"\n output[:funded_year] = data[\"investments\"][0][\"funding_round\"][\"funded_year\"] rescue \"\"\n\n if !@required_words.empty? || !@optional_words.empty?\n searchable_fields = [:category_code, :tag_list, :description, :overview]\n searchable = \"\"\n searchable_fields.each { |field| searchable << \" #{output[field]}\" }\n\n unless @optional_words.empty?\n return nil unless search_optional(searchable)\n end\n\n unless @required_words.empty?\n return nil unless search_required(searchable)\n end\n end\n\n File.open('allCompanies.txt', 'a') {|f| f.write(output.values.join(\"|\") + \"\\n\") }\n puts \"Finished getting company #{company}\"\nend", "def run\n super\n \n require 'nokogiri'\n require 'open-uri'\n require 'cgi'\n \n # Search URI\n search_uri = \"http://www.hoovers.com/search/company-search-results/100005142-1.html?type=company&term=#{@object.name}\"\n doc = Nokogiri::HTML(open(search_uri))\n company_path = doc.xpath(\"//*[@class='company_name']\").first.children.first['href']\n company_uri = \"http://www.hoovers.com#{company_path}\"\n \n # Open Page & Parse\n doc = Nokogiri::HTML(open(company_uri))\n \n # Get Company Profile\n # TODO\n \n # Get Address & Clean up\n address = (doc/\"/html/body/div[3]/div[2]/table/tbody/tr/td/strong/span\").inner_html\n puts \"Got Address: #{address}\"\n \n # Get Users\n user = (doc/\"/html/body/div[3]/div[2]/div[9]/table/tbody/tr/td\").inner_html\n\n unless user.blank?\n names = user.gsub(\"a href=\\\"/marketing/free-trial/100004836-1.html\\\" title=\\\"Email lists, email contacts, contact phone numbers, email leads, phone leads\\\" relatedarticles=\\\"false\\\" id=\\\"100004836\\\">E-mail</a>\",\"\").split(\"<\") \n puts \"Got Users: #{names.join(\" \")}\"\n \n names.each do |name| \n name.gsub!(\"&nbsp;\",\" \")\n fname,lname = name.split(\" \")\n create_object User, { :fname => fname, :lname => lname }\n end\n end\n \n\tnil\nend", "def get_company_info(link)\n info = {}\n company_page = parse_page(@agent.get(link))\n info[:title] = get_job_title(company_page)\n info[:company] = get_company(company_page)\n info[:location] = get_location(company_page)\n info[:date] = get_date(company_page)\n info[:company_id] = get_company_id(company_page)\n info[:position_id] = get_position_id(company_page)\n info\n end", "def search_web_page(base_url,company)\n @agent.get(\"#{base_url}#{CGI::escape(company)}\")\n end", "def get_information_all_companies()\n\t\tpage = 275\n\t\tbegin\n\t\t\turl = create_url(\"organizations\",\"\",page)\n\t\t\tputs \"Reading #{url}\"\n\t\t\tresult = read_url(url)\n\t\t\t#save_json(result, [\"organizations\"])\n\n\t\t\tadd_organization_info(result,\"name\")\n\t\t\tadd_organization_info(result,\"path\")\n\t\t\t\n\t\t\tnext_url = result['data']['paging']['next_page_url']\n\t\t\tpage = page + 1\n\t\tend while next_url != nil\n\t\tcreate_permalink(@paths)\n\t\tsave_json(\"\", [\"names\", \"paths\", \"permalinks\"])\n\tend", "def get_cities\n cities = {}\n doc = nil\n retry_if_exception do\n doc = Nokogiri::HTML( easy_curl(@host_url) )\n end\n return [] if not doc\n a_cities = doc.css(\"ul[class='s-dropdown afh-dd-city'] li a\")\n a_cities.each do |city|\n city_name = city.text\n city_code = city['href'].scan(/\\w+(?=\\/changecity)/).pop\n next if not city_code\n cities[city_code] = city_name\n end\n cities\nend", "def get_grand_company(page)\n gc = nil\n lines = page.grep(/txt_name/)\n\n # checks to see if the optional free company line has been added\n fc = lines.grep(/a href=/)\n\n # GOOD CONDITIONS\n # 5 lines, guarentees they're in a GC\n # 4 lines if they're NOT in an FC, otherwise the 4th line is FC\n if lines.length < 4 || (lines.length == 4 && ! fc.empty?)\n return gc\n else\n # Make name of grand company the beginning of the line\n line = lines[3][25..-1]\n # Get the name on it's own\n line = line.split('/')\n gc = line[0]\n end\n end", "def get_grand_company(page)\n gc = nil\n lines = page.grep(/txt_name/)\n\n # checks to see if the optional free company line has been added\n fc = lines.grep(/a href=/)\n\n # GOOD CONDITIONS\n # 5 lines, guarentees they're in a GC\n # 4 lines if they're NOT in an FC, otherwise the 4th line is FC\n if lines.length < 4 || (lines.length == 4 && ! fc.empty?)\n return gc\n else\n # Make name of grand company the beginning of the line\n line = lines[3][25..-1]\n # Get the name on it's own\n line = line.split('/')\n gc = line[0]\n end\n end", "def parse_multiple_search_results(page)\n companies = []\n rows = page.body.split('<tr class=\\'alt')\n rows.shift\n rows.each do |row|\n company = {\n 'name' => '',\n 'id' => '',\n 'records' => ''\n }\n company['name'] = row.split('<a class=\\'nowrap\\' title=\\'')[1].split('\\' href=')[0]\n company['id'] = row.split('\\' href=\\'/id')[1].split('/')[0].to_i\n company['records'] = row.split('=showCompDir&\\'>')[1].split('</a>')[0]\n companies << company\n end\n return companies\nend", "def scrape_contacts; end", "def scrape_page(page, url)\n # clean up page so valid enough for Nokogiri to parse\n page.gsub!('<p />','</p><p>')\n page.sub!('<hr />','<p>')\n page.gsub!('<hr ','</p><hr ')\n doc = Nokogiri.HTML(page)\n doc.search('a[@href*=\"getHRGHTML\"]').each do |a|\n save_company_from_element(a.parent)\n end\nrescue Exception => e\n puts \"Exception (#{e.inspect}) raised while getting or parsing data (source url=#{url}). Data: #{page.to_s}\\n\\nBacktrace:\\n#{e.backtrace}\"\nend", "def scrape_page(page, url)\n # clean up page so valid enough for Nokogiri to parse\n page.gsub!('<p />','</p><p>')\n page.sub!('<hr />','<p>')\n page.gsub!('<hr ','</p><hr ')\n doc = Nokogiri.HTML(page)\n doc.search('a[@href*=\"getHRGHTML\"]').each do |a|\n save_company_from_element(a.parent)\n end\nrescue Exception => e\n puts \"Exception (#{e.inspect}) raised while getting or parsing data (source url=#{url}). Data: #{page.to_s}\\n\\nBacktrace:\\n#{e.backtrace}\"\nend", "def fetch_from_cuisineaz url\n if cuisineaz_host? url\n page = Nokogiri::HTML(open(url).read)\n @title = page.css('h1').text\n\n # get times\n @preptime = page.css('#ctl00_ContentPlaceHolder_LblRecetteTempsPrepa').text.to_i\n @cooktime = page.css('#ctl00_ContentPlaceHolder_LblRecetteTempsCuisson').text.to_i\n\n @steps = []\n page.css(\"#preparation p\").each { |step_node|\n @steps << sanitize(step_node.text)\n }\n\n @ingredients = []\n page.css(\"section.recipe_ingredients li\").each { |ing_node|\n @ingredients << sanitize(ing_node.text)\n }\n\n begin\n @image = page.css('#ctl00_ContentPlaceHolder_recipeImgLarge').attr('src').to_s\n rescue NoMethodError => e\n end\n\n else\n raise ArgumentError, \"Instantiation cancelled (ulr not from #{G750_HOST}).\"\n end\n end", "def get_Company(name=nil)\n\n getElement_text(\"cust_vendors\").click\n\n getElement_text(\"Customers\").click\n\n if(name!=nil)\n getElement_text_direct(name).click\n else\n getElement_text(\"company_name_data\").click\n end\n end", "def call_company_service\n ch_api = CompaniesHouseApi.new\n response = ch_api.company company_number\n parse_response response\n end", "def all_companies_information\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_company_info'])\n\t\t url_params = {}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend", "def get_city_list\r\n url = \r\n page = Nokogiri::HTML(URI.open('http://annuaire-des-mairies.com/val-d-oise.html'))\r\n citys = page.css('a.lientxt[href]').each {|city| @citys_list << city.text.downcase.gsub(' ', '-')}\r\nend", "def scrape\n end", "def parse_page_ccmc(url, agent, depth)\n hospital_name = \"Connecticut Children's Medical Center\".titleize\n base = \"http://www.connecticutchildrens.org/physicians/\"\n page = agent.get(url)\n if depth == 0\n items = page.search(\".letters-wrap .letter\")\n items[0..(items.length - 1)].each do |li|\n link = base + li.search(\"a\").first[\"href\"]\n parse_page_ccmc(link, agent, depth + 1)\n end\n else\n items = page.search(\".phys-search-content\")\n items[0..(items.length - 1)].each do |li|\n name = li.search(\"h2 a\").text.titleize\n spec = li.search(\".phsy-search-spec a\").first\n spec = spec.text.titleize unless spec.nil?\n print \"......Parsing #{name} #{spec}\"\n hospital = Hospital.find_by_name(hospital_name)\n hid = hospital.id.to_s\n provider = Provider.create(name: name, hospital_id: hid)\n pid = provider.id.to_s\n specialty = Specialty.create(name: spec, provider_id: pid)\n print \"...DONE\\n\"\n end\n print \"...DONE\\n\"\n end \nend", "def get_company_url_from_internet( name )\n url_friendly_name = make_url_friendly name\n api_url = \"http://api.bing.net/xml.aspx?AppId=65E209AA925DE92F7B6235CFD453A33BE4893A66&Version=2.2&Market=en-US&Query=#{url_friendly_name}&Sources=web+spell&Web.Count=1\"\n url = ''\n response = open(api_url)\n xml = response.read\n doc = REXML::Document.new xml\n if ( doc != nil )\n results = doc.elements.to_a(\"//web:WebResult/web:Url\")\n url = results[0]\n else\n url = \"nothing\"\n end\n if url != nil\n begin\n domain_name = Domainatrix.parse(url.text)\n url = \"#{domain_name.domain}.#{domain_name.public_suffix}\"\n if is_noise? name, url\n url = ''\n end\n rescue\n url = ''\n end\n else\n url = ''\n end\n return url\n end", "def scrap\n\t\turl = 'https://sg.carousell.com/search/products/?query=' + @input\n \tpage = @agent.get(url)\n\t\t@searchData = Nokogiri::HTML(page.body)\n\tend", "def city_list(url)\n\troot = Nokogiri::HTML(open(url))\n list = root.css(\"a\").map do |link|\n\n\t\t# This makes sure that we only store actual links, then stores the text & link for each valid link in an array.\n\n if link[:href] =~ /http/ \n [link.text, link[:href]] \n end \n end\n\n\t# This cleans up the array and gets rid of nil elements\n\n\tlist = list.reject {|x| x.nil?} \n\t\t\n\t## Here we have various sections of CL that we can search in for various gigs. \n\t## If you wanted to see more software development stuff, you may search in /sof and /eng\n\t\n\t\t\n\t# list.map! {|f,l| [f, l + \"/cpg/\"]}\n\t# list.map! {|f,l| [f, l + \"/web/\"]}\n\tlist.map! {|f,l| [f, l + \"/web/\", l + \"/cpg/\"]}\t\n\t# list.map! {|f,l| [f, l + \"/web/\", l + \"/cpg/\", l + \"/eng/\", l + \"/sof/\", l + \"/sad/\"]}\n\t\nend", "def get_crunchbase_info\n begin\n info = Crunchbase::Company.get(self.name)\n self.process_logo_upload = true\n self.website = info.homepage_url\n self.num_employees = info.number_of_employees\n self.public = info.ipo ? true : false\n self.description = info.overview.present? ? info.overview : info.description\n self.founded = info.founded\n self.total_money_raised = info.total_money_raised\n self.tags = info.tags\n self.remote_logo_url = \"http://crunchbase.com/#{info.image.first.flatten[-1]}\" if info.image\n self.competitors = info.competitions.map { |company| company[\"competitor\"][\"name\"] } if info.competitions\n rescue Exception => e\n logger.error \"Company #get_crunchbase_info error #{e}\"\n ensure\n self.save\n end\n end", "def pull_data\n\tmechanize = Mechanize.new\n\n\tpage = mechanize.get('http://workinstartups.com/job-board/jobs/interns/')\n\tpage.search(\"ul.job-list li\").each do |x|\n str = x.to_s\n job = Job.new\n\n job.company = str[/at\\s(.*?)\\sin/m, 1]\n job.url = URI.extract(str).first\n job.role = x.at_css('a').text\n\n job.save\n end\nend", "def cours\n\n\trequire 'nokogiri'\n\trequire 'open-uri'\n\n\tnam= []\n\txprice= []\n\thash_cours={}\n\n# Fetch and parse HTML document\n\tdoc = Nokogiri::HTML(open('https://coinmarketcap.com/all/views/all/'))\n\n\n\tdoc.search('td.no-wrap.currency-name > a').each do |link|\n \t\tnam << link.content\n\tend\n\n\n\n\tdoc.css('a[class=price]').each do |link|\n \t\txprice << link.content\n\tend\n\n\thash_cours=[nam.zip(xprice)]\n\nreturn hash_cours\nend", "def getCompanyURLs(relativeURL)\n\tdoc = Nokogiri::HTML(open(@baseURL + relativeURL))\n\treturn doc.css('div.left.company_info a:not([onclick])').map { |a| a['href'] }\nend", "def get_cuisine_recipe_page(url)\r\n @doc = Nokogiri::HTML(open(\"https://www.bbcgoodfood.com#{url}\"))\r\n end", "def get_all_info\n\t\tpage = fetch\n\t\tscrape(page)\n\tend", "def search_for_company(search, cookies)\n companies = []\n search = search.gsub(/ /, '+')\n searchpage = '/FreeTextSearch.xhtml?opCode=search&autoSuggested=true&freeText='\n result = request_page(\"#{searchpage}#{search}\", cookies)\n if result.body.include?('Contacts at this Company')\n id = result.body.split('id=\"companyGuid\" name=\"companyGuid\" value=\"')[1].split('\"')[0].to_i\n elsif result.body.include?('Contacts Search Results')\n return parse_multiple_search_results_employee(result)\n elsif result.body.include?('did not match any results')\n return nil\n elsif result['Location']\n id = result['Location'].split('/')[5].to_i\n else\n return parse_multiple_search_results(result)\n end\n return id\nend", "def scrape\n google_url = create_google_url\n google_data = Scrubyt::Extractor.define do\n fetch google_url\n\n link_title \"//a[@class='l']\", :write_text => true do\n link_url\n end\n end\n google_data.to_hash.map {|r| r[:link_url]}\n end", "def scrape(url)\n\t\n $log.info \"START #{__FILE__}.#{__method__}\"\n\t\n \n def initialize \n super ARGV[0],\"groupon\"\n end\n \n begin\n html = open(url)\n doc = Nokogiri::HTML(html.read)\n doc.encoding = \"utf-8\"\n $log.info \"Open url : #{url}\"\n\n $log.info \"Fetching from : #{url}\"\n \n title \t\t= doc.at_xpath($deal_config[$site_name][\"title\"])\n deal_url\t= URI.parse(url)\n price \t\t= doc.at_xpath($deal_config[$site_name][\"price\"])\n location \t= doc.at_xpath($deal_config[$site_name][\"location\"])\n sold \t\t= doc.at_xpath($deal_config[$site_name][\"sold\"])\n items\t\t= doc.at_xpath($deal_config[$site_name][\"items\"])\n category\t= doc.at_xpath($deal_config[$site_name][\"category\"])\n deal_thumb\t= doc.at_xpath($deal_config[$site_name][\"deal_thumb\"])['src']\n description = doc.at_xpath($deal_config[$site_name][\"description\"]) \n discount = doc.at_xpath($deal_config[$site_name][\"discount\"])\n expiry = doc.at_xpath($deal_config[$site_name][\"expiry\"])['value'] \n city = doc.at_xpath($deal_config[$site_name][\"location_city\"])\n\n # check if there is an imagemap\n # if so, insert latitude and longitude\n # else try geocoding\n image_map = doc.at_xpath($deal_config[$site_name][\"image_map\"])\n lat = nil\n long = nil\n if !image_map.nil? && image_map.to_s != \"\"\n uri = URI.parse(URI.encode(image_map['src']))\n uri_params = CGI.parse(uri.query)\n if !uri_params[\"center\"].nil?\n lat, long = uri_params[\"center\"][0].chomp.split(',')\n end\n \n else\n # geocode address\n loc=GeoKit::Geocoders::MultiGeocoder.geocode(location.content.to_s.strip) \n if !loc.success\n #if loc.lat.nil?\n lat = nil \n long = nil\n elsif loc.success\n lat = loc.lat\n long = loc.lng\n end\n end\n \t\t\n $arr_deals << Deal.new(title, deal_url, deal_thumb, price, location, sold, items, category, description, lat, long, discount)\n \n # set the following to site name\n $arr_deals[-1].author = $deal_config[$site_name][\"author\"]\n \n # specialized code for expiry\n time = Time.now + expiry.to_i/1000\n $arr_deals[-1].expiry = time.strftime(\"%Y-%m-%d %H:%M:%S\")\n \n # add city to location 20120328\n cit = city.content.to_s.strip\n $arr_deals[-1].location += \", #{cit}\"\n # puts $arr_deals[-1].location\n \n # print ...\n #\t\tputs \"#{$arr_deals[-1].title} \\n\"\n #\t\tputs \"#{$arr_deals[-1].price} \\n\"\n #\t\tputs \"#{$arr_deals[-1].sold} \\n\"\n # \tputs \"#{$arr_deals[-1].items} \\n\"\n #\t\tputs \"#{$arr_deals[-1].location} \\n\"\n #\t\tputs \"#{$arr_deals[-1].deal_url} \\n\"\n #\t\tputs \"#{$arr_deals[-1].deal_thumb} \\n\"\n #\t\tputs \"#{$arr_deals[-1].category} \\n\"\n #\t\tputs \"#{$arr_deals[-1].description} \\n\"\n #\t\tputs \"#{$arr_deals[-1].latitude} \\n\"\n #\t\tputs \"#{$arr_deals[-1].longitude} \\n\"\n #\t\tputs \"#{$arr_deals[-1].discount} \\n\"\n\n $insert_number += 1\n puts \"inserting deal #{$insert_number}...\"\n $db.insert_deal($arr_deals[-1])\n \n $log.info \"Successfully retrieved data : #{url}\"\n\n rescue Exception=>e\n\t\n print \"Could not retrieve values. Maybe the site has changed?\"\n $log.error e.to_s\n puts e.to_s\n\t\t\n end\n\t\n $log.info \"END #{__FILE__}.#{__method__}\"\n\t\n end", "def get()\n html = html_for(baseurl)\n scrape html, baseurl\n end", "def scrape_it\n \n end", "def scrape\n setup_capybara\n\n categories = []\n each_category do |name, href|\n categories << { name: name, url: href }\n end\n\n categories.map do |category|\n cat = Category.new(category[:name], [])\n each_course category[:url] do |name, type|\n cat.courses << Course.new(name, type)\n end\n cat\n end\n end", "def get_company(company_name)\n \n company_name_ = company_name.gsub(\" \", \"%20\")\n prepare_token\n \n api = 'https://api.linkedin.com/v1/company-search:(companies:(id,name,universal-name,website-url,industries,description,logo-url,employee-count-range,specialties,founded-year,locations))?count=20&keywords=' + company_name_\n \n @response = @access_token.get(api)\n \n puts @response.body\n \n companies = Hash.from_xml(@response.body)\n \n if companies[\"company_search\"][\"companies\"][\"total\"] == \"0\"\n return @response.body\n end\n \n companies[\"company_search\"][\"companies\"][\"company\"].each do |company|\n #find the right company\n if company[\"universal_name\"] == company_name.downcase || \n company[\"name\"].downcase == company_name.downcase ||\n company[\"universal_name\"] == company_name.downcase + \"-inc.\"\n \n if company[\"industries\"][\"total\"] == \"1\"\n in_id = company[\"industries\"][\"industry\"][\"code\"]\n else\n in_id = company[\"industries\"][\"industry\"][0][\"code\"]\n end\n id = Industry.find_by_code(in_id).id\n \n if company.has_key?(\"specialties\")\n company_specialties = company[\"specialties\"][\"specialty\"].to_s\n else\n company_specialties = nil\n end\n \n new_company = Company.new(name: company[\"name\"],\n description: company[\"description\"],\n website: url_with_protocol(company[\"website_url\"]),\n logo_url: company[\"logo_url\"],\n tags: company_specialties,\n industry_id: id,\n employee_count_range: company[\"employee_count_range\"][\"name\"],\n founded_year: company[\"founded_year\"])\n new_company.logo_from_url company[\"logo_url\"] \n new_company.save\n return new_company\n end \n end\n \n #Not found\n puts \"Company Not Found\"\n return @response.body\n \n end", "def scrape_page_head(url)\n i=0\n html = open(url)\n # binding.pry\n playerindex = Nokogiri::HTML(html)\n\n # initialize array of player info hashes\n playhasharr = []\n\n # sxcrape to get all the player information headline-blocks (player name, position, school/club)\n pheadarr=playerindex.css (\"div.component.headline-block\")\n\n # put the name, position, school/club, year elements into a hash, then put the hash into an array\n pheadarr.each do |phrow|\n playhashrow={}\n # create playhashrow -- a hash for name, position, school/club, year\n\n # Get the name from div.head (div tag, class=head). The split(\",\").first is to remove a comma\n # in the last name on the list\n playhashrow[:name]=(phrow.css(\"div.text-block div.head\").text).split(\",\").first\n\n # schoolclub variable here actually is \"position|schoolclub, year\"\n schoolclub=phrow.css(\"div.text-block div.subhead\").text\n # get the player's position here in the first part of schoolclub (originally named split1)\n playhashrow[:position]=schoolclub.split(\",\").first\n # split1=prevexp.split(\",\").last.split(\"|\").first\n\n # Get the school / club name from the headline block\n playhashrow[:schoolclub]=schoolclub.split(\",\").last.split(\"|\").first.strip\n # Get the class year\n class_year = schoolclub.split(\",\").last.split(\"|\").last.strip\n # The way that the schoolclub variabkle\n if class_year !=playhashrow[:schoolclub]\n playhashrow[:class_year]=class_year\n\n end\n # put the current rank into the player hash (to avoid having to search later)\n playhashrow[:rank]=i+1\n # binding.pry\n playhasharr << playhashrow\n # puts (\"number #{i+1}\")\n i+=1\n end\n\n playhasharr\n end", "def scrape()\n scrapeForCurrentData\n end", "def crawl\n recursive_explore([@origin_url],1)\n end", "def index\n @page_id = 'companyList'\n @banners = Banner.companies.where('start_at <= ? and end_at >= ?', Time.now, Time.now).where(:language => params[:locale] == 'en' ? [0, 1] : [0, 2])\n @company_classifies = CompanyClassify.design\n @companies = params[:company_classify_id].present? ? Company.joins(:company_classify_relations).where('company_classify_relations.company_classify_id = ?', params[:company_classify_id]).design.allow.human_order : Company.design.allow.human_order\n end", "def crawl\n $list.regions.each do |r|\n url = \"http://\" << r.name << :query\n puts r.name\n peel(url)\n end\n end", "def scrape_table(page)\n rows = Nokogiri.HTML(page).css('#ContentPlaceMain_SearchResultsGridView tr')[1..-1]\n if rows.nil?\n puts \"No data found\"\n return true\n elsif rows.size == 300\n puts \"***Too many rows to show on one page. Need to refine prefix\"\n return\n end\n puts \"Found #{rows.size} companies\"\n\n rows.each do |row|\n begin\n record = {}\n company_number_link = row.at('td a') || row.at('td')\n record['CompanyNumber'] = company_number_link.inner_text.strip\n record['CompanyName'] = row.css('td')[2].inner_text.strip\n record['EntityType'] = row.css('td')[1].inner_text.strip\n record['RegistryUrl'] = \"https://www.jerseyfsc.org/registry/documentsearch/NameDetail.aspx?id=\" + company_number_link[:href].scan(/showDetail\\(\\'(\\d+)/).flatten.first.to_s rescue nil\n record['date_scraped'] = Time.now\n next unless COMPANY_TYPES.include?(record['EntityType'])\n # beginning_time = Time.now\n ScraperWiki.save([\"CompanyNumber\"], record)\n # puts \"Time elapsed #{(Time.now - beginning_time)*1000} milliseconds\"\n rescue Exception => e\n puts \"Exception raised while extracting data from row html: #{e.inspect}, #{row.to_html}\"\n end\n end\nrescue Exception => e\n puts \"Exception raised while parsing data: #{e.inspect}, #{e.backtrace}\"\nend", "def scrape_table(page)\n rows = Nokogiri.HTML(page).css('#ContentPlaceMain_SearchResultsGridView tr')[1..-1]\n if rows.nil?\n puts \"No data found\"\n return true\n elsif rows.size == 300\n puts \"***Too many rows to show on one page. Need to refine prefix\"\n return\n end\n puts \"Found #{rows.size} companies\"\n\n rows.each do |row|\n begin\n record = {}\n company_number_link = row.at('td a') || row.at('td')\n record['CompanyNumber'] = company_number_link.inner_text.strip\n record['CompanyName'] = row.css('td')[2].inner_text.strip\n record['EntityType'] = row.css('td')[1].inner_text.strip\n record['RegistryUrl'] = \"https://www.jerseyfsc.org/registry/documentsearch/NameDetail.aspx?id=\" + company_number_link[:href].scan(/showDetail\\(\\'(\\d+)/).flatten.first.to_s rescue nil\n record['date_scraped'] = Time.now\n next unless COMPANY_TYPES.include?(record['EntityType'])\n # beginning_time = Time.now\n ScraperWiki.save([\"CompanyNumber\"], record)\n # puts \"Time elapsed #{(Time.now - beginning_time)*1000} milliseconds\"\n rescue Exception => e\n puts \"Exception raised while extracting data from row html: #{e.inspect}, #{row.to_html}\"\n end\n end\nrescue Exception => e\n puts \"Exception raised while parsing data: #{e.inspect}, #{e.backtrace}\"\nend", "def get_city_names(url)\n doc = Nokogiri::HTML(URI.open(url))\n href = doc.css('.col-lg-offset-1')\n text = href.text.split\n return text[0]\n end", "def detail_page_scrape(cs, url, new_model)\n be_nice # wait time between page loads\n\n raw = RestClient::Request.execute(url: url, method: :get, verify_ssl: false)\n\n html = Nokogiri::HTML(raw.squish)\n\n # this page is itself a child, so its children are grandchildren\n # for each grandchild, update the model with the value\n cs.children.each do |gcs|\n element = html.css(gcs.selector).first\n\n handle_element(gcs, element, new_model)\n end\n end", "def search_company(name = \"\", limit = 50)\n\t\[email protected]_company(name, limit)\n\tend", "def company_name\n self.dig_for_string(\"agentSummary\", \"office\", \"companyName\")\n end", "def scrape_table(page_body)\n data_table = Nokogiri::HTML(page_body).css('table#WFDGRDCompanies tr.resultsGridBody').collect do |row|\n record = {}\n record['CompanyNumber'] = row.css('td')[0].inner_text.strip\n record['CompanyName'] = row.css('td')[1].inner_text.strip\n record['Status'] = row.css('td')[2].inner_text.strip\n record['EntityType'] = row.css('td')[3].inner_text.strip\n record['NameType'] = row.css('td')[4].inner_text.strip\n record['date_scraped'] = Time.now\n next if ['NameType'] == 'PREVIOUS' #these have the same company numbers as 'CURRENT' ones, and so would over-write them. Previous name details are avail on the company page, so we can discard this info\n begin\n ScraperWiki.save([\"CompanyNumber\"], record)\n rescue Exception=>e\n puts \"Exception (#{e.inspect}) raised saving company record:#{record.inspect}\"\n end\n end\nend", "def scrape_table(page_body)\n data_table = Nokogiri::HTML(page_body).css('table#WFDGRDCompanies tr.resultsGridBody').collect do |row|\n record = {}\n record['CompanyNumber'] = row.css('td')[0].inner_text.strip\n record['CompanyName'] = row.css('td')[1].inner_text.strip\n record['Status'] = row.css('td')[2].inner_text.strip\n record['EntityType'] = row.css('td')[3].inner_text.strip\n record['NameType'] = row.css('td')[4].inner_text.strip\n record['date_scraped'] = Time.now\n next if ['NameType'] == 'PREVIOUS' #these have the same company numbers as 'CURRENT' ones, and so would over-write them. Previous name details are avail on the company page, so we can discard this info\n begin\n ScraperWiki.save([\"CompanyNumber\"], record)\n rescue Exception=>e\n puts \"Exception (#{e.inspect}) raised saving company record:#{record.inspect}\"\n end\n end\nend", "def company_search(options = {})\n path = \"/company-search:(companies:(id,name,universal-name,website-url,logo-url,square_logo_url))?keywords=#{CGI.escape(options[:keyword])}&sort=relevance\"\n # binding.pry\n results = get(path, options)\n # binding.pry\n end", "def scrape_course_ucas_urls\n @all_providers.each do |provider|\n id = provider[:id]\n page_url = \"https://digital.ucas.com/search/results?SearchText=foundation+year&SubjectText=&SubjectText=&ProviderText=&ProviderText=&AutoSuggestType=&SearchType=&SortOrder=ProviderAtoZ&PreviouslyAppliedFilters=QM_0_Bachelor+degrees+(with+or+without+Honours)__&AcademicYearId=2019&ClearingOptOut=False&vacancy-rb=rba&filters=Destination_Undergraduate&filters=QualificationMapped_Bachelor+degrees+(with+or+without+Honours)&filters=QualificationMapped_Masters+degrees&UcasTariffPointsMin=0&UcasTariffPointsMax=144%2b&DistanceFromPostcode=1mi&RegionDistancePostcode=&CurrentView=Provider&__RequestVerificationToken=I4o0CAJi6qu_cPwc_8yGJYYEB1xPNnzrUoNUP14zJG-pDp-DXp9nZbEb4DJxWqCkT6XyZhsyCaovoLeFlQX24enN3zaLRVkgfvT87YXQsOY1&pageNumber=3&GroupByProviderId=#{id}&GroupByDestination=Undergraduate&GroupByFrom=0&GroupBySize=5000\"\n unparsed_page = HTTParty.get(page_url)\n parsed_page = Nokogiri::HTML(unparsed_page)\n tables = parsed_page.css('table.open')\n table_titles = tables.css('tr[1] > th').text\n table_text = tables.css('tr > td').text\n raw_name = tables.css('tr > th').text\n page_courses = parsed_page.css('a.course-summary')\n page_courses.each do |page_course|\n provider[:courses] << @base_url + page_course.attributes[\"href\"].value\n end\n end\n end", "def linkReturn(url)\n data = Nokogiri::HTML(open(url))\n links = data.css('div.case')\n allUrl = links.css('h3 a').map { |var| var['href'] }\n allUrl.each do |i|\n puts scraper(i)\n puts ''\n puts i\n end\nend", "def company_information\n @response = CompanyApi::Request::Setting.new(\n CompanyApi::Response::Formatter::Manager,\n request.cookies,\n {\"User-Agent\" => http_user_agent}\n ).company_information({})\n\n unless @response.success?\n return handle_temporary_redirects(@response)\n end\n\n @presenter_obj = ::WebPresenter::ManagerPresenter.new(@response, params)\n end", "def scrap\n\t\tdef get_townhall_email(townhall_url)\n\t\t\tpage = Nokogiri::HTML(open(townhall_url))\n\t\t\temail = page.xpath('/html/body/div/main/section[2]/div/table/tbody/tr[4]/td[2]').text\n\n\t\t\tif email.size < 1\n\t\t\t\temail = \"nill\"\n\t\t\tend\n\t\t\treturn email\n\t\tend\n\n\t\tdef get_townhall_urls\n\t\t\ti = 0\n\t\t\tpage = Nokogiri::HTML(open('http://annuaire-des-mairies.com/val-d-oise.html'))\n\t\t\tarray_ville = []\n\t\t\tarray_mail = []\n\t\t\thachier = {}\n\t\t\tarray = []\n\t\t\tville = page.xpath('//a[@class=\"lientxt\"]')\n\n\t\t\tville.each do |a|\n\t\t \tarray_ville[i] = a['href'][1..-1]\n\t\t \tarray_mail = get_townhall_email(\"http://annuaire-des-mairies.com#{array_ville[i].downcase}\")\n\t\t \thachier = {}\n\t\t \thachier[a.text] = array_mail\n\t\t \tarray[i] = hachier\n\t\t \ti = i + 1\n\t\t \tputs hachier\n\t\t end\n\t\t return array\n\t\tend\n\t\treturn get_townhall_urls\n\tend", "def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend", "def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend", "def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend", "def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend", "def get_cricket_list(cnl)\n regex_rin = /\\b[a-z]\\d+[-]\\w+[-]\\d+\\b/ # a01-rin-75\n regex_dms_id = /\\b[A-Z]{3}-[-\\w\\d]+\\W\\B/ # CAS-I02 or CAS-A02-0\n regex_ip = /\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/ # 10.211.161.69\n regex_model = /\\b[M,Z][a-z]+\\b/ # Milegate or Zhone\n\n # MSAN list page for the current CNL\n url = \"http://10.200.1.135/static/dslams/#{cnl.to_s.upcase}/\"\n\n result = []\n\n # Loads Cricket page\n begin\n page = Mechanize.new.get(url)\n\n # Iterates over each TR html tag in the page, scrapping RIN, DMS_ID, IP and DSLAM model to the bean\n page.search('tr').each do |tr|\n data = tr.inner_text\n next if data.scan(regex_ip).length <= 0\n result << { model: data.scan(regex_model)[0].to_s,\n dms_id: data.scan(regex_dms_id)[0].to_s.strip!,\n rin: data.scan(regex_rin)[0],\n ip: data.scan(regex_ip)[0] }\n end\n end\n\n result\n end", "def scrape_course_credits(parsed_html)\n if (parsed_html.css('div.credits')[0])\n parsed_html.css('div.credits')[0].children.text.strip\n else\n parsed_html.css('div#credits')[0].children.text.strip\n end\n end", "def scrape(name, query_param = \"\")\n sleep(1)\n Net::HTTP::Get.new(\"/biz/#{name}#{query_param}\", {\"User-Agent\" => \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36\"})\nend", "def scrape\n\n\t\tcustomer_api = Bigcommerce::Customer\n\t\tcustomer_count = customer_api.count.count\n\n\t\t#Bigcommerce api gives 50 items at once\n\t\tlimit = 50\n\t\tcustomer_pages = (customer_count/limit) + 1\n\n\t\tpage_number = 1\n\n\t\t# Loop through pages - each with 50 items\n\t\tcustomer_pages.times do \n\n\t\t\tcustomers = customer_api.all(page: page_number)\n\n\t\t\tcustomers.each do |c|\n\n\t\t\t\tinsert_sql(c, 1)\n\t\t\t\t\n\t\t\tend\n\n\t\t\tpage_number += 1\n\t\tend\n\n\tend", "def scrape_campaigns\n # Initialize crawler\n more_campaigns = true\n campaign_page = 0\n transalt_campaigns = []\n\n puts \"Scraping campaigns...\"\n # Collect all campaigns\n while more_campaigns do\n puts \"Scraping ?page=#{campaign_page}\"\n scraper = CampaignCrawler.new(campaign_page)\n output = scraper.crawl\n\n transalt_campaigns = transalt_campaigns + output['campaigns']\n\n output['campaigns'].empty? ? (more_campaigns = false) : campaign_page +=1\n end\n\n puts \"Scraped #{campaign_page} pages\\n\\n\"\n\n transalt_campaigns\n end", "def job_data\n fetch_data('https://www.themuse.com/api/public/jobs?&category=Engineering&category=Project+%26+Product+Management&level=Mid+Level&level=Entry+Level&location=Boston%2C+MA&location=New+York%2C+NY&location=San+Francisco%2C+CA&page=1&descending=true')[\"results\"]\nend", "def index\n if params[:company_type]\n @search = @community.companies.where(:company_type => params[:company_type]).search(params[:q])\n else\n @search = @community.companies.search(params[:q])\n end\n @companies = @search.result\n\n @tab_name = \"companies\"\n @page_title = \"Companies\"\n @page_subtitle = \"Loyal Businesses\"\n @page_description = \"\"\n\n add_breadcrumb \"Companies\", companies_path, :title => \"#{@community.name} Companies\"\n end", "def company_information(params)\n get('company-information',params)\n end", "def crypto_scrapper ()\r\n url = \"https://coinmarketcap.com/all/views/all/\"\r\n page_inspect = URI.open(url)\r\n page_inspected = Nokogiri::HTML(page_inspect)\r\n page_inspected.xpath('//a[contains(@href, \"/currencies\")]').each do |crypto|\r\n \r\n crypto = crypto.text\r\n B << crypto\r\n end\r\n #puts B.to_s\r\nend", "def crawler_page\n open(crawler_url)\n end", "def contract_urls\n Scrapers::ContractUrlExtractor.new(report.url).urls\n end", "def get_contractor_data\n @hash_contractor = {}\n @hash_contractor[:name] = @driver.find_element(:css, '.oH1Huge').text\n @hash_contractor[:job] = @driver.find_element(:css, '.oH2High').text\n @hash_contractor[:description] = @driver.find_element(:css, 'p.notranslate[itemprop=\"description\"]').text.gsub(/\\n+/, ' ')\n @hash_contractor[:skills] = @driver.find_element(:css, '.oExpandableOneLine.oSkills.oExpanded').text.gsub(' less', '')\n @hash_contractor[:hourly_rate] = @driver.find_element(:css, '.oCoinsIcon+.oTxtExtra.ib').text\n @hash_contractor[:rating] = @driver.find_element(:css, '.oStarIcon+.oTxtExtra.ib').text\n @hash_contractor[:hours] = @driver.find_element(:css, '.oClockIcon+.oTxtExtra.ib').text.gsub(',', '')\n @hash_contractor[:location] = @driver.find_element(:css, '.oTxtLrge.ib').text.downcase\n @hash_contractor[:url] = @driver.current_url\n end", "def parse_companies_house_response(response)\n @company_name = response['company_name']\n @company_number = response['company_number']\n parse_registered_office_address(response['registered_office_address'])\n # may have empty address line 1 e.g. boots so default it to company name\n # As code assumes address has address line 1 including back office\n @address_line1 = @company_name if @address_line1.blank?\n # this doesn't return anything\n nil\n end", "def Scrap(search)\n short_name = search.gsub(/\\./, ' ')\n short_name.gsub!(/ (DVDRip|LiMiTED|REPACK|720p|FRENCH|UNRATED|iNTERNAL|TRUEFRENCH).*$/, '')\n \n DataLoadFromSite(short_name)\n end", "def main\n api = with_curl\n puts api.map { |api| api.slice 'html_url', 'full_name' }\nend", "def fetch_from_g750 url\n if g750_host? url\n page = Nokogiri::HTML(open(url).read)\n @title = page.css('h1.c-article__title').text\n\n # get times\n @preptime = sanitize(page.css('ul.c-recipe-summary > li.c-recipe-summary__rating[title=\"Temps de préparation\"]').text).to_i\n @cooktime = sanitize(page.css('ul.c-recipe-summary > li.c-recipe-summary__rating[title=\"Temps de cuisson\"]').text).to_i\n\n @steps = []\n css_step = \"div[itemprop=recipeInstructions] p\"\n @steps = page.css(css_step).text.split /[( ),(<br>)]/\n\n @ingredients = []\n css_ingredient = \"div.c-recipe-ingredients ul.c-recipe-ingredients__list li.ingredient\"\n page.css(css_ingredient).each { |ing_node|\n @ingredients << sanitize(ing_node.text)\n }\n\n # get image\n css_image = 'div.swiper-wrapper img.photo'\n begin\n @image = page.css(css_image).attr('src').to_s\n rescue NoMethodError => e\n end\n\n else\n raise ArgumentError, \"Instantiation cancelled (ulr not from #{G750_HOST}).\"\n end\n end", "def scrape_custom(shop)\n p \"custom\"\n case shop[:name]\n when \"Ethical Kidz\"\n @string = \"/#{shop[:page_string]}\"\n end\n\n while shop[:incomplete]\n\n fields = shop[:subcategories] ? shop[:slugs] : [\"\"]\n \n fields.each do |slug|\n\n shop[:url] = \"#{shop[:initial_url]}#{slug}#{@string}\" \n \n p \"Trying #{shop[:url]}\"\n\n $html = Nokogiri::HTML(open(shop[:url]))\n \n @data={}\n $html.css($shop_css[:product_css]).each_with_index do |product,index|\n begin\n puts index\n @data = get_data_from_product(shop,product)\n shop[:results][:data] << @data\n p @data\n \n rescue StandardError => e\n # p \"Problem = #{@problem}\" unless @problem.empty?\n p @data\n raise e\n \n end\n \n end\n end\n shop[:incomplete] = false\n end\n \n shop[:results][:data].flatten.uniq\n shop\nend", "def flightglobal \n fg_output= {}\n source = \"Flightglobal\"\n url = \"https://www.flightglobal.com/searchresults?qkeyword=&PageSize=10&parametrics=WVPUBDATE%7C%5BNOW-1DAY%20TO%20NOW%5D&SortOrder=2\"\n page = Nokogiri::HTML(open(url))\n\n elements = page.css(\"li\").each_with_index {|line, index|\n title = line.css(\"h3\").text\n paragraph = line.css(\"p\").text\n date = paragraph.slice(0,10)\n description = paragraph[20..]\n link = line.css(\"h3>a>@href\").text\n #puts title\n #puts link\n if title.length > 2\n fg_output[index] = {\n :title => title,\n :description => description,\n :link => link,\n :source => source\n }\n end\n }\n fg_output\nend", "def scrap_data\n\turl_array = get_townhall_urls \n url_array.each do |townhall_url| \n# -> Pour chaque URL d'une ville du Val d'Oise, on associe l'adresse mail de la mairie\n\t\tget_townhall_email(townhall_url)\n\tend\nend", "def pull_company(cfpb, iex)\n # Start with CFPB because it is way more brittle\n complaint = CFPBService.search_complaints cfpb\n stock = IEXService.search_stocks iex\n\n {\n cfpb_complaint_count: complaint[:complaint_count],\n cfpb_random_complaint: complaint[:comment],\n iex: stock\n }\n end", "def scrape_cfp_list(category)\n category_encoded = category.sub(' ','%20')\n content = ''\n page = 1\n\n until (content =~ /Expired/)\n uri = \"http://www.wikicfp.com/cfp/call?conference=#{category_encoded}&page=#{page}\"\n body = (Nokogiri::HTML(open(uri))).to_s\n \n content << body\n page += 1\n end\n\n content = content.split(/Expired/).first\n return content\nend", "def gather_credit_info\r\n credit_accounts = @page.css(\"table[id='dashboardAccounts'] tr[id]\")\r\n @ca_index = 1\r\n while @ca_index <= credit_accounts.count do\r\n #account_name = @page.css(\"#dashboardAccounts td.ng-scope.icon-two-line-col > div > div > a > span\").text\r\n account_name = @page.search(\"#dashStep1 tr:nth-of-type(#{@ca_index}) td:nth-of-type(1) span\").text\r\n account_available_balance = @page.css(\"#dashStep1 tr:nth-of-type(#{@ca_index}) td:nth-of-type(3) span\").text\r\n account_currency = @page.css(\"#dashStep1 tr:nth-of-type(#{@ca_index}) td:nth-of-type(2) span\").text\r\n ca = Accounts.new(account_name, account_available_balance, account_currency,\"Credit\")\r\n @available_accounts << ca\r\n @ca_index += 1\r\n end\r\n end", "def index\n @companies = Company.page(params[:page])\n @log = ParsingLog.running_parser\n\n render partial: \"companies_list\" if request.xhr? \n end", "def show\n @companies = current_user.companies.all.order(:ticker)\n @comments = @company.comments.all.order('created_at DESC')\n @comment = Comment.new\n\n require 'finnhub_ruby'\n\n FinnhubRuby.configure do |config|\n config.api_key['token'] = ENV['finhub_api']\n end\n \n finnhub_client = FinnhubRuby::DefaultApi.new\n\n ticker = @company.ticker\n @price = finnhub_client.quote(ticker).c\n @name = finnhub_client.company_profile2({symbol: ticker}).name\n end", "def scrape_category(url)\n begin\n doc = Nokogiri::HTML(open(url))\n category = doc.css(\"div.fabric h2\").first\n return category.content unless category.nil?\n rescue Exception => ex\n puts ex\n end\nend", "def get_cities_names\n name_of_cities = []\n\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n doc.xpath('//p/a').each do |town|\n name_of_cities << town.text\n end\n\n name_of_cities\nend", "def company\n @company ||= research_param(:company) || company_list.first\n end", "def get_the_name_of_val_doise_townhalls(url)\n page = Nokogiri::HTML(open(url))\n commune = []\n news_links = page.css(\"a\").select{|link| link['class'] == \"lientxt\"}\n news_links.each do |communes|\n commune << communes.text\n end\n return commune\nend", "def company_name\n element_with_value('CompanyName', opts[:company_name][0..34])\n end", "def get_product_info url\n product_info = nil\n \n mech_agent = Mechanize.new { |agent|\n agent.log = Logger.new \"/Users/simon/a_syllabus/lang/ruby/scripts/z_data/mechanize/mechanize.log\"\n agent.history.clear\n agent.redirect_ok = true \n agent.follow_meta_refresh = true\n agent.keep_alive = true\n agent.open_timeout = 30\n agent.read_timeout = 30 \n # pp Mechanize::AGENT_ALIASES # show list of agents - no mac chrome!\n agent.user_agent_alias = 'Mac Safari'\n }\n \n mech_agent.get(url) # get page\n \n @product_page = mech_agent.page\n \n pp @product_page\n \n supplier_regex = [ \n /(sainsburys)/,\n /(morrisons)/,\n /(tesco)/,\n /(waitrose)/,\n /(coop)/,\n /(asda)/,\n /(ocado)/,\n /(booker)/,\n /(fatsecret)/\n ]\n \n \n match = nil\n \n supplier_regex.each{ |regex| \n url =~ regex\n \n match = $1\n \n break if $1 \n }\n \n \n # SAVE page for inspection\n local_copy_location = '/Users/simon/a_syllabus/lang/ruby/scripts/z_data/mechanize'\n \n retireved_page_name = \"retievd_page_from_#{match}.html\"\n \n File.open( File.join(local_copy_location,retireved_page_name ), 'w') { |file| file << @product_page.body }\n # file automatically closed by block\n \n \n case match\n \n when 'sainsburys'\n product_info = scrape_sainsburys\n \n when 'morrisons'\n product_info = scrape_morrisons\n \n when 'tesco'\n product_info = scrape_tesco\n \n when 'waitrose'\n product_info = scrape_waitrose\n \n when 'coop'\n product_info = scrape_coop\n \n when 'asda'\n product_info = scrape_asda\n \n when 'ocado'\n product_info = scrape_ocado\n \n when 'booker'\n product_info = scrape_booker\n \n when 'fatsecret'\n product_info = scrape_fatsecret\n \n when nil\n product_info = scrape_specialist\n \n end\n \n product_info\n end", "def jira_search\n\n @lunch_special = SlackJIRABot.new\n doc = Nokogiri::HTML(open('http://www.truetastes.com/anitas-cafe-lunch-catering/'))\n\n ####\n # Search for nodes by css\n\n if(doc)\n doc.css('div.specials_copy').each do |specials|\n @lunch_special.html_content = specials.inner_html\n @lunch_special.text_content = specials.content\n end\n end\n\n return @lunch_special\n\nend", "def get_companies \n \n prepare_token\n \n #Use the access token to make an authenticated API call\n #api = 'https://api.linkedin.com/v1/companies/1337:(id,name,universal-name,website-url,industries,description,logo-url,employee-count-range)'\n api = 'https://api.linkedin.com/v1/company-search:(facets:(code,buckets:(code,name,count)),companies:(id,name,universal-name,website-url,industries,description,logo-url,employee-count-range,locations:(address:(region-code))))?facets=location,industry&facet=location,us:84&facet=industry,6&count=300&start=20'\n #api = 'https://api.linkedin.com/v1/companies/1337:(id,name,ticker,description)'\n @response = @access_token.get(api)\n \n #Print body of response to command line window\n puts @response.body\n \n \n hashs = Hash.from_xml(@response.body)\n \n \n \n hashs[\"company_search\"][\"companies\"][\"company\"].each do |hash|\n \n \n \n #hash = Hash.from_xml(@response.body)\n if hash[\"industries\"][\"total\"] == \"1\"\n in_id = hash[\"industries\"][\"industry\"][\"code\"]\n else\n in_id = hash[\"industries\"][\"industry\"][0][\"code\"]\n end\n id = Industry.find_by_code(in_id).id\n \n company = Company.new(name: hash[\"name\"],\n description: hash[\"description\"],\n website: hash[\"website_url\"],\n logo_url: hash[\"logo_url\"],\n industry_id: id,\n employee_count_range: hash[\"employee_count_range\"][\"name\"])\n company.logo_from_url hash[\"logo_url\"] \n company.save\n \n end\n \n # Handle HTTP responses\n case @response\n when Net::HTTPUnauthorized\n # Handle 401 Unauthorized response\n when Net::HTTPForbidden\n # Handle 403 Forbidden response\n end\n end", "def list_climbs\n\tsporturl = \"https://www.mountainproject.com/area/classics?type=sport\"\n\t@list = ClassicClimbs::Climb.all\n\tif @list.empty? == true\n\tClassicClimbs::Scraper.scrape_sportclimbs(sporturl)\n\tClassicClimbs::Climb.create_climb(ClassicClimbs::Scraper.all)\n\[email protected]_index(1) do |item, index|\n\t\tputs(\"#{index}. #{item.name} - #{item.grade}\")\n\tend\n\telse\n\t\t# avoid crawling again if it's been crawled the first time\n\t\[email protected]_index(1) do |item, index|\n\t\tputs(\"#{index}. #{item.name} - #{item.grade}\")\n\tend\nend\n\tself.sub_menu\n\tend", "def get_search_result(sbi_url)\n return `curl -L -A #{K_User_Agent} #{sbi_url}` \nend", "def start_scraping(page_limit, output_file_path)\n\n # add header in csv file before loop starts\n CSV.open(output_file_path, 'w') do |csv|\n csv << ['Artist Name', 'City', 'Venue', 'Date', 'Time', 'Ticket Price']\n end\n\n # loop for retrieving data for pages upto page_limit\n page_no = 1\n loop do\n url = \"http://www.wegottickets.com/searchresults/page/#{page_no}/all#paginate\"\n parse_page = self.parse_data(url)\n \n puts \"Processing url:\", url\n\n concert_div_arr = parse_page.css('.content.block-group.chatterbox-margin')\n if concert_div_arr.length == 0 # no concert elements are found\n break\n end\n concert_details_array = self.extract_concert_details_data(concert_div_arr)\n\n self.store_concert_details_data(concert_details_array, output_file_path)\n \n # add up pagginations results\n if page_no >= page_limit && page_limit != -1 \n break\n end\n page_no = page_no + 1\n end\n end", "def company\n @company ||= Harvest::API::Company.new(credentials)\n end", "def company; end", "def company; end", "def fetch_drink_page(name, url, size, milk)\n doc = Hpricot Curl::Easy.http_get(url).body_str\n key = nil\n data = {}\n\n (doc.at('#nutrition')/:td).each do|td|\n value = td.inner_text.gsub(/\\(.*\\)/,'').strip\n if key.nil?\n key = value\n else\n data[CaribouToDB[key]] = value if CaribouToDB.key?(key)\n key = nil\n end\n end\n data[:name] = ((doc.at(\"#content h1\").inner_text) || name).cleanstr\n data[:size] = size\n data[:milk] = milk\n data\nend", "def scrap(item)\n items = []\n html_file = open(\"https://www.etsy.com/fr/search/clothing?q=#{item}\")\n html_doc = Nokogiri::HTML(html_file)\n html_doc.search('.card-meta').each do |title|\n item_name = title.search(\".card-title\")[0].text.strip\n item_price = title.search(\".currency\")[0].text.to_f\n items << {name: item_name, price: item_price}\n end\n return items.first(10)\nend", "def get_all_the_urls_of_val_doise_townhalls (web_list)\npage = Nokogiri::HTML(RestClient.get(web_list))#recupere le code html du site\npage.css(\"a.lientxt\").each do |note|\nnote['href'] = note['href'][1..-1]#donne les urls de chaque commune en retirant le premier caractaire c-a-d \".\"\nweb_page = \"http://annuaire-des-mairies.com\" + note['href']\nputs web_page\nget_the_email_of_a_townhal_from_its_webpage(web_page)#rappel la fonction get_the_email_of_a_townhal_from_its_webpage pour recuperer les adresses emails grace aux liens (fonctions recurssive)\nend\nend", "def get_coupons\n @rewards_source = async_response(\"https://m.cvs.com/mt/www.cvs.com/extracare/landing.jsp\")[:body]\n if $debug\n puts @rewards_source\n exit\n end\n @deals_array = Array.new\n rewards = @rewards_source.scan(/<div class=\"un_exEntry\">\\n.+\\>(.+)\\<.div><.div.+$\\n.+\\>(.+)\\<.div.+$\\n.+\\>(.+)\\<.div.+$\\n.+$/)\n rewards.each do |deal|\n name = deal[0]\n due_date = deal[1]\n note = deal[2]\n # defer_date = deal[3]\n @deals_array.push({name: name,due_date: parse_date(due_date), defer_date: Time.now, note: note})\n end\n @deals_array\n end" ]
[ "0.7220884", "0.71377754", "0.6646778", "0.6604847", "0.6593254", "0.64999235", "0.64590096", "0.64050984", "0.64050984", "0.62870485", "0.628092", "0.624683", "0.624683", "0.62284976", "0.60694", "0.6059287", "0.6037628", "0.6007892", "0.6000365", "0.6000208", "0.5956205", "0.5953594", "0.5943082", "0.5926327", "0.5913198", "0.590913", "0.59052736", "0.58671224", "0.5844943", "0.5831699", "0.5799535", "0.5797148", "0.5794436", "0.57915777", "0.5782089", "0.5775895", "0.5723027", "0.5718447", "0.5711607", "0.5697209", "0.56942385", "0.56933385", "0.56933385", "0.56928575", "0.5683408", "0.5676338", "0.56762666", "0.5675817", "0.5675817", "0.56645113", "0.5660848", "0.5657694", "0.5647412", "0.5643084", "0.56372136", "0.56372136", "0.56372136", "0.56372136", "0.5634637", "0.5632259", "0.56271297", "0.5612032", "0.5603675", "0.5599074", "0.5597021", "0.5592455", "0.5591981", "0.5590218", "0.5588918", "0.55878407", "0.55732435", "0.5572352", "0.5571231", "0.5568173", "0.55428714", "0.5540775", "0.55365515", "0.552431", "0.55222344", "0.55205965", "0.55100834", "0.5508053", "0.549825", "0.54927254", "0.54908323", "0.548974", "0.54882914", "0.54866713", "0.5482015", "0.5481134", "0.54796916", "0.54774547", "0.5476433", "0.54758173", "0.5468181", "0.5468181", "0.5467631", "0.5452694", "0.5452535", "0.5451972" ]
0.54608136
97
Process a raw line and return the synthesized symbol of the truth record Sample: "5352 Recv 15:03:55.362.0 0x000001ae DataFrame StdFrame 0x08 1a3a000000000000" "9983\tRecv\t15:04:10.061.0\t0x1824f401\tDataFrame\t ExtFrame\t0x08\t004a004b004a0000 \r\n"
def preprocess_truth_line(text) matches = text.match(/^\d+[\t|\s]+Recv[\t|\s]+.{14}[\t|\s]+0x([\d|a-f]+)[\t|\s]+\w+[\t|\s]+\w+[\t|\s]+0x[\d|a-f]+[\t|\s]+([\d|a-f]+)/) return nil if matches.nil? frame_id, frame_data = matches[1], matches[2] frame_id.upcase.sub(/^[0:]*/,"") + '#' + frame_data.upcase end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_raw(raw, line_number)\n raw\n end", "def parse_line(line)\n begin\n @loggie.write(\"#{line}\\n\")\n line = line.split(\" \")\n if line[9] == 'voice'\n return Message.new(line[12],line[15],'started.',line[0].to_f,GROUP,line[8])\n elsif line[9] == 'end'\n return Message.new(line[14],line[17].gsub(',',''),'ended.',line[0].to_f,GROUP,line[8])\n elsif line[7] == \"audio\"\n led(\"rx\", line[-2].split('/')[0].to_i / 141.0)\n return \"audio\"\n elsif line[6] == 'group'\n return Message.new(line[4],line[7],line.last,line[0].to_f,GROUP,\"RF\")\n elsif line =~ /Call from/\n return Message.new(line[4],line[6],line.last,line[0].to_f,PRIV,\"RF\")\n end\n rescue => e\n @@logger.debug(e.inspect)\n @@logger.debug(e.backtrace)\n exit 1\n end\n end", "def parse(raw)\n frames = raw.split(/\\n/)\n @value = frames.map {|f| f.lstrip }.select {|f| f.length > 0 }\n end", "def parse(line)\n\t\titems = line.split(' ')\n\t\trecord = {}\n\t\t# debugger\n\t\trecord[:event] = items[0]\n\t\trecord[:time] = items[1]\n\t\trecord[:fnode] = items[2]\n\t\trecord[:tnode] = items[3]\n\t\trecord[:pktype] = items[4]\n\t\trecord[:pktsize] = items[5]\n\t\trecord[:fid] = items[7]\n\t\trecord[:srcadd] = items[8]\n\t\trecord[:desadd] = items[9]\n\t\trecord[:seqnum] = items[10]\n\t\trecord[:pktid] = items[11]\n\t\trecord\n\tend", "def to_line(details)\n unless record = record_type(details[:record_type])\n raise ArgumentError, \"Invalid record type #{details[:record_type].inspect}\"\n end\n\n if record.respond_to?(:pre_gen)\n details = details.dup\n record.send(:pre_gen, details)\n end\n\n case record.type\n when :text; return details[:line]\n else\n return record.to_line(details) if record.respond_to?(:to_line)\n\n line = record.join(details)\n\n if regex = record.rts\n # If they say true, then use whitespace; else, use their regex.\n if regex == true\n regex = /\\s+$/\n end\n return line.sub(regex,'')\n else\n return line\n end\n end\n end", "def gen_raw_line\n return nil unless self.valid?\n line = ''\n data = []\n SUB_STR_ATTRIBUTES.each do |field,field_regex|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n line = \"#{data.join ' ,'}\"\n end\n\n data = []\n BOOL_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \",#{data.join ','} \"\n end\n end\n\n data = []\n ARR_STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \", #{data.join ','} \"\n end\n end\n\n data = []\n STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n line += data.join ' '\n return line\n end", "def decompose(raw_line)\n if raw_line =~ @@irc_line\n c = $~\n line = IRCSupport::Line.new\n\n if c[:tags]\n line.tags = {}\n c[:tags].split(/;/).each do |tag|\n key, value = tag.split(/=/)\n line.tags[key] = value ? value : true\n end\n end\n\n line.prefix = c[:prefix] if c[:prefix]\n line.command = c[:command].upcase\n line.args = []\n line.args.concat c[:args].split(@@space) if c[:args]\n line.args << c[:trailing_arg] if c[:trailing_arg]\n else\n raise ArgumentError, \"Line is not IRC protocol: #{raw_line.inspect}\"\n end\n\n return line\n end", "def decode(line)\n time, tag, *args = line.split\n [tag.to_s.to_sym, decode_args(args), decode_time(time)]\n end", "def parseWebServerLine(raw_line)\n\ttokens = /^(\\S+) (\\S+) (\\S+) \\[(\\S+ \\+\\d{4})\\] \"(\\S+ \\S+ [^\"]+)\" (\\d{3}) (\\d+|-) \"(.*?)\" \"([^\"]+)\"$/.match(raw_line).to_a\n\treturn tokens\nend", "def receive_data_line line\n end", "def txString(s, line)\r\n @transform = true\r\n sent,new_sent = parseSentance(s, line, 0)\r\n matches = parseSentance(s, line, 0)\r\n good_matches = []\r\n matches.each do |match|\r\n sent, new_sent = match\r\n if sent == line\r\n good_matches << [ sent, new_sent ]\r\n end\r\n end\r\n return [ [-1, \"Failed to match given string:\" + line] ] unless good_matches.size > 0\r\n good_matches\r\n end", "def receive_line (line)\n msg = Message.decode line\n \n receive_message msg\n end", "def handle_text_line(line, record)\n line =~ record.match ? {:record_type => record.name, :line => line} : nil\n end", "def extract_status_line(line)\n line =~ /RTSP\\/(\\d\\.\\d) (\\d\\d\\d) ([^\\r\\n]+)/\n @rtsp_version = $1\n @code = $2.to_i\n @message = $3\n\n if @rtsp_version.nil?\n raise RTSP::Error, \"Status line corrupted: #{line}\"\n end\n end", "def send_raw_line(line)\n @logger.debug \"<< #{line}\" if @logger\n @socket.puts(line)\n end", "def parse_bsd_line(line)\n finish_current_train\n train = TrainSchedule.new\n train.update_from_cif line\n @on_train_schedule_delete&.call self, train\n end", "def parseString(s, line, trace, transform)\r\n @sp = trace\r\n @transform = transform\r\n sent,new_sent = parseSentance(s, line, trace)\r\n\r\n matches = parseSentance(s, line, 0)\r\n good_matches = []\r\n matches.each do |match|\r\n sent, new_sent = match\r\n if sent == line\r\n print \"\\n\\n\\nMATCHED!\" + sent.nil?.to_s + \".\" + line + \".\\n\"\r\n print \"tx to:\" + new_sent.to_s + \"\\n\"\r\n else\r\n print \"\\n\\n\\nNO match\" + \".\" + sent.to_s + \".\" + line + \".\\n\"\r\n end\r\n end\r\n end", "def process_line(buf) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/AbcSize\n query = buf.chomp.chomp(';')\n begin\n ffi_query = ffi_polar.new_query_from_str(query)\n rescue ParseError => e\n print_error(e)\n return\n end\n\n begin\n results = Query.new(ffi_query, host: host).results.to_a\n rescue PolarRuntimeError => e\n print_error(e)\n return\n end\n\n if results.empty?\n puts false\n else\n results.each do |result|\n if result.empty?\n puts true\n else\n result.each do |variable, value|\n puts \"#{variable} = #{value.inspect}\"\n end\n end\n end\n end\n end", "def receive_line(line)\n # stub\n end", "def parse_line line, contexts\n line = line.encode Encoding::UTF_8 if encode_lines?\n\n handler = handler_for_line line\n\n handler.process line, contexts\n end", "def string\n @line\n end", "def tokenize ln, line\r\n pure_line = line.gsub(/^#{regex_line_comment}/, '') # trim line comment marker\r\n\r\n indent_level = 0\r\n processor_name = '_raw'\r\n line_code = ''\r\n block_open = false\r\n if matches = /#{regex_proc_line}/.match(pure_line) \r\n processor_name = matches[\"processor_name_\"]\r\n indent_level = matches[\"leading_spaces_\"].size\r\n line_code = matches[\"line_code_\"]\r\n block_open = true if /#{regex_block_start}\\s*$/ =~ line_code\r\n line_code.gsub!(/\\s*(#{regex_block_start})?\\s*$/, '') \r\n elsif matches = /^#{regex_proc_head}[^\\s]/.match(pure_line) \r\n indent_level = matches[\"leading_spaces_\"].size\r\n end\r\n\r\n Token.new ln, line, indent_level, processor_name, line_code, block_open \r\n end", "def read_packet; end", "def getLineFromString(line)\n return line.slice!(line.index(\"\\#~~!!\") + 6)\nend", "def recordize line\n line.split(\"\\t\") rescue nil\n end", "def parse_header\n @snp, @line, @type, @in, @polymorphism, @chromosome, @orientation = self.sequence_id.split(\" \") \n @type = @type.to_sym\n if @in\n @in = @in.to_sym == :exon \n else\n @exon = false\n end\n\n if @polymorphism.to_sym == :homoeologous\n @homoeologous = true\n else\n @homoeologous = false\n end\n @parsed = true\n @orientation = @orientation.to_sym\n end", "def parse837(first_line) read_837_header(first_line).skip_to_trailer.read_837_trailer; end", "def read_tsbs(line)\n case line\n when TSBS::CollapSound\n @collapsound = RPG::SE.new($1.to_s,$2.to_i,$3.to_i)\n when TSBS::SBS_Start_S\n @load_tsbs = true\n @use_sprite = true\n @sprite_name = $1.to_s\n when TSBS::SBS_Start\n @load_tsbs = true\n when TSBS::SBS_End\n @load_tsbs = false\n end\n super(line)\n end", "def decode_line(line)\r\n line.to_s.force_encoding('ISO-8859-1').encode('UTF-8')\r\n end", "def recognize\n @filetype = @raw[0,3].split(\"\").map { |c| c.ord }\n @magic = case @filetype[2]\n when 0xfa # Model 320, 633x, 644xg, 644xs, 654xs: D2 9B FA\n 0x88\n when 0x61 # Model 634xg: 49 04 61\n 0x11\n else\n STDERR.puts \"*** Unknown model: %02x %02x %02x\" % [@filetype[0],@filetype[1],@filetype[2]]\n STDERR.puts \"*** Maybe try 'decode -88' ?\"\n nil\n end\n end", "def encoding_line; end", "def parse_line(line)\n catch :line_parsed do\n UNDERSTOOD_ROWS.each do |record_type|\n if line.start_with?(record_type)\n send \"parse_#{record_type.downcase}_line\", line.chomp\n throw :line_parsed\n end\n end\n\n if line[0].eql?('/')\n parse_comment_line line.chomp\n throw :line_parsed\n end\n\n logger.error \"Can't understand line: #{line.chomp.inspect}\"\n end\n end", "def parse_bsn_line(line)\n finish_current_train\n @current_train = TrainSchedule.new\n @current_train.update_from_cif line\n @current_train_action = :create\n end", "def parse_bsr_line(line)\n finish_current_train\n @current_train = TrainSchedule.new\n @current_train.update_from_cif line\n @current_train_action = :update\n end", "def parser_received(line)\n\t\tif line.include? MailHeader.received\n @count=@count+1\n # fields=line.split(MailHeader.key_separator)\n if line.length>1\n @received_value=@received_value+line\n end #end fields.length\n else\n if line.include? MailHeader.key_separator\n if received_value.start_with? MailHeader.received\n #get the received value\n # puts @received_value\n end\n @received_value=\"\"\n else\n @received_value=@received_value+line\n end\n end #end line include?\n\n # parser the received from the mail header\n if received_value.include? MailHeader.smtp_code_550 or received_value.include? MailHeader.smtp_code_551 or received_value.include? MailHeader.smtp_code_553 or received_value.include? MailHeader.smtp_code_554\n mail_header_output.correct_email_format=MailHeader.unknown\n elsif received_value.include? MailHeader.smtp_code_552\n #the address is correct\n end\n\tend", "def process_input(line)\n case line\n when /^:((.+?)(?:!.+?)?) INVITE \\S+ :(\\S+)/i\n handle :incoming_invite, $1, $2, $3\n when /^:((.+?)(?:!.+?)?) PRIVMSG (\\S+) :?\\001ACTION (.+?)\\001$/i\n handle :incoming_act, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) PRIVMSG (\\S+?) :?\\001(.+?)\\001$/i\n handle :incoming_ctcp, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) PRIVMSG (\\S+?) :?(.+?)$/i\n handle :incoming_msg, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) NOTICE (\\S+?) :?\\001(.+?)\\001$/i\n handle :incoming_ctcpreply, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) NOTICE (\\S+?) :?(.+?)$/i\n handle :incoming_notice, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) MODE (\\S+?) :?(\\S+?)(?: (.+?))?$/i\n handle :incoming_mode, $1, $2, $3, $4, $5\n when /^:((.+?)(?:!.+?)?) JOIN :?(\\S+?)$/i\n handle :incoming_join, $1, $2, $3\n when /^:((.+?)(?:!.+?)?) PART (\\S+?)(?: :?(\\S+?)?)?$/i\n handle :incoming_part, $1, $2, $3, $4\n when /^:((.+?)(?:!.+?)?) KICK (\\S+?) (\\S+?) :?(.+?)$/i\n handle :incoming_kick, $1, $2, $3, $4, $5\n when /^:((.+?)(?:!.+?)?) QUIT :?(.+?)$/i\n handle :incoming_quit, $1, $2, $3\n when /^:((.+?)(?:!.+?)?) NICK :?(\\S+?)$/i\n handle :incoming_nick, $1, $2, $3\n when /^PING :?(.+?)$/i\n handle :incoming_ping, $1\n when /^:((.+?)(?:!.+?)?) (\\d{3})\\s+(\\S+?) (.+?)$/i\n handle_numeric($3.to_i, $1, $2, $4, $5)\n else\n handle :incoming_miscellany, line\n end\n end", "def streams_for(line)\n line.split(/({{\\s*[^}]+\\s*}})/)\n end", "def parse(line)\n res='unknown'\n raw=line.split(':')\n res=raw[1] if raw[1]!=nil\n res.strip\n end", "def parse_header line, samples, options\n header = VcfHeader.new(options[:debug])\n header.add(line)\n print line if not options[:skip_header]\n STDIN.each_line do | headerline |\n if headerline !~ /^#/\n # If no records in VCF, we never get here\n line = headerline\n break # end of header\n end\n header.add(headerline)\n if not options[:skip_header]\n if headerline =~ /^#CHR/\n # The header before actual data contains the sample names, first inject the BioVcf meta information\n print header.tag(options),\"\\n\" if options[:tag] and not options[:skip_header]\n # Then the additional filter(s)\n # ##FILTER=<ID=LowQual,Description=\"Low quality\">\n add_filter = options[:add_filter]\n if add_filter\n print \"##FILTER=<ID=\",add_filter,\",Description=\\\"\",options[:filter],\"\\\">\\n\"\n end\n \n selected = header.column_names\n if samples\n newfields = selected[0..8]\n samples.each do |s|\n newfields << selected[s+9] \n end\n selected = newfields\n end\n print \"#\",selected.join(\"\\t\"),\"\\n\"\n else\n print headerline\n end\n end\n end\n print header.printable_header_line(options[:set_header]),\"\\n\" if options[:set_header]\n VcfRdf::header if options[:rdf]\n if line =~ /^#/\n # We did not read a record\n line = nil\n end\n return header,line\nend", "def getLine\r\n\t\treturn @Line\r\n\tend", "def process_record(text_line)\n text_line = pre_process(text_line)\n return pad_record(text_line)\n end", "def recordize line\n line.split(\"\\t\")\n end", "def line_code\n @attrs['Line']\n end", "def raw\n @lines.map(&:first).join(\"\\n\") + \"\\n\"\n end", "def read_track\n\tc = c1 = type = needed = 0\n\tsysex_continue = false\t# True if last msg was unfinished\n\trunning = false\t\t# True when running status used\n\tstatus = 0\t\t# (Possibly running) status byte\n\n\t@bytes_to_be_read = 0\n\tread_mt_header_string(MTrk_BYTE_ARRAY, false)\n\n\t@bytes_to_be_read = read32()\n\t@curr_ticks = @ticks_so_far = 0\n\n\tstart_track()\n\n\twhile @bytes_to_be_read > 0\n @curr_ticks = read_var_len() # Delta time\n @ticks_so_far += @curr_ticks\n\n # Copy raw var num data into raw time stamp data\n @raw_time_stamp_data = @raw_var_num_data.dup()\n\n c = getc()\t\t# Read first byte\n\n if sysex_continue && c != EOX\n error(\"didn't find expected continuation of a sysex\")\n end\n\n if (c & 0x80).zero? # Running status?\n error('unexpected running status') if status.zero?\n running = true\n else\n status = c\n running = false\n end\n\n needed = NUM_DATA_BYTES[(status >> 4) & 0x0f]\n\n if needed.nonzero?\t# i.e., is it a channel message?\n c1 = running ? c : (getc() & 0x7f)\n\n # The \"& 0x7f\" here may seem unnecessary, but I've seen\n # \"bad\" MIDI files that had, for example, volume bytes\n # with the upper bit set. This code should not harm\n # proper data.\n chan_message(running, status, c1,\n (needed > 1) ? (getc() & 0x7f) : 0)\n next\n end\n\n case c\n when META_EVENT\t# Meta event\n type = getc()\n msg_init()\n msg_read(read_var_len())\n meta_event(type)\n when SYSEX\t\t# Start of system exclusive\n msg_init()\n msg_add(SYSEX)\n c = msg_read(read_var_len())\n\n if c == EOX || !@no_merge\n handle_sysex(msg())\n else\n sysex_continue = true\n end\n when EOX\t\t# Sysex continuation or arbitrary stuff\n msg_init() if !sysex_continue\n c = msg_read(read_var_len())\n\n if !sysex_continue\n handle_arbitrary(msg())\n elsif c == EOX\n handle_sysex(msg())\n sysex_continue = false\n end\n else\n bad_byte(c)\n end\n\tend\n\tend_track()\n end", "def listen\n\t\trec = @sp.gets(sep=\"\\r\")\n\t\[email protected] \"Rx: \" + rec\n\t\treturn rec\n\t end", "def receive_line line\n message = IRCParser::Message.parse line\n\n @network.got_message message\n end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def parse_line(lineno)\n @native_text[lineno] = @content_type_handler.parse_line( @list[lineno]) \n end", "def frame_line(frame_position)\n #This is a stub, used for indexing\n end", "def parse_line(line)\n # If the previous line didn't and a logical line, we're not going to start one. If it did,\n # we're indeed going to start a new logical line\n @state[:ll_start] = @state[:ll_end]\n\n # We will start with the assumption that we're going to end the current logical line. We may layer\n # find out that we did not, in fact, do so.\n @state[:ll_end] = true\n\n # Reset the line continuator flag the the last line may have set to true\n @state[:line_continuator] = false\n\n # Find the first non-(space/tab) character\n index = 0\n while index < line.length && [\" \", \"\\t\"].include?(line[index])\n index += 1\n end\n @state[:indent_string] = line[0...index]\n\n # Iterate over the line's characters as long as there are any. We use different iteration\n # methods depending on whether we're inside a string or not\n index = 0\n while index < line.length\n if @state[:in_string].nil?\n index = parse_characters_normal(line, index)\n else\n index = parse_characters_in_string(line, index)\n end\n end\n\n # We have reached the end of the line. Decide whether or not the logical line ends here.\n @state[:ll_end] = @state[:in_string].nil? && @state[:open_braces] == 0 && !@state[:line_continuator]\n end", "def accept_raw raw\n @res << raw.parts.join(\"\\n\")\n end", "def accept_raw raw\n @res << raw.parts.join(\"\\n\")\n end", "def read_frame\n byte = read_and_unpack_byte\n fin = (byte & 0b10000000) == 0b10000000\n rsv1 = byte & 0b01000000\n rsv2 = byte & 0b00100000\n rsv3 = byte & 0b00010000\n opcode = byte & 0b00001111\n\n @logger.debug \"unexpected value: rsv1: #{rsv1}\" unless rsv1 == 0\n @logger.debug \"unexpected value: rsv2: #{rsv2}\" unless rsv2 == 0\n @logger.debug \"unexpected value: rsv3: #{rsv3}\" unless rsv3 == 0\n\n byte = read_and_unpack_byte\n mask = (byte & 0b10000000) == 0b10000000\n lenflag = byte & 0b01111111\n\n # if len <= 125, this is the length\n # if len == 126, length is encoded on next two bytes\n # if len == 127, length is encoded on next eight bytes\n len = case lenflag\n when 126 # 2 bytes\n bytes = @sock.read(2)\n len = bytes.unpack(\"n\")[0]\n when 127 # 8 bytes\n bytes = @sock.read(8)\n len = bytes.unpack(\"Q\")[0]\n else\n lenflag\n end\n\n if mask then\n masking_key = @sock.read(4).unpack(\"C*\")\n end\n\n payload = @sock.read(len)\n payload = apply_mask(payload, masking_key) if mask\n\n return fin, opcode, mask, len, masking_key, payload\n end", "def process_line_of_tsv_in_this_pipe line\n parts = line.strip.split(\"\\t\")\n case parts.size\n when 2\n timestamp = Time.now\n key, value = parts\n when 3\n key, value = parts[0..1]\n timestamp = Time.parse(parts.last)\n else\n error(\"Each line of input must be a tab separated row consisting of 2 columns (key, value) or 3 columns (timestamp, key, value)\")\n return\n end\n send_data(key, value, timestamp)\n end", "def pre_process(text_line)\n processed_line = \"\"\n if text_line.slice(0..1)== \"LD\" && text_line.slice(14..20) == 'XXXXXXX'\n if @false_header_loaded\n processed_line = \"DT\" + text_line.slice(2..text_line.length())\n else\n processed_line = \"DH\" + text_line.slice(2..text_line.length())\n end\n elsif text_line.slice(0..1)== \"LD\"\n @false_header_loaded = true\n processed_line = text_line\n else\n processed_line = text_line\n end\n\n return processed_line\n\n end", "def line\n buffer[line_number]\n end", "def parse_line(line)\n ln, fn, mi, sex, fav_color, dob = line.split(' | ')\n LineParser.to_h(fn, ln, mi, sex, fav_color, parse_dob(dob))\n end", "def original_line; end", "def compile_line(aRawLine)\n line_rep = aRawLine.map { |couple| compile_couple(couple) }\n \n # Apply the rule: when a line just consist of spaces \n # and a section element, then remove all the spaces from that line.\n line_to_squeeze = line_rep.all? do |item|\n if item.kind_of?(StaticText)\n item.source =~ /\\s+/\n else\n false\n end\n end\n line_rep_ending(line_rep) unless line_to_squeeze\n \n return line_rep\n end", "def read_line\n line = @socket.readline.chomp\n warn \"<- #{line}\" if @options[:debug]\n line\n end", "def get_raw_information\n @infos[RAW]\n end", "def postprocess_print(send, type, line)\n if type == \"syntaxchecksuccess\"\n return syntax_check_success(send, line)\n\n elsif type == \"syntaxcheckfail\"\n return syntax_check_fail(send, line)\n\n elsif type == \"augmentsuccess\"\n return augment_success(send, line)\n\n elsif type == \"augmentfail\"\n return augment_fail(send, line)\n\n elsif type == \"executeoutput\"\n return execute_output(send, line)\n\n elsif type == \"executeerror\"\n return execute_error(send, line)\n end\n end", "def method_missing(method, *params)\n raw_line.send method, *params\n end", "def context_type_relay_row\n ContextTypeDef.new(\n :relay_row,\n [\n /(?=\\s{4}(?<timing>Ritir|Squal|\\d{1,2}'\\d{2}\"\\d{2}))/uix\n # Old version:\n# /Ritir.*|Squal.*|(\\d{1,2}'\\d\\d\"\\d\\d +\\d{1,4}[\\,|\\.]\\d\\d)(\\r\\n|\\n|$|\\Z)/i\n ],\n :relay_header\n )\n end", "def lex_line\n @chunks = @line.scan(/#{BRACKET_RE}|#{DATE_RE}|#{MOD_RE}|#{ATTR_REGEX}|#{OTHER_RE}/).chunk do |seg|\n case seg\n when BRACKET_RE then :bracket\n when MOD_RE then :modifier\n when DATE_RE then :date\n when ATTR_REGEX then :attr\n when OTHER_RE then :other\n else :error\n end\n end.to_a\n # it should be impossible to encounter errors, but cry if they happen\n check_for_errors\n @chunks\n end", "def parse(raw_line)\n line = decompose(raw_line)\n\n if line.command =~ /^(PRIVMSG|NOTICE)$/ && line.args[1] =~ /\\x01/\n return handle_ctcp_message(line)\n end\n\n msg_class = case\n when line.command =~ /^\\d{3}$/\n begin\n constantize(\"IRCSupport::Message::Numeric#{line.command}\")\n rescue\n constantize(\"IRCSupport::Message::Numeric\")\n end\n when line.command == \"MODE\"\n if @isupport['CHANTYPES'].include?(line.args[0][0])\n constantize(\"IRCSupport::Message::ChannelModeChange\")\n else\n constantize(\"IRCSupport::Message::UserModeChange\")\n end\n when line.command == \"NOTICE\" && (!line.prefix || line.prefix !~ /!/)\n constantize(\"IRCSupport::Message::ServerNotice\")\n when line.command == \"CAP\" && %w{LS LIST ACK}.include?(line.args[0])\n constantize(\"IRCSupport::Message::CAP::#{line.args[0]}\")\n else\n begin\n constantize(\"IRCSupport::Message::#{line.command.capitalize}\")\n rescue\n constantize(\"IRCSupport::Message\")\n end\n end\n\n message = msg_class.new(line, @isupport, @capabilities)\n\n case message.type\n when :'005'\n @isupport.merge! message.isupport\n when :cap_ack\n message.capabilities.each do |capability, options|\n if options.include?(:disable)\n @capabilities = @capabilities - [capability]\n elsif options.include?(:enable)\n @capabilities = @capabilities + [capability]\n end\n end\n end\n\n return message\n end", "def read_tsbs(line)\n case line\n when TSBS::DefaultATK\n @attack_id = $1.to_i\n when TSBS::DefaultDEF\n @guard_id = $1.to_i\n when TSBS::SBS_Start\n @load_tsbs = true\n when TSBS::SBS_Start_S\n @load_tsbs = true\n @battler_name = $1.to_s\n when TSBS::SBS_End\n @load_tsbs = false\n end\n super(line)\n end", "def get_line(code)\n return code[2][0]\n end", "def create_record(line, line_number = -1) #:nodoc:\n h = Hash.new\n\n pack_format = self.class.get_subclass_variable 'pack_format'\n fields = self.class.get_subclass_variable 'fields'\n\n f = line.unpack(pack_format)\n (0..(fields.size-1)).map do |index|\n unless fields[index].is_padding?\n h.store fields[index].name, fields[index].pass_through_filters(f[index])\n end\n end\n Record.new(self.class, h, line_number)\n end", "def tokenizer_relay_header_event_code\n TokenExtractor.new(\n :event_uisp_code,\n /(?<=codice:\\s)\\s*[XMF][ABCDEFGH][ML]\\d/ix,\n 4\n )\n end", "def process_testcase(line_buffer)\n line_buffer\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def cook_line(raw_line)\n return nil if raw_line.nil?\n cooked_line = raw_line.lstrip.rstrip\n return nil if cooked_line.empty?\n cooked_line\n end", "def receive_line ln\n # no-op\n end", "def parse_event_line(s)\n minute, word_1, word_2 = s.scan(/.+ ..:(..)\\] (\\S+) (\\S+)/).flatten\n [minute.to_i, word_1, word_2]\n end", "def process_line(line)\n @line = line\n if line =~ /^=/ then\n process_heading_line(line)\n elsif (listtype = special_list_line_type(line)) then\n special_list_line(listtype, line)\n elsif line =~ /^\\s*:/ then\n special_list_continuation_line(line)\n else\n @interp.normal_line(line)\n end\n end", "def possibly_add_trace_info_calls(line)\n # If the current line does not start a logical line, don't bother\n if not @state[:ll_start]\n return line\n end\n\n # We will be making decisions based on the first word on the line\n line_words = line.split\n if line_words.empty?\n # The line is empty, so we disregard it\n return line\n end\n first_word = line_words[0]\n\n # Extract first word and check if it makes us want to refrain from adding a line number call\n if KEYWORDS_WITHOUT_LINE_NUMBERS.include?(first_word)\n # It's one of the statements we don't want\n return line\n\n elsif [\"'\", '\"', \"#\"].include?(first_word[0])\n # The line starts with a string or with a comment\n return line\n end\n\n # Do include a line number call\n return \"#{@state[:indent_string]}garbledwebpiratenlibraryname.debug(locals(), globals())\\n\" +\n \"#{@state[:indent_string]}garbledwebpiratenlibraryname.line(#{@state[:line_number]})\\n\" +\n \"#{line}\"\n end", "def st_lex(raw)\n @tokens = raw.delete(' ').gsub(\"\\n\", '')\n end", "def original_text\n @line\n end", "def parse(rawdata)\n end", "def process_line line\n if line.include?(\"@\") && @add_tags_to_main\n @nd[:main_tags] << line \n elsif line.include?(\"Feature:\")\n @nd[:feature] = line.sub(\"Feature:\",\"\")\n @add_tags_to_main = false\n elsif line.include?(\"Scenario:\")\n @nd[:scenarios].push({:name => line.sub(\"Scenario:\",\"\"), :steps => []})\n @add_to_s = true\n elsif\n begin\n @nd[:scenarios].last[:steps].push(line) if @add_to_s\n @add_to_s = true \n rescue\n end\n end\n end" ]
[ "0.62167466", "0.61395377", "0.61065084", "0.6039564", "0.5759533", "0.570317", "0.5541976", "0.55359715", "0.55344516", "0.5494722", "0.5493833", "0.5490411", "0.5458892", "0.54140705", "0.5411361", "0.53648347", "0.5346582", "0.5342015", "0.53378135", "0.53374296", "0.5329978", "0.5328432", "0.52879214", "0.52704155", "0.5263877", "0.5259163", "0.5220881", "0.52067167", "0.51792157", "0.51472044", "0.5138593", "0.5131686", "0.51222503", "0.5122174", "0.50932467", "0.5089122", "0.5081427", "0.50726527", "0.5060711", "0.50563484", "0.50550294", "0.5045407", "0.5035015", "0.5029659", "0.5026237", "0.5023815", "0.5017439", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.5007108", "0.50003", "0.49998298", "0.49889964", "0.4986727", "0.4986727", "0.49845684", "0.4982945", "0.4982492", "0.49802268", "0.49700657", "0.49661735", "0.49611282", "0.49596137", "0.49570787", "0.49486655", "0.49475807", "0.49467087", "0.494493", "0.49369696", "0.4935731", "0.493351", "0.49306923", "0.4930033", "0.49262398", "0.49100423", "0.49100423", "0.49100423", "0.49100423", "0.49100423", "0.4909397", "0.4892299", "0.48879278", "0.48808184", "0.4879321", "0.48749223", "0.48739612", "0.48701048", "0.4868541" ]
0.68291134
0
Process a raw line and return the synthesized symbol of the observation record Sample: "(20171226 15:04:10.818578) can0 18A003A000000000000" "(20171226 15:04:05.204456) can0 28A0284004900110000\n"
def preprocess_obvervation_line(text) matches = text.match(/can\d\s+([\d|A-F]+\#[\d|A-F]+)\n?$/) return nil if matches.nil? matches[1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_line(line)\n begin\n @loggie.write(\"#{line}\\n\")\n line = line.split(\" \")\n if line[9] == 'voice'\n return Message.new(line[12],line[15],'started.',line[0].to_f,GROUP,line[8])\n elsif line[9] == 'end'\n return Message.new(line[14],line[17].gsub(',',''),'ended.',line[0].to_f,GROUP,line[8])\n elsif line[7] == \"audio\"\n led(\"rx\", line[-2].split('/')[0].to_i / 141.0)\n return \"audio\"\n elsif line[6] == 'group'\n return Message.new(line[4],line[7],line.last,line[0].to_f,GROUP,\"RF\")\n elsif line =~ /Call from/\n return Message.new(line[4],line[6],line.last,line[0].to_f,PRIV,\"RF\")\n end\n rescue => e\n @@logger.debug(e.inspect)\n @@logger.debug(e.backtrace)\n exit 1\n end\n end", "def decode(line)\n time, tag, *args = line.split\n [tag.to_s.to_sym, decode_args(args), decode_time(time)]\n end", "def process_raw(raw, line_number)\n raw\n end", "def parse_event_line(s)\n minute, word_1, word_2 = s.scan(/.+ ..:(..)\\] (\\S+) (\\S+)/).flatten\n [minute.to_i, word_1, word_2]\n end", "def parse(line)\n\t\titems = line.split(' ')\n\t\trecord = {}\n\t\t# debugger\n\t\trecord[:event] = items[0]\n\t\trecord[:time] = items[1]\n\t\trecord[:fnode] = items[2]\n\t\trecord[:tnode] = items[3]\n\t\trecord[:pktype] = items[4]\n\t\trecord[:pktsize] = items[5]\n\t\trecord[:fid] = items[7]\n\t\trecord[:srcadd] = items[8]\n\t\trecord[:desadd] = items[9]\n\t\trecord[:seqnum] = items[10]\n\t\trecord[:pktid] = items[11]\n\t\trecord\n\tend", "def parse_bsd_line(line)\n finish_current_train\n train = TrainSchedule.new\n train.update_from_cif line\n @on_train_schedule_delete&.call self, train\n end", "def getLineFromString(line)\n return line.slice!(line.index(\"\\#~~!!\") + 6)\nend", "def parse(raw)\n frames = raw.split(/\\n/)\n @value = frames.map {|f| f.lstrip }.select {|f| f.length > 0 }\n end", "def preprocess_truth_line(text)\n matches = text.match(/^\\d+[\\t|\\s]+Recv[\\t|\\s]+.{14}[\\t|\\s]+0x([\\d|a-f]+)[\\t|\\s]+\\w+[\\t|\\s]+\\w+[\\t|\\s]+0x[\\d|a-f]+[\\t|\\s]+([\\d|a-f]+)/)\n return nil if matches.nil?\n frame_id, frame_data = matches[1], matches[2]\n frame_id.upcase.sub(/^[0:]*/,\"\") + '#' + frame_data.upcase\nend", "def next_sentence\n\t\n\t\t# Loop through serial data\n\t\tbuffer = \"\"\n\t\twhile true do\n\t\t\tc = @serial.getc\n\t\t\tif c.nil?\n\t\t\t\traise \"Can't connection to the GPS!\"\n\t\t\tend\n\n\t\t\t# End of the line, collect the data\n\t\t\tif c == 10\n\t\t\t\tbuffer.lstrip!\n\t\t\t\t\n\t\t\t\t# Valid sentence\n\t\t\t\tif buffer[0,1] == \"$\"\n\t\t\t\t\tbreak\n\t\t\t\t\t\n\t\t\t\t# Try again, probably a partial line\n\t\t\t\telse\n\t\t\t\t\tbuffer = \"\"\n\t\t\t\tend\n\t\t\t\t\n\t\t\t# Add to buffer\n\t\t\telse\n\t\t\t\tbuffer << c\n\t\t\tend\n\t\tend\n\t\t\n\t\tbuffer\n\tend", "def parse_bsn_line(line)\n finish_current_train\n @current_train = TrainSchedule.new\n @current_train.update_from_cif line\n @current_train_action = :create\n end", "def parse(line)\n res='unknown'\n raw=line.split(':')\n res=raw[1] if raw[1]!=nil\n res.strip\n end", "def decompose(raw_line)\n if raw_line =~ @@irc_line\n c = $~\n line = IRCSupport::Line.new\n\n if c[:tags]\n line.tags = {}\n c[:tags].split(/;/).each do |tag|\n key, value = tag.split(/=/)\n line.tags[key] = value ? value : true\n end\n end\n\n line.prefix = c[:prefix] if c[:prefix]\n line.command = c[:command].upcase\n line.args = []\n line.args.concat c[:args].split(@@space) if c[:args]\n line.args << c[:trailing_arg] if c[:trailing_arg]\n else\n raise ArgumentError, \"Line is not IRC protocol: #{raw_line.inspect}\"\n end\n\n return line\n end", "def to_line(details)\n unless record = record_type(details[:record_type])\n raise ArgumentError, \"Invalid record type #{details[:record_type].inspect}\"\n end\n\n if record.respond_to?(:pre_gen)\n details = details.dup\n record.send(:pre_gen, details)\n end\n\n case record.type\n when :text; return details[:line]\n else\n return record.to_line(details) if record.respond_to?(:to_line)\n\n line = record.join(details)\n\n if regex = record.rts\n # If they say true, then use whitespace; else, use their regex.\n if regex == true\n regex = /\\s+$/\n end\n return line.sub(regex,'')\n else\n return line\n end\n end\n end", "def gen_raw_line\n return nil unless self.valid?\n line = ''\n data = []\n SUB_STR_ATTRIBUTES.each do |field,field_regex|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n line = \"#{data.join ' ,'}\"\n end\n\n data = []\n BOOL_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \",#{data.join ','} \"\n end\n end\n\n data = []\n ARR_STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \", #{data.join ','} \"\n end\n end\n\n data = []\n STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n line += data.join ' '\n return line\n end", "def line_postprocess(line)\n # Forces the values to be ASCII strings\n asciify(line)\n\n line[:quotation_time] = ::Nordea.parse_time(line[:quotation_time])\n line[:reserved].strip! if line[:reserved].respond_to? :strip!\n fill_proper_rate_type(line)\n\n line[:euro_area] = (line[:euro_area] == '1')\n\n line[:euro_adoption_date] = if line[:euro_area]\n Nordea.parse_date(line[:euro_adoption_date])\n else\n nil\n end\n\n line[:currency_expiry] = (line[:currency_expiry] == 'K')\n line[:currency_convertability] = (line[:currency_convertability] == 'K')\n floatify(line)\n\n line\n end", "def string\n @line\n end", "def parse_bsr_line(line)\n finish_current_train\n @current_train = TrainSchedule.new\n @current_train.update_from_cif line\n @current_train_action = :update\n end", "def streams_for(line)\n line.split(/({{\\s*[^}]+\\s*}})/)\n end", "def lex_line\n @chunks = @line.scan(/#{BRACKET_RE}|#{DATE_RE}|#{MOD_RE}|#{ATTR_REGEX}|#{OTHER_RE}/).chunk do |seg|\n case seg\n when BRACKET_RE then :bracket\n when MOD_RE then :modifier\n when DATE_RE then :date\n when ATTR_REGEX then :attr\n when OTHER_RE then :other\n else :error\n end\n end.to_a\n # it should be impossible to encounter errors, but cry if they happen\n check_for_errors\n @chunks\n end", "def parse_NMEA(raw)\n\t\tdata = { :last_nmea => nil }\n\t\tif raw.nil?\n\t\t\treturn data\n\t\tend\n\t\traw.gsub!(/[\\n\\r]/, \"\")\n\n\t\tline = raw.split(\",\");\n\t\tif line.size < 1\n\t\t\treturn data\n\t\tend\n\t\t\n\t\t# Invalid sentence, does not begin with '$'\n\t\tif line[0][0, 1] != \"$\"\n\t\t\treturn data\n\t\tend\n\t\t\n\t\t# Parse sentence\n\t\ttype = line[0][3, 3]\n\t\tline.shift\n\n\t\tif type.nil?\n\t\t\treturn data\n\t\tend\n\t\t\n\t\tcase type\n\t\t\twhen \"GGA\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:time]\t\t\t\t= line.shift\n\t\t\t\tdata[:latitude]\t\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:lat_ref]\t\t\t= line.shift\n\t\t\t\tdata[:longitude]\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:long_ref]\t\t\t= line.shift\n\t\t\t\tdata[:quality]\t\t\t= line.shift\n\t\t\t\tdata[:num_sat]\t\t\t= line.shift.to_i\n\t\t\t\tdata[:hdop]\t\t\t\t= line.shift\n\t\t\t\tdata[:altitude]\t\t\t= line.shift\n\t\t\t\tdata[:alt_unit]\t\t\t= line.shift\n\t\t\t\tdata[:height_geoid]\t\t= line.shift\n\t\t\t\tdata[:height_geoid_unit] = line.shift\n\t\t\t\tdata[:last_dgps]\t\t= line.shift\n\t\t\t\tdata[:dgps]\t\t\t\t= line.shift\n\t\n\t\t\twhen \"RMC\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:time]\t\t\t= line.shift\n\t\t\t\tdata[:validity]\t\t= line.shift\n\t\t\t\tdata[:latitude]\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:lat_ref]\t\t= line.shift\n\t\t\t\tdata[:longitude]\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:long_ref]\t\t= line.shift\n\t\t\t\tdata[:speed]\t\t= line.shift\n\t\t\t\tdata[:course]\t\t= line.shift\n\t\t\t\tdata[:date]\t\t\t= line.shift\n\t\t\t\tdata[:variation]\t= line.shift\n\t\t\t\tdata[:var_direction] = line.shift\n\t\t\t\t\n\t\t\twhen \"GLL\"\n\t\t\t\tdata[:last_nmea] \t= type\n\t\t\t\tdata[:latitude]\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:lat_ref]\t\t= line.shift\n\t\t\t\tdata[:longitude]\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:long_ref]\t\t= line.shift\n\t\t \tdata[:time]\t\t\t\t= line.shift\n\t\t\t\t\n\t\t\twhen \"RMA\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tline.shift # data status\n\t\t\t\tdata[:latitude]\t\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:lat_ref]\t\t= line.shift\n\t\t\t\tdata[:longitude]\t= latLngToDecimal(line.shift)\n\t\t\t\tdata[:long_ref]\t\t= line.shift\n\t\t \t\tline.shift # not used\n\t\t \t\tline.shift # not used\n\t\t\t\tdata[:speed]\t\t\t= line.shift\n\t\t\t\tdata[:course]\t\t\t= line.shift\n\t\t\t\tdata[:variation]\t= line.shift\n\t\t\t\tdata[:var_direction]\t= line.shift\n\t\t \t\n\t\t\twhen \"GSA\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:mode]\t\t\t\t\t\t= line.shift\n\t\t\t\tdata[:mode_dimension]\t= line.shift\n\t\t \t\n\t\t \t# Satellite data\n\t\t \tdata[:satellites] ||= []\n\t\t \t12.times do |i|\n\t\t \t\tid = line.shift\n\t\t \t\t\n\t\t \t\t# No satallite ID, clear data for this index\n\t\t \t\tif id.empty?\n\t\t \t\t\tdata[:satellites][i] = {}\n\t\t \t\t\n\t\t \t\t# Add satallite ID\n\t\t \t\telse\n\t\t\t \t\tdata[:satellites][i] ||= {}\n\t\t\t \t\tdata[:satellites][i][:id] = id\n\t\t \t\tend\n\t\t \tend\n\t\t \t\n\t\t \tdata[:pdop]\t\t\t= line.shift\n\t\t \tdata[:hdop]\t\t\t= line.shift\n\t\t \tdata[:vdop]\t\t\t= line.shift\n\t\t \t\n\t\t\twhen \"GSV\"\n\t\t\t\tdata[:last_nmea] \t= type\n\t\t\t\tdata[:msg_count]\t= line.shift\n\t\t\t\tdata[:msg_num]\t\t= line.shift\n\t\t\t\tdata[:num_sat]\t\t= line.shift.to_i\n\t\t\t\t\n\t\t\t\t# Satellite data\n\t\t \t\tdata[:satellites] ||= []\n\t\t\t\t4.times do |i|\n\t\t \t\t\tdata[:satellites][i] ||= {}\n\t\t \t\t\n\t\t\t\t\tdata[:satellites][i][:elevation]\t= line.shift\n\t\t\t\t\tdata[:satellites][i][:azimuth]\t\t= line.shift\n\t\t\t\t\tdata[:satellites][i][:snr]\t\t\t= line.shift\n\t\t\t\tend\n\t\t \t\n\t\t when \"HDT\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:heading]\t= line.shift\n\t\t\t\t\n\t\t\twhen \"ZDA\"\n\t\t\t\tdata[:last_nmea] = type\n\t\t\t\tdata[:time]\t= line.shift\n\t\t\t\t\n\t\t\t\tday\t\t= line.shift\n\t\t\t\tmonth\t= line.shift\n\t\t\t\tyear\t= line.shift\n\t\t\t\tif year.size > 2\n\t\t\t\t\tyear = year[2, 2]\n\t\t\t\tend\n\t\t\t\tdata[:date] = \"#{day}#{month}#{year}\"\n\t\t\t\t\n\t\t\t\tdata[:local_hour_offset]\t\t= line.shift\n\t\t\t\tdata[:local_minute_offset]\t= line.shift\n\t\tend\n\t\t\n\t\t# Remove empty data\n\t\tdata.each_pair do |key, value|\n\t\t\tif value.nil? || (value.is_a?(String) && value.empty?)\n\t\t\t\tdata.delete(key)\n\t\t\tend\n\t\tend\n\t\t\n\t\tdata\n\tend", "def parseWebServerLine(raw_line)\n\ttokens = /^(\\S+) (\\S+) (\\S+) \\[(\\S+ \\+\\d{4})\\] \"(\\S+ \\S+ [^\"]+)\" (\\d{3}) (\\d+|-) \"(.*?)\" \"([^\"]+)\"$/.match(raw_line).to_a\n\treturn tokens\nend", "def parse_line(line)\n ln, fn, mi, sex, fav_color, dob = line.split(' | ')\n LineParser.to_h(fn, ln, mi, sex, fav_color, parse_dob(dob))\n end", "def decode_line(line)\r\n line.to_s.force_encoding('ISO-8859-1').encode('UTF-8')\r\n end", "def recordize line\n line.split(\"\\t\") rescue nil\n end", "def create_timestamp(line)\n\t\tTime.strptime(line[1], '%Q')\n\tend", "def parse_std_line(line)\n a = line.scan(/[ ]*([^()]*) \\(/)[0]\n a << line.scan( /(?:\\()([^()]*)(?:\\))/)\n a.flatten\nend", "def convert_nagios_line(line)\n line_array = line.split(' ')\n epoch_timestamp = line_array[0].gsub(/\\D/, '')\n human_timestamp = Time.at(epoch_timestamp)\n format(human_timestamp, line_array, 1)\nend", "def process_line(line_text)\n date_string,symbol = line_text.split(',')\n month,day,year = date_string.split('/')\n [Date.new(year.to_i, month.to_i, day.to_i), symbol.strip]\n end", "def convert_line_to_event(line, es)\n\t\t\tbegin\n\t\t\t\tline.chomp! # remove \\n\n\t\t\t\[email protected](line) { |time, record|\n\t\t\t\t\tif time && record\n\t\t\t\t\t\tes.add(time, record)\n identifier = record[@identifier].gsub(/\\s+/, '')\n if [email protected] identifier\n @redis.set identifier, true\n @redis.expire identifier, 60*60*24*45\n get_additional_data(identifier)\n end\n else\n\t\t\t\t\t\tlog.warn \"pattern not match\"\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\trescue => e\n\t\t\t\tlog.warn line.dump, :error => e.to_s\n\t\t\t\tlog.debug_backtrace(e.backtrace)\n\t\t\tend\n\t\tend", "def process_initial(time_stamp, line)\n process(time_stamp, line)\n end", "def handle_text_line(line, record)\n line =~ record.match ? {:record_type => record.name, :line => line} : nil\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def extract_data line\n card_num = line.match(/^\\d+/).to_s\n card_name = line.gsub(/^\\d+/,\"\").strip\n require 'pry'; binding.pry;\n if card_has = line.match(/\\[(\\d+)\\]/)\n card_has = card_has.captures.first\n card_name = card_name.gsub(/\\[\\d+\\]/,\"\").strip\n else\n card_has = 0\n end\n card = {\n card_name: card_name,\n card_num: card_num.to_i,\n card_has: card_has.to_i,\n }\nend", "def cook_line(raw_line)\n return nil if raw_line.nil?\n cooked_line = raw_line.lstrip.rstrip\n return nil if cooked_line.empty?\n cooked_line\n end", "def __extract_pd_expression__(source_line)\n source_line.to_s.strip\n end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def process_record(text_line)\n text_line = pre_process(text_line)\n return pad_record(text_line)\n end", "def translate(line)\r\n if line[0,3] == \"A2P\"\r\n return to_phonetic(line[4,line.length])\r\n end\r\n if line[0,3] == \"P2A\"\r\n return from_phonetic(line[4,line.length])\r\n end\r\n \r\n return nil\r\n end", "def parse_line(line)\n catch :line_parsed do\n UNDERSTOOD_ROWS.each do |record_type|\n if line.start_with?(record_type)\n send \"parse_#{record_type.downcase}_line\", line.chomp\n throw :line_parsed\n end\n end\n\n if line[0].eql?('/')\n parse_comment_line line.chomp\n throw :line_parsed\n end\n\n logger.error \"Can't understand line: #{line.chomp.inspect}\"\n end\n end", "def txString(s, line)\r\n @transform = true\r\n sent,new_sent = parseSentance(s, line, 0)\r\n matches = parseSentance(s, line, 0)\r\n good_matches = []\r\n matches.each do |match|\r\n sent, new_sent = match\r\n if sent == line\r\n good_matches << [ sent, new_sent ]\r\n end\r\n end\r\n return [ [-1, \"Failed to match given string:\" + line] ] unless good_matches.size > 0\r\n good_matches\r\n end", "def parse_line_data(line)\n line.strip.gsub('\"', '').split ' = '\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def receive_data_line line\n end", "def serial_read_line()\n s = \"\"\n c = @sp.getc\n until c == 13 # collect until 13 (new line)\n s.concat(c)\n c = @sp.getc\n end\n @sp.putc 13\n @sp.flush\n return s\n end", "def card_from_line(line)\n infer_set(line)\n infer_card(line)\n infer_foil(line)\n end", "def recordize line\n line.split(\"\\t\")\n end", "def capture_value(line)\n value = line.dup\n [@cell_mapping['capture']].flatten.each do |pattern|\n if matchdata = value.to_s.match(pattern)\n value = matchdata[1]\n else\n value = nil\n end\n end\n value.nil? ? value : value.strip\n end", "def process_line(ln)\n ln.strip!\n if ln =~ /(.*)\\s+\\(\\d+\\)\\z/\n $1\n else\n ln\n end\n end", "def compile_line(aRawLine)\n line_rep = aRawLine.map { |couple| compile_couple(couple) }\n \n # Apply the rule: when a line just consist of spaces \n # and a section element, then remove all the spaces from that line.\n line_to_squeeze = line_rep.all? do |item|\n if item.kind_of?(StaticText)\n item.source =~ /\\s+/\n else\n false\n end\n end\n line_rep_ending(line_rep) unless line_to_squeeze\n \n return line_rep\n end", "def testParseLine\n ep = EiBiScheduleParser.new\n\n line = \"7490;2300-0455;;;WBCQ;E;NA;;;;\"\n bc = ep.parseEiBiTextLine(line)\n assert_equal 7490, bc[:frequency]\n assert_equal \"WBCQ\", bc[:broadcaster]\n assert_equal 23, bc[:startHour]\n assert_equal 0, bc[:startMinute]\n assert_equal 4, bc[:endHour]\n assert_equal 55, bc[:endMinute]\n assert_equal \"NA\", bc[:targetRegion]\n end", "def original_line; end", "def parse_cr data, ix\n ln = (@linebuffer << data[0...ix]).join\n @linebuffer.clear\n\n ln.force_encoding(\"UTF-8\")\n\n receive_line ln\n @outputbuffer.print ln\n\n # jump back to the last line feed\n @outputbuffer.pos = @lf_offset\n\n # parse rest of the data\n parse_crlf data[(ix+1)..-1]\n end", "def bgnstr_record() @records.get(GRT_BGNSTR); end", "def tokenize ln, line\r\n pure_line = line.gsub(/^#{regex_line_comment}/, '') # trim line comment marker\r\n\r\n indent_level = 0\r\n processor_name = '_raw'\r\n line_code = ''\r\n block_open = false\r\n if matches = /#{regex_proc_line}/.match(pure_line) \r\n processor_name = matches[\"processor_name_\"]\r\n indent_level = matches[\"leading_spaces_\"].size\r\n line_code = matches[\"line_code_\"]\r\n block_open = true if /#{regex_block_start}\\s*$/ =~ line_code\r\n line_code.gsub!(/\\s*(#{regex_block_start})?\\s*$/, '') \r\n elsif matches = /^#{regex_proc_head}[^\\s]/.match(pure_line) \r\n indent_level = matches[\"leading_spaces_\"].size\r\n end\r\n\r\n Token.new ln, line, indent_level, processor_name, line_code, block_open \r\n end", "def parse_line\n s0 = @scanner.pos\n match_spaces\n s2 = parse_te\n if s2 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s4 = @scanner.pos\n s5 = parse_fugou\n if s5 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n s6 = parse_from\n if s6 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n @reported_pos = s4\n s4 = transform_teban_fugou_from(s2, s5, s6)\n end\n end\n if s4 == :failed\n s4 = @scanner.pos\n s5 = []\n s6 = match_regexp(/[^\\r\\n ]/)\n while s6 != :failed\n s5 << s6\n s6 = match_regexp(/[^\\r\\n ]/)\n end\n @reported_pos = s4\n s4 = s5.join\n end\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s6 = parse_time\n s6 = nil if s6 == :failed\n match_str('+')\n if parse_nl == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'move' => s4, 'time' => s6 }\n end\n end\n end\n s0\n end", "def get_log_time(line)\n data_string = line.match(/[\\w]*[\\s]*[\\w]*[\\s]*[^\\s]*/)[0]\n # the year is not included, so this will fail if the current year is different\n # for now we'll hack it to be the current year\n date = DateTime.parse(\"#{data_string} #{REPORT_YEAR}\")\nend", "def convert_record(line)\n record = line.split(' ')\n if record[1] == 'A' || record[1] == 'AAAA'\n ip = IPAddr.new record[2]\n name = ip.reverse\n puts name + \". PTR \" + record[0]\n end\nend", "def parseString(s, line, trace, transform)\r\n @sp = trace\r\n @transform = transform\r\n sent,new_sent = parseSentance(s, line, trace)\r\n\r\n matches = parseSentance(s, line, 0)\r\n good_matches = []\r\n matches.each do |match|\r\n sent, new_sent = match\r\n if sent == line\r\n print \"\\n\\n\\nMATCHED!\" + sent.nil?.to_s + \".\" + line + \".\\n\"\r\n print \"tx to:\" + new_sent.to_s + \"\\n\"\r\n else\r\n print \"\\n\\n\\nNO match\" + \".\" + sent.to_s + \".\" + line + \".\\n\"\r\n end\r\n end\r\n end", "def convert_message_line(line)\n line_array = line.split(' ')\n human_timestamp = Time.parse(line_array[0..2].join(' '))\n format(human_timestamp, line_array, 3)\nend", "def get_raw_information\n @infos[RAW]\n end", "def process_line(line)\n return true if line.empty?\n\n chunks = line.split(SPLIT_PATTERN, fmt.length)\n enough_fields?(line) # can raise exception\n\n point = { path: extract_path(chunks),\n value: extract_value(chunks) }\n\n tags = line_tags(chunks)\n\n point.tap do |p|\n p[:tags] = tags unless tags.empty?\n p[:ts] = extract_ts(chunks) if fmt.include?('t')\n p[:source] = extract_source(chunks) if fmt.include?('s')\n p[:interval] = options[:interval] || 'm' if fmt.include?('d')\n end\n end", "def parse_line line, contexts\n line = line.encode Encoding::UTF_8 if encode_lines?\n\n handler = handler_for_line line\n\n handler.process line, contexts\n end", "def raw\n @lines.map(&:first).join(\"\\n\") + \"\\n\"\n end", "def line_code\n @attrs['Line']\n end", "def original_text\n @line\n end", "def parse_bx_line(line)\n @current_train.update_from_cif line\n end", "def _parse_line line\n # note there could be multiple Supplementary cards\n if line[0].start_with? \"Main\"\n @statement.suffix = \"_main\"\n elsif line[0].start_with? \"Supplementary\"\n _new_statement \"_supp\"\n end\n return unless (Date.parse(line[0]) rescue false)\n _write_to_statement line[0], line[1], line[2], line[3]\n end", "def line\n buffer[line_number]\n end", "def grab_sin(string)\n string.slice(SIN_NUMBER) \nend", "def translate(line)\n if line[0, 3].upcase == \"A2P\"\n return to_phonetic(line[4..-1])\n elsif line[0, 3].upcase == \"P2A\"\n return from_phonetic(line[4..-1])\n end\n end", "def parse_time(row)\n raw_time = row[1]\n if raw_time\n time = \"#{raw_time[0..4]}#{raw_time[-2..-1].downcase!}\"\n\n # remove leading 0\n time = time[1..-1] if time[0] === '0'\n time\n else\n nil\n end\nend", "def parse_line(line)\n matrix(line)\n .each_slice(3)\n .map(&:join)\n end", "def fromStateString(line, s)\n\ti = s\n\tuntil line[i] == '\t' || i == line.length\n\t\ti = i+1\n\t\tif i>7\n\t\t\tputs 'ERROR: cannot read line in fromStateString'\n\t\t\treturn -1\n\t\tend\n\tend\n\treturn line[s..i-1]\nend", "def encoding_line; end", "def match_general(line, lineno, file)\n rec = nil\n if (md = match_general_regex(file).match(line))\n label = md[1]\n text = md[2]\n rec = Note.new(self, file, label, lineno, text, remark(file))\n end\n rec\n end", "def add_line(char_array)\n if @raw_data.length == 3\n return\n end\n\n @raw_data << char_array\n\n if @raw_data.length == 3\n parse_char\n end\n end", "def process_line(buf) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/AbcSize\n query = buf.chomp.chomp(';')\n begin\n ffi_query = ffi_polar.new_query_from_str(query)\n rescue ParseError => e\n print_error(e)\n return\n end\n\n begin\n results = Query.new(ffi_query, host: host).results.to_a\n rescue PolarRuntimeError => e\n print_error(e)\n return\n end\n\n if results.empty?\n puts false\n else\n results.each do |result|\n if result.empty?\n puts true\n else\n result.each do |variable, value|\n puts \"#{variable} = #{value.inspect}\"\n end\n end\n end\n end\n end", "def parse_line(line)\n results = LineRegexp.match(line)\n if results \n @elements[:line] = results[-1]\n results[-1] # remaining line \n else\n @elements[:line] = line\n line \n end\n end", "def line\n end" ]
[ "0.587391", "0.58448356", "0.56759423", "0.56545967", "0.56508857", "0.56350976", "0.5508815", "0.55046046", "0.54666936", "0.5457123", "0.5401766", "0.53997487", "0.53987557", "0.539206", "0.535403", "0.5327109", "0.5318762", "0.5295599", "0.5263337", "0.5259635", "0.5243567", "0.52274996", "0.5223426", "0.5217445", "0.5205477", "0.5198028", "0.515945", "0.5156093", "0.51471955", "0.5139492", "0.51363295", "0.51149327", "0.5114911", "0.5114911", "0.5114911", "0.5114911", "0.5114911", "0.51054156", "0.51020926", "0.50942785", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.5089615", "0.50743353", "0.5062089", "0.5046965", "0.5045161", "0.5013327", "0.5010127", "0.5010127", "0.5010127", "0.49974707", "0.49973294", "0.49931514", "0.49912995", "0.49834538", "0.49689", "0.49658978", "0.49627212", "0.49516976", "0.49511668", "0.49443334", "0.49342868", "0.4932138", "0.49217945", "0.49140584", "0.49113095", "0.4909688", "0.49068725", "0.48974434", "0.48936316", "0.48841694", "0.4869389", "0.4867112", "0.48663867", "0.48637503", "0.4861982", "0.48386788", "0.48384252", "0.4837703", "0.4828538", "0.48211777", "0.4817382", "0.48133218", "0.4813316", "0.48087502", "0.48074237", "0.4806922" ]
0.4841357
89
Compute the smallest edit distance (Levenshtein Distance) of the two token streams
def compute_smallest_edit_distance(eval_stream, ref_stream) m_sz, n_sz = eval_stream.size, ref_stream.size arr = Matrix.build(n_sz+1, m_sz+1) do |row, col| if row == 0 col elsif col == 0 row else 0 end end.to_a puts "[INFO] DP Matrix generated: #{arr.size} x #{arr.first.size}" progress_dots = 0 puts "[INFO] Start computing" for j in 1..m_sz for i in 1..n_sz replace_cost = arr[i-1][j-1] + (eval_stream[j] == ref_stream[i] ? 0 : 1) insert_cost = arr[i][j-1] + 1 delete_cost = arr[i-1][j] + 1 arr[i][j] = [replace_cost, insert_cost, delete_cost].min end print "." progress_dots += 1 print " #{(progress_dots.to_f/m_sz * 100).round(3)}%\n" if (0 == progress_dots % ProgressDotsPerLine) end print "\n" arr[n_sz][m_sz] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def levenshtein_distance(str1, str2)\n s = str1\n t = str2\n n = s.length\n m = t.length\n\n return m if n.zero?\n return n if m.zero?\n\n d = (0..m).to_a\n x = nil\n\n str1.each_char.with_index do |char1, i|\n e = i + 1\n\n str2.each_char.with_index do |char2, j|\n cost = (char1 == char2 ? 0 : 1)\n x = [\n d[j + 1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n ].min\n d[j] = e\n e = x\n end\n\n d[m] = x\n end\n\n x\n end", "def levenshtein_distance(str1, str2)\n s = str1\n t = str2\n n = s.length\n m = t.length\n\n return m if (0 == n)\n return n if (0 == m)\n\n d = (0..m).to_a\n x = nil\n\n str1.each_char.each_with_index do |char1,i|\n e = i + 1\n\n str2.each_char.each_with_index do |char2,j|\n cost = (char1 == char2) ? 0 : 1\n x = min3(\n d[j + 1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n )\n d[j] = e\n e = x\n end\n\n d[m] = x\n end\n\n return x\n end", "def levenshtein_distance(str1, str2)\n s = str1\n t = str2\n n = s.length\n m = t.length\n\n return m if (0 == n)\n return n if (0 == m)\n\n d = (0..m).to_a\n x = nil\n\n str1.each_char.each_with_index do |char1,i|\n e = i+1\n\n str2.each_char.each_with_index do |char2,j|\n cost = (char1 == char2) ? 0 : 1\n x = min3(\n d[j+1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n )\n d[j] = e\n e = x\n end\n\n d[m] = x\n end\n\n return x\n end", "def levenshtein_distance_to(other)\n String::Similarity.levenshtein_distance(self, other)\n end", "def levenshtein_distance_to(other)\n levenshtein_distance(self, other)\n end", "def levenshtein_distance(str1, str2)\n n = str1.length\n m = str2.length\n return m if n.zero?\n return n if m.zero?\n\n d = (0..m).to_a\n x = nil\n\n # to avoid duplicating an enumerable object, create it outside of the loop\n str2_codepoints = str2.codepoints\n\n str1.each_codepoint.with_index(1) do |char1, i|\n j = 0\n while j < m\n cost = (char1 == str2_codepoints[j]) ? 0 : 1\n x = min3(\n d[j + 1] + 1, # insertion\n i + 1, # deletion\n d[j] + cost # substitution\n )\n d[j] = i\n i = x\n\n j += 1\n end\n d[m] = x\n end\n\n x\n end", "def levenshtein_distance str1, str2\n s = str1\n t = str2\n n = s.length\n m = t.length\n max = n/2\n\n return m if (0 == n)\n return n if (0 == m)\n return n if (n - m).abs > max\n\n d = (0..m).to_a\n x = nil\n\n n.times do |i|\n e = i+1\n\n m.times do |j|\n cost = (s[i] == t[j]) ? 0 : 1\n x = [\n d[j+1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n ].min\n d[j] = e\n e = x\n end\n\n d[m] = x\n end\n\n return x\n end", "def rlevenshtein(str1, str2)\n return 0 if (str1 == \"\" || str2 == \"\")\n return ([str1.length, str2.length].max - levenshtein(str1, str2)) / [str1.length, str2.length].min.to_f\n end", "def levenshtein_distance(string1, string2)\n ld = Class.new.extend(Gem::Text).method(:levenshtein_distance)\n\n ld.call(string1, string2)\n end", "def levenshtein_similarity_to(other)\n String::Similarity.levenshtein(self, other)\n end", "def levenshtein_distance(first, second)\n matrix = [(0..first.length).to_a]\n (1..second.length).each do |j|\n matrix << [j] + [0] * first.length\n end\n\n (1..second.length).each do |i|\n (1..first.length).each do |j|\n matrix[i][j] = if first[j - 1] == second[i - 1]\n matrix[i - 1][j - 1]\n else\n [\n matrix[i - 1][j],\n matrix[i][j - 1],\n matrix[i - 1][j - 1]\n ].min + 1\n end\n end\n end\n matrix.last.last\n end", "def shortest(word1, word2)\n word1_indices = @hash[word1]\n word2_indices = @hash[word2]\n\n dis = @size\n i, j = 0, 0\n while word1_indices[i] && word2_indices[j]\n dis = [dis, (word1_indices[i] - word2_indices[j]).abs].min\n if word1_indices[i] < word2_indices[j]\n i += 1\n else\n j += 1\n end\n end\n\n return dis\n end", "def min_distance(word1, word2)\n edit = Array.new(word1.size + 1) {\n Array.new(word2.size + 1)\n }\n \n (0..word1.size).each { |i|\n edit[i][0] = i\n }\n\n (0..word2.size).each { |i|\n edit[0][i] = i\n }\n\n (1..word1.size).each { |i|\n (1..word2.size).each { |j|\n if word1[i - 1] == word2[j - 1]\n edit[i][j] = edit[i - 1][j - 1]\n else\n edit[i][j] = 1 + [edit[i - 1][j] || 0, edit[i][j - 1] || 0, edit[i - 1][j - 1] || 0].min\n end\n }\n }\n\n edit[word1.size][word2.size]\nend", "def levenshtein(first, second)\n m, n = first.length, second.length\n return m if n == 0\n return n if m == 0\n\n # Create our distance matrix\n d = Array.new(m+1) {Array.new(n+1)}\n 0.upto(m) { |i| d[i][0] = i }\n 0.upto(n) { |j| d[0][j] = j }\n\n 1.upto(n) do |j|\n 1.upto(m) do |i|\n d[i][j] = first[i-1] == second[j-1] ? d[i-1][j-1] : [d[i-1][j]+1,d[i][j-1]+1,d[i-1][j-1]+1,].min\n end\n end\n d[m][n]\nend", "def string_distance(word1, word2, max: 3, th: 3)\n d = DamerauLevenshtein.distance(word1, word2, 1, max)\n (d - [word1.length, word2.length].min).abs < th ? nil : d\nend", "def get_distance(s1, s2)\n a1 = s1.split(//)\n a2 = s2.split(//)\n\n max, min = s1.size > s2.size ? [a1, a2] : [a2, a1]\n\n range = [(max.size / 2 - 1), 0].max\n indexes = Array.new(min.size, -1)\n flags = Array.new(max.size, false)\n\n matches = 0\n (0...min.size).each do |mi|\n c1 = min[mi]\n ([mi - range, 0].max...[mi + range + 1, max.size].min).each do |i|\n next unless !flags[i] && c1 == max[i]\n\n indexes[mi] = i\n flags[i] = true\n matches += 1\n break\n end\n end\n\n ms1 = Array.new(matches, nil)\n ms2 = Array.new(matches, nil)\n\n si = 0\n (0...min.size).each do |i|\n if indexes[i] != -1\n ms1[si] = min[i]\n si += 1\n end\n end\n\n si = 0\n (0...max.size).each do |i|\n if flags[i]\n ms2[si] = max[i]\n si += 1\n end\n end\n\n transpositions = 0\n (0...ms1.size).each do |mi|\n transpositions += 1 if ms1[mi] != ms2[mi]\n end\n\n prefix = 0\n (0...min.size).each do |mi|\n prefix += 1 if s1[mi] == s2[mi]\n break unless s1[mi] == s2[mi]\n end\n\n if 0 == matches\n 0.0\n else\n m = matches.to_f\n t = (transpositions / 2)\n j = ((m / s1.size) + (m / s2.size) + ((m - t) / m)) / 3.0\n return j < THRESHOLD ? j : j + [0.1, 1.0 / max.size].min * prefix * (1 - j)\n end\n end", "def edit_distance(v,w)\n <<-DOC\n In 1966, Vladimir Levenshtein introduced the notion of the edit distance between two strings as the minimum number of edit operations \n needed to transform one string into another.\n Sample Input:\n PLEASANTLY\n MEANLY\n Sample Output:\n 5\n\n # http://en.wikipedia.org/wiki/Levenshtein_distance\n DOC\n\n\n s = []\n (0..(v.length)).each {|i| s[i] = []}\n (0..(v.length)).each {|i| s[i][0] = i}\n (0..(w.length)).each {|j| s[0][j] = j}\n\n (1..(v.length)).each do |i|\n (1..(w.length)).each do |j|\n if v[i] == w[j] \n s[i][j] = s[i-1][j-1]\n else\n s[i][j] = [s[i-1][j]+1, s[i][j-1]+1, s[i-1][j-1]+1].min\n end\n end\n end\n puts s[v.length][w.length]\n end", "def levenshtein(str1, str2)\n m = str1.length\n n = str2.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m+1) {Array.new(n+1)}\n (0..m).each { |i| d[i][0] = i}\n (0..n).each { |j| d[0][j] = j}\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if str1[i-1] == str2[j-1] # adjust index into string\n d[i-1][j-1] # no operation required\n else\n [ d[i-1][j]+1, # deletion\n d[i][j-1]+1, # insertion\n d[i-1][j-1]+1, # substitution\n ].min\n end\n end\n end\n return d[m][n]\n end", "def nonCacheEditDistance(word1, word2)\n if (defined?(MAX_LEVENSHTEIN_DISTANCE) && MAX_LEVENSHTEIN_DISTANCE)\n return nonCacheEditDistanceHelper(word1, word2, 0, MAX_LEVENSHTEIN_DISTANCE)\n else\n return nonCacheEditDistanceHelper(word1, word2, 0, 999)\n end\n end", "def transformation_distance(str1, str2)\n # puts \"#{@count += 1}\"\n\n str1,str2 = str1.downcase, str2.downcase\n # Dont need to compute if it has already been computed earlier, return from the aux hash.\n return @aux[\"#{str1}_#{str2}\"] if !(@aux[\"#{str1}_#{str2}\"].nil?)\n\n # if one string is empty, return the length of other string - obviously!\n return (@aux[\"#{str1}_#{str2}\"] = str2.size) if str1.empty?\n return (@aux[\"#{str1}_#{str2}\"] = str1.size) if str2.empty?\n\n \n # reduced_str denotes the last character removed from the original string.\n reduced_str1 = str1.size==1 ? \"\" : str1[0..-2]\n reduced_str2 = str2.size==1 ? \"\" : str2[0..-2]\n\n # Levenshtein algorithm:\n cost = (str1[-1] == str2[-1]) ? 0 : 1\n return (@aux[\"#{str1}_#{str2}\"] = [transformation_distance(reduced_str1,str2) + 1,\n transformation_distance(str1,reduced_str2) + 1,\n transformation_distance(reduced_str1, reduced_str2) + cost].min)\nend", "def shortest(word1, word2)\n \n end", "def str_sim(other)\n max = Math.max(self.size, other.size)\n min = (self.size - other.size).abs.to_f\n 1 - (self.levenshtein(other)-min) / (max - min)\n end", "def shortest(word1, word2)\n ans = @M\n for i in @d[word1]\n for j in @d[word2]\n ans = [ans, (i-j).abs].min\n end\n end\n return ans\n end", "def levenshtein_distance(s, t)\n m = s.length\n n = t.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m+1) {Array.new(n+1)}\n\n (0..m).each {|i| d[i][0] = i}\n (0..n).each {|j| d[0][j] = j}\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if s[i-1] == t[j-1] # adjust index into string\n d[i-1][j-1] # no operation required\n else\n [ d[i-1][j]+1, # deletion\n d[i][j-1]+1, # insertion\n d[i-1][j-1]+1, # substitution\n ].min\n end\n end\n end\n d[m][n]\nend", "def levenshtein_distance(s, t)\n m = s.length\n n = t.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m+1) { Array.new(n+1) }\n\n (0..m).each { |i| d[i][0] = i }\n (0..n).each { |j| d[0][j] = j }\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if s[i-1] == t[j-1] # adjust index into string\n d[i-1][j-1] # no operation required\n else\n [d[i-1][j]+1, # deletion\n d[i][j-1]+1, # insertion\n d[i-1][j-1]+1, # substitution\n ].min\n end\n end\n end\n d[m][n]\nend", "def min_distance(word1, word2)\n dp = Array.new(word1.size + 1) { Array.new(word2.size + 1) }\n\n # increment values in 1st row and col\n (0...dp.size).each do |i|\n dp[i][0] = i\n end\n (0...dp[0].size).each do |j|\n dp[0][j] = j\n end\n\n (1...dp.size).each do |i|\n (1...dp[0].size).each do |j|\n dp[i][j] = if word1[i - 1] == word2[j - 1]\n # if chars are same, value will be from diagonal upward\n dp[i - 1][j - 1]\n else\n [\n dp[i - 1][j - 1],\n dp[i][j - 1],\n dp[i - 1][j]\n ].min + 1\n end\n end\n end\n dp[-1][-1]\nend", "def distance(str1, str2, max_distance = T.unsafe(nil)); end", "def levenshtein_distance(s, t)\n m = s.length\n n = t.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m + 1) { Array.new(n + 1) }\n\n (0..m).each { |i| d[i][0] = i }\n (0..n).each { |j| d[0][j] = j }\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if s[i - 1] == t[j - 1] # adjust index into string\n d[i - 1][j -1] # no operation required\n else\n [d[i - 1][j]+1, # deletion\n d[i][j - 1]+1, # insertion\n d[i - 1][j - 1]+1, # substitution\n ].min\n end\n end\n end\n\n d[m][n]\n end", "def dynamicEditDistance(str1, str2)\n matrix = Array.new(str1.length + 1) { Array.new(str2.length + 1) }\n\n # Set up first row of matrix\n (0...matrix[0].length).each do |i|\n matrix[0][i] = i\n end\n\n # Set up first column of matrix\n (0...matrix.length).each do |i|\n matrix[i][0] = i\n end\n\n # Build the matrix\n (1..str1.length).each do |i|\n (1..str2.length).each do |j|\n # If the current letters are the same, we take the old value\n # since there is no edit distance. Otherwise, we take the minimum\n # of the three values of substituion, deletion, or insertion\n if str1[i-1] == str2[j-1]\n matrix[i][j] = matrix[i-1][j-1]\n else\n matrix[i][j] = 1 + min(matrix[i-1][j-1], matrix[i-1][j], matrix[i][j-1])\n end\n end\n end\n\n return matrix[str1.length][str2.length]\nend", "def compute(left_strand,right_strand)\n return 0 if left_strand == right_strand\n\n left_chars = left_strand.chars\n right_chars = right_strand.chars\n\n distance = 0\n\n left_chars.each_with_index do |left_char,idx|\n right_char = right_chars[idx]\n break if right_char.nil? # ignore extra length on first strand when longer\n\n distance += 1 unless left_char == right_char\n end\n\n distance\n end", "def min_distance(word1, word2)\n dp = Array.new(word1.size + 1) { Array.new(word2.size + 1) }\n \n for i in 0...dp.size\n dp[i][0] = i \n end\n for j in 0...dp[0].size\n dp[0][j] = j\n end\n \n for i in 1...dp.size\n for j in 1...dp[0].size\n if word1[i - 1] == word2[j - 1]\n dp[i][j] = dp[i-1][j-1]\n else\n dp[i][j] = [\n dp[i - 1][j],\n dp[i][j - 1],\n dp[i - 1][j - 1],\n ].min + 1\n end\n end\n end\n \n dp[-1][-1]\nend", "def damerau_levenshtein(other)\n n, m = self.length, other.length\n return m if n == 0\n return n if m == 0\n matrix = Array.new(n+1) do |i|\n Array.new(m+1) do |j|\n if i == 0 then j\n elsif j == 0 then i\n else 0 end\n end\n end\n (1..n).each do |i|\n (1..m).each do |j|\n cost = (self[i] == other[j]) ? 0 : 1\n delete = matrix[i-1][j] + 1\n insert = matrix[i][j-1] + 1\n substitution = matrix[i-1][j-1] + cost\n matrix[i][j] = [delete, insert, substitution].min\n if (i > 1) && (j > 1) && (self[i] == other[j-1]) && (self[i-1] == other[j])\n matrix[i][j] = [matrix[i][j], matrix[i-2][j-2] + cost].min\n end\n end\n end\n return matrix.last.last\n end", "def levenshtein_distance(s, t)\n m = s.length\n n = t.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m+1) {Array.new(n+1)}\n\n (0..m).each {|i| d[i][0] = i}\n (0..n).each {|j| d[0][j] = j}\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if s[i-1] == t[j-1] # adjust index into string\n d[i-1][j-1] # no operation required\n else\n [ d[i-1][j]+1, # deletion\n d[i][j-1]+1, # insertion\n d[i-1][j-1]+1, # substitution\n ].min\n end\n end\n end\n d[m][n]\n end", "def distance(str1, str2)\n\t\twords1 = str1.downcase.split\n\t\twords2 = str2.downcase.split\n\t\tlen1 = words1.count.to_f\n\t\tlen2 = words2.count.to_f\n\t\tadded = (words2 - words1).count.to_f\n\t\tkept = len1 - (words1 - words2).count.to_f\n\t\treturn 0 if kept == 0\n\t\td = kept/len1\n\t\td *= 1 - (added/len2) unless added == 0\n\t\treturn d\n\tend", "def distance (w1, w2)\n count = 0\n #add a count for every index where the characters are different\n i = 0\n while i < w2.length\n if w1[i].downcase != w2[i].downcase\n count = count + 1\n end\n i = i + 1\n end\n count\n end", "def hamming_distance(a, b)\n raise \"Unequal buffers passed.\" if a.length != b.length\n a.bytes.zip(b.bytes).map { |a, b| (a ^ b).to_s(2) }.join.count('1')\n end", "def str_distance(str1, str2)\n end", "def str_distance(str1, str2)\n end", "def ngram_distance(s1, s2, n = 2)\n result = C::ngram_distance(s1, s2, n)\n raise(\"memory allocation error\") if result == -1\n result\n end", "def str_distance(str1, str2)\n return @str_cache[str1][str2] if @str_cache[str1][str2]\n return str1.length if str2.nil?\n return str2.length if str1.nil?\n\n if str1 == str2\n @str_cache[str1][str2] = 0\n return 0\n end\n\n if str1[0] == str2[0]\n @str_cache[str1][str2] = str_distance(str1[1..-1], str2[1..-1])\n else\n replace_dist = 1 + str_distance(str1[1..-1], str2[1..-1])\n delete_dist = 1 + str_distance(str1[1..-1], str2)\n insert_dist = 1 + str_distance(str1, str2[1..-1])\n @str_cache[str1][str2] = [replace_dist, delete_dist, insert_dist].min\n end\n @str_cache[str1][str2]\n end", "def jaro_distance( s1, s2 )\n jaro_distance_internal( Input.new( s1, s2 ) )\n end", "def fanalyze(s1, s2=nil)\n res = \"Total Length: %d\\n\" % [s1.size]\n res += \"Distance: %f\\n\" %\n [Levenshtein.distance(s1, s2).to_f / s2.size.to_f] if s2 != nil\n res += \"Avg Word Length: %f\\n\" % [avgwordlen(s1)]\n res += \"Entropy: %d\\n\" % [entropy(s1)]\n (1..3).inject(res) do |res, i|\n res + \"%d-grams:\\n%s\\n\" % [i, ngrams(s1, i).indent(4)]\n end\nend", "def hamming_distance(first_word, second_word)\n if first_word.length == second_word.length\n first_word = first_word.split('')\n second_word = second_word.split('')\n distance = 0\n first_word.each_with_index do |a, i|\n if a != second_word[i]\n distance += 1\n end\n end\n distance\n else\n nil\n end\nend", "def str_distance(str1, str2)\n ans = str_distance_helper(str1, str2)\n @dist_cache = Hash.new { |hash, key| hash[key] = {} }\n ans\n end", "def edit_distance_similarity (target)\n return 1-(self.edit_distance(target) / [self.length, target.length].max.to_f)\n end", "def calculate_distance(translated_text, answer)\n DamerauLevenshtein.distance(prepare(translated_text), prepare(answer))\n end", "def get_score(arr1, arr2)\n score = 0\n\n min = arr1\n\n if arr2.length < arr1.length\n min = arr2\n end\n\n for i in 0..min.length\n if !arr1[i].nil? && !arr2[i].nil?\n score += Levenshtein.distance(arr1[i], arr2[i]) \n end\n end\n\n return score\n end", "def hamming_distance str1, str2\n result = 0\n \n str1.split('').each_index do |i|\n result += 1 if str1[i] != str2[i]\n end\n\n p result\nend", "def str_distance(str1, str2)\n return str2.length unless str1\n return str1.length unless str2\n return @str_cache[str1][str2] if @str_cache[str1][str2]\n\n if str1 == str2\n dist = 0\n elsif str1[0] == str2[0]\n dist = str_distance(str1[1..-1], str2[1..-1])\n else\n move_both = 1 + str_distance(str1[1..-1], str2[1..-1])\n move_left = 1 + str_distance(str1[1..-1], str2)\n move_right = 1 + str_distance(str1, str2[1..-1])\n dist = [move_both, move_left, move_right].min\n end\n\n @str_cache[str1][str2] = dist\n end", "def similarity_to other, threshold = nil\n Babushka::Levenshtein.distance self, other, threshold\n end", "def edit_distance(str1, str2)\n m = str1.length\n n = str2.length\n\n i = 0\n dp = []\n while i < m do\n j = 0\n while j < n do\n if i == 0\n dp[i][j] = j\n elsif j == 0\n dp[i][j] = i\n elsif str1[i-1] == str2[j-1]\n dp[i][j] = dp[i-1][j-1]\n else\n dp[i][j] = [dp[i-1][j-1], dp[i-1][j], dp[i][j-1] ].min + 1\n end\n j += 1\n end\n i += 1\n end\n puts dp[m][n]\nend", "def msd_similarity(origin, msd)\n intersection = if origin.pos == msd.pos\n origin.grammemes.inject(0) do |sim, (k, v)|\n msd[k] == v ? sim + 1 : sim\n end\n else\n 0\n end\n\n union = (origin.grammemes.keys | msd.grammemes.keys).length\n\n intersection - union\n end", "def anagram_distance(word1, word2)\n if word1.length != word2.length\n return -1;\n end\n\n hash = {};\n\n word1.each_char do |ch|\n hash[ch] = hash[ch].nil? ? 1 : hash[ch]+1\n end\n\n word2.each_char do |ch|\n if !hash[ch].nil? && hash[ch] > 0\n hash[ch] -=1\n end\n end\n\n hash.values.sum\nend", "def distance(str1, str2)\n validate(str1)\n validate(str2)\n ffi_distance(str1, str2)\n end", "def jaro_distance(s1, s2)\n result = C::jaro_distance(s1, s2)\n raise(\"memory allocation error\") if result < 0.0\n result\n end", "def distance(other)\n ('A'..'Z').inject(0) { |acc, i| acc + (frequency(i) - other.frequency(i))**2}\n end", "def common_neighbours(str1, str2)\n pairs1 = get_bigrams(str1)\n pairs2 = get_bigrams(str2)\n union = pairs1.length + pairs2.length;\n hit_count = 0\n pairs1.each{ |pair1|\n pairs2.each{ |pair2|\n hit_count += 1 if pair1 == pair2\n }\n }\n #return (2.0 * hit_count) / union.to_f\n return ((2.0 * hit_count) / union.to_f) / [str1.length, str2.length].min.to_f # -1)\n end", "def find(str1, str2)\n min_distance = 999\n return min_distance unless @hash.has_key?(str1) && @hash.has_key?(str2)\n\n pos1, pos2 = @hash[str1], @hash[str2]\n # Given two sorted arrays of equal length, how do you find a\n # pair of numbers, one from each array, such that the absolute\n # difference between the two numbers is minimum.\n\n i, j = 0, 0\n until i == pos1.size || j == pos2.size\n diff = (pos1[i] - pos2[j]).abs\n min_distance = diff if diff < min_distance\n if pos1[i] < pos2[j]\n i += 1\n else\n j += 1\n end\n end\n\n min_distance\n end", "def distance( s1, s2 )\n input = Input.new( s1, s2 )\n return empty_score( input ) if input.empty?\n score = jaro_distance_internal( input )\n\n if score > boost_threshold then\n score += winkler_score( input, score )\n end\n return score\n end", "def shared_words(other_text, min_word_length, distance: 0)\n if (distance > 0) then\n @word_array.each do |word|\n other_text.word_array.each do |other|\n if (damlev(word, other) > distance) then\n intersection << word\n intersection << other\n end\n end\n end\n else\n intersection = (@word_array & other_text.word_array)\n end\n intersection = intersection.reject{ |word| word.length < min_word_length }\n return intersection\n end", "def compare_two_seq2(sequence1 = \"\", sequence2 = \"\")\n aln_seq = muscle_sequence2(sequence1,sequence2)\n seq1 = aln_seq[0]\n seq2 = aln_seq[1]\n length = seq1.size\n diff = 0\n (0..(length-1)).each do |position|\n nt1 = seq1[position]\n nt2 = seq2[position]\n diff += 1 unless nt1 == nt2\n end\n return diff\nend", "def similarity_to(other,options={})\n shared_words = shared_words_with(other,options)\n shared_words.length * 2.0 / (words.length + other.words.length)\n end", "def percent_match(other)\n max = [length, other.length].max\n 1.0 - levenshtein_distance_to(other).to_f / max\n end", "def score(s, d)\n i, j, k = deflate(s).length, deflate(d).length, deflate(s + d).length\n # how to calculate significance of similarity?\n k < (i + j)\n end", "def distance a, b\n (a[0] - b[0]).abs + (a[1] - b[1]).abs\n end", "def for_fs_sake(string)\n words = string.split\n min_f_distance = nil\n min_f_word = \"\"\n\n words.each do |word|\n current_f_distance = find_f_distance(word)\n if current_f_distance && (min_f_distance.nil? || current_f_distance < min_f_distance)\n min_f_distance = current_f_distance\n min_f_word = word\n end\n end\n\n min_f_word\nend", "def euclidean_distance(s1, s2)\n d2 = 0.0\n get_features.each do |f|\n if s1.has_key? f and s2.has_key? f\n d2 += (s1[f]-s2[f])**2\n end\n end\n \n Math.sqrt(d2)\n end", "def str_distance(str1, str2, dist_cache = Hash.new { |hash, key| hash[key] = {} })\n return dist_cache[str1][str2] if dist_cache[str1][str2]\n\n l1, l2 = str1.length, str2.length\n\n if str1 == \"\"\n count = str2.length\n elsif str2 == \"\"\n count = str1.length\n elsif str1[0] == str2[0]\n count = str_distance(str1.slice(1, l1), str2.slice(1, l2), dist_cache)\n else\n test1 = str_distance(str1.slice(1, l1), str2.slice(1, l2), dist_cache)\n\n if l1 > l2\n test2 = str_distance(str1.slice(1, l1), str2, dist_cache)\n else\n test2 = str_distance(str1, str2.slice(1, l2), dist_cache)\n end\n\n count = 1 + [test1, test2].min\n end\n\n dist_cache[str1][str2] = count\n count\n end", "def invert_levenshtein1(a, b)\n row\t= (0..a.length).to_a\n 1.upto(b.length) do |y|\n prow = row\n row = [y]\n\n 1.upto(a.length) do |x|\n row[x] = [\n prow[x],\n row[x-1],\n prow[x-1] - (a[x-1] == b[y-1] ? 1 : 0)\n ].min\n end\n end\n\n row[-1]\n end", "def diff_ratio( other )\n return 0.0 if self == other\n return 1.0 if empty? || other.empty?\n\n s_words = self.words( true )\n o_words = other.words( true )\n\n common = (s_words & o_words).size.to_f\n union = (s_words | o_words).size.to_f\n\n (union - common) / union\n end", "def human_distance(other)\n distance_to(other).round(1)\n end", "def dist first, second\n first = first.is_a? Atom ? frac(first.pos(false)) : first.to_v\n second = second.is_a? Atom ? frac(second.pos(false)) : second.to_v\n real((first - second).map{|v| v = v % 1; v > 0.5 ? 1 - v : v}).magnitude\n end", "def shortest_nonshared_substrings s1, s2\n i = 1\n distinct = Set.new\n while i < [s1.length, s2.length].min and distinct.empty?\n distinct = distinct_kmers(i, s1, s2)\n i += 1\n end\n distinct\nend", "def calculate_similarity(other_doc)\n self.terms.inject(0.0) do |dot_product, term|\n dot_product + (self.tfidf(term.word) * other_doc.tfidf(term.word))\n end\n end", "def distance_from(other)\n\t\t\trlong1 = self.longitude * D2R\n\t\t\trlat1 = self.latitude * D2R\n\t\t\trlong2 = other.longitude * D2R\n\t\t\trlat2 = other.latitude * D2R\n\t\t\t\n\t\t\tdlon = rlong1 - rlong2\n\t\t\tdlat = rlat1 - rlat2\n\t\t\t\n\t\t\ta = Math::sin(dlat/2) ** 2 + Math::cos(rlat1) * Math::cos(rlat2) * Math::sin(dlon/2) ** 2\n\t\t\tc = 2 * Math::atan2(Math::sqrt(a), Math::sqrt(1-a))\n\t\t\td = R * c\n\t\t\t\n\t\t\treturn d\n\t\tend", "def closest_match(token, library, cache)\n if cache.has_key?(token)\n return cache[token]\n end\n closest_tokens = []\n closest_token_score = 999\n library.each do |entity|\n ld_score = levenshtein_distance(token, entity)\n if ld_score < closest_token_score\n closest_token_score = ld_score\n closest_tokens = [entity]\n elsif ld_score == closest_token_score\n closest_tokens << entity\n end\n end\n cache[token] = {closest_token_score => closest_tokens}\n {closest_token_score => closest_tokens}\nend", "def hamming_distance(string1, string2)\n h = 0\n (0..string1.length - 1).each do |i|\n h += 1 if string1[i] != string2[i]\n end\n h\nend", "def closest_match(tokenstream, preference=:none)\n token_locs=self.apply_to(tokenstream)\n return find_closest_match(token_locs, tokenstream.label_index)\n end", "def distance(p1, p2)\n if p1[0] == p2[0]\n distance(p1[1..-1], p2[1..-1])\n else\n # pp p1\n # pp p2\n p1.length + p2.length - 2\n end\nend", "def string_distance_chunked(word, phrase, max: 3, th: 3)\n phrase.split(/\\W|_/i).reject{ |chunk| chunk.strip.empty? }.map{ |chunk|\n string_distance(word, chunk, max: max, th: th)\n }.compact.min\nend", "def jaro_winkler_distance(s1, s2, long_tolerance = false)\n result = C::jaro_winkler_distance(s1, s2, long_tolerance)\n raise(\"memory allocation error\") if result < 0.0\n result\n end", "def distance_to(other)\n self.to_i ^ other.to_i\n end", "def short_long_short(str1, str2)\n arr = [str1, str2].sort_by(&:length)\n\n arr[0] + arr[1] + arr[0]\nend", "def tokenizer_relay_header_distance\n TokenExtractor.new(\n :distance,\n /\\dx\\d{2,3}\\s+(stile|mi|sl|mx)/i,\n 4 # (max size)\n )\n end", "def tokenizer_relay_header_distance\n TokenExtractor.new(\n :distance,\n /\\dx\\d{2,3}\\s+(stile|mi|sl|mx)/i,\n 4 # (max size)\n )\n end", "def point_mutations(string1, string2)\n # keep track of the differences between the two strings\n difference = 0\n\n # Loop through the 1st string, storing each of the indexes and letters into variables\n string1.chars.each_with_index do |letter, index|\n puts \"letter: #{letter}, index: #{index}\"\n\n # if the current letter of string1 is not the same as the corresponding letter in string2, increment the difference variable by 1\n if letter != string2[index]\n difference += 1\n end\n \n end # string1\n\n puts \"The hamming distance between #{string1} and #{string2} is #{difference}.\"\n\nend", "def Compute_Edit_Distance(other_tree, w)\n\t\tnum_mats = @key_roots.size\n\t\t@dist_mats = Array.new(num_mats)\n\t\t@dist_mats[0]=Array.new(@post_order_list.size)\n\t\tfor i in 0...@post_order_list.size\n\t\t\t@dist_mats[0][i]=Array.new(other_tree.post_order_list.size)\n\t\t\tfor j in 0...other_tree.post_order_list.size\n\t\t\t\t@dist_mats[0][i][j]=Cell.new\n\t\t\tend\n\t\tend\n\t\t@tree_dist=@dist_mats[0] # for easier reference\n\t\t\n\t\tcurr_matrix_index=1\n\t\tfor i in 0...@key_roots.size\n\t\t\tfor j in 0...other_tree.key_roots.size\n\t\t\t\tTree_Distance(@key_roots[i].po_num, other_tree.key_roots[j].po_num, other_tree, curr_matrix_index, w)\n\t\t\t\tcurr_matrix_index+=1\n\t\t\tend\n\t\tend\n\t\t\n\t\t#FOR DEBUGGING\n\t\tputs \"Final tree_dist\"\n\t\tfor i in 0...@post_order_list.size\n\t\t\tstr = \"\"\n\t\t\tfor j in 0...other_tree.post_order_list.size\n\t\t\t\tstr = str + @tree_dist[i][j].cost.to_s + \" \"\n\t\t\tend\n\t\t\tputs str\n\t\tend\n\t\t\n\t\tputs \"\"\n\t\t\n\t\tputs \"Mappings\"\n\t\ta = Alignment.new\n\t\tMapping(@tree_dist[@post_order_list.size-1][other_tree.post_order_list.size-1].back_ptrs[0], a)\n\t\treturn a\n\tend", "def compare_two_seq(seq1 = \"\", seq2 = \"\")\n length = seq1.size\n diff = 0\n (0..(length-1)).each do |position|\n nt1 = seq1[position]\n nt2 = seq2[position]\n diff += 1 unless nt1 == nt2\n end\n return diff\nend", "def distance_from(other)\n Phashion.hamming_distance(fingerprint, other.fingerprint)\n end", "def similar?(a, b) # rubocop:disable Naming/UncommunicativeMethodParamName\n Levenshtein.normalized_distance(a.downcase, b.downcase) < 0.3 # chosen quasi-randomly ;)\n end", "def distance(v1, v2)\n sum_squares = node_count.times.reduce(0.0) do |sum, i|\n d = v1[i] - v2[i]\n sum + d * d\n end\n Math.sqrt(sum_squares)\n end", "def proximate(p1, p2, distance, search_phrase_1, search_phrase_2)\n if p1 && p2\n\n # Short circuit if the both terms have been found and the distance is Infinity\n return true if distance.equal?(Float::INFINITY)\n\n word_distance = p1 < p2 ? p2 - (p1 + search_phrase_1.split(' ').size - 1) : p1 - (p2 + search_phrase_2.split(' ').size - 1)\n return word_distance <= distance\n end\n false\n end", "def short_long_short(str1, str2)\n short, long = [str1, str2].sort_by(&:length)\n short+long+short\nend", "def longest_shared_substring s1, s2\n sufs1 = all_suffixes(s1)\n root = SuffixTreeNode.new\n sufs1.each{|s| root.add(s)}\n sufs2 = all_suffixes(s2)\n best = []\n sufs2.each do |s|\n nxt = root.overlay(s)\n best = nxt if nxt.length > best.length\n end\n best\nend", "def distance(other)\n (other - self).magnitude.abs\n end", "def for_cs_sake(string)\n words = string.delete(\"!.,?;:\").split(\" \")\n words = words.select { |word| word.include?(\"c\") }\n c_distances = []\n words.each do |word|\n c_distances << find_c_distance(word)\n end\n c_distances\n lowest_c_distance = c_distances.min\n p words.select { |word| find_c_distance(word) == lowest_c_distance }[0]\nend", "def distance_to(token)\n dist = self.xloc - token.xloc\n dist.abs\n end", "def compare(other)\n score = 0.0\n firstname_dist = Levenshtein.distance(normalized_firstname, other.normalized_firstname)\n lastname_dist = Levenshtein.distance(normalized_lastname, other.normalized_lastname)\n\n mod = 1.0\n if lastname_found?\n if normalized_firstname[0] == other.normalized_firstname[0]\n mod += 3.0\n if normalized_firstname.length < 3 or other.normalized_firstname.length < 3\n mod += 3.0\n end\n if lastname_dist == 0\n mod += 4.0\n end\n end\n end\n\n if normalized_firstname.length > 0 and other.normalized_firstname.length > 0\n score += 0.25 * (firstname_dist / (normalized_firstname.length.to_f) + firstname_dist / (other.normalized_firstname.length.to_f)) / mod\n end\n if normalized_lastname.length > 0 and other.normalized_lastname.length > 0\n score += 0.25 * (lastname_dist / (normalized_lastname.length.to_f) + lastname_dist / (other.normalized_lastname.length.to_f))\n end\n\n score\n end", "def similar_two(str, best_dist = 2)\n best_pair = str.first(2)\n # Arbitrarily large distance\n best_so_far = str.map(&:length).max * 42\n\n str.combination(2).each do |a, b|\n next if a.length != b.length\n\n dist = Levenshtein.distance(a, b)\n\n return [a, b] if dist == best_dist\n\n if dist < best_so_far\n best_pair = [a, b]\n best_so_far = dist\n end\n end\n\n best_pair\n end", "def run_diff(a, b)\n\t\t\ta = \"\" if a == nil\n\t\t\tb = \"\" if b == nil\n\t\t\n\t\t\t@a = a\n\t\t\t@b = b\n\t\t\n\t\t\t# run the initial word-based diff\n\t\t\t@worddiff = WordDiff.new(a, b)\n\t\t\n\t\t\tawords = @worddiff.a_words\n\t\t\tbwords = @worddiff.b_words\n\t\t\twdiff = @worddiff.differences\n\t\t\n\t\t\t#\n\t\t\t# now run through all the words in the longest\n\t\t\t# of the sentences, and for words that differ\n\t\t\t# run a character based diff and calculate the differing\n\t\t\t# characters actual position within the sentences\n\t\t\t#\n\t\t\tmax = awords.length\n\t\t\tmax = bwords.length if bwords.length > awords.length\n\t\t\n\t\t\tstr = \"\"\n\t\t\n\t\t\tfor i in 0..max-1\n\t\t\n\t\t\t\tif wdiff.include?(i)\n\t\t\t\t\tdiff_by_char(awords[i], bwords[i]).each do |chardiff|\n\t\t\t\t\t\[email protected](chardiff + str.length)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\n\t\t\t\tstr << \" #{bwords[i]}\"\n\t\t\tend\n\n\t\t\t# return void\t\t\n\t\t\treturn\n\t\tend" ]
[ "0.7502699", "0.74843526", "0.74593514", "0.74559355", "0.73908305", "0.73652923", "0.7277934", "0.708751", "0.7015121", "0.69886535", "0.6924769", "0.68887687", "0.6854668", "0.68144125", "0.67570454", "0.66988224", "0.6660383", "0.6645816", "0.6638259", "0.66046107", "0.6574251", "0.6565622", "0.64858145", "0.6483691", "0.6483142", "0.64641047", "0.646059", "0.645211", "0.6437797", "0.64319617", "0.64121073", "0.639972", "0.63892984", "0.63890374", "0.6366142", "0.63241214", "0.6323997", "0.6323997", "0.62154573", "0.6213754", "0.62028325", "0.6187291", "0.6172215", "0.6162835", "0.6156188", "0.6118586", "0.6115603", "0.607726", "0.60705215", "0.6067491", "0.60471296", "0.6038626", "0.60306406", "0.6025212", "0.6014513", "0.60109866", "0.6007468", "0.6005268", "0.59430736", "0.5929304", "0.59141904", "0.5896336", "0.58828276", "0.58779186", "0.5861543", "0.5852921", "0.5837099", "0.5833755", "0.5817849", "0.5805839", "0.57690686", "0.5761037", "0.5710819", "0.5710747", "0.56902045", "0.5675397", "0.5675101", "0.56748295", "0.5674578", "0.56624943", "0.5645302", "0.5642752", "0.5640224", "0.56088895", "0.56088895", "0.56060016", "0.56052214", "0.5602046", "0.56016195", "0.5598338", "0.5591318", "0.5583772", "0.55719227", "0.5562742", "0.5552387", "0.5547489", "0.5535162", "0.5529988", "0.55213666", "0.55153525" ]
0.6015106
54
Open the two input files, read in by line, and compute their similiarity
def perform(truth_fn, observation_fn) # Preprocess Truth file line_num = 0 File.readlines(truth_fn).each do |text| line_num += 1 if generate_symTable_and_tokens(text, :preprocess_truth_line, $truthTokens).nil? puts "[INFO] Ignore #{truth_fn}:#{line_num} => #{text}" end end # Preprocess Obversation file line_num = 0 File.readlines(observation_fn).each do |text| line_num += 1 if generate_symTable_and_tokens(text, :preprocess_obvervation_line, $observationTokens).nil? puts "[INFO] Ignore #{observation_fn}:#{line_num} => #{text}" end end puts "[INFO] >>> Number of Symbols: #{$symTable.size}" puts "[INFO] >>> Number of Turth Stream Tokens: #{$truthTokens.size}" puts "[INFO] >>> Number of Obversation Stream Tokens: #{$observationTokens.size}" # Compute similarity of the obversation stream against to truth stream if 0 == $truthTokens.size puts "[ERROR] Can not compute similarity. Empty truth values." exit 1 end distance = compute_smallest_edit_distance($observationTokens, $truthTokens) puts "[INFO] >>> Minimal Edit Distance = #{distance}" ($truthTokens.size - distance).to_f / $truthTokens.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sameFile( fileA, fileB )\n\n\n # Both exist.\n return false unless File.exists?( fileA ) and File.exists?( fileB )\n # Both are the same size.\n aBytes = File.stat( fileA ).size\n bBytes = File.stat( fileB ).size\n return false unless aBytes == bBytes\n\n # Random sample comparison.\n same = true\n $options[:samples].times do \n start = rand( aBytes ) \n length = [aBytes, start + SampleSize].min - start + 1\n aSample = File.read( fileA, length, start )\n bSample = File.read( fileB, length, start )\n same = same && aSample == bSample\n end\n return same\nrescue\n STDOUT.puts \"ERROR: Can't read file [#{fileA}]\"\n $errorCount += 1\n return true # So we don't get two messages for the same file\nend", "def sameFile( fileA, fileB )\n\n # If symlinks, make sure they link to the same thing.\n if File.symlink?( fileA ) || File.symlink?( fileB )\n return false unless File.symlink?( fileA ) and File.symlink?( fileB )\n linkA = File.readlink( fileA )\n linkB = File.readlink( fileB )\n return linkA == linkB\n end\n\n # Both exist.\n return false unless File.exists?( fileA ) and File.exists?( fileB )\n # Both are the same size.\n aBytes = File.stat( fileA ).size\n bBytes = File.stat( fileB ).size\n return false unless aBytes == bBytes\n\n # Random sample comparison.\n same = true\n $options[:samples].times do\n start = rand( aBytes )\n length = [aBytes, start + SampleSize].min - start + 1\n aSample = File.read( fileA, length, start )\n bSample = File.read( fileB, length, start )\n same = same && aSample == bSample\n end\n return same\nrescue\n STDOUT.puts \"ERROR: Can't read file [#{fileA}]\"\n $errorCount += 1\n return true # So we don't get two messages for the same file\nend", "def find_same_files\n # loop over find_similar_files groups\n # diff -b file1 file2\n end", "def compare_files(f1, f2)\n begin\n file1 = IO.read f1[:path]\n file2 = IO.read f2[:path]\n rescue => e # file doesn't exists, db have to be updated\n @show.call \"\\t[Error]: #{e} Please update your database\"\n return nil\n end\n # if 100% similarity and files have the same size\n if @options[\"p\"][:value] == 100\n return nil if f1[:size] != f2[:size]\n return 100 * (Algorithms.fdupes_match(file1, f1[:size], file2, f2[:size]) + 1)\n end\n Algorithms.diff(file1, file2)\n end", "def bindiff(file1, file2, tol)\n if tol.nil? then tol = 0 end #Ruby seriously needs to fix this nil/0 shit\n i = 0; small = 0; tol_count = 0; \n f1 = get_file_contents(file1)\n f2 = get_file_contents(file2)\n if f1.length() != f2.length() then\n puts \"The two files are of differing lengths.\"\n if f1.length() < f2.length() then small = f1.length() \n else small = f2.length() end\n end\n while i <= small\n if f1[i] != f2[i] then \n tol_count+=1\n if tol_count > tol then puts \"Files begin to differ at offset 0x#{i.to_s(16)}\" end\n end\n i+=1\n end\n if tol_count == 0 then puts \"Files are exactly the same.\" end\nend", "def file_diff(fn1, fn2)\n result = ''\n File.open(fn1) do |f1|\n File.open(fn2) do |f2|\n while f1.eof? == false && f2.eof? == false\n line1 = f1.gets.chomp\n line2 = f2.gets.chomp\n result << \"<#{line1}\\n>#{line2}\\n\" if line1 != line2\n end\n if f1.eof? == false\n while f1.eof? == false\n line1 = f1.gets\n result << \"<#{line1}\\n\"\n end\n end\n if f2.eof? == false\n while f2.eof? == false\n line2 = f2.gets\n result << \">#{line2}\\n\"\n end\n end\n end\n end\n result\nend", "def file_diff(fn1,fn2)\n result = ''\n File.open(fn1) do |f1|\n File.open(fn2) do |f2|\n while f1.eof? == false and f2.eof? == false\n line1 = f1.gets.chomp\n line2 = f2.gets.chomp\n result << \"<#{line1}\\n>#{line2}\\n\" if line1 != line2\n end\n if f1.eof? == false\n while f1.eof? == false\n line1 = f1.gets\n result << \"<#{line1}\\n\"\n end\n end\n if f2.eof? == false\n while f2.eof? == false\n line2 = f2.gets\n result \">#{line2}\\n\"\n end\n end\n end\n end\n result\nend", "def query_pairwise(seq1, seq2)\n tf = Tempfile.open('sim4')\n tf.print seq1.to_fasta('seq1', 70)\n tf.close(false)\n tf2 = Tempfile.open('seq2')\n tf2.print seq1.to_fasta('seq2', 70)\n tf2.close(false)\n r = exec_local(tf.path, tf2.path)\n tf.close(true)\n tf2.close(true)\n r\n end", "def diff(fn1,fn2)\n result = ''\n f1 = File.open(fn1)\n f2 = File.open(fn2)\n while f1.eof? == false and f2.eof? == false\n line1 = f1.gets\n line2 = f2.gets\n result << \"<#{line1}\\n>#{line2}\\n\" if line1 != line2\n end\n if f1.eof? == false\n while f1.eof? == false\n line1 = f1.gets\n result << \"<#{line1}\\n\"\n end\n end\n if f2.eof? == false\n while f2.eof? == false\n line2 = f2.gets\n result \">#{line2}\\n\"\n end\n end\n f1.close\n f2.close\n result\nend", "def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end", "def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end", "def compare_file(a, b)\r\n return false unless File.size(a) == File.size(b)\r\n File.open(a, 'rb') {|fa|\r\n File.open(b, 'rb') {|fb|\r\n return compare_stream(fa, fb)\r\n }\r\n }\r\n end", "def compare_file(a, b)\n return false unless File.size(a) == File.size(b)\n File.open(a, 'rb') {|fa|\n File.open(b, 'rb') {|fb|\n return compare_stream(fa, fb)\n }\n }\n end", "def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end", "def get_matrix(m1, m2)\n m1_size = m1.size \n m1_rows = m1[0][0].to_i #get rows by looking at first digit\n m1_cols = (m1[0][0].to_s[-1,1]).to_i #get columns by looking at second digit\n m1.shift #get rid of first row in array\n \n if m1_size-1 != m1.size\n puts \"row, and column defintion on line one does not match file in file1\"\n exit\n end\n \n #Build matrix for data file 1\n matrix1 = Matrix.build(m1_rows, m1_cols)\n matrix1 = Matrix.rows(m1)\n\n m2_size = m2.size #determine array size\n m2_rows = m2[0][0].to_i #get rows by looking at first digit\n m2_cols = (m2[0][0].to_s[-1,1]).to_i #get columns by looking at second digit\n m2.shift #get rid of first row in array\n\n if m2_size-1 != m2.size\n puts \"row, and column defintion on line one does not match file in file2\"\n exit\n end\n\n #Lets build the matrix\n matrix2 = Matrix.build(m2_rows, m2_cols)\n matrix2 = Matrix.rows(m2) \n \n begin\n puts \"Matrix from file 1: #{matrix1}\"\n puts \"Matrix from file 2: #{matrix2}\"\n multmatrix = matrix1 * matrix2.transpose\n puts \"m x n matrix: #{multmatrix}\"\n File.open('MatrixOutput.txt', 'w') {|file| file.write(multmatrix)}\n rescue\n puts \"Sorry dimensions don't match up\"\n end\nend", "def files_are_same(file1, file2)\n begin\n File.open(file1, 'rb').read == File.open(file1, 'rb').read\n rescue\n false\n end\nend", "def check_files_similarity(files, extension)\n duplicates = {}\n files.each_with_index do |f1, index|\n next if f1 == nil || index == files.length - 1\n ((index + 1)..(files.length - 1)).each do |j|\n next if files[j] == nil\n f2 = files[j]\n break if @options[\"s\"][:value] == 1 && f1[:size] != f2[:size]\n next if Algorithms.levenshtein(f1[:name], f2[:name]) > @options[\"l\"][:value]\n begin\n result = compare_files(f1, f2)\n rescue => e\n @show.call \"\\t[Not treated]:\\n\\t\\t - #{f1[:path]} \\n\\t\\t - #{f2[:path]} \\n\\t\\t => #{e}\"\n end\n next if result == nil\n f3 = f2.clone\n f3[:similarity] = result\n if (@options[\"p\"][:value] == 100 && result == 100) || (result >= @options[\"p\"][:value])\n # remove one of the file 100% duplicated\n # 2 files 100% duplicated will also be duplicated with other files\n # if sim(a,b) == 100 && sim(a, c) == 100 so sim(a, c) == 100\n files[j] = nil if @options[\"p\"][:value] == 100 && result == 100\n if duplicates.key?(f1[:path])\n duplicates[f1[:path]] << [f3[:path], result]\n else\n duplicates[f1[:path]] = [[f3[:path], result]]\n end\n end\n end\n end\n @show.call \"Process[#{Process.pid}]: Extension #{extension.name} processed!\"\n duplicates\n end", "def _same_contents?(p1, p2)\n contents1 = p1.read.split(\"\\n\").map { |line| line.chomp }\n contents2 = p2.read.split(\"\\n\").map { |line| line.chomp }\n contents1 == contents2\n end", "def similarity\n size1 = pixel_count(@image_path_1)\n size2 = pixel_count(@image_path_2)\n\n if size1 < size2\n big = @image_path_2\n small = @image_path_1\n else\n big = @image_path_1\n small = @image_path_2\n end\n\n min_size = size(small)\n width = min_size[0] * @resize_factor\n height = min_size[1] * @resize_factor\n\n a = \"convert #{Shellwords.escape(small)} #{Shellwords.escape(big)} -resize '#{width}'x'#{height}'\\! MIFF:- | compare -metric AE -fuzz \\\"#{@color_fuzz}%\\\" - null: 2>&1\"\n result = `#{a}`\n\n result.to_i / (width * height)\n end", "def isogram_matcher(isogram1, isogram2)\n \n # get common, get match in same position\n # position\n positions = 0\n i = 0\n while i < isogram1.length\n if isogram1[i] == isogram2[i]\n positions += 1\n end\n i += 1\n end\n \n # common\n common = (isogram1.split(\"\") & isogram2.split(\"\")).length\n common = common - positions\n \n [positions, common]\n \nend", "def load_outputs\n if File.exist?(@reciprocal_hits)\n # puts \"reciprocal output already exists\"\n else\n @query_results = Hash.new\n @target_results = Hash.new\n q_count=0\n t_count=0\n if !File.exists?(\"#{@output1}\")\n raise RuntimeError.new(\"can't find #{@output1}\")\n end\n if !File.exists?(\"#{@output2}\")\n raise RuntimeError.new(\"can't find #{@output2}\")\n end\n if File.exists?(\"#{@output1}\") and File.exists?(\"#{@output2}\")\n File.open(\"#{@output1}\").each_line do |line|\n cols = line.chomp.split(\"\\t\")\n hit = Hit.new(cols, @query_is_prot, @target_is_prot)\n @query_results[hit.query] = [] if !@query_results.has_key?(hit.query)\n @query_results[hit.query] << hit\n q_count += 1\n end\n File.open(\"#{@output2}\").each_line do |line|\n cols = line.chomp.split(\"\\t\")\n hit = Hit.new(cols, @target_is_prot, @query_is_prot)\n @target_results[hit.query] = [] if !@target_results.has_key?(hit.query)\n @target_results[hit.query] << hit\n t_count += 1\n end\n else\n raise \"need to run blast first\"\n end\n end\n [q_count, t_count]\n end", "def byteCompare(f1, f2)\n byteChunk = 1\n file1 = File.open(f1,\"rb\")\n file2 = File.open(f2,\"rb\")\n until file1.eof?\n buffer1 = file1.read(byteChunk).bytes\n buffer2 = file2.read(byteChunk).bytes\n if buffer1!=buffer2\n file1.close\n file2.close\n return false\n end\n #puts buffer1.join(\",\")\n #puts buffer2.join(\",\")\n end\n file1.close\n if !file2.eof?\n file2.close\n return false\n end\n file2.close\n return true\nend", "def compare(f1, f2)\n data = []\n data[0] = JSON.parse File.read f1\n data[1] = JSON.parse File.read f2\n data.each_with_index do |d, i|\n if d.count == 0\n puts \"No data in ##{i+1} file\"\n exit 1\n end\n data[i] = d.map { |row| row['_source'] }\n end\n all = {}\n all_keys = []\n data.each_with_index do |d, i|\n all_keys[i] = {}\n d.each_with_index do |row, r|\n ks = row.keys.sort\n ks.each do |k| \n all_keys[i][k] = 0 unless all_keys[i].key?(k)\n all_keys[i][k] += 1\n all[k] = 0 unless all.key?(k)\n all[k] += 1\n end\n end\n end\n ks = all.keys.sort.join(',')\n ks1 = all_keys[0].keys.sort\n ks2 = all_keys[1].keys.sort\n if ks1 != ks2\n puts \"WARNING: different key sets:\\n#{ks1}\\nnot equal to:\\n#{ks2}\"\n end\n vals1 = all_keys[0].values.uniq\n vals2 = all_keys[1].values.uniq\n puts \"Unique key presence counts in 1st file: #{vals1}\"\n puts \"Unique key presence counts in 2nd file: #{vals2}\"\n skip_keys = ENV['SKIP_KEYS']\n if skip_keys.nil? || skip_keys == ''\n skip_keys = 'metadata__updated_on,metadata__timestamp,metadata__enriched_on'\n elsif skip_keys == \"-\"\n skip_keys = ''\n end\n skip_keys = skip_keys.split(',').map(&:strip)\n skip = {}\n skip_keys.each do |k|\n skip[k] = true\n end\n keys = ENV['KEYS']\n if keys.nil? || keys == ''\n puts \"You should specify keys to check via KEYS='key1,key2,...,keyN', available keys:\\n#{ks}\"\n puts \"You can also specify special value ALLKEYS\"\n puts \"You can specify non-standard keys to skip, default are: metadata__updated_on,metadata__timestamp,metadata__enriched_on\"\n puts \"To specify them use SKIP_KEYS='key1,key2,...,keyN', use 'SKIP_KEYS=- to disable skipping anything\"\n puts \"Will use default key: grimoire_creation_date\"\n keys = 'grimoire_creation_date'\n end\n if keys == 'ALLKEYS'\n keys = ks.split(',')\n else\n keys = keys.split(',').map(&:strip)\n end\n diff = 0\n keys.each do |k|\n next if skip.key?(k)\n values = []\n data.each_with_index do |d, i|\n values[i] = {}\n d.each_with_index do |row, r|\n v = (row[k] || '(nil)').to_s\n values[i][v] = true\n end\n end\n miss1 = {}\n miss2 = {}\n values[1].keys.each do |k|\n unless values[0].key?(k)\n miss1[k] = true\n end\n end\n values[0].keys.each do |k|\n unless values[1].key?(k)\n miss2[k] = true\n end\n end\n if miss1.count > 0 || miss2.count > 0\n puts \"Key: #{k}\"\n diff += 1\n end\n if miss1.count > 0\n puts \"Values from 2nd file missing in 1st file: #{miss1.keys.sort.join(',')}\"\n end\n if miss2.count > 0\n puts \"Values from 1st file missing in 2nd file: #{miss2.keys.sort.join(',')}\"\n end\n end\n puts \"Differences on #{diff} keys specified to check\"\nend", "def filematch(file1, file2)\n system(\"diff #{file1} #{file2} > /dev/null\")\nend", "def filematch(file1, file2)\n system(\"diff #{file1} #{file2} > /dev/null\")\nend", "def path_sim(other)\n path_arr = self.scan(/\\w+/)\n path_arr2 = other.scan(/\\w+/)\n return 0 if path_arr.size == 0 || path_arr2.size == 0\n max_length = Math.max(path_arr.size, path_arr2.size)\n path_overlap = 0 ; 0.upto(max_length-1){|i|\n if path_arr[i] == path_arr2[i]\n path_overlap += 1\n else\n break\n end\n }\n path_overlap / max_length.to_f\n end", "def double_open filename1, filename2\n open( filename1 ) do |f1|\n open( filename2 ) do |f2|\n yield f1, f2\n end\n end\nend", "def compare\n\t\t\t\n\t\t\tDir.foreach(@folder1) do |item|\n\t\t\t\tbegin\n \t\t\t\tnext if item == '.' or item == '..'\n \t\t\t\tfullfilename = File.expand_path(@folder1, item)\n \t\t\t\tthe_hash = Digest::MD5.hexdigest(File.read(File.join(File.expand_path(@folder1), item)))\n \t\t\t\titem = item.downcase\n \t\t\t\tfiledata = FileHashResults.new(item, the_hash, nil)\n \t\t\t\t@filehash[item] = filedata\n \t\t\trescue\n \t\t\t #puts \"Skipped:#{item.inspect}\"\n \t\t\tend\n\t\t\tend\n\n\t\t\tDir.foreach(@folder2) do |item|\n\t\t\t begin\n \t\t\t\tnext if item == '.' or item == '..'\n \t\t\t\tthe_hash = Digest::MD5.hexdigest(File.read(File.join(@folder2, item)))\n \t\t\t\titem = item.downcase\n if(@filehash[item]==nil)\n \t\t\t\t\tfiledata = FileHashResults.new(item, nil, the_hash)\n \t\t\t\t\t@filehash[item] = filedata\n \t\t\t\t\tnext\n \t\t\t\tend\n \t\t\t\t@filehash[item.downcase].file_hash2 = the_hash\n \t\t\trescue\n #puts \"Skipped:#{item.inspect}\"\n end\t\n\t\t\tend\n\t\tend", "def identical?(file1, file2)\n File.identical?(file1, file2)\n end", "def diff_files(file_id1, file_id2)\n\t\t\tfile1 = get_file(file_id1)\n\t\t\tfile2 = get_file(file_id2)\n\t\t\tfile1 = file1.lines\n\t\t\tfile2 = file2.lines\n\n\t\t\treturn ((file1 - file2) + (file2-file1))\n\t\tend", "def compare_two_seq2(sequence1 = \"\", sequence2 = \"\")\n aln_seq = muscle_sequence2(sequence1,sequence2)\n seq1 = aln_seq[0]\n seq2 = aln_seq[1]\n length = seq1.size\n diff = 0\n (0..(length-1)).each do |position|\n nt1 = seq1[position]\n nt2 = seq2[position]\n diff += 1 unless nt1 == nt2\n end\n return diff\nend", "def combine_files(file1, file2)\n new_coverage = combine_coverages(file1.coverage, file2.coverage)\n # NOTE: It is possible that both don't exist but eventually either one does or it's just one of the names that was\n # used in the code\n new_filename = strict_file_exists?(file1.filename) ? file1.filename : file2.filename\n SimpleCov::SourceFile.new(new_filename, new_coverage)\n end", "def diffem\n\t\tputs \"\\nFile 1 [#{file1.size} bytes]\"\n\t\tputs \"File 2 [#{file2.size} bytes]\\n\\n\"\n\n\t\tcount = 0\n\n\t\[email protected]_byte do |byte|\n\t\t\tif byte == @file2[count]\n\t\t\t\tprint sprintf(ColorConstants::BLUE + \"%02x \", byte)\n\t\t\telse\n\t\t\t\tprint sprintf(ColorConstants::RED + \"%02x \", byte)\n\t\t\tend\n\n\t\t\tcount = count+1\n\n\t\t\tif count % 32 == 0\n\t\t\t\tprint \"\\n\"\n\t\t\tend\n\t\tend\n\n\t\tputs ColorConstants::NO_COLOR + \"\\n---\"\n\t\tcount = 0\n\n\t\[email protected]_byte do |byte|\n\t\t\tif byte == @file1[count]\n\t\t\t\tprint sprintf(ColorConstants::BLUE + \"%02x \", byte)\n\t\t\telse\n\t\t\t\tprint sprintf(ColorConstants::RED + \"%02x \", byte)\n\t\t\tend\n\n\t\t\tcount = count+1\n\n\t\t\tif count % 32 == 0\n\t\t\t\tprint \"\\n\"\n\t\t\tend\n\t\tend\n\tend", "def get_common_lines\n file2 = @file2.dup\n common_lines = {}\n\n acc = 0\n @file1.each_with_index { |str, i|\n line = file2.index(str)\n unless line.nil?\n common_lines[i] = acc + line\n acc += line + 1\n file2 = file2.drop(line + 1)\n end\n }\n\n common_lines\n end", "def parse_to_file()\n i = 0\n str_n = \"\"\n\n # generating string with 50 N's\n while i<50\n str_n = \"#{str_n}N\"\n i += 1\n end\n\n seq1 = \"\"\n seq2 = \"\"\n\n line1 = @f1.readline().chomp\n line2 = @f2.readline().chomp\n\n tmp1 = line1.split(\" \")\n tmp2 = line2.split(\" \")\n\n header = \"#{tmp1[0]}::#{tmp2[0]}\"\n\n while [email protected]?()\n\n line2 = @f2.readline().chomp\n line1 = @f1.readline().chomp\n\n unless line1.include?('>')\n seq1 = seq1 + \"#{line1}\"\n seq2 = seq2 + \"#{line2}\"\n\n else\n\n seq = seq1 + str_n + seq2\n seq1 = \"\"\n seq2 = \"\"\n str = \"#{header}\\n#{seq}\"\n @out.write(str+\"\\n\")\n\n tmp1 = line1.split(\" \")\n tmp2 = line2.split(\" \")\n\n header = \"#{tmp1[0]}::#{tmp2[0]}\"\n\n end\n end\n @out.write(header+\"\\n\"+seq1+str_n+seq2+\"\\n\")\n end", "def test_file_size_differs\n TestHelper::FillContents($source_dir, {\n 'A.txt' => {\n type: 'file',\n contents: 'SuperLongFileThatHasLotsOfStuff',\n }\n })\n TestHelper::FillContents($backup_dir, {\n 'A.txt' => {\n type: 'file',\n contents: 'ShortFile',\n }\n })\n expected_results = {\n items_processed: 2,\n similarities: 1,\n differences: 1,\n skipped: 0,\n errors: 0,\n }\n actual_results = TestHelper::RunVerification(\n [$source_dir, $backup_dir]\n )\n assertResultsAsExpected(expected_results, actual_results)\n end", "def diff___( from_file, to_file )\r\n raise StandardError, \"Under investigation\" \r\n got = @ndev.rpc.file_compare( :from_file => from_file, :to_file => to_file )\r\n end", "def isogram_matcher(isogram1, isogram2)\n\nend", "def merge(prt_pdb, lig_pdb, complex_pdb)\n prt_lines = File.readlines(prt_pdb)\n lig_lines = File.readlines(lig_pdb)\n\n prt_atm_lines = prt_lines.select { |line| /ATOM/ =~ line }\n lig_atm_lines = lig_lines.select { |line| /HETATM/ =~ line}\n\n f = File.open(complex_pdb, 'w')\n\n f.write(\"MODEL 1\\n\")\n prt_atm_lines.each do |line| f.write(line) end\n f.write(\"TER\\n\")\n lig_atm_lines.each do |line| f.write(line) end\n f.write(\"END\\n\")\n\n f.close()\n\nend", "def processdup_all(c)\n prev_base = nil\n show = false\n c.each do |l|\n base = get_base(l[:file])\n if prev_base && base != prev_base\n show = true\n break\n end\n prev_base = base\n end\n if show\n c.each do |l|\n puts \"#{get_file(l[:file])} similarity #{l[:count]}\"\n end\n puts \"\"\n end\nend", "def test_transform(f1,f2,hashpass,salt,iteration,option)\n succes = nil\n begin\n datastring = \"\"\n File.open(f1).each do |line|\n datastring = datastring + line.gsub(\"a\",\"4\")\n end\n\n file2 = File.new(f2,\"w\")\n file2.write(datastring)\n file2.close\n counter = 1\n lines = File.foreach(f2).count\n File.open(f2).each do |line|\n if option == \"-v\"\n fr = counter * (100.0/lines)\n printf(\"\\r%15s: [%-100s]\",\"#{line.chomp}\", \"=\" * (fr))\n end\n if cracked?(hashpass, line.chomp,salt,iteration,option)\n return succes = line\n end\n counter +=1\n end\n puts \"\"\n succes\n\n rescue => err\n puts \"Exception: #{err}\"\n end\nend", "def similar_messages\n @similar_tempfile.rewind\n @similar_tempfile.readlines\n end", "def diff_file(from_file, to_file, context=3)\n seq1 = File.open(from_file).readlines\n from_mtime = File.stat(from_file).mtime\n seq2 = File.open(to_file).readlines\n to_mtime = File.stat(to_file).mtime\n sdiff = Diff::LCS.sdiff(seq1, seq2)\n diff_lines(seq1, seq2, from_file, to_file, from_mtime, \n to_mtime, context)\n end", "def calculate_similarity(movie_in_common)\n simil = 0.0\n movie_in_common.each do |x|\n #find index of the common movie/ratings\n rating1 = cache_1[1][cache_1[0].index(x)]\n rating2 = cache_2[1][cache_2[0].index(x)]\n simil += (5-(rating1.to_i - rating2.to_i).abs)/5.0\n end\n return simil\n end", "def get_file_delta(file1, file2)\n diff_filename = calculate_diff_filename(file1, file2)\n\n # if the file already exists we can just return it immediatly\n if File.exist? diff_filename\n log.info 'File already calculated'\n return diff_filename\n end\n\n # load the files in to graphs\n clear_graph GRAPH_A\n clear_graph GRAPH_B\n read_file_into_graph(file1, GRAPH_A)\n read_file_into_graph(file2, GRAPH_B)\n\n # loading the differences\n clear_graph DIFF_GRAPH_A\n clear_graph DIFF_GRAPH_B\n calculate_graph_diffs(GRAPH_A, GRAPH_B, DIFF_GRAPH_A)\n calculate_graph_diffs(GRAPH_B, GRAPH_A, DIFF_GRAPH_B)\n\n create_difference_file(DIFF_GRAPH_A, DIFF_GRAPH_B, diff_filename)\n\n log.info \"[*] written to file: #{diff_filename}\"\n return diff_filename\nend", "def compare_stream(a, b)\n bsize = fu_stream_blksize(a, b)\n\n sa = String.new(capacity: bsize)\n sb = String.new(capacity: bsize)\n\n begin\n a.read(bsize, sa)\n b.read(bsize, sb)\n return true if sa.empty? && sb.empty?\n end while sa == sb\n false\n end", "def readWeights\n\ti=0\n\tFile.open(RISKS).each_line { |line|\n\t\tns = line.split\n\t\t@risks[ns[0]] = ns[1].to_i\n\t\ti = i+1\n\t}\n\tFile.open(SYS_FUN).each_line { |line|\n\t\tns = line.split\n\t\t@frisk[ns[0]] = ns[1].to_i\n\t\ti = i+1\n\t}\n\treturn i\nend", "def linearAccuracy\n wrong = 0\n correct = 0\n tp = 0\n tn = 0\n fp = 0\n fn = 0\n\n @label = Array.new(@total_line) {0.00}\n @evaluate = Array.new(@total_line) {0.00}\n @bayes_part = Array.new(@total_line) {0.00}\n\n t_file = File.open(\"./true_label.txt\", \"r\").to_enum\n e_file = File.open(\"./p_zh.txt\", \"r\").to_enum\n b_file = File.open(\"./decision_label.txt\", \"r\").to_enum\n\n array_count = 0\n loop do\n #access next line in each file with .next\n line_t = t_file.next.to_f\n line_e = e_file.next.to_f\n line_b = b_file.next.to_f\n\n if line_e != 0.0\n if line_t == 1.0\n if line_e == 1.0\n tp += 1\n elsif line_e == -1.0\n fp += 1\n else\n puts \"what?\"\n end\n elsif line_t == -1.0\n if line_e == 1.0\n fn += 1\n elsif line_e == -1.0\n tn += 1\n else\n puts \"what??\"\n end\n else\n puts \"what???\"\n end \n\n @evaluate[array_count] = line_e\n @label[array_count] = line_t\n @bayes_part[array_count] = line_b\n array_count += 1\n end\n end\n\n # write best results in simple linear to file\n File.open('true_label_linear.txt', 'w') do |f1| \n # use \"\\n\" for two lines of text \n @label.each do |line|\n f1.puts line\n end\n end\n\n File.open('decision_label_linear.txt', 'w') do |f2| \n # use \"\\n\" for two lines of text \n @evaluate.each do |line|\n f2.puts line\n end\n end\n\n File.open('decision_label_bayes_part.txt', 'w') do |f3| \n # use \"\\n\" for two lines of text \n @bayes_part.each do |line|\n f3.puts line\n end\n end\n\n puts (\"#{@label.size} lines\")\n correct = tp + tn\n wrong = fp + fn\n @Accuracy = 0.0\n @Accuracy = correct.to_f * 100 / (correct + wrong)\n puts \"Simple Accuracy #{@Accuracy}%\"\n tpr = tp.to_f / (tp + fn)\n fpr = fp.to_f / (fp + tn)\n puts \"fp: #{fp} fn: #{fn} tp: #{tp} tn: #{tn}\"\n puts \"tpr #{tpr} fpr: #{fpr}\"\n\n print \"linear \"\n system('./calc_auc ./true_label_linear.txt ./decision_label_linear.txt')\n\n print \"bayes part accordingly \"\n system('./calc_auc ./true_label_linear.txt ./decision_label_bayes_part.txt')\nend", "def fcompares(fname1, sname, fname2)\n cmp = true\n if (fexists fname1, sname) and (fexists fname2, sname)\n x = eval \"$#{fname1}['#{sname},facets']\"\n y = eval \"$#{fname2}['#{sname},facets']\"\n if x == y\n (eval \"$#{fname1}\").each do |i|\n if sname.eql? i.scan(/^\\w+/)\n x = eval \"$#{fname1}[i]\"\n y = eval \"$#{fname2}[i]\"\n if x != y\n cmp = false\n end\n end\n end\n return cmp\n else \n return false\n end\n else\n reuturn false\n end\nend", "def main\n input = STDIN.read.each_line.to_a\n input.shift # Discard first line\n while input.any?\n a, b = input.first.split.map{ |i| i.to_i }\n puts (Fib.get(b) - Fib.get(a))\n input.shift\n end\nend", "def concatinate(f1, f2)\n\t\tDir.foreach(\"#{f1}\") do |x0|\n\t\t\tnext if x0 == '.' or x0 == '..' or x0.start_with?('.')\n\t\t\tDir.foreach(\"#{f2}\") do |x1|\n\t\t\t\tnext if x1 == '.' or x1 == '..' or x1.start_with?('.')\n\t\t\t\t\n\t\t\t\t# concatenate x and y \t\t\n \t\t\t\tsystem(\"cat #{f1}/#{x0} #{f2}/#{x1} > t1/#{x0}#{x1}\")\n\t\t\t\t# compress concatenated files\n \t\t\t\tsystem(\"7za a -t7z t2/#{x0}#{x1}.7z t1/#{x0}#{x1}\")\n \t \t\t#system(\"7za a -t7z -mx9 -mmt2 -ms4g -m0=lzma:d128m:fb256 t2/#{x0}#{x1}.7z t1/#{x0}#{x1}kd\")\n \t \t\t\n \t \tend \n \t end\t\t\n\tend", "def compare_inventory_files(old_file, new_file)\n old_inventory = inventory_from(old_file)\n\n\n new_inventory = inventory_from(new_file)\n\n x = (new_inventory - old_inventory).length\n # Excercise: add number of added files\n puts \"The following #{x} file(s) have been added:\"\n puts new_inventory - old_inventory\n\n y = (old_inventory - new_inventory).length\n\n puts \"\"\n # Excercise: add number of deleted files\n puts \"The following #{y} file(s) have been deleted:\"\n puts old_inventory - new_inventory\n\n x = new_inventory.length - x\n\n y = old_inventory.length - y \n\n puts \"\"\n # Excercise: add number of unchanged files\n puts \"Unchanged files: #{x} \"\n puts \"Verification of unchanged files: #{y} \"\nend", "def double_open(first, second)\n\topen(first) do |f1|\n\t\topen(second) do |f2|\n\t\t\tuntil f1.eof? or f2.eof?\n\t\t\t\tyield f1, f2\n\t\t\tend\n\t\tend\n\tend\nend", "def brute_force(file)\n entries = file.readlines.map(&:to_i)\n\n entries.each_with_index do |line_1, idx_1|\n entries[idx_1 + 1.. entries.size - 1].each_with_index do |line_2, idx_2|\n entries[idx_2 + 1.. entries.size - 2].each do |line_3|\n sum = line_1 + line_2 + line_3\n return line_1 * line_2 * line_3 if sum == TARGET\n end\n end\n end\n end", "def merge_join(key_index, file1, file2)\n # Sorting part.\n merge_sorter!(key_index, file1, file2)\n # Merging part.\n r = file1[i = 0]\n q = file2[j = 0]\n while i != file1.length && j != file2.length\n if greater_than?(r[key_index], q[key_index])\n q = file2[j += 1]\n elsif less_than?(r[key_index], q[key_index])\n r = file1[i += 1]\n else\n # The records match on the join key.\n puts \"#{r[key_index]} #{r.reject { |e| e == r[key_index] }.to_csv.chomp} #{q.reject \\\n { |e| e == r[key_index] }.to_csv.chomp}\" unless r[key_index].nil? || q[key_index].nil?\n t = file2[k = j + 1]\n # Check for further records that match with r on the join key.\n while k != file2.length && r[key_index] == t[key_index]\n puts \"#{r[key_index]} #{r.reject { |e| e == r[key_index] }.to_csv.chomp} #{t.reject \\\n { |e| e == r[key_index] }.to_csv.chomp}\" unless r[key_index].nil? || t[key_index].nil?\n t = file2[k += 1]\n end\n s = file1[l = i + 1]\n # Check for further records that match with q on the join key.\n while l != file1.length && q[key_index] == s[key_index]\n puts \"#{q[key_index]} #{q.reject { |e| e == q[key_index] }.to_csv.chomp} #{s.reject \\\n { |e| e == q[key_index] }.to_csv.chomp}\" unless q[key_index].nil? || s[key_index].nil?\n s = file1[l += 1]\n end\n r = file1[i += 1]\n q = file2[j += 1]\n end\n end\nend", "def compute_multithread(file, start_t, end_t)\n\n start = Time.now\n\n integers_array, integers_set = read_file(file)\n nb_matching_pairs_t1 = 0\n nb_matching_pairs_t2 = 0\n nb_matching_pairs_t3 = 0\n nb_matching_pairs_t4 = 0\n\n t1 = Thread.new{nb_matching_pairs_t1 = two_sum(integers_array,integers_set,-10000,-5000)}\n t2 = Thread.new{nb_matching_pairs_t2 = two_sum(integers_array,integers_set,-4999,0)}\n t3 = Thread.new{nb_matching_pairs_t3 = two_sum(integers_array,integers_set,1,5000)}\n t4 = Thread.new{nb_matching_pairs_t4 = two_sum(integers_array,integers_set,5001,10000)}\n\n\n t1.join()\n t2.join()\n t3.join()\n t4.join()\n\n total_matching_pairs = nb_matching_pairs_t1 + nb_matching_pairs_t2 + nb_matching_pairs_t3 + nb_matching_pairs_t4\n puts \"matching pairs : #{total_matching_pairs}\"\n puts \"runtime : #{Time.now - start}\"\n\n return total_matching_pairs\n\nend", "def similarity(user1,user2)\n\t\tsim = 0\n\t\tfirst_user = @user_set[\"#{user1}\"].sort_by{|k, v| k.to_i}.to_h\n\t\tsecond_user = @user_set[\"#{user2}\"].sort_by{|k, v| k.to_i}.to_h\n\t\tin_common = first_user.keys & second_user.keys\n\t\tin_common.each do |movie|\n\t\t\tif (first_user[movie].to_i.between?(second_user[movie].to_i-1, second_user[movie].to_i+1))\n\t\t\t\tsim += 1\n\t\t\tend\n\t\tend\n\t\treturn sim\n\tend", "def comparative(file_name)\n @scrap_lines = File.readlines(file_name)\n\n @upload_docs.each do |upload_doc_line|\n if @scrap_lines.include?(upload_doc_line)\n if File.file?(\"report.txt\") \n File.open(\"report.txt\" ,\"w\"){ |file| file.write(upload_doc_line)}\n else\n @reportfile = File.new(\"report.txt\",\"w+\")\n File.open(\"report.txt\",\"w\"){ |file| file.write(upload_doc_line)}\n @reportfile.close\n end\n else\n puts \"No instances of plagiarism detected in the application;\"\n end\n end \n end", "def merge\n @mergeit.merge_data(@input_files)\n end", "def compare_run_times(tests, method1, method2)\n total_time_map_reduce = 0\n total_time_regex = 0\n\n tests.each do |test|\n map_reduce_time = time_method(method1, test[:text])\n regex_time = time_method(method2, test[:text])\n\n total_time_map_reduce += map_reduce_time\n total_time_regex += regex_time\n end\n\n puts\n puts \"Map Reduce Total Time: #{total_time_map_reduce.round(2)} milliseconds\"\n puts \"Regex Total Time: #{total_time_regex.round(2)} milliseconds\"\nend", "def similarity(user1,user2)\n #retrieves the recorded related to user1 and user2\n #then create an array which contains the movie ids which both user have rated them\n u1=@users[user1]\n u2=@users[user2]\n u1_movies=u1.collect{|itm| itm[1]}\n u2_movies=u2.collect{|itm| itm[1]}\n common_movies=u1_movies & u2_movies\n \n if common_movies.empty?\n return 0\n end\n \n #Similarity is defined as the average of (4 - distance between rating of user 1 and 2) for movie id\n #which both usres have rated\n similarity=0.0\n common_movies.each do |movie|\n rating1=u1.rassoc(movie)[2]\n rating2=u2.rassoc(movie)[2]\n similarity+=4-(rating1-rating2).abs\n end\n return similarity/common_movies.size\n end", "def merge_lines_coverage(a, b)\n b.each_with_index.map do |b_count, i|\n a_count = a[i]\n (a_count.nil? && b_count.nil?) ? nil : a_count.to_i + b_count.to_i\n end\n end", "def compare_stream(a, b)\r\n bsize = fu_stream_blksize(a, b)\r\n sa = sb = nil\r\n while sa == sb\r\n sa = a.read(bsize)\r\n sb = b.read(bsize)\r\n unless sa and sb\r\n if sa.nil? and sb.nil?\r\n return true\r\n end\r\n end\r\n end\r\n false\r\n end", "def test_can_extract_symbols_and_numbers\n test_file = 'extractor_test_basics'\n src_directory = File.join('testRawData', 'pdf/')\n dst_directory = File.join('testExtractedData', 'pdf/')\n\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n\n correct_output_file = File.join('testCorrectOutputData','basics.txt')\n comparison = FileUtils.compare_file(\"#{dst_directory}#{test_file}.txt\",correct_output_file)\n\n assert_equal comparison, true\n end", "def compare_two_seq(seq1 = \"\", seq2 = \"\")\n length = seq1.size\n diff = 0\n (0..(length-1)).each do |position|\n nt1 = seq1[position]\n nt2 = seq2[position]\n diff += 1 unless nt1 == nt2\n end\n return diff\nend", "def merge(stmt2)\n # print each statement to a file\n [ [ @rows, \"/tmp/merge.1\" ],\n [ stmt2.rows, \"/tmp/merge.2\" ] ].each do | cur_rows, cur_file |\n f = File.open(cur_file, \"w\")\n cur_rows.each do |row| \n if !row[0].nil?\n f.puts(row[0].text) \n end\n end\n f.close\n end\n \n # run an sdiff on it\n @diffs = []\n IO.popen(\"sdiff -w1 /tmp/merge.1 /tmp/merge.2\") do |f|\n f.each { |line| @diffs.push(line.chomp) }\n end\n system(\"rm /tmp/merge.1 /tmp/merge.2\")\n \n # paralellize the arrays, by inserting blank rows\n @diffs.each_with_index do |cur_diff,idx|\n if cur_diff == \"<\"\n new_row = [@rows[idx][0]]\n while new_row.length < stmt2.rows[idx].length\n new_row.push(Cell.new)\n end\n stmt2.rows.insert(idx,new_row)\n elsif cur_diff == \">\"\n new_row = [stmt2.rows[idx][0]]\n while new_row.length < @rows[idx].length\n new_row.push(Cell.new)\n end\n @rows.insert(idx,new_row)\n else\n end\n end\n \n # merge them together\n @rows.size.times do |i|\n @rows[i].concat(stmt2.rows[i])\n end\n end", "def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += (5-(simil1.to_i - simil2.to_i).abs)/5.0\n\t\tend\n\t\tbegin \n\t\t\treturn (simil * 1.0/movie_in_common.size)\n\t\trescue\n\t\t\treturn 0.0\n\t\tend\n\tend", "def pearson_similarity (u1,u2)\n\t\tsimilarity = @train_data[u1].movie_and_rating.keys & @train_data[u2].movie_and_rating.keys\n\t\tif similarity.empty?\n\t\t\treturn 0\n\t\tend\n\t\tsum_1 = 0\n\t\tsum_2 = 0\n\t\tsum_1_sq = 0\n\t\tsum_2_sq = 0\n\t\tproduct = 0\n\n\t\tsimilarity.each do |mov|\n\t\t\tsum_1 += @train_data[u1].return_rating(mov)\n\t\t\tsum_1_sq += @train_data[u1].return_rating(mov)**2\n\t\t\tsum_2 += @train_data[u2].return_rating(mov)\n\t\t\tsum_2_sq += @train_data[u2].return_rating(mov)**2\n\t\t\tproduct += @train_data[u1].return_rating(mov)*@train_data[u2].return_rating(mov)\n\t\tend\n\n\t\tnumerator = product - (sum_1*sum_2/similarity.length)\n\t\tdenom = Math.sqrt((sum_1_sq-(sum_1**2)/similarity.length)*(sum_2_sq-(sum_2**2)/similarity.length))\n\n\t\tif denom == 0 \n\t\t\treturn 0\n\t\tend\n\t\treturn numerator/denom\n\tend", "def analyze tud_map1, tud_map2\n r2 = r_squared tud_map1, tud_map2\n r = pearsons_r r2\n t = t_test r, tud_map1.count\n if t > 1.97\n significant = true\n else\n significant = false\n end \n { r_squared: r2, t: t, significant: significant }\nend", "def test_file_must_nofuzzy()\n\t\tCfruby::FileEdit.file_must_contain(@multilinefilename, \" first line\", :fuzzymatch => false)\n\t\tFile.open(@multilinefilename, File::RDONLY) { |fp|\n\t\t\tlines = fp.readlines()\n\t\t\tassert(lines.length == @multilinefilecontents.split(\"\\n\").length + 1)\n\t\t\tfirstcount = 0\n\t\t\tlines.each() { |line|\n\t\t\t\tif(line =~ /first/)\n\t\t\t\t\tfirstcount = firstcount + 1\n\t\t\t\tend\n\t\t\t}\n\t\t\tassert_equal(2, firstcount)\n\t\t}\n\t\t\n\t\tCfruby::FileEdit.file_must_not_contain(@multilinefilename, \" first line\", :fuzzymatch => false)\n\t\tFile.open(@multilinefilename, File::RDONLY) { |fp|\n\t\t\tlines = fp.readlines()\n\t\t\tassert(lines.length == @multilinefilecontents.split(\"\\n\").length)\n\t\t\tfirstcount = 0\n\t\t\tlines.each() { |line|\n\t\t\t\tif(line =~ /first/)\n\t\t\t\t\tfirstcount = firstcount + 1\n\t\t\t\tend\n\t\t\t}\n\t\t\tassert_equal(1, firstcount)\n\t\t}\n\tend", "def load_data(filename)\n if File.exist? filename\n File.foreach (filename) do |line|\n number = line.chomp.to_i\n next if (@hash1.key?(number) || @hash2.key?(number))\n @hash1[number] = true if number <= 0\n @hash2[number] = true if number > 0\n end\n end\n end", "def similarity(user1, user2)\n if @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n sim_rating = 0\n user1ratings = @userdata[user1.to_s.to_sym]\n user2ratings = @userdata[user2.to_s.to_sym]\n user2ids = []\n user2ratings.each{ |id, rating| user2ids.push id }\n user1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n return sim_rating\n else\n puts \"User not found\"\n return nil\n end\n end", "def same_file?(a, b)\n File.expand_path(a) == File.expand_path(b)\n end", "def find_files(src,dest,options)\r\n src_files = self.find_as_relative( src, options[:excludes] )\r\n dest_files = self.find_as_relative( dest, options[:excludes] )\r\n\r\n # output target files\r\n puts \"  元フォルダ:\" + src_files.size.to_s + \"件\" if self.debug?\r\n puts \"同期先フォルダ:\" + dest_files.size.to_s + \"件\" if self.debug?\r\n #pp src_files if self.debug?\r\n sleep 1 if self.debug?\r\n\r\n #両方にあるファイル名で中身が違うもので src の方が古いもの\r\n same_name_files = (dest_files & src_files)\r\n same_name_files.reject!{|e|\r\n #ファイルが同じモノは省く\r\n next unless File.exists?( File.expand_path(e,dest))\r\n puts \"compare file bin. #{e}\" if self.debug? || self.verbose?\r\n $stdout.flush if self.debug?\r\n FileUtils.cmp( File.expand_path(e,src) , File.expand_path(e,dest) ) \r\n } if options[:strict]\r\n same_name_files.reject!{|e|\r\n #ファイルサイズが同じモノを省く(全部比較する代替手段)\r\n next unless File.exists?( File.expand_path(e,dest))\r\n puts \"size/mtime compare #{e}\" if self.debug? || self.verbose?\r\n File.size(File.expand_path(e,src)) == File.size( File.expand_path(e,dest))\r\n #&& File.mtime(File.expand_path(e,src)) == File.mtime( File.expand_path(e,dest) )\r\n } unless options[:strict]\r\n if options[:update] then\r\n same_name_files= same_name_files.select{|e|\r\n puts \"mtime is newer #{e}\" if self.debug? || self.verbose?\r\n (File.mtime(File.expand_path(e,src)) > File.mtime( File.expand_path(e,dest)))\r\n }\r\n end\r\n if options[:overwrite] == false then\r\n same_name_files= same_name_files.reject{|e|\r\n puts \"can over write? #{e}\" if self.debug? || self.verbose?\r\n (File.exists?(File.expand_path(e,src)) && File.exists?( File.expand_path(e,dest)))\r\n }\r\n end\r\n $stdout.flush if self.debug?\r\n files_not_in_dest = (src_files - dest_files)\r\n #files\r\n files =[]\r\n files = (files_not_in_dest + same_name_files ).flatten\r\n files\r\n end", "def difffiles(fileone, filetwo, addresskeys)\n fileoneresult = String.new\n filetworesult = String.new\n arry = Array.new\n addresskeys.each do |key|\n fileoneresult = balongnvtool(fileone, key)\n filetworesult = balongnvtool(filetwo, key)\n unless fileoneresult.eql? filetworesult\n #Determine the name of the feild that has a diff\n arry.push(getdifname(fileoneresult))\n end\n end\n cleanedarry = removebandspecificaddresses(arry)\n puts cleanedarry\n return cleanedarry\n end", "def run_single(existing_file, audio_params, is_real_run)\n # get existing file info and comparisons between expected and actual\n existing_file_info = @file_info.audio_info(existing_file)\n\n @logger.debug(@class_name) do\n \"Actual file info: #{existing_file_info}\"\n end\n\n compare_hash = compare_info(existing_file, existing_file_info, audio_params)\n\n base_msg = \"for #{compare_hash}\"\n\n @logger.info(@class_name) do\n \"Compared expected and actual info #{base_msg}\"\n end\n\n # MID LEVEL PROBLEM: is the file valid?\n # usually will not log 'File integrity uncertain', since the info check will raise an error\n # for most things that would present as 'File integrity uncertain'.\n check_file_integrity = compare_hash[:checks][:file_errors] == :pass\n if check_file_integrity\n @logger.debug(@class_name) {\n \"File integrity ok #{base_msg}\"\n }\n else\n msg = \"File integrity uncertain #{base_msg}\"\n @logger.warn(@class_name) { msg }\n end\n\n # MID LEVEL PROBLEM: extensions do not match\n # (this is impossible, since if the extension/media_type doesn't match,\n # can't find the file in the first place)\n check_extension = compare_hash[:checks][:extension] == :pass\n if check_extension\n @logger.debug(@class_name) {\n \"File extensions match #{base_msg}\"\n }\n else\n msg = \"File extensions do not match #{base_msg}\"\n @logger.warn(@class_name) { msg }\n end\n\n # HIGH LEVEL PROBLEM: do the hashes match?\n # if the hash from params is 'SHA256::' then first check all other checks pass\n # then update it.\n check_file_hash = compare_hash[:checks][:file_hash] == :pass\n is_expected_file_hash_default = compare_hash[:expected][:file_hash] == 'SHA256::'\n if check_file_hash\n @logger.debug(@class_name) {\n \"File hashes match #{base_msg}\"\n }\n\n elsif is_expected_file_hash_default\n # do nothing here - raise error if something else doesn't match\n else\n msg = \"File hashes DO NOT match #{base_msg}\"\n\n # log error\n @logger.error(@class_name) { msg }\n\n # write row of csv into log file\n log_csv_line(\n existing_file, true, nil,\n compare_hash, nil, nil,\n :high_file_hashes_do_not_match,\n audio_params[:id]\n )\n\n raise BawAudioTools::Exceptions::FileCorruptError, msg\n end\n\n changed_metadata = {}\n\n # LOW LEVEL PROBLEM: media type, sample_rate, channels, bit_rate, data_length_bytes, duration_seconds\n check_media_type = compare_hash[:checks][:media_type] == :pass\n changed_metadata[:media_type] = compare_hash[:actual][:media_type] unless check_media_type\n\n check_sample_rate = compare_hash[:checks][:sample_rate_hertz] == :pass\n changed_metadata[:sample_rate_hertz] = compare_hash[:actual][:sample_rate_hertz] unless check_sample_rate\n\n check_channels = compare_hash[:checks][:channels] == :pass\n changed_metadata[:channels] = compare_hash[:actual][:channels] unless check_channels\n\n check_bit_rate_bps = compare_hash[:checks][:bit_rate_bps] == :pass\n changed_metadata[:bit_rate_bps] = compare_hash[:actual][:bit_rate_bps] unless check_bit_rate_bps\n\n check_data_length_bytes = compare_hash[:checks][:data_length_bytes] == :pass\n unless check_data_length_bytes\n changed_metadata[:data_length_bytes] =\n compare_hash[:actual][:data_length_bytes]\n end\n\n check_duration_seconds = compare_hash[:checks][:duration_seconds] == :pass\n changed_metadata[:duration_seconds] = compare_hash[:actual][:duration_seconds] unless check_duration_seconds\n\n # check on file hash - if everything else matches, update it. if anything else doesn't\n # match, raise an error\n if is_expected_file_hash_default\n if changed_metadata.empty?\n changed_metadata[:file_hash] = compare_hash[:actual][:file_hash]\n else\n msg = \"File hash and other properties DO NOT match #{changed_metadata} #{base_msg}\"\n\n # log error\n @logger.error(@class_name) { msg }\n\n # write row of csv into log file\n log_csv_line(existing_file, true, nil,\n compare_hash, nil, nil,\n :medium_multiple_properties_do_not_match,\n audio_params[:id])\n\n raise BawAudioTools::Exceptions::FileCorruptError, msg\n end\n end\n\n # use api for any changes/updates for low level problems\n update_result = nil\n if changed_metadata.empty?\n @logger.info(@class_name) {\n \"No updates required #{base_msg}\"\n }\n else\n\n msg = \"Update required #{changed_metadata} #{base_msg}\"\n @logger.warn(@class_name) { msg }\n\n if is_real_run\n @logger.info(@class_name) { 'Updating properties.' }\n host = Settings.api.host\n port = Settings.api.port\n\n # get auth token\n security_info = @api_communicator.request_login\n\n # update audio recording metadata\n update_result = @api_communicator.update_audio_recording_details(\n 'mismatch between file and database',\n existing_file,\n audio_params[:id],\n changed_metadata,\n security_info\n )\n else\n @logger.info(@class_name) { 'Dry Run: Would have updated properties.' }\n end\n end\n\n api_result_value = :unknown\n api_result_value = :notrequired if changed_metadata.empty?\n api_result_value = :dry_run if !changed_metadata.empty? && !is_real_run\n api_result_value = :sent_with_unknown_response if !changed_metadata.empty? && is_real_run\n api_result_value = update_result ? :success : :error unless update_result.nil?\n\n {\n compare_hash:,\n api_result_hash: changed_metadata,\n api_result: api_result_value\n }\n end", "def files_match(actual, expected)\n FileCompareAssertion.new(actual, expected)\n end", "def cosine_similarity(x1, y1, x2, y2)\n dp = (x1 * x2) + (y1 * y2)\n mag1 = Math.sqrt((x1 ** 2) + (y1 ** 2))\n mag2 = Math.sqrt((x2 ** 2) + (y2 ** 2))\n return 0 if mag1 == 0 || mag2 == 0\n return (dp / (mag1 * mag2))\n end", "def calc_result(input_file_location)\n result = 0\n File.readlines(input_file_location).each do |line|\n int = Integer(line)\n result += int\n end\n result\nend", "def cmpUnordered(expected, actual, write_observed = 1)\n if File.directory?(expected) && File.directory?(actual)\n Dir.foreach(expected) do | dirent |\n next if dirent == \".\" or dirent == \"..\"\n unless cmpUnordered(expected + \"/\" + dirent, actual + \"/\" + dirent)\n return false\n end\n end\n return true\n end\n\n unless File.readable?(expected)\n raise(\"cannot read file '\" + expected + \"'\")\n end\n unless File.readable?(actual)\n raise(\"cannot read file '\" + actual + \"'\")\n end\n expected_lines = 0\n actual_lines = 0\n only_expected = Set.new\n only_actual = Set.new\n file_expected = File.open(expected)\n file_actual = File.open(actual)\n file_expected.each.zip(file_actual.each).each do | line_expected, line_actual |\n if not line_expected == nil\n expected_lines += 1\n end\n if not line_actual == nil\n actual_lines += 1\n end\n if not expected_lines == actual_lines\n break\n elsif not line_expected == line_actual\n if only_expected.include?(line_actual)\n only_expected.delete(line_actual)\n else\n only_actual.add(line_actual)\n end\n if only_actual.include?(line_expected)\n only_actual.delete(line_expected)\n else\n only_expected.add(line_expected)\n end\n end\n end\n file_expected.close\n file_actual.close\n same = only_expected.empty?() && only_actual.empty?() && expected_lines == actual_lines\n copyObserved(actual, expected, same, write_observed)\n return same\n end", "def diff(file1, data)\n return true unless File.exists?(file1)\n f1 = File.open(file1)\n d1 = f1.read\n f1.close\n return ! (d1 == data)\n end", "def match_countries\n long = []\n File.readlines(\"data/countries_long_codes.txt\").each do |l|\n t = l.chomp.split(\",\")\n long << {code: t[0], name: t[1]}\n end\n\n short = []\n File.readlines(\"data/countries_short_codes.txt\").each do |l|\n t = l.chomp.split(\",\")\n short << {code: t[0], name: t[1]}\n end\n\n countries = []\n long.each do |x|\n min = 1000\n match = short[0]\n short.each do |y|\n d = Levenshtein.distance(x[:name], y[:name])\n if d < min\n min = d\n match = y\n end\n end\n c = {\n name: x[:name],\n names: [],\n long_code: x[:code],\n short_code: match[:code]\n }\n countries << c\n end\n countries\nend", "def test_does_not_duplicate_if_file_already_exists\n test_file = 'extractor_test_small_sample'\n src_directory = File.join('testRawData', 'pdf/')\n dst_directory = File.join('testExtractedData', 'pdf/')\n\n\tnumber_files_before = TestUtils.count_files_directory(dst_directory)\n\n # Order of tests is not guaranteed, so create the file if necessary\n if (not File.exists?(\"#{dst_directory}#{test_file}.txt\"))\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n number_files_before = number_files_before + 1\n end\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n number_of_files_after = TestUtils.count_files_directory(dst_directory)\n \n assert_equal number_files_before, number_of_files_after\n end", "def mismatches_in_horizon h, o1, o2, s, c1 = @sc1.cycle_time, c2 = @sc2.cycle_time\n tt = traveltime(s)\n \n for b1 in @sc1.greenwaves(h, o1, @from_direction, c1)\n b1.shift!(tt) # project this emitted band forward in time\n uncovered_bands = [b1]\n bands2 = @sc2.greenwaves(b1.to_r, o2, @from_direction, c2)\n # b1 shifted is now all potential mismatches;\n # use the bands from sc2 to chop off pieces\n while b2 = bands2.shift and not uncovered_bands.empty?\n b1 = uncovered_bands.pop\n remaining = b1.subtract(b2)\n uncovered_bands.concat remaining\n end\n \n uncovered_bands.each{|b|yield b}\n end\n end", "def identical?( src, dst )\n source = IO.read(src)\n destination = IO.read(dst)\n source == destination\n end", "def similarity (u1, u2)\r\n\t\t# make sure data is loaded first\r\n\t\tif @user_ratings.nil?\r\n\t\t\tputs \"data has not been loaded\"\r\n\t\t\treturn 0\r\n\t\telse\r\n\t\t\t# make sure users exist before calculating similarity\r\n\t\t\tif check(u1, u2)==1\r\n\t\t\t\tu1_rate_hash = @user_ratings[u1]\r\n\t\t\t\tu2_rate_hash = @user_ratings[u2]\r\n\t\t\t\t# merge the two hashes since that produces a set \r\n\t\t\t\t# then can get the length to get # of unique movies the two users have rated (in case users have not ranked all the same movies)\r\n\t\t\t\tnum_total_movies = u1_rate_hash.merge(u2_rate_hash).keys.length\r\n\t\t\t\t# make combination of all movies that both users ahve seen\r\n\t\t\t\tboth_seen = u1_rate_hash.keys & u2_rate_hash.keys\r\n\t\t\t\tsum = 0\r\n\t\t\t\t# loops throught the movies both users have seen and takes the difference between the ratings\r\n\t\t\t\t# this is subtracted from 4 (the max difference) to give an inverse on the difference if they have the same rating then 4 is added to the sum\r\n\t\t\t\tboth_seen.each do |id|\r\n\t\t\t\t\tsum +=4 - (u1_rate_hash[id] - u2_rate_hash[id]).abs\r\n\t\t\t\tend\r\n\t\t\t\t# the formula for similarity\r\n\t\t\t\t# the # movies both have seen /the number of unique movies both have seen\r\n\t\t\t\t# this gives a percentage of similarity between the movies both users have rated\r\n\t\t\t\t# ensures similarity in preference of movies not just ratings\r\n\t\t\t\t# those who have more similar taste in movies ranked will have thier percentage of similarity affected less as it will be close to 1\r\n\t\t\t\t# where those who have disparate tastes in music will be closer to 0 reducing the total score and reflecting their difference in tastes\r\n\t\t\t\t# the sum is divided by 0 to normalize it(if all ranks are the same the sum comes to 4*number of movies both seen \r\n\t\t\t\t# and needs to be removed to get a # below #movies both seen)\r\n\t\t\t\t# divide by total number of movies seen to get a percentage of similarity of ranks\r\n\t\t\t\t# +0.0 TO TURN INTO DECIMALS *100 TO GET THE PERCENT\r\n\t\t\t\tn =((0.0+both_seen.length)/(num_total_movies))*(((0.0+sum)/4)/both_seen.length)*100\r\n\t\t\t\tif n.nan?\r\n\t\t\t\t\tn = 0.0\r\n\t\t\t\tend\r\n\t\t\t\treturn n\r\n\t\t\telse\r\n\t\t\t\treturn 0\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def sample(inputfile, outputfile)\n File.open(outputfile, 'w') do |out_file|\n trace_list = []\n File.open(inputfile, 'r').each do |line|\n trace_list = trace_list << get_trace_id(line)\n end\n sampled = sampled_traces(trace_list)\n File.open(inputfile, 'r').each do |line|\n if (sampled.include?(get_trace_id(line)))\n out_file.print line\n end\n end \n end\nend", "def diff_strings(a, b)\n require 'tempfile'\n require 'open3'\n\n # Create files\n Tempfile.open('old') do |old_file|\n Tempfile.open('new') do |new_file|\n # Write files\n old_file.write(a)\n old_file.flush\n new_file.write(b)\n new_file.flush\n\n # Diff\n cmd = [ 'diff', '-u', old_file.path, new_file.path ]\n Open3.popen3(*cmd) do |stdin, stdout, stderr|\n result = stdout.read\n return (result == '' ? nil : result)\n end\n end\n end\n rescue Errno::ENOENT\n warn 'Failed to run `diff`, so no diff with the previously compiled ' \\\n 'content will be available.'\n nil\n end", "def testReuseMixWithSourceFilesProcessed\n lProcessID = {\n :Param1 => 'TestParam1'\n }.unique_id\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Mix1' => {\n :Tracks => {\n 'Wave.wav' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n 'Final' => {\n :Tracks => {\n 'Mix1' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam2'\n }\n ]\n }\n }\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ],\n [ 'Wave/Noise1s.wav', \"05_Mix/Wave.0.Test.#{lProcessID}.wav\" ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Wave.0.Test.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => \"05_Mix/Wave.0.Test.#{lProcessID}.wav\",\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam2'\n }\n }\n ], 'Process_Test.rb'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Mix1.wav'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Final.wav'\n end\n end", "def search_expect_file(f,other_connect,num,same_flag = 0)\n match = 0\n\n if @ORG_DIRECTION == \"IN\"\n match = search_expect_file_for_IN(f,other_connect,num,same_flag)\n elsif @ORG_DIRECTION == \"OUT\"\n match = search_expect_file_for_OUT(f,other_connect,num,same_flag)\n else\n printf(\"@Internal error. (file:%s,line:%s)\\n\",__FILE__,__LINE__)\n exit\n end\n return match\n end", "def sim_distance(preferences, person1, person2)\n have_movies_in_common = preferences[person1].detect {|movie, rating| preferences[person2].keys.include?(movie) }\n \n # if they have no ratings in common, return 0 \n return 0 unless have_movies_in_common\n \n # Add up the squares of all the differences \n sum_of_squares = 0\n preferences[person1].each do |movie, rating| \n sum_of_squares += (rating - preferences[person2][movie])**2 if preferences[person2].keys.include?(movie) \n end\n\n return 1/(1 + sum_of_squares)\nend", "def similarity(user1, user2)\n\t\tif @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n\t\t\tsim_rating = 0\n\t\t\tuser1ratings = @userdata[user1.to_s.to_sym]\n\t\t\tuser2ratings = @userdata[user2.to_s.to_sym]\n\t\t\tuser2ids = []\n\t\t\tuser2ratings.each{ |id, rating| user2ids.push id }\n\t\t\tuser1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n\t\t\t\t\treturn sim_rating\n\t\telse\n\t\t\tputs \"User not found\"\n\t\t\treturn nil\n\t\tend\n\tend", "def image_compare(path1, path2, differencesInPercent=0)\n return $marathon.compareImages(path1,path2,differencesInPercent)\nend", "def similarity(m1, m2)\n if m1.is_a?(SparseVector) && m2.is_a?(SparseVector)\n m1.cosine(m2)\n elsif m2.size == m1.size\n a_dot_b = 0.0\n a_sq_sum = 0.0\n b_sq_sum = 0.0\n m1.each2(m2) do |x1,x2|\n a_dot_b = x1 * x2\n a_sq_sum += x1 * x1\n b_sq_sum += x2 * x2\n end\n a_dot_b / ( Math.sqrt(a_sq_sum) * Math.sqrt(b_sq_sum) )\n else\n 0.0\n end\n end", "def texts_score(text1, text2)\n words1 = text1.downcase.scan(/[a-zA-Z]+/) - noise_words\n words2 = text2.downcase.scan(/[a-zA-Z]+/) - noise_words\n common_words = words1 & words2\n p common_words\n common_words.length.to_f / (words1.length + words2.length)\n end", "def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += 1.0/((simil1.to_i - simil2.to_i).abs + 1) # 1/(rating difference + 1)\n\t\tend\n\t\treturn simil.round(2)\n\tend", "def eval h,o1,o2,s\n z = eval_speed(s)\n mismatches_in_horizon(h,o1,o2,s){|band| z += band.width}\n z\n end", "def findFastqFiles()\n @read1FileList = Dir[\"*_R1_*.fastq.gz\"]\n @read2FileList = Dir[\"*_R2_*.fastq.gz\"]\n\n if @read1FileList == nil || @read1FileList.length < 1\n raise \"Did not find any fastq files for read 1\"\n else\n @read1FileList.sort! # Sort all the filenames by segment number\n end\n\n if @mode.eql?(\"paired\") && (@read2FileList == nil || @read2FileList.length < 1) \n raise \"Did not find any fastq files for read 2 for paired-end mode\"\n end\n\n if @read2FileList != nil && @read2FileList.length >= 1\n @read2FileList.sort! # Sort the read 2 fastq filenames by segment number\n end\n end", "def combine_salmon\n @tpm = {}\n @counts = {}\n if @paired == 1\n @data.each_with_index do |left,i|\n name = \"#{left[:name]}-#{left[:type]}-#{left[:rep]}\"\n File.open(left[:salmon]).each do |line|\n unless line.start_with?(\"#\")\n cols = line.chomp.split(\"\\t\")\n transcript = cols[0]\n tpm = cols[2].to_f\n counts = cols[3].to_f\n @tpm[transcript] ||= {}\n @tpm[transcript][name] = tpm\n @counts[transcript] ||= {}\n @counts[transcript][name] = counts\n end\n end\n end\n elsif @paired == 2\n @data.each_with_index.each_slice(2) do |(left,i), (right,j)|\n name = \"#{left[:name]}-#{left[:type]}-#{left[:rep]}\"\n File.open(left[:salmon]).each do |line|\n unless line.start_with?(\"#\")\n cols = line.chomp.split(\"\\t\")\n transcript = cols[0]\n tpm = cols[2].to_f\n counts = cols[3].to_f\n @tpm[transcript] ||= {}\n @tpm[transcript][name] = tpm\n @counts[transcript] ||= {}\n @counts[transcript][name] = counts\n end\n end\n end\n end\n File.open(\"#{@output_dir}/combined_tpm.csv\", \"wb\") do |out|\n out.write \"transcript\"\n @tpm[@tpm.keys.first].each do |file, tpm|\n out.write \"\\t#{file}\"\n end\n out.write \"\\n\"\n @tpm.each do |transcript, hash|\n out.write \"#{transcript}\"\n hash.each do |file, tpm|\n out.write \"\\t#{tpm}\"\n end\n out.write \"\\n\"\n end\n end\n File.open(\"#{@output_dir}/combined_counts.csv\", \"wb\") do |out|\n out.write \"transcript\"\n @counts[@counts.keys.first].each do |file, counts|\n out.write \"\\t#{file}\"\n end\n out.write \"\\n\"\n @counts.each do |transcript, hash|\n out.write \"#{transcript}\"\n hash.each do |file, counts|\n out.write \"\\t#{counts}\"\n end\n out.write \"\\n\"\n end\n end\n end", "def image_compare(path1, path2, differencesInPercent=0)\n return $marathon.compareImages(path1,path2,differencesInPercent)\nend" ]
[ "0.6356287", "0.6303709", "0.61563057", "0.6117033", "0.60641253", "0.6007488", "0.5987714", "0.59845835", "0.59647256", "0.5955391", "0.5955391", "0.5928021", "0.59131616", "0.59022915", "0.58573145", "0.5672314", "0.56437457", "0.5585771", "0.55559933", "0.54960656", "0.548076", "0.5460968", "0.53823656", "0.53764683", "0.5374247", "0.53740734", "0.53546226", "0.5334616", "0.5332906", "0.5322167", "0.5320419", "0.530461", "0.52925104", "0.52591366", "0.5237174", "0.52124274", "0.5184474", "0.5167782", "0.5149313", "0.5134082", "0.51258415", "0.51117784", "0.509556", "0.50919724", "0.50660247", "0.50633556", "0.5051488", "0.50434107", "0.50382674", "0.5035518", "0.5033964", "0.49962845", "0.4984846", "0.49786523", "0.4957033", "0.49429545", "0.4934201", "0.49296787", "0.49149328", "0.49076745", "0.49059364", "0.48889112", "0.48635632", "0.48361933", "0.48356575", "0.48345393", "0.48323414", "0.48197", "0.48194334", "0.4816247", "0.4816106", "0.48044947", "0.48019087", "0.4795044", "0.47929066", "0.47863227", "0.47815445", "0.4775153", "0.4773346", "0.476924", "0.47601986", "0.47558483", "0.47530484", "0.47492823", "0.47486028", "0.47458783", "0.47434124", "0.4742391", "0.47382894", "0.4732225", "0.4731987", "0.47296408", "0.47239828", "0.47238407", "0.4722635", "0.47211227", "0.47168452", "0.4712754", "0.47104377", "0.47030133" ]
0.5833666
15
Wait for page to be displayed. Url matcher from above is used to verify that page is displayed.
def initialize # Wait for the page to be displayed with 30 seconds timeout raise 'The page was not loaded' unless self.displayed?(30) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_until_page_loads(path)\n @wait.until { @driver.current_url == path}\n @wait.until { @driver.execute_script('return PAGE_RENDERED;') == true }\n $verbose ? puts(\"#{path} successfully loaded\") : nil\n end", "def wait_to_load\n activity_div.wait_until(&:exists?)\n @page = @bank_page.load_page\n end", "def wait_for_page\n sleep 0.7\n end", "def wait_for_freelancer_page_visible\n sleep 15\n end", "def wait_page_load\n @browser.wait_for_load\n end", "def wait_for_url(url)\n wait_for { current_url.include?(url) }\n end", "def wait_for_page_to_load\n @wait_on.each { |element| wait_for_element(element) }\n loading_message.wait_while_present if loading_message.present?\n true\n rescue\n false\n end", "def wait_for_url(url)\n browser.wait_until(timeout: 5, message: \"URL did not become `#{url}`\") {\n browser.url.include? url\n }\n end", "def wait_for_browser\r\n # NOTE: no need any more\r\n end", "def wait_for_render(how, what)\n @wait.until {element_visible?(how, what)}\n end", "def go_to_and_wait_to_load(url)\n current_name = driver.title\n driver.get url\n\n # wait until the current title changes to see that you're at a new url\n @wait.until { driver.title != current_name }\n end", "def confirm_on_page\n @browser.div(class: 'home').wait_until_present(5)\n end", "def go_back_and_wait\n go_back\n assert_page_loaded\n end", "def wait_for_page_title()\n wait_for :page_title, \"Error waiting for page title to load\"\n end", "def wait_for_page_title()\n wait_for :page_title, \"Error waiting for page title to load\"\n end", "def show_read\n find('#show-read').click\n\n # Ensure entries have finished loading\n expect(page).to have_no_css 'div#loading'\nend", "def wait_until_page_loaded(page_name, prev_url)\n time_secs = 0\n while Capybara.current_session.current_url == prev_url\n break if time_secs > PAGE_TIMEOUT_SECS\n sleep 1\n time_secs+=1\n end\n fail \"ERROR: Page #{page_name} failed to load after #{PAGE_TIMEOUT_SECS} secs\" if Capybara.current_session.current_url == prev_url\n end", "def wait_for_page_and_verify_text(text)\n @selenium.wait_for_page_to_load(120000)\n check_page_and_verify_text(text)\n end", "def wait_for_page_to_load(page)\n Logbook.message(\"Waiting for page #{page} to load...\")\n wait_for do\n @browser.execute_script(\"return document.querySelector('link[rel=\\\"icon\\\"]') !== null\")\n end\n end", "def click_wait\n @webpage.click_wait(@locator)\n end", "def wait_for_ready(wait: 10)\n Support::Waiter.wait_until(max_duration: wait, reload_page: false, raise_on_failure: true) do\n ready?\n end\n end", "def wait_page_load(criteria,value,expected_element_text,seconds_wait)\r\n\t \t\ttext_on_page = @driver.find_element(criteria.to_sym, value).text\r\n\t \t\twait_for(seconds_wait) { text_on_page.include?(expected_element_text)}\r\n\t \tend", "def wait_loading\n puts \"[BrowserOperator] wait_loading\" << '..' * 10\n browser.div(:id, 'pageLoading').wait_while_present()\n end", "def wait_for_visible(locator)\n wait_for { find_element(locator).displayed? }\n end", "def open_and_wait( location)\n selenium.open(location)\n wait_for_page_to_load\n end", "def wait_for_page_to_load timeout\r\n command 'waitForPageToLoad', timeout\r\n end", "def wait_for_page_to_load timeout\r\n command 'waitForPageToLoad', timeout\r\n end", "def page_should_finish_loading\n expect(page).not_to have_css '.sidebar-spinner'\n expect(page).to have_css '#subscription-stats'\nend", "def waitForPageToLoad(title, what='title')\n puts \"waitForPageToLoad:('#{title}',#{what})\"\n begin\n wait = Selenium::WebDriver::Wait.new(:timeout => THE_TIMEOUT)\n wait.until {@driver.title}\n puts \"waitForPageToLoad until reached title element with text set to [#{@driver.title}]\"\n rescue Exception => e\n puts \"waitForPageToLoad exception [#{e}]\"\n return\n end\n waitForElementPresent(:css, what)\n iter = 0\n found = false\n THE_TIMES.times do\n puts \"waitForPageToLoad: iter=[#{iter}] waiting for-->[#{title}] currently-->[#{@driver.find_element(:css, what).text}] \"\n iter += 1\n if @driver.find_element(:css, what).text == title\n found = true\n break\n end\n sleep 1.0\n end\n if found then\n puts \"waitForPageToLoad: After [#{iter}] tries: found expected text=[#{title}] in [#{what}] element\"\n else\n puts \"----TEST FAILED:---waitForPageToLoad: After [#{iter}] tries: NOT FOUND expected text=[#{title}] in [#{what}] element\"\n end\n found.should == true\n end", "def wait_for_logout_page()\n wait_for :logout_page, \"Error waiting for search for logout\"\n end", "def wait_for_logout_page()\n wait_for :logout_page, \"Error waiting for search for logout\"\n end", "def wait_for_pdf_window(string)\n Timeout.timeout(Nenv.browser_timeout) do\n loading = true\n while loading\n check = url_match(string, RouteHelper.browser.windows.last.use.url)\n loading = false if check\n sleep(1)\n end\n return true\n end\n rescue Timeout::Error => e\n raise \"Timeout waiting for window to load - #{e}\"\n exit\n end", "def wait_for_dom_has_loaded\n Capybara.default_max_wait_time = 40\n Timeout.timeout(Capybara.default_max_wait_time) do\n loop until page_has_loaded?\n end\n end", "def verify_if_searchresult_page_is_shown\n handle_captcha\n wait_until_element_displays(SEARCH_RESULT_CLEAR_BTN,15)\n puts \"Search Result is shown\"\n storeResultsInHash\n end", "def wait_for_element_to_load(locator)\n sleep 1\n puts \"Waiting for this locator to be visible on the page: #{locator}\"\n if isElementVisible(locator)\n return true\n else\n raise Selenium::WebDriver::Error::NoSuchElementError\n end\n sleep 1\n end", "def wait_for_modal_visible\n wait_until { page.find(modal_id).visible? }\nrescue Capybara::TimeoutError\n flunk 'Expected modal to be visible.'\nend", "def wait_for\n subject = nil\n wait.until { (subject = yield).displayed? }\n sleep(1.2) # FIXME: wait animations to complete\n subject\n end", "def open_home_page\n selenium.open(context.browser_url)\n wait_for_page_to_load\n end", "def wait_for_modal_hidden\n wait_until { !page.find(modal_id).visible? }\nrescue Capybara::TimeoutError\n flunk 'Expected modal to be visible.'\nend", "def wait_for_ajax_complete\n wait_until { page.evaluate_script 'jQuery.active == 0' rescue true }\n end", "def wait_until_displayed(element, timeout=10)\n wait_until(timeout) { element.displayed? }\nend", "def show_existing(url)\n puts \"Checking: #{url}\"\n load_query_form\n query = @driver.find_element(:name, 'q')\n query.clear\n query.send_keys url\n show_button = @driver.find_element(:xpath, '//button[1]')\n show_button.click\n begin\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n response = wait.until { show_response }\n puts 'The response code is: ' + response.to_s\n rescue\n response = :rescrape\n end\n response\n end", "def hide_read\n find('#hide-read').click\n\n # Ensure entries have finished loading\n expect(page).to have_no_css 'div#loading'\nend", "def click_visible_link(locator)\n wait_randomly\n click_link(locator.to_s, match: :first, visible: true)\nrescue StandardError\n raise_with_new_message 'Unable to click on link'\nend", "def load_url_and_wait_for_element(url,sym,id)\n current_name = driver.title\n driver.get url\n\n @wait.until { driver.title != current_name and driver.find_elements(sym, id).size > 0 }\n end", "def load_page\n logger.info 'Loading Core homepage'\n get ConfigCore.base_url\n when_exists(page_heading, Config.medium_wait)\n end", "def test_00030_homepage_topic_widget\n @browser.wait_until { @home_page.home_featured_topic_row.present? }\n assert @home_page.home_featured_topic.present?\n end", "def wait_visible!(timeout=@wait)\n self.el\n wait_for(timeout: timeout, message: \"Element at #{location} is not visible\") { visible? }\n end", "def open(url)\n super\n assert_page_loaded\n end", "def test_pageload\n @driver.navigate.to(@url)\n element = @driver.find_element(:class, \"ss-form-title\")\n assert_equal(element.text,\"Basic Web Forms\") # Check if the page open and the title is \"Basic Web Forms\"\n end", "def wait_page_load()\n rc = nil\n Log.Debug(:h5, \"[#{self.class.to_s}.WAIT_PAGE_LOAD]\") {\n _check_repl_lock\n _compile_wait_page_load\n rc = exec\n rc = (rc.is_str? and rc.include?(READY_STATE_COMPLETE)) ? true : false\n }\n Log.Debug \"{#{self.class.to_s}.wait_page_load} :=> #{rc.safe_s}\"\n rc\n end", "def post_title_displayed?\n wait = Selenium::WebDriver::Wait.new(timeout: 15)\n wait.until { displayed? POST_TITLE }\n end", "def click_home\n wait_for_load_and_click home_link_element\n end", "def check_if_end_tour_button_is_displayed\n\n page.should have_button(END_TOUR_BUTTON)\n sleep(THREAD_SLEEP_1)\n\n end", "def load_page\n @mechanize_instance.get(@url)\n end", "def test_00090_homepage_open_q_conv_link\n @browser.wait_until { @home_page.open_questions_widget.present? }\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify the title link would redirect to conversation page.\n q_title = @home_page.open_questions_widget.posts[0].title\n @home_page.open_questions_widget.posts[0].click_title_link\n @browser.wait_until { @convdetail_page.conv_detail.present? }\n assert_equal @convdetail_page.conv_title.when_present.text, q_title, \"title doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify avatar link would redirect to profile page\n @home_page.open_questions_widget.posts[0].click_avatar\n @browser.wait_until { @profile_page.profile_page.present? }\n author_name = @profile_page.profile_page_author_name_betaon.when_present.text\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify author link would redirect to profile page\n @home_page.open_questions_widget.posts[0].click_author_link\n @browser.wait_until { @profile_page.profile_page.present? }\n assert_equal @profile_page.profile_page_author_name_betaon.when_present.text, author_name, \"Author doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify topic link would redirect to the correct topic page\n post_in_topic = @home_page.open_questions_widget.posts[0].in_topic_link.when_present.text\n\n @home_page.open_questions_widget.posts[0].click_topic_link\n @browser.wait_until { @topicdetail_page.topic_filter.present? }\n assert_equal @topicdetail_page.topic_title.when_present.text, post_in_topic, \"Title doesn't match\"\n end", "def click\n\tbegin\n\t @selenium.click(@locator)\n\trescue => e\n\t sleep(3)\n\t @selenium.click(@locator)\n\tend\n\n\tbegin\n\t @selenium.wait_for_page_to_load\n\trescue => e\n\t sleep(2)\n\t @selenium.wait_for_condition(\"selenium.browserbot.getCurrentWindow()\", TIMEOUT)\n\tend\n\t\n end", "def check_if_back_button_is_displayed\n\n page.should have_button(BACK_BUTTON)\n sleep(THREAD_SLEEP_1)\n\n end", "def click_and_wait(locator, wait_for = default_timeout)\n click locator\n assert_page_loaded(wait_for)\n end", "def wait_for_element_to_be_visible(id, name, time)\n begin\n wait = [60, time].max\n element = get_element(id, name)\n !wait.times {\n break if element.displayed?\n sleep 1\n }\n rescue\n end\nend", "def go_to_page(url)\n Logbook.step(\"Open start page #{url} :)\")\n @browser.get url\n sleep 2\n\n @browser\n end", "def load_page\n page.visit('')\n end", "def test_00140_homepage_featured_q_widget_conv_links\n @browser.wait_until { @home_page.featured_q_widget.present? }\n @browser.wait_until { @home_page.featured_q_widget.posts.size > 0 }\n\n # verify the title link would redirect to conversation page.\n q_title = @home_page.featured_q_widget.posts[0].title\n @home_page.featured_q_widget.posts[0].click_title_link\n @browser.wait_until { @convdetail_page.conv_detail.present? }\n assert_equal @convdetail_page.conv_title.when_present.text, q_title, \"title doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_q_widget.posts.size > 0 }\n\n # verify avatar link would redirect to profile page\n @home_page.featured_q_widget.posts[0].click_avatar\n @browser.wait_until { @profile_page.profile_page.present? }\n author_name = @profile_page.profile_page_author_name_betaon.when_present.text\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_q_widget.posts.size > 0 }\n\n # verify author link would redirect to profile page\n @home_page.featured_q_widget.posts[0].click_author_link\n @browser.wait_until { @profile_page.profile_page.present? }\n assert_equal @profile_page.profile_page_author_name_betaon.when_present.text, author_name, \"Author doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_q_widget.posts.size > 0 }\n\n # verify topic link would redirect to the correct topic page\n post_in_topic = @home_page.featured_q_widget.posts[0].in_topic_link.when_present.text\n\n @home_page.featured_q_widget.posts[0].click_topic_link\n @browser.wait_until { @topicdetail_page.topic_filter.present? }\n assert_equal @topicdetail_page.topic_title.when_present.text, post_in_topic, \"Title doesn't match\"\n end", "def test_document_server(url)\n test_name = \"Test Document Server Connection\"\n puts test_name\n get_website(url)\n login_as_guest_test\n if @browser.find_element(:css=>'.focus') #Dismisses the splashscreen if present\n @wait.until{@browser.find_element(:css=>'.focus')}.click\n end\n login_toolshelf_button_test\n login_test\nend", "def wait_for_element(element)\n @wait.until {\n bool = false\n\n if(element.displayed?)\n bool = true\n @element = element\n break\n end \n\n bool == true\n }\n end", "def wait_for_results_to_load\n wait_until { searchbar_element.attribute('class').include?(Constants::SEARCHING_CLASS) }\n rescue StandardError\n puts 'Loading in search modal didn\\'t appear!'\n ensure\n wait_until { !searchbar_element.attribute('class').include?(Constants::SEARCHING_CLASS) }\n end", "def wait_for_page_present(cls_name)\r\n case cls_name\r\n when 'data-manage'\r\n page_title = '视图管理列表'\r\n when 'shared-zones'\r\n page_title = '共享区列表'\r\n when 'share_zone_rr' # customized class_name\r\n page_title = '共享区记录列表'\r\n when 'zone_list' # customized class_name\r\n page_title = '区列表'\r\n when 'rr_list' # customized class_name\r\n page_title = '记录列表'\r\n when 'shared-rrs'\r\n page_title = '共享记录列表'\r\n when 'search'\r\n page_title = '全局搜索列表'\r\n when 'stub-zones'\r\n page_title = '存根区列表'\r\n when 'forward-zones'\r\n page_title = '转发区列表'\r\n when 'redirect-rrs'\r\n page_title = '重定向列表'\r\n when 'hint-zones'\r\n page_title = '根配置列表'\r\n when 'hint_zone_rr'\r\n page_title = '记录列表'\r\n when 'local-policies'\r\n page_title = '本地策略列表'\r\n when 'query-source'\r\n page_title = '请求源地址列表'\r\n when 'monitorsetting'\r\n page_title = '监测设置列表'\r\n when 'views'\r\n page_title = '视图管理列表'\r\n when 'sortlists' # customized class_name\r\n page_title = '记录排序列表'\r\n when 'acls'\r\n page_title = '访问控制列表'\r\n when 'ip-rrls'\r\n page_title = 'IP解析限速列表'\r\n when 'domain-rrls'\r\n page_title = '域名解析限速列表'\r\n when 'monitor_strategies'\r\n page_title = '策略列表'\r\n when 'redirections'\r\n page_title = 'URL转发列表'\r\n when 'users'\r\n page_title = '用户管理列表'\r\n when 'audit-logs'\r\n page_title = '操作日志列表'\r\n when 'warning_records'\r\n page_title = '告警记录'\r\n when 'data_backup_logs'\r\n page_title = '备份/恢复列表'\r\n end\r\n sleep 1\r\n begin\r\n page_open = Watir::Wait.until {ZDDI.browser.div(:id=>\"tableTitle\").span.text == page_title}\r\n return 'succeed' if page_open\r\n rescue\r\n # Watir::Wait.until 默认等待30s, 超时后报错.\r\n return 'fail'\r\n end\r\n end", "def waitForLoader\n element = @driver.find_element(:css, 'html')\n 45.times {\n if !element.attribute('css').include?(PAGELOADER_ELEMENT) # provide the loader class\n return\n else\n sleep 1\n end\n }\n raise 'Loading Spinner Timeout'\n end", "def initialize\n @klass = 'HOME'\n @description = nil\n # Wait for the page to be displayed with MAX_WAIT_ON_LOAD seconds timeout\n raise 'The page was not loaded' unless self.displayed?($janus::MAX_WAIT_ON_LOAD)\n end", "def wait_for_ajax\n Timeout.timeout(Capybara.default_wait_time) do\n loop do\n active = page.evaluate_script('jQuery.active')\n break if active == 0\n end\n end\n end", "def wait_to_appear(sym,id)\n @wait.until {\n element_arr = driver.find_elements(sym,id)\n element_arr.size > 0 and element_arr[0].displayed? #wait until the element both exists and is displayed\n }\n end", "def get_page\n begin\n puts \"@@@@@@@@@@@@@ Visiting: #{@url} from #{@parent_page.address if @parent_page.present?}\"\n require 'nokogiri'\n require 'open-uri'\n @page = Nokogiri::HTML(open(@url))\n @page_title = (title_container = @page.css('title').first) ? title_container.content : \"Title unknown\"\n @links = @page.css(\"a\")\n\n return true\n rescue => exc\n puts \"==Problem with URL #{@url} == #{ exc.message}\"\n return false\n end\n end", "def refresh_feed\n open_feeds_menu\n expect(page).to have_css '#refresh-feed'\n find('#refresh-feed').click\n # Ensure entries have finished loading\n expect(page).to have_no_css 'div#loading'\nend", "def wait_for_welcome_screen\n wait_for_elements_exist([trait])\n end", "def wait_visible!(timeout=@wait)\n wait_for(timeout: timeout, message: \"Element at #{locator} is not visible\") { visible? }\n end", "def check_if_join_public_league_pop_up_is_displayed\n\n page.should have_content(read_file_content(JOIN_A_PUBLIC_LEAGUE_PATH))\n sleep(THREAD_SLEEP_1)\n\n end", "def more_navigate\n page(FeedDetailsPage).await\n page(FooterTabBarPage).select_tab(\"More\")\n page(MorePage).seemenu\nend", "def load_page\n @page ||= @mechanize.get(url)\n end", "def wait_until_loaded(element)\n navigation = AppletCarousel.instance\n navigation.wait_until_action_element_visible(element, 60)\nend", "def publish_wait\n page.wont_have_css 'publish-spinner'\n end", "def expect_game_to_be_over\n expect(page).to have_content(\"Your Results\")\n end", "def test_00160_homepage_featured_b_widget\n # # @browser.execute_script(\"window.scrollBy(0,8000)\")\n # @browser.wait_until { @home_page.home_featured_blog.present? }\n # assert @home_page.home_featured_blog.present?\n # assert @home_page.home_featured_b_desc.present?\n @browser.wait_until { @home_page.featured_b_widget.present? }\n @browser.wait_until { @home_page.featured_b_widget.posts.size > 0 }\n\n # verify the title link would redirect to conversation page.\n q_title = @home_page.featured_b_widget.posts[0].title\n @home_page.featured_b_widget.posts[0].click_title_link\n @browser.wait_until { @convdetail_page.conv_detail.present? }\n assert_equal @convdetail_page.conv_title.when_present.text, q_title, \"title doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_b_widget.posts.size > 0 }\n\n # verify avatar link would redirect to profile page\n @home_page.featured_b_widget.posts[0].click_avatar\n @browser.wait_until { @profile_page.profile_page.present? }\n author_name = @profile_page.profile_page_author_name_betaon.when_present.text\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_b_widget.posts.size > 0 }\n\n # verify author link would redirect to profile page\n @home_page.featured_b_widget.posts[0].click_author_link\n @browser.wait_until { @profile_page.profile_page.present? }\n assert_equal @profile_page.profile_page_author_name_betaon.when_present.text, author_name, \"Author doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_b_widget.posts.size > 0 }\n\n # verify topic link would redirect to the correct topic page\n post_in_topic = @home_page.featured_b_widget.posts[0].in_topic_link.when_present.text\n\n @home_page.featured_b_widget.posts[0].click_topic_link\n @browser.wait_until { @topicdetail_page.topic_filter.present? }\n assert_equal @topicdetail_page.topic_title.when_present.text, post_in_topic, \"Title doesn't match\"\n end", "def click_reports_link\n wait_for_page_and_click reports_link\n end", "def explore_footer\n explore_footer_link.click\n sleep 1\n wait_for_ajax\n LoginPage.new @browser\n end", "def wait_for_ajax(&block)\n wait_until do\n page.driver.browser.execute_script(<<-JS)\n return !Ext.Ajax.isLoading();\n JS\n end\n yield\n end", "def wait_for_e(xpath)\n $browser.element(:xpath => xpath).wait_until(&:present?)\nend", "def wait_before_and_after\r\n wait_for_browser\r\n yield\r\n wait_for_browser\r\n end", "def fetch_page\n Varnisher.log.info \"Looking for external resources on #{@url}...\"\n\n begin\n @html = Net::HTTP.get_response(@uri).body\n rescue\n Varnisher.log.info \"Hmm, I couldn't fetch that URL. Sure it's right?\\n\"\n return\n end\n end", "def wait_for_visible(locator, options={})\n builder = JavascriptExpressionBuilder.new\n wait_for_condition builder.visible(locator).script, options[:timeout_in_seconds]\n end", "def verify_landing_page\n @higgs.page_title_present?('Puppet Enterprise Installer')\n @higgs.link_present?('email the CEO.')\n @higgs.select_link(\"Let's get started\")\n @higgs.page_title_present?('Puppet Enterprise Installer - Choose your deployment')\n end", "def open(url = @url)\n @browser.goto(url)\n wait_for_page_to_load\n end", "def go_back_and_wait\n selenium.go_back\n wait_for_page_to_load\n end", "def is_on_page? page_text, negation = ''\n should_not_have_exception = false\n should_have_exception = false\n begin\n wait_for(timeout: 5) { has_text? page_text }\n # If negation is not nil, we should raise an error if this message was found on the view\n should_not_have_exception = true unless negation == ''\n rescue\n # only raise exception if negation is nil, otherwise this is the expected behaviour\n should_have_exception = true if negation == ''\n end\n raise \"Unexpected Page. The page should not have: '#{page_text}'\" if should_not_have_exception\n raise \"Unexpected Page. Expected was: '#{page_text}'\" if should_have_exception\n end" ]
[ "0.7413323", "0.72536707", "0.7201008", "0.71494627", "0.69868624", "0.69339645", "0.6843561", "0.6831059", "0.68261796", "0.67356426", "0.6705139", "0.670131", "0.6653075", "0.6639472", "0.6639472", "0.6614516", "0.6610064", "0.6609883", "0.650811", "0.6390504", "0.6334343", "0.63074297", "0.62994313", "0.6295465", "0.6287654", "0.6260746", "0.6260746", "0.6256744", "0.62330574", "0.6202656", "0.6202656", "0.6190695", "0.61478555", "0.61136895", "0.60692495", "0.606168", "0.60571414", "0.6047127", "0.60424244", "0.60247815", "0.60179985", "0.60031074", "0.5998947", "0.5987542", "0.59858227", "0.59843355", "0.5975778", "0.5971079", "0.5968069", "0.59674096", "0.5953236", "0.5939484", "0.59374285", "0.59267503", "0.59202355", "0.59104306", "0.5903371", "0.58987707", "0.5892047", "0.58869237", "0.586438", "0.5852484", "0.5849114", "0.58437526", "0.58370334", "0.582106", "0.5820681", "0.5799933", "0.57963276", "0.578682", "0.578236", "0.57819116", "0.57790124", "0.57739973", "0.57701427", "0.57571775", "0.5754669", "0.57333773", "0.57314515", "0.57286817", "0.5725914", "0.5725874", "0.5723189", "0.57214034", "0.5705519", "0.5703134", "0.57007295", "0.56968015", "0.56964236", "0.5691578", "0.5686613", "0.5671617", "0.56693137" ]
0.66586405
18
Creates a new course with the following hash of params
def create_course(param = {}) course_name.set param['name'] course_oid.set param['oid'] description.set param['description'] passing_score.set param['passing_score'] prerequisite.select(param['prereq']) unless create_course_params['prereq'] == 'N/A' course_locale.select(param['locale']) course_duration.set param['duration'] upload_file('Course File', param['course_file']) submit_button.click end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(params)\n response = self.class.post(\n '/webservice/rest/server.php',\n {\n :query => query_hash('core_course_create_courses', token),\n :body => {\n :courses => {\n '0' => {\n :fullname => params[:full_name],\n :shortname => params[:short_name],\n :categoryid => params[:parent_category],\n :idnumber => params[:idnumber]\n }\n }\n }\n }.merge(query_options)\n )\n check_for_errors(response)\n response.parsed_response.first\n end", "def create_new_course(account_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :course__name__,\n :course__course_code__,\n :course__start_at__,\n :course__end_at__,\n :course__license__,\n :course__is_public__,\n :course__public_syllabus__,\n :course__public_description__,\n :course__allow_student_wiki_edits__,\n :course__allow_wiki_comments__,\n :course__allow_student_forum_attachments__,\n :course__open_enrollment__,\n :course__self_enrollment__,\n :course__restrict_enrollments_to_course_dates__,\n :course__term_id__,\n :course__sis_course_id__,\n :course__integration_id__,\n :course__hide_final_grades__,\n :course__apply_assignment_group_weights__,\n :offer,\n :enroll_me,\n :course__syllabus_body__,\n \n ]\n\n # verify existence of params\n raise \"account_id is required\" if account_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :account_id => account_id\n )\n\n # resource path\n path = path_replace(\"/v1/accounts/{account_id}/courses\",\n :account_id => account_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n Course.new(response)\n end", "def create\n @course = Course.new(course_params)\n\n if @course.save\n flash[:success] = \"Curso criado com sucesso\"\n redirect_to courses_path\n else\n flash[:error] = \"Não foi possível criar o curso\"\n redirect_to courses_path\n end\n end", "def create\n course = Course.new(course_params)\n\n if course.save\n render json: course, status: :created\n else\n render json: course.errors, status: :unprocessable_entity\n end\n end", "def create\n @course = Course.new(course_params)\n \n respond_to do |format|\n if @course.save\n #format.html { redirect_to course_build_path(:id =>\"courseinfo\", :course_id => @course.id), notice: \"Course Created\" }\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(courses_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if (params[:course])\n @course = Course.new(params[:course])\n @user = User.find_by_id(session[:user_id])\n else\n params[:course] = {:name=>params[:title], \n :f_day=>params[:description], \n :l_day=>params[:price]\n }\n @course = Course.new(params[:course])\n @course.user_id = session[:user_id]\n end\n \n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: courses_path.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @course = Course.new(course_params)\n\n CourseBuilder.build do |builder|\n builder.set_code(course_params['code'])\n builder.set_title(course_params['title'])\n builder.set_instructor(course_params['instructor'])\n builder.set_semester(course_params['semester'])\n builder.set_credit(course_params['credit'])\n builder.set_room(course_params['room'])\n builder.set_evaluation(course_params['midterm'], course_params['final'], course_params['assignment'], course_params['project'])\n\n @course = builder.course\n end\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_url, notice: 'Course was successfully created.' }\n format.json { render :index, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:course][:user_id]=current_user.id\n \n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Curso criado com sucesso.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # render plain: params[:courses].inspect\n @courses = Courses.new(courses_params)\n\n respond_to do |format|\n if @courses.save\n format.html { redirect_to @courses, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @courses }\n else\n format.html { render :new }\n format.json { render json: @courses.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course ' + @course.course_id + ' was successfully created!' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tcourse = Course.new(course_params)\n\t\tif course.save\n\n\t\t params[:course][\"major_id\"].each do |major_id|\n\t if !major_id.empty?\n\t course.major << Major.find(major_id)\n\t end\n\t end\n\n\t params[:course][\"minor_id\"].each do |minor_id|\n\t if !minor_id.empty?\n\t course.minor << Minor.find(minor_id)\n\t end\n\t end\n\n\t params[:course][\"concentration_id\"].each do |concentration_id|\n\t if !concentration_id.empty?\n\t course.concentration << Concentration.find(concentration_id)\n\t end\n\t end\n\n\t params[:course][\"distribution_id\"].each do |distribution_id|\n\t if !distribution_id.empty?\n\t course.distribution << Distribution.find(distribution_id)\n\t end\n\t end\n\n\t\t\tredirect_to '/courses'\n\t\telse\n\t\t\tflash[:danger] = \"The form you submitted is invalid.\"\n\t\t\tredirect_to '/courses/new'\n\t\tend\n\tend", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: \"Course was successfully created.\" }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n respond_to do |format|\n if @course.save\n\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_url, notice: 'Curso creado satisfactoriamente' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @course = current_user.courses.build(course_params)\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: \"Course was successfully created.\" }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_course\r\n @course = Course.create(fast_course_params)\r\n respond_to do |format|\r\n if @course.save\r\n format.html { redirect_to courses_path, notice: 'Course was successfully created.' }\r\n format.json { render courses_path, status: :created, location: @course }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @course.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_path(), notice: 'El curso fue exitosamente creado.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { redirect_to new_course_path, notice: \"Debe escribir por lo menos el nombre del curso para crearlo.\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = current_teacher.courses.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_url, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = current_teacher.courses.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :manage, Course\n @course = Course.new(course_params)\n @course.course_sections.each do |course_section|\n course_section.name = \"#{@course.name} #{course_section.grade_section.name}\"\n end\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n if @course.save\n redirect_to @course, notice: 'Course was successfully created'\n else\n render action: 'new'\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, :notice=> 'Curso creado' }\n format.json { render :json=> @course, :status=> :created, :location=> @course }\n else\n format.html { render :action=> \"new\" }\n format.json { render :json=> @course.errors, :status=> :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to admin_courses_path, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to static_pages_admin_url, notice: 'Course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n @course.user = current_user\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: \"Course was successfully created.\" }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.find(params[:course_id])\n #@grade = Grade.new(params[:grade])\n end", "def create\n # find if there are any courses with both the same name and section number\n duplicate_courses = Course.where(name: course_params[:name], section: course_params[:section])\n # SQL Equivalent (in SQLite):\n # SELECT \"courses\".* FROM \"courses\" WHERE \"courses\".\"name\" = ? AND \"courses\".\"section\" = ?\n # where ? == name of course and section of course\n\n if duplicate_courses.blank?\n # else make a new course based on parameters passed from form\n @course = Course.new(course_params)\n # check validity and successful save\n if @course.valid? && @course.save\n # @course.save SQL Equivalent:\n # INSERT INTO \"courses\"\n # (\"teacher_id\", \"deptName\", \"name\", \"section\", \"created_at\", \"updated_at\")\n # VALUES (?, ?, ?, ?, ?, ?);\n\n\n # redirect\n redirect_to '/admin/index'\n return\n else\n # otherwise check the error\n if @course.invalid?\n flash[:fail] = \"Unable to create course: #{@course.errors.full_messages}\"\n else\n flash[:fail] = \"Unable to create course for unknown reason. Try again!\"\n end\n\n redirect_back(fallback_location: '/admin/index')\n return\n end\n else\n # sent an error\n flash[:fail] = \"There is already a course with that name and section!\"\n redirect_back(fallback_location: '/admin/index')\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to admin_course_url(@course), notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course_detail = CourseDetail.new(course_detail_params)\n\n respond_to do |format|\n if @course_detail.save\n format.html { redirect_to @course_detail, notice: 'Course detail was successfully created.' }\n format.json { render :show, status: :created, location: @course_detail }\n else\n format.html { render :new }\n format.json { render json: @course_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @given_course = GivenCourse.new(given_course_params)\n\n respond_to do |format|\n if @given_course.save\n format.html { redirect_to @given_course, notice: 'Given course was successfully created.' }\n format.json { render :show, status: :created, location: @given_course }\n else\n format.html { render :new }\n format.json { render json: @given_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:course][\"starttime(1i)\"] = '2009'\n params[:course][\"starttime(2i)\"] = '11'\n params[:course][\"starttime(3i)\"] = '14'\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to(@course) }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course added. Warning no Instructor assigned. Go to the manage user history tab and add instructor' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n \n format.html { redirect_to @course, notice: 'course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n ppp @course.errors.full_messages\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to [:admin, @course], :notice => 'Course was successfully created.' }\n format.json { render :json => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user_course = UserCourse.new(user_course_params)\n respond_to do |format|\n if @user_course.save\n format.html { redirect_to @user_course, notice: 'User course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user_course }\n else\n format.html { render action: 'new' }\n format.json { render json: @user_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_course = Admin::Course.new(admin_course_params)\n\n respond_to do |format|\n if @admin_course.save\n format.html { redirect_to @admin_course, notice: t('crud.created_successfully!', name: Admin::Course.model_name.human) }\n format.json { render :show, status: :created, location: @admin_course }\n else\n format.html { render :new }\n format.json { render json: @admin_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course= Course.new(course_params)\n @course.owner_id=current_user.id\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Create course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def course_params\n params.require(:course).permit(:course_id, :name, :description)\n end", "def create\n # Instantiate a new object using form parameters\n attrs = params.permit(:coursenumber, :title, :description, :start_date, :end_date, :created_at, :updated_at, :status, :active, :inactivation_request)\n @instructor = Instructor.find_by_email params[:email]\n\n attrs[:instructor] = @instructor\n if @instructor\n @course = Course.create(attrs)\n redirect_to courses_path\n else\n @course = Course.new\n render new_course_path\n end\n end", "def create\n #@course = Course.new(params[:course])\n # TODO Implement logic for getting course here\n course_code = params[:course][:code]\n # @course = NTNU::API::CourseClient.getCourse(course_code) \n\n respond_to do |format|\n if @course.save\n format.html { redirect_to(@course, :notice => 'Course was successfully created.') }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def course_params\n params.require(:course).permit(:course_title, :course_code)\n end", "def create\n @last_offering = Course.last_offering(params[:course][:number])\n @course = @last_offering.copy_as_new_course\n\n @course.year = params[:course][:year]\n @course.semester = params[:course][:semester]\n respond_to do |format|\n @course.updated_by_user_id = current_user.id if current_user\n if @course.save\n\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to edit_course_path(@course) }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n @course.save\n render_jsonapi_response(@course)\n end", "def course_params\n params.require(:course).permit(:title, :code, :password)\n end", "def create\n @course = CourseAccount.new(id_user:11,id_course: params[:course],coin:5000)\n @course.save()\n session[:id_course] =params[:course]\n render :json =>[@course,session[:id_course]]\n\n end", "def create\n @course = Course.new(new_course_params)\n\n if @course.save\n redirect_to stafftools_course_path(@course)\n else\n render :new\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to( :action => 'show', :id => @course) }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n @course.publisher = current_user\n respond_to do |format|\n if @course.save\n format.html { redirect_to new_course_lesson_path(@course), :notice => 'Course was successfully created.' }\n format.json { render :json => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @classcourse = Classcourse.new(classcourse_params)\n\n respond_to do |format|\n if @classcourse.save\n format.html { redirect_to @classcourse, notice: 'Classcourse was successfully created.' }\n format.json { render :show, status: :created, location: @classcourse }\n else\n format.html { render :new }\n format.json { render json: @classcourse.errors, status: :unprocessable_entity }\n end\n end\n end", "def course_params\n params.require(:course).permit(:course_number, :title, :description, :start_date, :end_date, :is_active, :notifications, :deadlines)\n end", "def create\n if @course.save\n redirect_to @course, notice: 'Course was successfully created.'\n else\n redirect_to action: :new\n end\n end", "def create\n @course = Course.new(course_params)\n\n if @course.save\n @course.generate_join_token\n if current_user.has_role? :instructor\n current_user.courses << @course\n current_user.add_role :instructor, @course\n current_user.add_role :grader, @course\n end\n\n flash[:notice] = \"Course created successfully.\"\n redirect_to @course\n else\n render :action => :new\n end\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to courses_path }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @people_course = PeopleCourse.new(people_course_params)\n\n respond_to do |format|\n if @people_course.save\n format.html { redirect_to @people_course, notice: 'People course was successfully created.' }\n format.json { render :show, status: :created, location: @people_course }\n else\n format.html { render :new }\n format.json { render json: @people_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @titre = \"Creating a course\"\n if params[:formation_id]\n @formation = Formation.find(params[:formation_id])\n @course = @formation.courses.create(course_params)\n else\n @course = Course.new(course_params)\n end\n if @course.save\n redirect_to edit_course_path(@course)\n else\n render 'new'\n end\n end", "def course_params\n params.require(:course).permit(:course_name, :course_desc, :course_subj, :course_cred, :teacher_id)\n end", "def course_params\n params.require(:course).permit(:subject, :code, :title, :description)\n end", "def create\n @type_course = TypeCourse.new(params[:type_course])\n\n respond_to do |format|\n if @type_course.save\n format.html { redirect_to @type_course, notice: 'Type course was successfully created.' }\n format.json { render json: @type_course, status: :created, location: @type_course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @type_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course_name = CourseName.new(course_name_params)\n\n respond_to do |format|\n if @course_name.save\n format.html { redirect_to @course_name, notice: 'Course name was successfully created.' }\n format.json { render :show, status: :created, location: @course_name }\n else\n format.html { render :new }\n format.json { render json: @course_name.errors, status: :unprocessable_entity }\n end\n end\n end", "def course_params\n params.require(:course).permit(:cce_class_id, :title)\n end", "def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to :action => 'index' }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n render \"status/501_not_implemented\", status: :not_implemented\n #@course = Course.new(course_params)\n #\n #if @course.save\n # render :show, status: :created, location: @course\n #else\n # render json: @course.errors, status: :unprocessable_entity\n #end\n end", "def create\n @schedule_course = ScheduleCourse.new(schedule_course_params)\n\n respond_to do |format|\n if @schedule_course.save\n format.html { redirect_to @schedule_course, notice: 'Schedule course was successfully created.' }\n format.json { render :show, status: :created, location: @schedule_course }\n else\n format.html { render :new }\n format.json { render json: @schedule_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curriculum_course = CurriculumCourse.new(curriculum_course_params)\n\n respond_to do |format|\n if @curriculum_course.save\n format.html { redirect_to @curriculum_course, notice: 'Curriculum course was successfully created.' }\n format.json { render :show, status: :created, location: @curriculum_course }\n else\n format.html { render :new }\n format.json { render json: @curriculum_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def course_params\n params.require(:course).permit(:name, :number, :description, :grade_level_id, :academic_year_id, :academic_term_id, :employee_id,\n {:academic_term_ids => []},\n {:course_sections_attributes => [:id, :name, :grade_section_id, :instructor_id, :_destroy]},\n {:course_texts_attributes => [:id, :book_title_id, :order_no, :_destroy]})\n end", "def create\n @course=Course.find(params[:course_id])\n puts @course.id\n @course_maker = CourseMaker.new(course_maker_params)\n @course_maker.course=@course\n\n respond_to do |format|\n if @course_maker.save\n format.html { redirect_to @course, notice: 'Course maker was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n \n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, :notice => t('selecao_admin.flash_messages.successfully_created', :model => @course.class.model_name.human) }\n format.json { render :json => @course, :status => :created, :location => @course }\n format.js\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @course = Course.new(params[:course])\n @course_template = CourseNumber.find(params[:course][:course_number_id]) unless params[:course][:course_number_id].blank?\n if @course_template\n @course.name = @course_template.name\n @course.number = @course_template.number \n end\n\n respond_to do |format|\n if @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to(@course) }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n\n #section_chunks = get_chunks(params)\n sections = JSON.parse(params['sections'])\n\n # The course has been created by the signed-in user.\n @course.user_id = current_user.id\n respond_to do |format|\n if @course.save\n # Save the course's subcomponents to the course.\n update_section_chunks(sections)\n\n format.html { redirect_to @course }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render new_course_path }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @person_course = PersonCourse.new(person_course_params)\n\n respond_to do |format|\n if @person_course.save\n format.html { redirect_to @person_course, notice: 'Person course was successfully created.' }\n format.json { render :show, status: :created, location: @person_course }\n else\n format.html { render :new }\n format.json { render json: @person_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.new(course_params)\n @course.user_id = current_user.id\n @course.save\n respond_with(@course, location: @course)\n end", "def create\n @university_course = UniversityCourse.new(university_course_params)\n\n respond_to do |format|\n if @university_course.save\n format.html { redirect_to @university_course, notice: 'University course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @university_course }\n else\n format.html { render action: 'new' }\n format.json { render json: @university_course.errors, status: :unprocessable_entity }\n end\n end\n end", "def course_params\n params.require(:course).permit(:course_id, :name, :teacher_id, :hours)\n end", "def course_params\n params.require(:course).permit(:title, :description, :short_description, :language, :level, :price)\n end" ]
[ "0.786746", "0.7648681", "0.76388013", "0.7608392", "0.7579288", "0.7557643", "0.75401956", "0.7527627", "0.7508889", "0.7508591", "0.7502794", "0.74793756", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7472013", "0.7471716", "0.7464716", "0.74602383", "0.74193805", "0.74154115", "0.7413115", "0.7406147", "0.73816365", "0.73816365", "0.73816365", "0.73816365", "0.73816365", "0.73816365", "0.73816365", "0.73668736", "0.7355227", "0.73545927", "0.7332231", "0.730768", "0.72942203", "0.7283079", "0.725519", "0.72542995", "0.72518355", "0.724069", "0.72358394", "0.72223794", "0.7206209", "0.71935517", "0.71826214", "0.71791315", "0.7170623", "0.71618927", "0.71295595", "0.7123925", "0.7110212", "0.7102408", "0.7090899", "0.70823896", "0.708063", "0.7059667", "0.70555365", "0.7055278", "0.7049298", "0.7038916", "0.7037783", "0.7037234", "0.7036997", "0.70279115", "0.7024971", "0.7020923", "0.7015807", "0.70063484", "0.7003579", "0.70003045", "0.6973608", "0.6960091", "0.69559556", "0.69528484", "0.6944707", "0.6943939", "0.69429237", "0.69427776", "0.6939121", "0.6937153", "0.6931539", "0.6930025", "0.69269985", "0.6923801", "0.69227517", "0.6921919", "0.6921411", "0.6921403", "0.6918993", "0.69141644", "0.69113976" ]
0.8029758
0
group_owner_id defaults to the current owner_id
def authorize_ec2_security_group(group_name, group_owner_id=owner_id) key = group_name.match(/^sg-/) ? 'EC2SecurityGroupId' : 'EC2SecurityGroupName' authorize_ingress({ key => group_name, 'EC2SecurityGroupOwnerId' => group_owner_id }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group_owner\n User.find_by(id: self.user_id)\n end", "def owner_of(group)\n current_user.is_owner?(group)\n end", "def with_group_owner\n self\n end", "def set_owner(id)\n self.owner_id = id\n end", "def owner_user_id\n return @owner_user_id\n end", "def owner_user_id\n return @owner_user_id\n end", "def owner_id\n @sg.owner_id\n end", "def owner_id\n @sg.owner_id\n end", "def owner_id\n data.owner_id\n end", "def group_owner?\n super\n end", "def group_owner?\n super\n end", "def owner\n\t\tself.project_groups.find_by_project_creator(true).try(:user)\n\tend", "def owner_id\n data[:owner_id]\n end", "def owner_id\n data[:owner_id]\n end", "def group\n object.group.id\n end", "def owned_groups\n @owned_groups = Group.where(\"owner_id = ?\", current_user)\n end", "def owner\n if object.owner && (current_user.lead? || object.owner.id == current_user.id)\n object.owner.id\n else\n nil\n end\n end", "def owner\n @owner ||= User.find(owner_user_id)\n end", "def group_id\n super\n end", "def edit\n if GroupsController.group_owner? current_user.id, params[:id]\n set_group\n else\n respond_to do |format|\n format.html { redirect_to groups_path, alert: \"Can't Edit. You are not the group owner\" }\n format.json { render json: \"Only owners can edit the respective group page\", status: :unauthorized }\n end\n end\n end", "def owner\n user_id\n end", "def set_group\n @group = Group.find_by(id: params[:id],user_id: current_handle_user.id)\n end", "def group_owners_only\n where('group_owner_id.null': true)\n end", "def group\n self.event.owner\n end", "def group_params\n params.require(:group).permit(:name, :owner_id)\n end", "def set_owner\n @owner = Owner.find_by_owner_user_id(current_owner_user.id)\n end", "def autoset_owner\n bypass_auth do\n if accessor\n self.owner_id ||= accessor.id\n end\n end\n\n true # this is very important!\n end", "def store_owner_id\n self.user_id = self.album.user_id\n end", "def filter_owner(group_ids)\n group_ids = Array(group_ids)\n group_ids.delete(user.my_group_id)\n group_ids\n end", "def owner\n get_user owner_id\n end", "def correct_owner_id\n return 0 if accountant? or admin?\n return session[:user_id] if reseller?\n return session[:owner_id]\n end", "def group_id\n @attributes[:group_id]\n end", "def group_id\n @attributes[:group_id]\n end", "def group_id\n @attributes[:group_id]\n end", "def initialize_mailing_list_group_with_owner\n initialize_mailing_list_group\n update_ok(!@mailing_list_group.nil? && current_user.id == @mailing_list_group.user_id)\n end", "def owner=(_)\n end", "def set_group\n @group = current_user.groups.find(params[:group_id])\n end", "def set_group\n #@group = Group.find(params[:id])\n end", "def group_id\n get_info[:groupID]\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def set_owner\n @owner = Owner.find(params[:owner_id])\n end", "def update\n if GroupsController.group_owner? current_user.id, params[:id]\n set_group\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to group_path(@group), alert: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to groups_path, alert: \"Not updated. You are not the group owner\" }\n format.json { render json: \"Only owners can edit the respective group page\", status: :unauthorized }\n end\n end\n end", "def owner\r\n\t\t\t`#{BITS::BITSADMIN} /getowner {#{@id}}`\r\n\t\tend", "def group_id\n \tregisterable.class.name == \"Group\" ? registerable.id : nil\n end", "def set_group\n if is_user_member_of_group? current_user, Group.find(params[:id])\n @group = Group.find(params[:id])\n else\n @group = Group.new\n end\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def group() self['group'] || node[:users]['root'][:primary_group] ; end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def owner\n {owner_id: self.object.user.id, \n owner_account: self.object.user.email}\n end", "def group; Group.get(self.group_id); end", "def set_group\n # byebug\n @group = Group.find(params[:id])\n end", "def set_group_user\n @group_user = group_user.find(params[:id])\n end", "def set_agroup\r\n @agroup = Agroup.find(params[:id])\r\n end", "def edit\n @group = current_user.created_groups.find(params[:id])\n end", "def set_os_groups_principal\n @os_groups_principal = OsGroupsPrincipal.find(params[:id])\n end", "def owner(arg=nil)\n arg.nil? ? @owner : @owner = arg.to_s\n end", "def group_members_only\n where('group_owner_id.not_null': true)\n end", "def show\n @owner_profile = User.find(@group.owner_id).profile\n end", "def set_group\n @group = Group.with_attached_logo.includes(:conversations).friendly.find(params[:id])\n end", "def owner\n @owner\n end", "def group_owner_entry?\n group_entry? && principle == \"GROUP\"\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if !current_user || (!current_user.is_admin && [email protected]?(current_user))\n format.html { redirect_to(@group, :notice => 'No permissions to edit group.')}\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n\n elsif @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def owner\n return self.user\n end", "def current_group\n end", "def manage_group\n @group = Group.find(params[:id])\n end", "def set_owner #:doc:\n self.owner_class.owner= get_current_owner\n end", "def create\n ip = request.location\n @user = current_user\n @group = @user.groups_as_owner.new(params[:group])\n params[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n @group.school_id = @user.school_id\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def group_ids\n @group_ids ||= current_user.group_ids\n end", "def owner\n User.find_by(id: user_id)\n end", "def group\n strong_memoize(:group) do\n if params[:group_id].present? && valid_request?\n the_group = Group.find_by(id: params[:group_id])\n can?(current_user, :read_group, the_group) ? the_group : nil\n end\n end\n end", "def set_object_owner\n @object_owner = ObjectOwner.find(params[:id])\n end", "def demote\n @group_user = @parent.find(params[:id]) #get the record\n\n if !current_user or (!current_user.is_admin and [email protected]?(current_user)) or current_user == @group_user.user\n redirect_to @group, :notice => \"You cannot demote that user.\"\n return\n end\n\n respond_to do |format|\n # We'll set is_owner to true. Remember update_attribute bypasses validations!\n if @group_user.update_attribute(:is_owner, false)\n format.html { redirect_to(@group, :notice => 'Group user is now a regulare member.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group_user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_owner\n @goal.owner = current_user\n end", "def set_owner(ownername)\n @result.owner = ownername\n end", "def owner\n @owner ||= User.new(connection, :login => @attributes[:owner])\n end", "def owner() self['owner'] || 'root' ; end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end" ]
[ "0.8172053", "0.77662015", "0.7726203", "0.71466225", "0.70898277", "0.70898277", "0.6991115", "0.6990758", "0.69636214", "0.69533837", "0.69533837", "0.6952436", "0.6907562", "0.6907562", "0.68503493", "0.6818043", "0.6802009", "0.67520535", "0.6716727", "0.66990435", "0.66601264", "0.6639911", "0.6599507", "0.6528326", "0.6515356", "0.6503491", "0.6502533", "0.64724535", "0.64706314", "0.64626837", "0.6435735", "0.6427777", "0.6427777", "0.6427777", "0.6388946", "0.6311793", "0.6307929", "0.63019717", "0.6293626", "0.6289658", "0.6289658", "0.6289658", "0.6289658", "0.6289658", "0.6282594", "0.6282529", "0.6270714", "0.6268587", "0.6264972", "0.62457484", "0.62457484", "0.62457484", "0.62457484", "0.62457484", "0.62457484", "0.62447834", "0.6244598", "0.6244598", "0.6244598", "0.6244598", "0.6244598", "0.62438107", "0.62402964", "0.62402964", "0.62402964", "0.62402964", "0.62402964", "0.62402964", "0.62402964", "0.62351495", "0.6229693", "0.6226133", "0.62172174", "0.61999285", "0.61896676", "0.6177528", "0.61591923", "0.61587644", "0.61514974", "0.6150484", "0.61216396", "0.61215496", "0.6121249", "0.6119645", "0.61155677", "0.61037505", "0.6102193", "0.6098494", "0.6095188", "0.60774773", "0.6075084", "0.6072586", "0.60648113", "0.6059913", "0.60562927", "0.60476756", "0.60461104", "0.60422885", "0.60415524", "0.60415524", "0.60415524" ]
0.0
-1
Add the current machine to the RDS security group.
def authorize_me authorize_ip_address(Fog::CurrentMachine.ip_address) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n ec2 = self.class.new_ec2(@resource.value(:user), @resource.value(:password))\n group = @resource.value(:name)\n begin\n ec2.describe_security_groups({:group_name => group})\n rescue Exception => e\n ec2.create_security_group({ \n :group_name => group,\n :group_description => @resource.value(:desc)\n })\n end\n # if instance in that security group exists, start it\n # otherwise just create a new instance \n ec2.run_instances(\n { :image_id => @resource.value(:image),\n # security groups\n :security_group => group,\n :instance_type => @resource.value(:type)\n })\n end", "def security_group=(new_cidr_block)\n new_cidr_block = new_cidr_block + '/32' unless new_cidr_block.include? \"/\"\n @environment.vpc.security_groups.each do |sg|\n @security_group = sg if sg.group_name == 'SshSecurityGroup' + new_cidr_block\n end\n\n # only create security group if it does not exist\n if @security_group.nil?\n ec2 = Aws::EC2::Resource.new(region: 'us-west-2')\n\n @security_group = ec2.create_security_group(\n group_name: 'SshSecurityGroup' + new_cidr_block,\n description: 'Enable SSH access via port 22',\n vpc_id: @environment.vpc.id\n )\n\n @security_group.authorize_egress(\n ip_permissions: [\n ip_protocol: 'tcp',\n from_port: 22,\n to_port: 22,\n ip_ranges: [\n cidr_ip: new_cidr_block\n ]\n ]\n )\n end\n end", "def create_security_group_for_inception_vm\n \n return if settings[\"inception\"][\"security_group\"] \n\n ports = {\n ssh_access: 22,\n ping: { protocol: \"icmp\", ports: (-1..-1) } \n }\n security_group_name = \"#{settings.bosh_name}-inception-vm\"\n\n provider.create_security_group(security_group_name, \"inception-vm\", ports)\n\n settings[\"inception\"] ||= {}\n settings[\"inception\"][\"security_group\"] = security_group_name\n save_settings!\n end", "def add_to_group(group)\n self.memberships.create(group_id: group.id)\n end", "def create_db_security_group(name, description = name)\n request({\n 'Action' => 'CreateDBSecurityGroup',\n 'DBSecurityGroupName' => name,\n 'DBSecurityGroupDescription' => description,\n :parser => Fog::Parsers::AWS::RDS::CreateDBSecurityGroup.new\n })\n end", "def add_instance(params)\n Fog::Logger.deprecation(\n \"#{self.class}.#{__method__} is deprecated, use Fog::Compute::Google::InstanceGroup.#{__method__} instead [light_black](#{caller(0..0)})[/]\"\n )\n params[:instance] = [params[:instance]] unless params[:instance] == Array\n service.add_instance_group_instances(params[:group], params[:zone], params[:instance])\n end", "def modify_security_group(db_instance_identifier, vpc_security_groups)\n modify_db_instance(db_instance_identifier: db_instance_identifier, vpc_security_group_ids: vpc_security_groups)\n end", "def add_vm_to_vm_group(vm, vm_group_name)\n DrsLock.new(@vm_attribute_manager, DRS_LOCK_VMGROUP ).with_drs_lock do\n vm_group = find_vm_group(vm_group_name)\n logger.debug(\"VmGroup: #{vm_group_name} already exists\") unless vm_group.nil?\n\n vm_group_spec = VimSdk::Vim::Cluster::VmGroup.new\n vm_group_spec.vm = vm_group ? vm_group.vm.concat([vm]) : [vm]\n vm_group_spec.name = vm_group_name\n\n group_spec = VimSdk::Vim::Cluster::GroupSpec.new\n group_spec.info = vm_group_spec\n\n group_spec.operation = vm_group ? VimSdk::Vim::Option::ArrayUpdateSpec::Operation::EDIT : VimSdk::Vim::Option::ArrayUpdateSpec::Operation::ADD\n\n config_spec = VimSdk::Vim::Cluster::ConfigSpecEx.new\n config_spec.group_spec = [group_spec]\n\n logger.debug(\"Adding VM to VM group: #{vm_group_name}\")\n reconfigure_cluster(config_spec)\n end\n end", "def modify_db_instance(db_name, apply_immediately, options={})\n if security_groups = options.delete('DBSecurityGroups')\n options.merge!(Fog::AWS.indexed_param('DBSecurityGroups.member.%d', [*security_groups]))\n end\n\n if vpc_security_groups = options.delete('VpcSecurityGroups')\n options.merge!(Fog::AWS.indexed_param('VpcSecurityGroupIds.member.%d', [*vpc_security_groups]))\n end\n\n request({\n 'Action' => 'ModifyDBInstance',\n 'DBInstanceIdentifier' => db_name,\n 'ApplyImmediately' => apply_immediately,\n :parser => Fog::Parsers::AWS::RDS::ModifyDBInstance.new\n }.merge(options))\n end", "def << group\n group.set_fleet @fleet.name\n end", "def add_instance(opts)\n unless %w[app util].include?(opts[:role].to_s)\n # Fail immediately because we don't have valid arguments.\n raise InvalidInstanceRole, \"Instance role must be one of: app, util\"\n end\n\n # Sanitize the name to remove whitespace if there is any\n if opts[:name]\n name = opts[:name].gsub(/\\s+/, '')\n end\n\n if opts[:role] == 'util'\n unless name && name.length > 0\n raise InvalidInstanceName, \"When specifying a util instance you must also specify a name.\"\n end\n end\n \n request = { \"role\" => opts[:role], \"name\" => opts[:name] }\n request['snapshot_id'] = opts[:snapshot_id] if opts.key?(:snapshot_id)\n request['instance_size'] = opts[:instance_size] if opts.key?(:instance_size)\n\n # We know opts[:role] is right, name can be passed straight to the API.\n # Return the response body for error output, logging, etc.\n return api.post(\"/environments/#{id}/add_instances\", :request => request)\n end", "def add_group_member\n @group_member = RockGroupMember.find_or_initialize_by({\n GroupId: @group_id,\n PersonId: person.mapped_record.person_alias.PersonId\n })\n @group_member.IsSystem = false\n @group_member.GroupRoleId = 266 # member for worship services\n @group_member.GroupMemberStatus = 1 #\n @group_member.Guid = SecureRandom.uuid\n @group_member.CreatedDateTime = Time.new\n @group_member.Note = 'Imported From Arena'\n\n @group_member.save!\n end", "def add_security_group_queue(userid, security_group)\n task_opts = {\n :action => \"adding Security Group to Instance for user #{userid}\",\n :userid => userid\n }\n\n queue_opts = {\n :class_name => self.class.name,\n :method_name => 'add_security_group',\n :instance_id => id,\n :role => 'ems_operations',\n :queue_name => queue_name_for_ems_operations,\n :zone => my_zone,\n :args => [security_group]\n }\n\n MiqTask.generic_action_with_callback(task_opts, queue_opts)\n end", "def set_security_group\n @security_group = SecurityGroup.find(params[:id])\n end", "def create_group\n group_params = params.require(:group_params)\n\n group_id = @infra.ec2.create_security_group({group_name: group_params[0], description: group_params[1], vpc_id: group_params[3]})\n @infra.ec2.create_tags(resources: [group_id[:group_id]], tags: [{key: 'Name', value: group_params[2]}])\n\n render text: I18n.t('security_groups.msg.change_success')\n end", "def create_db_instance(db_name, options={})\n \n if security_groups = options.delete('DBSecurityGroups')\n options.merge!(Fog::AWS.indexed_param('DBSecurityGroups.member.%d', [*security_groups]))\n end\n \n request({\n 'Action' => 'CreateDBInstance',\n 'DBInstanceIdentifier' => db_name,\n :parser => Fog::Parsers::AWS::RDS::CreateDBInstance.new,\n }.merge(options))\n end", "def add_group_as_member(group)\n self.groups.push group\n end", "def aws_create_security_group( name, opts = {} )\n opts = deep_merge_hashes( @aws_default_sg_options, opts )\n region = opts.delete( :region )\n ec2 = AWS::EC2.new.regions[ region ]\n unless ec2.security_groups.find { |sg| sg.name == name }\n ec2.security_groups.create( name, opts )\n end\n end", "def addUserToGroup\n @user_to_add = User.find(params[:user_to_add])\n @current_group = Group.find_by_id(session[:current_group_id])\n @user_to_add.groups << @current_group\n redirect_to findAvailableUsers_url, notice: 'User was successfully added.'\n end", "def ensure_security_group_prepared\n provider.create_security_group(system_config.security_group, required_public_ports)\n end", "def create_group\n group_params = params.require(:group_params)\n\n group_id = @infra.ec2.create_security_group({ group_name: group_params[0], description: group_params[1], vpc_id: group_params[3] })\n @infra.ec2.create_tags(resources: [group_id[:group_id]], tags: [{ key: 'Name', value: group_params[2] }])\n\n render plain: I18n.t('security_groups.msg.change_success')\n end", "def set_resource_group_machine\n @resource_group_machine = ResourceGroupMachine.find(params[:id])\n #authorize(@resource_group_machine)\n end", "def add_resource(*names)\n self.synchronize do\n # Recording membership first, used for ALL_UP event\n names.each do |name|\n g = OmfEc.experiment.group(name)\n if g # resource to add is a group\n @members += g.members\n self.add_resource(*g.members.uniq)\n else\n @members << name.to_s\n OmfEc.subscribe_and_monitor(name) do |res|\n info \"Config #{name} to join #{self.name}\"\n res.configure(membership: self.id)\n end\n end\n end\n end\n end", "def create(name, desc=nil, addresses=[], ports=[], protocols=[], &each_group)\n desc ||= \"Security Group #{name}\"\n ret = @@ec2.create_security_group(:group_name => name, :group_description => desc)\n return false unless (ret && ret['return'] == 'true')\n authorize(name, addresses, ports, protocols)\n get(name, &each_group)\n end", "def add_switch(hostname, descr, community)\n db_cached_connect\n\n retvalue = nil\n\n begin\n modify_switch(nil, hostname, descr, community)\n rescue DBI::ProgrammingError => e\n if e.message[/Key .* already exists/]\n STDERR.puts \"This switch (#{hostname}) already exists, not adding.\"\n else\n raise e\n end\n end\n\n return retvalue\n end", "def add_to_host\n raise \"Unknown guest host! You must set current_host_id before creating\" unless current_host_id > 0\n user = User.find(current_host_id) # Raise error if not found\n user.add_guest(self, @circle)\n self.is_emergency_contact_for(user) if @emergency_contact\n true\n end", "def security_group(sg_name, hsh={}, &block)\n sg_name = sg_name.to_s\n security_groups[sg_name] ||= Ironfan::Cloud::SecurityGroup.new(self, sg_name)\n security_groups[sg_name].configure(hsh, &block)\n security_groups[sg_name]\n end", "def add(name_, opts_={})\n @group._add(name_, opts_)\n end", "def add_user(user)\n group_members.create(group: self, user: user, accepted: DateTime.now)\n end", "def security_group\n node = 'AWS_SECURITY_GROUP'\n q = []\n\n # security_group node\n q.push(_upsert({ node: node, id: @name }))\n\n # vpc node and relationship\n if @data.vpc_id\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_VPC',\n child_name: @data.vpc_id,\n relationship: 'MEMBER_OF_VPC'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # ingress rules\n @data.ip_permissions.each do |ingress|\n ingress.ip_ranges.each_with_index do |ip_range, i|\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_SECURITY_GROUP_INGRESS_RULE',\n child_name: \"#{@name}-#{ingress.ip_protocol}-#{ingress.to_port}-#{i}\",\n relationship: 'HAS_INGRESS_RULE',\n relationship_attributes: {\n cidr_ip: ip_range.cidr_ip,\n ip_protocol: ingress.ip_protocol,\n to_port: ingress.to_port,\n from_port: ingress.from_port,\n direction: 'ingress'\n }\n }\n\n q.push(_upsert_and_link(opts))\n end\n end\n\n # egress rules\n @data.ip_permissions_egress.each do |egress|\n egress.ip_ranges.each_with_index do |ip_range, i|\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_SECURITY_GROUP_EGRESS_RULE',\n child_name: \"#{@name}-#{egress.ip_protocol}-#{egress.to_port}-#{i}\",\n relationship: 'HAS_EGRESS_RULE',\n relationship_attributes: {\n cidr_ip: ip_range.cidr_ip,\n ip_protocol: egress.ip_protocol,\n to_port: egress.to_port,\n from_port: egress.from_port,\n direction: 'egress'\n }\n }\n\n q.push(_upsert_and_link(opts))\n end\n end\n\n q\n end", "def add_machine(opts = {})\n backend_name = opts.fetch(:backend, 'default')\n dryrun = opts.fetch(:dryrun, false)\n hostname = opts.fetch(:hostname)\n\n if machine = Boxcutter::Server.find_by_hostname(\"#{hostname}.blueboxgrid.com\")\n\n app = Boxcutter::LoadBalancer::Application.all.first\n\n app.services.each do |service|\n if backend = service.backends.detect {|backend| backend.name == backend_name}\n log \"Adding machine #{machine.hostname} to backend #{backend.name}\"\n unless dryrun\n response = backend.add_machine(machine.id, :port => 80)\n log \"Added #{machine.hostname} to #{backend.name} with response: #{response.body}\"\n else\n log \"#{machine.hostname} was not added to the backend because --dryrun was specified\"\n end\n else\n log \"Could not find default backend on #{service}\"\n end\n end\n else\n log \"Could not find server '#{hostname}' on BlueBoxGroup\"\n end\n end", "def add\n # check if it exists\n as_exist = @compute_client.availability_sets.check_availability_set_exists(@rg_name, @as_name)\n if as_exist\n OOLog.info(\"Availability Set #{@as_name} exists in the #{@location} region.\")\n else\n # need to create the availability set\n OOLog.info(\"Creating Availability Set '#{@as_name}' in #{@location} region\")\n\n begin\n #if we are using the managed disk attached to vm availability set needs to setup use_managed_disk to true\n\n\n @compute_client.availability_sets.create(resource_group: @rg_name, name: @as_name, location: @location, use_managed_disk: true, platform_fault_domain_count: Utils.get_fault_domains(@location\n ), platform_update_domain_count: Utils.get_update_domains)\n rescue MsRestAzure::AzureOperationError => e\n OOLog.fatal(\"Error adding an availability set: #{e.body}\")\n rescue => ex\n OOLog.fatal(\"Error adding an availability set: #{ex.message}\")\n end\n end\n end", "def add_instance(instance)\n register_response = client.register_instances_with_load_balancer(load_balancer_name: name,\n instances: [{instance_id: instance.ec2_instance_id}])\n remaining_instance_count = register_response.instances.size\n puts \"Added #{instance.hostname} to ELB #{name}. Attached instances: #{remaining_instance_count}\".light_blue\n _wait_for_instance_health_check(instance)\n end", "def create_security_group(security_group_name)\n ports = {\n ssh_access: 22,\n nats_server: 4222,\n message_bus: 6868,\n blobstore: 25250,\n bosh_director: 25555,\n bosh_registry: 25777\n }\n # TODO: New stemcells to be released will use 25777, so this can be deleted\n ports[:openstack_registry] = 25889 if openstack?\n\n provider.create_security_group(security_group_name, \"microbosh\", ports)\n\n settings[\"bosh_cloud_properties\"][provider_name][\"default_security_groups\"] = [security_group_name]\n settings[\"bosh_security_group\"] = {}\n settings[\"bosh_security_group\"][\"name\"] = security_group_name\n settings[\"bosh_security_group\"][\"ports\"] = {}\n ports.each { |name, port| settings[\"bosh_security_group\"][\"ports\"][name.to_s] = port }\n save_settings!\n end", "def add_to_group(group)\n raise 'InvalidGroup' unless group.respond_to?(:add_user)\n # just be lazy and hand off to the group to do the work...\n group.add_user(self)\n end", "def set_aws_security_group_egress\n @aws_security_group_egress = AwsSecurityGroupEgress.find(params[:id])\n end", "def add_watcher_group(group)\n if Watcher.where(\"watchable_type='#{self.class}' and watchable_id = #{self.id} and user_id = '#{group.id}'\").limit(1).blank?\n # insert directly into table to avoid user type checking\n Watcher.connection.execute(\"INSERT INTO #{Watcher.table_name} (user_id, watchable_id, watchable_type) VALUES (#{group.id}, #{self.id}, '#{self.class.name}')\")\n end\n end", "def add_group!( group )\n save if add_group( group )\n end", "def add_to_lb(group)\n @haproxy.identity_filter(@load_balancer)\n # We don't have to identify the nodes in the group\n # for every action. I'm doing it here to make each\n # method easier to read\n @rpcutil.class_filter(group)\n begin\n @rpcutil.ping.each do |node|\n hostname = node.results[:sender]\n # Disable the nodes\n @haproxy.enable(:backend => 'puppetcamp', :server => hostname).each do |rpcresult|\n if rpcresult.results[:statuscode] != 0\n raise LoadBalancerAddException, hostname\n end\n end\n end\n ensure\n @haproxy.reset_filter\n @rpcutil.reset_filter\n end\nend", "def select_security_group\n compute.security_groups.each { |s| [s.name, s.id] }\n end", "def create_secgroup(group)\n connect = aws_api_connect('EC2_Client')\n begin\n p group[:name]\n sec_id = connect.describe_security_groups({\n filters: [\n {\n name: \"group-name\",\n values: [group[:name]],\n },\n ],\n }).security_groups[0].group_id\n return sec_id\n rescue => e\n not_created = true\n end\n\n if not_created == true\n resp = aws_api_connect(\"EC2_Resource\")\n pants = resp.create_security_group({\n group_name: group[:name], # required\n description: group[:description], # required\n vpc_id: group[:vpc_id],\n })\n secgroup_id = pants.id\n puts \"Created secgroup id #{group[:name]} with id #{secgroup_id}.\"\n return secgroup_id\n end\n end", "def groupadd(group)\n # XXX I don't like specifying the path to groupadd - need to sort out paths before long\n send(run_method, \"grep '#{group}:' /etc/group || sudo /usr/sbin/groupadd #{group}\")\n end", "def create_security_group_iso(iso)\n @logger.info(\"Creating SecurityGroup #{iso.name}\")\n sg = SugarCRM::SecurityGroup.new(:name => iso.name) unless find_sugarcrm_object('security_group','name', iso.name)\n sg.save! if sg\n end", "def adjust_security_groups\n\n all_regions.each do |region|\n c = connection(region)\n g = c.security_groups.get(primary_group)\n \n g.authorize_port_range(1024..65535, :cidr_ip => \"#{master.public_ip_address}/32\")\n nodes.each do |node|\n g.authorize_port_range(1024..65535, :cidr_ip => \"#{node.public_ip_address}/32\")\n end\n end\n end", "def <<(group) \n @groups[group.name] = group\n end", "def addrole\n\t\tself.add_role :Guest\n\tend", "def update_security_groups(elb_name, vpc_id, security_groups)\n @elb.apply_security_groups_to_load_balancer({\n load_balancer_name: elb_name,\n security_groups: security_groups.map do |sg_name|\n SecurityGroups::vpc_security_groups[vpc_id][sg_name].group_id\n end\n })\n end", "def attach_to_elb(instance, elb_name, subnet = nil)\n begin\n @log.info \"\"\n @log.info \"Adding to ELB: #{elb_name}\"\n elb = AWS::ELB.new\n AWS.memoize do\n unless subnet\n # Build list of availability zones for any existing instances\n zones = { }\n zones[instance.availability_zone] = instance.availability_zone\n elb.load_balancers[elb_name].instances.each do |elb_instance|\n zones[elb_instance.availability_zone] = elb_instance.availability_zone\n end\n \n # Build list of existing zones\n existing_zones = { }\n elb.load_balancers[elb_name].availability_zones.each do |zone|\n existing_zones[zone.name] = zone\n end\n \n # Enable zones\n zones.keys.each do |zone_name|\n elb.load_balancers[elb_name].availability_zones.enable(zones[zone_name])\n end\n \n # Disable zones\n existing_zones.keys.each do |zone_name|\n elb.load_balancers[elb_name].availability_zones.disable(existing_zones[zone_name]) unless zones.has_key?(zone_name)\n end\n end\n \n elb.load_balancers[elb_name].instances.register(instance)\n end\n rescue StandardError => bang\n @log.error \"Error adding to load balancers: \" + bang.to_s\n end\n end", "def add_user_to_group(user, group)\n\t\t\tend", "def add_user(newuser)\n @group_users.push(newuser)\n end", "def add_server(key, data)\n rightscale_deprecated[:server] = Mash.new unless rightscale_deprecated.has_key?(:server)\n server_names = {\n \"RS_sketchy\" => \"sketchy\",\n \"RS_syslog\" => \"syslog\",\n \"RS_lumberjack\" => \"lumberjack\",\n \"RS_server\" => \"core\"\n }\n rightscale_deprecated[:server][server_names[key]] = data unless (server_names[key] == nil)\nend", "def add_hosts_group\n puppet_ip = any_hosts_as?(:loadbalancer) ? loadbalancer.ip : master.ip\n hosts_group = {\n \"name\" => \"Clamps Managed Hosts\",\n \"rule\" => [\"or\", [\"=\", %w[fact id], \"root\"]],\n \"parent\" => pe_infra_uuid,\n \"classes\" => {\n \"hosts\" => {\n \"purge_hosts\" => false,\n \"collect_all\" => true,\n \"host_entries\" => {\n \"puppet\" => { \"ip\" => puppet_ip }\n }\n }\n }\n }\n\n dispatcher.find_or_create_node_group_model(hosts_group)\nend", "def allowSecurityManagement()\n banner(\"Allow Security\")\n @run.society.each_enclave() do |enclave|\n securityAgents = getSecurityAgents(enclave)\n securityAgentsName = \"SecurityAgentsIn#{enclave}\"\n declareSet(securityAgentsName, securityAgents)\n permit(enclaveAgentsName(enclave), securityAgentsName,\n \"AllowSecurityManagement-#{enclave}-I\",\n [ enclave ])\n permit(securityAgentsName, enclaveAgentsName(enclave),\n \"AllowSecurityManagement-#{enclave}-II\",\n [ enclave ])\n end\n end", "def add_to_group(group_path, group_name)\n group = RubyAem::Resources::Group.new(@client, group_path, group_name)\n group.add_member(@call_params[:name])\n end", "def add_default_group_membership!\n return if guest?\n return if Account.global_tenant?\n\n Hyrax::Group.find_or_create_by!(name: Ability.registered_group_name).add_members_by_id(id)\n end", "def add_schedule_to_storage(group, params) \n sl = ScrapingAuthenticate.new\n sp = ScrapingPomelo.new\n if group.storage\n sp.load(group.storage.path)\n end\n if sl.login_pomelo?(params[:user], params[:password])\n group.storage.destroy if group.storage\n\n ## The .load storage brings the last temporal user fetched too.\n ## So if a new user is going to be fetched the .load couldn't being \n ## executed after him/her .login pomelo because the scraping authenticate \n ## takes the name of the temporal user while .login.\n\n ## In other words, the .student_info is being executed but the name inside \n ## the matrix is the one from the student loaded. Then the repeated cells are\n ## deleted by the .unique\n\n #@sp.set_rails_id_temporal_student(@current_user.id) #The name of the person will be set!\n sp.student_info(true)\n s = Storage.create(path:sp.save(Storage.get_path))\n group.update_attribute(:storage_id, s.id)\n return true\n else\n return false\n end \n end", "def set_security_groups(lb_id, security_group_ids)\n params = {}\n\n params.merge!(Fog::AWS.serialize_keys('SecurityGroups', security_group_ids))\n request({\n 'Action' => 'SetSecurityGroups',\n 'LoadBalancerArn' => lb_id,\n :parser => Fog::Parsers::AWS::ELBV2::SetSecurityGroups.new\n }.merge!(params))\n end", "def create_security_group(name, vpc_id)\n sg = ec2.create_security_group({\n group_name: name,\n description: \"Kontena Grid\",\n vpc_id: vpc_id\n })\n\n sg.authorize_ingress({ # SSH\n ip_protocol: 'tcp', from_port: 22, to_port: 22, cidr_ip: '0.0.0.0/0'\n })\n sg.authorize_ingress({ # HTTP\n ip_protocol: 'tcp', from_port: 80, to_port: 80, cidr_ip: '0.0.0.0/0'\n })\n sg.authorize_ingress({ # HTTPS\n ip_protocol: 'tcp', from_port: 443, to_port: 443, cidr_ip: '0.0.0.0/0'\n })\n sg.authorize_ingress({ # OpenVPN\n ip_protocol: 'udp', from_port: 1194, to_port: 1194, cidr_ip: '0.0.0.0/0'\n })\n sg.authorize_ingress({ # Overlay / Weave network\n ip_permissions: [\n {\n from_port: 6783, to_port: 6783, ip_protocol: 'tcp',\n user_id_group_pairs: [\n { group_id: sg.group_id, vpc_id: vpc_id }\n ]\n },\n {\n from_port: 6783, to_port: 6784, ip_protocol: 'udp',\n user_id_group_pairs: [\n { group_id: sg.group_id, vpc_id: vpc_id }\n ]\n }\n ]\n })\n\n sg\n end", "def add_group(group, gid=nil)\n\t\t\t\tCfruby.controller.attempt(\"Adding group \\\"#{group}\\\"\", 'destructive') {\n\t\t\t\t\t# Only add the group if it's not already there\n\t\t\t\t\tif !group?(group)\n\t\t\t\t\t\tif(gid == nil)\n\t\t\t\t\t\t\t`/usr/sbin/pw groupadd '#{shellescape(group)}'`\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t`/usr/sbin/pw groupadd '#{shellescape(group)}' -g #{gid.to_i()}`\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend", "def add_app_group(group,app)\n\t\tresults = submit_cmd('create app group',:db,\" -env #{self.env} -domain #{self.domain} -plant #{self.plant} -group #{group} -app_instance #{app}\")\n\t puts results\n\tend", "def add(group, name)\n if group.nil? or group.empty? or name.nil? or name.empty?\n raise MuError, \"Ansible::Inventory.add requires both a host group string and a name\"\n end\n lock\n read\n @inv[group] ||= []\n @inv[group] << name\n @inv[group].uniq!\n save!\n unlock\n end", "def modify_image_launch_perm_add_groups(image_id, user_group=['all'])\n modify_image_attribute(image_id, 'launchPermission', 'add', :user_group => user_group.to_a)\n end", "def aws_instance_create(opts)\n AWS::EC2::InstanceCollection.new.create(\n image_id: Rails.configuration.x.aws[Rails.configuration.x.aws['region']][\"ami_#{self.os}\"], \n private_ip_address: self.ip_address,\n key_name: Rails.configuration.x.aws['ec2_key_pair_name'],\n user_data: self.generate_init,\n instance_type: \"t2.small\",\n subnet: self.subnet.driver_id\n )\n end", "def create_security_group(name, description)\n # EC2 doesn't like an empty description...\n description = \" \" if description.blank?\n link = generate_request(\"CreateSecurityGroup\", \n 'GroupName' => name.to_s, \n 'GroupDescription' => description.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def create_security_group(name, description)\n # EC2 doesn't like an empty description...\n description = \" \" if description.blank?\n link = generate_request(\"CreateSecurityGroup\", \n 'GroupName' => name.to_s,\n 'GroupDescription' => description.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def spAdd\n provider_name = $prompt.ask('Provider Name:')\n provider_phone = $prompt.ask('Provider Phone Number:')\n $all_sp.push(ServiceProvider.new(provider_name, provider_phone, [], {}, []))\n successPrint()\n end", "def add_group(user)\n # NB: system users aren't supported on solaris 10\n return <<-HERE.undent\n if ! getent group '#{user.group}' > /dev/null 2>&1; then\n /usr/sbin/groupadd '#{user.group}'\n fi\n HERE\n end", "def add_instance(instance)\n self.save unless self.persisted?\n instance.ie = self\n self.instances << instance\n instance.save && self.save\n end", "def add_case(new_case)\n @group_of_case.push(new_case)\n end", "def create_group\n group new_resource.group do\n gid new_resource.gid\n system true\n end\n end", "def register\n instances = @volt_app.store.active_volt_instances\n instances.where(server_id: @server_id).first.then do |item|\n ips = local_ips.join(',')\n time = Time.now.to_i\n if item\n item.assign_attributes(ips: ips, time: time, port: @port)\n else\n instances << {server_id: @server_id, ips: ips, port: @port, time: time}\n end\n end\n end", "def execute!(step)\n\n if step.substep == 0\n machine_blueprint = MachineBlueprint.fetch(self.deployment.deployment_options.rds_machine_blueprint)\n\n fail_step(\"Missing RDS Machine Blueprint\") unless machine_blueprint\n\n\n if !cloud.master_db\n machine = self.deployment.add_machine([:master_db],machine_blueprint)\n machine.launch!\n log \"Launching new DB server from blueprint #{machine_blueprint.name}\"\n step.config.machine_id = machine.id\n else\n step.config.machine_id = cloud.master_db.id\n end\n end\n end", "def student_group_add(student_group_name)\n players = []\n if not student_group = self.scenario.user.student_groups.find_by_name(student_group_name)\n errors.add(:name, \"student group not found\")\n return\n end\n student_group.student_group_users.each do |student_group_user|\n if not self.players.where(\"user_id = #{student_group_user.user_id} AND student_group_id = #{student_group.id}\").first\n\n cnt = 1\n login = \"#{student_group_user.user.name.filename_safe}\"\n while self.players.find_by_login(login)\n cnt += 1\n login = login += cnt.to_s\n end\n\n player = self.players.new(\n login: login,\n password: Player.random_password,\n user_id: student_group_user.user.id,\n student_group_id: student_group_user.student_group.id\n )\n player.save\n players.push(player)\n end\n end\n players\n end", "def add_code( instruction )\n raise \"Not an instruction:#{instruction.to_s}:#{instruction.class.name}\" unless instruction.is_a?(SlotMachine::Instruction)\n new_current = instruction.last #after insertion this point is lost\n @current.insert(instruction) #insert after current\n @current = new_current\n self\n end", "def create_new_vm_group\n end", "def add_member\n return unless (request.post? && params[:student_user_name])\n # add member to the group with status depending if group is empty or not\n grouping = Grouping.find(params[:grouping_id])\n @assignment = Assignment.find(params[:id], include: [{groupings: [{student_memberships: :user, ta_memberships: :user}, :group]}])\n student = Student.find_by_user_name(params[:student_user_name])\n if student.nil?\n @error = \"Could not find student with user name #{params[:student_user_name]}\"\n render :error_single\n return\n end\n set_membership_status = grouping.student_memberships.empty? ?\n StudentMembership::STATUSES[:inviter] :\n StudentMembership::STATUSES[:accepted]\n grouping.invite(params[:student_user_name], set_membership_status)\n grouping.reload\n @grouping = construct_table_row(grouping, @assignment)\n end", "def add_group(*args)\n end", "def sadd\n @redis.sadd md5_list, @md5_sum\n end", "def handle_add( m, params )\n # lame auth check\n # TODO: need to get a look into new auth system\n\n name = params[:name].downcase\n machine = params[:machine].downcase\n amount = params[:amount]\n beats = params[:beats]\n\n # caluclate beats for one good and multiply with 100 -> better for later use\n beats = beats.to_f / amount.to_f\n beats *= 100\n\n # tag version || current amount || maximal amount || beats for one good || deliverybeat (always 'nil' if not reordered) || linked machine\n if machine == \"-\"\n stock = Stock.new( @stockversion, amount, amount, beats, nil, machine )\n @stock[name] = stock\n\n m.reply( \"#{name} added\" )\n elsif machine == \"yes\"\n name += \"_machine\"\n stock = Stock.new( @stockversion, amount, amount, beats, nil, machine )\n @stock[name] = stock\n\n m.reply( \"#{name} added\" )\n elsif machine == \"no\" and @stock.has_key?( name + \"_machine\" )\n machine = name + \"_machine\"\n stock = Stock.new( @stockversion, amount, amount, beats, nil, machine )\n @stock[name] = stock\n\n m.reply( \"#{name} added\" )\n else\n m.reply( \"Please first create the machine which should be linked to (same syntax, just replace the machine name with 'yes'), or use '-' to inidcate that there is no machine.\" ); return\n end\n\n # save dataset in case the bot crashes an got no chance to do so\n save\n end", "def new_playgroup(db, name, kids, address)\r\n\t\tdb.execute(\"INSERT INTO playgroups (name, kids, address) VALUES (?,?,?)\", [name, kids, address])\r\n\tend", "def security_group_created_with_egress?(\n ec2_resource,\n group_name,\n description,\n vpc_id,\n ip_protocol,\n from_port,\n to_port,\n cidr_ip_range\n)\n security_group = ec2_resource.create_security_group(\n group_name: group_name,\n description: description,\n vpc_id: vpc_id\n )\n puts \"Created security group '#{group_name}' with ID \" \\\n \"'#{security_group.id}' in VPC with ID '#{vpc_id}'.\"\n security_group.authorize_egress(\n ip_permissions: [\n {\n ip_protocol: ip_protocol,\n from_port: from_port,\n to_port: to_port,\n ip_ranges: [\n {\n cidr_ip: cidr_ip_range\n }\n ]\n }\n ]\n )\n puts \"Granted egress to security group '#{group_name}' for protocol \" \\\n \"'#{ip_protocol}' from port '#{from_port}' to port '#{to_port}' \" \\\n \"with CIDR IP range '#{cidr_ip_range}'.\"\n return true\nrescue StandardError => e\n puts \"Error creating security group or granting egress: #{e.message}\"\n return false\nend", "def ec2_security_groups\n data.ec2_security_groups\n end", "def add_openldap_group\n return unless any_hosts_as?(:openldap)\n\n openldap_group = {\n \"name\" => \"OpenLDAP Server\",\n \"rule\" => [\"or\", [\"=\", \"name\", openldap.node_name]], # pinned node\n \"parent\" => pe_infra_uuid,\n \"classes\" => {\n \"openldap::server\" => {\n \"databases\" => { \"dc=delivery,dc=puppetlabs,dc=net\" => {\n \"rootdn\" => \"cn=admin,dc=delivery,dc=puppetlabs,dc=net\",\n \"rootpw\" => \"Puppet11\"\n } }\n }\n }\n }\n\n dispatcher.find_or_create_node_group_model(openldap_group)\nend", "def refresh!\n response = Wucluster.ec2.describe_security_groups(:group_name => id)\n update! response.securityGroupInfo.item.first\n end", "def get_current_group\n sd = get_security_descriptor\n\n sd&.group\n end", "def addSec(sec)\n @sec += sec ;\n return self ;\n end", "def add_group(name)\n join_button_for(name).fire_event(\"onclick\")\n self.linger_for_ajax(1)\n end", "def create_security_group(name, description=nil)\n # EC2 doesn't like an empty description...\n description = \"-\" if description.right_blank?\n link = generate_request(\"CreateSecurityGroup\",\n 'GroupName' => name.to_s,\n 'GroupDescription' => description.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def add_to_group(group)\n gm = Fl::Framework::Actor::GroupMember.query_for_actor_in_group(self, group).first\n if gm.nil?\n gm = self.actor_containers.create(:group => group, :actor => self)\n end\n\n gm\n end", "def add_user( user )\n raise TypeError.new('not a user') unless user.is_a?(Ecore::User)\n user.add_group(self)\n end", "def security_groups\n @resource.security_groups.map { |sg| SecurityGroup.new(id: sg.group_id, ec2_resource: @ec2_resource) }\n end", "def allowed_to_create_security_groups=(value)\n @allowed_to_create_security_groups = value\n end", "def manage_group\n if new_resource.append\n members_to_be_added = [ ]\n if new_resource.excluded_members && !new_resource.excluded_members.empty?\n # First find out if any member needs to be removed\n members_to_be_removed = [ ]\n new_resource.excluded_members.each do |member|\n members_to_be_removed << member if current_resource.members.include?(member)\n end\n\n unless members_to_be_removed.empty?\n # We are using a magic trick to remove the groups.\n reset_group_membership\n\n # Capture the members we need to add in\n # members_to_be_added to be added later on.\n current_resource.members.each do |member|\n members_to_be_added << member unless members_to_be_removed.include?(member)\n end\n end\n end\n\n if new_resource.members && !new_resource.members.empty?\n new_resource.members.each do |member|\n members_to_be_added << member unless current_resource.members.include?(member)\n end\n end\n\n logger.debug(\"#{new_resource} not changing group members, the group has no members to add\") if members_to_be_added.empty?\n\n add_group_members(members_to_be_added)\n else\n # We are resetting the members of a group so use the same trick\n reset_group_membership\n logger.debug(\"#{new_resource} setting group members to: none\") if new_resource.members.empty?\n add_group_members(new_resource.members)\n end\n end", "def create_security_group(name, description=nil)\n # EC2 doesn't like an empty description...\n description = \"-\" if description.blank?\n link = generate_request(\"CreateSecurityGroup\",\n 'GroupName' => name.to_s,\n 'GroupDescription' => description.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def create\n @resource_group_machine = ResourceGroupMachine.new(resource_group_machine_params)\n #authorize(@resource_group_machine)\n respond_to do |format|\n if @resource_group_machine.save\n format.html { redirect_to @resource_group_machine, notice: 'Resource group machine was successfully created.' }\n format.json { render :show, status: :created, location: @resource_group_machine }\n else\n format.html { render :new }\n format.json { render json: @resource_group_machine.errors, status: :unprocessable_entity }\n end\n end\n end", "def store_group(uuid)\n Uploadcare::Group.store(uuid)\n end", "def create\n ::ActiveRecord::Base.transaction do\n if group.save!\n membership = add_creator_as_group_admin!\n @side_effects << membership\n end\n end\n rescue ActiveRecord::RecordInvalid => _exception\n raise if group.valid?\n group\n end", "def register_server(name)\n do_send(Erlang::Tuple.new([\n Erlang::Atom.new('register_with_group'),\n Erlang::Atom.new(name)]))\n end", "def add_user(user, reason)\n compatibility_score = 0\n group_leader = User.find(self.creator)\n \n # initializing <tt>group</tt> because of something funky going on with <tt>self</tt> in this context\n group = Group.where(:creator => self.creator).first\n \n case reason\n when \"creator\"\n compatibility_score += 42\n self.initialize_group_meeting_times(user)\n self.initialize_group_schedule(user.schedule) # leader must have a schedule..\n when \"friend\"\n compatibility_score += 21\n compatibility_score += user.number_of_compatible_time_blocks_with(group_leader.schedule)\n else\n compatibility_score += user.number_of_compatible_time_blocks_with(group_leader.schedule)\n end\n \n if reason != \"creator\"\n group.update_group_meeting_times(user)\n group.update_group_schedule(user.schedule) if user.schedule != nil\n end\n \n Membership.create(:group_id => self.id, :user_id => user.id, :compatibility_score => compatibility_score)\n end", "def add(value)\n @stack.push(value)\n end", "def addMember(group_or_eperson)\n raise 'must give non nil group_or_eperson' if group_or_eperson.nil?\n\n @model.addMember(group_or_eperson)\n @model.update\n @model\n end" ]
[ "0.57602894", "0.5734369", "0.5555561", "0.5528507", "0.5337871", "0.53162956", "0.5296002", "0.5228811", "0.52073044", "0.51378554", "0.5137595", "0.512515", "0.50814545", "0.5078808", "0.50601643", "0.50600517", "0.50364786", "0.5032829", "0.50321704", "0.5020412", "0.50073856", "0.49899513", "0.49606752", "0.495014", "0.49234742", "0.49193192", "0.48986337", "0.48900685", "0.4887985", "0.48640934", "0.48378995", "0.4829935", "0.4816308", "0.48148078", "0.48114187", "0.48099506", "0.48084328", "0.4740657", "0.4693285", "0.46896073", "0.46733224", "0.4669405", "0.46659833", "0.46610504", "0.4658513", "0.46546084", "0.4652281", "0.46370474", "0.46219984", "0.46208483", "0.46172264", "0.4612668", "0.45870653", "0.45862442", "0.45788538", "0.4577701", "0.4576192", "0.45695403", "0.4566984", "0.45664918", "0.45644972", "0.45544007", "0.4554067", "0.45524326", "0.45498505", "0.45493227", "0.4542592", "0.45412958", "0.45380974", "0.45330736", "0.4526893", "0.45256197", "0.45152953", "0.45141", "0.45138827", "0.45124593", "0.44955367", "0.44902673", "0.44899407", "0.44802618", "0.44756564", "0.44709414", "0.4468947", "0.44658482", "0.44653192", "0.44642532", "0.44625935", "0.44582966", "0.445202", "0.4441473", "0.44411474", "0.44407016", "0.44363403", "0.44302857", "0.44258416", "0.4421268", "0.4419477", "0.4417353", "0.4410074", "0.44067234", "0.4400847" ]
0.0
-1
Add the ip address to the RDS security group.
def authorize_ip_address(ip) authorize_cidrip("#{ip}/32") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def security_group=(new_cidr_block)\n new_cidr_block = new_cidr_block + '/32' unless new_cidr_block.include? \"/\"\n @environment.vpc.security_groups.each do |sg|\n @security_group = sg if sg.group_name == 'SshSecurityGroup' + new_cidr_block\n end\n\n # only create security group if it does not exist\n if @security_group.nil?\n ec2 = Aws::EC2::Resource.new(region: 'us-west-2')\n\n @security_group = ec2.create_security_group(\n group_name: 'SshSecurityGroup' + new_cidr_block,\n description: 'Enable SSH access via port 22',\n vpc_id: @environment.vpc.id\n )\n\n @security_group.authorize_egress(\n ip_permissions: [\n ip_protocol: 'tcp',\n from_port: 22,\n to_port: 22,\n ip_ranges: [\n cidr_ip: new_cidr_block\n ]\n ]\n )\n end\n end", "def authorize_security_group_IP_ingress(name, owner, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n @ec2.autorize_security_group_ingress_IP(name, protocol, from_port, to_port, cidr_ip) \n rescue Exception\n on_query_exception('authorize_security_group_IP_ingress')\n end", "def authorize_db_security_group_ingress(name, opts={})\n unless opts.key?('CIDRIP') || ((opts.key?('EC2SecurityGroupName') || opts.key?('EC2SecurityGroupId')) && opts.key?('EC2SecurityGroupOwnerId'))\n raise ArgumentError, 'Must specify CIDRIP, or one of EC2SecurityGroupName or EC2SecurityGroupId, and EC2SecurityGroupOwnerId'\n end\n\n request({\n 'Action' => 'AuthorizeDBSecurityGroupIngress',\n :parser => Fog::Parsers::AWS::RDS::AuthorizeDBSecurityGroupIngress.new,\n 'DBSecurityGroupName' => name\n }.merge(opts))\n end", "def authorize_db_security_group_ingress(name, opts={})\n unless opts.key?('CIDRIP') || (opts.key?('EC2SecurityGroupName') && opts.key?('EC2SecurityGroupOwnerId'))\n raise ArgumentError, 'Must specify CIDRIP, or both EC2SecurityGroupName and EC2SecurityGroupOwnerId'\n end\n\n request({\n 'Action' => 'AuthorizeDBSecurityGroupIngress',\n :parser => Fog::Parsers::AWS::RDS::AuthorizeDBSecurityGroupIngress.new,\n 'DBSecurityGroupName' => name\n }.merge(opts))\n\n end", "def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n edit_security_group( :authorize, name, :from_port => from_port, :to_port => to_port, :protocol => protocol, :cidr_ip => cidr_ip )\n end", "def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n edit_security_group( :authorize, name, :from_port => from_port, :to_port => to_port, :protocol => protocol, :cidr_ip => cidr_ip )\n end", "def add_ip(vid, ip = nil)\n perform_request(action: 'vserver-addip', vserverid: vid, ipv4addr: ip)\n returned_parameters['ipaddress']\n end", "def add(private_ip=nil, interface='eth0')\n\n\t\t\t# use AWS api to add a private ip address to the given interface.\n\t\t\t# if unspecified, let AWS auto-assign the ip.\n\n\t\t\t# add the new ip to the local config with `ip addr add ...` and use\n\t\t\t# `ip rule ...` or `ip route ...` if necessary\n\n\t\t\t# throw named exception if the private ip limit is reached, if the ip\n\t\t\t# specified is already in use, or for any similar error\n\n\t\t\t# return the new ip\n\t\tend", "def addIPAddressAdminAccess(ipaddress)\n addipaddress_button.click\n ipaddressesarray = all(:xpath, \".//input[contains(@id,'com.spigit.user.UserConfig.restrictedIPAccessForAdmin')]\")\n ipaddressesarray[-1].set(ipaddress)\n end", "def security_group_created_with_egress?(\n ec2_resource,\n group_name,\n description,\n vpc_id,\n ip_protocol,\n from_port,\n to_port,\n cidr_ip_range\n)\n security_group = ec2_resource.create_security_group(\n group_name: group_name,\n description: description,\n vpc_id: vpc_id\n )\n puts \"Created security group '#{group_name}' with ID \" \\\n \"'#{security_group.id}' in VPC with ID '#{vpc_id}'.\"\n security_group.authorize_egress(\n ip_permissions: [\n {\n ip_protocol: ip_protocol,\n from_port: from_port,\n to_port: to_port,\n ip_ranges: [\n {\n cidr_ip: cidr_ip_range\n }\n ]\n }\n ]\n )\n puts \"Granted egress to security group '#{group_name}' for protocol \" \\\n \"'#{ip_protocol}' from port '#{from_port}' to port '#{to_port}' \" \\\n \"with CIDR IP range '#{cidr_ip_range}'.\"\n return true\nrescue StandardError => e\n puts \"Error creating security group or granting egress: #{e.message}\"\n return false\nend", "def ingress\n ip, security_group = parse_security_group_and_ip_from_args\n rds.authorize_db_security_group_ingress(security_group, 'CIDRIP' => ip)\n self.access\n end", "def add_ip(vid)\n perform_request(:action => 'vserver-addip', :vserverid => vid)\n end", "def create_security_group(name, vpc_id)\n sg = ec2.create_security_group({\n group_name: name,\n description: \"Kontena Grid\",\n vpc_id: vpc_id\n })\n\n sg.authorize_ingress({ # SSH\n ip_protocol: 'tcp', from_port: 22, to_port: 22, cidr_ip: '0.0.0.0/0'\n })\n sg.authorize_ingress({ # HTTP\n ip_protocol: 'tcp', from_port: 80, to_port: 80, cidr_ip: '0.0.0.0/0'\n })\n sg.authorize_ingress({ # HTTPS\n ip_protocol: 'tcp', from_port: 443, to_port: 443, cidr_ip: '0.0.0.0/0'\n })\n sg.authorize_ingress({ # OpenVPN\n ip_protocol: 'udp', from_port: 1194, to_port: 1194, cidr_ip: '0.0.0.0/0'\n })\n sg.authorize_ingress({ # Overlay / Weave network\n ip_permissions: [\n {\n from_port: 6783, to_port: 6783, ip_protocol: 'tcp',\n user_id_group_pairs: [\n { group_id: sg.group_id, vpc_id: vpc_id }\n ]\n },\n {\n from_port: 6783, to_port: 6784, ip_protocol: 'udp',\n user_id_group_pairs: [\n { group_id: sg.group_id, vpc_id: vpc_id }\n ]\n }\n ]\n })\n\n sg\n end", "def add_ip(ip)\n @ips << L3::Misc.ipv42long(ip)\n end", "def modify_security_group(db_instance_identifier, vpc_security_groups)\n modify_db_instance(db_instance_identifier: db_instance_identifier, vpc_security_group_ids: vpc_security_groups)\n end", "def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n link = generate_request(\"AuthorizeSecurityGroupIngress\", \n 'GroupName' => name.to_s, \n 'IpProtocol' => protocol.to_s, \n 'FromPort' => from_port.to_s, \n 'ToPort' => to_port.to_s, \n 'CidrIp' => cidr_ip.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def ass_ip(instance_id, ip)\n @connection.get 'AssociateEip', {\n eip: ip,\n instance: instance_id,\n zone: 'sh1a'\n }\n end", "def authorize_db_security_group( options = {} )\n raise ArgumentError, \"No :db_security_group_name provided\" if options.does_not_have?(:db_security_group_name)\n\n params = {}\n params['DBSecurityGroupName'] = options[:db_security_group_name]\n\n if options.has?(:cidrip)\n params['CIDRIP'] = options[:cidrip]\n elsif options.has?(:ec2_security_group_name) && options.has?(:ec2_security_group_owner_id)\n params['EC2SecurityGroupName'] = options[:ec2_security_group_name]\n params['EC2SecurityGroupOwnerId'] = options[:ec2_security_group_owner_id]\n else\n raise ArgumentError, \"No :cidrip or :ec2_security_group_name and :ec2_security_group_owner_id provided\"\n end\n\n return response_generator(:action => \"AuthorizeDBSecurityGroupIngress\", :params => params)\n end", "def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n link = generate_request(\"AuthorizeSecurityGroupIngress\", \n 'GroupName' => name.to_s,\n 'IpProtocol' => protocol.to_s,\n 'FromPort' => from_port.to_s,\n 'ToPort' => to_port.to_s,\n 'CidrIp' => cidr_ip.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def security_group\n node = 'AWS_SECURITY_GROUP'\n q = []\n\n # security_group node\n q.push(_upsert({ node: node, id: @name }))\n\n # vpc node and relationship\n if @data.vpc_id\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_VPC',\n child_name: @data.vpc_id,\n relationship: 'MEMBER_OF_VPC'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # ingress rules\n @data.ip_permissions.each do |ingress|\n ingress.ip_ranges.each_with_index do |ip_range, i|\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_SECURITY_GROUP_INGRESS_RULE',\n child_name: \"#{@name}-#{ingress.ip_protocol}-#{ingress.to_port}-#{i}\",\n relationship: 'HAS_INGRESS_RULE',\n relationship_attributes: {\n cidr_ip: ip_range.cidr_ip,\n ip_protocol: ingress.ip_protocol,\n to_port: ingress.to_port,\n from_port: ingress.from_port,\n direction: 'ingress'\n }\n }\n\n q.push(_upsert_and_link(opts))\n end\n end\n\n # egress rules\n @data.ip_permissions_egress.each do |egress|\n egress.ip_ranges.each_with_index do |ip_range, i|\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_SECURITY_GROUP_EGRESS_RULE',\n child_name: \"#{@name}-#{egress.ip_protocol}-#{egress.to_port}-#{i}\",\n relationship: 'HAS_EGRESS_RULE',\n relationship_attributes: {\n cidr_ip: ip_range.cidr_ip,\n ip_protocol: egress.ip_protocol,\n to_port: egress.to_port,\n from_port: egress.from_port,\n direction: 'egress'\n }\n }\n\n q.push(_upsert_and_link(opts))\n end\n end\n\n q\n end", "def aws_security_group_enable_outbound_to_subnets(opts)\n opts[:security_group].authorize_egress('10.0.0.0/16')\n end", "def set_aws_security_group_egress\n @aws_security_group_egress = AwsSecurityGroupEgress.find(params[:id])\n end", "def SetIp(node)\n \tnode.GetInterfaces().each do |ifn|\n\t self.GetGroupInterface(node, ifn).ip=\"1.1.1.1\"\n \t #self.GetGroupInterface(node, ifn).up\n\tend\n end", "def add_ip(opts)\n opts = check_params(opts,[:ips])\n super(opts)\n end", "def create_db_security_group(name, description = name)\n request({\n 'Action' => 'CreateDBSecurityGroup',\n 'DBSecurityGroupName' => name,\n 'DBSecurityGroupDescription' => description,\n :parser => Fog::Parsers::AWS::RDS::CreateDBSecurityGroup.new\n })\n end", "def aws_security_group_enable_outbound_port_80(opts)\n opts[:security_group].authorize_egress('0.0.0.0/0', protocol: :tcp, ports: 80)\n end", "def associate_public_ip(c)\n associate_address_with(Application.public_ip, @instance_id) if master? && Application.public_ip && !Application.public_ip.empty?\n end", "def aws_security_group_enable_inbound(opts)\n opts[:security_group].authorize_ingress(:tcp, 20..8080)\n end", "def get_ipaddress(asset_tag=asset_tag, pool)\n @connection.ipaddress_allocate!(asset_tag, pool, count = 1)\n end", "def create_db_instance(db_name, options={})\n \n if security_groups = options.delete('DBSecurityGroups')\n options.merge!(Fog::AWS.indexed_param('DBSecurityGroups.member.%d', [*security_groups]))\n end\n \n request({\n 'Action' => 'CreateDBInstance',\n 'DBInstanceIdentifier' => db_name,\n :parser => Fog::Parsers::AWS::RDS::CreateDBInstance.new,\n }.merge(options))\n end", "def create\n ec2 = self.class.new_ec2(@resource.value(:user), @resource.value(:password))\n group = @resource.value(:name)\n begin\n ec2.describe_security_groups({:group_name => group})\n rescue Exception => e\n ec2.create_security_group({ \n :group_name => group,\n :group_description => @resource.value(:desc)\n })\n end\n # if instance in that security group exists, start it\n # otherwise just create a new instance \n ec2.run_instances(\n { :image_id => @resource.value(:image),\n # security groups\n :security_group => group,\n :instance_type => @resource.value(:type)\n })\n end", "def associate_address(instance_id, public_ip)\n link = generate_request(\"AssociateAddress\", \n \"InstanceId\" => instance_id.to_s,\n \"PublicIp\" => public_ip.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def associate_address(instance_id, public_ip)\n link = generate_request(\"AssociateAddress\", \n \"InstanceId\" => instance_id.to_s,\n \"PublicIp\" => public_ip.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def adjust_security_groups\n\n all_regions.each do |region|\n c = connection(region)\n g = c.security_groups.get(primary_group)\n \n g.authorize_port_range(1024..65535, :cidr_ip => \"#{master.public_ip_address}/32\")\n nodes.each do |node|\n g.authorize_port_range(1024..65535, :cidr_ip => \"#{node.public_ip_address}/32\")\n end\n end\n end", "def add_to_lb(group)\n @haproxy.identity_filter(@load_balancer)\n # We don't have to identify the nodes in the group\n # for every action. I'm doing it here to make each\n # method easier to read\n @rpcutil.class_filter(group)\n begin\n @rpcutil.ping.each do |node|\n hostname = node.results[:sender]\n # Disable the nodes\n @haproxy.enable(:backend => 'puppetcamp', :server => hostname).each do |rpcresult|\n if rpcresult.results[:statuscode] != 0\n raise LoadBalancerAddException, hostname\n end\n end\n end\n ensure\n @haproxy.reset_filter\n @rpcutil.reset_filter\n end\nend", "def associate_address(instance_id)\n new_ip = next_unused_elastic_ip\n vputs(\"Assigning #{new_ip} to the ec2 instance #{instance_id}\")\n ec2.associate_address(instance_id, new_ip)\n loop do\n if describe_instance(:instance_id => instance_id).public_ip == new_ip\n return new_ip\n end\n sleep 1\n end\n end", "def add(opt)\n ipaddr_modify(RTM_NEWADDR, NLM_F_CREATE|NLM_F_EXCL, opt)\n end", "def add_to_group(group)\n self.memberships.create(group_id: group.id)\n end", "def add_address(ipaddress, rule)\n return false unless rule.is_a?(Rule)\n @addresses ||= {}\n (@addresses[ipaddress] ||= []) << rule\n rule\n end", "def subnet_group\n @dbi.db_subnet_group\n end", "def subnet_group\n @dbi.db_subnet_group\n end", "def set_security_group\n @security_group = SecurityGroup.find(params[:id])\n end", "def create(name, desc=nil, addresses=[], ports=[], protocols=[], &each_group)\n desc ||= \"Security Group #{name}\"\n ret = @@ec2.create_security_group(:group_name => name, :group_description => desc)\n return false unless (ret && ret['return'] == 'true')\n authorize(name, addresses, ports, protocols)\n get(name, &each_group)\n end", "def authorize_ec2_security_group(group_name, group_owner_id=owner_id)\n key = group_name.match(/^sg-/) ? 'EC2SecurityGroupId' : 'EC2SecurityGroupName'\n authorize_ingress({\n key => group_name,\n 'EC2SecurityGroupOwnerId' => group_owner_id\n })\n end", "def network_objects_add_ip(rule_name,data)\n \n addr_list = data.split(',')\n self.msg(rule_name, :debug, 'network_objects_add_ip', \"addr_list\" +addr_list.to_s)\n \n addr_list.each do |ip_data|\n \n self.msg(rule_name, :debug, 'network_objects_add_ip', \"processing address\" +ip_data.to_s)\n @ff.link(:href, 'javascript:mimic_button(\\'add: ...\\', 1)').click\n @ff.select_list(:name, 'net_obj_type').select_value('1')\n \n if ip_data.size > 0\n \n self.msg(rule_name, :debug, 'network_objects_add_ip', \"set ip address\" +ip_data)\n str_ip_data = ip_data.strip\n octets=str_ip_data.split('.')\n @ff.text_field(:name, 'ip0').set(octets[0])\n @ff.text_field(:name, 'ip1').set(octets[1])\n @ff.text_field(:name, 'ip2').set(octets[2])\n @ff.text_field(:name, 'ip3').set(octets[3])\n @ff.link(:text, 'Apply').click\n \n end # end of if\n \n end # end of each\n \n end", "def add_subnet(subnet)\n key_sym = subnet.subnet_id.to_sym\n @subnet_ids[key_sym] = subnet unless @subnet_ids.key?(key_sym)\n end", "def associate!(address_or_ip)\n @@ec2.associate_address(id, address_or_ip)\n @address = nil\n end", "def update\n if @auth_ip_address_group.update_attributes(auth_ip_address_group_params)\n render json: @auth_ip_address_group, status: :ok\n else\n render_error(@auth_ip_address_group, :unprocessable_entity)\n end\n end", "def attach(server)\n requires :ip\n server = server.serverid if server.is_a?(Fog::Compute::Glesys::Server)\n raise Fog::Errors::Error.new(\"Ip is already attached to a server, #{serverid}\") unless serverid.nil?\n data = service.ip_add(\n :ipaddress => identity,\n :serverid => server\n ).body[\"response\"][\"details\"]\n merge_attributes data\n end", "def associate_address(instance_id, public_ip)\n action = 'AssociateAddress'\n params = {\n 'Action' => action,\n 'InstanceId' => instance_id,\n 'PublicIp' => public_ip\n }\n\n response = send_query_request(params)\n response.is_a?(Net::HTTPSuccess)\n end", "def add_security_group_queue(userid, security_group)\n task_opts = {\n :action => \"adding Security Group to Instance for user #{userid}\",\n :userid => userid\n }\n\n queue_opts = {\n :class_name => self.class.name,\n :method_name => 'add_security_group',\n :instance_id => id,\n :role => 'ems_operations',\n :queue_name => queue_name_for_ems_operations,\n :zone => my_zone,\n :args => [security_group]\n }\n\n MiqTask.generic_action_with_callback(task_opts, queue_opts)\n end", "def register_ip(user_ip)\r\n # Checking database for existing record\r\n {\r\n :ip => user_ip,\r\n :time => Time.now # Check date format compability\r\n }\r\n # Inserting or updating a record\r\n end", "def regist_ip\n puts 'Registering IP address of this node'\n\n sock = TCPSocket.open($leader_ip)\n sock.write(\"regist\")\n ret_ip = sock.gets\n sock.close\n return ret_ip\n end", "def ip_permissions(sg)\n sg.security_group_rules\n end", "def update_security_groups(elb_name, vpc_id, security_groups)\n @elb.apply_security_groups_to_load_balancer({\n load_balancer_name: elb_name,\n security_groups: security_groups.map do |sg_name|\n SecurityGroups::vpc_security_groups[vpc_id][sg_name].group_id\n end\n })\n end", "def ensure_security_group_prepared\n provider.create_security_group(system_config.security_group, required_public_ports)\n end", "def aws_elastic_ip_create(opts)\n AWS::EC2::ElasticIpCollection.new.create(vpc: true)\n end", "def aws_instance_elastic_ip_associate(opts)\n opts[:instance].associate_elastic_ip(opts[:elastic_ip])\n end", "def set_ip_address\n @ip_address = IpAddress.find(params[:id])\n end", "def qos_add_ip(rule_name,data)\n \n addr_list = data.split(',')\n self.msg(rule_name, :debug, 'qos_add_rule', \"addr_list\" +addr_list.to_s)\n \n addr_list.each do |ip_data|\n \n self.msg(rule_name, :debug, 'qos_add_rule', \"processing address\" +ip_data.to_s)\n @ff.link(:href, 'javascript:mimic_button(\\'add: ...\\', 1)').click\n @ff.select_list(:name, 'net_obj_type').select_value('1')\n \n if ip_data.size > 0\n \n self.msg(rule_name, :debug, 'qos_add_rule', \"set ip address\" +ip_data)\n str_ip_data = ip_data.strip\n octets=str_ip_data.split('.')\n @ff.text_field(:name, 'ip0').set(octets[0])\n @ff.text_field(:name, 'ip1').set(octets[1])\n @ff.text_field(:name, 'ip2').set(octets[2])\n @ff.text_field(:name, 'ip3').set(octets[3])\n @ff.link(:text, 'Apply').click\n \n end # end of if\n \n end # end of each\n \n end", "def private_ip_v4_address; end", "def addRule(hosts,\n proto: \"tcp\",\n port: nil,\n egress: false,\n port_range: \"0-65535\"\n )\n rule = Hash.new\n rule[\"proto\"] = proto\n if hosts.is_a?(String)\n rule[\"hosts\"] = [hosts]\n else\n rule[\"hosts\"] = hosts\n end\n if port != nil\n port = port.to_s if !port.is_a?(String)\n rule[\"port\"] = port\n else\n rule[\"port_range\"] = port_range\n end\n ec2_rule = convertToEc2([rule])\n\n begin\n if egress\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).authorize_security_group_egress(\n group_id: @cloud_id,\n ip_permissions: ec2_rule\n )\n else\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).authorize_security_group_ingress(\n group_id: @cloud_id,\n ip_permissions: ec2_rule\n )\n end\n rescue Aws::EC2::Errors::InvalidPermissionDuplicate => e\n MU.log \"Attempt to add duplicate rule to #{@cloud_id}\", MU::DEBUG, details: ec2_rule\n end\n end", "def aws_create_security_group( name, opts = {} )\n opts = deep_merge_hashes( @aws_default_sg_options, opts )\n region = opts.delete( :region )\n ec2 = AWS::EC2.new.regions[ region ]\n unless ec2.security_groups.find { |sg| sg.name == name }\n ec2.security_groups.create( name, opts )\n end\n end", "def db_subnet_group\n data[:db_subnet_group]\n end", "def db_subnet_group\n data[:db_subnet_group]\n end", "def aws_security_group_enable_outbound_port_443(opts)\n opts[:security_group].authorize_egress('0.0.0.0/0', protocol: :tcp, ports: 443)\n end", "def edit_security_group(action, group_name, params)\n hash = {}\n case action\n when :authorize, :grant then action = \"AuthorizeSecurityGroupIngress\"\n when :revoke, :remove then action = \"RevokeSecurityGroupIngress\"\n else raise \"Unknown action #{action.inspect}!\"\n end\n hash['GroupName'] = group_name\n hash['SourceSecurityGroupName'] = params[:source_group] unless params[:source_group].blank?\n hash['SourceSecurityGroupOwnerId'] = params[:source_group_owner].to_s.gsub(/-/,'') unless params[:source_group_owner].blank?\n hash['IpProtocol'] = params[:protocol] unless params[:protocol].blank?\n unless params[:port].blank?\n hash['FromPort'] = params[:port]\n hash['ToPort'] = params[:port]\n end\n hash['FromPort'] = params[:from_port] unless params[:from_port].blank?\n hash['ToPort'] = params[:to_port] unless params[:to_port].blank?\n hash['CidrIp'] = params[:cidr_ip] unless params[:cidr_ip].blank?\n #\n link = generate_request(action, hash)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def create_group\n group_params = params.require(:group_params)\n\n group_id = @infra.ec2.create_security_group({group_name: group_params[0], description: group_params[1], vpc_id: group_params[3]})\n @infra.ec2.create_tags(resources: [group_id[:group_id]], tags: [{key: 'Name', value: group_params[2]}])\n\n render text: I18n.t('security_groups.msg.change_success')\n end", "def associate_address!(conn, server, pool_name = nil)\n pool_name ||= conn.addresses.get_address_pools.first['name']\n ip = conn.addresses.create(:pool => pool_name)\n ip.server = server\n server.reload\n end", "def add_group_as_member(group)\n self.groups.push group\n end", "def aws_security_group_egress_params\n params.require(:aws_security_group_egress).permit(:security_group_id, :egress_id, :ip_protocol, :from_port, :to_port)\n end", "def add_instance(params)\n Fog::Logger.deprecation(\n \"#{self.class}.#{__method__} is deprecated, use Fog::Compute::Google::InstanceGroup.#{__method__} instead [light_black](#{caller(0..0)})[/]\"\n )\n params[:instance] = [params[:instance]] unless params[:instance] == Array\n service.add_instance_group_instances(params[:group], params[:zone], params[:instance])\n end", "def modify_db_instance(db_name, apply_immediately, options={})\n if security_groups = options.delete('DBSecurityGroups')\n options.merge!(Fog::AWS.indexed_param('DBSecurityGroups.member.%d', [*security_groups]))\n end\n\n if vpc_security_groups = options.delete('VpcSecurityGroups')\n options.merge!(Fog::AWS.indexed_param('VpcSecurityGroupIds.member.%d', [*vpc_security_groups]))\n end\n\n request({\n 'Action' => 'ModifyDBInstance',\n 'DBInstanceIdentifier' => db_name,\n 'ApplyImmediately' => apply_immediately,\n :parser => Fog::Parsers::AWS::RDS::ModifyDBInstance.new\n }.merge(options))\n end", "def create_group\n group_params = params.require(:group_params)\n\n group_id = @infra.ec2.create_security_group({ group_name: group_params[0], description: group_params[1], vpc_id: group_params[3] })\n @infra.ec2.create_tags(resources: [group_id[:group_id]], tags: [{ key: 'Name', value: group_params[2] }])\n\n render plain: I18n.t('security_groups.msg.change_success')\n end", "def authorize_security_group_ingress( options = {} )\n options = { :group_name => nil,\n :ip_protocol => nil,\n :from_port => nil,\n :to_port => nil,\n :cidr_ip => nil,\n :source_security_group_name => nil,\n :source_security_group_owner_id => nil }.merge(options)\n\n # lets not validate the rest of the possible permutations of required params and instead let\n # EC2 sort it out on the server side. We'll only require :group_name as that is always needed.\n raise ArgumentError, \"No :group_name provided\" if options[:group_name].nil? || options[:group_name].empty?\n\n params = { \"GroupName\" => options[:group_name],\n \"IpProtocol\" => options[:ip_protocol],\n \"FromPort\" => options[:from_port].to_s,\n \"ToPort\" => options[:to_port].to_s,\n \"CidrIp\" => options[:cidr_ip],\n \"SourceSecurityGroupName\" => options[:source_security_group_name],\n \"SourceSecurityGroupOwnerId\" => options[:source_security_group_owner_id]\n }\n return response_generator(:action => \"AuthorizeSecurityGroupIngress\", :params => params)\n end", "def set_security_groups(lb_id, security_group_ids)\n params = {}\n\n params.merge!(Fog::AWS.serialize_keys('SecurityGroups', security_group_ids))\n request({\n 'Action' => 'SetSecurityGroups',\n 'LoadBalancerArn' => lb_id,\n :parser => Fog::Parsers::AWS::ELBV2::SetSecurityGroups.new\n }.merge!(params))\n end", "def edit_security_group(action, group_name, params)\n hash = {}\n case action\n when :authorize, :grant then action = \"AuthorizeSecurityGroupIngress\"\n when :revoke, :remove then action = \"RevokeSecurityGroupIngress\"\n else raise \"Unknown action #{action.inspect}!\"\n end\n hash['GroupName'] = group_name\n hash['SourceSecurityGroupName'] = params[:source_group] unless params[:source_group].right_blank?\n hash['SourceSecurityGroupOwnerId'] = params[:source_group_owner].to_s.gsub(/-/,'') unless params[:source_group_owner].right_blank?\n hash['IpProtocol'] = params[:protocol] unless params[:protocol].right_blank?\n unless params[:port].right_blank?\n hash['FromPort'] = params[:port]\n hash['ToPort'] = params[:port]\n end\n hash['FromPort'] = params[:from_port] unless params[:from_port].right_blank?\n hash['ToPort'] = params[:to_port] unless params[:to_port].right_blank?\n hash['CidrIp'] = params[:cidr_ip] unless params[:cidr_ip].right_blank?\n #\n link = generate_request(action, hash)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def save_ip_addr\n self.ip_address = IPAddr.new(self.ip_address).to_i.to_s(16).rjust(8, \"0\")\n end", "def groupadd(group)\n # XXX I don't like specifying the path to groupadd - need to sort out paths before long\n send(run_method, \"grep '#{group}:' /etc/group || sudo /usr/sbin/groupadd #{group}\")\n end", "def set_IPAddress(value)\n set_input(\"IPAddress\", value)\n end", "def apply_security_groups_to_load_balancer(security_group_ids, lb_name)\n params = Fog::AWS.indexed_param('SecurityGroups.member', [*security_group_ids])\n request({\n 'Action' => 'ApplySecurityGroupsToLoadBalancer',\n 'LoadBalancerName' => lb_name,\n :parser => Fog::Parsers::AWS::ELB::ApplySecurityGroupsToLoadBalancer.new\n }.merge!(params))\n end", "def associate_address( options = {} )\n options = { :instance_id => '', :public_ip => '' }.merge(options)\n raise ArgumentError, \"No ':instance_id' provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n raise ArgumentError, \"No ':public_ip' provided\" if options[:public_ip].nil? || options[:public_ip].empty?\n params = {\n \"InstanceId\" => options[:instance_id],\n \"PublicIp\" => options[:public_ip]\n }\n return response_generator(:action => \"AssociateAddress\", :params => params)\n end", "def modify_security_ips(d_b_instance_id, security_ips, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ModifySecurityIps'\n\t\targs[:query]['DBInstanceId'] = d_b_instance_id\n\t\targs[:query]['SecurityIps'] = security_ips\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :client_token\n\t\t\targs[:query]['ClientToken'] = optional[:client_token]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend", "def ipaddress(node)\n @use_private_ip_for_ssh ? node['ec2']['local_ipv4'] : node['ec2']['public_ipv4']\n end", "def security_group(sg_name, hsh={}, &block)\n sg_name = sg_name.to_s\n security_groups[sg_name] ||= Ironfan::Cloud::SecurityGroup.new(self, sg_name)\n security_groups[sg_name].configure(hsh, &block)\n security_groups[sg_name]\n end", "def reserve_ip(hostname, network, dns_view, aliases = nil, start_ip = nil, end_ip = nil)\n begin\n log(:info, \"Running reserve_ip...\")\n\n # set function call based on network or range\n if network.nil?\n raise \"start_ip parameter not found for range\" if start_ip.nil?\n raise \"end_ip parameter not found for range\" if end_ip.nil?\n function_call = \"func:nextavailableip:#{start_ip}-#{end_ip}\"\n else\n function_call = \"func:nextavailableip:#{network}\"\n end\n\n # set body for connection\n body = {\n :ipv4addrs => [\n :ipv4addr => function_call\n ],\n :name => hostname,\n :view => dns_view,\n :configure_for_dns => true,\n :comment => \"Added by CFME\"\n }\n\n # add aliases if we have them\n body[:aliases] = aliases unless aliases.nil?\n\n # call infoblox to reserve ip\n host_response = call_infoblox(:post, 'record:host', :json, :json, body, 'ipv4addr')\n log(:info, \"Inspecting host: #{host_response.inspect}\")\n\n # pull the ip from the host object\n host_hash = parse_json_response(host_response)\n ip_addr = host_hash['ipv4addrs'].first['ipv4addr']\n rescue Exception => error\n log(:info, error.inspect)\n return false\n end\n end", "def insert_network(name, ip_range)\n data = false\n conn = @ec2_main.environment.connection\n if conn != nil\n response = conn.insert_network(name, ip_range)\n if response.status == 200\n data = response.body\n else\n data = {}\n end\n else\n raise \"Connection Error\"\n end\n return data\n end", "def add_group(group, gid=nil)\n\t\t\t\tCfruby.controller.attempt(\"Adding group \\\"#{group}\\\"\", 'destructive') {\n\t\t\t\t\t# Only add the group if it's not already there\n\t\t\t\t\tif !group?(group)\n\t\t\t\t\t\tif(gid == nil)\n\t\t\t\t\t\t\t`/usr/sbin/pw groupadd '#{shellescape(group)}'`\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t`/usr/sbin/pw groupadd '#{shellescape(group)}' -g #{gid.to_i()}`\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend", "def start_ip= attr\n\t\tip = IP.parse(attr)\n\t\twrite_attribute(:ip_v4, (ip.proto==\"v4\"))\n\t\twrite_attribute(:start_ip, ip.to_hex) \n\tend", "def public_ip_v4_address; end", "def db_security_group_arn\n data.db_security_group_arn\n end", "def literal_other_append(sql, value)\n if value.is_a?(IPAddr)\n literal_string_append(sql, \"#{value.to_s}/#{value.instance_variable_get(:@mask_addr).to_s(2).count('1')}\")\n else\n super\n end\n end", "def literal_other_append(sql, value)\n if value.is_a?(IPAddr)\n literal_string_append(sql, \"#{value.to_s}/#{value.instance_variable_get(:@mask_addr).to_s(2).count('1')}\")\n else\n super\n end\n end", "def set_IPAddress(value)\n set_input(\"IPAddress\", value)\n end", "def attach_to_elb(instance, elb_name, subnet = nil)\n begin\n @log.info \"\"\n @log.info \"Adding to ELB: #{elb_name}\"\n elb = AWS::ELB.new\n AWS.memoize do\n unless subnet\n # Build list of availability zones for any existing instances\n zones = { }\n zones[instance.availability_zone] = instance.availability_zone\n elb.load_balancers[elb_name].instances.each do |elb_instance|\n zones[elb_instance.availability_zone] = elb_instance.availability_zone\n end\n \n # Build list of existing zones\n existing_zones = { }\n elb.load_balancers[elb_name].availability_zones.each do |zone|\n existing_zones[zone.name] = zone\n end\n \n # Enable zones\n zones.keys.each do |zone_name|\n elb.load_balancers[elb_name].availability_zones.enable(zones[zone_name])\n end\n \n # Disable zones\n existing_zones.keys.each do |zone_name|\n elb.load_balancers[elb_name].availability_zones.disable(existing_zones[zone_name]) unless zones.has_key?(zone_name)\n end\n end\n \n elb.load_balancers[elb_name].instances.register(instance)\n end\n rescue StandardError => bang\n @log.error \"Error adding to load balancers: \" + bang.to_s\n end\n end", "def add_to_group(group_path, group_name)\n group = RubyAem::Resources::Group.new(@client, group_path, group_name)\n group.add_member(@call_params[:name])\n end", "def create_security_group_for_inception_vm\n \n return if settings[\"inception\"][\"security_group\"] \n\n ports = {\n ssh_access: 22,\n ping: { protocol: \"icmp\", ports: (-1..-1) } \n }\n security_group_name = \"#{settings.bosh_name}-inception-vm\"\n\n provider.create_security_group(security_group_name, \"inception-vm\", ports)\n\n settings[\"inception\"] ||= {}\n settings[\"inception\"][\"security_group\"] = security_group_name\n save_settings!\n end", "def execute(server_id)\n connection.create_ip_address(server_id, ip_params)\n end", "def modify_image_launch_perm_add_groups(image_id, user_group=['all'])\n modify_image_attribute(image_id, 'launchPermission', 'add', :user_group => user_group.to_a)\n end", "def revoke_security_group_IP_ingress(name, owner, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n @ec2.revoke_security_group_ingress_IP(name, protocol, from_port, to_port, cidr_ip) \n rescue Exception\n on_query_exception('revoke_security_group_IP_ingress')\n end", "def add_group(group, gid=nil)\n\t\t\tend" ]
[ "0.6491142", "0.614331", "0.6031237", "0.60004073", "0.5926284", "0.5926284", "0.58699954", "0.58220404", "0.5800351", "0.5796592", "0.5758454", "0.5721502", "0.57127887", "0.56476074", "0.5643926", "0.5621095", "0.561757", "0.5600346", "0.5598551", "0.55921835", "0.55314344", "0.5511943", "0.55041647", "0.5489594", "0.54838693", "0.54767555", "0.5470662", "0.54175997", "0.5350684", "0.5327377", "0.53234565", "0.52968043", "0.52968043", "0.5292339", "0.5291491", "0.5249048", "0.5220844", "0.5207089", "0.5203991", "0.5203168", "0.5203168", "0.51972765", "0.51936215", "0.51613396", "0.51568425", "0.5150286", "0.5127465", "0.51164263", "0.5105375", "0.5102168", "0.5092142", "0.50828385", "0.5077639", "0.5061092", "0.5046121", "0.504605", "0.5024679", "0.5012803", "0.50070405", "0.5006117", "0.49871725", "0.49860013", "0.4983247", "0.4982229", "0.4982229", "0.49820438", "0.4980216", "0.49799025", "0.49781486", "0.49664143", "0.49573836", "0.4951959", "0.49517742", "0.49453637", "0.49452603", "0.4943775", "0.49420074", "0.49394575", "0.49384195", "0.4933859", "0.49333853", "0.4931054", "0.4930903", "0.4916313", "0.4914404", "0.49136636", "0.49070945", "0.49070817", "0.48847196", "0.48667973", "0.48585045", "0.4856974", "0.4856974", "0.48566243", "0.48555374", "0.48546302", "0.48525554", "0.4828431", "0.48145625", "0.48142025", "0.48087695" ]
0.0
-1
group_owner_id defaults to the current owner_id
def revoke_ec2_security_group(group_name, group_owner_id=owner_id) key = group_name.match(/^sg-/) ? 'EC2SecurityGroupId' : 'EC2SecurityGroupName' revoke_ingress({ key => group_name, 'EC2SecurityGroupOwnerId' => group_owner_id }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group_owner\n User.find_by(id: self.user_id)\n end", "def owner_of(group)\n current_user.is_owner?(group)\n end", "def with_group_owner\n self\n end", "def set_owner(id)\n self.owner_id = id\n end", "def owner_user_id\n return @owner_user_id\n end", "def owner_user_id\n return @owner_user_id\n end", "def owner_id\n @sg.owner_id\n end", "def owner_id\n @sg.owner_id\n end", "def owner_id\n data.owner_id\n end", "def group_owner?\n super\n end", "def group_owner?\n super\n end", "def owner\n\t\tself.project_groups.find_by_project_creator(true).try(:user)\n\tend", "def owner_id\n data[:owner_id]\n end", "def owner_id\n data[:owner_id]\n end", "def group\n object.group.id\n end", "def owned_groups\n @owned_groups = Group.where(\"owner_id = ?\", current_user)\n end", "def owner\n if object.owner && (current_user.lead? || object.owner.id == current_user.id)\n object.owner.id\n else\n nil\n end\n end", "def owner\n @owner ||= User.find(owner_user_id)\n end", "def group_id\n super\n end", "def edit\n if GroupsController.group_owner? current_user.id, params[:id]\n set_group\n else\n respond_to do |format|\n format.html { redirect_to groups_path, alert: \"Can't Edit. You are not the group owner\" }\n format.json { render json: \"Only owners can edit the respective group page\", status: :unauthorized }\n end\n end\n end", "def owner\n user_id\n end", "def set_group\n @group = Group.find_by(id: params[:id],user_id: current_handle_user.id)\n end", "def group_owners_only\n where('group_owner_id.null': true)\n end", "def group\n self.event.owner\n end", "def group_params\n params.require(:group).permit(:name, :owner_id)\n end", "def set_owner\n @owner = Owner.find_by_owner_user_id(current_owner_user.id)\n end", "def autoset_owner\n bypass_auth do\n if accessor\n self.owner_id ||= accessor.id\n end\n end\n\n true # this is very important!\n end", "def store_owner_id\n self.user_id = self.album.user_id\n end", "def filter_owner(group_ids)\n group_ids = Array(group_ids)\n group_ids.delete(user.my_group_id)\n group_ids\n end", "def owner\n get_user owner_id\n end", "def correct_owner_id\n return 0 if accountant? or admin?\n return session[:user_id] if reseller?\n return session[:owner_id]\n end", "def group_id\n @attributes[:group_id]\n end", "def group_id\n @attributes[:group_id]\n end", "def group_id\n @attributes[:group_id]\n end", "def initialize_mailing_list_group_with_owner\n initialize_mailing_list_group\n update_ok(!@mailing_list_group.nil? && current_user.id == @mailing_list_group.user_id)\n end", "def owner=(_)\n end", "def set_group\n @group = current_user.groups.find(params[:group_id])\n end", "def set_group\n #@group = Group.find(params[:id])\n end", "def group_id\n get_info[:groupID]\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def owner=(value)\n @owner = value\n end", "def set_owner\n @owner = Owner.find(params[:owner_id])\n end", "def update\n if GroupsController.group_owner? current_user.id, params[:id]\n set_group\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to group_path(@group), alert: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to groups_path, alert: \"Not updated. You are not the group owner\" }\n format.json { render json: \"Only owners can edit the respective group page\", status: :unauthorized }\n end\n end\n end", "def owner\r\n\t\t\t`#{BITS::BITSADMIN} /getowner {#{@id}}`\r\n\t\tend", "def group_id\n \tregisterable.class.name == \"Group\" ? registerable.id : nil\n end", "def set_group\n if is_user_member_of_group? current_user, Group.find(params[:id])\n @group = Group.find(params[:id])\n else\n @group = Group.new\n end\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def set_OwnerId(value)\n set_input(\"OwnerId\", value)\n end", "def group() self['group'] || node[:users]['root'][:primary_group] ; end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def set_owner\n @owner = Owner.find(params[:id])\n end", "def owner\n {owner_id: self.object.user.id, \n owner_account: self.object.user.email}\n end", "def group; Group.get(self.group_id); end", "def set_group\n # byebug\n @group = Group.find(params[:id])\n end", "def set_group_user\n @group_user = group_user.find(params[:id])\n end", "def set_agroup\r\n @agroup = Agroup.find(params[:id])\r\n end", "def edit\n @group = current_user.created_groups.find(params[:id])\n end", "def set_os_groups_principal\n @os_groups_principal = OsGroupsPrincipal.find(params[:id])\n end", "def owner(arg=nil)\n arg.nil? ? @owner : @owner = arg.to_s\n end", "def group_members_only\n where('group_owner_id.not_null': true)\n end", "def show\n @owner_profile = User.find(@group.owner_id).profile\n end", "def set_group\n @group = Group.with_attached_logo.includes(:conversations).friendly.find(params[:id])\n end", "def group_owner_entry?\n group_entry? && principle == \"GROUP\"\n end", "def owner\n @owner\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if !current_user || (!current_user.is_admin && [email protected]?(current_user))\n format.html { redirect_to(@group, :notice => 'No permissions to edit group.')}\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n\n elsif @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def owner\n return self.user\n end", "def current_group\n end", "def manage_group\n @group = Group.find(params[:id])\n end", "def set_owner #:doc:\n self.owner_class.owner= get_current_owner\n end", "def create\n ip = request.location\n @user = current_user\n @group = @user.groups_as_owner.new(params[:group])\n params[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n @group.school_id = @user.school_id\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def group_ids\n @group_ids ||= current_user.group_ids\n end", "def owner\n User.find_by(id: user_id)\n end", "def group\n strong_memoize(:group) do\n if params[:group_id].present? && valid_request?\n the_group = Group.find_by(id: params[:group_id])\n can?(current_user, :read_group, the_group) ? the_group : nil\n end\n end\n end", "def set_object_owner\n @object_owner = ObjectOwner.find(params[:id])\n end", "def demote\n @group_user = @parent.find(params[:id]) #get the record\n\n if !current_user or (!current_user.is_admin and [email protected]?(current_user)) or current_user == @group_user.user\n redirect_to @group, :notice => \"You cannot demote that user.\"\n return\n end\n\n respond_to do |format|\n # We'll set is_owner to true. Remember update_attribute bypasses validations!\n if @group_user.update_attribute(:is_owner, false)\n format.html { redirect_to(@group, :notice => 'Group user is now a regulare member.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group_user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_owner\n @goal.owner = current_user\n end", "def set_owner(ownername)\n @result.owner = ownername\n end", "def owner\n @owner ||= User.new(connection, :login => @attributes[:owner])\n end", "def owner() self['owner'] || 'root' ; end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end" ]
[ "0.81719637", "0.77667946", "0.7725763", "0.7146375", "0.7089867", "0.7089867", "0.6990967", "0.69906116", "0.69637877", "0.6953418", "0.6953418", "0.6952131", "0.6907714", "0.6907714", "0.68497586", "0.6817341", "0.68021923", "0.6752042", "0.6716601", "0.66992486", "0.6660328", "0.6639699", "0.6599613", "0.65286547", "0.6515793", "0.6503214", "0.65021455", "0.64727575", "0.6471678", "0.64627564", "0.6436165", "0.6426773", "0.6426773", "0.6426773", "0.63884175", "0.631187", "0.6307269", "0.6301671", "0.62925416", "0.6289672", "0.6289672", "0.6289672", "0.6289672", "0.6289672", "0.62823623", "0.6282111", "0.62711036", "0.62683743", "0.6264284", "0.62462616", "0.62462616", "0.62462616", "0.62462616", "0.62462616", "0.62462616", "0.624511", "0.624511", "0.624511", "0.624511", "0.624511", "0.6244324", "0.624343", "0.6239982", "0.6239982", "0.6239982", "0.6239982", "0.6239982", "0.6239982", "0.6239982", "0.62353444", "0.62285644", "0.62258863", "0.62168014", "0.6199686", "0.6190239", "0.6176693", "0.6159198", "0.61583465", "0.6151322", "0.61504257", "0.6121563", "0.6121459", "0.6120201", "0.61194754", "0.61149186", "0.6103261", "0.6101781", "0.6098434", "0.6094972", "0.6077709", "0.607404", "0.6072797", "0.6064014", "0.6059529", "0.60554534", "0.6047812", "0.60461736", "0.60424507", "0.60412496", "0.60412496", "0.60412496" ]
0.0
-1
Returns error message if there is an error
def error? task_result_field if States::Error.include?(task_state) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message\n @errormsg\n end", "def error\n valid? ? nil : @error_message\n end", "def error_message; end", "def error_message\n error.message\n end", "def error message\n message = \"ERROR: \" + process_message(message)\n output_message message, @error_color if valid_conditions 3\n end", "def error_msg\n name\n end", "def error\n\t\t\t\t\"ERROR\"\n\t\t\tend", "def error_message\n return @error_message\n end", "def error_message\n raise \"calculator is empty\"\n end", "def error_message\n @error_message || \"Could not log in\"\n end", "def error\n return if success? unless parse_error?\n @data['error'] || @data['message']\n end", "def error_message\n if error == 'on_reserve'\n 'another user has already reserved this item'\n elsif error == 'too_many'\n \"you cannot renew a loan more than 10 times\"\n elsif code == 'PatronNotFound'\n 'problem with user id - please contact an administrator for assistance'\n end\n end", "def error_message(e)\n fail e\n end", "def error\n @error\n end", "def error_message\n @data[\"message\"]\n end", "def error\n nil\n end", "def error msg\n @error = msg\n end", "def error\r\n @error\r\n end", "def error\n nil\n end", "def error\n return {error: \"\"}\n end", "def error\n end", "def error?; end", "def error?; end", "def error?; end", "def error\n errors.full_messages.first\n end", "def error_message\n @@state[@server] ? @@state[@server][:message] : \"\"\n end", "def error_message?\n true if message[:error]\n end", "def errmsg(message); end", "def error_string\n # This method should be overridden\n end", "def describe_error\n message = \"\"\n if self.account_number == nil\n message = message + I18n.t(:wrong_or_missing_account_number, :scope => [:model, :index]) + \" \"\n end\n if self.account_bank_number == nil\n message = message + I18n.t(:wrong_or_missing_account_bank_number, :scope => [:model, :index]) + \" \"\n end\n if self.student.uic == nil\n message = message + I18n.t(:missing_uic, :scope => [:model, :index]) + \" \"\n end\n if self.sident == -666\n message = message + I18n.t(:missing_sident_666, :scope => [:model, :index]) + \" \"\n end\n if self.sident == nil\n message = message + I18n.t(:missing_sident, :scope => [:model, :index]) + \" \"\n end\n return message\n\n end", "def error\n return unless id.nil?\n @error ||= @response['message']\n end", "def error\r\n\t\t\t`#{BITS::BITSADMIN} /geterror {#{@id}}`\r\n\t\tend", "def error(string); end", "def error(string); end", "def error(message)\n output[:errors] << message\n end", "def message\n @error['message']\n end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error_message\n self[:error_message]\n end", "def error(message)\n output[:errors] << message\n end", "def print_error(error_message)\n error \"An error occurred!\"\n if error_message.include? \"400\"\n # 400 error indicates a bad request. At this point, it's most likely that\n # the user has passed an invalid Font Family ID. However, the API also \n # returns a 400 error in the case that a new Kit is attempting to be\n # created when the user is at their maximim Kit capacity.\n say \"The API indicated that the request was bad.\"\n say \"It's likely because the entered Font Family ID was invalid,\"\n say \"or that you've reached your maximum Kit limit.\"\n elsif error_message.include? \"404\"\n # 404 error indicates that a resource wasn't found. This is likely \n # because of an invalid ID. This shouldn't show up, as the menu shouldn't\n # let the user make a request on an ID that doesn't exist, but it's still\n # a common error code so include some message for it.\n say \"The API indicated that it couldn't find the resource.\"\n say \"Make sure that the the Kit wasn't deleted while using this application.\"\n end\n end", "def error\n print \"That is not a valid input. \\n\"\n end", "def error(message)\n @__result.add_error message\n false\n end", "def error\n return nil if reply_code == \"0000\" \n return \"#{reply_text}\"\n end", "def error\n end", "def error?\n error\n end", "def error\n params[\"ErrDesc\"]\n end", "def evaluate_error_message(error_code)\n case error_code\n when '0' then\n return 'We did not find a candidate profile matching your account. Please fill out your candidate profile first.'\n when '1' then\n return 'We did not find a faculty profile matching your account. Please fill out your faculty profile first.'\n when '2' then\n return 'We did not find the application form you are creating an appointment for.'\n else\n return 'Sorry. This page has encountered an error.'\n end\n else\n end", "def error_message\n if !success?\n body\n end\n rescue JSON::ParserError => ex\n ex.message\n end", "def error(msg = '')\n\t\toutput.print_error(msg)\n\tend", "def error_message(obj, name = \"\")\n if name.present? && obj.get_operation_result.code.zero?\n \"Could not find user '#{name}'\"\n else\n \"#{obj.get_operation_result.message} (code #{obj.get_operation_result.code})\"\n end\n end", "def error(message)\n\t\tp message\n\tend", "def message\n \"Telphin returned an error #{@error_code}: '#{@error_msg}'\"\n end", "def error_message\n err = details[\"err\"] || details[\"errmsg\"] || details[\"$err\"]\n if code = details[\"code\"]\n \"failed with error #{code}: #{err.inspect}\\n\\n\" <<\n \"See #{ERROR_REFERENCE}\\nfor details about this error.\"\n elsif code = details[\"assertionCode\"]\n assertion = details[\"assertion\"]\n \"failed with error #{code}: #{assertion.inspect}\\n\\n\" <<\n \"See #{ERROR_REFERENCE}\\nfor details about this error.\"\n else\n \"failed with error #{err.inspect}\"\n end\n end", "def error\n return @error\n end", "def errmsg(message)\n error.print(\"*** #{message}\\n\")\n end", "def error?\n @error\n end", "def error?\n @error\n end", "def error\n\t\tputs \"*********************\"\n\t\tputs \"<ERROR> Invalid input\"\n\t\tputs \"*********************\"\n\tend", "def error_message\n\t\t\tif @publication.errors.any?\n message = '<div id=\"error_explanation\"> ' +\n '<h2>' + @publication.errors.count.to_s + ' error(es) tratando de grabar la publicación:</h2> <ul>'\n @publication.errors.full_messages.each do |msg|\n message = message + '<li>'+ msg +'</li>'\n end\n message = message + '</ul>\t</div> '\n message.html_safe\n end\n end", "def error\n failure\n end", "def error_message (errors)\n\tmessage = \"\"\n\terror_array = errors.split\n\n\terror_array.each do |error|\n\t\tcase error\n\t\twhen \"name\"\n\t\t\tmessage += \"Invalid Name \\n\"\n\t\twhen \"email\"\n\t\t\tmessage += \"Invalid Email \\n\"\n\t\twhen \"dup\"\n\t\t\tmessage += \"Duplicate Name \\n\"\n\t\twhen \"bName\"\n\t\t\tmessage += \"Invalid Business Name \\n\"\n\t\tend\n\tend\n\t\n\treturn message\nend", "def error_message\n return '' if url.nil? || status_code == 200\n\n case status_code\n when 400\n 'The URL was not entered correctly. Be sure to use http:// or https:// to start all URLS'\n when 401\n 'The URL was not authorized for download.'\n when 403..404\n 'The URL was not found.'\n when 410\n 'The requested URL is no longer available.'\n when 411\n 'URL cannot be downloaded, please link directly to data file'\n when 414\n \"The server will not accept the request, because the URL #{url} is too long.\"\n when 408, 499\n 'The server timed out waiting for the request to complete.'\n when 409\n \"You've already added this URL in this version.\"\n when 500..511\n 'Encountered a remote server error while retrieving the request.'\n else\n 'The given URL is invalid. Please check the URL and resubmit.'\n end\n end", "def error msg\n puts \"#{self.class} error: #{msg}\"\n end", "def failed?\n error.present?\n end", "def error_message\n if @errors\n @errors.map { |(k,v)|\n \"#{k} #{v.join(',')}\"\n }.join(\"; \")\n end\n end", "def error\n data['error']\n end", "def error?\n !error.blank?\n end", "def error?\n true\n end", "def error\n @last_error && @last_error.error\n end", "def error(ex) [:error, ex]; end", "def error(message)\n @__result.add_error message\n false\n end", "def error\n placed_error = placed ? nil : 'Eva is not placed'\n placed_error || command.error\n end", "def error_message\n @response.reason_phrase\n end", "def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end", "def error\n return unless error?\n err || GenericError.new(error_code, error_msg)\n end", "def api_error\n dm_data.first.first == \"errors\"\n end", "def get_error_message\n error_msg = \"\"\n \n self.errors.full_messages.each do |msg|\n if error_msg != \"\"\n error_msg << \"<br>\"\n end\n error_msg << msg\n end\n\n error_msg\n end", "def error?\n message.fields[0] == 'WE'\n end", "def error_message(error)\n error_definition = error_definition(error)\n\n if error_definition && !error_definition.text.blank?\n error_definition.text\n else\n error.message\n end\n end", "def error\n errors.first\n end", "def error\n errors.first\n end", "def display_error\n error <<~MSG\n Sorry, please check\n your input to verify it\n is correct.\n MSG\n prompt error\nend", "def failure_message\n @message\n end", "def error(message)\n print(1, message)\n end", "def error_message\n \"JPT - #{setting_name} received an invalid argument: #{source}\"\n end", "def has_error?\n status == ERROR \n end", "def error\n @data['error']\n end", "def error\n @data['error']\n end", "def print_error\n puts @error_text if @error_text\n print_usage\n end", "def error(message)\n raw \"ERROR :#{message}\\r\\n\"\n end", "def error(msg)\n puts red(bold(\"[!] #{msg}\"))\n end", "def flash_error\n err = \"\"\n self.errors.messages.each {|name, value|\n err += value[0]\n }\n err\n end", "def getError\n return @error\n end", "def error(message) puts(message) || exit end", "def error_message\n if nagios_mode?\n puts \"CRIT: #{invalid_metadata_files.size} metadata files and #{invalid_packages.size} packages with invalid checksums\"\n else\n invalid_metadata_files.each do |metadata|\n msg metadata.explain_error\n end\n invalid_packages.each do |pkg|\n msg pkg.explain_error\n end\n end\n end" ]
[ "0.7982122", "0.79227185", "0.7870464", "0.76630884", "0.76078886", "0.7585859", "0.75676686", "0.75119203", "0.74794", "0.7406865", "0.7352388", "0.73436135", "0.7312576", "0.7307238", "0.7293063", "0.7285613", "0.72824585", "0.7279738", "0.7275888", "0.7269337", "0.72584414", "0.72234654", "0.72234654", "0.72234654", "0.72115964", "0.720784", "0.7202817", "0.72026354", "0.7202566", "0.71912766", "0.71849227", "0.71830744", "0.71700704", "0.71700704", "0.71403253", "0.71323407", "0.71162474", "0.71162474", "0.71162474", "0.71162474", "0.71162474", "0.71162474", "0.71162474", "0.7115643", "0.7113677", "0.7113349", "0.71130013", "0.7110524", "0.7101095", "0.70957065", "0.7089815", "0.7086108", "0.70843184", "0.7064593", "0.7062138", "0.7056106", "0.7053274", "0.7048149", "0.70446855", "0.70273083", "0.7010002", "0.7008359", "0.7008359", "0.6997182", "0.6974574", "0.6970146", "0.6965288", "0.69645834", "0.6960231", "0.69517624", "0.69464254", "0.69431686", "0.6942808", "0.69412285", "0.6936184", "0.69319713", "0.6927717", "0.6920183", "0.6916552", "0.69108737", "0.6910112", "0.6905648", "0.69018906", "0.69015825", "0.6883434", "0.68736655", "0.68736655", "0.6869157", "0.68621707", "0.6859863", "0.68573356", "0.68544745", "0.6845249", "0.6845249", "0.6844051", "0.68391454", "0.6833318", "0.6830651", "0.68271", "0.68229324", "0.68171346" ]
0.0
-1