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
end utility methods private The methods below should not be private methods, as they will be called from outside of this file. Namely, it will be taken care of by the controller, with input coming from the statistics UI template. Statistic creation initially goes through a pipeline of operations which successively cleans the unstructured data and organizes it in such a way that analytics can be made possible. Currently Statistic creation is done during the destruction of a Scenario, whereby the bash data is brought down from an s3 bucket and parsed into a nested Hash, mapping users to timestamps to commands. The methods defined below are helper methods that allow the investigator to reveal certain aspects of the data.
def perform_analytics(data) # input -> data: a hash of the form { users -> list of strings of commands } # output -> results: a nested array of two-element arrays results = [] # [[ string, count ]] or {string => count}, chartkick can deal with either. frequencies = Hash.new(0) data.keys.each do | user | data[user].each do | cmd | if !frequencies.include?(cmd) frequencies[cmd] = 1 else frequencies[cmd] += 1 end end end return frequencies end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_stats(example)\n file_path = example.metadata[:file_path].gsub('./qa/specs/features', '')\n api_fabrication = ((example.metadata[:api_fabrication] || 0) * 1000).round\n ui_fabrication = ((example.metadata[:browser_ui_fabrication] || 0) * 1000).round\n\n {\n name: 'test-stats',\n time: time,\n tags: {\n name: example.full_description,\n file_path: file_path,\n status: example.execution_result.status,\n smoke: example.metadata.key?(:smoke).to_s,\n reliable: example.metadata.key?(:reliable).to_s,\n quarantined: quarantined(example.metadata),\n retried: ((example.metadata[:retry_attempts] || 0) > 0).to_s,\n job_name: job_name,\n merge_request: merge_request,\n run_type: run_type,\n stage: devops_stage(file_path),\n testcase: example.metadata[:testcase]\n },\n fields: {\n id: example.id,\n run_time: (example.execution_result.run_time * 1000).round,\n api_fabrication: api_fabrication,\n ui_fabrication: ui_fabrication,\n total_fabrication: api_fabrication + ui_fabrication,\n retry_attempts: example.metadata[:retry_attempts] || 0,\n job_url: QA::Runtime::Env.ci_job_url,\n pipeline_url: env('CI_PIPELINE_URL'),\n pipeline_id: env('CI_PIPELINE_ID'),\n merge_request_iid: merge_request_iid\n }\n }\n rescue StandardError => e\n log(:error, \"Failed to transform example '#{example.id}', error: #{e}\")\n nil\n end", "def statistics; end", "def main\n operations.each { |op|\n template = [['sample: Sample Name', '', '', '', ''],['title: Title 1', 'title 1\\'s step 1', 'title 1\\'s step 2','title: Title n', '...'],['Ingredient 1', 'Ingredient 1\\'s quantity', 'Ingredient k', 'Ingredient k\\'s quantity', '...']]\n show {\n title \"File format (csv)\"\n table template\n }\n \n ups = upload_file\n if ups.nil?\n show { note \"No files found...\"}\n return\n end\n\n file = ups[0]\n data = read_url(file)\n \n # Remove nils from the data array.\n remove_data_nils data\n \n if(data.empty?)\n show { note \"no data, returning...\" } \n return\n end\n \n # Look through data for duplicates\n create_samples data\n \n }\n end", "def stats\n \n end", "def summary\n \n end", "def generate_analytics\n # parameters passed in via query string, see comment above\n statistic = Statistic.find(params[:id]) # yank statistic entry\n user = params[:user] # array of usernames\n # start_time = params[:start_time] # start of time window (as string)\n # end_time = params[:end_time] # end of time window (also as string)\n # find relevant commands based on query params above\n if statistic.bash_analytics.keys.include?(user) && statistic.bash_analytics[user] != {}\n times = statistic.bash_analytics[user].keys.sort\n start = times[0]\n end_ = times[-1]\n commands = statistic.grab_relevant_commands(user, start, end_)\n # perform analytics on the comands & put into serializable form\n @analytics = statistic.perform_analytics(commands).to_json\n respond_to do |format|\n format.js{ render js: \"new Chartkick.ColumnChart('chart', #{@analytics});\" }\n end\n else\n respond_to do |format|\n format.js{ render js: \"alert('User not in scenario.');\"}\n end\n end\n end", "def stats\n end", "def stats\n end", "def create_a_participant_stats_dto(parti)\n\t\tapi_fetch = APIFetcher.new\n\t\ttemp_psd = ParticipantStatsDto.new(first_blood_assist: api_fetch.is_nil_ret_bool(parti.dig(\"stats\", \"firstBloodAssist\")), \\\n\t\t\t\t\t\t\t\t\t\t\tvision_score: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"visionScore\")), \\\n\t\t\t\t\t\t\t\t\t\t\tmagic_damage_dealt_to_champions: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"magicDamageDealtToChampions\")), \\\n\t\t\t\t\t\t\t\t\t\t\tdamage_dealt_to_objectives: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"damageDealtToObjectives\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttotal_time_crowd_control_dealt: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"totalTimeCrowdControlDealt\")), \\\n\t\t\t\t\t\t\t\t\t\t\tlongest_time_spent_living: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"longestTimeSpentLiving\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttriple_kills: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"tripleKills\")), \\\n\t\t\t\t\t\t\t\t\t\t\tnode_neutralize_assist: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"nodeNeutralizeAssist\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_1_var_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk1Var1\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_1_var_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk1Var3\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_1_var_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk1Var2\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_3_var_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk3Var3\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_3_var_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk3Var2\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_9: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore9\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_8: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore8\")), \\\n\t\t\t\t\t\t\t\t\t\t\tkills: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"kills\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore1\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_0: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore0\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore3\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore2\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_5: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore5\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_4: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore4\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_6: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore7\")), \\\n\t\t\t\t\t\t\t\t\t\t\tplayer_score_7: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"playerScore7\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_5_var_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk5Var1\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_5_var_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk5Var3\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_5_var_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk5Var2\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttotal_score_rank: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"totalScoreRank\")), \\\n\t\t\t\t\t\t\t\t\t\t\tneutral_minions_killed: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"neutralMinionsKilled\")), \\\n\t\t\t\t\t\t\t\t\t\t\tdamage_dealt_to_turrets: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"damageDealtToTurrets\")), \\\n\t\t\t\t\t\t\t\t\t\t\tphysical_damage_dealt_to_champions: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"physicalDamageDealtToChampions\")), \\\n\t\t\t\t\t\t\t\t\t\t\tnode_capture: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"nodeCapture\")), \\\n\t\t\t\t\t\t\t\t\t\t\tlargest_multikill: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"largestMultiKill\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_2_var_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk2Var2\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_2_var_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk2Var3\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttotal_units_healed: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"totalUnitsHealed\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_2_var_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk2Var1\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_4_var_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk4Var1\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_4_var_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk4Var2\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_4_var_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk4Var3\")), \\\n\t\t\t\t\t\t\t\t\t\t\twards_killed: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"wardsKilled\")), \\\n\t\t\t\t\t\t\t\t\t\t\tlargest_critical_strike: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"largestCriticalStrike\")), \\\n\t\t\t\t\t\t\t\t\t\t\tlargest_killing_spree: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"largestKillingSpree\")), \\\n\t\t\t\t\t\t\t\t\t\t\tquadra_kills: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"quadraKills\")), \\\n\t\t\t\t\t\t\t\t\t\t\tteam_objective: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"teamObjective\")), \\\n\t\t\t\t\t\t\t\t\t\t\tmagic_damage_dealt: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"magicDamageDealt\")), \\\n\t\t\t\t\t\t\t\t\t\t\titem_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"item2\")), \\\n\t\t\t\t\t\t\t\t\t\t\titem_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"item3\")), \\\n\t\t\t\t\t\t\t\t\t\t\titem_0: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"item0\")), \\\n\t\t\t\t\t\t\t\t\t\t\titem_6: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"item6\")), \\\n\t\t\t\t\t\t\t\t\t\t\titem_5: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"item5\")), \\\n\t\t\t\t\t\t\t\t\t\t\titem_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"item1\")), \\\n\t\t\t\t\t\t\t\t\t\t\titem_4: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"item4\")), \\\n\t\t\t\t\t\t\t\t\t\t\tneutral_minions_killed_team_jungle: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"neutralMinionsKilledTeamJungle\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_0: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk0\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk1\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk2\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk3\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_4: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk4\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_5: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk5\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_3_var_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk3Var1\")), \\\n\t\t\t\t\t\t\t\t\t\t\tdamage_self_mitigated: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"damageSelfMitigated\")), \\\n\t\t\t\t\t\t\t\t\t\t\tmagical_damage_taken: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"magicalDamageTaken\")), \\\n\t\t\t\t\t\t\t\t\t\t\tfirst_inhibitor_kill: api_fetch.is_nil_ret_bool(parti.dig(\"stats\", \"firstInhibitorKill\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttrue_damage_taken: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"trueDamageTaken\")), \\\n\t\t\t\t\t\t\t\t\t\t\tnode_neutralize: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"nodeNeutralize\")), \\\n\t\t\t\t\t\t\t\t\t\t\tassists: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"assists\")), \\\n\t\t\t\t\t\t\t\t\t\t\tcombat_player_score: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"combatPlayerScore\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_primary_style: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perkPrimaryStyle\")), \\\n\t\t\t\t\t\t\t\t\t\t\tgold_spent: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"goldSpent\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttrue_damage_dealt: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"trueDamageDealt\")), \\\n\t\t\t\t\t\t\t\t\t\t\tparticipant_id: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"participantId\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttotal_damage_taken: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"totalDamageTaken\")), \\\n\t\t\t\t\t\t\t\t\t\t\tphysical_damage_dealt: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"physicalDamageDealt\")), \\\n\t\t\t\t\t\t\t\t\t\t\tsight_wards_bought_in_game: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"sightWardsBoughtInGame\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttotal_damage_dealt_to_champions: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"totalDamageDealtToChampions\")), \\\n\t\t\t\t\t\t\t\t\t\t\tphysical_damage_taken: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"physicalDamageTaken\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttotal_player_score: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"totalPlayerScore\")), \\\n\t\t\t\t\t\t\t\t\t\t\twin: api_fetch.is_nil_ret_bool(parti.dig(\"stats\", \"win\")), \\\n\t\t\t\t\t\t\t\t\t\t\tobjective_player_score: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"objectivePlayerScore\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttotal_damage_dealt: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"totalDamageDealt\")), \\\n\t\t\t\t\t\t\t\t\t\t\tneutral_minions_killed_enemy_jungle: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"neutralMinionsKilledEnemyJungle\")), \\\n\t\t\t\t\t\t\t\t\t\t\tdeaths: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"deaths\")), \\\n\t\t\t\t\t\t\t\t\t\t\twards_placed: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"wardsPlaced\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_sub_style: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perkSubStyle\")), \\\n\t\t\t\t\t\t\t\t\t\t\tturret_kills: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"turretKills\")), \\\n\t\t\t\t\t\t\t\t\t\t\tfirst_blood_kill: api_fetch.is_nil_ret_bool(parti.dig(\"stats\", \"firstBloodKill\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttrue_damage_dealt_to_champions: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"trueDamageDealtToChampions\")), \\\n\t\t\t\t\t\t\t\t\t\t\tgold_earned: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"goldEarned\")), \\\n\t\t\t\t\t\t\t\t\t\t\tkilling_sprees: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"killingSprees\")), \\\n\t\t\t\t\t\t\t\t\t\t\tunreal_kills: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"unrealKills\")), \\\n\t\t\t\t\t\t\t\t\t\t\taltars_captured: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"altarsCaptured\")), \\\n\t\t\t\t\t\t\t\t\t\t\tfirst_tower_assist: api_fetch.is_nil_ret_bool(parti.dig(\"stats\", \"firstTowerAssist\")), \\\n\t\t\t\t\t\t\t\t\t\t\tchamp_level: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"champLevel\")), \\\n\t\t\t\t\t\t\t\t\t\t\tfirst_tower_kill: api_fetch.is_nil_ret_bool(parti.dig(\"stats\", \"firstTowerKill\")), \\\n\t\t\t\t\t\t\t\t\t\t\tdouble_kills: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"doubleKills\")), \\\n\t\t\t\t\t\t\t\t\t\t\tnode_capture_assist: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"nodeCaptureAssist\")), \\\n\t\t\t\t\t\t\t\t\t\t\tinhibitor_kills: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"inhibitorKills\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_0_var_1: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk0Var1\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_0_var_2: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk0Var2\")), \\\n\t\t\t\t\t\t\t\t\t\t\tperk_0_var_3: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"perk0Var3\")), \\\n\t\t\t\t\t\t\t\t\t\t\tvision_wards_bought_in_game: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"visionWardsBoughtInGame\")), \\\n\t\t\t\t\t\t\t\t\t\t\taltars_neutralized: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"altarsNeutralized\")), \\\n\t\t\t\t\t\t\t\t\t\t\tpenta_kills: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"pentaKills\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttotal_heal: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"totalHeal\")), \\\n\t\t\t\t\t\t\t\t\t\t\ttime_ccing_others: api_fetch.is_nil_ret_int(parti.dig(\"stats\", \"timeCCingOthers\")))\n\t\ttemp_psd.save!\n\t\treturn temp_psd\n\tend", "def extractMetadata()\n Logging.LogScriptInfo \"Extract metadata from #{@logFile}...\"\n\n # Get the meta datas from the json report\n metas = {}\n iterations = []\n # totalDpsMeanStdDev = 0\n\n # Fight infos\n metas[\"fightLength\"] = @jsonData[\"sim\"][\"options\"][\"max_time\"].round\n metas[\"fightLengthVariation\"] = @jsonData[\"sim\"][\"options\"][\"vary_combat_length\"]\n metas[\"targetError\"] = @jsonData[\"sim\"][\"options\"][\"target_error\"]\n\n # Template infos\n @jsonData[\"sim\"][\"players\"].each do |player|\n if player[\"name\"] == \"Template\"\n # Get the gear using items simc encoded string\n gearSlots = [\"head\", \"neck\", \"shoulders\", \"back\", \"chest\", \"wrists\", \"hands\", \"waist\", \"legs\", \"feet\", \"finger1\", \"finger2\", \"trinket1\", \"trinket2\", \"main_hand\", \"off_hand\"]\n gear = []\n gearSlots.each do |gearSlot|\n item = player[\"gear\"][gearSlot]\n if item\n gear.push \"#{gearSlot}=#{item[\"encoded_item\"]}\"\n end\n end\n\n # Get the talents spell id\n talents = []\n player[\"talents\"].each do |talent|\n columnOffset = talent[\"tier\"] - (talents.length + 1)\n talents.fill(0, talents.length, columnOffset) if columnOffset > 0\n talents.push talent[\"spell_id\"]\n end\n\n metas[\"templateGear\"] = gear\n metas[\"templateTalents\"] = talents\n metas[\"templateDPS\"] = player[\"collected_data\"][\"dps\"][\"mean\"].round\n iterations.push player[\"collected_data\"][\"dps\"][\"count\"]\n # totalDpsMeanStdDev += player['collected_data']['dps']['mean_std_dev']\n end\n end\n @jsonData[\"sim\"][\"profilesets\"][\"results\"].each do |player|\n iterations.push player[\"iterations\"]\n # totalDpsMeanStdDev += player['stddev'] / Math.sqrt(player['iterations'])\n end\n\n # Statistics\n metas[\"elapsedTime\"] = @jsonData[\"sim\"][\"statistics\"][\"elapsed_time_seconds\"].round(2)\n metas[\"totalEventsProcessed\"] = @jsonData[\"sim\"][\"statistics\"][\"total_events_processed\"]\n metas[\"totalIterations\"] = iterations.sum\n metas[\"totalActors\"] = iterations.size\n # metas['totalIterationsMean'] = iterations.sum.to_f / iterations.size.to_f\n # metas['totalIterationsVariance'] = iterations.inject(0.0) { |s, x| s + (x - metas['statistics']['total_iterations_mean']) ** 2 }\n # metas['totalIterationsStdDev'] = Math.sqrt(metas['statistics']['total_iterations_variance'])\n # metas['totalIterationsSem'] = metas['statistics']['total_iterations_stddev'] / Math.sqrt(iterations.size)\n # metas['totalMeanDpsStdDev'] = totalDpsMeanStdDev / iterations.size\n # metas['totalMeanDpsVariance'] = metas['statistics']['total_mean_dps_stddev'] ** 2\n # metas['totalMeanDpsSem'] = metas['statistics']['total_mean_dps_stddev'] / Math.sqrt(iterations.size)\n\n # Build infos\n metas[\"simcBuildTimestamp\"] = DateTime.parse(@jsonData[\"build_date\"] + \" \" + @jsonData[\"build_time\"] + \" \" + Time.now.strftime(\"%:z\")).to_time.to_i\n metas[\"simcGitRevision\"] = @jsonData[\"git_revision\"]\n metas[\"wowVersion\"] = @jsonData[\"sim\"][\"options\"][\"dbc\"][@jsonData[\"sim\"][\"options\"][\"dbc\"][\"version_used\"]][\"wow_version\"]\n metas[\"wowBuild\"] = @jsonData[\"sim\"][\"options\"][\"dbc\"][@jsonData[\"sim\"][\"options\"][\"dbc\"][\"version_used\"]][\"build_level\"]\n\n # Add additional data\n metas.merge!(@additionalMetadata)\n\n return metas\n end", "def stats\n ## TODO:\n end", "def wrestler_output\n\n\t\tputs \"Name: #{self.values[:name]}\"\n\t\tputs \"Set: #{self.values[:set]}\"\n\t\tputs \"Singles Priority: #{self.values[:prioritys]}\"\n\t\tputs \"Tag Team Priority: #{self.values[:priorityt]}\"\n\t\tputs \"TT Probability: #{self.statistics[:tt_probability]}\"\n\t\tputs \"Card Rating: #{self.statistics[:total_card_rating]}\"\n\t\tputs \"OC Probability: #{self.statistics[:oc_probability]}\"\n\t\tputs \"Total Points-Per-Round: #{self.statistics[:total_card_points_per_round]}\"\n\t\tputs \"DQ Probability-Per-Round: #{self.statistics[:dq_probability_per_round]}\"\n\t\tputs \"P/A Probability-Per-Round: #{self.statistics[:pa_probability_per_round]}\"\n\t\tputs \"Submission Roll Probability-Per-Round: #{self.statistics[:sub_probability_per_round]}\"\n\t\tputs \"XX Roll Probability-Per-Round: #{self.statistics[:xx_probability_per_round]}\"\n\t\tputs \"Submission Loss Probability: #{self.points[:sub_prob]}\"\n\t\tputs \"Tag Team Save Probability: #{self.points[:tag_prob]}\"\n\t\tputs \"\\n\"\n\n\t\ttt_probability = \"%.1f\" % (self.statistics[:tt_probability] * 100) + \"%\"\n\t\tcard_rating = \"%.1f\" % self.statistics[:total_card_rating]\n\t\toc_probability = \"%.1f\" % (self.statistics[:oc_probability] * 100) + \"%\"\n\t\ttotal_card_points_per_round = \"%.3f\" % self.statistics[:total_card_points_per_round]\n\t\tdq_probability_per_round = \"%.1f\" % (self.statistics[:dq_probability_per_round] * 100) + \"%\"\n\t\tpa_probability_per_round = \"%.1f\" % (self.statistics[:pa_probability_per_round] * 100) + \"%\"\n\t\tsub_probability_per_round = \"%.1f\" % (self.statistics[:sub_probability_per_round] * 100) + \"%\"\n\t\txx_probability_per_round = \"%.1f\" % (self.statistics[:xx_probability_per_round] * 100) + \"%\"\n\t\t\n\t\tsub_prob = \"%.1f\" % (self.points[:sub_prob] * 100) + \"%\"\n\t\ttag_prob = \"%.1f\" % (self.points[:tag_prob] * 100) + \"%\"\n\n\t\tf = File.new('files/results.csv', 'a')\n\t\tf.write(\"#{self.values[:name]},#{self.values[:set]}, #{self.values[:prioritys]}, #{self.values[:priorityt]}, #{tt_probability}, #{card_rating}, #{oc_probability}, #{total_card_points_per_round}, #{dq_probability_per_round}, #{pa_probability_per_round}, #{sub_probability_per_round}, #{xx_probability_per_round}, #{sub_prob}, #{tag_prob}, \\n\")\n\t\tf.close\n\tend", "def set_stats\n {\n \"projectId\": '1234',\n \"invalid\": 2,\n \"error\": 1,\n \"info\": 0,\n \"warning\": 2\n }\nend", "def stats; end", "def stats; end", "def update_stats \n $logger.info \"regenerating stats from #{self.table_name}...\"\n \n # first delete the old data (always a good idea)\n AccessByServicePerMin.delete_all standard_condition \n AccessByServicePerHour.delete_all standard_condition\n AccessByServicePerDay.delete_all standard_condition\n \n # and reconstruct from the raw data\n success_entries = get_grouped_entries\n failure_entries = get_grouped_entries(false) \n \n # fill up gaps, merge the success and failure data and\n # write per-minute statistics\n 0.upto(23) do |hour|\n 0.upto(59) do |minute|\n \n the_timestamp = Time.at(start_ts + (hour * 60 + minute) * 60)\n \n new_row = AccessByServicePerMin.new(\n :host_name => self.host_name,\n :service_name => self.service_name,\n :log_ts => the_timestamp.strftime(\"%Y-%m-%d %H:%M:%S\"),\n :success_count => 0, \n :failure_count => 0,\n :response_time_micros_avg => 0\n )\n if success_entries.has_key?(the_timestamp)\n new_row[:success_count] = success_entries[the_timestamp].the_count\n new_row[:response_time_micros_avg] = success_entries[the_timestamp].the_avg\n end\n if failure_entries.has_key?(the_timestamp)\n new_row[:failure_count] = failure_entries[the_timestamp].the_count\n end\n new_row.save()\n end\n end\n \n # group the data we've just written by hour\n grouped_by_hour = get_hour_stats_from_minutes\n 0.upto(23) do |hour|\n the_timestamp = Time.at(start_ts + (hour * 60 * 60))\n new_row = AccessByServicePerHour.new(\n :host_name => self.host_name,\n :service_name => self.service_name,\n :log_ts => the_timestamp.strftime(\"%Y-%m-%d %H:%M:%S\"),\n :success_count => 0, \n :failure_count => 0,\n :response_time_micros_avg => 0 \n )\n if grouped_by_hour.has_key?(the_timestamp)\n new_row[:success_count] = grouped_by_hour[the_timestamp].success_sum\n new_row[:failure_count] = grouped_by_hour[the_timestamp].failure_sum\n new_row[:response_time_micros_avg] = grouped_by_hour[the_timestamp].the_avg\n end\n new_row.save\n end\n \n # and update the daily stats from the hours\n row = get_daily_stats_from_hours.first \n AccessByServicePerDay.new(\n :host_name => self.host_name,\n :service_name => self.service_name,\n :log_ts => start_ts.strftime(\"%Y-%m-%d %H:%M:%S\"),\n :success_count => row.success_sum, \n :failure_count => row.failure_sum,\n :response_time_micros_avg => row.the_avg\n ).save()\n $logger.info \"updated stats for #{self.service_name}@#{self.host_name} : #{row.success_sum} successful calls, #{row.failure_sum} failures between #{start_ts} and #{stop_ts}\"\n end", "def basic_stack_data_format(info)\n info = info.to_smash\n Smash.new(\n :id => info[:id],\n :created => Time.parse(info[:insertTime]),\n :updated => Time.parse(info.fetch(:operation, :endTime, info.fetch(:operation, :startTime, info[:insertTime]))),\n :description => info[:description],\n :name => info[:name],\n :state => determine_state(info.fetch(:operation, {})),\n :status => determine_state(info.fetch(:operation, {})).to_s.split('_').map(&:capitalize).join(' '),\n :custom => info\n )\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def statistics\n super\n end", "def dash_data_create\n set_cat_data\n\n grants_percent = ((session[:research_sub].to_f / session[:num_charities].to_f) * 100).to_s + '%'\n research_percent = ((session[:grants_sub].to_f / session[:num_charities].to_f) * 100).to_s + '%'\n\n a_val = Array.new()\n b_val = Array.new()\n c_val = Array.new()\n d_val = Array.new()\n e_val = Array.new()\n values = Array.new()\n\n a_val.push('a', @a_research, @a_grant)\n b_val.push('b', @b_research, @b_grant)\n c_val.push('c', @c_research, @c_grant)\n d_val.push('d', @d_research, @d_grant)\n e_val.push('e', @e_research, @e_grant)\n values.push(session[:rex_spending], session[:rex_est_spending], session[:grant_total], session[:num_charities], grants_percent, research_percent)\n attributes = %w{Total_Research_Spending Total_Estimated_Research_Spending Total_Grants_Spending Total_Number_of_Charities Research_Forms_Submitted Grant_Forms_Submitted}\n attributes1 = values\n attributes2 = %w{Category Research_Expenditure Grant_Expenditure}\n attributesa = a_val\n attributesb = b_val\n attributesc = c_val\n attributesd = d_val\n attributese = e_val\n\n CSV.generate(headers: true) do |csv|\n csv << attributes\n csv << attributes1\n csv << attributes2\n csv << attributesa\n csv << attributesb\n csv << attributesc\n csv << attributesd\n csv << attributese\n end\n end", "def summary; end", "def summary; end", "def summary; end", "def summary; end", "def quick_stats\n\tend", "def statistic!\n statistic = Statistic.find_by(source: Statistic::GITHUB, source_id: issue_id)\n\n if statistic\n statistic.tap { |stat| stat.update! issue_attributes }\n else\n statistic = Statistic.create! issue_attributes\n end\n\n associate_github_user_with statistic\n end", "def stats\n groups = ::Twigg::Pivotal::Status.status\n\n groups.each do |current_state, stories|\n header = pluralize stories.size,\n \"#{current_state} story\",\n \"#{current_state} stories\"\n puts header\n\n stories.each do |story|\n print \"[#{story.story_type}] #{story.name}\"\n if story.owned_by\n puts \" [#{story.owned_by['initials']}]\"\n else\n puts\n end\n end\n\n puts\n end\n\n puts '', 'Totals'\n groups.each do |current_state, stories|\n puts number_with_delimiter(stories.size) + \" #{current_state}\"\n end\n puts\n end", "def init_statistic\n create_statistic if course_user&.role == 'student' && statistic.nil?\n end", "def system_usage_data\n {\n counts: {\n assignee_lists: count(List.assignee),\n boards: count(Board),\n ci_builds: count(::Ci::Build),\n ci_internal_pipelines: count(::Ci::Pipeline.internal),\n ci_external_pipelines: count(::Ci::Pipeline.external),\n ci_pipeline_config_auto_devops: count(::Ci::Pipeline.auto_devops_source),\n ci_pipeline_config_repository: count(::Ci::Pipeline.repository_source),\n ci_runners: count(::Ci::Runner),\n ci_triggers: count(::Ci::Trigger),\n ci_pipeline_schedules: count(::Ci::PipelineSchedule),\n auto_devops_enabled: count(::ProjectAutoDevops.enabled),\n auto_devops_disabled: count(::ProjectAutoDevops.disabled),\n deploy_keys: count(DeployKey),\n deployments: count(Deployment),\n successful_deployments: count(Deployment.success),\n failed_deployments: count(Deployment.failed),\n environments: count(::Environment),\n clusters: count(::Clusters::Cluster),\n clusters_enabled: count(::Clusters::Cluster.enabled),\n project_clusters_enabled: count(::Clusters::Cluster.enabled.project_type),\n group_clusters_enabled: count(::Clusters::Cluster.enabled.group_type),\n clusters_disabled: count(::Clusters::Cluster.disabled),\n project_clusters_disabled: count(::Clusters::Cluster.disabled.project_type),\n group_clusters_disabled: count(::Clusters::Cluster.disabled.group_type),\n clusters_platforms_gke: count(::Clusters::Cluster.gcp_installed.enabled),\n clusters_platforms_user: count(::Clusters::Cluster.user_provided.enabled),\n clusters_applications_helm: count(::Clusters::Applications::Helm.available),\n clusters_applications_ingress: count(::Clusters::Applications::Ingress.available),\n clusters_applications_cert_managers: count(::Clusters::Applications::CertManager.available),\n clusters_applications_prometheus: count(::Clusters::Applications::Prometheus.available),\n clusters_applications_runner: count(::Clusters::Applications::Runner.available),\n clusters_applications_knative: count(::Clusters::Applications::Knative.available),\n in_review_folder: count(::Environment.in_review_folder),\n groups: count(Group),\n issues: count(Issue),\n keys: count(Key),\n label_lists: count(List.label),\n lfs_objects: count(LfsObject),\n milestone_lists: count(List.milestone),\n milestones: count(Milestone),\n pages_domains: count(PagesDomain),\n projects: count(Project),\n projects_imported_from_github: count(Project.where(import_type: 'github')),\n projects_with_repositories_enabled: count(ProjectFeature.where('repository_access_level > ?', ProjectFeature::DISABLED)),\n projects_with_error_tracking_enabled: count(::ErrorTracking::ProjectErrorTrackingSetting.where(enabled: true)),\n protected_branches: count(ProtectedBranch),\n releases: count(Release),\n remote_mirrors: count(RemoteMirror),\n snippets: count(Snippet),\n suggestions: count(Suggestion),\n todos: count(Todo),\n uploads: count(Upload),\n web_hooks: count(WebHook)\n }\n .merge(services_usage)\n .merge(approximate_counts)\n }.tap do |data|\n if Feature.enabled?(:group_overview_security_dashboard)\n data[:counts][:user_preferences] = user_preferences_usage\n end\n end\n end", "def fabrication_stats(resource:, info:, fabrication_method:, http_method:, fabrication_time:, timestamp:, **)\n {\n name: 'fabrication-stats',\n time: time,\n tags: {\n resource: resource,\n fabrication_method: fabrication_method,\n http_method: http_method,\n run_type: env('QA_RUN_TYPE') || run_type,\n merge_request: merge_request\n },\n fields: {\n fabrication_time: fabrication_time,\n info: info,\n job_url: QA::Runtime::Env.ci_job_url,\n timestamp: timestamp\n }\n }\n end", "def create_metrics_for_snapshot(snapshot)\n\n @eth0_rx_counter ||= 0\n @eth0_tx_counter ||= 0\n @uptime_counter ||= 0\n \n # Build a random value for the network counters.\n @eth0_rx_counter += rand(100000)\n @eth0_tx_counter += rand(200000)\n\n # Increase the uptime counter by one minute.\n @uptime_counter += 1.minute\n\n # Create the load.average metric.\n Sherlock::Models::Metric.create!(\n :node_id => snapshot.node_id,\n :timestamp => snapshot.timestamp,\n :path => 'load.average',\n :counter => rand()\n )\n\n # Create the memory metrics.\n Sherlock::Models::Metric.create!(\n :node_id => snapshot.node_id,\n :timestamp => snapshot.timestamp,\n :path => 'memory.physical.used',\n :counter => rand(100000) + 1000\n )\n Sherlock::Models::Metric.create!(\n :node_id => snapshot.node_id,\n :timestamp => snapshot.timestamp,\n :path => 'memory.swap.used',\n :counter => rand(1000) + 1000\n )\n \n # Create a uptime metric.\n Sherlock::Models::Metric.create!(\n :node_id => snapshot.node_id,\n :timestamp => snapshot.timestamp,\n :path => 'uptime',\n :counter => @uptime_counter\n )\n\n # Create the process count metric.\n Sherlock::Models::Metric.create!(\n :node_id => snapshot.node_id,\n :timestamp => snapshot.timestamp,\n :path => 'processes.count',\n :counter => rand(100) + 10\n )\n\n # Create the eth0 network metrics.\n Sherlock::Models::Metric.create!(\n :node_id => snapshot.node_id,\n :timestamp => snapshot.timestamp,\n :path => 'network_interfaces.eth0.bytes.rx',\n :counter => @eth0_rx_counter\n )\n Sherlock::Models::Metric.create!(\n :node_id => snapshot.node_id,\n :timestamp => snapshot.timestamp,\n :path => 'network_interfaces.eth0.bytes.tx',\n :counter => @eth0_tx_counter\n )\n\nend", "def setup_summary_report\n assign_to_from_dates\n @filter = @filter.remove_blanks_in_arrays\n @filter_name = @filter[:name]\n assign_grouping_type\n assign_facilities\n end", "def test_scenario3\n data = [[File.dirname(__FILE__)+'/data/iris.csv', \n false, \n File.dirname(__FILE__)+'/tmp/logistic.json']]\n puts\n puts \"Scenario 3: Successfully creating a local logistic regression from an exported file\"\n\n data.each do |filename, pmml, exported_file|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And the source is in the project\"\n assert_equal(source[\"object\"]['project'], @project[\"resource\"])\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And the dataset is in the project\"\n assert_equal(dataset[\"object\"]['project'], @project[\"resource\"])\n \n puts \"An I create a logistic regression\"\n logistic_regression = @api.create_logisticregression(dataset)\n\n puts \"And I wait until the logistic_regression is ready\"\n assert_equal(BigML::HTTP_CREATED, logistic_regression[\"code\"])\n assert_equal(1, logistic_regression[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(logistic_regression), true)\n \n puts \"And I export the <%s> logistic regression to <%s>\" % [pmml, exported_file]\n @api.export(logistic_regression[\"resource\"], exported_file)\n \n puts \"When I create a local logistic regression from the file <%s>\" % exported_file\n local_Logistic= BigML::Logistic.new(exported_file)\n \n puts \"Then the logistic regression ID and the local logistic regression ID match\"\n assert_equal(local_Logistic.resource_id, logistic_regression[\"resource\"])\n \n end\n end", "def setup_superuser_stats # rubocop:disable Metrics/AbcSize\n @stats =\n {\n user_count: User.all,\n dataset_count: Identifier.all,\n user_7days: User.where(['stash_engine_users.created_at > ?', Time.new - 7.days]),\n dataset_started_7days: Resource.joins(:current_resource_state)\n .where(stash_engine_resource_states: { resource_state: %i[in_progress] })\n .where(['stash_engine_resources.created_at > ?', Time.new - 7.days]),\n dataset_submitted_7days: Identifier.where(['stash_engine_identifiers.created_at > ?', Time.new - 7.days])\n }\n end", "def perform\n\n set_user(@data['user'])\n\n set_client_token(@data['client_token'])\n\n set_oracle_price_points(@data['oracle_price_points'])\n\n set_pending_critical_interactions(@data['pending_critical_interactions']) if @data['pending_critical_interactions'].present?\n\n set_client_token_planner(@data['client_token_planner']) if @data['client_token_planner'].present?\n\n set_chain_interaction_params(@data['chain_interaction_params']) if @data['chain_interaction_params'].present?\n\n set_client_balances(@data['client_balances']) if @data['client_balances'].present?\n\n set_token_supply_details(@data['token_supply_details']) if @data['token_supply_details'].present?\n\n set_client_stats(@data['client_stats']) if @data['client_stats'].present?\n\n set_api_console_data(@data['api_console_data']) if @data['api_console_data'].present?\n\n set_client_bt_addresses_data(@data['client_bt_addresses']) if @data['client_bt_addresses'].present?\n\n end", "def create\n\n project_dir = Pathname.new(APP_CONFIG[:user_data_dir]) + @project.user.id.to_s + @project.key \n \n @req = Req.new(req_params)\n @req.project_id = @project.id\n \n @h_env = JSON.parse(@project.version.env_json)\n @std_method = @req.std_method\n @step = @req.step\n \n @h_attrs = {}\n @h_errors = {}\n \n if @std_method and @step\n\n # ## cell_filtering\n # \n # if @step.id == 9\n # ## write list of filtered cells\n # filepath = project_dir + 'filtered_out_cells.txt'\n # File.open(filepath, 'w') do |f|\n # f.write(params[:req][:all_filtered])\n # end\n # end\n\n h_global_params = JSON.parse(@step.method_attrs_json)\n \n @h_attrs = JSON.parse(@std_method.attrs_json)\n ## complement attributes with global parameters - defined at the level of the step \n \n h_global_params.each_key do |k|\n @h_attrs[k]={}\n h_global_params[k].each_key do |k2|\n @h_attrs[k][k2] = h_global_params[k][k2]\n end\n end\n\n # ### apply write_in_file\n # @h_attrs.each_key do |k|\n # if filename = @h_attrs[k]['write_in_file']\n # filepath = project_dir + filename\n # File.open(filepath, 'w') do |f|\n # f.write(params[:attrs][k])\n # end\n # end\n # end\n end\n \n tmp_attrs = params[:attrs]\n\n if tmp_attrs\n tmp_attrs.each_pair do |k, v|\n if @h_attrs[k] and @h_attrs[k]['req_data_structure'] and [\"array\", \"hash\"].include? @h_attrs[k]['req_data_structure']\n tmp_attrs[k] = JSON.parse(v) #Basic.safe_parse_json(v, nil)\n end\n end\n end\n @req.attrs_json = (tmp_attrs) ? tmp_attrs.to_json : \"{}\"\n @req.user_id = (current_user) ? current_user.id : 1\n\n \n\n respond_to do |format|\n if @req.save\n\n create_runs()\n errors_txt = nil\n list_errors = []\n if @h_errors[:already_existing]\n list_errors.push(\"#{@h_errors[:already_existing]} configuration#{(@h_errors[:already_existing] > 1) ? 's' : ''} #{(@h_errors[:already_existing] > 1) ? 'were' : 'was'} already launched, #{(@h_errors[:already_existing] > 1) ? 'they were' : 'it was'} not added.\")\n end\n if list_errors.size > 0\n errors_txt = list_errors.join(\" \")\n end\n \n format.json { render :json => {:status => 'success', :errors => errors_txt}}\n # format.html { redirect_to @req, notice: 'Req was successfully created.' }\n # format.json { render :show, status: :created, location: @req }\n else\n format.json { render :json => {:status => 'failed', :log => tmp_attrs.to_json}}\n # format.html { render :new }\n # format.json { render json: @req.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_scenario2\n data = [{'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.98029',\n 'params' => {\"combiner\" => 0},\n 'tlp' => 1},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.95061',\n 'params' => {\"combiner\" => 1},\n 'tlp' => 1},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.98029',\n 'params' => {\"combiner\" => 2},\n 'tlp' => 1},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.98029',\n 'params' => {\"operating_kind\" => \"votes\"},\n 'tlp' => 1},\n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.97064',\n 'params' => {\"operating_kind\" => \"probability\"},\n 'tlp' => 1}, \n {'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'number_of_models' => 5,\n 'measure' => 'average_phi',\n 'value' => '0.95061',\n 'params' => {\"operating_kind\" => \"confidence\"},\n 'tlp' => 1},\n ]\n \n puts\n puts \"Scenario: Successfully creating an evaluation for an ensemble\" \n\n data.each do |item|\n puts\n puts \"Given I create a data source uploading a \" + item[\"filename\"] + \" file\"\n source = @api.create_source(item[\"filename\"], {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset with local source\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"And I create an ensemble of #{item['number_of_models']} models and #{item['tlp']} tlp\"\n \n ensemble = @api.create_ensemble(dataset, {\"number_of_models\"=> item[\"number_of_models\"], \n \"seed\" => 'BigML', \n 'ensemble_sample'=>{'rate' => 0.7, \n 'seed' => 'BigML'}, \n 'missing_splits' => false})\n \n\n puts \"And I wait until the ensemble is ready\"\n assert_equal(BigML::HTTP_CREATED, ensemble[\"code\"])\n assert_equal(@api.ok(ensemble), true)\n\n puts \"When I create an evaluation for the ensemble with the dataset\"\n evaluation = @api.create_evaluation(ensemble, dataset, item[\"params\"])\n\n puts \"And I wait until the evaluation is ready\"\n assert_equal(BigML::HTTP_CREATED, evaluation[\"code\"])\n assert_equal(@api.ok(evaluation), true)\n\n puts \"Then the measured #{item['measure']} is #{item['value']}\"\n evaluation = @api.get_evaluation(evaluation)\n assert_equal(item[\"value\"].to_f, evaluation[\"object\"][\"result\"][\"model\"][item[\"measure\"]].to_f) \n\n end\n\n end", "def create_summaries(obj, base_time)\n base_start = base_time\n base_end = base_time + 40.hours\n summaries = {\n :all => obj.summary,\n :all_constrained => obj.summary(base_start ... base_end),\n :wide => obj.summary(base_start - 1.hours ... base_end + 1.hours),\n #TODO: push this farther forward?\n :clipped => obj.summary(base_start + 30.minutes ... base_start + 25.hours),\n :empty => obj.summary(base_start ... base_start),\n }\n\n #TODO: move?\n if obj.respond_to?(:by_command_name)\n summaries[:all_filtered] = obj.by_command_name('vi').summary(base_start ... base_end)\n end\n\n summaries\n end", "def generate_site_stats\n H.ul {\n H.li {\"#{$r.get(\"users.count\")} users\"} +\n H.li {\"#{$r.zcard(\"news.cron\")} news posted\"} +\n H.li {\"#{$r.info['used_memory_human']} of used memory\"}\n }\nend", "def generateCVSToStatisticAnalysis (projectName, localClone, pathInput,pathOutput)\n\t\tprefixProjectName = formatProjectName(projectName)\n\t\t\n\t\tlistSlices = []\n\t\tlistConflictsAndFiles = []\n\t\tlistNumberOfCommits = []\n\t\tlistNumberOfAuthors = []\n\t\tlistDelayDeltaIntegration = []\n\t\tlistMinimumLifeTime = []\n\t\tlistNmberOfChangedFiles = []\n\t\tlistNumberOfChangedLines = []\n\t\tlistContributionConclusionDelay = []\n\t\tlistPackages = []\n\n\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_CommitList.csv\", 'r') do |mainMerges|\n\t\t\twhile line = mainMerges.gets \n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\tFile.open(localClone+pathInput+prefixProjectName+\".csv\", 'r') do |auxMerges| \n\t\t\t\t\t\twhile lineAux = auxMerges.gets \n\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\")\n\t\t\t\t\t\t\t\tisConflicting = \"0\"\n\t\t\t\t\t\t\t\tif camposMainMerge[1].gsub(\"\\\"\",\"\").eql?(\"true\")\n\t\t\t\t\t\t\t\t\tisConflicting = \"1\"\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\texistsCommonSlice = camposAuxMerge[2].gsub(\"\\\"\",\"\")\n\t\t\t\t\t\t\t\ttotalCommonSlices = camposAuxMerge[3].gsub(\"\\\"\",\"\")\n\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices\n\t\t\t\t\t\t\t\tlistSlices.push(dados)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\tend #while\n\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_Slices.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices\"\n\t\t\tlistSlices.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_Slices.csv\", 'r') do |mainMerges|\n\t\t\t#while line = mainMerges.gets \n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\tdados=\"\"\n\t\t\t\t\tif camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\").eql?(\"0\")\n\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\tconflictingFilesNumber = \"0\"\n\t\t\t\t\t\tconflictsNumber = \"0\"\n\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber\n\t\t\t\t\t\tlistConflictsAndFiles.push(dados)\n\t\t\t\t\telsif camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\").eql?(\"1\")\t\t\t\t\t\n\t\t\t\t\t\tFile.open(localClone+pathInput+prefixProjectName+\"_MergeScenarioList.csv\", 'r') do |auxMerges|\n\t\t\t\t#\t\t\twhile lineAux = auxMerges.gets \n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\t#conflictingFilesNumber = camposAuxMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposAuxMerge[2].to_s.split(\"@\").length.to_s #.gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposAuxMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber\n\t\t\t\t\t\t\t\t\t\tlistConflictsAndFiles.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t#\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\t\tend# elsif\n\t\t\t\tend #each_line\n\t\t#\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_ConflictingFilesAndConflicts.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber\"\n\t\t\tlistConflictsAndFiles.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_ConflictingFilesAndConflicts.csv\", 'r') do |mainMerges| \n\t\t\t#while line = mainMerges.gets \n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_CommitList.csv\", 'r') do |auxMerges| \n\t\t\t\t#\t\t\twhile lineAux = auxMerges.gets \n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposAuxMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")#8\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposAuxMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")#8#9\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistNumberOfCommits.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t#\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t#\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfCommits.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage\"\n\t\t\tlistNumberOfCommits.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfCommits.csv\", 'r') do |mainMerges| \n\t\t\t#while line = mainMerges.gets \n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_AuthorList.csv\", 'r') do |auxMerges| \n\t\t\t\t#\t\t\twhile lineAux = auxMerges.gets \n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposAuxMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistNumberOfAuthors.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t#\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t#\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfAuhtors.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage\"\n\t\t\tlistNumberOfAuthors.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\t\t\n\t\t# Deprecated - generate csv with delay and delta integration - metrics not used anymore\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfAuhtors.csv\", 'r') do |mainMerges| \n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_DelayDeltaIntegrationList.csv\", 'r') do |auxMerges|\n\t\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdeltaIntegration = camposAuxMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration\n\t\t\t\t\t\t\t\t\t\tlistDelayDeltaIntegration.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_DelayAndDeltaIntegration.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration\"\n\t\t\tlistDelayDeltaIntegration.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_DelayAndDeltaIntegration.csv\", 'r') do |mainMerges| \n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_LifetimeAuthorDateList.csv\", 'r') do |auxMerges| \n\t\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistMinimumLifeTime.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_MinimumLifeTime.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage\"\n\t\t\tlistMinimumLifeTime.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_MinimumLifeTime.csv\", 'r') do |mainMerges| \n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_NumberOfChangedFiles.csv\", 'r') do |auxMerges| \n\t\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposMainMerge[13].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposMainMerge[14].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedFilesArithAverage = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedFilesGeoAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistNmberOfChangedFiles.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfChangedFiles.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage, numberOfChangedFilesArithAverage, numberOfChangedFilesGeoAverage\"\n\t\t\tlistNmberOfChangedFiles.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfChangedFiles.csv\", 'r') do |mainMerges| \n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_NumberOfChangedLines.csv\", 'r') do |auxMerges| \n\t\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposMainMerge[13].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposMainMerge[14].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedFilesArithAverage = camposMainMerge[15].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedFilesGeoAverage = camposMainMerge[16].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedLinesArithAverage = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedLinesGeoAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage+\",\"+numberOfChangedLinesArithAverage+\",\"+numberOfChangedLinesGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistNumberOfChangedLines.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfChangedLines.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage, numberOfChangedFilesArithAverage, numberOfChangedFilesGeoAverage, numberOfChangedLinesArithAverage, numberOfChangedLinesGeoAverage\"\n\t\t\tlistNumberOfChangedLines.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfChangedLines.csv\", 'r') do |mainMerges|\n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_ContributionConclusionDelayList.csv\", 'r') do |auxMerges|\n\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposMainMerge[13].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposMainMerge[14].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedFilesArithAverage = camposMainMerge[15].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedFilesGeoAverage = camposMainMerge[16].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedLinesArithAverage = camposMainMerge[17].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedLinesGeoAverage = camposMainMerge[18].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tcontributionConclusionDelay = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\n\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage+\",\"+numberOfChangedLinesArithAverage+\",\"+numberOfChangedLinesGeoAverage+\",\"+contributionConclusionDelay\n\t\t\t\t\t\t\t\t\tlistContributionConclusionDelay.push(dados)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\tend #while\n\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_ContributionConclusionDelay.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage, numberOfChangedFilesArithAverage, numberOfChangedFilesGeoAverage, numberOfChangedLinesArithAverage, numberOfChangedLinesGeoAverage, contributionConclusionDelay\"\n\t\t\tlistContributionConclusionDelay.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\t#aqui inderir a última variável desejada, precisar alterar de acordo com a última\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_ContributionConclusionDelay.csv\", 'r') do |mainMerges|\n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\tFile.open(localClone+pathInput+prefixProjectName+\"_Packages.csv\", 'r') do |auxMerges|\n\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposMainMerge[13].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposMainMerge[14].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedFilesArithAverage = camposMainMerge[15].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedFilesGeoAverage = camposMainMerge[16].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedLinesArithAverage = camposMainMerge[17].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedLinesGeoAverage = camposMainMerge[18].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tcontributionConclusionDelay = camposMainMerge[19].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t#metricas de package adicionadas\n\t\t\t\t\t\t\t\t\texistsCommonPackages = camposAuxMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\ttotalCommonPackages = camposAuxMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\n\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage+\",\"+numberOfChangedLinesArithAverage+\",\"+numberOfChangedLinesGeoAverage+\",\"+contributionConclusionDelay+\",\"+existsCommonPackages+\",\"+totalCommonPackages\n\t\t\t\t\t\t\t\t\tlistPackages.push(dados)\n\t\t\t\t\t\t\t\t\t#puts \"dados = #{dados}\"\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\tend #while\n\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_AllVariables.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage, numberOfChangedFilesArithAverage, numberOfChangedFilesGeoAverage, numberOfChangedLinesArithAverage, numberOfChangedLinesGeoAverage, contributionConclusionDelay, existsCommonPackages, totalCommonPackages\"\n\t\t\tlistPackages.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\t\t#puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tputs \"end running generateCVSToStatisticAnalysis from #{prefixProjectName} project\"\n\tend", "def summary\n end", "def summary\n end", "def build_summary_data(start_time, end_time, response)\n build_enphase_summary(response.body) \n build_data_harvest(start_time, end_time, response)\n \n total_end_time = Time.now.to_f\n build_job(start_time, total_end_time)\n end", "def import_active_stats\n\n end", "def run\n options_parse\n \n # output files (or set outfile to $stdout if no output file specified)\n outfile = $stdout\n unless @options[:out].nil?\n outfile = File.open(@options[:out], \"w+\")\n end\n \n outfile.write \"Id,Story,Labels,Iteration,Iteration Start,Iteration End,Story Type,Estimate,\"\n outfile.write \"Current State,Created at,Accepted at,Deadline,Requested By,Owned By,\"\n outfile.puts \"Description,URL,Note\"\n id = 1\n \n # parse the input file and produce \n ScarabParser.parse(@options[:in]).each do |key, attributes|\n # provide estimates for the statuses that require them\n new_status = STATUS_MAP[attributes[\"Status\"]]\n estimate = case\n when [ 'finished', 'accepted', 'started' ].include?(new_status) then\n case (attributes[\"Estimated effort\"] || 1).to_i\n when 0 then 0\n when 1 then 1\n when 2..6 then 2\n when 7..12 then 3\n when 13..24 then 5\n else 8\n end\n else ''\n end\n \n # build the CSV row for the new input file\n outfile.write(id) # Id\n outfile.write(\",\\\"#{attributes[\"Summary\"]}\\\"\") # Story\n outfile.write(\",\") # Labels\n outfile.write(\",\") # Iteration\n outfile.write(\",\") # Iteration Start\n outfile.write(\",\") # Iteration End\n outfile.write(\",#{@options[:story_type]}\") # Story Type\n outfile.write(\",#{estimate}\") # Estimate\n outfile.write(\",#{new_status}\") # Current State\n outfile.write(\",\") # Created at\n outfile.write(\",\") # Accepted at\n outfile.write(\",\") # Deadline\n outfile.write(\",\") # Requested By\n outfile.write(\",\") # Owned By\n outfile.write(\",\\\"#{attributes[\"Description\"]}\\\"\") # Description\n outfile.write(\",\") # URL\n outfile.write(\",\") # Note\n outfile.write(\"\\n\")\n \n # increment ID for the next pass\n id += 1\n end\n \n # close output file (if one was opened)\n unless @options[:out].nil?\n outfile.close\n end\n end", "def create\n @statistic = Statistic.new(statistic_params)\n\n respond_to do |format|\n if @statistic.save\n format.html { redirect_to @statistic, notice: 'Statistic was successfully created.' }\n format.json { render :show, status: :created, location: @statistic }\n else\n format.html { render :new }\n format.json { render json: @statistic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @statistic = Statistic.new(statistic_params)\n\n respond_to do |format|\n if @statistic.save\n format.html { redirect_to @statistic, notice: 'Statistic was successfully created.' }\n format.json { render :show, status: :created, location: @statistic }\n else\n format.html { render :new }\n format.json { render json: @statistic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @statistic = Statistic.new(statistic_params)\n\n respond_to do |format|\n if @statistic.save\n format.html { redirect_to @statistic, notice: 'Statistic was successfully created.' }\n format.json { render :show, status: :created, location: @statistic }\n else\n format.html { render :new }\n format.json { render json: @statistic.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_scenario2\n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 4}, 'Iris-setosa', {\"kind\" => \"probability\", \"threshold\" => 0.1, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 4}, 'Iris-versicolor', {\"kind\" => \"probability\", \"threshold\" => 0.9, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"sepal length\" => 4.1, \"sepal width\" => 2.4}, 'Iris-setosa', {\"kind\" => \"confidence\", \"threshold\" => 0.1, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"sepal length\" => 4.1, \"sepal width\" => 2.4}, 'Iris-versicolor', {\"kind\" => \"confidence\", \"threshold\" => 0.9, \"positive_class\" => \"Iris-setosa\"}, \"000004\"]\n ]\n puts\n puts \"Scenario : Successfully comparing predictions in operating points for models\"\n\n data.each do |filename, data_input, prediction_result, operating_point, objective|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create model\"\n model=@api.create_model(dataset)\n \n puts \"And I wait until the model is ready\"\n assert_equal(BigML::HTTP_CREATED, model[\"code\"])\n assert_equal(1, model[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(model), true)\n \n puts \"And I create a local model\"\n local_model = BigML::Model.new(model, @api)\n\n puts \"When I create a prediction for %s in %s \" % [JSON.generate(data_input), JSON.generate(operating_point)]\n prediction = @api.create_prediction(model, data_input, {\"operating_point\" => operating_point})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n\n puts \"Then the prediction for '<%s>' is '<%s>'\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end\n\n puts \"And I create a local prediction for <%s> in <%s>\" % [JSON.generate(data_input), JSON.generate(operating_point)]\n local_prediction = local_model.predict(data_input, {\"operating_point\" => operating_point})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n \n if (local_model.regression) or \n (local_model.is_a?(BigML::MultiModel) and local_model.models[0].regression)\n assert_equal(local_prediction.to_f.round(4), prediction_result.to_f.round(4))\n else\n assert_equal(local_prediction, prediction_result)\n end \n \n end\n \n end", "def creation #wizard will be able to create objects, his proficiency is based on the skill level he has in this type of magic\r\n \r\n end", "def print_stat\n puts \"\\n\"\n puts \"********************\"\n puts \"Statistics:\"\n\n puts \"\\n\"\n puts \"Failed: #{$fail_uploaded_count}\"\n $not_uploaded_features_list.each do |feature|\n puts feature\n end\n\n puts \"\\n\"\n puts \"Success: #{$success_uploaded_count}\"\n $uploaded_features_list.each do |feature|\n puts feature\n end\n puts \"********************\"\n\n File.write('result.log', \"#{$updated_count},#{$created_count},#{$deleted_count}\")\nend", "def create_statistics_output(result)\n size_improvement = result['originalSize'] - result['compressedSize']\n size_gzip_improvement = result['originalGzipSize'] - result['compressedGzipSize']\n rate_improvement = (size_improvement * 100)/result['originalSize']\n rate_gzip_improvement = (size_gzip_improvement * 100)/result['originalGzipSize']\n out = \"Original Size: #{result['originalSize']} bytes (#{result['originalGzipSize']} bytes gzipped) \\n\"\n out << \"Compiled Size: #{result['compressedSize']} bytes (#{result['compressedGzipSize']} bytes gzipped) \\n\"\n out << \"\\t Saved #{rate_improvement}% off the original size (#{rate_gzip_improvement}% off the gzipped size)\"\n end", "def report\r\n\r\n STATE_DATA.each do |key, value|\r\n\r\n initialize(key, value[:population_density], value[:population]) \r\n virus_effects\r\n end\r\n \r\n end", "def create_report\n\tcreate_rep_heading\n \tcreate_product_data\n \tcreate_brand_data\nend", "def status\n stat = Hash.new(\"Empty!\")\n stat[:name] = @name\n stat[:level] = @level\n stat[:hp_cur] = @cur_health\n stat[:hp_max] = @max_health\n stat[:str] = @strength\n stat[:exp_cur] = @cur_exp\n stat[:exp_max] = @max_exp\n\n return stat\n\n #\"Name: #{@name}\\n\" +\n #\"Level: #{@level}\\n\" +\n #\"Health: #{@cur_health}/#{@max_health}\\n\" +\n #\"Strength: #{@strength}\"\n end", "def create\n @statistic = Statistic.new(statistic_params)\n @statistic.avg_time_on_site *= 60 # conversion mn en seconde\n respond_to do |format|\n if @statistic.save\n format.html { redirect_to statistics_path, notice: 'Statistic was successfully created.' }\n format.json { render :show, status: :created, location: @statistic }\n else\n format.html { render :new }\n format.json { render json: @statistic.errors, status: :unprocessable_entity }\n end\n end\n end", "def http_statistics\n super\n end", "def run\n\t\t\tsummary\n\t\tend", "def perform\n set_token(@data['token'])\n set_stake_currencies(@data['stake_currencies'])\n set_all_stake_currencies(@data['all_stake_currencies']) if @data['all_stake_currencies'].present?\n set_price_points(@data['price_points'])\n set_manager(@data['manager']) if @data['manager'].present?\n set_client(@data['client']) if @data['client'].present?\n set_client_manager(@data['client_manager'])\n set_contract_details(@data['contract_details'])\n set_gas_price(@data['gas_price'])\n set_auxiliary_addresses(@data['auxiliary_addresses'])\n set_origin_addresses(@data['origin_addresses'])\n set_workflow(@data['workflow'])\n set_workflow_current_step(@data['workflow_current_step'])\n set_sign_messages(@data['sign_messages'])\n set_workflow_payload(@data['workflow_payload'])\n set_sub_env_payload(@data['sub_env_payloads']) if @data['sub_env_payloads'].present?\n set_developer_page_addresses(@data['developer_page_addresses']) if @data['developer_page_addresses'].present?\n set_api_keys(@data['api_keys']) if @data['api_keys'].present?\n set_email_already_sent_flag(@data['email_already_sent_flag']) if @data['email_already_sent_flag'].present?\n set_webhook_enabled_flag(@data['webhook_enabled_flag']) if @data['webhook_enabled_flag'].present?\n set_dashboard_details(@data['dashboard_details']) if @data['dashboard_details'].present?\n set_graph_urls(@data['graph_urls']) if @data['graph_urls'].present?\n set_test_economy_details(@data['test_economy_details']) if @data['test_economy_details'].present?\n set_min_balances(@data['min_balances']) if @data['min_balances'].present?\n set_webhook_secrets(@data['webhook_secrets']) if @data['webhook_secrets'].present?\n end", "def main\n\n\n operations.running.retrieve interactive: false\n save_user operations\n debug_setup(operations) if debug\n \n if KIT_NAME == \"uw kit\"\n if debug\n labels = \"ABCDEF\".split('')\n operations.each.with_index do |op, i|\n op.input(INPUT).item.associate(SAMPLE_KEY, labels[i]) \n op.input(INPUT).item.associate(COMPONENT_KEY, \"\") \n end\n end\n end\n \n save_temporary_input_values(operations, INPUT)\n operations.each do |op|\n op.temporary[:pack_hash] = PACK_HASH\n end\n save_temporary_output_values(operations)\n \n # reassign labels to sample numbers if uw kit\n if KIT_NAME == \"uw kit\"\n operations.each do |op|\n op.temporary[:output_sample] = {\"A\"=>1, \"B\"=>2}[op.temporary[:output_sample]]\n end \n end\n \n run_checks operations\n if KIT_NAME == \"uw kit\"\n uw_kit_introduction operations.running\n else\n kenya_kit_introduction operations.running\n end\n area_preparation \"pre-PCR\", MATERIALS, POST_PCR\n get_pcr_packages operations.running\n open_pcr_packages operations.running\n debug_table operations.running\n check_for_tube_defects sorted_ops.running\n # nuttada thaw\n # nuttada needs vortex + centrigure\n centrifuge_samples sorted_ops.running\n resuspend_pcr_mix sorted_ops.running\n add_template_to_master_mix sorted_ops.running\n cleanup sorted_ops\n start_thermocycler sorted_ops.running\n conclusion sorted_ops\n return {}\n end", "def create_stat_for(start_at, end_at)\n info \"#{start_at}..#{end_at}\"\n se =StatExtractor.new\n (Date.parse(start_at)..Date.parse(end_at)).each do |basedate|\n #puts \"\\n== [create_stat_for] #{basedate.to_s} ==\"\n Rule.stat_rules('day').each{|r|se.extract_stat(basedate.to_s, \"day\", r.rtype , r )}\n Rule.stat_rules('week').each{|r|se.extract_stat(basedate.to_s, \"week\", r.rtype , r )} if basedate.wday == 1\n Rule.stat_rules('month').each{|r|se.extract_stat(basedate.to_s, \"month\", r.rtype , r )} if basedate.day == 1\n end \nend", "def set_stats(hunt_stat, str_stat, sneak_stat, chr_stat)\n $stats[:hunt] = hunt_stat\n $stats[:strength] = str_stat\n $stats[:sneak] = sneak_stat\n $stats[:charisma] = chr_stat\n end", "def create\n if current_user\n if (current_user.username == 'Administrator'&&current_user.id==1)\n @statistic = Statistic.new(params[:statistic])\n\n respond_to do |format|\n if @statistic.save\n format.html { redirect_to @statistic, notice: 'Statistic was successfully created.' }\n format.json { render json: @statistic, status: :created, location: @statistic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @statistic.errors, status: :unprocessable_entity }\n end\n end\n\telse\n \tredirect_to root_url, :notice => 'Uwaga! Nie masz uprawnie&#324;!'\n \tend\n else\n redirect_to :login, :notice => 'Informacja! Zaloguj si&#281; aby obejrze&#263;!'\n end\n end", "def test_scenario4\n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 4}, 'Iris-setosa', {\"kind\" => \"probability\", \"threshold\" => 0.1, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 4}, 'Iris-virginica', {\"kind\" => \"probability\", \"threshold\" => 0.9, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"sepal length\" => 4.1, \"sepal width\"=> 2.4}, 'Iris-setosa', {\"kind\" => \"confidence\", \"threshold\" => 0.1, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"sepal length\" => 4.1, \"sepal width\"=> 2.4}, 'Iris-versicolor', {\"kind\" => \"confidence\", \"threshold\" => 0.9, \"positive_class\" => \"Iris-setosa\"}, \"000004\"]\n ]\n puts\n puts \"Successfully comparing predictions in operating points for ensembles\"\n\n data.each do |filename, data_input, prediction_result, operating_point, objective|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create an ensemble\"\n ensemble = @api.create_ensemble(dataset, {\"number_of_models\"=> 2, \"seed\" => 'BigML', 'ensemble_sample'=>{'rate' => 0.7, 'seed' => 'BigML'}, 'missing_splits' => false})\n \n puts \"And I wait until the ensemble is ready\"\n assert_equal(BigML::HTTP_CREATED, ensemble[\"code\"])\n assert_equal(1, ensemble[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(ensemble), true)\n \n puts \"And I create a local ensemble\"\n local_ensemble = BigML::Ensemble.new(ensemble, @api)\n local_model = BigML::Model.new(local_ensemble.model_ids[0], @api)\n \n puts \" When I create a prediction for <%s>\" % [JSON.generate(data_input)]\n prediction = @api.create_prediction(ensemble['resource'], data_input, {\"operating_point\" => operating_point})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n \n \n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end \n \n puts \"And I create a local prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = local_ensemble.predict(data_input, {\"operating_point\" => operating_point})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n \n if (local_ensemble.regression) or \n (local_ensemble.is_a?(BigML::MultiModel) and local_ensemble.models[0].regression)\n assert_equal(local_prediction.to_f.round(4), prediction_result.to_f.round(4))\n else\n assert_equal(local_prediction, prediction_result)\n end \n \n end\n end", "def create_data\n get_install_id do |install_id|\n get_client_count do |client_count|\n get_server_count do |server_count|\n identity_key = @options.fetch(:identity_key, \"\")\n flavour, version = get_version_info\n timestamp = Time.now.to_i\n data = {\n :tessen_identity_key => identity_key,\n :install => {\n :id => install_id,\n :sensu_flavour => flavour,\n :sensu_version => version\n },\n :metrics => {\n :points => [\n {\n :name => \"client_count\",\n :value => client_count,\n :timestamp => timestamp\n },\n {\n :name => \"server_count\",\n :value => server_count,\n :timestamp => timestamp\n }\n ]\n }\n }\n yield data\n end\n end\n end\n end", "def setup_data_structures\n\t\t\t@summaryMetricHashArr = []\n\t\t\t@metricsDataAggregator = {}\n\t\t\t@summaryMetrics = {}\n\t\t\t@sequenceCounter = 0\n\n\t\t\textractedFrames = @video.video_detections.first.extracted_frames\n\n\t\t\t@timeFactors = States::SummaryResolutions.new.timeFactors\n\t\t\t@minTimeFactor = @timeFactors.min\n\n\t\t\t@timeFactors.each do |t|\n\t\t\t\t@summaryMetrics[t] = SummaryMetric.create(\n\t\t\t\t\tvideo_id: @video.id,\n\t\t\t\t\tdet_group_id: @detGroupId,\n\t\t\t\t\tresolution_seconds: t)\n\n\t\t\t\t@metricsDataAggregator[t] = Metrics::MetricsDataAggregator.new(\n\t\t\t\t\t@configReader, t, @video.detection_frame_rate, @summaryMetrics[t].id, extractedFrames) \n\t\t\t\t@metricsDataAggregator[t].reset()\n\t\t\tend\n\t\tend", "def stat() end", "def test_scenario2\n data = [[File.dirname(__FILE__)+'/data/iris_missing.csv', {\"fields\" => {\"000000\" => {\"optype\" => \"numeric\"}}}, {\"000000\" => 1}]]\n\n puts\n puts \"Scenario: Successfully obtaining parsing error counts\"\n\n data.each do |filename, params, missing_values|\n puts\n puts \"Given I create a data source uploading a %s file\" % filename \n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I update the source with params <%s>\" % JSON.generate(params)\n source = @api.update_source(source, params)\n assert_equal(BigML::HTTP_ACCEPTED, source[\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset with local source\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"I ask for the error counts in the fields\"\n step_results = @api.error_counts(dataset)\n puts \"Then the error counts dict is <%s>\" % missing_values \n\n assert_equal(missing_values, step_results) \n \n end\n\n end", "def list_system_statistics_historic\n @instance = prepare_param_instance\n @stat_class_bit = params[:stat_class][:bit] # Bit-wert fuer Test auf Statistic-Klasse\n @stat_class_bit = nil if @stat_class_bit == \"\"\n\n save_session_time_selection # Werte puffern fuer spaetere Wiederverwendung\n\n list_system_statistics_historic_sum if params[:sum]\n list_system_statistics_historic_full if params[:full]\n end", "def get_stats_file(classification, transformation, preprocess)\n format = \"#{classification}_#{transformation}_#{preprocess}\"\n filename = File.join(@res, 'stats', format + '.json')\n\n filename\n end", "def get_statistics\n @estadisticas = {}\n #Extraer el nombre e id de todas las estadisticas existentes para buscar el total de todas las especies\n Estadistica.all.each do |estadistica|\n # Saltar estadísticas que ya no se usan\n next if Estadistica::ESTADISTICAS_QUE_NO.index(estadistica.id)\n @estadisticas[estadistica.id] = {\n 'nombre_estadistica': estadistica.descripcion_estadistica,\n 'conteo': EspecieEstadistica.all.where(\"estadistica_id = #{estadistica.id} AND conteo > 0\").size\n }\n end\n @totales_estadisticas = build_json_to_statics(@estadisticas)\n @estadisticas\n end", "def initialize(attributes = {})\n attributes.each do |name, local_average|\n send(\"#{name}=\", local_average)\n end\n\tif self.call_average_method.nil?\n\t\tself.call_average_method = (attributes[:hook]+\"_average\").to_sym\n\tend\n\t\n\tif self.call_total_method.nil?\n\t\tself.call_total_method = (attributes[:hook]+\"_total\").to_sym\n\tend\n\tif self.values.nil?\n\t\tself.values = Hash.new([])\n\t\tself.dates = Hash.new([])\n\t\tnames = [:personal_average, :local_average, :global_average, :super_global_average]\n\t\tself.statistics_set_array.each_with_index {|statistic_set, level| \n\t\t\tself.values[names[level]] = statistic_set.map(&((attributes[:hook]+\"_average_c\")).to_sym).collect! {|x| x.to_f.round(1) }\n\t\t\tdates_set = statistic_set.map(&:date_c)\n\t\t\tif !dates_set.empty?\n\t\t\t\tself.dates[names[level]] = dates_set.collect! {|x| x.try(:beginning_of_month).try(:to_date) }\n\t\t\tend\n\t\t}\n\tend\n\t\n\tif self.name.nil?\n\t\tself.name = self.entry_type.human_attribute_name(attributes[:hook]).to_s\n\tend\n\tif alternate_name.nil?\n\t\tself.alternate_name = self.name\n\tend\n\tself.statistics_set_array = nil\n end", "def iiop_statistics\n super\n end", "def get_stats \n #health\n parts_health = self.parts.map{|part| part.health}\n health_total = get_total(parts_health)\n\n #speed\n parts_speed = self.parts.map{|part| part.speed}\n speed_total = get_total(parts_speed)\n\n #attack\n parts_attack = self.parts.map{|part| part.attack}\n attack_total = get_total(parts_attack)\n\n #defense\n parts_defense = self.parts.map{|part| part.defense}\n defense_total = get_total(parts_defense)\n\n #battery_life\n parts_battery_life = self.parts.map{|part| part.battery_life}\n battery_life_total = get_total(parts_battery_life)\n\n grand_total = health_total + speed_total + attack_total + defense_total + battery_life_total\n\n #Normalizing stats\n self.health = health_total / grand_total * 100\n self.speed = speed_total / grand_total * 100\n self.attack = attack_total / grand_total * 100\n self.defense = defense_total / grand_total * 100\n self.battery_life = battery_life_total / grand_total * 100\n self.save\n end", "def profile_example_summaries()\n \"\"\nend", "def stats\n @additions ||= 0\n @deletions ||= 0\n @stats_row_one = {\n active_user_count: @active_user_count,\n pull_count: @pull_count,\n comment_count: @comment_count,\n qa_signoff_count: @qa_signoff_count\n }\n @stats_row_two = {\n avg_additions: @additions.round.to_i,\n avg_deletions: @deletions.round.to_i,\n net_additions: @net_additions\n }\n end", "def addNumberStatsForSingleSettingOfVarianceVariable run_object , values\r\n statsGuy = run_object\r\n # note non use of index to lookup value...\r\n ppAndFile \"-----------\", \"Doing stats on runs runs just numbers #{values.inspect}\"\r\n ppAndFile \"download times %'iles'\", VaryParameter.getDuplesFromClientsAndPercentile(\"createClientDownloadTimes\", statsGuy).join(\" \")\r\n ppAndFile \"download total times %'iles'\", VaryParameter.getDuplesFromClientsAndPercentile(\"createClientTotalDownloadTimes\", statsGuy).join(\" \")\r\n ppAndFile \"death methods\", statsGuy.getDeathMethodsAveraged.sort.join(\" \")\r\n\r\n ppAndFile \"server upload [received] distinct seconds [instantaneous server upload per second] %'iles'\",\r\n VaryParameter.getDuplesFromClientsAndPercentile(\"allServerServedPointsPartial\", statsGuy).join(\" \")\r\n\r\n ppAndFile \" instantaneous tenth of second throughput %'iles'\",\r\n VaryParameter.getDuplesFromClientsAndPercentile(\"totalThroughPutPointsPartial\", statsGuy).join(\" \")\r\n\r\n ppAndFile \"upload bytes %'iles'\", VaryParameter.getDuplesFromClientsAndPercentile(\"createClientTotalUpload\", statsGuy).join(\" \")\r\n ppAndFile \"dht gets\", VaryParameter.getDuplesFromClientsAndPercentile(\"multipleDHTGets\", statsGuy).join(\" \")\r\n ppAndFile \"dht puts\", VaryParameter.getDuplesFromClientsAndPercentile(\"multipleDHTPuts\", statsGuy).join(\" \")\r\n ppAndFile \"dht removes\", VaryParameter.getDuplesFromClientsAndPercentile(\"multipleDHTRemoves\", statsGuy).join(\" \")\r\n ppAndFile \"percentiles of percent received from just peers (not origin)\", VaryParameter.getDuplesFromClientsAndPercentile(\r\n \"createPercentFromClients\", statsGuy).join(\" \") # ltodo graphs for percent dT\r\n\r\n ppAndFile \"client upload sum percentiles:\", VaryParameter.getDuplesFromClientsAndPercentile(\"createClientTotalUpload\", statsGuy).join(\" \")\r\n ppAndFile \" :totalBytesReceivedFromPeersAcrossAllRuns #{statsGuy.totalBytesReceivedFromPeersAcrossAllRuns}, :totalBytesUploadedByServerAcrossAllRuns #{statsGuy.totalBytesUploadedByServerAcrossAllRuns} :totalBytesServedFromPeersAcrossAllRuns #{statsGuy.totalBytesServedFromPeersAcrossAllRuns}\"\r\n @totalBytesReceivedFromPeersAcrossAllRuns.plus_equals(statsGuy.totalBytesReceivedFromPeersAcrossAllRuns)\r\n @totalBytesUploadedByServerAcrossAllRuns.plus_equals(statsGuy.totalBytesUploadedByServerAcrossAllRuns)\r\n @totalBytesServedFromPeersAcrossAllRuns.plus_equals(statsGuy.totalBytesServedFromPeersAcrossAllRuns)\r\n #ltodo note how many opendht's never came back\r\n #ltodo say how many did not make it, too...\r\n print \"wrote stats to #{@outputFile.path}\\n\"\r\n end", "def goaltending_stats(stats)\n\nend", "def user_stats\n generate 'sufia:user_stats'\n end", "def report_st_ops_file_stats(options)\n latest_st_ops_file_path = Subtitle::OperationsFile.find_latest(\n config.base_dir(:subtitle_operations_dir)\n )\n st_ops_json_string = File.read(latest_st_ops_file_path)\n\n operations = Hash.new(0)\n # Match lines like ` \"operation_type\": \"content_change\",`\n st_ops_json_string.scan(/^\\s+\"operation_type\": \"([^\"]+)\"/) { |match|\n # match example: [\"insert\"]\n operations[match.first] += 1\n }\n\n l = ['']\n l << \"st-ops file stats\".color(:blue)\n l << (\"=\" * 24).color(:blue)\n l << \"File: #{ latest_st_ops_file_path }\"\n l << \"Size: #{ (File.size(latest_st_ops_file_path).to_f / 2**20).round } MB\"\n l << ''\n l << \"Operations:\"\n l << \"-\" * 24\n operations.to_a.sort { |(k_a, _v_a),(k_b, _v_b)|\n k_a <=> k_b\n }.each { |k,v|\n number_with_delimiter = v.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n l << \"#{ k.ljust(16) } #{ number_with_delimiter.rjust(7) }\"\n }\n l << \"-\" * 24\n total_ops_count = operations.values.inject(0) { |m,v| m += v; m }\n l << \"Total: #{ total_ops_count.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse.rjust(17) }\"\n l << ''\n\n l.each { |e| $stderr.puts e }\n end", "def get_job_analytics\n file_type = study_file.file_type\n\n trigger = study_file.remote_location.present? ? 'sync' : 'upload'\n\n # retrieve pipeline metadata for VM information\n vm_info = metadata.dig('pipeline', 'resources', 'virtualMachine')\n\n job_perftime = get_total_runtime_ms\n # Event properties to log to Mixpanel.\n # Mixpanel uses camelCase for props; snake_case would degrade Mixpanel UX.\n job_props = {\n perfTime: job_perftime, # Latency in milliseconds\n fileName: study_file.name,\n fileType: file_type,\n fileSize: study_file.upload_file_size,\n action:,\n studyAccession: study.accession,\n trigger:,\n jobStatus: failed? ? 'failed' : 'success',\n machineType: vm_info['machineType'],\n bootDiskSizeGb: vm_info['bootDiskSizeGb'],\n exitStatus: exit_code # integer exit code from PAPI, e.g. `137` for out of memory (OOM)\n }\n\n case action\n when :ingest_expression\n # since genes are not ingested for raw count matrices, report number of cells ingested\n cells = study.expression_matrix_cells(study_file)\n cell_count = cells.present? ? cells.count : 0\n job_props.merge!({ numCells: cell_count, is_raw_counts: study_file.is_raw_counts_file? })\n if !study_file.is_raw_counts_file?\n genes = Gene.where(study_id: study.id, study_file_id: study_file.id).count\n job_props.merge!({:numGenes => genes})\n end\n when :ingest_cell_metadata\n use_metadata_convention = study_file.use_metadata_convention\n job_props.merge!({useMetadataConvention: use_metadata_convention})\n if use_metadata_convention\n project_name = 'alexandria_convention' # hard-coded is fine for now, consider implications if we get more projects\n current_schema_version = get_latest_schema_version(project_name)\n job_props.merge!(\n {\n metadataConvention: project_name,\n schemaVersion: current_schema_version\n }\n )\n end\n when :ingest_cluster, :ingest_subsample\n cluster = ClusterGroup.find_by(study_id: study.id, study_file_id: study_file.id, name: cluster_name_by_file_type)\n job_props.merge!({metadataFilePresent: study.metadata_file.present?})\n # must make sure cluster is present, as parse failures may result in no data having been stored\n if cluster.present?\n cluster_type = cluster.cluster_type\n cluster_points = cluster.points\n can_subsample = cluster.can_subsample?\n job_props.merge!(\n {\n clusterType: cluster_type,\n numClusterPoints: cluster_points,\n canSubsample: can_subsample\n }\n )\n end\n when :differential_expression\n cluster = ClusterGroup.find_by(study_id: study.id, study_file_id: study_file.id)\n annotation_params = {\n cluster: cluster,\n annot_name: params_object.annotation_name,\n annot_type: 'group',\n annot_scope: params_object.annotation_scope\n }\n annotation = AnnotationVizService.get_selected_annotation(study, **annotation_params)\n job_props.merge!(\n {\n numCells: cluster&.points,\n numAnnotationValues: annotation[:values]&.size\n }\n )\n when :image_pipeline\n data_cache_perftime = params_object.data_cache_perftime\n job_props.merge!(\n {\n 'perfTime:dataCache' => data_cache_perftime,\n 'perfTime:full' => data_cache_perftime + job_perftime\n }\n )\n when :ingest_anndata\n # AnnData file analytics TODO\n end\n job_props.with_indifferent_access\n end", "def collect_stats\n # code callously ripped from statistics.rake !\n folders = STATS_FOLDERS.select{|name, dir| File.directory?(dir) }\n cs = CodeStatistics.new(*folders)\n statz = cs.statistics\n tyme = Time.now.to_i\n yaml = { \"build_#{ tyme }\" => statz }.to_yaml\n return yaml.sub(/^---/, '') # abrogate that pesky document marker!\n end", "def reset\n @base_directory = ENV['CC_BUILD_ARTIFACTS'] || 'tmp/metric_fu'\n @scratch_directory = File.join(@base_directory, 'scratch')\n @output_directory = File.join(@base_directory, 'output')\n @data_directory = File.join('tmp/metric_fu', '_data')\n @metric_fu_root_directory = File.join(File.dirname(__FILE__),\n '..', '..')\n @template_directory = File.join(@metric_fu_root_directory,\n 'lib', 'templates')\n @template_class = AwesomeTemplate\n set_metrics\n set_graphs\n set_code_dirs\n @flay = { :dirs_to_flay => @code_dirs,\n :minimum_score => 100,\n :filetypes => ['rb'] }\n @flog = { :dirs_to_flog => @code_dirs }\n @reek = { :dirs_to_reek => @code_dirs,\n :config_file_pattern => nil}\n @roodi = { :dirs_to_roodi => @code_dirs,\n :roodi_config => nil}\n @saikuro = { :output_directory => @scratch_directory + '/saikuro',\n :input_directory => @code_dirs,\n :cyclo => \"\",\n :filter_cyclo => \"0\",\n :warn_cyclo => \"5\",\n :error_cyclo => \"7\",\n :formater => \"text\"}\n @churn = {}\n @stats = {}\n @rcov = { :environment => 'test',\n :test_files => ['test/**/*_test.rb',\n 'spec/**/*_spec.rb'],\n :rcov_opts => [\"--sort coverage\",\n \"--no-html\",\n \"--text-coverage\",\n \"--no-color\",\n \"--profile\",\n \"--rails\",\n \"--exclude /gems/,/Library/,/usr/,spec\"],\n :external => nil\n }\n @rails_best_practices = {}\n @hotspots = {}\n @file_globs_to_ignore = []\n\n @graph_engine = :bluff # can be :bluff or :gchart\n end", "def create_and_send_stats_files\n if params[:type] == \"stata\"\n download_stata_files\n else\n download_spss_files\n end\n end", "def load_statistics\n\t\tnew_stats = self.stat_lines.map {|s_l| {:stat_line_id => s_l.id}} - self.stat_line_entries.map {|s_l_e| {:stat_line_id => s_l_e.stat_line_id}}\n\t\t# vvv\n\t\tnew_entries = self.stat_line_entries.new(new_stats)\n\t\t# new_entries.stat_line_units.new\n\t\tnew_entries.each do |entry|\n\n\t\t\t\n\t\t\tnew_unit = entry.stat_line_entry_units.new\n\t\t\tentry.stat_line_items.each do |item|\n\t\t\t\tnew_unit.stat_line_item_entries.new(:stat_line_item_id => item.id)\n\t\t\tend\n\t\t\t# StatLineEntryInstance.build_instance(entry)\n\t\t\t# entry.stat_line_entry_instances.new\n\t\tend\n\t\t# zzz\n\t\t# stat_hash = self.stat_lines\n\t\t# self.stat_line_entries.new(:stat_line => self.stat_lines.collect)\n\t\t# sss\n\t\tself\n\tend", "def test_scenario9\n \n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 5}, \"000004\", 'Iris-versicolor', {}, \"probability\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2}, \"000004\", 'Iris-setosa', {}, \"probability\" ]\n ]\n puts\n puts \"Scenario: Successfully comparing predictions for logistic regressions with operating kind and supervised model:\"\n\n data.each do |filename, data_input, objective, prediction_result, params, operating_kind|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression with objective\" \n logisticregression=@api.create_logisticregression(dataset)\n\n puts \"And I wait until the logistic regression is ready\"\n assert_equal(BigML::HTTP_CREATED, logisticregression[\"code\"])\n assert_equal(1, logisticregression[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(logisticregression), true)\n \n puts \"And I create a local logistic regression\"\n localSupervisedModel = BigML::SupervisedModel.new(logisticregression)\n\n puts \"When I create a prediction for <%s>\" % [JSON.generate(data_input)]\n prediction = @api.create_prediction(logisticregression['resource'], data_input, {\"operating_kind\" => operating_kind})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n\n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end\n \n puts \"And I create a local prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = localSupervisedModel.predict(data_input, {\"operating_kind\" => operating_kind})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n\n assert_equal(local_prediction, prediction_result)\n \n end\n \n end", "def summary\n # TODO\n end", "def create\n\n #player = Player.all.sample\n #game = Game.all.sample\n #tr = TweetRecord.new\n #tr.user_screen_name=\"rebeccag_dev\"\n #tr.user_twitter_id=1234567890123\n #tr.status_text=\"@c2sb #g#{game.id}p#{player.id}sFGM\"\n #Rails.logger.info \"Sending tweet #{tr.inspect}\"\n #TweetCollector.add_tweet(tr)\n ##StatisticsCollector.add_tweet(68,\"#g17p#{player.id}sFGM\")\n #Rails.logger.info \"Submitted tweet for player #{player.id} - #{player.name}\"\n #Rails.logger.info(\"Tweet log #{StatisticsCollector.get_tweet_log.last.inspect}\")\n #has_error = false\n\n\n @user_reported_statistic = UserReportedStatistic.new()\n stat_params=params[:user_reported_statistic]\n @tweet = params[:tweet]\n user_id = stat_params[:user]\n tr = TweetRecord.new\n tr.status_text=@tweet\n tr.user_id= user_id\n TweetCollector.add_tweet(tr)\n @user_reported_statistic = UserReportedStatistic.new\n\n if tr.has_error?\n @statistic_types = StatisticType.all\n @games = Game.all\n @teams = Team.all\n @players = Player.all\n @users = User.all\n tr.error_msgs.each do | x|\n @user_reported_statistic.errors.add(:tweet,x)\n end\n end\n logger.info(\"logger update_stat\")\n\n respond_to do |format|\n if tr.has_error?\n format.html { render action: \"new\" }\n format.json { render json: @user_reported_statistic.errors, status: :unprocessable_entity }\n else\n format.html { redirect_to user_reported_statistics_url, notice: 'User reported statistic was successfully created.' }\n format.json { render json: @user_reported_statistic, status: :created, location: @user_reported_statistic }\n end\n\n end\n end", "def test_scenario8\n \n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 5}, \"000004\", 'Iris-versicolor', {}, \"probability\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2}, \"000004\", 'Iris-setosa', {}, \"probability\" ]\n ]\n puts\n puts \"Scenario: Successfully comparing predictions for logistic regressions with operating kind\"\n\n data.each do |filename, data_input, objective, prediction_result, params, operating_point|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression with objective\" \n logisticregression=@api.create_logisticregression(dataset)\n\n puts \"And I wait until the logistic regression is ready\"\n assert_equal(BigML::HTTP_CREATED, logisticregression[\"code\"])\n assert_equal(1, logisticregression[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(logisticregression), true)\n \n puts \"And I create a local logistic regression\"\n localLogisticRegression = BigML::Logistic.new(logisticregression)\n\n puts \"When I create a prediction for <%s>\" % [JSON.generate(data_input)]\n prediction = @api.create_prediction(logisticregression['resource'], data_input, {\"operating_kind\" => operating_point})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n\n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end\n \n puts \"And I create a local prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = localLogisticRegression.predict(data_input, {\"operating_kind\" => operating_point})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n\n assert_equal(local_prediction, prediction_result)\n \n end\n \n end", "def initialize(scenario)\n $stdout.sync = true\n @log = Logger.new($stdout)\n @log.level = Logger::INFO\n\n @entities = Hash.new # leave default value of nil for hash key not existing\n @tracker = EntityTracker.new\n @scenario = Scenario.new(scenario)\n end", "def stats_data\n data = super || default_data\n # Generate percentile data\n if global_stat\n data['percentiles'] = %w[media units time].each_with_object({}) do |key, out|\n # Find the first percentile with a value above our own\n percentiles = global_stat.stats_data.dig('percentiles', key)\n next unless percentiles && data[key]\n\n out[key] = percentiles.find_index { |val| val > data[key] }.to_f / 100\n end\n\n data['averageDiffs'] = %w[media units time].each_with_object({}) do |key, out|\n # Find the difference from average\n average = global_stat.stats_data.dig('average', key)\n next unless average && data[key] && average.positive? && data[key].positive?\n\n out[key] = (data[key] - average) / average\n end\n end\n data\n end" ]
[ "0.6137582", "0.5838895", "0.58100486", "0.57925653", "0.5538713", "0.5532725", "0.55223686", "0.55223686", "0.551081", "0.5502233", "0.5495581", "0.5489085", "0.5460216", "0.54348266", "0.54348266", "0.53910595", "0.5382593", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.5376617", "0.53585285", "0.53546935", "0.53546935", "0.53546935", "0.53546935", "0.5341979", "0.53334147", "0.5314543", "0.5307968", "0.5286812", "0.52774596", "0.52750826", "0.52582324", "0.52434796", "0.52389646", "0.5236586", "0.52280325", "0.5223519", "0.5214763", "0.5213277", "0.5203002", "0.52019036", "0.52019036", "0.5190471", "0.5173901", "0.5172972", "0.5171649", "0.5171649", "0.5171649", "0.51702374", "0.514614", "0.51455164", "0.5143718", "0.5140947", "0.51219577", "0.5118835", "0.5117041", "0.5110511", "0.51091594", "0.51060724", "0.5105075", "0.5095004", "0.5093499", "0.5087385", "0.50867903", "0.5084806", "0.5071037", "0.5069949", "0.50651884", "0.50650644", "0.5043", "0.5042871", "0.5042827", "0.50416374", "0.50336355", "0.5031151", "0.5026882", "0.5024069", "0.5011454", "0.50088125", "0.5007686", "0.5005552", "0.49965107", "0.49962518", "0.49957052", "0.49926445", "0.49916676", "0.49912345", "0.4988445", "0.49850398", "0.4973326", "0.49688196" ]
0.0
-1
accept any name except Bob
def check_sign(number) if number == 0 number elsif number > 0 "#{number} is positive" else "#{number} is negative" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allow?(name) \n return return_symbol if name_matchers.reject{|name_matcher| !name.match(name_matcher) } \n end", "def valid_name (name)\r\n /^\\w+$/.match (name)\r\n end", "def name_can_not_be_greg\n if self && self.name.downcase == \"greg\"\n self.errors.add(:name, \"Can not be Greg\")\n end \n end", "def validate_name(name)\n !name.scan(/\\D/).empty?\n end", "def validate_name(arg = nil)\n set_or_return(:name, arg, :kind_of => String, :callbacks => {\n \"user must be string of word characters and Engine ID should be either empty string or 5 to 32 octets separated by colons\" => lambda {\n |name| !@@title_pattern.match(name).nil?\n }\n })\n end", "def name_valid?(name)\n name.nil? || /^[A-Za-z]{2,}$/.match?(name)\n end", "def validate_name(arg=nil)\n set_or_return(:name, arg, kind_of: String, callbacks: {\n 'user must be string of word characters and ' \\\n 'Engine ID should be either empty string or ' \\\n '5 to 32 octets separated by colons' => lambda do |name|\n !@@title_pattern.match(name).nil?\n end,\n })\n end", "def validate_name\n\t\t\tunless Nacreon::NameRX.match(name)\n\t\t\t\terrors.add(:name,\n\t\t\t\t\t'must contain only letters, numbers, and \"-\".')\n\t\t\tend\n\t\tend", "def valid_name!(name)\n not_empty!(name)\n unless [String, Symbol].include?(name.class)\n coercion_error!\n end\n name\n end", "def validate_name\n if name.match(/\\|/)\n errors.add(:name, \"cannot have a '|' character\")\n end\n end", "def your_name_is_not_dumb\n if name.include?(\"dumb\")\n errors.add(:name, \"is dumb\")\n end\n end", "def get_valid_name\r\n while true \r\n name = gets.chomp\r\n break if valid_name(name)\r\n puts \"Please only use letters, numbers or '_' in your name\"\r\n end\r\n name\r\n end", "def correct_name\n name == \"Chris\" || name == \"Blake\"\nend", "def correct_name\n name == \"Chris\" || name == \"Blak\"\nend", "def match_name?(gotten_name, requested_name)\n gotten_name.text.strip.downcase == requested_name.downcase\n end", "def name_valid_format\n if name.present? and not name.match(/[\\w]+([\\s]+[\\w]+){1}+/)\n errors.add :name , \"must be seperated by space and should not contain any special characters.\"\n end\n end", "def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n end\n end", "def is_valid_name?(name)\n return name.class == String && name.match(/[a-zA-Z]+?/)\n end", "def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n else\n return false\n end\n end", "def name_is_valid?(user, name)\n\t\t\tuser.respond_to? \"#{name}s_participating\" and [\"event\",\"class\",\"game\", \"offering_session\", \"personal_trainer\", \"group_training\"].include? name.underscore\n\t\tend", "def name_check(name)\n if name.nil? or name.empty? or name =~ /\\W+/ or name == \"0\"\n\n #raise an error in case of invalid input\n raise ArgumentError.new(\"Error - invalid name\")\n end\n #capitalize the first letter of the name\n name = name.capitalize\n end", "def name_check(name)\n if name.nil? or name.empty? or name =~ /\\W+/ or name == \"0\"\n\n #raise an error in case of invalid input\n raise ArgumentError.new(\"Error - invalid name\")\n end\n #capitalize the first letter of the name\n name = name.capitalize\n end", "def carefull_name?(name)\n not !! (name =~ /\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}/)\nend", "def name_legal?\n if @params\n if self.name.include?(\"\\\\\") or self.name.include?(\"/\")\n errors.add(\"Invalid name:\", \"Slashes not allowed in names.\")\n elsif self.name == \"\"\n errors.add(\"Invalid name:\", \"No name provided.\")\n end\n end\n end", "def _validate_name(name)\n if name =~ %r{/}\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'a slash.')\n end\n\n if name =~ /\\s/\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'whitespace.')\n end\n\n if name[0, 1] == '.'\n results.add_error('name', 'The name of a spec should not begin' \\\n ' with a period.')\n end\n end", "def test_only_name_argument\n \n output = `./cheers Abby`\n expected = <<EOS\n Give me an... A\n Give me a... B\n Give me a... B\n Give me a... Y\n Abby’s just GRAND!\n Try again with `./cheers.rb [Name] [MM/DD Birthday]\nEOS\n assert_equal expected, output\n end", "def getname\n #getting user details \n begin \n print\" \\n Plz Enter your name:\"\n @name=gets.chomp\n if (@name=~ /^[A-Z a-z]+$/ and @name.length<=10) #check regular expression for correct name\n \n break #break loop if user enter corrcect name\n else \n \n puts\"Enter Valid name.......\"\n end \n\n \n end while (@name!=~ /^[-a-z]+$/) #@continue until user not enter correct name\n end", "def name_validator\n puts \"Whats your characters name\"\n name = gets.strip\n until name[/\\d/].nil? do #uses regular expressions to see if the name has anything other then letters\n puts \"Your name must only have letters input again\"\n name = gets.strip\n end\n return name\nend", "def is_valid_name(str)\n\tnames_arr = str.split(\" \")\n if names_arr.length < 2\n return false\n end\n\n \tnames_arr.each do |name|\n if check_case(name)\n return true\n \n else\n return false\n end\n end \nend", "def test_username_with_invalid_examples\n person = @valid_person\n invalid_usernames = %w{rails/rocks web2.0 javscript:something ME}\n invalid_usernames.each do |username|\n person.username = username\n assert !person.valid?, \"#{username} shouldn't pass validation, but does\"\n end\n end", "def valid_name?(name)\n !!(name =~ NAME_REGEX)\n end", "def hand_out_gift(name)\n $names ||= [] # conditional assignment, global variable\n if $names.include?(name.strip)\n \traise ArgumentError.new('Child already got a gift from Santa')\n else \n \t$names << name.strip\n end\n #names.include?(name) ? names << name : raise Argument Error.new(\"#{name} has gotten his gift from Santa\") # => didn't work\nend", "def show_me(name)\n !!name.match(/\\A[A-Z][a-z]+(-[A-Z][a-z]+)*\\z/)\nend", "def name_filter\n self.gsub(/[^a-zA-Z\\s\\-\\(\\)]/, '')\n end", "def username_is_allowed #same as 'validates_exclusion_of' method\n if FORBIDDEN_USERNAMES.include?(username) # checking to see if the username is in FORBIDDEN_USERNAMES\n errors.add(:username, \"has been restricted from use.\") # if the username is in FORBIDDEN_USERNAMES, it will add an error to the errors array\n end\n end", "def ask_name\n begin\n connection.puts \"What's your name? (10 alphanum/spaces only, please.)\"\n # Only grab 10 characters.\n name = connection.gets.chomp[0..10]\n end while !only_chars? name\n name\n end", "def name_is_valid\n errors.add(:name,\"Invalid string for name.\") unless name_is_valid?\n end", "def username_is_acceptable\n errors.add(:username, \"^That username is unacceptable\") unless User.verify_username_is_acceptable(self.username)\n end", "def normalize_input\n self.name = name.downcase\n end", "def parse_name\n\tname = ARGV.shift\n\tunless %w(jo caro wir).include?(name)\n\t\tname = 'jo' \n\t\tputs \"assuming jo...\"\n\tend\n\treturn name\nend", "def is_valid_name(name)\n name_arr = name.split(\" \")\n if (name_arr.length > 1)\n name_arr.each do |word|\n if !(word[0] == word[0].upcase && word[1..-1] == word[1..-1].downcase)\n return false\n end\n end\n else\n return false\n end\n true\nend", "def is_valid_name(str)\n\tnames = str.split(\" \")\n \tif names.length < 2\n return false\n end\n \n \tnames.each do | name |\n if(name[0] != name[0].upcase || name[1..-1] != name[1..-1].downcase)\n return false\n end\n end\n return true\nend", "def validate_username_reserved\n return unless username_reserved?\n\n errors.add(:username, :exclusion)\n end", "def allow_name_change?\n true\n end", "def valid_name?(name)\n name =~ /^[^\\/?*:;{}\\\\]+$/\n end", "def get_name\n ask(\"give me a name to submit to local arena\") { |q|\n q.validate = /\\w+/\n }\nend", "def name?(name)\n name = name&.strip\n !(name.blank? || name.match?(%r{(N[/\\\\]+A|UNKNOWN)}i))\n end", "def validateName(name)\n if (name == nil)\n return false\n end\n \n return true # TODO This is wrong. Finish this function.\nend", "def name_is_valid\n errors.add(:name,'Invalid empty string for name.') unless name_is_valid?\n end", "def request_user_name\n puts \"Please enter your name: \"\n name = gets.chomp\n end", "def process_name\n\t\tlower_case_name = params[:input].downcase\n\t\tif lower_case_name == \"alex\" \n\t\t\t@name = \"Howdy\"\n\t\telsif lower_case_name == \"fitz\"\n\t\t\t@name = \"nice\"\n\t\telse\n\t\t\t@name = \"What are you staring at\"\n\t\tend\n\t\tRails.logger.info \"Lower case name was: \" + lower_case_name\t\t\t\t\n\tend", "def role_name_must_be_whitelisted\n unless role_name.present? &&\n Employable::RoleStories.role_names.include?(role_name.to_sym)\n role_names_to_sentence = Employable::RoleStories.role_names.to_sentence(\n two_words_connector: ' or ',\n last_word_connector: ', or '\n )\n errors.add(:role_name, \"must be one of \\\"#{role_names_to_sentence}\\\"\")\n end\n end", "def name_invalid\n errors.add(:name, :unknown)\n end", "def prompt_name\n puts \"Please input a name:\"\n # split name on spaces\n name_parts = gets.chomp.split\n\n if name_parts.count != 2\n raise \"Uh-oh, finnicky parsing!\"\n end\n\n name_parts\nend", "def pick_username(username)\n name = username\n blacklist = Set.new\n\n while user_exists?(name)\n blacklist << name\n new_name = LoginUserManager.pick_username(name, blacklist)\n\n if blacklist.include?(new_name)\n raise RangeError, \"Misbehaved login policy chose blacklisted name #{new_name}\"\n else\n name = new_name\n end\n end\n\n name\n end", "def is_valid_name(name)\n return false if name.split.length < 2\n name == format_name(name)\nend", "def allowNameService()\n banner(\"Allow Name Service\")\n nameServers = getNameServers()\n @NameServersName = \"NameServers\"\n declareSet(@NameServersName, nameServers)\n permit(@NameServersName, @allAgentsName, \"AllowNameService-I\")\n permit(@allAgentsName, @NameServersName, \"AllowNameService-II\")\n end", "def named_filter; end", "def validate_name?\n # if you create user from admin interface(or as a team member), then \"name\" param is provided, it is present or blank - not nil\n !name.nil?\n end", "def name_is_valid?(user, name)\n\t\tuser.respond_to? \"#{name}s_administrating\" and (this_is_offering?(name) || this_is_multisession?(name))\n\tend", "def new_name(data)\n data.strip!\n if data.nil?\n ask_new_name\n return\n end\n\n data.capitalize!\n if $manager.player_exist? data\n output \"A character with that name already exists, please choose another.\"\n ask_new_name\n return\n elsif data.length > 20 or data.length < 3\n output \"Please choose a name less than 20 letters long but longer than 2 letters.\"\n ask_new_name\n return\n elsif data !~ /^[A-Z][a-z]+$/\n output \"Only letters a to z, please.\"\n ask_new_name\n return\n end\n\n @new_name = data\n ask_sex\n end", "def sanitize_name(str)\n str.gsub(' ','_').downcase.gsub(\"&\", \"and\")\n end", "def match?(name); end", "def safe_name\n name.gsub(/(^[0-9]*|[^0-9a-z])/i, '')\n end", "def isValidUserName?(userName)\n\t\tuserName =~ /^[a-z_][a-z0-9_-]*$/\n\tend", "def set_name\n\t\tresponse = false\n\t\twhile not response\n\t\t\tputs \"What is your name?\"\n\t\t\tresponse = gets.chomp.downcase.capitalize!\n\t\t\t# entry_ok?(response) # Need to implement is_alpha check \n\t\tend\n\t\tresponse\n\tend", "def exclude_name(name)\n @rest_call.append_headers(\"X-Nuage-FilterType\", \"predicate\")\n @rest_call.append_headers(\"X-Nuage-Filter\", \"name ISNOT '#{name}'\")\n end", "def greet1\n print 'Enter your name : '\n name = gets.to_s.chomp\n if name == 'Alice' || name == 'Bob'\n puts 'Hello #{name}'\n else\n puts 'Hello'\n end\nend", "def name=(name)\n raise ArgumentError.new('El nombre deberia conteniar al menos dos palabras') unless name =~ /\\w+\\s+\\w+.*$/\n @name = name\n end", "def name_is_valid?(user, name)\n\t\t\tuser.respond_to? \"#{name}s_membership\" and this_is_act?(name)\n\t\tend", "def validate_name(value)\n return false if(value.to_s.length >= MAX_NAME_LENGTH)\n return true\n end", "def req_name\n\t\tputs \"What is your name?\"\n\t\t@name = gets.chomp\n\tend", "def enter_name(name)\n return @player_name = 'Anonymus' if name.empty?\n\n @player_name = name[0...18]\n end", "def initialize(name)\n if name == \"\"\n @name = \"User\"\n else\n @name = name[0].upcase + name[1..-1].downcase\n end\n end", "def valid_name?(nm)\n\t\treturn false unless (nm =~ VALID_NAME)\n\t\ttrue\n\tend", "def match_author_exact(name, reject = false)\n name = name.downcase || \"\"\n proc = Proc.new { |entry|\n author = entry.author.downcase || \"\"\n author.include?(name)\n }\n reject ? self.entries.reject(&proc) : self.entries.find_all(&proc)\n end", "def valid_user_name(login, name)\n valid = false\n imperfect = false\n email = email(name, login, false)\n if email\n valid, imperfect = true, false\n else\n email = email(name, login, false, true)\n valid, imperfect = true, true if email\n end\n [valid, imperfect]\n end", "def validate_class_name(name)\n only_basic_type(name) || name.gsub(/-/, \"_\").camelcase\n end", "def is_valid_name(str)\r\n\twords = str.split(\" \")\r\n \tif words.length < 2\r\n return false\r\n end\r\n \twords.each do |word|\r\n if !capitalized(word)\r\n return false\r\n end\r\n end\r\n return true\r\nend", "def name_checker(player_name)\n\tputs \"hi #{player_name}\"\nend", "def playerNameValidator\n puts \"\\\"What's your name?\\\"\"\n playerName = gets.chomp.capitalize\n until (playerName.length > 1) && (playerName.is_a?String)\n puts \"\\\"I'm sorry, I didn't hear you well. What's your name?\\\"\"\n playerName = gets.chomp.capitalize\n end \n return playerName\nend", "def username_is_allowed\n\t\tif FORBIDDEN_USERNAMES.include?(username)\n\t\t\terrors.add(:username, \"has been restricted from use.\")\n\t\tend\n\tend", "def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end", "def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end", "def scoped_name_is(name)\n name = SqlHelper::escapeWildcards(name)\n where do\n first_name.op('||', ' ').op('||', last_name).like(name) | \n first_name.op('||', last_name).like(name) \n end\n end", "def is_named? n\n n && n.downcase == @name\n end", "def filter_argument; end", "def greet(name,owner)\n return \"Hello boss\" if name.eql? owner\n return \"Hello guest\" \nend", "def cleanse_name\n return if self.name.nil?\n self.name = self.name.strip\n self.name = nil if self.name.length == 0\n end", "def sanitize_name(name)\n name.gsub!(' ', '_')\n name.downcase!\n name.gsub!('-', '_')\n name.gsub!('\\'', '_')\n name\n end", "def username_is_email\n errors.add(:userName,'is not in email format') unless userName=~ /^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/i\n end", "def valid_name(input)\n while true\n if input =~ /^(\\w){2,}$/\n return input.downcase\n else\n puts \"Try again! Only use letters, numbers, or underscore\"\n input = gets.chomp\n end\n end\nend", "def _sanitize_name(name)\n name.to_s.tr_s('^a-zA-Z0-9', '_')\n end", "def exempt?\n if @a_name.include?(\"book\") || @a_name.include?(\"chocolate\") || @a_name.include?(\"headache\")\n true\n else \n false\n end\n end", "def sanitize_name\n self.name = Tag.sanitize_name(self.name)\n end", "def greet(name)\n puts \"hi #{name}!\"\n if name == \"nico\" || name == \"nicolas\"\n puts \"that's a great name \\n\"\n end\nend", "def are_you_playing_banjo(name)\n name[0] =~ /[Rr]/ ? \"#{name} plays banjo\" : \"#{name} does not play banjo\"\nend", "def test_no_alice\n skip\n names = [\"chuck\", \"charlene\", \"cory\", \"chris\", \"carl\"]\n # write code here\n refute has_alice\n end", "def name=(value)\n if value == \"\"\n raise \"Name cannot be blank!\"\n elsif value.is_a? Integer\n raise \"Name cannot contain numbers!\"\n else\n if value.is_a? String\n @name = value\n end\n end\n end", "def possible_name_params\n params.require(:possible_name).permit(:user_id, :name, :first_lastname, :second_lastname)\n end", "def name_parameterized\n parameterize(@name)\n end" ]
[ "0.6387961", "0.63849723", "0.62850595", "0.6264245", "0.6209132", "0.61507624", "0.6120526", "0.6076266", "0.60428", "0.60258096", "0.59472674", "0.5945586", "0.58928156", "0.5886686", "0.58759624", "0.5872772", "0.58523166", "0.5841868", "0.5835568", "0.5827848", "0.5822463", "0.5822463", "0.58221555", "0.58202225", "0.58176947", "0.57955915", "0.5786562", "0.577556", "0.5742645", "0.57238954", "0.5696826", "0.56918067", "0.56748164", "0.56570894", "0.56509495", "0.56352204", "0.5605149", "0.55938077", "0.5569345", "0.55693316", "0.55675364", "0.55654556", "0.5549048", "0.5547534", "0.55261064", "0.5517476", "0.55135554", "0.5510136", "0.54977256", "0.549518", "0.54793054", "0.54777676", "0.54766446", "0.5472568", "0.5457282", "0.5452785", "0.5451066", "0.54404676", "0.5431359", "0.54089695", "0.53839844", "0.5375447", "0.53749937", "0.53708535", "0.536209", "0.53598213", "0.5348948", "0.5346221", "0.5345539", "0.5343343", "0.533372", "0.5330879", "0.5329161", "0.53244025", "0.5323068", "0.53210974", "0.5320758", "0.5318343", "0.5317588", "0.531698", "0.5299618", "0.52897197", "0.5288011", "0.5288011", "0.52803", "0.5279116", "0.5277391", "0.5274528", "0.52723587", "0.52709013", "0.52688956", "0.5262802", "0.5261918", "0.5259075", "0.52520263", "0.5251801", "0.5250629", "0.52497053", "0.52472943", "0.52420706", "0.5237167" ]
0.0
-1
Ternary operator ? == "then" : == "else"
def check_sign(number) number > 0 ? "#{number} is positive" : "#{number} is negative" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ternary(statement, true_result, false_result)\n statement && true_result || false_result\nend", "def on_ifop(statement, true_val, false_val)\n return Node.new(\n :ternary,\n [statement, true_val, false_val],\n metadata\n )\n end", "def else?\n loc.else\n end", "def else_branch\n node.else\n end", "def else?\n !loc.else.nil?\n end", "def yesno(s)\n puts s ? 'yes' : 'no'\n end", "def else_statement(fn, ce_false, is_nxt)\n if @scanner.peek.value == 'else'\n match(Token.new(:identifier, 'else'))\n fn.code << \"#{ce_false}:;\\n\"\n block_statements(fn)\n fn.code << \"#{is_nxt}:;\\n\"\n\n else\n fn.code << \"#{is_nxt}:;\\n\"\n fn.code << \"#{ce_false}:;\\n\"\n end\n end", "def yes_or_no(value = false)\n value ? \"Yes\" : \"No\"\n end", "def render_output_of_ternary(ternary_arr, df_data)\n value_for_field_name(ternary_arr[0], df_data).present? ? ternary_arr[1] : ternary_arr[2]\n end", "def check_else(els)\n # put through translator with original target to mimic as if\n # else were change;\n # literal=true to make sure always x>y syntax\n return initial(@rule[0], els, true).sub(/\\A(.*)>/, '').strip\n end", "def ternary_condition(value)\n\t\tis_strike?(value) ? 10 : value\n\tend", "def eval_if_then_else(node, env, stack_trace)\n\n\tcondition = eval_node_under(node.condition, env, stack_trace)\n\tcase condition\n\tin Boolean\n\t\tif condition.value \n\t\t\treturn eval_node_under(node.true_exp, env, stack_trace), env\n\t\telse\n\t\t\tif condition.false_exp # is not empty\n\t\t\t\treturn eval_node_under(node.false_exp, env, stack_trace), env\n\t\t\telse # Don't do anything (return UnitNode)\n\t\t\t\treturn UnitNode(node.line, node.col), env\n\t\t\tend\n\t\tend\n\telse\n\t\tthrow_error(\"If statement's condition does not evaluate to a Boolean.\", node, stack_trace)\n\tend\nend", "def test_if_statement_modifiers\n result = :default_value\n result = :true_value if true\n\n assert_equal :true_value, result\n end", "def yeah_or_booh boolean\n boolean && 'yeah' || 'booh'\nend", "def else_clause\n expect :if\n self[3]\n end", "def hello_world(lang)\n lang == \"es\" ? result = \"Hola Mundo\" : lang == \"de\" ? result = \"Hallo Welt\" : result = \"Hello World\"\n p result\nend", "def else_statement\n if @enum.peek.value == 'else'\n @instruction.push('state_'+(@if_count+1).to_s+\":\\n\")\n match(Token.new(:reserved, 'else'))\n block_statements\n end\n end", "def is_old? #any tiem you see a method with a ? after it only returns a true or false value\n @age > 80 ? true : false #ternary value\n # the method below\n # if @age > 80\n # true\n # else\n # false\n end", "def alternate_operator\n logical_operator? ? SEMANTIC_AND : LOGICAL_AND\n end", "def is_it_a_baby(age)\n age < 2 ? \"baby\" : \"not a baby\"\nend", "def emit_true_if_branch\n emit_self(new(Rubinius::AST::TrueLiteral), if_branch, else_branch)\n end", "def else!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 44 )\n\n\n\n type = ELSE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 222:7: 'else'\n match( \"else\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 44 )\n\n\n end", "def k_else!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 40 )\n\n\n\n type = K_ELSE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 413:4: 'else'\n match( \"else\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 40 )\n\n\n end", "def on_ternary_if_boolean(node)\n comparsion, condition, if_true, if_false = node.children\n if comparsion\n node.update(:ternary, [ condition, if_true, if_false ])\n else\n node.update(:ternary, [ condition, if_false, if_true ])\n end\n end", "def conditional\n expr = logical_or\n\n if match?(:question)\n then_branch = expression\n consume(:colon, \"Expect ':' after then branch of conditional expression.\")\n else_branch = conditional\n expr = Ringo::Conditional.new(expr, then_branch, else_branch)\n end\n\n expr\n end", "def vowels_with_ternary_operator(letter)\n (vowels.include? letter) ? true : false # this only seems to work when I put the conditional in parenthesis\nend", "def foo a\r\n if a==1; \"one\" elsif a==2; \"two\" else \"unknown\" end\r\nend", "def else!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 66 )\n\n type = ELSE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 187:8: 'else'\n match( \"else\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 66 )\n\n end", "def yeah_or_boo( a,b )\n (a > b) && 'yeah' || 'boo'\nend", "def see_color_with_nested_ternary(str)\n # rubocop:disable Style/NestedTernaryOperator\n str.start_with?('red') ? 'red' : str.start_with?('blue') ? 'blue' : ''\n # rubocop:enable Style/NestedTernaryOperator\n end", "def else_branch\n node_parts[-1]\n end", "def else_branch\n node_parts[-1]\n end", "def excl\n \"else \"\n end", "def else!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n\n type = ELSE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 322:8: 'else'\n match( \"else\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 20 )\n\n end", "def yes_or_no(boolean)\n\t if boolean\n\t 'Yes'\n else\n 'No'\n end\n end", "def default_if_not_specified(opt,default_opt)\n opt ? opt : default_opt\nend", "def else_branch?\n !node.else.kind_of?(Rubinius::AST::NilLiteral)\n end", "def parse_else_if_header\n expect(:KW_ELSE_IF)\n expect(:L_PARANTH)\n cond = parse_expression\n expect(:R_PARANTH)\n\n cond\n end", "def my_if(condition, then_clause, else_clause)\n if condition\n then_clause.call\n else\n else_clause.call\n end\nend", "def even_odd(number)\n number.even? ? \"#{number} is even!\" : \"Noo! #{number} is odd!!!\"\n #last line, one statement, this will be auto returned from defined method\nend", "def test_or_live\n test? ? 'test' : 'live'\n end", "def conditionally(*) end", "def conditionally(*) end", "def check_truth?(statement)\n if statement == nil\n \"Neither exactly true nor false\"\n elsif statement == true\n \"It's true!\"\n else\n \"I admit, tis' false.\"\n end\nend", "def check_truth?(statement)\n if statement == nil\n \"Neither exactly true nor false\"\n elsif statement == true\n \"It's true!\"\n else\n \"I admit, tis' false.\"\n end\nend", "def check_truth?(statement)\n if statement == nil\n \"Neither exactly true nor false\"\n elsif statement == true\n \"It's true!\"\n else\n \"I admit, tis' false.\"\n end\nend", "def some_method(x)\n if x > 5 && x < 10\n return :a\n elsif x < 5\n return :b\n end # else??\n \n :c\nend", "def if_statement\n consume(:lparen, \"Expect '(' after 'if'.\")\n condition = expression\n consume(:rparen, \"Expect ')' after if condition.\")\n\n then_branch = statement\n else_branch = match?(:else) ? statement : nil\n\n return Ringo::If.new(condition, then_branch, else_branch)\n end", "def as_yes_or_no(boolean)\n boolean ? 'Yes' : 'No'\n end", "def on_ternary_if(node)\n comparsion, op = node.children\n node.children.concat op.children.slice!(2..-1)\n\n on_ternary_if_boolean(node)\n end", "def to_s\n \"if \" + @condition.to_s + \" then\\n\" + indent(@then_part.to_s) + (else_part.skip? ? \"\" : (\"\\nelse\\n\" + indent(@else_part.to_s))) + \"\\nend\"\n end", "def bar(param = \"no\")\n p param == \"no\" ? \"yes\" : \"no\"\nend", "def saludar(saludo = 'Hola a todos')\n puts saludo == 'Hola' ? 'Hola Mundo' : saludo\nend", "def human_boolean(boolean_statement)\n\t\tboolean_statement ? \"Yes\" : \"No\"\n\tend", "def else(&fn)\n raise Qo::Exceptions::MultipleElseClauses if @else\n\n @else = fn || Qo::IDENTITY\n end", "def make_if test, zero, not_zero\n noop = \":\"\n \"if [ \\\"0\\\" -eq \\\"$#{test}\\\" ]; then #{zero || noop}; else #{not_zero || noop} ; fi\"\n end", "def func1 val # Val should be inside round brackets ().\r\n if val = 1 # Requires == to check status\r\n return true # Indent both returns as they relate to the if and else.\r\n else\r\n return false\r\n end\r\nend", "def and_then &block\n if @value == nil\n Default.new @fallback, nil\n else\n Default.new @fallback, block.call(@value)\n end\n end", "def complex_condition?(condition); end", "def func1 val\n if val = 1 # should be conditional assignment ==\n return true\n else\n return false\n end\nend", "def tbool(b)\n t(b ? \"common._yes\" : \"common._no\")\n end", "def switch(it)\n it == true ? false : true\nend", "def active_if_equal(arg1, arg2)\n \"active\" if arg1 == arg2\n end", "def not_if(val) val ? :not_to : :to end", "def default_true\n return (@acts[1].nil? ? true : @acts[1])\n end", "def elseif!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n\n type = ELSEIF\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 324:10: 'elseif'\n match( \"elseif\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 22 )\n\n end", "def if_condition; end", "def query_gender_neutral\n print 'Would you prefer a gender neutral experience? y/n '\n query_yesno == 'y' ? (return true) : (return false)\nend", "def drink_milk(thirsty = true)\n return \"I am not thirsty\" if thirsty == false\nend", "def fb_else(&proc)\n content = capture(&proc) \n concat(content_tag(\"fb:else\",content),proc.binding)\n end", "def process_else(exp)\n add_to_score :branch\n penalize_by 0.1 do\n process_until_empty exp\n end\n s()\n end", "def tokenize_else(_chunk)\n raise Errors::UnexpectedElse unless @current_scope.inside_if_block?\n token = Token.new Token::ELSE\n @stack << token\n close_if_statement\n token\n end", "def do_conditional\n cond = inequality\n\n loop do\n type = @lexer.peek_next_type\n\n break unless [:AND, :OR].include? type\n @lexer.skip\n\n # The rhs has to be evaluated here because of short-circuiting\n\n rhs = inequality\n\n cond &&= rhs if type == :AND\n cond ||= rhs if type == :OR\n end\n\n return unless cond\n\n expect [:THEN]\n line_do\n end", "def get_or_else(val_or_lam = nil, &blk)\n v_or_f = val_or_lam || blk\n if !empty? then value else (v_or_f.respond_to?(:call) ? v_or_f.call : v_or_f) end\n end", "def parser_else(args)\r\n if @if_stack.empty?\r\n #_rl_init_file_error (\"$else found without matching $if\")\r\n return 0\r\n end\r\n\r\n # Check the previous (n) levels of the stack to make sure that\r\n # we haven't previously turned off parsing.\r\n return 0 if @if_stack.detect {|x| x }\r\n\r\n # Invert the state of parsing if at top level.\r\n @_rl_parsing_conditionalized_out = !@_rl_parsing_conditionalized_out\r\n return 0\r\n end", "def literal_true\n 'true'\n end", "def yes_no(bool)\n case bool\n when 1\n \"yes\"\n when 0\n \"no\"\n end\n end", "def cond(pred, true_fn, false_fn, name: nil)\n _op(:case, [pred], false_fn, true_fn, name: name)\n end", "def or_else(&blk)\n yield value\n end", "def boolean_to_human(test)\n test ? \"Yes\" : \"No\"\n end", "def time_of_day?(sky)\n puts \"It's #{sky ? 'daytime' : 'nighttime'}!\" # my original below:\nend", "def likeBananas?\n\t\treturn @likeBananas ? \"eek eek!\" : \"uh uh!\"\n\tend", "def truthy?(val)\n v = val&.downcase\n v == \"t\" || v == \"y\" || v == \"1\"\nend", "def conditionally_true\n\t\t!!self\n\tend", "def tst_result\n passed? ? \"p\" : \"f\"\n end", "def get_or_else(val_or_lam = nil, &blk)\n v_or_f = val_or_lam || blk\n if either_value.left? then either_value.left_value else (v_or_f.respond_to?(:call) ? v_or_f.call : v_or_f) end\n end", "def non_complex_expression?(condition); end", "def if(condition, true_value, false_value)\n {\"Fn::If\" => [condition, true_value, false_value]}\n end", "def conditional\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 48 )\n return_value = ConditionalReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n char_literal226 = nil\n char_literal227 = nil\n t = nil\n f = nil\n logical_or225 = nil\n\n tree_for_char_literal226 = nil\n tree_for_char_literal227 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 577:5: logical_or ( '?' t= expression ':' f= expression )?\n @state.following.push( TOKENS_FOLLOWING_logical_or_IN_conditional_3808 )\n logical_or225 = logical_or\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, logical_or225.tree )\n end\n # at line 577:16: ( '?' t= expression ':' f= expression )?\n alt_51 = 2\n look_51_0 = @input.peek( 1 )\n\n if ( look_51_0 == QMARK )\n alt_51 = 1\n end\n case alt_51\n when 1\n # at line 577:19: '?' t= expression ':' f= expression\n char_literal226 = match( QMARK, TOKENS_FOLLOWING_QMARK_IN_conditional_3813 )\n if @state.backtracking == 0\n\n tree_for_char_literal226 = @adaptor.create_with_payload( char_literal226 )\n root_0 = @adaptor.become_root( tree_for_char_literal226, root_0 )\n\n end\n @state.following.push( TOKENS_FOLLOWING_expression_IN_conditional_3819 )\n t = expression\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, t.tree )\n end\n char_literal227 = match( COLON, TOKENS_FOLLOWING_COLON_IN_conditional_3822 )\n @state.following.push( TOKENS_FOLLOWING_expression_IN_conditional_3828 )\n f = expression\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, f.tree )\n end\n\n end\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 48 )\n\n end\n \n return return_value\n end", "def else!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 6 )\n\n\n\n type = ELSE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 27:7: 'sino'\n match( \"sino\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 6 )\n\n\n end", "def yesno(bool)\n return 'N/A' if bool.nil?\n bool ? 'YES' : 'NO'\n end", "def even_or_odd(number)\n number.even? ? 'That number is even ' : 'That number is odd'\nend", "def format_yn( expr )\n return (expr) ? 'Yes' : 'No'\n end", "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", "def word(strings)\n if strings[0..-1].capitalize! # strings[0].capitalize! ; strings[1..-1]\n # only if cap first letter # strings[0..-1]\n\n puts \"no #{strings} does not have capitalized first letter :-( )\"\n # ternary -- KOOL!!!!!\n puts strings[0..-1] == capitalize(strings) ? \"only first \" : \"not first\"\nelse\n puts \"yes #{strings} has capitalized first letter :-) \"\n\nend\nend", "def before_tarantula(string)\n tarantula = 'tarantula'\n return value = tarantula <=> string\n \n if value == 0 \n return false\n elsif value == 1\n return true\n else \n return false \n end\n\nend", "def true_false(data)\n if data\n \"Evaluates: TRUE\"\n else\n \"Evaluates: FALSE\"\n end\nend", "def wordify_boolean(bool)\n# bool ? t(:\"shared.boolean.yes\") : t(:\"shared.boolean.no\")\n bool ? \"Ja\" : \"Nein\"\n end", "def if_statement(fn)\n match(Token.new(:reserved, 'if'))\n match(Token.new(:symbol, '('))\n tf = condition_expression(fn)\n match(Token.new(:symbol, ')'))\n is_nxt = fn.new_label\n is_else = tf[1]\n fn.code << \"#{tf[0]}:;\\n\"\n #fn.code << block_statements(fn)\n block_statements(fn)\n fn.code << \"goto #{is_nxt};\\n\"\n else_statement(fn, tf[1], is_nxt)\n\n end", "def if_statement(var_env)\n return nil unless eql_lit?(ECMA262::ID_IF)\n unless(eql_lit?(ECMA262::PUNC_LPARENTHESIS) and cond=exp(var_env, {}) and\n eql_lit?(ECMA262::PUNC_RPARENTHESIS) and s = statement(var_env))\n raise ParseError.new(\"unexpected token\", self)\n end\n if(eql_lit?(ECMA262::ID_ELSE) and e = statement(var_env))\n ECMA262::StIf.new(cond, s, e)\n else\n ECMA262::StIf.new(cond, s, nil)\n end\n end", "def else_block\n self << \"else {\"\n yield if block_given?\n self << \"}\"\n nil\n end" ]
[ "0.7405856", "0.68724704", "0.67900676", "0.6786287", "0.65658075", "0.6467765", "0.64098865", "0.6359833", "0.6308969", "0.6269744", "0.62695235", "0.6257247", "0.62191004", "0.6208144", "0.6196348", "0.61727494", "0.6171337", "0.613032", "0.6084351", "0.6083681", "0.6041825", "0.5978448", "0.595243", "0.5929404", "0.5927491", "0.59273976", "0.59243286", "0.5919524", "0.59162235", "0.59117866", "0.5907893", "0.5907893", "0.5888054", "0.58848166", "0.58840233", "0.5876652", "0.5873521", "0.5872158", "0.58128756", "0.57586414", "0.5757777", "0.57275116", "0.57275116", "0.5725556", "0.5725556", "0.5725556", "0.57238454", "0.5723252", "0.5699985", "0.5695428", "0.5695184", "0.5695025", "0.56900996", "0.5670703", "0.5663616", "0.56434757", "0.5640189", "0.56322265", "0.5614791", "0.5605836", "0.55852014", "0.5578898", "0.55684936", "0.5563597", "0.5557383", "0.554699", "0.553579", "0.55343455", "0.5533821", "0.55283326", "0.5522354", "0.5514901", "0.5512853", "0.550627", "0.5501574", "0.54937315", "0.54895914", "0.54893667", "0.5477752", "0.54710215", "0.54604876", "0.5460246", "0.5454933", "0.5426465", "0.5422069", "0.54220575", "0.5417761", "0.5414344", "0.5412739", "0.5395868", "0.5391559", "0.5389429", "0.53783613", "0.5378187", "0.5378186", "0.53738034", "0.5372206", "0.53712887", "0.5370065", "0.5363878", "0.53592056" ]
0.0
-1
START Feed Action Tests
def test_get_feed get :feed assert_response :success end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_mp3_feed_works\n get \"/podcast_feed/all/mp3/rss.xml\"\n assert last_response.ok?\n end", "def fetch_test_feed\n logger.info 'FeedManager: env is test, fetching test data'\n data = Feedzirra::Feed.parse File.open(Rails.root.join('test', 'test_feeds', 'valid_feed.xml'), 'r').read\n return Feed.new :title => data.title,\n :items => data.entries,\n :url => data.url,\n :feed_url => data.feed_url,\n :valid => true\n\n end", "def run_actions; end", "def feed\n end", "def test02_post_open_news_251RepostArticle\n\t\trepostArticlePop\n\t\tsleep 3\n\t\trepostPopulate251\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend", "def start\n test_btc\n test_email\n end", "def test_ID_25890_published_posts_01\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n publish_post_if_not_found(\"Sports\",\"Basketball\")\n end", "def feed\n\n end", "def test04_post_open_news_250RepostArticle\n\t\trepostArticlePop\n\t\tsleep 3\n\t\trepostPopulate250\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend", "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 test1Action\n executeTest(\n 'DummyUser',\n {\n 'DummyTool' => {\n 'DummyAction' => [\n []\n ]\n }\n }\n )\n end", "def action_run\n end", "def atest_ID_25891_scheduled_posts_02\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n sleep 5\n go_to_scheduled_tab_on_your_post_page\n verify_text \"Your Posts\",\"Current Drafts\", \"Scheduled Posts\", \"Published Posts\", \"Scheduled\"\n assert $profile_edit_post.exists?\n assert $profile_delete.exists?\n assert $count_of_scheduled.exists?\n end", "def test_00120_profilepage_check_new_activity_feed\n @topicdetail_page = @topiclist_page.go_to_topic(\"A Watir Topic\")\n title = \"Test q created by Watir - #{get_timestamp}\"\n @topicdetail_page.create_conversation(type: :question,\n title: title,\n details: [{type: :text, content: \"Watir test description\"}])\n\n @profile_page.goto_profile\n @browser.wait_until { !@profile_page.question_list_in_activity_pane.activity_at_title(title).nil? }\n activity_card = @profile_page.question_list_in_activity_pane.activity_at_title(title)\n activity_card.click_conv_link\n @browser.wait_until { @convdetail_page.convdetail.present? }\n assert @convdetail_page.root_post_title.text =~ /#{title}/ \n end", "def test_00130_profilepage_check_activity_feed_link\n @profile_page.goto_profile\n @browser.wait_until { @profile_page.profile_activity_item.present? }\n\n @browser.wait_until { @profile_page.question_list_in_activity_pane.activity_list.size > 0 }\n activity_card = @profile_page.question_list_in_activity_pane.activity_list[0]\n conv = activity_card.conv_title\n activity_card.click_conv_link\n\n @browser.wait_until { @convdetail_page.convdetail.present? }\n assert @convdetail_page.convdetail.text.include? conv\n end", "def create_feed\n end", "def create_feed\n end", "def create_feed\n end", "def create_feed\n end", "def subscribe_feed(url)\n open_feeds_menu\n find('#add-subscription').click\n expect(page).to have_css '#subscribe-feed-popup'\n within '#subscribe-feed-popup' do\n fill_in 'Feed', with: url\n find('#subscribe-submit').click\n end\n\n # Ensure entries have finished loading\n expect(page).to have_no_css 'div#loading'\nend", "def test03_post_open_news_250RepostNote\n\t\trepostNotePop\n\t\tsleep 3\n \t\trepostPopulate250\n \t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend", "def feed( category, message, feedOptions = nil )\n feedTask = FeedTask.new( @web, self, category, message, feedOptions )\n feedTask.perform()\n end", "def test02_flag_repost_article_TC_24323\n\t\trepostArticlePop\n\t\tsleep 2\n\t\trepost\n\t\tcommentFlag\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Comment\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"R8_T2: FAILED! User unable to flag post.\"\n\t\tend\n\tend", "def test03_post_open_news_251RepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepostPopulate251\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend", "def helper_start_test(message, encoded_message = nil)\n post '/start', { message: message }, session\n\n assert_equal 302, last_response.status\n assert_flash 'Time started.'\n assert_time_start(encoded_message || message)\n\n # follow redirect back to actions page\n get last_response['Location']\n\n assert_all_actions\n assert_displayed_flash 'Time started.'\n end", "def test05_post_open_news_250RepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepostPopulate250\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend", "def run test_identifier=nil\n @dispatcher.run!\n # start\n message(\"start\")\n suite_setup,suite_teardown,setup,teardown,tests=*parse(test_identifier)\n if tests.empty? \n @dispatcher.exit\n raise RutemaError,\"No tests to run!\"\n else\n # running - at this point all checks are done and the tests are active\n message(\"running\")\n run_scenarios(tests,suite_setup,suite_teardown,setup,teardown)\n end\n message(\"end\")\n @dispatcher.exit\n @dispatcher.report(tests)\n end", "def begin_lights_test\n puts 'Invoker: start test'\n @on_start.execute if @on_start.is_a? Command\n\n puts 'Invoker: ...loading last tests...'\n\n puts 'Invoker: starting last tests'\n @on_finish.execute if @on_finish.is_a? Command\n end", "def run_app_tests\n end", "def run_test\n # Add your code here...\n end", "def run_test\n # Add your code here...\n end", "def start\n @actions << :start\n end", "def test2Actions\n executeTest(\n 'DummyUser',\n {\n 'DummyTool' => {\n 'DummyActionWithParams' => [\n [ 'Param1', 'Param2' ]\n ],\n 'DummyAction' => [\n []\n ]\n }\n }\n )\n end", "def test_ID_25889_current_drafts_04\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n verify_post_and_draft_count_updated_after_draft_posted\n end", "def feed\n\t\tputs \"You feed #{@name}\"\n\t\t@stuff_in_belly = 10\n\t\tpassage_of_time\n\tend", "def init_atom_feed\n @atom_feed = \"#{params[:controller]}/feed\"\n end", "def test_count_articles_for_user_with_feed\n feed = UserFeed.find(6) #NErr the Blog\n count = VwArticlesForUser.count_articles_for_user(feed, :feed, 3)\n assert count == 2\n end", "def start\n return self.class.get(\"/action/start\") == \"Downloads started\"\n end", "def test_playlist\n end", "def action_start\n proxy_action(:start)\n end", "def start_test(test_status)\n # Abstract\n end", "def run\n test_using_random_sample\n test_using_first_of\n end", "def atest_ID_25891_scheduled_posts_01\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n sleep 5\n scheduledPostCount = count_scheduled_current\n if (scheduledPostCount < 5)\n i=1\n while i < 3\n $browser.goto($patch_note)\n $post_pick_group.when_present().click\n $group_select.when_present().select(\"Sports\")\n $post_compose_note.wait_until_present()\n $browser.link(:text, \"Basketball\").when_present().click\n $post_compose_note.when_present().set(\"Note field populated by automated test.\")\n $advanced_options.when_present().click\n currentTime = Time.now() + 2\n currentDate = currentTime.strftime(\"%Y-%m-%d\")\n $post_advanced_calendar.when_present().set(\"#{currentDate}\")\n $post_advanced_time.when_present().set(\"11:00 PM\")\n sleep 3\n $browser.link(:text => /11:00/).click\n $profile_schedule.when_present().fire_event(\"onclick\")\n sleep 3\n i = i+1\n end\n end\n end", "def start_run; end", "def test!\n @@api.post(endpoint: self.endpoint + ['test'])\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n end", "def pre_run\n puts \"You must define a `pre_run` method in your child class where you define `@list_url` to the RSS XML url\"\n end", "def testloop\n \n end", "def launch!\n\t\tintroduction\n\t\t\taction = nil\n\t\t\tuntil action == :quit\n\t\t\t# action loop\n\t\t\t# what do you want to do? (list, find, add, quit)\n\t\t\tprint \"> \"\n\t\t\tuser_response = gets.downcase.strip!.split(' ')\n\t\t\t# do that action\n\t\t\taction,args = do_action(user_response[0],user_response[1])\n\t\tend\n\t\tconclusion\n\tend", "def test_index\n get :index\n \n assert_redirected_to :action => :unread\n end", "def atest_ID_25891_scheduled_posts_03\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n sleep 5\n go_to_scheduled_tab_on_your_post_page\n scheduledPostCountCurrent = count_scheduled_current\n $profile_delete_on_scheduled_post.when_present().click\n $delete_on_delete_this_draft.when_present().click\n $browser.refresh\n $count_of_scheduled.wait_until_present()\n scheduledPostCountAfterDeletingScheduledPost = count_scheduled_current\n assert scheduledPostCountAfterDeletingScheduledPost == scheduledPostCountCurrent - 1\n end", "def feed_action\n url = url_for :action => \"success_text\", :only_path => false\n \n data = {:template_id => ZackPublisher.find_bundle_id('story_action'), \n :template_data => {:role => \"use the force\", :comment => params[:comment], \n :video => {:video_src =>\"http://www.youtube.com/v/OssgMY_mkMc&hl=en&fs=1\", :preview_img => \"http://zacknmiri.com/images/f1.znm.png\"}\n }\n }\n \n feedStory = { :method => 'feedStory',\n :content => { :feed => data,\n :next => url }}\n render :text => feedStory.to_json\n end", "def read_feed(feed, user)\n folder = feed.user_folder user\n if folder.present?\n open_folder folder\n sleep 0.5\n end\n\n folder_id = folder&.id || 'none'\n within \"#folders-list #folder-#{folder_id}\" do\n expect(page).to have_css \"[data-sidebar-feed][data-feed-id='#{feed.id}']\", visible: true\n\n # Click on feed to read its entries\n find(\"[data-sidebar-feed][data-feed-id='#{feed.id}']\", visible: true).click\n end\n\n # Ensure entries have finished loading\n expect(page).to have_no_css 'div#loading'\nend", "def runner\n \nend", "def test_ID_25890_published_posts_02\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n $profile_published.when_present().click\n sleep 5\n verify_text \"Your Posts\",\"Drafts\", \"Scheduled\", \"Published\"\n assert $profile_published.exists?\n assert $count_of_published.exists?\n end", "def test02_post_open_news_EmptyGDM\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_now.exists?\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend", "def start_test_run(test_run)\n puts \"RunId: #{test_run.runId}\\nProject: #{test_run.projectName}\\nTest Count: #{test_run.testCount}\\nQueue Size: #{test_run.queueSize}\\nRunOptions: #{test_run.runOptions}\\nStatus: #{test_run.status}\\n\"\n end", "def run_one_test(session)\n \n end", "def setup\n puts \"Starting test\"\n TRConnector.instance.start\n sleep(1)\n end", "def testing\n # ...\n end", "def runner; end", "def test04_250RepostArticle\n\t\trepostArticlePop\n\t\tsleep 3\n\t\trepostPopulate250\n\t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS4T04: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend", "def test_stories_find_upcoming\n assert_not_nil @rdigg.stories.find_upcoming(:count => 3)\n end", "def runner\n\nend", "def launch!\n introduction\n # action loop\n result = nil\n until result == :quit do\n action, args = get_action\n result = do_action(action, args)\n end\n conclusion\n end", "def run!\n make_new_account\n\n length.times do\n universe = ACTIVITIES\n activity = universe.sample\n unless respond_to?(activity, true)\n LLL.error \"activity #{activity} not implemented\"\n next\n end\n\n LLL.info \"trying #{activity}\"\n before_time = Time.now.to_f\n Timeout.timeout(@timeout) do\n send activity\n end\n after_time = Time.now.to_f\n\n @report[activity].add(after_time - before_time)\n end\n end", "def test_ID_25889_current_drafts_05\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n verify_draft_count_updated_after_deleting_draft\n end", "def setup_end_action\n @break_action = true\n @finish = true\n end", "def test02_post_closed_news_GroupRepostArticle\n\t\trepostArticlePop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd \"Repost text #{random}.\"\n \t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend", "def test03_flag_repost_event_TC_24323\n\t\trepostEventPop\n\t\tsleep 2\n\t\trepost\n\t\tcommentFlag\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Comment\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"R8_T3: FAILED! User unable to flag post.\"\n\t\tend\n\tend", "def graffiti_test\n end", "def test_single_item_result\n while_logged_in do\n with_queries do\n pass\n #assert_nothing_raised{ @conn.tasks(query:@single_page_query) }\n end\n end\n end", "def testRunAction\n executeSlave(\n [\n '--user', 'DummyUser',\n '--tool', 'DummyTool',\n '--action', 'DummyAction'\n ],\n :AddRegressionActions => true,\n :Repository => 'Dummy/SlaveActionActive'\n ) do |iError|\n assert_equal('DummyUser', $Variables[:DummyAction_User])\n end\n end", "def start\n\t\twhile @shutdown == false do\n\t\t\t@shutdown = true if @qa_pairs.length == 0\n\t\t\tputs @win_msg if @qa_pairs.length == 0\n\t\t\tself.test\n\t\tend\n\tend", "def test04_L1DLT04_TC_24418\n\t\t#skipping for now, currently unable to interact with the \"Tweet\" button\n\tend", "def test(input)\n workflow.register\n common_activity_worker.register\n\n workflow_execution = run(input)\n\n last_event = ''\n while last_event != 'WorkflowExecutionCompleted' && last_event != 'WorkflowExecutionFailed' && last_event != 'WorkflowExecutionTerminated' do\n event_types = workflow_execution.events.map(&:event_type)\n last_event = event_types.last\n if 'DecisionTaskScheduled' == last_event\n workflow.run_once\n elsif 'ActivityTaskScheduled' == last_event\n common_activity_worker.run_once\n end\n end\n end", "def test_setup\r\n \r\n end", "def read_entry(entry)\n expect(page).to have_css \"#feed-entries #entry-#{entry.id}\"\n entry_should_be_marked_unread entry\n open_entry entry\n entry_should_be_marked_read entry\nend", "def run!\n process_classic\n\n length.times do\n activity = ACTIVITIES.sample\n\n unless respond_to?(activity, true)\n LLL.error \"activity #{activity} not implemented\"\n next\n end\n\n LLL.info \"trying #{activity}\"\n before_time = Time.now.to_f\n Timeout.timeout(@timeout) do\n send activity\n end\n after_time = Time.now.to_f\n\n @report[activity].add(after_time - before_time)\n end\n end", "def test\n self.test_session.test\n end", "def action(type)\n ENV[\"runner_path\"] = $runner_path\n\n dirname = File.dirname(File.expand_path(__FILE__))\n script = File.join(dirname, \"action.py\")\n\n puts \"Calling python script: #{script} #{type}\"\n exec(\"python\", script, type, *$items)\nend", "def test_reviewer_home\n\n post('index', {}, {})\n assert_response(:success)\n assert_template('tracker/index')\n \n post('index', {}, lee_hweng_session)\n assert_response(:success)\n assert_template('tracker/reviewer_home')\n\n #follow_redirect\n #assert_no_tag :content => \"POST Placement Review\"\n\n end", "def execute(setup)\n @action.call(setup)\n end", "def initiate\n Scraper.initiate_scrape\n puts \"\\n\\nWelcome to Today on Crowder! To exit type 'exit'.\"\n list_articles\n end", "def prepopulate\n # AtomFeedReaderHelper.prepopulate\n # @atom_feed_reads = AtomFeedRead.where(successfully_read: false).order('avalon_last_updated ASC')\n # render 'atom_feed_reader/index'\n AtomFeedReaderTask.new.perform\n end", "def tests; end", "def tests; end", "def test02_post_open_blog_ArticleOneComment_TC_24319\n\t\tlogin $user_1_email, $master_password\n\t\tsleep 2\n\t\t$browser.goto($patch_blogs_post_open_article)\n\t\t\n\t\tcommentPopSubmit \"Blog Article Comment #{random}\"\n\tend", "def run\n\n @startDate = Time.now.to_i * 1000\n @status = 'Started'\n start_test_run(create_test_objects(@tests, @runOptions, @id), @cmd)\n @status = 'Completed'\n @endDate = Time.now.to_i * 1000\n set_status\n @event_emitter.emit_event(test_run_completed: self)\n check_status_and_exit\n #add login for sending an exit code based on whether or not there were any failures.\n end", "def feed!\n http_fetch(feed_url)\n end", "def test_count_find_articles_for_user_args_with_feed\n feed = UserFeed.find(5) #New York Times\n args = VwArticlesForUser.find_articles_for_user_args(true, feed, :feed, 3, nil, nil)\n assert args[:select] == \"DISTINCT id\"\n assert args[:conditions] == [\"feed_id = ? AND (article_user_id = ? OR article_user_id IS NULL)\", 4, 3]\n assert args[:order] == \"pub_date DESC\"\n assert args[:limit].blank?\n assert args[:offset].blank?\n end", "def test_run\n assert_respond_to(@ts, :run)\n end", "def test_00030_view_upcoming_event\n @admin_events_page.start!(user_for_test)\n check_events\n \t@browser.wait_until{ @admin_events_page.first_event_item.present? }\n \ttitle = @admin_events_page.first_event_title.text\n \t# topics = @admin_events_page.first_event_topics.map{ |x|x.inner_html }\n \t@admin_events_page.event_view.click\n @browser.wait_until{ @admin_events_page.pic_view.present? }\n assert @admin_events_page.content_view.text.include? title\n # topics_view = @admin_events_page.related_topics_view.map{ |x|x.inner_html }\n # assert topics.sort == topics_view.sort\n end", "def test02_post_open_news_ArticleOneComment_TC_24319\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_news_post_open_article)\n\t\t\n\t\tcommentPopSubmit \"Test Comment #{random}\"\n\tend", "def start_tests(files)\n end", "def test_my_brain_start\n current_user.test_my_brain_started!\n redirect_to \"#{ENV[\"test_my_brain_url\"]}?id=#{current_user.subject_code}#{current_user.current_event_brain_code}\", allow_other_host: true\n end", "def run\n loop { sleep 5 while @feeds.alive? }\n end", "def generate_tests\n for tweet_json in TWEET_JSONS\n test_description = \"tweet_json: '#{tweet_json}'\"\n #puts \"scheduling test #{test_description}\"\n generate_one_test test_description, tweet_json\n end\nend", "def set_feed_items\n @rescue_action = RescueAction.find(params[:rescue_action_id])\n end" ]
[ "0.6573332", "0.6347964", "0.6263043", "0.624825", "0.61992455", "0.6184532", "0.61655474", "0.6161431", "0.6106196", "0.60878974", "0.6031313", "0.5993742", "0.59935594", "0.5933913", "0.5873512", "0.5824045", "0.5824045", "0.5824045", "0.5824045", "0.57848823", "0.5769436", "0.57563376", "0.5713681", "0.57117707", "0.5705145", "0.5699973", "0.5693046", "0.5681883", "0.56438524", "0.5628632", "0.5628632", "0.56192625", "0.5616868", "0.56087124", "0.5595454", "0.558381", "0.5580415", "0.5575263", "0.5571584", "0.5560385", "0.5559539", "0.5551434", "0.5551288", "0.5549765", "0.55492395", "0.5545583", "0.5532189", "0.55187386", "0.5516211", "0.5515163", "0.55064577", "0.5482259", "0.54744065", "0.54737055", "0.54733664", "0.5463077", "0.5462938", "0.5462839", "0.5458113", "0.54571635", "0.5440825", "0.5432281", "0.5431694", "0.54208493", "0.5412717", "0.5394798", "0.5392286", "0.5391041", "0.53899974", "0.5388125", "0.538431", "0.53684735", "0.5363209", "0.5359378", "0.5358239", "0.535819", "0.5354415", "0.5351206", "0.5350997", "0.5343992", "0.53350973", "0.5333147", "0.53271365", "0.53244895", "0.5321421", "0.53208286", "0.53203493", "0.53203493", "0.5313465", "0.5312667", "0.5312175", "0.53112483", "0.53108114", "0.53105664", "0.53048974", "0.53012973", "0.5300088", "0.5290559", "0.5288361", "0.52816015" ]
0.6938861
0
This is needed to stop test/unit from complaining that there is no test specified.
def test_hack assert(true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nothing\n end", "def test_nothing\n end", "def default_test\r\n end", "def default_test; end", "def default_test\n end", "def no_test\n flunk \"Test hasn't been written yet.\"\n end", "def default_test\n end", "def default_test\n end", "def __dummy_test__\n end", "def default_test\n end", "def test_nothing; end", "def testNoAction\n executeTest('DummyUser', {})\n end", "def test_empty\n # Empty.\n end", "def test_0_dummy\n\t\tend", "def test\n return\n # TODO\n # skips test framework, but we can probably just bastardize the options in the same way as with :skip_bundle\n # either make `test` build the actual directories etc., or use a script\n # either way, this method is stupid.\n end", "def test\n return\n # TODO\n # skips test framework, but we can probably just bastardize the options in the same way as with :skip_bundle\n # either make `test` build the actual directories etc., or use a script\n # either way, this method is stupid.\n end", "def tests; end", "def tests; end", "def test_nothing\n return true\n end", "def testing\n # ...\n end", "def testMissingUser\n setupTest do |iTasksFileName, iTicketsFileName|\n executeProcess(\n [\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ],\n :Error => WEACE::MissingVariableError\n )\n end\n end", "def test_defaults\n end", "def test(what = nil)\n ActiveRecord::Base.logger.silence do\n case what\n when NilClass, :all\n rake \"test:units\"\n when String\n begin\n old_env, ENV[\"RAILS_ENV\"] = ENV[\"RAILS_ENV\"], \"test\"\n ENV['TEST'] = \"test/#{what}_test.rb\"\n rake \"test:single\"\n ensure\n ENV['TEST'] = nil\n ENV[\"RAILS_ENV\"] = old_env\n end\n end\n end\n nil\n rescue SystemExit\n nil\n end", "def test_entry\n raise 'Implement the method \"test_entry\" in your test class'\n end", "def test(arg = nil)\n puts \"test\"\n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker()}\n end", "def test_entry\n raise \"Implement this method in your test class\"\n end", "def test_case; end", "def my_tests\n end", "def test_should_be_setup\n assert false\n end", "def test_not_run?(test_case)\n test_case[:exec_status] == 'n'\n end", "def run(*args) #:nodoc:\n return if @method_name == \"default_test\"\n super\n end", "def self_test; end", "def self_test; end", "def test_unit_not_dead\n end", "def test?\n rspec? || minitest?\n end", "def prerequisite_unmet_message\n \" No tests found. The 'tests' task will be empty.\"\n end", "def __\n raise \"__ should be replaced with a value or expression to make the test pass.\"\nend", "def test_method\n end", "def testNoAction\n executeMaster( [ '--process', 'DummyProcess', '--user', 'DummyUser' ],\n :Repository => 'Dummy/MasterServerInstalledWithDummySender',\n :AddRegressionProcesses => true,\n :AddRegressionSenders => true\n ) do |iError|\n assert_equal(nil, $Variables[:DummySenderCalls])\n end\n end", "def test\n end", "def test\n end", "def test\n end", "def tests=(_arg0); end", "def tests=(_arg0); end", "def testMissingComment\n setupTest do |iTasksFileName, iTicketsFileName|\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ],\n :Error => WEACE::MissingVariableError\n )\n end\n end", "def test \n end", "def test_no_arg\n\tassert_output(nil, abort) {GoldRush.argchecker(-1)}\n end", "def default_test\n info \"self: #{self}\"\n end", "def test_setup\r\n \r\n end", "def test1Action\n executeTest(\n 'DummyUser',\n {\n 'DummyTool' => {\n 'DummyAction' => [\n []\n ]\n }\n }\n )\n end", "def before_test(test); end", "def before_test(test); end", "def test\n return \"\ndef test_#{@test_name}\n assert_nothing_raised(#{self.class.name}) do\n #{@method} :#{@action}, #{@params.inspect}, #{@session.inspect}, #{@flash.inspect}\n end\nend\n\"\n end", "def testMissingTasks\n setupTest do |iTasksFileName, iTicketsFileName|\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ],\n :Error => WEACE::MissingVariableError\n )\n end\n end", "def testing!(msg=\"Expected to be in testing env, but was not.\")\n raise LT::Critical.new(msg) if !self.testing?\n end", "def createDefaultTest\n assertNothingRaised 'Should be able to create default AssertionFailure' do\n failure = RubyUnit::AssertionFailure.new\n hash = {}\n assertEqual hash, failure.data, 'Default data Hash should be empty'\n end\n end", "def test\n @commands_and_opts.push OPTIONAL_OPTS[:test]\n self\n end", "def initialize_test\n self.multiruby_skip ||= []\n self.testlib ||= :minitest\n self.test_prelude ||= nil\n self.test_task = nil\n end", "def test_print_start_nil\n assert_raises(StandardError) { print_start(nil) } # pass\n end", "def assert_no_error_occurred\n assert_exit_status(0)\n end", "def testMissingVersion\n setupTest do |iTasksFileName, iTicketsFileName|\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ],\n :Error => WEACE::MissingVariableError\n )\n end\n end", "def test\n\n end", "def test_disabled?\n ENV['NO_TEST'] == '1'\nend", "def test_disabled?\n ENV['NO_TEST'] == '1'\nend", "def defaultFailTest\n rescue_assertion /#{FAILING}/ do\n fail\n end\n end", "def test_super options\n p \"Super Test Called\"\n return \"Super Test Called\"\n end", "def test?\n if @options[:test].nil?\n super\n else\n @options[:test]\n end\n end", "def int_test_name\n name = test_method.test_name if test_method.respond_to?(:test_name)\n name || 'Functional'\n end", "def test_it_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:generate).arity)\n end", "def testMissingTickets\n setupTest do |iTasksFileName, iTicketsFileName|\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ],\n :Error => WEACE::MissingVariableError\n )\n end\n end", "def running_test_case; end", "def test_file_exists?\n\t\tif @test_file_name.nil?\n\t\t\tputs \"No test data given to run. Exiting.\"\n\t\t\texit(0)\n\t\tend\n\tend", "def test_file_missing(filename)\n end", "def assert_no_test_warnings\n refute has_test_warnings?(@review)\n end", "def setup\n # Do nothing\n end", "def setup\n # Do nothing\n end", "def setup\n # Do nothing\n end", "def setup\n # Do nothing\n end", "def setup\n # Do nothing\n end", "def setup\n # Do nothing\n end", "def setup\n # Do nothing\n end", "def testMissingBranch\n setupTest do |iTasksFileName, iTicketsFileName|\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}'\n ],\n :Error => WEACE::MissingVariableError\n )\n end\n end", "def test?\n @options[:test] || super\n end", "def test?\n @options[:test] || super\n end", "def test\n if phase.has_key?('test')\n execute(\"test\", phase['test'])\n end\n end", "def testMissingDeliver\n setupTest do |iTasksFileName, iTicketsFileName|\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep'\n ],\n :Error => WEACE::MissingVariableError\n )\n end\n end", "def test\n testMode == \"test\" || testMode == \"screenshot\" || testMode == \"testsuite\"\n end", "def test?\n rspec? || env == 'test'\n end", "def test_output_target_is_nil\n Crd::Spec.new 'Testing' do |s|\n assert_nil( s.output )\n end\n end", "def message\n \"Test does not have a 'When' step.\"\n end", "def test_fail_setup\n @actor.setup\n end", "def test_placeholder\n assert(true)\n end", "def testMissingSVNCO\n setupTest do |iTasksFileName, iTicketsFileName|\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--deliver', 'deliver %{DeliverablesDir}'\n ],\n :Error => WEACE::MissingVariableError\n )\n end\n end", "def run_test\n # Add your code here...\n end", "def run_test\n # Add your code here...\n end", "def stest_method_1(test); end", "def test_step; end", "def method_missing(m)\n if m.to_s =~ /test_/\n @untested += 1\n else\n super\n end\n end", "def testMissingMaster\n executeProcess(\n [\n '--slaveticket', '456'\n ],\n :Error => WEACE::MissingVariableError\n )\n end" ]
[ "0.76619726", "0.7476823", "0.74766475", "0.7436754", "0.74323094", "0.7390081", "0.73688567", "0.73688567", "0.7338989", "0.7278272", "0.72308105", "0.7103861", "0.6944664", "0.6903399", "0.67680943", "0.67680943", "0.6746586", "0.6746586", "0.67067266", "0.67013687", "0.6648694", "0.6611646", "0.6595024", "0.6570146", "0.6545118", "0.65165496", "0.651252", "0.64896655", "0.6485036", "0.6476865", "0.6471608", "0.64699537", "0.6455225", "0.6455225", "0.6401074", "0.64002365", "0.6399179", "0.6388089", "0.6387837", "0.6381063", "0.63736886", "0.63736886", "0.63736886", "0.6372692", "0.6372692", "0.6328879", "0.6323959", "0.6318788", "0.6313522", "0.6272753", "0.62390584", "0.62361026", "0.62361026", "0.6223532", "0.6210213", "0.6204988", "0.615404", "0.61528206", "0.6149508", "0.614629", "0.61453956", "0.6127842", "0.612021", "0.609766", "0.609766", "0.6097004", "0.6083759", "0.6081747", "0.60800564", "0.6065619", "0.6063754", "0.60636467", "0.60611737", "0.60282505", "0.60215616", "0.59992826", "0.59992826", "0.59992826", "0.59992826", "0.59992826", "0.59992826", "0.59992826", "0.5998231", "0.59882903", "0.59882903", "0.5977957", "0.59759223", "0.5966322", "0.59575105", "0.59548503", "0.59232074", "0.59159815", "0.5912061", "0.59110177", "0.59010005", "0.59010005", "0.58954144", "0.5887938", "0.58858174", "0.5884378" ]
0.6091755
66
Defines the base unit of the class. ==== Example class Coolness true end
def base name, options = {} self.base_unit = name unit name, Rational(1), options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def superclass() end", "def base_class\n # create the base class file\n File.open(File.join(repo_name, 'lib', \"#{use_kata_name}.rb\"), 'w') {|f| f.write <<EOF}\nclass #{class_name}\nend\nEOF\n end", "def class Motorbike < Vehicle\r\n def wheelie\r\n end\r\nend", "def base_class; end", "def class() end", "def initialize(base)\n @base = base\n end", "def standard_unit\n self.specimen_class ||= infer_specimen_class(self.class)\n SpecimenClass::UNIT_HASH[self.specimen_class]\n end", "def inherited(base); end", "def base\n detailed_units true\n end", "def is_derived_unit?\n !is_base_unit?\n end", "def initialize(klass, base)\n @klass = klass\n @base = base\n end", "def base_class!\n @base_class = self\n end", "def name\n 'base'\n end", "def inherited_constants; end", "def inherited(klass); end", "def inherited(klass); end", "def inherited(subclass); end", "def class; end", "def class; end", "def base; self; end", "def cls; end", "def initialize(name) #constructor\n self.name = name\n self.hp = 50 # default values\n self.mp = 10\n self.atk = 10\n self.speed = 5\n self.ct = 0\n self.maxhp = 5\n self.maxmp = 10\n self.status = 'alive'\n ALL_UNITS << self\n end", "def unit_class\n UNIT_CLASSES[ @type ]\n end", "def initialize(name) #constructor\n self.name = name\n self.hp = 50 #default values line7-14 every object has these by default\n self.mp = 10\n self.atk = 10\n self.speed = 5\n self.ct = 0\n self.maxhp = 50\n self.maxmp = 10\n self.status = 'alive'\n ALL_UNITS << self\n end", "def base\n @@base\n end", "def base\n self\n end", "def __type; @type == TYPE_BUILDING ? \"Building\" : \"Unit\"; end", "def base\n @base\n end", "def class\n (class << self; self; end).superclass\n end", "def bases; end", "def unit(short, base, size)\n @short = short\n @base = base\n @size = size\n register(short, self)\n end", "def base_unit\n units[0]\n end", "def __mock_class\n (class << self; self; end).superclass\n end", "def class\n (class << self; self; end).superclass\n end", "def initialize(base = nil)\n super\n @type = self.class.symbolize\n @base.type ||= TYPES[@type]\n end", "def super_class; end", "def super_class; end", "def derived_class(mod, name, doc, &init)\n ObjectClass.create(mod, [self], name, doc, &init)\n end", "def base\n @base ||= Failures.new\n end", "def namespace_inheritance; end", "def namespace_inheritance; end", "def test_subclass_name\n bo1 = Pt::Boundary::MyA.new(\"\\n===\\n\")\n assert_equal \"Part::Boundary::MyA\", bo1.subclass_name\n assert_equal \"Boundary::MyA\", bo1.subclass_name(index_ini: 1)\n assert_equal \"MyA\", bo1.subclass_name(index_ini: 2)\n\n ss = PlainText::Part::Section::Subsection.new [\"abc\"]\n assert_equal \"Part::Section::Subsection\", ss.subclass_name\n assert_equal \"Section::Subsection\", ss.subclass_name(index_ini: 1)\n end", "def BaseClass(name)\n name == \"string\" ? String : Object\nend", "def BaseClass(name)\n name == \"string\" ? String : Object\nend", "def definition\n super\n end", "def definition\n super\n end", "def description\n \"#{super} - Tramezzino\"\n end", "def initialize(base_class)\n @base_class = base_class\n end", "def BaseClass name\n name == \"string\" ? String : Object\nend", "def traits; end", "def make cclass\r\n\t\tcase cclass\r\n\t\twhen \"neutral\"\r\n\t\t\tret = CharClass.make(cclass, \"Neutral\", \"Nothing\",Stats.create(:strength => 1,:speed => 1,:serenity => 1,:stamina => 1,:sorcery => 1))\r\n\t\tend\r\n\t\t\r\n\t\tret\r\n\tend", "def superclass!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n\n type = SUPERCLASS\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 333:4: 'superclass'\n match( \"superclass\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end", "def create_class(classname, superclass); end", "def initialize(_owner, _base, _def_test=:equals_int)\n @owner = _owner\n @rules = Hash.new { |h, k| h[k] = [] }\n _base.rules.each { |k, tests| @rules[k] = tests.clone } unless _base.nil?\n raise Error.new 'Must provide a default test' if _def_test.nil?\n @def_test = _def_test\n end", "def test_automatically_provides_command_name_to_superclass\n assert_equal( 'compc', @cmd.command )\n end", "def initialize(name)\n super(name)\n @weapon_level = 1\n @life_points = 100\n end", "def initialize(name) # je recrée un initialize et je fais appel aux caractéristiques de la classe mère avec super\n super(name)\n\n @life_points = 100 # j'ajoute les caractéristiques propres au joueur humain\n @weapon_level = 1\n end", "def constructor; end", "def anatomy; end", "def initialize\n super(true)\n end", "def base\n if type.base?\n self\n else\n prefix ? type.base * prefix.factor : type.base\n end\n end", "def class_constant; end", "def class_constant; end", "def setbase(base)\n\t\t\t@base = base\n\t\tend", "def definition\n \"class #{full_name}\"\n end", "def neutral_base\n \"my neutral base\"\n end", "def superclass=(object); end", "def superclass\n\t\t\t\treturn Object\n\t\t\tend", "def inherited(base)\n unless base == Billomat::SingletonBase\n Billomat.resources << base\n base.timeout = 20\n end\n super\n end", "def initialize(number)\n super(number, :cargo) #recieves all the train methods as a subclass\n end", "def root_type\n raise \"subclass responsibility\"\n end", "def klass; end", "def klass; end", "def klass; end", "def klass; end", "def klass; end", "def klass; end", "def klass; end", "def klass; end", "def cloaking_class\n class << self\n self\n end\n end", "def inherited(base)\n Base.inherited(base)\n end", "def super_decl; end", "def declaration\n fail 'Subclasses must implement declaration()!'\n end", "def required_class; end", "def base?\n if self.base != nil\n true\n else\n false\n end\n end", "def type; super; end", "def unit(name)\n Unit.new(name, self)\n end", "def type\n raise 'derived should implement'\n end", "def setup\n raise \"setup must be defined in a subclass\"\n end", "def metametaclass; self.metaclass.metaclass; end", "def initialize\n \t\ttmax = TERRAIN_TRIANGLE_MAX_HEIGHT\n \t\ttmin = TERRAIN_TRIANGLE_MIN_HEIGHT\n \tsuper(50,100, tmin, tmax-tmin, BROWN)\n\t @depth = 20\n \t@groups = [:all, :terrain, :can_kill]\n \tend", "def make_base_env(klass)\n TypeEnv::BaseTypeEnv.new(klass)\n end", "def is_base_unit?\n Dimensions::BASE_QUANTITIES.map {|base| base.remove_underscores }.include? self.measures\n end", "def define_class(class_name, superclazz=Object)\n clazzDef = ClassDef.new\n clazzDef.class_name = class_name\n clazzDef.class_ancestors = superclazz\n return clazzDef\n end", "def initialize(pseudo)\n\t\t@name = pseudo\n\t\t@weapon_level = 1\n\t\t@life_points = 100\n\tend", "def inherited( subclass )\n\t\t\tsuper\n\t\t\tsubclass.instance_variable_set( :@idle_timeout, self.idle_timeout.dup )\n\t\t\tsubclass.instance_variable_set( :@heartbeat_rate, self.heartbeat_rate.dup )\n\t\tend", "def name; super; end", "def name; super; end", "def base=(value)\n @base = value\n valid_base?\n return @base\n end", "def inherit_stuff\n return unless accepted_genus\n\n self.classification ||= accepted_genus.classification\n self.lifeform ||= accepted_genus.lifeform\n end" ]
[ "0.6647527", "0.6366933", "0.63147736", "0.63143635", "0.62903374", "0.6182327", "0.605098", "0.60183364", "0.6010736", "0.58870333", "0.58845043", "0.58530265", "0.58347595", "0.58311456", "0.5828461", "0.5828461", "0.5774724", "0.57660365", "0.57660365", "0.5753517", "0.5719354", "0.566568", "0.5660933", "0.56528926", "0.5604223", "0.55992556", "0.5595445", "0.5589877", "0.55861676", "0.55829823", "0.557452", "0.5559533", "0.5540091", "0.55302626", "0.55258673", "0.55180293", "0.55180293", "0.5503614", "0.548518", "0.54805446", "0.54805446", "0.54545856", "0.54543656", "0.54543656", "0.54511017", "0.54511017", "0.5431286", "0.54231477", "0.54086286", "0.54018015", "0.53803945", "0.5367245", "0.53658783", "0.535258", "0.53341776", "0.5334155", "0.53320116", "0.53295463", "0.5327318", "0.53156227", "0.5312426", "0.5311009", "0.5311009", "0.53019124", "0.5301447", "0.5294013", "0.52939", "0.52937686", "0.52880543", "0.52790123", "0.5266539", "0.52590746", "0.52590746", "0.52590686", "0.52590686", "0.52590686", "0.52590686", "0.52590686", "0.52590686", "0.52547944", "0.52526325", "0.52493614", "0.5248395", "0.52443254", "0.52438", "0.5233242", "0.5232439", "0.52267146", "0.52110523", "0.5203624", "0.5198716", "0.51959056", "0.5191286", "0.5190896", "0.51865", "0.5182648", "0.51817423", "0.51817423", "0.51672286", "0.5162799" ]
0.625815
5
Returns the hash of rules for the current class.
def rules Gorilla.units[name] ||= {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rules_as_hash\n\t\tunless @rules_as_hash\n\t\t\t@rules_as_hash = self.rules.each_with_object( {} ) do |rule, hash|\n\t\t\t\tpred, succ = self.parse_rule( rule )\n\t\t\t\thash[ pred ] = succ\n\t\t\tend\n\n\t\t\tself.alphabet.each do |char|\n\t\t\t\t@rules_as_hash[ char ] = char unless @rules_as_hash.key?( char )\n\t\t\tend\n\t\tend\n\n\t\treturn @rules_as_hash\n\tend", "def hash\n self.class.hash ^ @ns.hash\n end", "def hash\n [bitmask, self.class].hash\n end", "def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end", "def hash\n self.class.name.hash\n end", "def rules\n @rules ||= {}\n end", "def rules\n @rules ||= {}\n end", "def rules\n @rules ||= {}\n end", "def hash\n code = 17\n code = 37 * code\n self.instance_variables.each do |v|\n code += self.instance_variable_get(v).hash\n end\n code\n end", "def hash\n [bitmask, self.class].hash\n end", "def to_hash\n the_hash = Hash.new\n the_hash.replace(@rules)\n the_hash\n end", "def hash\n ([self.class] + self.class.comparison_attrs.map{|x| send(x)}).hash\n end", "def hash\n [self.class, to_s].hash\n end", "def hash\n [self.class, to_s].hash\n end", "def rules\n @rules.dup.freeze\n end", "def hash\n to_h.hash ^ self.class.hash\n end", "def rules\n return @rules unless @rules.nil?\n\n # this initialization code runs only once\n @rules = {}\n 7.downto(0).each do |rule_key|\n key = rule_key.to_s(2).rjust(3, '0') # convert to binary, pad left with 0\n @rules[key.to_sym] = RULE_NAME >> rule_key & 1 # just the one bit\n end\n\n @rules\n end", "def rules\n @rules ||= {}\n end", "def hash\n @hash ||= self.to_a.hash\n end", "def rules\n self.class.rules\n end", "def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end", "def hash\n @hash ||= begin\n result = 17\n result = 31 * result + self.class.hash\n result = 31 * result + ord\n result.is_a?(Fixnum) ? result : result.hash\n end\n end", "def hash\n [check_id, exceptions, key, links, port, proof, protocol, since, status].hash\n end", "def hash\n\t\treturn [ self.class, self.dn ].hash\n\tend", "def hash\n [self.class, to_h].hash\n end", "def hash\n [self.class, to_h].hash\n end", "def hash\n [self.class, to_h].hash\n end", "def hash\n [class_id, object_type, action, cache_state, cached_time, last_access_time, md5sum, original_sha512sum, path, registered_workflows, used_count, file, network_element].hash\n end", "def hash\n instance_variables.map do |var|\n instance_variable_get(var).hash\n end.reduce(:^)\n end", "def classes_hash\n @classes\n end", "def classes_hash\n @classes\n end", "def hash\n [_name, _type, _klass].hash\n end", "def rules\n return @rules\n end", "def rules\n @rules.map{|r| [r.name, r.rule]}.to_h\n end", "def hash\n self.class.hash ^ operand.hash\n end", "def hash\n self.class.hash ^ key_attributes.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 to_a\n @rules.keys\n end", "def hash\n [self.class, id].hash\n end", "def classes_hash\n @classes_hash\n end", "def hash\n return super unless has_size?\n\n res = 0\n each do |el|\n res += el.hash\n end\n return res\n end", "def hash\n self.class.name.hash ^ @key.hash\n end", "def hash\n\t\t(language + type + klass + thing).hash\n\tend", "def hash\n\t\treturn [ self.subject, self.predicate, self.object ].hash\n\tend", "def rules\n @rules ||= []\n end", "def rules\n @rules ||= []\n end", "def hash # Hack for Ruby 1.8.6\n @node.id.hash ^ self.class.hash\n end", "def to_hash\n\t\t@classes.map { |name,klass| klass.to_hash }.reduce({}) { |sum,v| sum.merge( v) }\n\tend", "def hash\n self.state.hash\n end", "def hash\n self.class.hash ^ left.hash ^ right.hash\n end", "def hash\n \"#{self.class.name}-#{self.id}-#{@__metadata__.cas}-#{@__attributes__.hash}\".hash\n end", "def hash\n @hash[:perm_type].hash ^\n @hash[:perms].hash ^\n @hash[:inheritance].hash ^\n @hash[:target].hash\n end", "def hash\n @__set.to_a.hash\n end", "def defined_rules\n @defined_rules ||= {}\n end", "def hash\n return to_s.hash\n end", "def get_rules\r\n @rules\r\n end", "def hash\n\t\treturn self.name.to_s.hash\n\tend", "def hash\r\n\t\treturn @name.hash() + @type.hash()\r\n\tend", "def hash\n fsm_class.to_s.hash ^ state_var.to_s.hash\n end", "def hash\n require 'yaml'\n hash = YAML.load(File.read(self.yaml_file)) #gets hash from yaml file\n return hash\n end", "def hash_code; end", "def hash\n [code, scope].hash\n end", "def hash\n [accept_tos, verify_sms, kyc_check, documentary_verification, selfie_check, watchlist_screening, risk_check].hash\n end", "def hash\n ([graph_name] + operands).hash\n end", "def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end", "def hash\n [self.class, self.val, self.attribute].hash\n end", "def hash\n code.hash\n end", "def hash\n self.to_f.hash\n end", "def hash\n [duration, rrule, start].hash\n end", "def hash\n return Digest::MD5.hexdigest(self.describe(' '))\n end", "def hash\r\n return to_s.hash\r\n end", "def hash\n state.hash\n end", "def hash\n state.hash\n end", "def hash\n to_a.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 hash\n [rel, href].hash\n end", "def hash\n return name.hash ^ direction.hash ^ lhs.hash ^ rhs.hash\n end", "def consistent_hash\n Zlib.crc32(self.to_yaml, 0)\n end", "def hash\n size.hash ^ rank.hash\n end", "def hash\n to_s.hash\n end", "def hash\n type.hash ^ (id.hash >> 1)\n end", "def hash\n 0\n end", "def hash\n @hash || calculate_hash!\n end", "def to_hash() end", "def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # add special cases for refs\n self.hash_id = NodeId.sha1(\"#{prefix} #{self.size}\\0#{self.content}\")\n end", "def hash(*) end" ]
[ "0.6794187", "0.6490616", "0.64846677", "0.6477441", "0.64107436", "0.63832694", "0.63832694", "0.63832694", "0.6380443", "0.63434917", "0.6340206", "0.6268185", "0.6236619", "0.62218547", "0.6218318", "0.6203768", "0.620095", "0.6198281", "0.61724883", "0.61709374", "0.61691827", "0.61691827", "0.61511123", "0.6123207", "0.6080949", "0.6080949", "0.6080949", "0.60310614", "0.60232866", "0.598072", "0.598072", "0.595599", "0.59551144", "0.59435195", "0.59284526", "0.5924959", "0.59142214", "0.59142214", "0.59142214", "0.59142214", "0.59142214", "0.59142214", "0.59142214", "0.59123087", "0.59009135", "0.5890357", "0.5876985", "0.58595043", "0.58305675", "0.58205694", "0.5789479", "0.5789479", "0.57884884", "0.5783671", "0.57803744", "0.5770048", "0.5754429", "0.57491475", "0.5716758", "0.57109153", "0.5707557", "0.57066363", "0.56855243", "0.5679877", "0.5678051", "0.56730086", "0.5637557", "0.5625322", "0.56173086", "0.5616943", "0.5612895", "0.55869466", "0.55821604", "0.55754286", "0.55681", "0.55673677", "0.5563962", "0.55625486", "0.55625486", "0.55368316", "0.55355847", "0.55355847", "0.55355847", "0.55355847", "0.55355847", "0.55355847", "0.55355847", "0.55355847", "0.55355847", "0.55355847", "0.55341345", "0.5534026", "0.55329144", "0.5532856", "0.55284977", "0.5520071", "0.5520032", "0.55129004", "0.55095595", "0.54994506", "0.5483813" ]
0.0
-1
Class method version of Gorilla::Unitnormalize, to handle, e.g., Enumerable, Numeric, and Range objects.
def normalize input, &block case input when Range normalize(input.min, &block)..normalize(input.max, &block) when Enumerable input.map { |unit| normalize unit, &block } when Numeric normalize Unit.new(input), &block else # Unit, etc. input.normalize(&block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to(unit)\n unit = Unit.get(unit) if unit.is_a?(Symbol)\n self.normalize + unit.denormalize\n end", "def normalize\n divide(magnitude)\n end", "def normalized; end", "def normalize\n self / self.norm\n end", "def normalize; end", "def normalize!\n\t\t\tmagnitude = self.mag\n\t\t\t@elem.collect! {|elem| elem / magnitude}\n\t\t\treturn self\n\t\tend", "def normalize!; end", "def normalize(type); end", "def normalize!; length = 1.0; self; end", "def normalize\n end", "def normalize!\n\t\t\tmag = self.mag\n\t\t\t@elements = @elements.collect {|elem| elem / mag }\n\t\t\treturn self\n\t\tend", "def normalize( value )\n value\n end", "def unit \n\t\t\tunitq = self.dup\n\t\t\tmagnitude = self.abs\n\t\t\tunitq[0] /= magnitude\n\t\t\tunitq[1] /= magnitude\n\t\t\tunitq[2] /= magnitude\n\t\t\tunitq[3] /= magnitude\n\t\t\treturn unitq\n\t\tend", "def normalize\n @value = case @kind\n when 'fixed' then @value*1024\n when 'enum', 'range' then @value.map{ |v| v*1024 }\n end if @unit == 'GB'\n end", "def normalize(min, max, val)\n\t\t(val - min) / (max - min)\n\tend", "def unnormalized; end", "def normalized=(_arg0); end", "def normalize!\n end", "def normalized\n @value\n end", "def normalized\n @normalized ||= valid_range? ? range : normalized_range(range)\n rescue Exception => e \n # puts e.message\n value\n end", "def normalize(min, max)\n map { |v| v.respond_to?(:-) ? (v - min) / (max - min) : v }\n end", "def normalize!\n self.replace self.normalize\n end", "def normalize!\n normalize self\n end", "def normalize(x)\n if x.ndim == 2\n s = Numo::SFloat::Math.sqrt((x**2).sum(axis: 1))\n x / s.reshape(s.shape[0], 1)\n elsif x.ndim == 1\n s = Numo::SFloat::Math.sqrt((x**2).sum)\n x / s\n end\nend", "def normalize!\n end", "def normalize(domain); end", "def normalize(value)\n Array(attrs[:normalize]).each do |method|\n next unless method.is_a?(Symbol)\n\n value = value.send(method) if value.respond_to?(method)\n end\n\n value\n end", "def normalize\n mag = self.magnitude\n Vector.new @x/mag, @y/mag, @z/mag\n end", "def normalize!\n total_items = @items.size\n raise \"No items set\" if total_items == 0\n total_sum = @items.values.map{|x| x[:value] }.inject(:+).to_f\n\n @items.each_pair do |key, values|\n @items[key][:normalized] = values[:value] / total_sum\n end\n @normalized = true\n end", "def normalize\n x_alize(true)\n end", "def normalize\n normalization_factor = norm_2(self)\n return self if normalization_factor.zero?\n\n self.scale (1.0 / normalization_factor.to_f)\n end", "def normalize!(normalize_method = :right)\n if normalize_method == :seconds\n count = self.to_f\n @years = (count / SECONDS_IN_YEAR).floor\n count -= @years * SECONDS_IN_YEAR\n @months = (count / SECONDS_IN_MONTH).floor\n count -= @months * SECONDS_IN_MONTH\n @days = (count / 86_400).floor\n count -= @days * 86_400\n @hours = (count / 3_600).floor\n count -= @hours * 3_600\n @minutes = (count / 60).floor\n count -= @minutes * 60\n @seconds = count\n else\n if @seconds >= 60\n minutes = (@seconds / 60).floor\n @seconds -= minutes * 60\n @minutes += minutes\n end\n if @minutes >= 60\n hours = (@minutes / 60).floor\n @minutes -= hours * 60\n @hours += hours\n end\n if @hours >= 24\n days = (@hours / 24).floor\n @hours -= days * 24\n @days += days\n end\n # No way to convert correctly days in month \n if @months >= 12\n years = (@months / 12).floor\n @months -= years * 12\n @years += years\n end\n end\n return self\n end", "def normalize\n f = 1.0 / length\n Vector2.new(@x * f, @y * f)\n end", "def normalize!\n nil\n end", "def normalize(v = nil)\n super(v || value)\n end", "def normalize!\n self.length = 1.0\n self\n end", "def normalized!\n self\n end", "def normalize; self.dup.normalize!; end", "def normalize(name); end", "def normalize\n self.dup.normalize!()\n end", "def normalize(measurement)\n group_name = Alchemist.conversion_table.keys.find do |k|\n Alchemist.conversion_table[k].include?(measurement.unit_name)\n end\n group = Alchemist.conversion_table[group_name]\n base_unit = BASE_UNITS.find { |u| group.include?(u) }\n measurement.to.send(base_unit).to_s\n end", "def normalize(string); end", "def normalize! level = 1.0\n self.divide!(@data.max / level)\n end", "def normalizer; end", "def normalize!\n constant = @terms.select{ |t| t.is_a? Numeric }.inject(:+)\n hterms = @terms.select{ |t| t.is_a? Ilp::Term }.group_by(&:var)\n @terms = []\n constant ||= 0\n @terms << constant\n hterms.each do |v, ts| \n t = ts.inject(Ilp::Term.new(v, 0)) { |v1, v2| v1.mult += v2.mult; v1 }\n terms << t if t.mult != 0\n end\n self\n end", "def normalize( arr, type = :linear )\n arr = arr.map { |v| v.to_f == 0.0 ? 0.0 : Math.log(v) } if type == :logarithmic\n\n return arr if arr.min == arr.max\n\n adj, fac = arr.min, arr.max-arr.min\n arr.map {|v| (v-adj).quo(fac) rescue 0 }\n end", "def normalize national_number, options = {}\n clean! national_number\n normalized = @codes.reduce national_number do |number, code|\n result = code.normalize number, options\n break result if result\n number\n end\n normalized\n end", "def normalize(value)\n return 0.0 if near_zero_or_less? value\n return 1.0 if near_one_or_more? value\n value\n end", "def normalize\n self.dup.normalize!\n end", "def normalize\n self.dup.normalize!\n end", "def normalize(a)\n case a\n when self\n a\n when Integer\n find a\n when Array\n a.map{ |e| normalize(e) }\n else\n begin\n a.__send__ \"#{ name.underscore }!\" # a.actor!\n rescue\n raise \"Unable to normalize #{ self } #{ a.inspect }\"\n end\n end\n end", "def number\n result = normalize(@input_number)\nend", "def normalize\n [@x / Math.sqrt(@x**2 + @y**2), @y / Math.sqrt(@x**2 + @y**2)]\n end", "def normalize!\n if self[2] < 0\n self[0], self[2] = self[0]+self[2], -self[2]\n end\n if self[3] < 0\n self[1], self[3] = self[1]+self[3], -self[3]\n end\n self\n end", "def Unitize(*args)\n Unitize::Measurement.new(*args)\nend", "def normalize\n f = 1.0 / length\n Normal3.new(@x * f, @y * f, @z * f)\n end", "def normalize!\n __normalize_method\n __normalize_params\n end", "def normalize\n Transformation.new(self, self, [lambda{|x|x}])\n end", "def normalize(options = {})\n return unless valid? # Only normalize valid value\n\n @value = case datatype\n when XSD.boolean then %(1 true).include?(@value.to_s.downcase) ? \"true\" : \"false\"\n when XSD.integer then @value.to_i.to_s\n when XSD.decimal then normalize_decimal(@value, options)\n when XSD.double then normalize_double(@value, options)\n when XSD.time then @value.is_a?(Time) ? @value.strftime(\"%H:%M:%S%Z\").sub(/\\+00:00|UTC/, \"Z\") : @value.to_s\n when XSD.dateTime then @value.is_a?(DateTime) ? @value.strftime(\"%Y-%m-%dT%H:%M:%S%Z\").sub(/\\+00:00|UTC/, \"Z\") : @value.to_s\n when XSD.date then @value.is_a?(Date) ? @value.strftime(\"%Y-%m-%d%Z\").sub(/\\+00:00|UTC/, \"Z\") : @value.to_s\n when RDF.XMLLiteral then normalize_xmlliteral(@value, options)\n else @value.to_s\n end\n end", "def normalize\n\t\t\tself.dup.normalize!\n\t\tend", "def denormalize(unit)\n unit = Unit.get(unit) if unit.is_a?(Symbol)\n \n # If the target is already a BaseUnit, return null Transformation.\n if unit.is_a?(BaseUnit)\n Transformation.new(self, self, [lambda{|x|x}])\n else\n unit.denormalize\n end\n end", "def normalize\n\t\t\treturn self.dup.normalize!\n\t\tend", "def normalize_value value\n return value if value.is_a? String\n return \"0\" if value < 0\n return \"10\" if value > 10\n value.to_s\nend", "def UNIT(*values)\n first, second = values\n Unit.convert_to(first, second)\n end", "def converted_value(other_unit)\n if other_unit.special?\n other_unit.magnitude scalar\n else\n scalar / other_unit.scalar\n end\n end", "def unit_vector(p1, p2)\n x = p2[0] - p1[0]\n y = p2[1] - p1[1]\n normalize_vector([x,y])\n end", "def normalize(value)\n value -= value.floor \n value += 1 if value < 0\n value\n end", "def /(numeric)\n map { |v| v.respond_to?(:/) ? v / numeric : v }\n end", "def normalize(value, mod, unit)\n value = value % mod if (mod && mod > 0) ;\n remain = 0 ;\n remain = value % unit if (unit && unit > 0) ;\n\n return value - remain ;\n end", "def normalize(value)\n ltz = value < 0\n whole_part = value.to_i\n rational_part = ((value * 1000).to_i - (whole_part * 1000)).abs\n\n rational_part = if rational_part > 750\n 750\n elsif rational_part > 500\n 500\n elsif rational_part > 250\n 250\n else\n 0\n end\n rational_part = rational_part * -1 if ltz\n whole_part + (rational_part / 1000.0)\n end", "def normalize()\n merge(normalize: 'true')\n end", "def normalize!\n reverse! if !normal?\n end", "def as unit\n check_unit! unit\n dist = self.dup\n dist.number = convert_to_meters * meters_map[unit]\n dist.unit = unit\n dist \n end", "def adjust_units stats, unit # :nodoc:\n if stats.first > 0.05 then\n stats << unit\n return stats\n end\n\n unit.replace \"m#{unit}\"\n\n stats = stats.map { |stat| stat * 1000 }\n\n stats << unit\n end", "def denormalize(to_units = nil)\n x_alize(false, to_units)\n end", "def normalize level = 1.0\n self.clone.normalize! level\n end", "def normalize(str) return str end", "def phony_normalized_method(*attributes)\n main_options = attributes.last.is_a?(Hash) ? attributes.pop : {}\n main_options.assert_valid_keys :country_code, :default_country_code\n attributes.each do |attribute|\n raise(StandardError, \"Instance method normalized_#{attribute} already exists on #{name} (PhonyRails)\") if method_defined?(:\"normalized_#{attribute}\")\n\n define_method :\"normalized_#{attribute}\" do |*args|\n options = main_options.merge(args.first || {})\n assign_values_for_phony_symbol_options(options)\n raise(ArgumentError, \"No attribute/method #{attribute} found on #{self.class.name} (PhonyRails)\") unless respond_to?(attribute)\n\n options[:country_code] ||= country_code if respond_to?(:country_code)\n PhonyRails.normalize_number(send(attribute), options)\n end\n end\n end", "def normalize_value(value)\n case value\n when Range then normalize_range(value)\n when Array then value.map! {|v| v.is_a?(Range) ? normalize_range(v) : v }.join(',')\n else value.to_s\n end\n end", "def normalize\n resize(1.0)\n end", "def normalize!\n mag = magnitude\n return self if mag == 0\n self.x, self.y, self.z = self.x / mag, self.y / mag, self.z / mag\n self\n end", "def numericize\n\t\tcollect(&:to_f)\n\tend", "def normalize_vector(v)\n d = v[0]*v[0] + v[1]*v[1]\n if d != 1\n root = Math.sqrt(d)\n v[0] /= root\n v[1] /= root\n end\n v\n end", "def normalise\n gcd = x.gcd(y)\n gcd = 1 if gcd.zero?\n\n self.class.new(x / gcd, y / gcd)\n end", "def normalize\n store.normalize(minimum: minimum_value, spread: @spread)\n end", "def normalize(value)\n @process.call(value)\n end", "def normal_units_uri\n UrisAreEolTerms.new(self).uri(:normal_units_uri)\n end", "def normalize\n input.upcase\n end", "def normalize!(context = nil)\n unless normalized?(context)\n self.class.normalizers.keys.each do |attr_name|\n __send__(:\"#{attr_name}=\", normalize_attribute(attr_name, context))\n end\n\n @normalization_context = context\n end\n\n self\n end", "def normalize_scalar_property_value(value)\n return \"NaN\" if value.kind_of?(Float) && value.nan?\n\n case value\n when true, false, nil then value\n when ActiveSupport::Duration then value.to_i\n when Numeric then value\n when String then value.strip\n when Symbol then value.to_s.strip\n when Time then value.getutc.strftime(\"%Y-%m-%dT%H:%M:%S\")\n when IPAddr then value.to_s\n when FLOAT_INFINITY then \"+infinity\"\n when -FLOAT_INFINITY then \"-infinity\"\n when Array then\n out = value.map { |e| normalize_scalar_property_value(e) }\n out = :invalid_property_value if out.detect { |e| e == :invalid_property_value }\n out\n else :invalid_property_value\n end\n end", "def normalize\n Transformation.new(self, base, @to_base)\n end", "def norm(v)\n len = Math.sqrt(v[0]**2 + v[1]**2)\n [v[0] / len, v[1] / len] \nend", "def normalize(v)\n case v\n when ActiveSupport::Duration then return from_duration(v)\n when IsoDuration then return v.to_s\n else v = v.to_s\n end\n MATCH_PATTERN.any? { |_, pattern| v.match?(pattern) } ? v : ''\n end", "def normalize1(text, analyzer = nil)\n\t\tEntry.normalize(text, normalizer1, analyzer)\n\tend", "def pre_normalize(text); end", "def Vector3dNormalize(arg0)\n ret = _invoke(1610744180, [arg0], [VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def units\n @units = SQF.units @this\n @units\n end", "def scale_unit(n, start1, stop1, start2, stop2, limit = false)\r\n norm = (n - start1) / (stop1 - start1).to_f\r\n norm = norm.clamp(0,1) if limit\r\n\t((norm * (stop2 - start2)) + start2)\r\nend", "def Unitwise(*args)\n Unitwise::Measurement.new(*args)\nend", "def normalize(v)\n find(v)&.alpha3 || super(v)\n end" ]
[ "0.6815934", "0.67310166", "0.67151874", "0.6477827", "0.64341897", "0.64118713", "0.6294422", "0.6287442", "0.6274068", "0.62591845", "0.6256661", "0.6229033", "0.62161964", "0.60913044", "0.60724473", "0.60711014", "0.606446", "0.60351926", "0.60207754", "0.60141015", "0.6013581", "0.5951011", "0.5925667", "0.59202975", "0.5907483", "0.58795595", "0.5870629", "0.5859555", "0.5844761", "0.583997", "0.58333784", "0.58312356", "0.5793606", "0.573637", "0.5733876", "0.572787", "0.5720849", "0.5716054", "0.57125264", "0.5631201", "0.5630155", "0.5627924", "0.560091", "0.5592735", "0.55714667", "0.5544871", "0.55422825", "0.5542049", "0.55308425", "0.55308425", "0.55306536", "0.5527744", "0.55028886", "0.5474647", "0.5470103", "0.54700285", "0.545524", "0.54518956", "0.5400745", "0.5373266", "0.5369544", "0.5358106", "0.5349831", "0.5344756", "0.5333546", "0.53297555", "0.53256965", "0.53242195", "0.5296612", "0.5290454", "0.52844626", "0.528217", "0.52658784", "0.5265383", "0.5260127", "0.52584547", "0.52266604", "0.5214867", "0.52082163", "0.5201855", "0.51988924", "0.5198739", "0.51894283", "0.51858765", "0.5183346", "0.5171126", "0.5164189", "0.5155277", "0.51488614", "0.5121027", "0.5116577", "0.5105998", "0.51025695", "0.5086376", "0.5062521", "0.5052702", "0.5047277", "0.5045383", "0.50368166", "0.50130355" ]
0.7427953
0
Instantiates a new unit for the class. Assumes the base unit if one is defined. ==== Example Gorilla::Unit.new 1 => (1) Gorilla::Time.new 1 => (1 second) Gorilla::Time.new 1, :minute => (1 minute)
def initialize amount, unit = self.class.base_unit if unit && self.class.rules[unit].nil? raise TypeError, "no such unit #{self.class}:#{unit}" elsif unit.nil? && !instance_of?(Unit) raise ArgumentError, "unit can't be nil for #{self.class}" end @amount, @unit = (amount.to_r if amount), unit end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unit(name)\n Unit.new(name, self)\n end", "def initialize(unit_type)\n \n @resolution_unit = unit_type\n \n # Create our hash.\n # The default value is an empty bucket with\n # a start point and resolution.\n @buckets = Hash.new do |hash, key|\n period = create_period( key )\n @buckets[ key ] = TimeSeries::Bucket.new( period )\n end\n \n if not UNITS.member?(unit_type)\n raise ArgumentError, \"#{unit_type} is not an allowed unit of time\"\n end\n\n end", "def new\n @unit_of_measure = UnitOfMeasure.new\n end", "def initialize(value, unit = nil)\n @value = value\n @unit = unit\n end", "def initialize(symbol, name, base, from_and_to_base)\n\n # If a Unit with this symbol exists...\n if @@registry.has_key?(symbol)\n raise(PhysicalQuantifier::Error,\n \"Unit already defined for symbol '#{symbol.to_s}'\")\n \n # If a BaseUnit with this symbol exists...\n else\n unless BaseUnit.exists?(base)\n raise PhysicalQuantifier::Error::BaseUnit::NotDefined\n end \n @symbol = symbol\n @name = name\n @base = Unit.get(base)\n if from_and_to_base.kind_of?(Numeric)\n @from_base = eval \"[lambda{ |x| x / #{from_and_to_base.to_f} }]\"\n @to_base = eval \"[lambda{ |x| x * #{from_and_to_base.to_f} }]\"\n else\n unless from_and_to_base.is_a?(Array)\n raise(PhysicalQuantifier::Error,\n \"You must pass an array of two lambda objects to Unit#new\")\n end\n @from_base = [from_and_to_base[0]]\n @to_base = [from_and_to_base[1]]\n end\n @@registry[@symbol] = self\n end\n end", "def time_unit\n @time_unit ||= PERIOD_MAPPING[@name]\n end", "def initialize(units=:mm)\n\t @units = units\n\tend", "def as unit\n check_unit! unit\n dist = self.dup\n dist.number = convert_to_meters * meters_map[unit]\n dist.unit = unit\n dist \n end", "def create_unit(unit_id, team, unit_type, unit_characteristics)\n unit = case unit_type\n when 'UNIT'\n Minion.new(self, unit_id, team, unit_characteristics)\n when 'HERO'\n Hero.new(self, unit_id, team, unit_characteristics)\n when 'TOWER'\n Tower.new(self, unit_id, team, unit_characteristics)\n when 'GROOT'\n Mercenary.new(self, unit_id, team, unit_characteristics)\n end\n\n if unit.type == :mercenary\n populate_neutral_team(unit)\n else\n @teams[unit.team].populate(unit)\n end\n end", "def create_unit(unit_id, team, unit_type, unit_characteristics)\n unit = case unit_type\n when 'UNIT'\n Minion.new(self, unit_id, team, unit_characteristics)\n when 'HERO'\n Hero.new(self, unit_id, team, unit_characteristics)\n when 'TOWER'\n Tower.new(self, unit_id, team, unit_characteristics)\n when 'GROOT'\n Mercenary.new(self, unit_id, team, unit_characteristics)\n end\n\n if unit.type == :mercenary\n populate_neutral_team(unit)\n else\n @teams[unit.team].populate(unit)\n end\n end", "def initialize(unit:, length:, width:, height:)\n @unit = unit\n @length = length\n @width = width\n @height = height\n end", "def new\n @unit = Unit.new\n\n @unit.libe = :seigneur\n @unit.weapon = '-'\n @unit.amount = 1\n @unit.points = 0\n\n set_units_rules_data\n\n @edition_disabled = false\n\n set_hash_for_vue(false )\n end", "def createUnit _obj, _args\n \"_obj createUnit _args;\" \n end", "def set_unit\n @unit = Unit.find(params[:id])\n @unit_time = @unit.unit_times[1]\n @unit_time_2 = @unit.unit_times[2]\n end", "def UNIT(*values)\n first, second = values\n Unit.convert_to(first, second)\n end", "def initialize(hour, minute)\n set_time hour, minute\n end", "def add_unit(conversion)\n return self\n end", "def Unitize(*args)\n Unitize::Measurement.new(*args)\nend", "def base name, options = {}\n self.base_unit = name\n unit name, Rational(1), options\n end", "def unit=(new_unit) #:nodoc:\n case new_unit\n when :day, :days\n @unit = IntervalUnits::DAY\n when :month, :months\n @unit = IntervalUnits::MONTH\n else\n @unit = new_unit\n end\n end", "def create_new_unit(xml_unit, new_version)\n unit_name = xml_unit.attribute('name')\n\n new_version.units.new(\n :name => unit_name\n )\n end", "def unit=(value)\n @unit = value\n end", "def units=(args)\n\t@units = (!args or args.is_a?(Units)) ? args : Units.new(args)\n end", "def unit=(a_unit)\n self[:unit] = a_unit.to_s\n end", "def initialize(name) #constructor\n self.name = name\n self.hp = 50 # default values\n self.mp = 10\n self.atk = 10\n self.speed = 5\n self.ct = 0\n self.maxhp = 5\n self.maxmp = 10\n self.status = 'alive'\n ALL_UNITS << self\n end", "def new\n # build a 'temporary' post which is written to DB later (create-method)\n @unit = Unit.new\n end", "def add_gang_to_unit\n @h_params = unit_params.to_h\n @h_params[ :gang_id ] = @gang.id\n @h_params[ :name ] = GameRules::UnitNameGenerator.generate_unique_unit_name(@campaign )\n\n @unit = Unit.new( @h_params )\n end", "def base_unit\n units[0]\n end", "def unit=(value)\n if value.respond_to?(:to_i)\n @unit = value.to_i\n else\n raise TypeError, \"Can't set a Duration's unit to a #{value.class.name} object.\"\n end\n end", "def unit=(value)\n if value.respond_to?(:to_i)\n @unit = value.to_i\n else\n raise TypeError, \"Can't set a Duration's unit to a #{value.class.name} object.\"\n end\n end", "def initialize(meters = nil)\n @units = :meters\n if meters\n super\n else\n @value = nil\n end\n end", "def initialize(value, time = Time.now)\n raise \"Error! Only numbers are allowed for Measure values\" unless value.is_a? Numeric\n raise \"Error! Only Time is allowed for Measure time\" unless time.is_a? Time\n @value = value\n @time = time\n end", "def instantiate_time_object(name, values)\n prms = {}\n values.each_with_index{|v,i| prms[\"#{name}(#{i+1}i)\"] = v.to_s}\n #puts \"Article.new(#{prms.inspect}).send :#{name}\"\n t = Article.new(prms).send name.to_sym\n #puts \"#{t.class}\"\n t \n end", "def create\n @timeunit = Timeunit.new(params[:timeunit])\n\n respond_to do |format|\n if @timeunit.save\n format.html { redirect_to(@timeunit, :notice => 'Timeunit was successfully created.') }\n format.xml { render :xml => @timeunit, :status => :created, :location => @timeunit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @timeunit.errors, :status => :unprocessable_entity }\n end\n end\n end", "def to_unit(other = nil)\n other ? RubyUnits::Unit.new(self).convert_to(other) : RubyUnits::Unit.new(self)\n end", "def getUnit(db, uid)\n\tunit = UnitAbstract.new(db, uid)\n\ttype = unit.type\n\t\n\tif type == 'human'\n\t\treturn UnitHuman.new(db, uid)\n\tend\n\t\n\tunit\nend", "def initialize(degrees={})\n\t\tif(degrees.is_a?(Hash))\n\t\t\t#only set the instance variables for Temperate object\n\t\t\t#to the values of the first key/value pair in degrees hash\n\t\t\t@unit = degrees.keys[0]\n\t\t\t@degree = degrees.values[0]\n\t\tend\n\tend", "def initialize(hour, minute, second, interval)\n @hour = hour\n @minute = minute\n @second = second\n @interval = interval\n end", "def test_preferred_unit_with_oom_and_preference\n range = Class.new(Metric)\n range.instance_eval do\n self.dimension = Dimension::L\n configure Unit[:L, :SI, :meter], {:preference => 3.01}\n end\n m0 = range.new(100000, Unit[:L, :SI, :meter])\n assert m1 = m0.preferred\n assert_same @meter, m1.unit\n end", "def convert_time_between_units(base_value:, original_unit:, new_unit:)\n if original_unit == new_unit\n base_value\n else\n # first convert to seconds\n value_in_seconds = self.calculate_time_in_seconds(base_value: base_value, unit_label: original_unit)\n # now divide by multiplier to get value in new unit\n denominator = TIME_MULTIPLIERS[new_unit]\n value_in_seconds.to_f / denominator\n end\n end", "def convert_time_between_units(base_value:, original_unit:, new_unit:)\n if original_unit == new_unit\n base_value\n else\n # first convert to seconds\n value_in_seconds = calculate_time_in_seconds(base_value: base_value, unit_label: original_unit)\n # now divide by multiplier to get value in new unit\n denominator = TIME_MULTIPLIERS[new_unit]\n value_in_seconds.to_f / denominator\n end\n end", "def unit_t\n I18n.t \"#{self.unit_s}\", :count => 1\n end", "def fine_minuto\n Time.new(self.year, self.month, self.day, self.hour, self.min, 59)\n end", "def unit\n self.dup.unit!\n end", "def initialize(hour = 0, minute = 0, second = 0)\n @hour = hour\n @minute = minute\n @second = second\n end", "def create\n # I was not able to get this working. I suspected a change may have occurred in the API that hasn't been published to docs.\n # Used https://www.hurl.it/ to test requests to the API. Was getting a success response, but\n # never saw the newly created unit in either my SDK or in the stage environment. Could be in the DB but missing an attribute/flag that allows\n # association to the property and/or allows for display.\n puts 'test1'\n #@unit = Unit.new(params)\n puts 'XYZ'\n puts params[:name]\n puts 'ABC'\n end", "def initialize(name) #constructor\n self.name = name\n self.hp = 50 #default values line7-14 every object has these by default\n self.mp = 10\n self.atk = 10\n self.speed = 5\n self.ct = 0\n self.maxhp = 50\n self.maxmp = 10\n self.status = 'alive'\n ALL_UNITS << self\n end", "def unit_class\n UNIT_CLASSES[ @type ]\n end", "def parse_time_unit(time_unit)\n case time_unit\n when /[0-9]+[smhdy]/\n time = time_unit[/[0-9]+/].to_i\n unit = time_unit[/[smhdy]/]\n time * UNIT_MULTIPLIER.fetch(unit)\n when /[0-9]+/\n Integer(time_unit)\n else\n raise\n end\n rescue IndexError => e\n raise InvalidParameter, \"Invalid time specification specified: '#{time_unit}'\"\n end", "def new(tempo_or_input, options = {})\n klass = case tempo_or_input\n when Numeric then Timer\n when UniMIDI::Input then MIDIClockInput\n else\n raise \"Not a valid tempo source\"\n end\n klass.new(tempo_or_input, options)\n end", "def initialize(hours = 0, minutes = 0, seconds = 0, nano_seconds = 0)\n @hours = hours\n @minutes = minutes\n @seconds = seconds\n @nano_seconds = nano_seconds\n end", "def initialize(start_time, end_time, miles_driven)\r\n\t\t@start_time = start_time\r\n\t\t@end_time = end_time\r\n\t\t@miles_driven = miles_driven\r\n\r\n\t\t#caching a duration variable in minutes for easy calculations\r\n\t\t@duration = triptime(@start_time, @end_time)\r\n\tend", "def initialize(options=nil,&block)\n @acts_as_alternative_unit = true\n @acts_as_equivalent_unit = false\n\n self.factor = 1.0\n self.symbol = nil\n self.label = nil\n self.name = nil\n self.j_science = nil\n self.base_unit = nil\n self.prefix = nil\n\n if options.is_a? Hash\n self.dimensions = options[:dimensions] if options[:dimensions]\n self.factor = options[:factor] if options[:factor]\n self.name = options[:name] if options[:name]\n self.symbol = options[:symbol] if options[:symbol]\n self.label = options[:label] if options[:label]\n self.j_science = options[:j_science] if options[:j_science]\n end\n\n block.call(self) if block_given?\n valid?\n end", "def Unitwise(*args)\n Unitwise::Measurement.new(*args)\nend", "def populate(unit)\n @units[unit.id] = unit\n\n case unit.type\n when :hero\n @heroes << unit\n when :unit\n @minions << unit\n when :tower\n @towers << unit\n when :groot\n @mercenaries << unit\n end\n end", "def populate(unit)\n @units[unit.id] = unit\n\n case unit.type\n when :hero\n @heroes << unit\n when :unit\n @minions << unit\n when :tower\n @towers << unit\n when :groot\n @mercenaries << unit\n end\n end", "def initialize(name, price, units = 0)\n @name = name\n @price = price\n @units = units\n end", "def load(&block)\n block.call(self) if block_given?\n raise Exceptions::InvalidArgumentError, \"A unit with the same label: #{self.name}) already exists\" if loaded?\n Quantify::Unit.load(self) if valid?\n return self\n end", "def time_unit\n return \"1sec\"\n end", "def create_granularity_class(name)\n Class.new do\n include Instance\n\n @name = name\n @to_s = name.to_s\n\n define_singleton_method :start, &Boundary.get_callable(name, :start)\n define_singleton_method :finish, &Boundary.get_callable(name, :finish)\n\n class << self\n include Granularity\n\n attr_reader :name, :to_s\n\n alias_method :to_sym, :name\n\n alias_method :from, :new\n alias_method :[], :new\n\n # JSON conversion required by ActiveSupport\n def as_json(_options = nil)\n to_s\n end\n\n def remaining(ts = Time.now.utc)\n finish(ts) - ts\n end\n\n # methods useful to construct ranges\n def succ\n granularity = LINKS[name][:succ]\n Period[granularity] if granularity\n end\n\n def pred\n granularity = LINKS[name][:pred]\n Period[granularity] if granularity\n end\n\n def new(timestamp = Time.now)\n timestamp = timestamp.utc\n cached = Period::Cache.get name, start(timestamp)\n if cached\n # cache hit\n cached\n else\n # cache miss\n obj = super timestamp\n Period::Cache.set name, obj\n obj\n end\n end\n end\n\n # instance methods\n attr_reader :granularity, :timestamp, :start, :finish\n\n def initialize(timestamp)\n @granularity = self.class\n @timestamp = timestamp\n @start = granularity.start(self.timestamp)\n @finish = granularity.finish(self.timestamp)\n end\n\n # These are convenience methods to let us print directly the\n # granularity of this period _instead of_ the full data including\n # the \"compact\" representation of the start date. This is so to\n # avoid having to change many users at this stage, but can be\n # confusing as it makes string representation of the instance the\n # same as the one from the granularity.\n def to_s\n granularity.to_s\n end\n\n def to_sym\n granularity.to_sym\n end\n\n def to_hash\n {\n granularity: to_s,\n start: start,\n finish: finish,\n }\n end\n alias_method :to_h, :to_hash\n\n # always define this to prevent ActiveSupport from \"discovering\" the\n # wrong methods for JSON-ification, ie. #each and/or #to_h(ash).\n def as_json(options = nil)\n granularity.as_json(options)\n end\n\n # Comparing two specific period instances only works if they refer\n # to the same granularity and the same specific period range. It\n # does not matter whether their timestamp is different.\n include Comparable\n\n def <=>(o)\n case o\n when Symbol, Granularity\n granularity <=> o\n when Instance\n start <=> o.start if granularity == o.granularity\n else\n nil\n end\n end\n\n # case equality - whether a timestamp is included\n def ===(ts)\n ts >= start && ts < finish\n end\n\n # break this period down into smaller ones\n def break_down(&blk)\n klass = granularity.pred\n iter = if klass.nil?\n []\n else\n klass.new(start)..klass.new(finish - 1)\n end\n iter.each(&blk)\n end\n\n # get the list of periods contained by the enclosing period\n def build_up(&blk)\n klass = granularity.succ\n iter = if klass.nil?\n []\n else\n # #each calls break_down\n klass.new(start)\n end\n iter.each(&blk)\n end\n\n # Enumerable is not being included because some external code\n # actually thinks of this as a collection that must be listed\n # instead of just inspecting or printing its value (this is the\n # case with RSpec and ActiveSupport at least).\n alias_method :each, :break_down\n\n def remaining(ts)\n finish - ts\n end\n\n # Range period iteration\n def succ\n self.class.new(finish)\n end\n\n def pred\n self.class.new(start - 1)\n end\n end\n end", "def initialize(seconds)\n @hour = seconds / 60 / 60\n @min = seconds / 60 % 60\n @sec = seconds % 60\n end", "def initialize (hours, minutes, seconds)\n\n @hours = 0\n @minutes = 0\n @seconds = 0\n\n end", "def definition=(unit)\n base = unit.to_base\n @scalar = base.scalar\n @kind = base.kind\n @numerator = base.numerator\n @denominator = base.denominator\n self\n end", "def method_missing(id, *args)\n\t # Check this before valid_conversion? because valid_conversion? has low standards\n\t if (id.to_s =~ /(.+)\\?$/) and Units.valid_unit?($1)\n\t\t@units.is_a?($1)\n\t elsif (@units and @units.valid_conversion?(id)) or Units.valid_unit?(id)\n\t\tunits = Units.new(id)\n\t\tif @units\n\t\t (@units == units) ? self : self.class.new(@units.convert(@value, id), units)\n\t\telse\n\t\t self.class.new(value, units)\n\t\tend\n\t elsif (id.to_s =~ /^per_(.+)$/) and Units.valid_unit?($1)\n\t\tunits = @units ? @units.per({$1 => (args[0] || 1)}) : Units.new({$1 => -(args[0] || 1)})\n\t\tself.class.new(@value, units)\n\t elsif (id.to_s =~ /^to_(.+)$/) and Units.valid_unit?($1)\n\t\tunits = Units.new($1)\n\t\treturn self if @units == units\n\t\tself.class.new(@units.convert(@value, $1), units)\n\t else\n\t\t@value.send(id, *args)\n\t end\n\tend", "def unit(short, base, size)\n @short = short\n @base = base\n @size = size\n register(short, self)\n end", "def initialize(name, amount, units)\n\t\t\t@name = name\n\t\t\t@amount = amount\n\t\t\t@units = units\n\t\tend", "def initialize ( actual=nil )\n @actual = actual || Time.new() # the actual time (Time)\n @current = nil # the time that we report (Time)\n @updated = Time.new # when @current was last updated (Time)\n @wobble = 5 # the maximum error in @current (minutes)\n @fuzz = 1 # the number of digits to fuzz out (int)\n @method = 3 # the update algorithm to use (int)\n @am_pm = false # report 12-hour time? (boolean)\n @current_offset = @wobble - rand(2*@wobble+1)\n @current = @actual + offset\n @current_offset = @current.to_i/60 - @actual.to_i/60\n @update_count = 1 # number of times time was updated (int)\n end", "def multiply(other)\n options = []\n self.instance_of?(Unit::Compound) ? options += @base_units : options << self\n other.instance_of?(Unit::Compound) ? options += other.base_units : options << other\n Unit::Compound.new(*options)\n end", "def create\n @unit = Unit.new(params[:unit])\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unit = Unit.new(params[:unit])\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unit = Unit.new(unit_params)\n authorize @unit\n begin\n ActiveRecord::Base.transaction do\n @unit.save!\n end\n rescue => e\n render partial: \"shared/validation_messages\",\n locals: { object: @unit.errors.any? ? @unit : e },\n status: :bad_request\n else\n RefreshOpensearchJob.perform_later\n toast!(title: \"Unit created\",\n message: \"The unit \\\"#{@unit.title}\\\" has been created.\")\n render \"shared/reload\"\n end\n end", "def initialize(location, op=nil, time=nil)\n @location = location\n @op = op\n @time = (time || Time.now).utc\n end", "def initialize(timeout=600)\n @holder = NameTimerHolder.new(timeout)\n end", "def initialize(price_per_unit)\n @price_per_unit = price_per_unit\n end", "def initialize(price_per_unit)\n @price_per_unit = price_per_unit\n end", "def units_hash\n {\n \"_hrs\" => \"hours\",\n \"_hours\"=>\"hours\",\n \"_min\"=>\"minutes\",\n \"_minutes\"=>\"minutes\",\n \"_ppm\"=>\"ppm\",\n \"_ppb\"=>\"ppb\",\n \"_mgm3\"=>\"mg/m3\",\n \"_f\"=>\"&deg;f\",\n \"_c\"=>\"&deg;c\",\n \"_rh\"=>\"% rh\",\n \"_utf\"=>\"\"\n }\n end", "def units\n definitions = unit_counts\n\n units = []\n definitions.each do |type, count, flank|\n klass = \"Unit::#{type.camelcase}\".constantize\n count.times do\n unit = klass.new(:level => 1, :location => @planet, :flank => flank)\n unit.skip_validate_technologies = true\n\n units.push unit\n end\n end\n\n units\n end", "def initialize(params)\n if params[:total_seconds].present?\n init_with_total_seconds(params[:total_seconds].to_f)\n elsif params[:time_string].present?\n init_with_time_string(params[:time_string])\n else\n init_with_hms(params)\n end\n end", "def initialize(config)\n @name = config[\"name\"]\n if @name.nil?\n raise \"You must specify a name\"\n end\n @unit = \"\"\n @value = nil\n @interval = config.has_key?(\"interval\") ? config[\"interval\"] : DEFAULT_INTERVAL\n @retrievals = 0\n @last_retrieved_ts = Time.at(0)\n end", "def test_preferred_unit_with_only_oom\n range = Class.new(Metric)\n range.instance_eval do\n self.dimension = Dimension::L\n end\n m0 = range.new(100000, @meter)\n assert m1 = m0.preferred(Locale::FR)\n assert_same @kilometer, m1.unit\n end", "def set_unit\n @unit = Unit.friendly.find(params[:id])\n end", "def build( unit_type )\n @game.send \"<build x='#{@x}' y='#{@y}' type='#{WeewarAI::Unit::TYPE_FOR_SYMBOL[unit_type]}'/>\"\n @game.refresh\n end", "def initialize multiplier=1, type =:word , tile=nil, multiplied=false\n\t\t\t@tile = tile\n\t\t\t@multiplier = multiplier\n\t\t\t@type = type\n\t\t\t@multiplied = multiplied\n\t\tend", "def initialize(with_time=true)\n @with_time\n @day = Day.new # the time schedule for the mechanic\n end", "def *(value)\n if value.is_a?(self.class)\n self.class.new(@minutes * value.to_i)\n else\n self.class.new(@minutes * check_arguments(value))\n end\n end", "def set_time(hour, minute)\n hour = 0 if hour.negative?\n hour = 23 if hour > 23\n minute = 0 if minute.negative?\n minute = 59 if minute > 59\n time = Time.new(0, nil, nil, hour, minute, nil, nil)\n @hour = time.hour\n @minutes = time.min\n end", "def new\r\n @uom = Uom.new\r\n\r\n end", "def assert_same_unit(other)\n fail ArgumentError, 'Incompatible units' unless same_unit?(other)\n\n self\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def set_unit\n @unit = Unit.find(params[:id])\n end", "def initialize(time, in_ms = false)\n @t = time\n @ms = in_ms\n end", "def initialize(quantity, powers_hash, preferred_units = nil)\n \n # Store powers hash (convert symbol to hash if necessary).\n @powers = {}\n @powers.default = 0\n powers_hash = {powers_hash => 1} if powers_hash.is_a?(Symbol)\n powers_hash.each do |u,p|\n u = Unit.get(u) if u.is_a?(Symbol)\n @powers[u] = p\n end\n \n # Initialize preferred_units hash to pre-normalized state.\n preferred_units = {preferred_units => 1} if preferred_units.is_a?(Symbol)\n self.preferred_units = preferred_units || preferred_units_from(powers_hash)\n \n # Store quantity as float.\n @quantity = quantity.to_f\n \n # Normalize.\n normalize\n end", "def initialize(symbol, name, quality)\n if @@qualities.has_key?(quality)\n raise(PhysicalQuantifier::Error::BaseUnit::Duplicate,\n \"Base unit already defined for quality '#{quality.to_s}'\")\n else\n @symbol = symbol\n @name = name\n @quality = quality\n @@registry[symbol] = self\n @@qualities[quality] = self\n end\n end" ]
[ "0.6812265", "0.6573167", "0.65611273", "0.64837223", "0.6322942", "0.6248117", "0.62442726", "0.6212339", "0.61753416", "0.61753416", "0.6065566", "0.6058368", "0.6049597", "0.60394", "0.6038262", "0.6000114", "0.5999554", "0.5980516", "0.59610397", "0.5919792", "0.586102", "0.5819901", "0.5816174", "0.57540905", "0.5722574", "0.56973547", "0.56955147", "0.5671589", "0.56447923", "0.56447923", "0.56156826", "0.56141216", "0.55737007", "0.5549187", "0.5536877", "0.5536463", "0.5533629", "0.5527014", "0.5525255", "0.5523078", "0.5511731", "0.54993576", "0.5487848", "0.5483489", "0.54684854", "0.54666394", "0.54523784", "0.5448324", "0.5446549", "0.5436816", "0.543358", "0.5413661", "0.5412512", "0.5409074", "0.54000264", "0.54000264", "0.5394446", "0.5371664", "0.53507406", "0.5349929", "0.5348641", "0.53404456", "0.5333144", "0.5327742", "0.532139", "0.5321318", "0.5310261", "0.53060323", "0.530551", "0.530551", "0.5291547", "0.5287054", "0.52857214", "0.5272863", "0.5272863", "0.5269561", "0.52664036", "0.52612746", "0.5254817", "0.52402747", "0.52375954", "0.5237298", "0.5228784", "0.5223015", "0.52215827", "0.5193978", "0.51939553", "0.51799303", "0.51681083", "0.51681083", "0.51681083", "0.51681083", "0.51681083", "0.51681083", "0.51681083", "0.51681083", "0.51681083", "0.51672", "0.51552075", "0.5147632" ]
0.64601064
4
Converts an instance to a new unit. ==== Example Gorilla::Weight.new(1, :pound).convert_to(:ounce) => (16 ounces)
def convert_to other_unit return dup if unit == other_unit unless self.class.rules.key? other_unit raise TypeError, "no such unit #{self.class}:#{other_unit}" end if self.class.rules[unit][:rules] amount = self.class.follow_rules normalized_amount, unit, other_unit return self.class.new amount, other_unit else amount = normalized_amount end new = self.class.new amount new.unit = other_unit new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to(unit)\n unit = Unit.get(unit) if unit.is_a?(Symbol)\n self.normalize + unit.denormalize\n end", "def as(unit)\n self.class.to(@amount, unit)\n end", "def as unit\n check_unit! unit\n dist = self.dup\n dist.number = convert_to_meters * meters_map[unit]\n dist.unit = unit\n dist \n end", "def convert(to)\n Quantity.new({:unit => @unit.convert(to), :reference_value => @reference_value})\n end", "def convert_to(cost, unit)\n value =\n case unit\n\n # Plant and Node\n when :plant\n cost\n when :node, :node\n cost * number_of_units\n\n # MW capacity\n when :mw_input, :mw_input_capacity, :mw_typical_input_capacity\n cost / input_capacity.to_f\n when :mw_electricity\n cost / electricity_output_capacity.to_f\n when :mw_heat\n cost / heat_output_capacity.to_f\n\n # MWh production\n when :mwh_input\n cost / typical_input.to_f * SECS_PER_HOUR\n when :mwh_electricity\n cost / typical_electricity_output.to_f * SECS_PER_HOUR\n when :mwh_heat\n cost / typical_heat_output.to_f * SECS_PER_HOUR\n\n # full load hours\n when :full_load_hour\n cost / full_load_hours.to_f\n\n # Some other unit that is unknown\n else\n raise ArgumentError, \"#{unit} unknown! Cannot convert.\"\n end\n\n value && value.to_f == Float::INFINITY ? 0.0 : value\n end", "def convert_to_measured\n converter = 1\n case self.cost_unit\n when \"tsp\"\n converter = 0.16667 # convert to us_fl_oz \n self.cost_unit = \"us_fl_oz\"\n when \"tbsp\"\n converter = 0.5 # convert to us_fl_oz \n self.cost_unit = \"us_fl_oz\"\n when \"cup\"\n converter = 8 # convert to us_fl_oz \n self.cost_unit = \"us_fl_oz\"\n end\n self.cost_size *= converter\n end", "def convert_weight(weight)\n\t\tpounds = weight[2, 3] #Pulls the 3rd (X), 4th (Y) and 5th (Z) digit from the format 00XYZdddd where 'd' is the decimal portion of the eVS weight convention\n\t\tounces = ((('0.' + weight[5, 4]).to_f)*16).round(1).to_s\n\t\tounces = ounces.to_f.round().to_s.rjust(3, ' ') if ounces.size > 3\n\t\treturn pounds, ounces\n\tend", "def to(units)\n unless self.zero?\n case units\n when Hash\n @mineral=@mineral.to(units[:mineral]) if Unit.new(units[:mineral]).kind == :mass\n @ore=@ore.to(units[:ore]) if Unit.new(units[:ore]).kind == :mass\n @grade=@grade.to(units[:grade]) if Unit.new(units[:grade]).kind == :unitless\n when String\n unit=Unit.new(units)\n case unit.kind\n when :mass\n @mineral=@mineral.to(units)\n @ore=@ore.to(units)\n when :unitless\n @grade=@grade.to(units)\n else\n raise ArgumentError, \"Incorrect units given, cannot convert!\"\n end\n end\n return self\n else\n return ResourceCode.new\n end\n end", "def convert(value, from, to)\n raise ArgumentError, \"Invalid from unit type\" unless Unit.valid_unit?(from)\n raise ArgumentError, \"Invalid to unit type\" unless Unit.valid_unit?(to)\n\n from_zeros = zeros_for_unit(from)\n to_zeros = zeros_for_unit(to)\n\n raise ArgumentError, \"Value must be a string\" unless value.is_a? String\n\n if from == :hex\n is_hex = Nano::Check.is_valid_hex? value\n raise ArgumentError, \"Invalid hex value string\" unless is_hex\n else\n is_number = Nano::Check.is_numerical? value\n raise ArgumentError, \"Invalid number value string\" unless is_number\n end\n\n zero_difference = from_zeros - to_zeros\n\n big_number = 0\n if from == :hex\n big_number = BigDecimal(value.to_i(16))\n else\n big_number = BigDecimal(value)\n end\n\n is_increase = zero_difference > 0\n zero_difference.abs.times do |i|\n if is_increase\n big_number = big_number * 10\n else\n big_number = big_number / 10\n end\n end\n\n if to == :hex\n big_number.to_i.to_s(16).rjust(32, \"0\")\n else\n if big_number.to_i == big_number\n big_number.to_i.to_s\n else\n big_number.to_s(\"F\")\n end\n end\n end", "def convert_to(other_unit)\n other_unit = Unit.new(other_unit)\n if compatible_with?(other_unit)\n new(converted_value(other_unit), other_unit)\n else\n fail ConversionError, \"Can't convert #{self} to #{other_unit}.\"\n end\n end", "def convert\n self.class.convert(object)\n end", "def unit_conversion\n if user.metric_system?\n self.distance = Goal.kms_to_miles(distance) if distance.present?\n self.vertical_gain = Goal.meters_to_feet(vertical_gain) if vertical_gain.present?\n end\n end", "def convert\n end", "def convert\n end", "def convert(value, from, to)\n value * get(from, :against => to)\n end", "def convert_lbs_to_kg(weight)\n weight * 0.45\nend", "def to_unit(other = nil)\n other ? RubyUnits::Unit.new(self).convert_to(other) : RubyUnits::Unit.new(self)\n end", "def convert(value) value end", "def convert(object); end", "def convert(value, target)\n\ttarget_unit = Units.parse_symbol(target)\n\n\ttarget_base = target_unit[:base]\n\ttarget_conversions = BASE_CONVERSIONS[target_base];\n\traise ArgumentError, \"No conversions to '#{target_base}'\" unless target_conversions\n\n\tsource_prefix = self.prefix || 0\n\ttarget_prefix = PREFIXES[target_unit[:prefix]] || 0\n\tprefix_multiplier = 10**(source_prefix - target_prefix)\n\n\tconversion_factors = @units.select {|k,v| target_conversions.include?(k) }\n\tbase_multiplier = conversion_factors.map {|k,v| target_conversions[k]**v }.reduce(1) {|accumulator, factor| accumulator * factor }\n\n\tvalue * prefix_multiplier * base_multiplier\n end", "def to(result_unit)\n RubyUnits::Unit.new(\"#{value} #{unit}\").\n convert_to(result_unit).\n scalar\n end", "def unit_helper(number, from_unit_string, to_unit_string)\n converted_number = OpenStudio.convert(OpenStudio::Quantity.new(number, OpenStudio.createUnit(from_unit_string).get), OpenStudio.createUnit(to_unit_string).get).get.value\n end", "def unit_helper(number, from_unit_string, to_unit_string)\n converted_number = OpenStudio.convert(OpenStudio::Quantity.new(number, OpenStudio.createUnit(from_unit_string).get), OpenStudio.createUnit(to_unit_string).get).get.value\n end", "def add_unit(conversion)\n return self\n end", "def convert_imperial_to_metric(measurement, conversion_factor)\n measurement * conversion_factor\nend", "def convert_lbs_to_kg(lbs_weight, kg_conversion)\n lbs_weight * kg_conversion\nend", "def unit_converter(value, input_unit, output_unit)\n\t\treturn 0 if value == 0\n\t\treturn value if input_unit.downcase == output_unit.downcase\n\n\t\tif input_unit.downcase == 'gb'\n\t\t\tif output_unit.downcase == 'mb'\n\t\t\t\treturn value * 1024\n\t\t\tend\n\t\telse\n\t\t\tif input_unit.downcase == 'mb'\n\t\t\t\tif output_unit.downcase == 'gb'\n\t\t\t\t\treturn value / 1024\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif input_unit.downcase == 'tb'\n\t\t\t\t\tif output_unit.downcase == 'gb'\n\t\t\t\t\t\treturn value * 1024\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def convert(base)\n self.class.new(numerator, denominator, base)\n end", "def coerce(object)\n if object.kind_of?(Numeric) && object == 1\n return Unit.unity, self\n else\n raise Exceptions::InvalidArgumentError, \"Cannot coerce #{self.class} into #{object.class}\"\n end\n end", "def convert!; end", "def unit_helper(number, from_unit_string, to_unit_string)\n OpenStudio.convert(OpenStudio::Quantity.new(number, OpenStudio.createUnit(from_unit_string).get), OpenStudio.createUnit(to_unit_string).get).get.value\n end", "def convert\n raise NotImplementedError\n end", "def convert_to_fl_oz(amount, unit)\n\t\tcase unit\n\t\t\twhen 'gallon' then amount * 128\n\t\t\twhen 'quart' then amount * 32\n\t\t\twhen 'pint' then amount * 16\n\t\t\twhen 'cup' then amount * 8\n\t\t\twhen 'fl_oz' then amount\n\t\t\twhen 'Tbsp' then amount * 0.5\n\t\t\twhen 'tsp' then amount * 0.1666666666667\n\t\tend\n\tend", "def convert_to_metric(measurement, conversion_factor)\n measurement * conversion_factor\nend", "def convert_to_metric(measurement, conversion_factor)\n measurement * conversion_factor\nend", "def convert number\n raise_on_type_mismatch number\n typed_conversion number\n end", "def convert number\n raise_on_type_mismatch number\n typed_conversion number\n end", "def convert number\n raise_on_type_mismatch number\n typed_conversion number\n end", "def convert number\n raise_on_type_mismatch number\n typed_conversion number\n end", "def convert number\n raise_on_type_mismatch number\n typed_conversion number\n end", "def convert_to(units)\n units = {units => 1} if units.is_a?(Symbol)\n prefs = {}\n units.each do |u,p|\n u = Unit.get(u) if u.is_a?(Symbol)\n prefs[u.quality] = u\n end\n self.preferred_units = prefs\n end", "def convert(amount, from, to, opts={})\n amount * rate(from, to, opts)\n end", "def convert_to(unit, value_in_unit)\n target_unit = UnitOfMeasure.find_by(name: unit)\n\n if target_unit.uom_category != self.uom_category\n return value_in_unit\n #raise StandardError, \"Can only convert to measurment units in the same category\"\n end\n\n incoming_ref_value = target_unit.to_ref(value_in_unit)\n\n result_unit_value = self.ref_to_unit(incoming_ref_value) \n result_unit_value.to_f\n end", "def convert_lbs_to_kg(lbs_weight, kg_conversion)\n\tlbs_weight * kg_conversion\nend", "def to_wei_value(value)\n BigDecimal.new(value) * wei_conversion_factor\n end", "def transform_units(t)\n @powers[t.from] = t.to if powers.has_key?(t.from)\n end", "def to_au\n Measure.new(1/FACTOR, AU::Mass.new(power))\n end", "def convert_to_metric(metric, conversion_factor)\n return (metric * conversion_factor).to_s\nend", "def converter\n end", "def to_au\n return self if system == :au\n conv = type.conversions.find{ |c| c.system == :au }\n if conv\n conv.call #(self)\n else\n base.universal\n end\n end", "def converter; end", "def numeric_to\n @to\n end", "def convert_to(convert_currency)\n Money::Converter.new(amount, currency, convert_currency).convert \n end", "def to_au\n Measure.new(1/FACTOR, AU::Space.new(power))\n end", "def monetize\n (object.unit_price * 0.01).to_s\n end", "def convert(euros, exchange_rate)\n euros * (exchange_rate / 100)\nend", "def UNIT(*values)\n first, second = values\n Unit.convert_to(first, second)\n end", "def kilo_to_pound_converter(weight_kg)\n\t \t puts \"#{weight_kg} Kilos\"\n\t @weight_lb = ( (weight_kg) * (0.453592) ).to_f + \"\\s Pounds\"\n\t end", "def method_missing(method, *args, &block)\n if method.to_s =~ /(to_|in_)(.*)/\n if (Unit.is_unit?($2.to_sym))\n convert($2.to_sym)\n else\n raise ArgumentError, \"Unknown target unit type: #{$2}\"\n end\n else\n raise NoMethodError, \"Undefined method `#{method}` for #{self}:#{self.class}\"\n end\n end", "def to_units( units, thousands=0 )\n\t\treturn Units[ units ] + to_thousands( thousands )\n\tend", "def convert_to(to_currency)\n Money.new(self.amount * exchange_rate(to_currency), to_currency)\n end", "def to_meter_per_second(**options) = convert_to('meter-per-second', **options)", "def convert(fahrenheit)\n celsius = (5 * (fahrenheit - 32))/9\nend", "def Unitize(*args)\n Unitize::Measurement.new(*args)\nend", "def convert!\n @output = convert\n self\n end", "def convert(obj)\n if c = @converter\n c.call(obj)\n else\n obj\n end\n end", "def converter\n\n end", "def convert!(source_value: 1)\n (source_value / source_rate) * target_rate\n end", "def convert\n raise \"The convert method must be implemented by subclass!\"\n end", "def convert_to(to_currency)\n\t\tfrom_currency = self.currency\n\t\trate = Money.getRate(from_currency, to_currency)\n\n\t\tconverted_amount = self.amount * rate\n\n\t\tMoney.new(converted_amount, to_currency)\n\tend", "def to(to, options={})\n value = @value * self.class.exchange_rate(@from, to)\n options[:scale].nil? ? value : (value * (10 ** options[:scale])).round / (10 ** options[:scale]).to_f\n end", "def convert(fahrenheit)\n (fahrenheit - 32) * 5 / 9 \nend", "def method_missing(id, *args)\n\t # Check this before valid_conversion? because valid_conversion? has low standards\n\t if (id.to_s =~ /(.+)\\?$/) and Units.valid_unit?($1)\n\t\t@units.is_a?($1)\n\t elsif (@units and @units.valid_conversion?(id)) or Units.valid_unit?(id)\n\t\tunits = Units.new(id)\n\t\tif @units\n\t\t (@units == units) ? self : self.class.new(@units.convert(@value, id), units)\n\t\telse\n\t\t self.class.new(value, units)\n\t\tend\n\t elsif (id.to_s =~ /^per_(.+)$/) and Units.valid_unit?($1)\n\t\tunits = @units ? @units.per({$1 => (args[0] || 1)}) : Units.new({$1 => -(args[0] || 1)})\n\t\tself.class.new(@value, units)\n\t elsif (id.to_s =~ /^to_(.+)$/) and Units.valid_unit?($1)\n\t\tunits = Units.new($1)\n\t\treturn self if @units == units\n\t\tself.class.new(@units.convert(@value, $1), units)\n\t else\n\t\t@value.send(id, *args)\n\t end\n\tend", "def convert_unit_for_save reps, work\n reps = reps.to_i\n work = work.downcase unless work.nil?\n type = activity.activity_type\n case type\n when 0 # Weight lifting\n # If there's no unit attached, add their default one\n if (true if Float(work) rescue false)\n work = work + self.user.unit\n end\n # Converts the passed work units to grams (since we keep all weights in the DB as grams)\n work_g = work.to_unit.convert_to(\"g\").scalar.to_i rescue false\n work_g = (work + current_user.unit).to_unit.convert_to(\"g\").scalar.to_i rescue false if work_g == false\n unless work_g == false\n self.work = work_g\n return true\n end\n errors.add(:base, \"Unable to parse the weight \" + work)\n when 1 # Time\n # Converts the passed work unit to seconds\n work = ChronicDuration.parse(work) rescue 0\n work = work.nil? ? 0 : work\n self.work = work\n return true\n when 2 # Distance\n parsed_work = Unit.new(work) rescue nil\n # If it's nil, then Ruby Unit can't parse it, so let's try a quick parse ourselves for steps\n if parsed_work.nil?\n # Does the user specify steps?\n if work =~ /steps/i\n # Cool! Then let's find the number\n steps = /[0-9]+/.match(work)\n unless steps.nil?\n # Now, calculate the distance based on average stride data from\n stride = 74\n if self.user.preferences[\"height\"].to_i > 0\n stride = 0.414 * self.user.preferences[\"height\"].to_i\n end\n # Now multiply the steps by the height and we can get an approximate distance in cm, which we then convert to mm\n self.work = (stride * steps.to_s.to_i) * 10\n return true\n end\n end\n else\n self.work = parsed_work.convert_to(\"mm\").scalar.to_i\n return true\n end\n errors.add(:base, \"Unable to parse the distance \" + work)\n when 3 # Repetitions\n # Just make sure they pass in an integer\n self.reps = reps.to_i\n self.work = 0\n return true\n end\n errors.add(:base, \"Invalid workout type... What gives?!\")\n return false\n end", "def inch_to_feet_converter\n\t \n\t end", "def convert(from:, to:, amount:)\n self.rates[from][to] * amount\n end", "def convert_bytes_to_unit(data:, unit:)\n case unit\n when 'kb' then @usage = data.to_i / 1024\n when 'mb' then @usage = data.to_i / 1024 / 1024\n when 'gb' then @usage = data.to_i / 1024 / 1024 / 1024\n end\n end", "def convert_inches_to_cm length\n in_to_cm = 2.54\n length * in_to_cm\nend", "def convert_inches_to_cm length\n in_to_cm = 2.54\n length * in_to_cm\nend", "def convert_inches_to_cm length\n in_to_cm = 2.54\n length * in_to_cm\nend", "def conversion\n fetch(:conversion) do\n others = inelastic_siblings.sum(&:conversion)\n\n # Don't break the laws of thermodynamics; conversion may not be\n # negative.\n others > 1.0 ? 0.0 : 1.0 - others\n end\n end", "def convert_to(time_as_float)\n Duration.create(time_as_float.to_s, '%S.%N')\n end", "def convert(fahrenheit_temp)\n @celsius_temp = (fahrenheit_temp - 32) * 5 / 9\nend", "def convertKelvin\r\n case self.myScale\r\n when 'F'\r\n self.myDegrees = (self.myDegrees + 459.67) * (5.0/9.0)\r\n self.myScale = 'K'\r\n when 'C'\r\n self.myDegrees = (self.myDegrees + 273.15)\r\n self.myScale = 'K'\r\n end\r\n end", "def convert_to_metric(amount, conversion_factor)\n puts \"converting...\"\n amount * conversion_factor\nend", "def method_missing(id, *args)\n\t # Check this before valid_conversion? because valid_conversion? has low standards\n\t if (id.to_s =~ /(.+)\\?$/) and Units.valid_unit?($1)\n\t\t@units.is_a?($1)\n\t elsif @units.valid_conversion?(id)\n\t\tunits = Units.new(id)\n\t\t(@units == units) ? self : self.class.new(@units.convert(@value, id), units)\n\t elsif (id.to_s =~ /^to_(.+)$/) and Units.valid_unit?($1)\n\t\tunits = Units.new($1)\n\t\treturn self if @units == units\n\t\tself.class.new(@units.convert(@value, $1), units)\n\t else\n\t\t@value.send(id, *args)\n\t end\n\tend", "def to_revolution_per_meter(**options) = convert_to('revolution-per-meter', **options)", "def coerce_money(v)\n SpookAndPuff::Money.new(v.to_s)\n end", "def convert_value_by_type\n case self.value_type\n when 'Numeric'\n unless self.multiplier.nil? || self.multiplier.blank?\n val = self.value.include?('.') ? self.value.to_f : self.value.to_i\n return val.send(self.multiplier.to_sym)\n else\n return self.value.to_f\n end\n when 'Boolean'\n return self.value == '1'\n else\n return self.value\n end\n end", "def converted_value(other_unit)\n if other_unit.special?\n other_unit.magnitude scalar\n else\n scalar / other_unit.scalar\n end\n end", "def convert\n @input\n end", "def ref_to_unit(value)\n result = nil\n if self.uom_type == 'big'\n result = value/self.ratio\n elsif self.uom_type == 'small'\n result = value * self.ratio\n elsif self.uom_type == 'ref'\n result = value\n end\n result.to_f\n end", "def convert\n original = __getobj__.to_s\n\n unless irregular_number?( __getobj__ )\n # Split up the number into triplets\n trios_reverse = create_reversed_grouped_numbers( original )\n\n # Generate the number based on the triplets\n multi_triplet = trios_reverse.length > 1\n result = []\n trios_reverse.each_with_index do |e, factor|\n result << (convert_triplet( e, factor, multi_triplet ) + ' ' + MEGA[factor]).strip\n end\n\n # And finaly join the triplets in the correct order\n result.reverse.join ' '\n else\n convert_irregular_number( original )\n end\n end", "def normalize(measurement)\n group_name = Alchemist.conversion_table.keys.find do |k|\n Alchemist.conversion_table[k].include?(measurement.unit_name)\n end\n group = Alchemist.conversion_table[group_name]\n base_unit = BASE_UNITS.find { |u| group.include?(u) }\n measurement.to.send(base_unit).to_s\n end", "def to_grain(**options) = convert_to('grain', **options)", "def to_pound(**options) = convert_to('pound', **options)", "def convert(temperature_fahrenheit)\n (temperature_fahrenheit.to_f - 32) * 5 / 9\nend", "def volume_to_weight(amount)\n amount = amount.to_unit\n return amount if amount.to_base.units == \"kg\"\n \n standard_unit = weight_1_description.split(\",\").first.to_unit\n \n # standard_unit.scalar is usually 1, but just in case we'll use the actual value\n weight_1.to_unit(\"grams\") * standard_unit.scalar * amount.convert_to(standard_unit.units).scalar\n end", "def to_i\n @speed\n end", "def to_i(*) end" ]
[ "0.64903563", "0.6374293", "0.62455237", "0.6194792", "0.6123529", "0.6098176", "0.60672337", "0.59975475", "0.5896459", "0.57980335", "0.57770336", "0.57436615", "0.5738317", "0.5738317", "0.571105", "0.5701904", "0.5684671", "0.5653204", "0.5627536", "0.5600549", "0.5592673", "0.55552924", "0.55552924", "0.5534828", "0.5529656", "0.55050194", "0.5493285", "0.54800546", "0.5473477", "0.5467884", "0.54662824", "0.5458873", "0.5455896", "0.54548055", "0.54548055", "0.54399234", "0.54399234", "0.54399234", "0.54399234", "0.54397035", "0.5431043", "0.5427749", "0.5384849", "0.53757256", "0.53721726", "0.53614944", "0.53565574", "0.53194636", "0.5318841", "0.5316792", "0.5314124", "0.5298286", "0.52747774", "0.5267739", "0.52521336", "0.52328515", "0.5230065", "0.5219749", "0.5205006", "0.52020794", "0.51947063", "0.51918447", "0.5187627", "0.51757336", "0.5171229", "0.5160395", "0.5159639", "0.5158874", "0.5155365", "0.51542264", "0.5152031", "0.51392144", "0.5107715", "0.510753", "0.5103036", "0.5090641", "0.50732595", "0.50712156", "0.50712156", "0.50712156", "0.5067776", "0.5066873", "0.50646716", "0.5062372", "0.50510585", "0.5049979", "0.5041017", "0.5038034", "0.5028902", "0.5027133", "0.50223255", "0.5018471", "0.5009192", "0.50017405", "0.5001098", "0.49970362", "0.4997006", "0.49968305", "0.49929997", "0.4979518" ]
0.56537807
17
Returns whether a unit was defined as metric. ==== Example class Coolness true end Coolness.new(1, :megaFonzie).metric? => true
def metric? unit and self.class.rules[unit][:metric] || false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metric?\n @metric\n end", "def metric_ton? = unit == 'metric-ton'", "def metrics?\n @metrics\n end", "def pixel_per_meter? = unit == 'pixel-per-meter'", "def metricModel? \n model = Sketchup.active_model\n\n # Get the length Units of the active model from the unitsOptions\n # 0=inches,1=feet,2=mm,3=cm,4=m\n unit = model.options[\"UnitsOptions\"][\"LengthUnit\"]\n return !(unit==0 || unit==1)\nend", "def unit?(unit)\n @units.include?(unit)\n end", "def meter_per_second? = unit == 'meter-per-second'", "def metrics?\n public? && @metrics\n end", "def unit?\n !@unit.nil?\n end", "def has_metric(types)\n has_gauges(:metric, types, kind_class_name: 'analyzing/metric')\n end", "def valid_metric?(metric)\n @metrics.keys.include? metric\n end", "def is_units?(); @type == GRT_UNITS; end", "def earth_mass? = unit == 'earth-mass'", "def grain? = unit == 'grain'", "def units?\n return units.any?\n end", "def carat? = unit == 'carat'", "def scored?\n metric_type_codename == :score ||\n metric_type_codename == :wiki_rating\nend", "def is_base_unit?\n Dimensions::BASE_QUANTITIES.map {|base| base.remove_underscores }.include? self.measures\n end", "def is_benchmark_unit?\n @factor == 1.0\n end", "def include_metrics?\n include_metrics.nil? || include_metrics\n end", "def metric_with_unit(unit)\n metrics.select {|m| Unit.new(m) <=> Unit.new(unit)}\n end", "def revolution_per_meter? = unit == 'revolution-per-meter'", "def in_unit?(unit)\n unit = Unit.find(unit) if unit.is_a?(Numeric)\n units.include?(unit)\n end", "def megapixel? = unit == 'megapixel'", "def http_metrics?\n http_metrics\n end", "def metrics\n standard.unit.convert_to_metric imperials\n end", "def solar_mass? = unit == 'solar-mass'", "def megahertz? = unit == 'megahertz'", "def kilogram? = unit == 'kilogram'", "def constructs_units?\n each_constructable_item do |item, base, name|\n return true if base == \"unit\"\n end\n\n false\n end", "def pixel? = unit == 'pixel'", "def counter?(metric)\n counters.detect { |op| op.first == metric }\n end", "def metrics_enabled?\n if !block_given?\n return @j_del.java_method(:isMetricsEnabled, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling metrics_enabled?()\"\n end", "def metrics_enabled?\n if !block_given?\n return @j_del.java_method(:isMetricsEnabled, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling metrics_enabled?()\"\n end", "def metrics_enabled?\n if !block_given?\n return @j_del.java_method(:isMetricsEnabled, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling metrics_enabled?()\"\n end", "def fahrenheit? = unit == 'fahrenheit'", "def kilohertz? = unit == 'kilohertz'", "def is_miles?\n maintenance_service_interval_type.is_miles?\n end", "def unit?\n role?('unit')\n end", "def has_method_metrics?\n metrics.find_by(system_name: 'hits')&.parent?\n end", "def timer?(metric)\n timers.detect { |op| op.first == metric }\n end", "def units(metric=nil)\n (metric || (metric.nil? && self.metric?)) ? METRIC_UNITS : IMPERIAL_UNITS\n end", "def occupied?\n not @unit.nil?\n end", "def same_unit?(other)\n other.unit.eql?(unit)\n end", "def find_metric(name)\n @metrics.detect{|m| m.name == name }\n end", "def is_time_unit?\n self.is_numeric? && TIME_UNITS.include?(self.unit)\n end", "def kelvin? = unit == 'kelvin'", "def minutes?\n @name == :minutely\n end", "def is_data_golden\n report.is_data_golden\n end", "def stone? = unit == 'stone'", "def measurement_issue\n measurement_required? && measurement_not_present?\n end", "def ton? = unit == 'ton'", "def lux? = unit == 'lux'", "def celsius? = unit == 'celsius'", "def gc_metrics_enabled?\n gc_metrics_enabled\n end", "def gram? = unit == 'gram'", "def unit_validity(desired_unit)\n return Unitwise.valid?(desired_unit)\nend", "def test_preferred_unit_with_only_oom\n range = Class.new(Metric)\n range.instance_eval do\n self.dimension = Dimension::L\n end\n m0 = range.new(100000, @meter)\n assert m1 = m0.preferred(Locale::FR)\n assert_same @kilometer, m1.unit\n end", "def dot_per_inch? = unit == 'dot-per-inch'", "def dot_per_centimeter? = unit == 'dot-per-centimeter'", "def periodic_metrics_enabled?\n periodic_metrics_enabled\n end", "def global_metrics_enabled?\n Object.const_defined?('Sidekiq::Enterprise') && global_metrics_enabled\n end", "def milligram? = unit == 'milligram'", "def gigahertz? = unit == 'gigahertz'", "def hybrid_measures?\n !!measures.map(&:hqmf_id).intersect?(APP_CONSTANTS['result_measures'].map(&:hqmf_id))\n end", "def is_time_unit?\n is_numeric? && TIME_UNITS.include?(unit)\n end", "def knot? = unit == 'knot'", "def loose_match?(unit)\n return false if @type != unit.type\n return false if custom? && @custom_name.casecmp(unit.custom_name) != 0\n true\n end", "def has_stats?\n !@short_name.nil?\n end", "def value_ok(unit, value_to_convert)\n is_ok = case unit\n when :celsius then\n begin\n celsius_min = -273.15\n value_to_convert > celsius_min\n end\n when :fahrenheit then\n begin\n fahrenheit_min = -459.67\n value_to_convert > fahrenheit_min\n end\n when :kelvin then\n begin\n kelvin_min = 0\n value_to_convert > kelvin_min\n end\n else false\n end\n is_ok\nend", "def is_support_unit\n $data_enemies[@enemy_id].is_support_unit\n end", "def microgram? = unit == 'microgram'", "def valid?\n return false if @class_id.nil?\n class_id_validator = EnumAttributeValidator.new('String', [\"hyperflex.DatastoreStatistic\"])\n return false unless class_id_validator.valid?(@class_id)\n return false if @object_type.nil?\n object_type_validator = EnumAttributeValidator.new('String', [\"hyperflex.DatastoreStatistic\"])\n return false unless object_type_validator.valid?(@object_type)\n accessibility_summary_validator = EnumAttributeValidator.new('String', [\"ACCESSIBLE\", \"NOT_ACCESSIBLE\", \"PARTIALLY_ACCESSIBLE\"])\n return false unless accessibility_summary_validator.valid?(@accessibility_summary)\n datastore_kind_validator = EnumAttributeValidator.new('String', [\"UNKNOWN\", \"USER_CREATED\", \"INTERNAL\"])\n return false unless datastore_kind_validator.valid?(@datastore_kind)\n datastore_status_validator = EnumAttributeValidator.new('String', [\"NORMAL\", \"ALERT\", \"FAILED\"])\n return false unless datastore_status_validator.valid?(@datastore_status)\n mount_summary_validator = EnumAttributeValidator.new('String', [\"MOUNTED\", \"UNMOUNTED\", \"MOUNT_FAILURE\", \"UNMOUNT_FAILURE\"])\n return false unless mount_summary_validator.valid?(@mount_summary)\n true\n end", "def next_unit?\n !@unit.nil?\n end", "def magnitude?\n self.units.reject{|d,(u,m)| m==0}.empty?\n end", "def is_derived_unit?\n !is_base_unit?\n end", "def good?\n score <= Constants::THRESHOLDS[@class_type]\n end", "def is_si_unit?\n self.is_a? SI\n end", "def is_prefixed_unit?\n self.prefix ? true : false\n end", "def ounce? = unit == 'ounce'", "def eh_measures?\n measures.pluck(:reporting_program_type).include?('eh')\n end", "def is_specific_quantity?\n denominator_quantities == [:mass]\n end", "def covered?\n coverage.positive?\n end", "def should_log?(log)\n super(log) && (log.metric_only? ? metrics? : true)\n end", "def healthy?\n @healthy\n end", "def pound? = unit == 'pound'", "def is_used?\n self.cases_count == self.cases_max\n end", "def c3_cat1_task?\n product.c3_test && eh_measures?\n end", "def alive?()\n\t\tamount_of( :deuterium ) > 0\n\tend", "def is_molar_quantity?\n denominator_quantities == [:amount_of_substance]\n end", "def measurement_required?\n @event.event_type == 'delivery' || @event.event_type == 'pickup'\n end", "def is_time?\n ! maintenance_service_interval_type.is_miles?\n end", "def loaded?\n Unit.units.has_key? @label\n end", "def test_preferred_unit_with_oom_and_preference\n range = Class.new(Metric)\n range.instance_eval do\n self.dimension = Dimension::L\n configure Unit[:L, :SI, :meter], {:preference => 3.01}\n end\n m0 = range.new(100000, Unit[:L, :SI, :meter])\n assert m1 = m0.preferred\n assert_same @meter, m1.unit\n end", "def unitvector?\n end", "def speed?\n @speed\n end", "def speed?\n @speed\n end", "def full_moon?\n pom == FULL_MOON\n end", "def measure\n Measure.new(1, self)\n end", "def won?\n total_score\n #check to see total_score_instance > 100 - if it is, return true, else return false\n if @total_score_instance > 100\n return true\n else\n return false\n end\n end" ]
[ "0.8225088", "0.81232244", "0.73423445", "0.7090844", "0.6979925", "0.6822958", "0.6769892", "0.6758768", "0.6748588", "0.667046", "0.66321015", "0.66016424", "0.6527534", "0.6502581", "0.64179325", "0.63817996", "0.633297", "0.6319842", "0.6311718", "0.6305567", "0.62871915", "0.6259649", "0.6252295", "0.618203", "0.61642414", "0.6160685", "0.6119553", "0.60963213", "0.6075501", "0.60711443", "0.6040224", "0.6038738", "0.5993278", "0.5993278", "0.5993278", "0.5987536", "0.58958787", "0.58815813", "0.5876767", "0.58315986", "0.5822781", "0.58062667", "0.57981503", "0.5794458", "0.5788833", "0.5783002", "0.5769288", "0.57656914", "0.57620114", "0.5756061", "0.5739702", "0.57178813", "0.5717502", "0.5703846", "0.57022905", "0.56914", "0.563581", "0.5631008", "0.5627055", "0.5623608", "0.5619988", "0.561381", "0.55742294", "0.557091", "0.55410236", "0.5527986", "0.5524894", "0.54907346", "0.5486386", "0.54817235", "0.54811186", "0.54770106", "0.54261667", "0.53919566", "0.539006", "0.53825736", "0.53784996", "0.53761244", "0.5370873", "0.53379637", "0.5336632", "0.533147", "0.532108", "0.53192794", "0.5314296", "0.5304387", "0.530414", "0.53004634", "0.5292186", "0.52889013", "0.5286375", "0.52853495", "0.52794284", "0.5271174", "0.5255936", "0.52542675", "0.52542675", "0.5253396", "0.52521074", "0.5241111" ]
0.89512295
0
Get status based on exception type
def status(exception) exception.is_a?(RSpec::Expectations::ExpectationNotMetError) ? Status::FAILED : Status::BROKEN end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n return 404 if NOT_FOUND_ERRORS.include? @exception.class.to_s\n @exception.respond_to?(:http_status) ? @exception.http_status : 500\n end", "def status_code_for_exception(exception)\n Egregious.status_code_for_exception(exception)\n end", "def octokit_error_as_status(type)\n yield\n rescue Octokit::ClientError => e\n Rails.logger.error(e) # log error for further debugging if it's not 404.\n {\n state: \"missing\",\n statuses: [{\n context: \"Reference\", # for releases/show.html.erb\n state: \"missing\",\n description: \"Unable to get commit #{type}.\",\n updated_at: Time.now # needed for #cache_duration\n }]\n }\n end", "def get_http_status exception\n http_status = nil\n if defined?(ActionDispatch::ExceptionWrapper) &&\n ActionDispatch::ExceptionWrapper.respond_to?(\n :status_code_for_exception\n )\n http_status =\n ActionDispatch::ExceptionWrapper.status_code_for_exception(\n exception.class.name\n )\n end\n\n http_status\n end", "def type\n @exception.class.to_s\n end", "def http_status exception\n http_status = nil\n if defined?(ActionDispatch::ExceptionWrapper) &&\n ActionDispatch::ExceptionWrapper.respond_to?(\n :status_code_for_exception\n )\n http_status =\n ActionDispatch::ExceptionWrapper.status_code_for_exception(\n exception.class.name\n )\n end\n\n http_status\n end", "def status_to_error(status)\n case status\n when 1\n 'InvalidRequest'\n when 2\n 'InvalidCredentials'\n when 3\n 'NonExistentOrder'\n when 4\n 'NonExistentOrderItem'\n when 5\n 'InvalidStateChange'\n when 6\n 'InvalidStorno'\n when 7\n 'AnotherError'\n when 8\n 'OrderNotExported'\n when 9\n 'AutomaticDeliveryError'\n end\n end", "def status_details(exception)\n StatusDetails.new(message: exception&.message, trace: exception&.backtrace&.join(\"\\n\"))\n end", "def handle_status(env)\n status = env[:status]\n case status\n when BadSyntaxStatus then raise Ashikawa::Core::BadSyntax\n when ResourceNotFoundErrorError then raise resource_not_found_for(env)\n when ClientErrorStatuses then raise Ashikawa::Core::ClientError, status\n when ServerErrorStatuses then raise Ashikawa::Core::ServerError, status\n end\n end", "def status\n uniform_status? ? statuses.first : :bad_request\n end", "def get_status status_code\n status = STATUSES[status_code]\n if status\n status\n else\n status = STATUSES['IV']\n end\n end", "def status\n STATUSES[code] || 'Unknown'\n end", "def status_code\n STATUS_CODE\n end", "def status(state, body = nil)\n raise Halcyon::Exceptions.const_get(state.to_s.camel_case.to_sym).new(body)\n rescue NameError => e\n self.logger.error \"Invalid status #{state.inspect} specified.\"\n self.logger.error \"Backtrace:\\n\" << e.backtrace.join(\"\\n\\t\")\n raise Halcyon::Exceptions::ServiceUnavailable.new\n end", "def exception_codes\n return Egregious.exception_codes\n end", "def status_code\n self.status.to_i\n end", "def status\n case @result.retval\n when 0 ; \"ok\"\n when 1 ; \"warning\"\n when 2 ; \"critical\"\n end\n end", "def exception_class; end", "def exit_status_from_exception; end", "def type\n @type ||= get_type_from_status_code(code)\n end", "def type\n @error['type']\n end", "def to_i\n @status_code\n end", "def status_code\n data.status_code\n end", "def http_status\n self.class.http_status\n end", "def http_status\n self.class.http_status\n end", "def convert_status(status)\n case status\n when '-1'\n return :failure\n when '0'\n return :unknown\n when '1'\n return :working\n when '2'\n return :complete\n else\n return :error\n end\n end", "def getStatusCode\n @_statusCode\n end", "def status_codes\n STATUS_CODES\n end", "def http_err_code\n http_codes[@http_err]\n end", "def http_status\n self[:status_code]\n end", "def status status\n yield\n ActiveRecord::Base.connection_pool.with_connection do \n @log.update(success_status: status, is_error: 0, error_status: nil, error_message: nil)\n end\n rescue => e\n ActiveRecord::Base.connection_pool.with_connection do \n @log.update(success_status: 0, is_error: 1, error_status: status, error_message: e.to_s)\n end\n Rails.logger.debug \"Exception at status \" + status.to_s + \" : \" + e.message + \" --- \" + e.backtrace.to_s\n raise\n ensure\n # call to request url\n # request_url(repo, status, caller_locations(2,2)[0].label)\n end", "def status\n return :code => info[:statuscode].to_i, :messages => info[:messages]\n end", "def status_code\n @status_code ||= if absolved?\n \"A\"\n elsif finished?\n \"Z\"\n elsif interrupted?\n \"P\"\n elsif final_exam_passed?\n \"S\"\n elsif continues?\n \"S\"\n elsif studying?\n \"S\"\n elsif before_admit?\n \"S\"\n else\n raise UnknownState\n end\n return @status_code\n end", "def handle_status(env)\n case env[:status]\n when BadSyntaxStatus then bad_syntax\n when AuthenticationFailed then authentication_failed\n when ResourceNotFoundError then resource_not_found_for(env)\n when ClientErrorStatuses then client_error_status_for(env[:body])\n when ServerErrorStatuses then server_error_status_for(env[:body])\n end\n end", "def status_code\n ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[@status]\n end", "def unknown; status[:unknown]; end", "def failure_type\n @attributes[:failure_type]\n end", "def status_code\n wrapper.status_code.to_i\n end", "def status\n 500\n end", "def status(property_name)\n result.key?(property_name) ? result[property_name][0] : 404\n end", "def get_http_status line\n is_http_status?(line) ? line.to_i : nil\n end", "def status_code\n @data[:status_code].to_i\n end", "def status_code\n params[:code] || 500\n end", "def status_code\n params[:code] || 500\n end", "def status_code\n @parser.status_code\n end", "def status_type(example)\n status = example[:status]\n return status if status != 'failed' || control[:impact].nil?\n if control[:impact] >= 0.7\n 'critical'\n elsif control[:impact] >= 0.4\n 'major'\n else\n 'minor'\n end\n end", "def http_status_exception(exception)\n @exception = exception\n render_options = {:template => exception.template, :status => exception.status}\n render_options[:layout] = exception.template_layout if exception.template_layout\n render(render_options)\n rescue ActionView::MissingTemplate\n head(exception.status)\n end", "def status_code\n @response.status\n end", "def status_cause\n\n m = node_status['m']\n\n (@message['cause'] || []).find { |c| c['m'] == m }\n end", "def issue_status(issue)\n issue.status\n end", "def status_error\n @status = 500\n end", "def fetch_status\n return :green if fetch_successful?\n last_statuses = fetch_events.sorted.limit(Repository::RED_STATUS_THRESHOLD).pluck(:successful).uniq\n return :unknown if last_statuses.empty?\n return :yellow if last_statuses.length > 1\n last_statuses[0] ? :green : :red\n end", "def agent_failed( type )\n type == SSH_AGENT_FAILURE ||\n type == SSH2_AGENT_FAILURE ||\n type == SSH_COM_AGENT2_FAILURE\n end", "def last_error\n if current_status && current_status.error_class.present?\n {\n error_class: current_status.error_class,\n error_message: current_status.error_message,\n error_trace: current_status.error_backtrace\n }.with_indifferent_access\n else\n super\n end\n end", "def status_code; end", "def exception_to_hash(id, exception, status)\n json_error(id, exception.class.name, exception.message, status)\n end", "def status_code\n response_value(:code)\n end", "def result_message_severity(xccdf_status)\n case xccdf_status\n when 'fail'\n 'error'\n when 'notapplicable'\n 'warning'\n else\n 'info'\n end\n end", "def type\n case code\n when 100..199 then :informational_response\n when 200..299 then :success\n when 300..399 then :redirection\n when 400..499 then :client_error\n when 500..599 then :server_error\n else :unknown\n end\n end", "def response_status\n @response[:status]\n end", "def client_error_status_code\n _undefined\n end", "def processerror(exception)\n case exception\n\n when RestClient::NotAcceptable #406\n raise RequestFailureException, \"Request failure\"\n when RestClient::Unauthorized #401\n raise RequestFailureException, \"Unauthorized access\"\n when RestClient::ResourceNotFound #404\n raise RequestFailureException, \"Incorrect request parameters. Check your url and the input xml\"\n when RestClient::InsufficientStorage # 507\n raise RequestFailureException, \"Account is full.User cannot make any more requests\"\n when RestClient::ServiceUnavailable # 503 => 'Service Unavailable',\n raise RequestFailureException, \"Your API has been throttled for now. Please try again later\"\n\n when ArgumentError\n raise exception\n\n else\n puts exception.message\n raise UnhandledException\n\n\n end\n\n end", "def status(default_status = :active)\n if _workitem.fields.has_key?(\"__timed_out__\")\n :timeout\n elsif _workitem.fields.has_key?(\"__error__\")\n :error\n else\n default_status\n end\n end", "def status(*code)\n self.status_code = code.first if code.first.present?\n self.status_code\n end", "def status\n raise @invalid_uri_error if invalid_uri_error?\n raise @fetch_error if fetch_error\n @status || String.new\n end", "def set_status(status)\n if status.kind_of?(Symbol)\n status = Merb::ControllerExceptions::STATUS_CODES[status]\n status || raise(\"Can't find a response code with that name\")\n end\n @_status = status\n end", "def extract_status(mr_job)\n crashed = timed_out = false\n 1.upto mr_job.item_count do |i|\n mapper = mr_job.mapper_runner i\n timed_out = true if mapper.timed_out\n crashed = true if !mapper.timed_out && mapper.status_code != 0\n end\n\n if crashed\n :crashed\n elsif timed_out\n :limit_exceeded\n else\n :ok\n end\n end", "def status_code\n return manual_status_code if manual_status_code\n return 422 if errors.present?\n return 200 if result\n return 400\n end", "def vuln_exception_listing(status = nil)\n option = {}\n\n if status && !status.empty?\n if status =~ /Under Review|Approved|Rejected/\n option['status'] = status\n else\n raise ArgumentError.new 'The vulnerability status passed in is invalid!'\n end\n end\n\n xml = make_xml('VulnerabilityExceptionListingRequest', option)\n r = execute xml, '1.2'\n\n if r.success\n res = []\n r.res.elements.each('//VulnerabilityException') do |ve|\n submitter_comment = ve.elements['submitter-comment']\n reviewer_comment = ve.elements['reviewer-comment']\n res << {\n :vuln_id => ve.attributes['vuln-id'],\n :exception_id => ve.attributes['exception-id'],\n :submitter => ve.attributes['submitter'],\n :reviewer => ve.attributes['reviewer'],\n :status => ve.attributes['status'],\n :reason => ve.attributes['reason'],\n :scope => ve.attributes['scope'],\n :device_id => ve.attributes['device-id'],\n :port_no => ve.attributes['port-no'],\n :expiration_date => ve.attributes['expiration-date'],\n :vuln_key => ve.attributes['vuln-key'],\n :submitter_comment => submitter_comment.nil? ? '' : submitter_comment.text,\n :reviewer_comment => reviewer_comment.nil? ? '' : reviewer_comment.text\n }\n end\n res\n else\n false\n end\n end", "def status\n Integer(@object.payload[:status]) rescue nil\n end", "def status\n self.operation.response.statusCode\n end", "def server_error_status_code\n _undefined\n end", "def status_code\n attributes[:status_code]\n end", "def find_status\n health = get_es_resource('/_cluster/health')\n health['status'].downcase\n end", "def code\n @error['code']\n end", "def query_failure_type\n @attributes[:query_failure_type]\n end", "def agent_failed(type); end", "def status\n 'unknown'\n end", "def legacy_error status, message, extra={}\n case status\n when Error\n status = status.http_code\n when StandardError\n extra[:backtrace] = status.backtrace if params[:backtrace]\n status = 500\n end\n content_type 'application/json'\n return status, {\n error: message,\n }.merge(extra).to_json\n end", "def code_symbol\n HTTP_STATUS_CODES[status]\n end", "def determine_status(mfhd_status)\n\n unavailable_count = 0\n mfhd_status.each do |item_id, item|\n statusCode = item[:statusCode].to_i\n unavailable_count += 1 if statusCode > 1 && statusCode != 11\n end\n\n case\n when unavailable_count == 0\n return 'available'\n when unavailable_count == mfhd_status.size\n return 'not_available'\n else\n return 'some_available'\n end\n\n\n # # assume available\n # status = 'available'\n # unavailable = 0\n # # if statusCode > 1 some item status is set so some item may not be available; 11 (returned) is the exception\n # records.each { |record| unavailable += 1 if record[:statusCode].to_i > 1 && record[:statusCode].to_i != 11 }\n # unless unavailable == 0\n # if unavailable == item_count.to_i\n # status = 'not_available'\n # else\n # status = 'some_available'\n # end\n # end\n # \n # status\n\n end", "def show\n template = if template_exists?(status_code, 'exceptions')\n \"exceptions/#{status_code}\"\n else\n 'exceptions/500'\n end\n\n respond_to do |format|\n format.html { render template: template, status: status_code }\n format.json do\n render json: { message: exception.message }, status: status_code\n end\n end\n end", "def parse_status(status)\n status = status.to_hex_s\n \n sw1 = status[-4..-3]\n sw2 = status[-2..-1]\n \n case sw1\n when \"67\"\n case sw2\n when \"00\" then err = \"LC_INVALID\"\n else\n raise \"Unknown sw2 #{ sw2.inspect } for sw1 #{ sw1.inspect }\"\n end\n \n when \"6a\"\n case sw2\n when \"82\" then err = \"FILE_NOT_FOUND\"\n when \"86\" then err = \"INVALID_P1_P2\"\n else\n raise \"Unknown sw2 #{ sw2.inspect } for sw1 #{ sw1.inspect }\"\n end\n \n when \"90\"\n case sw2\n when \"00\"\n err = \"NO_ERROR\"\n else\n raise \"Unknown sw2 #{ sw2.inspect } for sw1 #{ sw1.inspect }\"\n end\n \n when \"98\"\n case sw2\n when \"01\" then err = \"TIM_ERROR_TLV\"\n when \"02\" then err = \"TIM_ERROR_VALUE\"\n when \"03\" then err = \"TIM_ERROR_DATA_MISSING\"\n when \"04\" then err = \"TIM_ERROR_INVALID_CHARACTER\"\n when \"11\" then err = \"TIM_ERROR_DATE_FORMAT\"\n when \"12\" then err = \"TIM_ERROR_DATE_OUT_OF_RANGE\"\n when \"13\" then err = \"TIM_ERROR_CURRENCY\"\n when \"21\" then err = \"TIM_ERROR_TAX_VERIFICATION_FAILED\"\n when \"22\" then err = \"TIM_ERROR_NEGATIVE_TURNOVER\"\n when \"31\" then err = \"TIM_ERROR_INVALID_SIGNATURE\"\n when \"41\" then err = \"TIM_ERROR_INVALID_LIFECYCLE\"\n when \"e1\" then err = \"TIM_ERROR_MEMORY_FAILURE\"\n when \"e2\" then err = \"TIM_ERROR_DATA_CORRUPTED\"\n when \"ff\" then err = \"TIM_ERROR_NOT_SUPPORTED\"\n else\n raise \"Unknown sw2 #{ sw2.inspect } for sw1 #{ sw1.inspect }\"\n end\n \n else\n raise \"Unknown sw1 #{ sw1.inspect }\"\n end\n \n Insika.log(\"Parsed status #{ err }\")\n return err\n end", "def status\n @json_body['status']\n end", "def exit_status\n status = 0\n if @metrics[\"changes\"] && @metrics[\"changes\"][TOTAL] &&\n @metrics[\"resources\"] && @metrics[\"resources\"][\"failed\"] &&\n @metrics[\"resources\"][\"failed_to_restart\"]\n status |= 2 if @metrics[\"changes\"][TOTAL] > 0\n status |= 4 if @metrics[\"resources\"][\"failed\"] > 0\n status |= 4 if @metrics[\"resources\"][\"failed_to_restart\"] > 0\n else\n status = -1\n end\n status\n end", "def exceptions\n @values['exceptions']\n end", "def status_code(*)\n end", "def status_effect\n return data.status\n end", "def parse_status\n @request[FSTATUS].to_i\n end", "def exit_status\n status = 0\n status |= 2 if @metrics[\"changes\"][\"total\"] > 0\n status |= 4 if @metrics[\"resources\"][\"failed\"] > 0\n status\n end", "def status_enum\n status_list\n end", "def to_s\n @error_status.to_s\n end", "def status\n response.status\n end", "def status\n response.status\n end", "def status_code\n params['Status']\n end", "def exit_status\n @status\n end", "def status_name\n STATUSES[status]\n end", "def status_color\n if skipped?\n :yellow\n elsif error?\n :red\n else\n :green\n end\n end", "def status\n response.status\n end", "def status\n STATUSES[self.status_id || 0]\n end" ]
[ "0.7215961", "0.6946121", "0.68357164", "0.68093836", "0.680381", "0.65789205", "0.63794637", "0.62857175", "0.62823534", "0.6265933", "0.60673904", "0.60505986", "0.6028482", "0.600572", "0.59988004", "0.59925705", "0.59704626", "0.59657085", "0.59550506", "0.590416", "0.59025806", "0.5900262", "0.5886896", "0.5849006", "0.5849006", "0.5842005", "0.5806113", "0.5796042", "0.57921505", "0.5789977", "0.57679456", "0.5755564", "0.5747516", "0.5747323", "0.574576", "0.57418144", "0.57408845", "0.57389385", "0.57271457", "0.5721258", "0.5719993", "0.5707475", "0.5703867", "0.5703867", "0.56762713", "0.5666387", "0.5645269", "0.5629606", "0.5606828", "0.56016314", "0.5576147", "0.5564723", "0.555773", "0.5556332", "0.55533963", "0.55448925", "0.5530524", "0.55304086", "0.5522306", "0.5514487", "0.55111915", "0.55057055", "0.5502539", "0.5502046", "0.5493306", "0.5482612", "0.54735166", "0.54731315", "0.5468408", "0.5467754", "0.54475284", "0.54425526", "0.54390395", "0.54264367", "0.54255617", "0.54004425", "0.5390906", "0.53851765", "0.5379908", "0.53783983", "0.5366297", "0.53640723", "0.53607446", "0.53607315", "0.5344486", "0.5333708", "0.5325619", "0.5316663", "0.5311005", "0.53077286", "0.5307722", "0.5306257", "0.52883345", "0.52883345", "0.52853626", "0.5276855", "0.5274719", "0.52720445", "0.5268188", "0.52634877" ]
0.63410676
7
Get exception status detail
def status_details(exception) StatusDetails.new(message: exception&.message, trace: exception&.backtrace&.join("\n")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n return 404 if NOT_FOUND_ERRORS.include? @exception.class.to_s\n @exception.respond_to?(:http_status) ? @exception.http_status : 500\n end", "def get_http_status exception\n http_status = nil\n if defined?(ActionDispatch::ExceptionWrapper) &&\n ActionDispatch::ExceptionWrapper.respond_to?(\n :status_code_for_exception\n )\n http_status =\n ActionDispatch::ExceptionWrapper.status_code_for_exception(\n exception.class.name\n )\n end\n\n http_status\n end", "def exception_details(e, msg); end", "def status_code_for_exception(exception)\n Egregious.status_code_for_exception(exception)\n end", "def status_message\n data.status_message\n end", "def status_message\n @data[:status_message]\n end", "def http_status exception\n http_status = nil\n if defined?(ActionDispatch::ExceptionWrapper) &&\n ActionDispatch::ExceptionWrapper.respond_to?(\n :status_code_for_exception\n )\n http_status =\n ActionDispatch::ExceptionWrapper.status_code_for_exception(\n exception.class.name\n )\n end\n\n http_status\n end", "def stack_status_reason\n data[:stack_status_reason]\n end", "def status\n inspect\n end", "def status\n return :code => info[:statuscode].to_i, :messages => info[:messages]\n end", "def inspect\n \"#<Rapture::HTTP::HTTPException @code=#{@code} @message=#{message.inspect}>\"\n end", "def status_code\n STATUS_CODE\n end", "def status_code\n data.status_code\n end", "def status\n case @result.retval\n when 0 ; \"ok\"\n when 1 ; \"warning\"\n when 2 ; \"critical\"\n end\n end", "def http_status\n self[:status_code]\n end", "def extract_information_from(env)\n exception = env['action_dispatch.exception']\n exception_wrapper = ActionDispatch::ExceptionWrapper.new(env, exception)\n @rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[exception.class.name]\n @message = exception.message\n @status_code = exception_wrapper.status_code\n end", "def status_message; end", "def status\n info[\"Status\"]\n end", "def to_s\n @error_status.to_s\n end", "def status status\n yield\n ActiveRecord::Base.connection_pool.with_connection do \n @log.update(success_status: status, is_error: 0, error_status: nil, error_message: nil)\n end\n rescue => e\n ActiveRecord::Base.connection_pool.with_connection do \n @log.update(success_status: 0, is_error: 1, error_status: status, error_message: e.to_s)\n end\n Rails.logger.debug \"Exception at status \" + status.to_s + \" : \" + e.message + \" --- \" + e.backtrace.to_s\n raise\n ensure\n # call to request url\n # request_url(repo, status, caller_locations(2,2)[0].label)\n end", "def status_code\n self.status.to_i\n end", "def status\n info['status']\n end", "def exit_status_from_exception; end", "def status_line\n\t\tst = self.status || self.derived_status_code\n\t\treturn STATUS_LINE_FORMAT % [ st, HTTP::STATUS_NAME[st] ]\n\tend", "def get_status status_code\n status = STATUSES[status_code]\n if status\n status\n else\n status = STATUSES['IV']\n end\n end", "def status(exception)\n exception.is_a?(RSpec::Expectations::ExpectationNotMetError) ? Status::FAILED : Status::BROKEN\n end", "def status_code\n attributes[:status_code]\n end", "def last_error\n if current_status && current_status.error_class.present?\n {\n error_class: current_status.error_class,\n error_message: current_status.error_message,\n error_trace: current_status.error_backtrace\n }.with_indifferent_access\n else\n super\n end\n end", "def getStatusCode\n @_statusCode\n end", "def exception_info(e)\n backtrace = Array(e.backtrace)[0, 500]\n\n res = {\n 'class' => e.class.to_s,\n 'message' => e.message,\n 'backtrace' => backtrace.join(\"\\n\"),\n 'rollup' => Digest::MD5.hexdigest(\"#{e.class}#{backtrace[0]}\")\n }\n\n if original = (e.respond_to?(:original_exception) && e.original_exception)\n remote_backtrace = []\n remote_backtrace << original.message\n if original.backtrace\n remote_backtrace.concat(Array(original.backtrace)[0,500])\n end\n res['remote_backtrace'] = remote_backtrace.join(\"\\n\")\n end\n\n res\n end", "def error_details\n return @error_details\n end", "def to_i\n @status_code\n end", "def response_status\n @response[:status]\n end", "def status\n data[:status]\n end", "def status\n STATUSES[code] || 'Unknown'\n end", "def status\n @json_body['status']\n end", "def exception\n @context[:exception]\n end", "def exception_to_hash(id, exception, status)\n json_error(id, exception.class.name, exception.message, status)\n end", "def http_err_code\n http_codes[@http_err]\n end", "def status_code\n @data[:status_code].to_i\n end", "def status_code\n @response.status\n end", "def status\n data.status\n end", "def http_status\n self.class.http_status\n end", "def http_status\n self.class.http_status\n end", "def status_infos\n data[:status_infos]\n end", "def status(state, body = nil)\n raise Halcyon::Exceptions.const_get(state.to_s.camel_case.to_sym).new(body)\n rescue NameError => e\n self.logger.error \"Invalid status #{state.inspect} specified.\"\n self.logger.error \"Backtrace:\\n\" << e.backtrace.join(\"\\n\\t\")\n raise Halcyon::Exceptions::ServiceUnavailable.new\n end", "def get_message\n get_status[:message]\n end", "def status\n raise @invalid_uri_error if invalid_uri_error?\n raise @fetch_error if fetch_error\n @status || String.new\n end", "def status\n @message\n end", "def status\n response.status\n end", "def status\n response.status\n end", "def status\n response.status\n end", "def exception\n @exception&.object\n end", "def status_code; end", "def status_code\n @parser.status_code\n end", "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 stack_status\n data[:stack_status]\n end", "def getStatus\n @status\n end", "def status\n self.operation.response.statusCode\n end", "def status_code\n response_value(:code)\n end", "def status\n params['ret_status']\n end", "def inspect\n \"<Response(#{status})>\"\n end", "def exception_codes\n return Egregious.exception_codes\n end", "def status\n instance_get(:status)\n end", "def details(options = {})\n\t\toptions = {colorize: true}.merge(options)\n\t\tinspect_results = inspect_variables(options)\n\t\tparts = []\n\t\tparts << (options[:colorize] ? red('Exception:') : 'Exception:')\n\t\tparts << \"\\t\" + \"#{self.class.name}: #{message}\"\n\t\tparts << (options[:colorize] ? red('Variables:') : 'Variables:')\n\t\tparts << inspect_results\n\t\tparts << (options[:colorize] ? red('Backtrace:') : 'Backtrace:')\n\t\tparts << \"\\t\" + backtrace.to_a.join(\"\\n\")\n\t\tparts.join(\"\\n\")\n\tend", "def status_code\n ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[@status]\n end", "def status\n @status ||= raw_response['responseHeader']['status']\n end", "def formatted_exception\n @exception && \"#{@exception.class.name}: #{@exception.message}\"\n end", "def message\n params['StatusDetail']\n end", "def status\n 'unknown'\n end", "def status\n Integer(@object.payload[:status]) rescue nil\n end", "def code\n @error['code']\n end", "def get_status\n return @m_status\n end", "def status\n 500\n end", "def type\n @exception.class.to_s\n end", "def status_detail\n @status_detail ||= []\n end" ]
[ "0.7047844", "0.6799808", "0.676369", "0.6662642", "0.66613734", "0.6559857", "0.6522813", "0.65098566", "0.6508267", "0.64736664", "0.64581007", "0.6454799", "0.6428949", "0.64248025", "0.64009047", "0.63842976", "0.634557", "0.63399905", "0.6338014", "0.63068277", "0.6290832", "0.6285498", "0.6256946", "0.6242243", "0.6238268", "0.6237118", "0.6224932", "0.62199754", "0.6207325", "0.618327", "0.61783326", "0.6173732", "0.6151654", "0.61144274", "0.6110899", "0.6108266", "0.6107219", "0.6105041", "0.6104706", "0.6092226", "0.6079822", "0.60750216", "0.60715014", "0.60715014", "0.60544366", "0.60486823", "0.60450953", "0.6029176", "0.6024903", "0.60234255", "0.602049", "0.602049", "0.6020368", "0.6012393", "0.6000292", "0.59970975", "0.59876597", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.59874165", "0.5987008", "0.5981914", "0.59668624", "0.5957299", "0.5953748", "0.59472597", "0.59472084", "0.59465015", "0.5946341", "0.5944295", "0.59374297", "0.5931491", "0.5926764", "0.59261703", "0.59229517", "0.592238", "0.59178084", "0.59143406", "0.5912841", "0.5909151" ]
0.81669265
0
Check if value is full url
def url?(value) URI.parse(value.to_s).scheme end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_url?\n\t\t# http:// or not http://\n\t\tx = self.long_url.start_with?(\"http://\", \"https://\")\n\t\tif x == false\n\t\t\treturn \"http://\" + self.long_url\n\t\telse\n\t\t\treturn self.long_url\n\t\tend\n\tend", "def proper_url? \n\t\tif !(self.long_url.start_with?('http://') || self.long_url.start_with?('https://'))\n\t\t\terrors.add(:long_url, \"is in invalid format.\")\n\t\tend \n\tend", "def is_url?\n path =~ URL_PATHS\n end", "def fake_url?\n url =~ /^\\d\\d\\d\\d-/\n end", "def absolute_url?(string); end", "def value_url_valid?\n begin\n uri = URI.parse(value)\n uri = URI.parse(\"http://#{url}\") if uri.scheme.nil?\n if uri.scheme.downcase != 'http' and uri.scheme.downcase != 'https'\n @errors_data << 'validate_no_http_s_url'\n return false\n end\n value = uri.to_s\n return true\n rescue\n @errors_data << 'validate_invalid_url'\n return false\n end\n end", "def real_url?\n url && url.present? && url != \"#\"\n end", "def validate_full_url\n if self.full_url.nil?\n return\n end\n\n if((self.full_url =~ URI::regexp(\"http\")) == nil && (self.full_url =~ URI::regexp(\"https\")) == nil)\n self.errors.add(:full_url, \"Full url is not a valid url\")\n end\n end", "def is_a_real_url?\n begin\n URI.parse(long_url)\n rescue URI::InvalidURIError\n errors.add(:message, \"must be a valid URL\")\n end \n end", "def valid_url?\n @url =~ URI::regexp\n end", "def is_url_valid\n\t\tunless self.long_url.starts_with?(\"http://\", \"https://\")\n\t\t\terrors.add(:long_url, \"invalid format\")\n\t\tend\n\tend", "def url?(uri)\n /\\w+\\:\\/\\// =~ uri\n end", "def is_url?\n self =~ /^#{URI::regexp}$/\n end", "def url?(uri)\n /\\w+\\:\\/\\// =~ uri\n end", "def url?\n !urn?\n end", "def url_ok(url)\n return url =~ URI::ABS_URI\n end", "def valid_url?\n # Not sure if we should make a change in the user initial data, we could just return as invalid.\n my_target_url = target_url.match(/http/) ? target_url : target_url.prepend(\"http://\")\n\n response = HTTParty.get(my_target_url) rescue nil\n\n return if response&.code == 200\n\n errors.add(:short_url)\n end", "def url?\n !url.nil?\n end", "def normalize_url\n return if self.url.blank?\n normalized = self.url.normalize\n if normalized.blank?\n self.errors.add(:url, \"is invalid\")\n return false\n elsif normalized.match(\"archiveofourown.org/users\")\n self.errors.add(:url, \"cannot be ao3 user\")\n return false\n elsif normalized.match(\"(.*)/collections/(.*)/works/(.*)\")\n normalized = $1 + \"/works/\" + $3\n elsif normalized.match(\"archiveofourown.org/collections\")\n self.errors.add(:url, \"cannot be an ao3 collection\")\n return false\n end\n self.url = normalized\n end", "def is_valid_url?\n (@url =~ URI::DEFAULT_PARSER.make_regexp) != nil\n end", "def url_filled?\n !url.blank?\n end", "def long_url_is_an_url\n errors.add(:long_url, \"This is not a valid url\") unless is_valid_url?(self.long_url_with_protocol)\n end", "def url_provided?\n @url = params[:url]\n @url.present? && @url.strip\n end", "def is_url?( path )\n path =~ URI::ABS_URI\nend", "def url_must_be_valid\n url.blank? ||\n (url_is_remote? and url_has_suffix? and url_matches?) ||\n errors.add(:url, :invalid)\n end", "def valid_url?\n !Sailpoint.config.url.blank?\n end", "def url\n @url ||= value.split(/\\s+/).detect { |v| v =~ %r{\\A[a-z0-9]+:\\S+}i } || value\n end", "def valid?\n Wgit::Url.valid?(self)\n end", "def absolute_url?\n (self.include?('://') || self.start_with?('/')) ? true : false\n end", "def is_url?(path)\n path.to_s =~ %r{\\Ahttps?://}\n end", "def valid?\n (uri.host =~ LINK_REGEX || uri.host =~ LINK_IP_REGEX) ? true : false\n end", "def invalid_url?(url)\n url.include? 'hurl.it'\n end", "def url_is(url = nil)\n url_is_empty if url.nil? && url_attribute.nil?\n url_is_empty if url.nil? || url.empty?\n @url = url\n end", "def url?(string)\n return false unless string.to_s =~ url_pattern\n return false if string.to_s =~ @@placeholder\n true\n end", "def off_site?(url)\n url !~ /^\\// # urls not starting with a /\n end", "def url?(link)\n true if link =~ /\\Ahttps?:\\/\\//\nend", "def url_valid?\n uri = URI(full_url)\n Net::HTTP.start(uri.host, uri.port, :use_ssl => full_url.start_with?(\"https\")) do |http|\n response = http.request_get(full_url)\n return response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPRedirection)\n end\n end", "def generic_enforce_valid(record, uri, value)\n return false unless uri.is_a?(URI::Generic)\n\n if value.match(%r{^\\w+://.+}).nil?\n record.url = \"http://\" + value\n true\n else\n false\n end\n end", "def valid_uri?\n !self.contentable.blank? || !self.uri_path.blank?\n end", "def valid_url?(url)\n uri = URI.parse(url)\n\n uri.absolute?\n rescue\n false\n end", "def is_a_uri?(value)\n uri = URI.parse(value)\n uri.is_a?(URI::HTTP) && !uri.host.nil? && uri.host.split(\".\").size > 1\n rescue URI::InvalidURIError\n false\n end", "def check_if_link_is_valid\n uri = URI.parse(self.url.split(\" \")[0])\n self.url = uri\n if !%w( http https ).include?(uri.scheme)\n self.url = nil\n end\n end", "def validate_uri(url)\n !!URI.parse(url)\n end", "def check(url)\n LongURL::URL.check url\n end", "def validate_uri(url)\n !!URI.parse(url)\n end", "def good_resource?(url)\n if rx_url\n !(url.to_s !~ rx_url)\n else\n true\n end\n end", "def validate_url_attribute(attribute)\n value = self.read_attribute(attribute)\n return true if value.blank?\n begin\n url = self.normalize_url!(value)\n self.write_attribute(attribute, url)\n return true\n rescue URI::InvalidURIError => e\n self.errors.add(attribute, 'is invalid')\n return false\n end\n end", "def url_has_a_dot_in?\n (external_resource_url =~ /\\./ )\n end", "def valid_url?(url)\n return false if url.nil? || url.strip.empty?\n\n URI(url)\n true\n rescue URI::InvalidURIError\n false\n end", "def usable_link?(type, url)\n case type\n when :twitter\n # twitter users starting with _ (like _NapervilleIl) are weatherbugs\n # if the username does not start with _ it is a valid username\n (url.match(/^http:\\/\\/(?:www\\.)?twitter.com[^\\/]*\\/[^_]/)) && (! url.match(/\\/share|\\/goodies/))\n when :facebook\n url.match(/^http:\\/\\/(?:www\\.)?facebook.com/)\n else\n true\n end\n end", "def check_params(longurl)\n if longurl==\"\"\n return false\n else \n short_domain = ShortDomain.where(domain: Domainatrix.parse(longurl).domain + '.' + Domainatrix.parse(longurl).public_suffix).first\n if short_domain == nil\n return false\n else\n return true\n end\n end\n end", "def is_uri?(source)\n !!(source =~ URI_REGEXP)\n end", "def page_url_is_correct\n ( current_url =~ self.class.page_url_validation_value ) !=nil\n end", "def part_of_current_url?(url)\n url = url.is_a?(String) ? url : polymorphic_path(url)\n url == '/' ? request.request_uri == '/' : request.request_uri.starts_with?(url)\n end", "def url_is_valid\n errors.add(:url, \"url is not valid\") unless is_http_url? || is_spotify_url?\n end", "def real_url?(context = nil)\n url = url context\n url.present? && url != '#'\n end", "def valid?\n value.present? && uri.present?\n end", "def valid_url\n unless UrlValidator.valid_entry_url? self.url\n errors.add :url, \"URL #{self.url} is not a valid http, https or protocol-relative URL\"\n end\n end", "def verify_linkurl(linkurl)\n url = Loofah.scrub_fragment(linkurl, :prune).to_s\n url if valid_url?(url)\n end", "def validate_url_format\n valid_url = false\n begin\n uri = URI.parse(url)\n valid_url = uri.scheme.present? || uri.host.present?\n rescue URI::InvalidURIError\n valid_url = false\n end\n errors.add(:url, 'format is invalid') unless valid_url\n end", "def is_valid_url?(url)\n if (url =~ /\\A#{URI::DEFAULT_PARSER.make_regexp}\\z/) == 0\n return true\n else\n return false\n end\n end", "def url?\n children[0] && children[0].is_a?(Url)\n end", "def is_url? string\n uri = URI.parse(string)\n %w( http https ).include?(uri.scheme)\n rescue URI::BadURIError\n false\n rescue URI::InvalidURIError\n false\n end", "def url?(string)\n begin\n uri = URI.parse(string)\n %w( http https ).include?(uri.scheme)\n rescue URI::BadURIError\n false\n rescue URI::InvalidURIError\n false\n end\n end", "def url_valid?\n ALLOWED_URLS.each do |host, url_allowed|\n if url.include? url_allowed\n @host = host\n return true\n end\n end\n false\n end", "def valid?(url)\n url =~ %r|^http://www.megaupload.com/\\?d=[a-zA-Z0-9]+$|\nend", "def validate_url(string)\n schemes = ['http', 'https']\n match = string.match(URI.regexp(schemes))\n return (0 == match.begin(0) and string.size == match.end(0)) if match\n false\n end", "def validate_uri(url)\n return validate({:url => url})\n end", "def validate_url\n self.url = ExternalWork.format_url(self.url)\n errors.add_to_base(t('invalid_url', :default => \"Not a valid URL\")) unless self.url_active?\n end", "def url_exist?\n\t\tbegin\n\t\t\turi = URI.parse(valid_url?)\n\t\t\tresponse = Net::HTTP.get_response(uri)\n\t\trescue \n\t\t\terrors.add(:long_url,\"is invalid url\")\n\t\t\t# in AR, error is a class by itself already \n\t\t\t# go to static.rb to check the errors\n\t\tend\n\tend", "def all_valid?\n valid_url?\n end", "def check_url_validation\n errors.add(:url, I18n.t('url_not_proper')) unless UrlShort.is_valid? (url)\n end", "def base_url?( url_path )\n @base_url ||= base_url.gsub(/http\\:\\/\\/[^\\/]+/, '')\n @base_url == url_path\n end", "def base_url?( url_path )\n @base_url ||= base_url.gsub(/http\\:\\/\\/[^\\/]+/, '')\n @base_url == url_path\n end", "def verify_linkurl(linkurl)\n url = Loofah.scrub_fragment(linkurl, :prune).to_s\n url if valid_url?(url)\n end", "def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end", "def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end", "def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end", "def assert_url\n begin\n URI.parse(url)\n return true\n rescue URI::InvalidURIError => e\n errors.add(\"url\", \"has invalid format\")\n return false\n end\n end", "def validate_url\n return head(:bad_request, content_type: 'application/json') unless params[:shorten][:url]\n end", "def url?(url)\n assert_type(url, String) # This includes Wgit::Url's.\n query = { url: url }\n retrieve(URLS_COLLECTION, query, limit: 1).any?\n end", "def validate_url\r\n url = @hostname\r\n #puts \"DEBUG: url: \" + url\r\n \r\n url_part = []\r\n url_parts = url.split('.') \r\n #puts \"DEBUG: url_parts[0]: \" + url_parts[0]\r\n \r\n if url_parts[0].is_a? Numeric \r\n validate_sub_url(url_parts[0])\r\n validate_sub_url(url_parts[1])\r\n validate_sub_url(url_parts[2])\r\n validate_sub_url(url_parts[3])\r\n else # letters\r\n #puts \"URL just letters\"\r\n end\r\n ping_url\r\n end", "def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end", "def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end", "def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end", "def check_uri_build\n\n end", "def url?\n result = url\n result && \"#{result}?#{File.mtime(path).to_i}\"\n rescue Errno::ENOENT\n result\n end", "def has_website?\n !url.blank?\n end", "def sierra_856_perfect?\n @url == self.proper.proper_856_content\n end", "def valid_url?(url)\n uri = URI.parse(url)\n uri.kind_of?(URI::HTTP)\n rescue URI::InvalidURIError\n false\n end", "def valid_url?(url)\n resp = Curl.get url\n\n if resp.body_str.include? @invalid_text\n return false\n else\n return true\n end\nend", "def internal?\n url[0] == \"#\"\n end", "def url?(url)\n assert_type(url, String) # This includes Wgit::Url's.\n hash = { 'url' => url }\n @client[:urls].find(hash).any?\n end", "def valid?\n return false if relative?\n return false unless to_origin && to_domain\n return false unless URI::DEFAULT_PARSER.make_regexp.match(normalize)\n\n true\n end", "def valid_link(link)\n\t\t!link.nil? and !link.empty?\n\tend", "def validate(url)\n if url && url.is_a?(String) && url.match(/(^$)|(^(http|https):\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(([0-9]{1,5})?\\/.*)?$)/ix)\n return true\n else\n raise InvalidURL\n end\n end", "def checkURL(twitter_user)\n\tchecker = twitter_user.to_s\n\tif checker.start_with?(\"http://\") or checker.start_with?(\"https://\") or checker.start_with?(\"twitter.\")\n\t\treturn checker[checker.rindex('/')+1..checker.length]\n\telse \n\t\treturn checker\n\tend\nend", "def invalid_uri?(uri)\n uri.grep(/^(#{PROTOCOLS.join('|')}):\\/\\/\\w/).empty?\n end", "def uri?(word)\n return false if config.include_uris\n !(word =~ URI.regexp).nil?\n end", "def full_url display_url\n if display_url.blank?\n return nil\n end\n return (display_url[0..6] == \"http://\" or display_url[0..7] == \"https://\") ? display_url : \"http://#{display_url}\"\n end" ]
[ "0.7798053", "0.76697046", "0.752585", "0.7499902", "0.74993503", "0.7461718", "0.7447176", "0.742179", "0.7375037", "0.73388517", "0.7315883", "0.73008", "0.7276913", "0.72729087", "0.7264941", "0.7253971", "0.7210881", "0.7199088", "0.71750695", "0.71686035", "0.7156956", "0.7126353", "0.7118211", "0.70680636", "0.70267934", "0.69978744", "0.69942874", "0.69770104", "0.6966703", "0.6962912", "0.69546294", "0.6937919", "0.6922936", "0.6915312", "0.6887588", "0.6859688", "0.6857955", "0.68258196", "0.68247163", "0.6813357", "0.6793571", "0.67789924", "0.67315066", "0.6728985", "0.6727548", "0.6709349", "0.6684883", "0.66819936", "0.66718924", "0.66641706", "0.6663686", "0.6659486", "0.66560835", "0.6655035", "0.6633937", "0.66290426", "0.66286665", "0.6627758", "0.6607929", "0.6595832", "0.6585215", "0.65783966", "0.65753335", "0.6571076", "0.65426224", "0.654018", "0.65393794", "0.6532691", "0.6524215", "0.65120566", "0.6509288", "0.648968", "0.6474483", "0.6474483", "0.64672446", "0.6463797", "0.6463797", "0.6463797", "0.64625216", "0.6458961", "0.6443998", "0.64332575", "0.64281917", "0.64281917", "0.64281917", "0.6427852", "0.64181423", "0.6410478", "0.64049983", "0.6398136", "0.6382244", "0.6377978", "0.63418084", "0.63314885", "0.63212824", "0.6321138", "0.63189775", "0.63041395", "0.6300652", "0.6300562" ]
0.7381783
8
Construct url from pattern
def url(value, link_pattern) link_pattern.sub("{}", value) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_url url, text\n scheme, url, = parse_url url\n\n \"[#{text.sub(%r{^#{scheme}:/*}i, '')}](#{url})\"\n end", "def url(name, *params)\n params.map! do |param|\n if param.is_a?(Hash)\n param[:format] = param[:format].to_s if param.has_key?(:format)\n param.each { |k,v| param[k] = v.to_param if v.respond_to?(:to_param) }\n end\n end\n url = router.generator.generate(name, *params)\n uri_root != \"/\" ? uri_root + url : url\n end", "def make_url(path, params, feed='')\n feed = '/' + feed unless feed.empty?\n \"#{BASE_URL}#{path}#{feed}?#{URI.encode_www_form(params)}\"\nend", "def to_substituted_uri\n url = pattern\n substitutions.each_pair do |slug, value|\n url = url.sub(slug, value)\n end\n begin\n Addressable::URI.parse(url)\n rescue Addressable::URI::InvalidURIError\n raise SitePrism::InvalidUrlMatcher, 'Could not automatically match your URL. Note: templated port numbers are not currently supported.'\n end\n end", "def generate_url(url, params = {})\n uri = URI(url)\n uri.query = params.to_query\n uri.to_s\n end", "def make_url(params)\n escaped_params = params.sort_by { |k,v| k.to_s }.map do |k,v|\n \"#{URI.escape k.to_s}=#{URI.escape v.to_s}\"\n end\n\n url = @url.dup\n url.query = escaped_params.join '&'\n return url\n end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end", "def build_url(path, params={})\n full_path = @uri.path + path\n full_url = \"#{@uri.scheme}://#{@uri.host}\"\n full_url += \":#{@uri.port}\" if @uri.port\n full_url += super(full_path, params, @uri.query)\n end", "def generate_url(url, params = {})\n uri = URI(url)\n\n res = \"#{uri.scheme}://#{uri.host}\"\n res += \":#{uri.port}\" if (uri.port and uri.port != 80 and uri.port != 443)\n res += \"#{uri.path}#\" if uri.path\n res += \"#{uri.fragment}\" if uri.fragment\n res += \"?#{params.to_query}\"\n\n return res\n end", "def generate_url(url, params = {})\n uri = URI(url)\n if Settings.get_params_char == '#'\n uri.fragment = params.to_query\n else\n uri.query = params.to_query\n end\n uri.to_s\n end", "def create_url(subpath='')\n paths = [ api_version, resources_path, subpath ]\n paths.select{|s| s != ''}.join('/')\n end", "def build_url(path, params = {})\n path = path.sub(%r{\\A/}, '')\n params = params.merge(access_token: @access_token)\n URL_TEMPLATE.expand(path: path, query: params)\n end", "def generate_url\n\t\tself.url ||= name.parameterize\n\tend", "def generate_url(url, params = {})\n uri = URI(url)\n\n res = \"#{uri.scheme}://#{uri.host}\"\n res += \":#{uri.port}\" if (uri.port and uri.port != 80 and uri.port != 443)\n res += \"#{uri.path}\" if uri.path\n res += \"#{uri.fragment}\" if uri.fragment\n res += \"?#{params.to_query}\"\n\n return res\n end", "def url(*args)\n named_route, params, recall, options = extract_params!(*args)\n\n options[:parameterize] ||= lambda { |name, param| Utils.escape_uri(param) }\n\n unless result = generate(:path_info, named_route, params, recall, options)\n return\n end\n\n uri, params = result\n params.each do |k, v|\n if v\n params[k] = v\n else\n params.delete(k)\n end\n end\n\n uri << \"?#{Utils.build_nested_query(params)}\" if uri && params.any?\n uri\n end", "def reg_url; /(.+)/; end", "def reg_url; /(.+)/; end", "def build_url(query_params: nil)\n url = [add_version(''), *@url_path].join('/')\n url = build_query_params(url, query_params) if query_params\n URI.parse(\"#{@host}#{url}\")\n end", "def url(*args)\n params = args.last.is_a?(Hash) ? args.pop : {}\n fragment = params.delete(:fragment) || params.delete(:anchor)\n path = make_path_with_params(args, value_to_param(params))\n rebase_url(fragment ? path << '#' << fragment.to_s : path)\n end", "def build_url(path, params={})\n full_path = @uri.path + path\n\n super full_path, params, @uri.query\n end", "def build_url(params)\n \"#{@base_url}?#{params.to_query}\"\n end", "def build_url(vars = {})\n \"/\" + path_spec.map do |p|\n case p\n when String\n p\n when Symbol\n vars.fetch(p)\n end\n end.join(\"/\")\n end", "def make_url(method, params = nil)\n escaped_params = expand_params(params).map do |k,v|\n k = URI.escape(k.to_s).gsub(';', '%3B').gsub('+', '%2B').gsub('&', '%26')\n v = URI.escape(v.to_s).gsub(';', '%3B').gsub('+', '%2B').gsub('&', '%26')\n \"#{k}=#{v}\"\n end\n\n query = escaped_params.join '&'\n\n url = @url + \"./#{method}\"\n url.query = query\n return url\n end", "def url_for(string); end", "def url_pattern\n %r{\n (?:^|\\W) # beginning of string or non-word char\n (?:(#{qualifier_regex})(?:\\s))? # qualifier (optional)\n https://github.com/\n (#{REPOSITORY_NAME}) # repository name\n /(?:issues|pulls)/\n (\\d+) # issue number\n (?=\n \\.+[ \\t]| # dots followed by space or non-word character\n \\.+$| # dots at end of line\n [^0-9a-zA-Z_.]| # non-word character except dot\n $ # end of line\n )\n }ix\n end", "def build_url(url_suffix)\n return @base_url+url_suffix\nend", "def construct_url(uri)\n \"#{uri.scheme}://#{uri.host}#{uri.path}\"\n end", "def format_url(url_params)\n url_base = \"https://agencyrecruiting.apihealthcare.com/UAM2/index.cfm\"\n args = format_arguments(url_params)\n url = \"#{url_base}?#{args}\"\n return url\n end", "def build_as_url\n URI(build_as_string)\n rescue Urb::InvalidUrl => e\n URI('/')\n end", "def generate_url(template); end", "def build_uri_path(path, params)\n path + handle_params(params)\n end", "def build_call_url(word)\r\n\t\t\tURI.parse(URI.escape(base_url + word))\r\n\t\tend", "def compose_url(url)\n abort \"Invalid URL: #{url}\" unless validate_url(url)\n\n query = {}\n query['map'] = 'true' if options['map']\n query['api_key'] = options['key'] if options['key']\n query['compression'] = options['compress'] if options['compress']\n\n uri = URI(url)\n uri.path = '/files'\n uri.query = URI.encode_www_form(query)\n uri.to_s\n end", "def url(*path)\n [\"#{request.scheme}://#{request.host_with_port}\", *path].join('/')\n end", "def url_pattern\n %r{#{services_url}}\n end", "def sub_url(url, param_map)\n param_map.reduce(url) do |new_url, (param, value)|\n new_url.gsub(\":#{param}\", value)\n end\n end", "def build_url url='', params={}, string_query=''\n queries = [string_query, hash_to_query(params)]\n queries.delete_if{|i| i.to_s.empty?}\n url += \"?#{queries.join('&')}\" unless queries.empty?\n url\n end", "def construct_target_url(api, query_params)\r\n\t\t\t\tpath = %(#{URL}/#{api}/#{VERSION})\r\n\t\t\t\tquery_string = %(?#{query_params}&apikey=#{API_KEY})\r\n\r\n\t\t\t\tURI.encode(path+query_string)\r\n\t\t\tend", "def url_for(*args)\n options = {}\n options = args.pop if args.last.kind_of?(Hash)\n\n segments = []\n segments << url_options[:base_path] if url_options[:base_path]\n segments << prefix if prefix\n segments << version\n segments += args.collect {|part| part.respond_to?(:to_param) ? part.to_param : part.to_s }\n\n url = \"\"\n url << url_options.fetch(:protocol, \"http\").to_s << \"://\"\n url << url_options.fetch(:host, env[\"SERVER_NAME\"])\n\n port = url_options.fetch(:port, env[\"SERVER_PORT\"]).to_i\n url << \":\" << port.to_s if port.nonzero? && port != 80\n\n url << Rack::Mount::Utils.normalize_path(segments.join(\"/\"))\n url << \"?\" << options.to_param if options.any?\n url\n end", "def url_regexp\n raise NotImplementedError\n end", "def build_url(action)\n \"#{@base_url}#{action}\"\n end", "def url(path, params = {})\n params = params.inject({}, &@@stringify)\n path = path.gsub(@@placeholder) { params.delete($1, &@@required) }\n params = params.inject('', &@@parameterize)\n [path, params].reject(&:nil?).reject(&:empty?).join('?')\n end", "def build_url(host)\n host.protocol + host.url\n end", "def create_url(parameters)\n # \"/badges/add/:as\n path = uri_path\n if path =~ /:/\n # [\"\", \"badges\", \"add\", \":as\"]\n parts = path.split('/')\n path = \"\"\n parts.each do |part|\n next if part == \"\" or part.nil?\n path << '/'\n if part =~ /:/\n part_name = /:(.*)/.match(part)[1]\n # parameters[:as]\n part = parameters[part_name.to_sym]\n end\n path << part\n end\n end\n url = \"#{Kickit::Config.rest_base_uri}#{path}\"\n end", "def create_url(api, options)\n options = options.symbolize_keys\n \n path = APIS[api].dup\n variable_regex = /\\$\\{(.+?)\\}/m\n \n while match = variable_regex.match(path)\n variable_name = $1.to_sym\n \n if options.has_key?(variable_name)\n path.sub!(variable_regex, options.delete(variable_name).to_s)\n else\n raise ArgumentError.new(\"Required argument missing: #{variable_name}\")\n end\n end\n \n url = self.base_url + '/' + path\n url + '?' + options.to_query\n end", "def prepare_url(parameter)\n \"#{URL}#{parameter}\"\n end", "def url_to *args\n path = path_to(*args)\n\n return path if path =~ /\\A[A-z][A-z0-9\\+\\.\\-]*:/\n\n uri = [host = \"\"]\n host << \"http#{'s' if @request.ssl?}://\"\n\n if @request.forwarded? || @request.port != (@request.ssl? ? 443 : 80)\n host << @request.host_with_port\n else\n host << @request.host\n end\n\n uri << @request.script_name.to_s\n uri << path\n File.join uri\n end", "def url_for(str)\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s), str)\n end", "def to_uri(url, params = {})\n return \"\" if url.blank?\n\n var_values = params.inject(\"\") { |str, h| str += \"#{h[0]}=#{h[1]}&\" }\n url += \"?\" + URI.encode(var_values.chomp(\"&\")) if !var_values.blank?\n \n url\n end", "def url(*path_parts)\n u = '/' + path_parts.join(\"/\")\n u += '.html' unless u =~ /\\.\\w{2,4}$/\n u\n end", "def generate_uri(url, options)\n uri = API_URL + url\n options.each do |key,value|\n uri += uri.include?(\"?\") ? \"&#{key}=#{value}\" : \"?#{key}=#{value}\"\n end\n URI.parse uri\n end", "def gen_url url, text\n scheme, url, id = parse_url url\n\n if %w[http https link].include?(scheme) and\n url =~ /\\.(gif|png|jpg|jpeg|bmp)$/ then\n \"<img src=\\\"#{url}\\\" />\"\n else\n if scheme != 'link' and %r%\\A((?!https?:)(?:[^/#]*/)*+)([^/#]+)\\.(rb|rdoc|md)(?=\\z|#)%i =~ url\n url = \"#$1#{$2.tr('.', '_')}_#$3.html#$'\"\n end\n\n text = text.sub %r%^#{scheme}:/*%i, ''\n text = text.sub %r%^[*\\^](\\d+)$%, '\\1'\n\n link = \"<a#{id} href=\\\"#{url}\\\">#{text}</a>\"\n\n link = \"<sup>#{link}</sup>\" if /\"foot/ =~ id\n\n link\n end\n end", "def makeURL(path)\n \"#{self.api_endpt + path}?token=#{self.token}\"\n end", "def reg_url2; /(.+)\\//; end", "def reg_url2; /(.+)\\//; end", "def build_url(action, query=nil)\n url = URI.parse($base_url).merge(action).to_s\n url = OpenID::Util.append_args(url, query) unless query.nil?\n return url\n end", "def complete_url(url, base)\n if url.start_with?(\"/\")\n resource_uri = base + url\n else\n resource_uri = url\n end \n return resource_uri\n end", "def url(uri=nil)\n @uri = Addressable::Template.new(uri.gsub(/:(?![0-9])(\\w+)/) { \"{#{$1}}\" }) unless uri.nil?\n @uri\n end", "def build_url(url)\n # this will remove any of the blank spaces. There is no reason for blank space in the url or brake lines\n url = url.gsub(\" \", \"\").gsub(/\\n/, \"\").gsub(/\\r/, \"\")\n \n \n # Step one tells me that the uri does have a http or a https to use\n one = url.slice(/(https|http)/)\n if one.nil?\n request_response = \"http://\"\n uri_split = url.split(\".\")\n else\n request_response = url.split(\"//\")[0] + \"//\"\n uri_split = url.split(\"//\")[1].split(\".\")\n end\n \n # Step two and three check for the .com and www at the begging. \n # The count is to make sure that is it missing something and not just taking the place of a sub domain.\n if uri_split.count <= 2\n two = url.slice(/(com|gov|org|net|mobi)/)\n three = url.slice(/(www)/)\n # don't add if the thing is there\n if three.nil?\n uri_split.unshift(\"www\")\n end\n if two.nil?\n uri_split << \"com\"\n end\n end\n path_seperator = uri_split[uri_split.length - 1].split(/\\//)\n if path_seperator && path_seperator.length <= 1\n uri_split[uri_split.length - 1] = path_seperator\n end\n string = uri_split.map{ |split| split }.join(\".\").to_s\n # I can't figure this part out but it sucks\n path_thing = string.split(/\\//) \n unless url.blank?\n url = request_response + string\n end\n end", "def url(name, params={})\n Merb::Router.generate(name, params)\n end", "def create_url(keyword)\n base_url = 'https://yandex.ru/search/xml?'\n tail_url = '&groupby=attr%3Dd.mode%3Ddeep.groups-on-page%3D100.docs-in-group%3D1'\n query_url = URI.encode_www_form([['user', @user], ['key', @key], ['query', keyword], ['lr', @region]])\n\n base_url + query_url + tail_url\n end", "def create_url\n\t\tif self.url.blank?\n\t\t\tself.url = self.title.downcase.gsub(/[^a-zA-Z0-9]+/, \"-\").chomp(\"-\")\n\t\tend\t\n\tend", "def url(prefix, stem)\n if prefix == ''\n \"/#{stem}/#{self.id}\"\n else\n \"#{prefix}/#{stem}/#{self.id}\"\n end\n end", "def scope_url_pattern\n return @scope_url_pattern if @scope_url_pattern\n\n domains = [uri.host + uri.path]\n\n domains += if scope.domains.empty?\n Array(scope.invalid_domains[1..-1])\n else\n Array(scope.domains[1..-1]).map(&:to_s) + scope.invalid_domains\n end\n\n domains.map! { |d| Regexp.escape(d.delete_suffix('/')).gsub('\\*', '.*').gsub('/', '\\\\\\\\\\?/') }\n\n domains[0].gsub!(Regexp.escape(uri.host), \"#{Regexp.escape(uri.host)}(?::\\\\d+)?\") if uri.port\n\n @scope_url_pattern = %r{https?:\\\\?/\\\\?/(?:#{domains.join('|')})\\\\?/?}i\n end", "def generate(params = {}, fallback = {})\n raise \"Cannot generate regexp Routes\" if regexp?\n query_params = params.dup if params.is_a? Hash\n url = @segments.map do |segment|\n value =\n if segment.is_a? Symbol\n if params.is_a? Hash\n params[segment] || fallback[segment]\n query_params.delete segment\n else\n if segment == :id && params.respond_to?(:to_param) \n params.to_param\n elsif segment == :id && params.is_a?(Fixnum)\n params\n elsif params.respond_to?(segment)\n params.send(segment)\n else\n fallback[segment]\n end\n end\n elsif segment.respond_to? :to_s\n segment\n else\n raise \"Segment type '#{segment.class}' can't be converted to a string\"\n end\n (value.respond_to?(:to_param) ? value.to_param : value).to_s\n end.join\n if query_params && !query_params.empty?\n url += \"?\" + Merb::Request.params_to_query_string(query_params)\n end\n url\n end", "def build_url(update)\n p = build_params(update)\n\n # Building the URL this way because I want the params in a certain order\n # url_for() orders params alphabetically because hashes are ordered\n new_url = '/'\n new_url << \"category/#{p[:slug]}\" if p[:slug]\n new_url << \"?search=#{p[:search]}\" if p[:search]\n if p[:sort] && p[:sort] != 'weight'\n new_url << (new_url =~ /\\?/ ? '&' : '?')\n new_url << \"sort=#{p[:sort]}\"\n end\n if p[:page] && p[:page] != 1\n new_url << (new_url =~ /\\?/ ? '&' : '?')\n new_url << \"page=#{p[:page]}\"\n end\n\n new_url\n end", "def to_url\n port = @attrs[:port]\n url = \"#{@attrs[:protocol]}://#{@attrs[:host]}\"\n url << \":#{port}\" if port\n url << \"#{@attrs[:path]}?\"\n\n params_str = params.map {|name, value|\n \"#{CGI.escape(name)}=#{CGI.escape(value)}\"\n }.join('&')\n url << params_str\n end", "def url_for(*args)\n options = args.extract_options!.with_indifferent_access\n # leading colon\n port = options[:port].blank? ? nil : \":#{options[:port]}\"\n # leading question mark\n query = options[:query].blank? ? nil : \"?#{options[:query]}\"\n # leading octothorpe\n fragment = options[:fragment].blank? ? nil : \"##{options[:fragment]}\"\n URI(\"#{url_scheme}://#{fqdn}#{port}#{app_root}#{options[:path]}#{query}#{fragment}\")\n end", "def build_uri\n URI.parse(base_url + \"?\" + query_params)\n end", "def _url\n URI.join(domain, path_gen.for_uri)\n end", "def normalize_path(url); end", "def normalize_path(url); end", "def build_url(params_hash)\n param_string = '?' + params_hash.merge(:LicenseKey => @license_key).map { |k, v| \"#{::CGI.escape(k.to_s)}=#{::CGI.escape(v.to_s)}\" }.sort.join('&')\n URI.parse(File.join(endpoint_url, @name + param_string))\n end", "def gen_url(url, appended_val, test)\n\n\t\tif(!url.include? 'http')\n \t\turl = \"http://\" + url\n ht_flag = \"T\" #Added to check if there is an http added automatically to a vanity/pixel url\n\t\tend\n\n\t\t# Generate the URI Objects\n\t\turl_uri = URI.parse(URI.encode(url.to_s.strip))\n\t\tappend_uri = URI.parse(URI.encode(appended_val.to_s.strip.gsub(/^(&)/,'?')))\n\n\t\turl_query = url_uri.query\n\t\tappend_query = append_uri.query\n \n\n\t\t# Get the parameters from each\n\t\turl_parameters = CGI.parse(url_query) if(url_query)\n\t\tappend_parameters = CGI.parse(append_query) if(append_query)\n\n\t\t# merge the parameters\n\t\tparameters = {}\n\t\tparameters.merge!(url_parameters) if(url_parameters)\n\t\tparameters.merge!(append_parameters) if(append_parameters)\n\n\t\t# add test value if needed\n\t\tif(test)\n\t\t\tparameters.merge!({\"mmcore.gm\" => [\"2\"]})\n\t\tend\n\n\t\t# change hash to string format\n\t\tquery_string = hash_to_querystring(parameters)\n\n\n\t\t# clean out spare '/' marks\n\t\tpath_url = url_uri.path\n\t\tpath_append = append_uri.path\n \n\t\t# combine everything back into URI\n\t\tpath_url = '' if(path_url == '/')\n\t\tpath_append = '' if(path_append == '/')\n \n\t\t#url_uri.query = query_string \n \n\t\tcombine_path = path_url + path_append\n\t\tcombine_path = '/' if combine_path[0] != '/'\n\n url_uri.path = combine_path\n url_uri.query = nil\n final_url = url_uri.to_s\n\t\tfinal_url = [url_uri.to_s, query_string].join('?') if(!query_string.empty?)\n\t\t# return the URI as string\n # Adding to remove an extra http added to the vanity url, linked to 41, here from 88-93\n if (ht_flag != 'T')\n return final_url.to_s.gsub('%7C','|').gsub('%23','#').gsub('%25','%') \n else\n return final_url.to_s.gsub('%7C','|').gsub('%23','#').gsub('%25','%').gsub('http://','')\n end\n #return final_url.to_s.gsub('%7C','|').gsub('%23','#').gsub('%25','%')\n\tend", "def build_url(url, params = nil)\n if params.respond_to? :each\n params.each do |key, value|\n # Convert dates to CC date format\n if value.respond_to? :iso8601\n params[key] = value.iso8601\n end\n\n if key.to_s == 'next' && value.match(/^.*?next=(.*)$/)\n params[key] = $1\n end\n end\n else\n params ||= {}\n end\n url + '?' + Util::Helpers.http_build_query(params)\n end", "def create_uri(url, parms)\n uri = URI(url)\n uri.query = URI.encode_www_form(parms)\n uri\nend", "def create_url\n #we trim away all periods and break apart the name by spaces to use to acquire the url of the poet in the Poetry Foundation website\n name_no_periods = @name.tr(\".\", \"\")\n name_no_periods = name_no_periods.split(\" \")\n\n #we use name_no_periods to generate the url for the poet (example url: \"https://www.poetryfoundation.org/poets/ben-jonson\")\n url = \"https://www.poetryfoundation.org/poets/\"\n name_no_periods.each { |part| url = \"#{url}#{part}-\"}\n\n #this leaves an extra hyphen at the end, but we can just cut that off in the return.\n url = url.chop\n end", "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 gen_url(url, text)\n if url =~ /([A-Za-z]+):(.*)/ then\n type = $1\n path = $2\n else\n type = \"http\"\n path = url\n url = \"http://#{url}\"\n end\n\n if type == \"link\" then\n url = if path[0, 1] == '#' then # is this meaningful?\n path\n else\n self.class.gen_relative_url @from_path, path\n end\n end\n\n if (type == \"http\" or type == \"link\") and\n url =~ /\\.(gif|png|jpg|jpeg|bmp)$/ then\n \"<img src=\\\"#{url}\\\" />\"\n else\n \"<a href=\\\"#{url}\\\">#{text.sub(%r{^#{type}:/*}, '')}</a>\"\n end\n end", "def build_url(url)\n return url unless http_auth\n\n protocol, uri = detect_protocol(url)\n username, password = [:username, :password].map { |part| CGI.escape http_auth[part] }\n \"#{protocol}#{username}:#{password}@#{uri}\"\n end", "def format_url\n self.url.chomp\n if self.url.match(\"https://\") || self.url.match(\"http://\")\n else self.url = \"http://\" + url\n end\n self.url\n end", "def url_for(path)\n url = scheme + '://' + host\n\n if scheme == 'https' && port != 443 ||\n scheme == 'http' && port != 80\n url << \":#{port}\"\n end\n\n url << path\n end", "def to_param\n if url\n url.gsub(/[\\/\\ \\.]/,'-')+\"-\"+id.to_s\n end\n end", "def url(params)\n \"%s%s\" % [config['endpoint'], query_string(params)]\n end", "def make_url(string)\n puts \"not implemented\"\nend", "def url_create(state_code, city_name)\n 'http://en.m.wikipedia.org/wiki/' + self.url_suffix_create(state_code, city_name)\n end", "def build_uri(path)\n path = path.to_s\n unless path.match(/^\\//)\n path = \"/#{path}\"\n end\n base_uri + path\n end", "def create_short_url(url_params) \n url = Url.new(url_params)\n url.suffix= url.create_suffix(url_params[:longurl],0)\n while url.unique(url.suffix) == false\n url.suffix = url.create_suffix(url_params[:longurl],1)\n end\n domain = Domainatrix.parse(url_params[:longurl]).domain + '.' + Domainatrix.parse(url_params[:longurl]).public_suffix\n short_domain = ShortDomain.where(domain: domain).first[:prefix]\n url.shorturl = \"http://\" + short_domain +'/'+ url.suffix\n if url.save\n return url\n else\n return nil\n end\n end", "def URI(url); end", "def build_uri(params = {}, specificator = nil, action = nil)\n params.merge!(api_token: ENV['pipedrive_api_token'])\n query_string = params.map{|k,v|\"#{k}=#{v}\"}.join('&')\n plural_resource_name = @resource_name == 'person' ? 'persons' : @resource_name.pluralize\n uri = URI(\"#{HOST}/#{[plural_resource_name, specificator, action].compact.join('/')}?#{query_string}\")\n end", "def inject_url(url, record)\n url.gsub(%r{(/id/?)}, \"/#{record.id}/\")\n end", "def url_for_params(params)\n routes.each do |route|\n if params_match_options?(params, route[1])\n return path_and_params(params, route[0], route[1])\n end\n end\n\n return '/', params\n end", "def url_for(path)\n url = scheme + '://' + host\n\n if scheme == 'https' && port != 443 ||\n scheme == 'http' && port != 80\n url << \":#{port}\"\n end\n\n url << path\n end", "def make_regexp(schemes = nil)\n unless schemes\n @regexp[:ABS_URI_REF]\n else\n /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x\n end\n end", "def make_regexp(schemes = nil)\n unless schemes\n @regexp[:ABS_URI_REF]\n else\n /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x\n end\n end", "def url(*names)\n params = names.extract_options! # parameters is hash at end\n name = names.join(\"_\").to_sym # route name is concatenated with underscores\n if params.is_a?(Hash)\n params[:format] = params[:format].to_s if params.has_key?(:format)\n params.each { |k,v| params[k] = v.to_param if v.respond_to?(:to_param) }\n end\n url = router.generator.generate(name, params)\n url = uri_root + url if defined?(uri_root) && uri_root != \"/\"\n url\n rescue Usher::UnrecognizedException\n route_error = \"route mapping for url(#{name.inspect}) could not be found!\"\n raise Padrino::Routing::UnrecognizedException.new(route_error)\n end", "def generate_url(path, params={}, options={})\n Hubspot::Config.ensure! :hapikey\n path = path.clone\n params = params.clone\n base_url = options[:base_url] || Hubspot::Config.base_url\n params[\"hapikey\"] = Hubspot::Config.hapikey unless options[:hapikey] == false\n\n if path =~ /:portal_id/\n Hubspot::Config.ensure! :portal_id\n params[\"portal_id\"] = Hubspot::Config.portal_id if path =~ /:portal_id/\n end\n\n params.each do |k,v|\n if path.match(\":#{k}\")\n path.gsub!(\":#{k}\",v.to_s)\n params.delete(k)\n end\n end\n raise(Hubspot::MissingInterpolation.new(\"Interpolation not resolved\")) if path =~ /:/\n query = params.map{ |k,v| param_string(k,v) }.join(\"&\")\n path += \"?\" if query.present?\n base_url + path + query\n end", "def url_(str)\n encoding = str.encoding\n str.b.gsub(/([^ a-zA-Z0-9_.-]+)/) do |m|\n '%' + m.unpack('H2' * m.bytesize).join('%').upcase\n end.tr(' ', '+').force_encoding(encoding)\n end" ]
[ "0.71301776", "0.680903", "0.67298335", "0.6648436", "0.6538054", "0.65193045", "0.6513451", "0.6513451", "0.6513451", "0.6491025", "0.6482116", "0.6476108", "0.6449089", "0.6430525", "0.6430313", "0.6419186", "0.6402814", "0.640198", "0.640198", "0.63851476", "0.63522124", "0.6344284", "0.6336523", "0.6285733", "0.625531", "0.6188503", "0.6123407", "0.6117785", "0.6082797", "0.60760546", "0.60623527", "0.605507", "0.6042376", "0.60316044", "0.60304314", "0.6005207", "0.60009706", "0.598171", "0.59743434", "0.5953417", "0.5952148", "0.59514105", "0.59477264", "0.59467125", "0.5946544", "0.5940257", "0.5934866", "0.5926675", "0.592532", "0.5919915", "0.5909511", "0.5903398", "0.58813804", "0.5881238", "0.5879551", "0.58681273", "0.58681273", "0.5857698", "0.58566976", "0.5840648", "0.5835875", "0.5831641", "0.582895", "0.5824293", "0.58215106", "0.58211815", "0.5820236", "0.58102477", "0.580882", "0.58059645", "0.58018804", "0.57854354", "0.5776844", "0.5776844", "0.57743967", "0.57682115", "0.57669866", "0.57646614", "0.575571", "0.5744968", "0.5732964", "0.5720428", "0.57104903", "0.57065487", "0.5705489", "0.5693929", "0.5681045", "0.5664878", "0.5663926", "0.5661141", "0.5659461", "0.5658656", "0.56561655", "0.5654381", "0.56542915", "0.56452525", "0.56452525", "0.56353205", "0.5632691", "0.56294656" ]
0.6524224
5
Retrieve all CPEs and their associated variants. The 'live' field in the output indicates whether any advisory has been shipped for that CPE and variant. This API does not require authentication. :apiurl: /api/v1/security/cpes :apimethod: GET :apiresponseexample: file:publican_docs/Developer_Guide/api_examples/cpes.json
def cpes @variants = Variant.all.group_by{|variant| variant.cpe || ''}.sort_by{|cpe,v| cpe} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @cps = Cp.all\n end", "def index\n @capexes = Capex.all\n end", "def index\n @pcs = Pc.all\n end", "def vpcs\n @vpcs ||= init_vpcs\n end", "def get_variants\n return [] if is_pdc?\n get_variants_by_package.values.flatten.uniq\n end", "def cpe\n\t\t\t\t\twhere(:reference_name => \"cpe\").select('DISTINCT value')\n\t\t\t\tend", "def index\n @c_povolanis = CPovolani.all\n end", "def index\n @cepas = Cepa.all\n end", "def index\n @csps = Csp.all\n end", "def nested_cpes(children)\n cpes = []\n children.each do |child|\n if child.has_key?('cpe_match')\n child['cpe_match'].each do |cpe_match|\n cpes << cpe_match['cpe23Uri'] if cpe_match.has_key?('cpe23Uri')\n cpes << cpe_match['cpe22Uri'] if cpe_match.has_key?('cpe22Uri')\n end\n elsif child.has_key?('children')\n cpes.push *nested_cpes(child['children']).flatten\n end\n end\n cpes\n end", "def get_cages_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CagesApi.get_cages ...'\n end\n # resource path\n local_var_path = '/inventory/cages'\n\n # query parameters\n query_params = {}\n query_params[:'AmsProtocolId'] = opts[:'ams_protocol_id'] if !opts[:'ams_protocol_id'].nil?\n query_params[:'AmsResearcherId'] = opts[:'ams_researcher_id'] if !opts[:'ams_researcher_id'].nil?\n query_params[:'AmsMouseId'] = opts[:'ams_mouse_id'] if !opts[:'ams_mouse_id'].nil?\n query_params[:'AmsRackId'] = opts[:'ams_rack_id'] if !opts[:'ams_rack_id'].nil?\n query_params[:'AmsRoomId'] = opts[:'ams_room_id'] if !opts[:'ams_room_id'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'CageList')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CagesApi#get_cages\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_available_cartridges\n args = Hash.new\n args['--porcelain'] = true\n args['--with-descriptors'] = true\n result = execute_direct(@@C_CONTROLLER, 'cartridge-list', args, false)\n result = parse_result(result)\n cart_data = JSON.parse(result.resultIO.string)\n cart_data.map! {|c| OpenShift::Cartridge.new(YAML.load(c))}\n end", "def index\n @vpcs = Vpc.order(:name).all\n end", "def index\n @vas_responses = VasResponse.all\n end", "def index\n @search = Scomp.search(params[:q])\n @scomps = @search.result\n end", "def index\n @pecas = Peca.find :all, :order => :produto_id\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pecas }\n end\n end", "def index\n @socio_cpfs = SocioCpf.all\n end", "def get_computes(request)\n # --- Get User's VMs ---\n vmpool = VirtualMachinePoolOCCI.new(\n @client,\n POOL_FILTER)\n\n # --- Prepare XML Response ---\n rc = vmpool.info\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n return to_occi_xml(vmpool, :code=>200, :verbose=>request.params['verbose'])\n end", "def index\n @selected_options_of_pcs = SelectedOptionsOfPc.all\n end", "def index\n @socio_spcs = SocioSpc.all\n end", "def get_copays\n raise InvalidVBSRequestError, request_data.errors unless request_data.valid?\n\n response = request.post('/Prod/GetStatementsByEDIPIAndVistaAccountNumber', request_data.to_hash)\n\n ResponseData.build(response: response).handle\n end", "def index\n @prod_cotis = ProdCoti.all\n end", "def cpes_affected\n vendor_data = @entry.dig('cve', 'affects', 'vendor', 'vendor_data') || []\n vendor_data.map do |vendor_data_entry|\n vendor_name = vendor_data_entry['vendor_name']\n vendor_data_entry\n .fetch('product', {})\n .fetch('product_data', [])\n .map {|product_data_entry| \"#{vendor_name}:#{product_data_entry['product_name']}\"}\n end.flatten.uniq\n end", "def get_all_peptide_members \n raise \"This Ensembl::Compara::Member is not a gene!\" unless self.source_name == \"ENSEMBLGENE\"\n return Ensembl::Compara::Member.find_all_by_gene_member_id(self.member_id) \n end", "def index\n @pe_exchange_products = PeExchangeProduct.all.page(params[:page]).per(params[:per_page])\n respond_to do |format|\n format.html\n format.json { render json:\n list_json(@pe_exchange_products, :include => [:pe_product])\n }\n end\n end", "def list_pucs\n\treturn if authorise_for_web(program_name?,'read') == false \n\n \tif params[:page]!= nil \n\n \t\tsession[:pucs_page] = params['page']\n\n\t\t render_list_pucs\n\n\t\t return \n\telse\n\t\tsession[:pucs_page] = nil\n\tend\n\n\tlist_query = \"@puc_pages = Paginator.new self, Puc.count, @@page_size,@current_page\n\t @pucs = Puc.find(:all,\n\t\t\t\t :limit => @puc_pages.items_per_page,\n\t\t\t\t :offset => @puc_pages.current.offset)\"\n\tsession[:query] = list_query\n\trender_list_pucs\nend", "def get_comps(zpid,count)\n url_s=@@zillow_webservice_url+'GetComps.htm?zws-id='+@zwsid+'&zpid='+zpid.to_s+'&count='+count.to_s\n fetch_result(url_s)\n end", "def get_vpcs\n resp = client.describe_vpcs\n return resp.vpcs.map { |vpc| vpc.vpc_id }\n end", "def index\n @proccs = Procc.all\n end", "def get_results\n response = @api.get(@cloud.url(:result, @process_id), no_callbacks: true, token: @cloud.access_token.token)\n @results = []\n response.each do |res|\n @results.push(CopyleaksApi::ResultRecord.new(res))\n end\n @results\n end", "def puppet_catalog_api\n {\n 2 => {\n url: \"https://#{@options[:puppet_master]}/#{@options[:branch]}/catalog/#{@node}\",\n parameters: {\n 'facts_format' => 'pson',\n 'facts' => CGI.escape(@facts.fudge_timestamp.without('trusted').to_pson),\n 'transaction_uuid' => SecureRandom.uuid\n }\n },\n 3 => {\n url: \"https://#{@options[:puppet_master]}/puppet/v3/catalog/#{@node}\",\n parameters: {\n 'environment' => @options[:branch],\n 'facts_format' => 'pson',\n 'facts' => CGI.escape(@facts.fudge_timestamp.without('trusted').to_pson),\n 'transaction_uuid' => SecureRandom.uuid\n }\n }\n }\n end", "def index\n @variants =\n if @product\n @product.variants.page params[:page]\n else\n Variant.page params[:page]\n end\n end", "def index\n @cets = Cet.all\n end", "def fetch_applicable_aptcs\n raise \"Cannot process without selected_aptc: #{@selected_aptc} and product_ids: #{@product_ids}\" if @selected_aptc.nil? || @product_ids.empty?\n\n @available_aptc ||= fetch_available_eligibility[:total_available_aptc]\n\n # TODO: Return a has of plan_id, applicable aptcs.\n @product_ids.inject({}) do |products_aptcs_hash, product_id|\n product_aptc = applicable_aptc_hash(product_id)\n products_aptcs_hash.merge!(product_aptc) unless product_aptc.empty?\n products_aptcs_hash\n end\n end", "def fetch_applicable_aptcs\n raise \"Cannot process without selected_aptc: #{@selected_aptc} and product_ids: #{@product_ids}\" if @selected_aptc.nil? || @product_ids.empty?\n\n @available_aptc ||= fetch_available_eligibility[:total_available_aptc]\n\n # TODO: Return a has of plan_id, applicable aptcs.\n @product_ids.inject({}) do |products_aptcs_hash, product_id|\n product_aptc = applicable_aptc_hash(product_id)\n products_aptcs_hash.merge!(product_aptc) unless product_aptc.empty?\n products_aptcs_hash\n end\n end", "def index\n @candidate_experiences = @candidate.experiences\n end", "def index\r\n @compositions = Composition.all\r\n end", "def index\n @description_of_pcs = DescriptionOfPc.all\n end", "def get_cages(opts = {})\n data, _status_code, _headers = get_cages_with_http_info(opts)\n data\n end", "def all_cops?; end", "def all\n @carts = Cart.get_all_of_carts(@user, params[:page])\n if @carts.present?\n @carts\n else\n @object = 'Cart'\n render \"api/v1/errors/404\", status: 401\n end\n end", "def index\n @precio_paquetes = PrecioPaquete.all\n end", "def index\n # @cov_pdps = CovPdp.all.page(params[:page])\n @q = CovPdp.ransack(params[:q])\n @cov_pdps = @q.result(distinct: true).order('added_at DESC').page(params[:page])\n\n authorize @cov_pdps\n end", "def variants\n variants = []\n self.cart.each do |variant_id|\n variants << Variant.find(variant_id)\n end\n variants.sort_by! { |variant| variant.category.id }\n end", "def index\n @peg_contact_infos = PegContactInfo.all\n end", "def index\n @psses = Pss.all\n end", "def index\n @pokemon_evolutions = PokemonEvolution.all\n end", "def index\n @compositions = Composition.all\n end", "def index\n @cpanel_promotions = Cpanel::Promotion.all\n end", "def index\n @grapes = Grape.all\n end", "def catalogs\n return @catalogs\n end", "def index\n @products = @co.products\n end", "def index\n @proveedor_paquetes = ProveedorPaquete.all\n end", "def espacios_disponibles_carros\n Space.where(sp_state: false, sp_type: 'CARRO').count\n end", "def index\n @parte_cuerpos = ParteCuerpo.all\n end", "def index\n tags = Array.wrap params.permit(:tags)[:tags]\n @clips = @allclips = Clip.where(session_id: session.id)\n @clips = @allclips.tagged_with(tags, any: true) if tags.any?\n @available_tags = Clip.available_tags_for(session.id)\n end", "def index\n @clips = Clip.all\n respond_to do |format|\n format.json { render json: @clips.to_json(:include => [:sound_board_clip_sources, :image_playing, :image_default ]) }\n format.xml { render xml: @clips }\n end\n end", "def index\n @ipc_all_acs = IpcAllAc.all\n end", "def index\n @copons = Copon.all\n end", "def prince_resolve\n puts \"\\n--------------------------------\"\n puts \"Resolving isoforms...\\n\\n\"\n \n header = %w(title search_engines pep qvalue)\n cutoff = config_value(\"//Refiner/@cutoff\").to_f\n files = []\n \n @samples.each do |key, value|\n value.combined.each {|file| files << file}\n end\n \n official_filenames = []\n all_prots_by_id = {}\n peptide_hits = files.map do |file|\n base = File.basename(file).chomp(File.extname(file))\n official_filenames << base\n IO.readlines(file).map do |line|\n t = line.chomp.split(\"\\t\")\n pep = t[2].to_f\n if pep < cutoff\n hit = PeptideHit.new\n hit.title = t[0]\n hit.search_engines = t[1].split('+')\n hit.charge = t[0].split('.')[-1]\n hit.pep = pep\n hit.qvalue = t[3].to_f\n hit.aaseq = t[4]\n hit.prots = t[5..-1].map do |id|\n prot = \n if all_prots_by_id.key?(id)\n all_prots_by_id[id]\n else\n all_prots_by_id[id] = Protein.new(id, nil, [])\n end\n prot.peps << hit\n prot\n end\n hit.filename = base\n hit\n end\n end.compact\n end\n \n minimum_proteins!(peptide_hits.flatten)\n end", "def index\n @pcr_inspections = PcrInspection.all\n end", "def index\n @ecopoints = Ecopoint.all\n end", "def catalogs\n path = \"#{api_root}/index/catalogs\"\n process_api_request(:get, path)\n end", "def index\n @placas = Placa.all\n end", "def index\n @papels = Papel.all\n end", "def get_all options=nil\n url = [\"/v1/catalog/services\"]\n url += check_acl_token\n url << use_named_parameter('dc', options[:dc]) if options and options[:dc]\n begin\n ret = @conn.get concat_url url\n rescue Faraday::ClientError\n raise Diplomat::PathNotFound\n end\n\n return OpenStruct.new JSON.parse(ret.body)\n end", "def show\n @establec_ppal = EstablecPpal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @establec_ppal }\n end\n end", "def evolution_request(species, name)\n\t\tevolution_request = HTTParty.get(\"http://pokeapi.co/api/v2/evolution-chain/#{species.evolution_id}\")\n\t\tevolutions = PokeapiEvolutions.new(evolution_request, name)\n\t\treturn evolutions\n\tend", "def index\n @cp_changes = CpChange.all\n\n render json: @cp_changes\n end", "def index\n @cp3s = Cp3.all\n end", "def index\n @peeps = Peep.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @peeps }\n end\n end", "def pets\n\t\t@pets_list\n\tend", "def index\n @prospecto_meta_largo_plazos = ProspectoMetaLargoPlazo.all\n end", "def index\n @profanes = Profane.all\n end", "def index\n @aws_vpc_tags = AwsVpcTag.all\n end", "def index\n if params[:search].blank?\n respond_to do |format|\n format.html { redirect_to home_index_path, alert: 'Please fill with CEP.' }\n end\n else\n @cep = Cep.find_by_code(params[:search])\n if @cep.nil? || @cep.supermarkets.empty?\n respond_to do |format|\n format.html { redirect_to home_index_path, alert: 'There is no supermarkets in this area.' }\n end\n else\n @supermarkets = @cep.supermarkets\n end\n end\n end", "def index\n @ppages = Ppage.all\n end", "def all_cops\n @all_cops ||= `#{options[:cmd]} --show-cops --force-default-config`.lines.select { |l| l.match(/^\\w/) }\n end", "def index\n @pucs = Puc.all\n end", "def index\n @pocs = Poc.all\n end", "def index\n @proposal_positions = ProposalPosition.all\n end", "def fetch_cards\n log 'fetch_cards'\n data = get(PRODUCTS_ENDPOINT, fields: { carteras: false,listaSolicitada: 'TODOS',indicadorSaldoPreTarj: false })\n data['datosSalidaTarjetas']['tarjetas'].map{ |data| build_card(data) }\n end", "def solutions\n @products = website.products\n end", "def index\n @catalogs = Catalog.list_public()\n end", "def index\n @copropietarios = Copropietario.all\n end", "def index\n @otg_crypsts = OtgCrypst.all\n end", "def index\n @propriedades = Propriedade.all\n end", "def index\n @cephalopods = Cephalopod.all\n end", "def index\n @provisions = Provision.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @provisions }\n end\n end", "def show\n @peca = Peca.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @peca }\n end\n end", "def get_speeches\n @record.speeches.select { |s| (s.contribution_type == \"O\" || s.contribution_type == \"C\") }\n end", "def genes()\n puts 'vcf_life gene'\n return nil if @data[:info].blank?\n return nil if @data[:info][:ann].blank?\n #return nil if @data[:info][:hgvs].blank?\n VcfTools.get_genes_from_ann( @data[:info][:ann] )\n end", "def index\n @cpfs = Cpf.all\n end", "def index\n @cotiz_mes_exps = CotizMesExp.all\n end", "def test_call_instance_method_get_provenance_records\r\n\t\tVCR.use_cassette('get_provenance_records') do\r\n\t\t\tcdo = CordraRestClient::DigitalObject.call_instance_method(API_URL, \"#{CORDRA_PREFIX}/82752031921751eb6ab9\",\"getProvenanceRecords\",nil,nil)\r\n\r\n\t\t\t# Check that its has at least one provenance record and the first one was for a create event\r\n\r\n\t\t\tassert_equal \"#{CORDRA_PREFIX}/82752031921751eb6ab9\", cdo[\"content\"][\"id\"]\r\n\t\t\tassert_equal true, cdo[\"provenanceRecords\"].length()>1\r\n\t\t\tassert_equal \"prov.994/6e157c5da4410b7e9de8\", cdo[\"provenanceRecords\"][0][\"attributes\"][\"content\"][\"eventTypeId\"]\r\n\t\tend\r\n\tend", "def index\n @cooperatives = Cooperative.all\n end", "def get_copays\n raise InvalidVBSRequestError, request_data.errors unless request_data.valid?\n\n response = request.post(\"#{settings.base_path}/GetStatementsByEDIPIAndVistaAccountNumber\", request_data.to_hash)\n\n # enable zero balance debt feature if flip is on\n if Flipper.enabled?(:medical_copays_zero_debt)\n zero_balance_statements = MedicalCopays::ZeroBalanceStatements.build(\n statements: response.body,\n facility_hash: user.vha_facility_hash\n )\n response.body.concat(zero_balance_statements.list)\n end\n\n ResponseData.build(response:).handle\n end", "def get_all_vpcs(ec2)\n all_vpcs = {}\n ec2.vpcs.each do |vpc|\n vpc_name=\"\"\n vpc.tags.each do |tag| \n vpc_name = tag.value if tag.key == \"Name\" \n end\n ## hash of hashes\n all_vpcs[vpc_name] = {\n 'cidr_block' => vpc.data['cidr_block'], \n 'vpc_id' => vpc.data['vpc_id'], \n }\n end\n all_vpcs\nend", "def show\n @species = Specie.find(params[:id])\n\n @pets = Pet.where(:specie_id => @species).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:secie => @species, :pets => @pets } }\n end\n end", "def index\n # @cov_odp_processeds = CovOdpProcessed.all.page(params[:page])\n @q = CovOdpProcessed.ransack(params[:q])\n @cov_odp_processeds = @q.result(distinct: true).order('added_at DESC').page(params[:page])\n authorize @cov_odp_processeds\n end" ]
[ "0.5546804", "0.54726803", "0.53062415", "0.5253674", "0.5248795", "0.52337486", "0.510101", "0.4996687", "0.4957536", "0.49566272", "0.49063808", "0.48832402", "0.48682535", "0.4859834", "0.48554453", "0.48535448", "0.48460883", "0.48076898", "0.47946066", "0.47735325", "0.47474113", "0.47127032", "0.47086978", "0.46998695", "0.46939018", "0.46867868", "0.46862468", "0.46816865", "0.4677226", "0.46753383", "0.46636721", "0.46607223", "0.4657127", "0.46488187", "0.46488187", "0.46449503", "0.46337086", "0.4632361", "0.46298158", "0.46289456", "0.46170813", "0.4614999", "0.4608835", "0.45986417", "0.4584474", "0.4581307", "0.45723778", "0.4571313", "0.45618036", "0.455477", "0.45527518", "0.4545061", "0.4540063", "0.45395058", "0.45364296", "0.4530457", "0.45253375", "0.45252097", "0.45235625", "0.45201212", "0.45142862", "0.45102733", "0.45093703", "0.45076814", "0.45060048", "0.450244", "0.44923502", "0.44899297", "0.4486888", "0.4474566", "0.44704193", "0.44682375", "0.4465735", "0.44579807", "0.44557256", "0.44553226", "0.44553158", "0.44520184", "0.44486663", "0.44437143", "0.44433737", "0.44426143", "0.4441349", "0.44397047", "0.44349197", "0.44279698", "0.44255257", "0.44253075", "0.4424266", "0.44224122", "0.44218293", "0.44209617", "0.4420828", "0.4420625", "0.4419903", "0.4419792", "0.4418807", "0.44182146", "0.44178596", "0.4416303" ]
0.5975741
0
Creates a SUBSCRIBE frame. Sets `ack` header to 'auto' unless it is already set to 'client' or 'clientindividual'.
def subscribe_frame d, h h[:ack] = 'auto' unless ['client', 'client-individual'].include?(h[:ack]) create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_client_ack_with_symbol_11\n if @conn.protocol != Stomp::SPL_11\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has two REQUIRED headers: message-id, which MUST contain a value \n # matching the message-id for the MESSAGE being acknowledged and \n # subscription, which MUST be set to match the value of the subscription's \n # id header.\n @conn.ack msg.headers['message-id'], :subscription => msg.headers['subscription']\n }\n checkEmsg(@conn)\n end", "def subscribe dest, ack=false\n send_frame \"SUBSCRIBE\", {:destination=>dest, :ack=>(ack ? \"client\" : \"auto\")}\n end", "def test_client_ack_with_symbol_10\n if @conn.protocol != Stomp::SPL_10\n assert true\n return\n end\n queue = make_destination()\n @conn.subscribe queue, :ack => :client\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_10\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has one required header, message-id, which must contain a value \n # matching the message-id for the MESSAGE being acknowledged.\n @conn.ack msg.headers['message-id']\n }\n checkEmsg(@conn)\n end", "def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end", "def test_client_ack_with_symbol_12\n if @conn.protocol != Stomp::SPL_12\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # The ACK frame MUST include an id header matching the ack header \n # of the MESSAGE being acknowledged.\n @conn.ack msg.headers['ack']\n }\n checkEmsg(@conn)\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 ack_frame *args\n create_ack_or_nack 'ACK', args\n end", "def ack(subscription_headers, message)\n #p [:ack, message.headers[\"message-id\"]]\n if message.headers[\"message-id\"].to_s.strip != \"\" && subscription_headers[\"ack\"].to_s == \"client\"\n SMQueue.dbg { [:smqueue, :ack, :message, message].inspect }\n connection.ack message.headers[\"message-id\"], { }\n else\n SMQueue.dbg { [:smqueue, :ack, :not_acknowledging, message].inspect }\n end\n if ENV['PAUSE_SMQUEUE']\n $stderr.print \"press enter to continue> \"\n $stderr.flush\n $stdin.gets\n end\n end", "def api_create_and_send(master, side_table = nil)\n data = { subscriber: make_hash }\n data[:subscriberMessage] = master.subscriber_message_data\n data[:subscriber][:allowResubscribe] = true\n data[:sideTable] = side_table.payload_hash unless side_table.nil?\n\n path = '/composite/subscribeAndSend'\n attrs = data[:subscriber][:attributes][:attributes]\n # attrs has the form [ {name: :attr1, value: 'val1'}, {name: ...}, ...]\n email = attrs.select {|h| h[:name] == :email}.first[:value]\n master_id = master.subscriber_message_data[:masterId]\n info(\"Yesmail: subscribeAndSend #{email} to master #{master_id}\")\n handler.post(data, path)\n end", "def subscription_opts\n { manual_ack: true, block: true }\n end", "def create_subscription(sender)\n PsegRecurring::Subscription.new(@credentials).send_subscription(sender)\n end", "def ack(opts={})\n\t\t\t# Set delivery tag\n\t\t\tdelivery_tag = opts.delete(:delivery_tag)\n\t\t\tdelivery_tag ||= self.delivery_tag\n\t\t\traise Bunny::AcknowledgementError, \"No delivery tag received\" unless delivery_tag\n\t\t\t\n client.send_frame(\n Qrack::Protocol09::Basic::Ack.new({:delivery_tag => delivery_tag, :multiple => false}.merge(opts))\n )\n\n\t\t\t# reset delivery tag\n\t\t\tself.delivery_tag = nil if self.delivery_tag == delivery_tag\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 acknowledge subscription, *ack_ids\n subscriber.acknowledge subscription: subscription_path(subscription), ack_ids: ack_ids\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 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 ack(opts = {})\n # Set delivery tag\n if delivery_tag.nil? and opts[:delivery_tag].nil?\n raise Bunny::AcknowledgementError, \"No delivery tag received\"\n else\n self.delivery_tag = opts[:delivery_tag] if delivery_tag.nil?\n end\n\n opts = {:delivery_tag => delivery_tag, :multiple => false}.merge(opts)\n\n client.send_frame(Qrack::Protocol::Basic::Ack.new(opts))\n\n # reset delivery tag\n self.delivery_tag = nil\n end", "def subscribe(args = {})\n :no_response\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(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_client(client,email)\n cursor = parse \"BEGIN msf.acm_utils.manage_tocs(:publication, :cno, :action, :email, :cur_status, :status_dt, :r_str); end;\"\n cursor.bind_param ':cno', client.to_s\n cursor.bind_param ':email', email ||= ''\n cursor.bind_param ':action', 'ADD'\n exec cursor do\n cursor[':r_str'] == 'Ok'\n end\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 gen_subscriber\n subscriber = @context.socket(ZMQ::SUB)\n\n subscriber.setsockopt(ZMQ::RCVTIMEO, @wait_timeout * 10**3)\n subscriber.connect(@subscriber_endpoint)\n\n subscriber\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(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 ack(msg)\n return unless msg.sub\n msg.sub.synchronize do\n ack_proto = STAN::Protocol::Ack.new({\n subject: msg.proto.subject,\n sequence: msg.proto.sequence\n }).to_proto\n nats.publish(msg.sub.ack_inbox, ack_proto)\n end\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(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 ack\n @mq.callback do\n @mq.send Protocol::Basic::Ack.new({ :delivery_tag => @header_obj.properties[:delivery_tag] })\n end\n end", "def create_webhook_subscription(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/webhooks/subscriptions',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def subscribe(subject, opts={}, &cb)\n raise BadConnectionError.new unless @sub_req_subject\n\n sub_options = {}\n sub_options.merge!(opts)\n sub_options[:ack_wait] ||= DEFAULT_ACK_WAIT\n sub_options[:max_inflight] ||= DEFAULT_MAX_INFLIGHT\n sub_options[:stan] = self\n\n sub = Subscription.new(subject, sub_options, cb)\n sub.extend(MonitorMixin)\n synchronize { @sub_map[sub.inbox] = sub }\n\n # Hold lock throughout\n sub.synchronize do\n # Listen for actual messages\n sid = nats.subscribe(sub.inbox) { |raw, reply, subject| process_msg(raw, reply, subject) }\n sub.sid = sid\n nats.flush(options[:connect_timeout])\n\n # Create the subscription request announcing the inbox on which\n\n # we have made the NATS subscription for processing messages.\n # First, we normalize customized subscription options before\n # encoding to protobuf.\n sub_opts = normalize_sub_req_params(sub_options)\n\n # Set STAN subject and NATS inbox where we will be awaiting\n # for the messages to be delivered.\n sub_opts[:subject] = subject\n sub_opts[:inbox] = sub.inbox\n\n sr = STAN::Protocol::SubscriptionRequest.new(sub_opts)\n reply = nil\n response = nil\n begin\n reply = nats.request(@sub_req_subject, sr.to_proto, timeout: options[:connect_timeout])\n response = STAN::Protocol::SubscriptionResponse.decode(reply.data)\n rescue NATS::IO::Timeout, Google::Protobuf::ParseError => e\n # FIXME: Error handling on unsubscribe\n nats.unsubscribe(sub.sid)\n raise e\n end\n\n unless response.error.empty?\n # FIXME: Error handling on unsubscribe should be async\n nats.unsubscribe(sub.sid)\n raise Error.new(response.error)\n end\n\n # Capture ack inbox for the subscription\n sub.ack_inbox = response.ackInbox.freeze\n\n return sub\n end\n rescue NATS::IO::Timeout\n raise SubReqTimeoutError.new(\"stan: subscribe request timeout on '#{subject}'\")\n end", "def unsubscribe\n synchronize do\n stan.nats.unsubscribe(self.sid)\n end\n\n # Make client stop tracking the subscription inbox\n # and grab unsub request subject under the lock.\n unsub_subject = nil\n stan.synchronize do\n stan.sub_map.delete(self.ack_inbox)\n unsub_subject = stan.unsub_req_subject\n end\n\n unsub_req = STAN::Protocol::UnsubscribeRequest.new({\n clientID: stan.client_id,\n subject: self.subject,\n inbox: self.ack_inbox\n })\n\n if self.durable_name\n unsub_req.durableName = self.durable_name\n end\n\n raw = stan.nats.request(unsub_subject, unsub_req.to_proto, {\n timeout: stan.options[:connect_timeout]\n })\n response = STAN::Protocol::SubscriptionResponse.decode(raw.data)\n unless response.error.empty?\n # FIXME: Error handling on unsubscribe\n raise Error.new(response.error)\n end\n end", "def create(params)\n params.merge!(\n :order_no => (Time.now.to_f * 10000).to_i.to_s, # Produce a unique order_no - it's not used anywhere, but ePay needs this\n :amount => 0\n )\n \n post = Api.default_post_for_params(params).merge({\n :subscription => 1,\n :subscriptionname => params[:description]\n })\n \n query = Api.authorize(post)\n \n if query['accept']\n # Return the new subscriber\n subscription = new(query[\"subscriptionid\"].to_i).reload\n \n # Set (obfuscated) card number:\n subscription.card_no = query[\"tcardno\"]\n \n subscription\n else\n new(nil, 'error' => query[\"error\"])\n end\n end", "def screencast_frame_ack(session_id:)\n {\n method: \"Page.screencastFrameAck\",\n params: { sessionId: session_id }.compact\n }\n end", "def subscription_channel\n @subscription_channel ||= ::AMQP::Channel.new(connection).prefetch(1)\n end", "def subscribe(message, local = false, &callback)\n response = make_response(message)\n client_id = message['clientId']\n subscription = [message['subscription']].flatten\n\n @engine.client_exists(client_id) do |exists|\n response['error'] = Error.client_unknown(client_id) unless exists\n response['error'] = Error.parameter_missing('clientId') if client_id.nil?\n response['error'] = Error.parameter_missing('subscription') if message['subscription'].nil?\n\n response['subscription'] = message['subscription'] || []\n\n subscription.each do |channel|\n next if response['error']\n response['error'] = Error.channel_forbidden(channel) unless local or Channel.subscribable?(channel)\n response['error'] = Error.channel_invalid(channel) unless Channel.valid?(channel)\n\n next if response['error']\n @engine.subscribe(client_id, channel)\n end\n\n response['successful'] = response['error'].nil?\n callback.call(response)\n end\n end", "def ack msgid\n send_frame \"ACK\", 'message-id'=> msgid\n end", "def get(headers = {}, &block)\n self.connect\n SMQueue.dbg { [:smqueue, :get, headers].inspect }\n subscription_headers = {\"ack\" => \"client\", \"activemq.prefetchSize\" => 1 }\n if client_id = configuration.client_id\n subscription_headers[\"client_id\"] = client_id\n end\n if sub_name = configuration.subscription_name\n subscription_headers[\"subscription_name\"] = sub_name\n end\n # if a client_id is supplied, then user wants a durable subscription\n # N.B. client_id must be unique for broker\n subscription_headers.update(headers)\n #p [:subscription_headers_before, subscription_headers]\n subscription_headers = normalize_keys(subscription_headers)\n if configuration.durable and client_id = configuration.client_id || subscription_headers[\"client_id\"]\n subscription_name = configuration.subscription_name || subscription_headers[\"subscription_name\"] || client_id\n # activemq only\n subscription_headers[\"activemq.subscriptionName\"] = subscription_name\n # JMS\n subscription_headers[\"durable-subscriber-name\"] = subscription_name\n end\n #p [:subscription_headers_after, subscription_headers]\n\n destination = configuration.name\n SMQueue.dbg { [:smqueue, :get, :subscribing, destination, :subscription_headers, subscription_headers].inspect }\n connection.subscribe destination, subscription_headers\n message = nil\n SMQueue.dbg { [:smqueue, :get, :subscription_headers, subscription_headers].inspect }\n begin\n # TODO: refactor this\n if block_given?\n SMQueue.dbg { [:smqueue, :get, :block_given].inspect }\n # todo: change to @running - (and set to false from exception handler)\n # also should check to see if anything left to receive on connection before bailing out\n while true\n SMQueue.dbg { [:smqueue, :get, :receive].inspect }\n # block until message ready\n message = connection.receive\n SMQueue.dbg { [:smqueue, :get, :received, message].inspect }\n case message.command\n when \"ERROR\"\n SMQueue.dbg { [:smqueue, :get, :ERROR, message].inspect }\n when \"RECEIPT\"\n SMQueue.dbg { [:smqueue, :get, :RECEIPT, message].inspect }\n else\n SMQueue.dbg { [:smqueue, :get, :yielding].inspect }\n if !message_seen?(message.headers[\"message-id\"])\n yield(message)\n end\n SMQueue.dbg { [:smqueue, :get, :message_seen, message.headers[\"message-id\"]].inspect }\n message_seen message.headers[\"message-id\"]\n SMQueue.dbg { [:smqueue, :get, :returned_from_yield_now_calling_ack].inspect }\n ack(subscription_headers, message)\n SMQueue.dbg { [:smqueue, :get, :returned_from_ack].inspect }\n end\n end\n else\n SMQueue.dbg { [:smqueue, :get, :single_shot].inspect }\n message = connection.receive\n SMQueue.dbg { [:smqueue, :get, :received, message].inspect }\n if !(message.command == \"ERROR\" or message.command == \"RECEIPT\")\n SMQueue.dbg { [:smqueue, :get, :message_seen, message.headers[\"message-id\"]].inspect }\n message_seen message.headers[\"message-id\"]\n SMQueue.dbg { [:smqueue, :get, :ack, message].inspect }\n ack(subscription_headers, message)\n SMQueue.dbg { [:smqueue, :get, :returned_from_ack].inspect }\n end\n end\n rescue Object => e\n SMQueue.dbg { [:smqueue, :get, :exception, e].inspect }\n handle_error e, \"Exception in SMQueue#get: #{e.message}\", caller\n ensure\n SMQueue.dbg { [:smqueue, :get, :ensure].inspect }\n SMQueue.dbg { [:smqueue, :unsubscribe, destination, subscription_headers].inspect }\n connection.unsubscribe destination, subscription_headers\n SMQueue.dbg { [:smqueue, :disconnect].inspect }\n connection.disconnect\n end\n SMQueue.dbg { [:smqueue, :get, :return].inspect }\n message\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 create\n args = ZAPIArgs.new\n args.uri = Resource_Endpoints::POST_SUBSCRIPTION\n\n args.req_body = ZAPIArgs.new\n args.req_body.accountKey = SAMPLE_ACCOUNT_KEY\n args.req_body.contractEffectiveDate = '2013-02-1'\n args.req_body.termType = 'TERMED'\n args.req_body.initialTerm = '12'\n args.req_body.autoRenew = true\n args.req_body.renewalTerm = \"3\"\n args.req_body.notes = 'Test POST subscription from z-ruby-sdk'\n args.req_body.subscribeToRatePlans = []\n args.req_body.subscribeToRatePlans[0] = ZAPIArgs.new\n args.req_body.subscribeToRatePlans[0].productRatePlanId = 'ff8080811ca15d19011cdda9b0ad3b51'\n args.req_body.subscribeToRatePlans[0].chargeOverrides = []\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0] = ZAPIArgs.new\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0].productRatePlanChargeId =\n 'ff8080811ca15d19011cddad8c953b53'\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0].quantity = 10\n args.req_body.invoiceTargetDate = '2013-12-31'\n args.req_body.invoiceCollect = false\n\n puts \"========== CREATE A SUBSCRIPTION ============\"\n\n begin\n @z_client.post(args) do |resp|\n ap resp\n return resp.subscriptionNumber if resp.httpStatusCode.to_i == 200 && resp.success\n end\n rescue ArgumentError => e\n puts e.message\n rescue RuntimeError => e\n puts e.message\n end\n\n nil\n end", "def request!\n self.type = :subscribe\n reply_if_needed!\n end", "def create\n if request.env['x-amz-sns-message-type'] == 'SubscriptionConfirmation' || ENV['HTTP_X_AMZ_SNS_MESSAGE_TYPE'] == \"SubscriptionConfirmation\" || @data['Type'] == \"SubscriptionConfirmation\"\n response = HTTParty.get(@data['SubscribeURL'])\n head :ok\n\n else\n mail_data = @data['mail']\n bounce_data = @data['bounce']\n recipients = [bounce_data['bouncedRecipients']].flatten\n envelope = Msg::Envelope.find_by_email_id(mail_data['messageId'])\n recipients.each do |recipient_data|\n Msg::Bounce.create({\n :envelope => envelope,\n :bounce_type => bounce_data['bounceType'],\n :bounce_subtype => bounce_data['bounceSubType'],\n :reporter => bounce_data['reportingMTA'],\n :email => recipient_data['emailAddress'],\n :status => recipient_data['status'],\n :diagnostic => recipient_data['diagnosticCode'],\n :raw_message => JSON.dump(bounce_data)\n })\n end\n head :ok\n end\n end", "def create_outbound_subscription(sender_address, options)\n Response.new self.class.post(\"/smsmessaging/outbound/#{sender_address}/subscriptions\", \n :basic_auth => @auth,\n :body => build_query_string(options),\n :headers => SMSIFIED_HTTP_HEADERS\n )\n end", "def subscribe(*args, &blk)\n (@client ||= connect).subscribe(*args, &blk)\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 service_subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscriptions')\n )\n )\n send_iq_stanza_fibered iq\n end", "def nack_frame *args\n create_ack_or_nack 'NACK', args\n end", "def describe_event_subscriptions(options={})\n if options[:max_records]\n params['MaxRecords'] = options[:max_records]\n end\n\n request({\n 'Action' => 'DescribeEventSubscriptions',\n :parser => Fog::Parsers::AWS::RDS::DescribeEventSubscriptions.new\n }.merge(options))\n end", "def create(params)\n params[:tag] ||= '*'\n post(\"#{domain}/unsubscribes\", params)\n end", "def subscribe_client_id(*args)\n raise_unsupported\n end", "def subscribe(subscription)\n @pipe.send_strings [\"subscribe\", subscription]\n end", "def create_request publisher, method, params\n CnsBase::RequestResponse::RequestSignal.new(publisher, method, params)\n end", "def subscription(options = {})\n\t\t\t# provide the client with another (i.e. the external address) if given\n\t\t\tsub = {server: config[:server_external] || config[:server], timestamp: (Time.now.to_f * 1000).round}.merge(options)\n\t\t\tsub[:signature] = Digest::SHA1.hexdigest([config[:secret_token], sub[:channel], sub[:timestamp]].join)\n\t\t\tsub\n\t\tend", "def create_subscription(body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/subscriptions'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.post(\n _query_url,\n headers: _headers,\n parameters: body.to_json\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def chimp_subscribe(resource, email_content_type=\"html\", double_optin=false)\n begin\n @client.call(\"listSubscribe\", @api_key, get_mailing_list_from_resource(resource), resource.email, resource.build_mail_merge(), email_content_type, double_optin)\n rescue XMLRPC::FaultException => e\n raise MailChimpAPI::CreateError, e.faultString\n end \n end", "def create_webhook_subscription(submission___context_id__,subscription___context_type__,subscription___event_types__,subscription___format__,subscription___transport_metadata__,subscription___transport_type__,opts={})\n query_param_keys = [\n \n\n ]\n\n form_param_keys = [\n :submission___context_id__,\n :subscription___context_type__,\n :subscription___event_types__,\n :subscription___format__,\n :subscription___transport_metadata__,\n :subscription___transport_type__,\n \n\n ]\n\n # verify existence of params\n raise \"submission___context_id__ is required\" if submission___context_id__.nil?\n raise \"subscription___context_type__ is required\" if subscription___context_type__.nil?\n raise \"subscription___event_types__ is required\" if subscription___event_types__.nil?\n raise \"subscription___format__ is required\" if subscription___format__.nil?\n raise \"subscription___transport_metadata__ is required\" if subscription___transport_metadata__.nil?\n raise \"subscription___transport_type__ is required\" if subscription___transport_type__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :submission___context_id__ => submission___context_id__,\n :subscription___context_type__ => subscription___context_type__,\n :subscription___event_types__ => subscription___event_types__,\n :subscription___format__ => subscription___format__,\n :subscription___transport_metadata__ => subscription___transport_metadata__,\n :subscription___transport_type__ => subscription___transport_type__\n\n )\n\n # resource path\n path = path_replace(\"/lti/subscriptions\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_query_params(options, query_param_keys)\n\n response = mixed_request(:post, path, query_params, form_params, headers)\n response\n \n\n end", "def test_creating_receive_ACK_message\n test_string = @mf.hex_string_to_string(\"82 00 82\")\n test_message = @msg_fac.new_incoming_message(test_string)\n assert_kind_of(HAIthermo::Message::ReceiveACK, test_message)\n end", "def unsubscribe\n @conn.send_data :opcode => UNSUBSCRIBE, :channel => @name\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(response)\n response.headers['Content-Type'] = 'text/event-stream'\n @subscriber = response\n end", "def test_receipt\n conn_subscribe make_destination, :receipt => \"abc\"\n msg = @conn.receive\n assert_equal \"abc\", msg.headers['receipt-id']\n checkEmsg(@conn)\n end", "def retrieve_subscription(subscription_id:,\n include: nil)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/subscriptions/{subscription_id}',\n 'default')\n .template_param(new_parameter(subscription_id, key: 'subscription_id')\n .should_encode(true))\n .query_param(new_parameter(include, key: 'include'))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',:node => node_id)\n )\n )\n send_iq_stanza_fibered iq\n end", "def test_conn_1p_0124\n dest = make_destination\n msg = \"payload: #{Time.now.to_f}\"\n shdrs = { \"key1\" => \"val1\", \"key2\" => \"val2\",\n \"key3\" => [\"kv3\", \"kv2\", \"kv1\"] }\n assert_nothing_raised {\n @conn.publish dest, msg, shdrs\n }\n #\n sid = @conn.uuid()\n @conn.subscribe dest, :id => sid\n #\n received = @conn.receive\n assert_equal msg, received.body\n if @conn.protocol != Stomp::SPL_10\n assert_equal shdrs[\"key3\"], received.headers[\"key3\"] unless ENV['STOMP_RABBIT'] || ENV['STOMP_AMQ11']\n else\n assert_equal \"kv3\", received.headers[\"key3\"]\n end\n #\n @conn.unsubscribe dest, :id => sid\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(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 receive_acknowledgement sequence_number\n @stats[:acks_received] += 1\n\n frame_acknowledged = sequence_number-1\n if frame_acknowledged == -1\n frame_acknowledged = (@options[:window_size] * 2) - 1\n end\n puts \"Frame #{frame_acknowledged} ACK'd\"\n\n perform_acknowledgement frame_acknowledged\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 resubscribe!\n update!(unsubscribed_at: nil, resubscribed_at: ::Caffeinate.config.time_now)\n\n caffeinate_campaign.to_dripper.run_callbacks(:on_resubscribe, self)\n end", "def create_subscriptions\n Subscription.create_subscriptions(self.id, self.hashtag)\n end", "def post body=nil, headers={}\n @connection.post \"subscriptions.json\", body, headers\n end", "def basic_nack(delivery_tag, multiple: false, requeue: false)\n write_bytes FrameBytes.basic_nack(@id, delivery_tag, multiple, requeue)\n nil\n end", "def send_ack(spark)\n return unless ['request', :request].include? spark[:type]\n ack_msg = spark.merge sent_to: spark[:sender], sender: channel\n hsdq_send_ack ack_msg\n end", "def generate_subscriptions_report(generate_subscriptions_report, opts = {})\n data, _status_code, _headers = generate_subscriptions_report_with_http_info(generate_subscriptions_report, opts)\n data\n end", "def create_subscription(name, conninfo_hash, publications, options = {})\n options[:slot_name] = name if !options.key?(:slot_name) && !options.key?(\"slot_name\") && (options['create_slot'] == false || options[:create_slot] == false)\n\n connection_string = connection.escape_string(PG::Connection.parse_connect_args(conninfo_hash))\n base_command = <<-SQL\n CREATE SUBSCRIPTION #{connection.quote_ident(name)}\n CONNECTION '#{connection_string}'\n PUBLICATION #{safe_list(publications)}\n SQL\n typed_exec(command_builder.command_with_options(base_command, \"WITH\", options))\n end", "def test_webhook_subscription(subscription_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/webhooks/subscriptions/{subscription_id}/test',\n 'default')\n .template_param(new_parameter(subscription_id, key: 'subscription_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def create\n s_params = params[:subscription]\n s_params.delete(:id)\n @subscription = Subscription.new(s_params)\n @subscription.save\n respond_with(@subscription)\n end", "def consume_requeue\n @consumer = @requeue.subscribe do |info, props, body|\n Proletariat.publish(props.headers['proletariat-to'], body,\n props.headers)\n\n nil\n end\n end", "def request(subject, payload, opts={}, &blk)\n return unless subject\n inbox = new_inbox\n\n # If a callback was passed, then have it process\n # the messages asynchronously and return the sid.\n if blk\n opts[:max] ||= 1\n s = subscribe(inbox, opts) do |msg, reply|\n case blk.arity\n when 0 then blk.call\n when 1 then blk.call(msg)\n else blk.call(msg, reply)\n end\n end\n publish(subject, payload, inbox)\n\n return s\n end\n\n # In case block was not given, handle synchronously\n # with a timeout and only allow a single response.\n timeout = opts[:timeout] ||= 0.5\n opts[:max] = 1\n\n sub = Subscription.new\n sub.subject = inbox\n sub.received = 0\n future = sub.new_cond\n sub.future = future\n\n sid = nil\n synchronize do\n sid = (@ssid += 1)\n @subs[sid] = sub\n end\n\n send_command(\"SUB #{inbox} #{sid}#{CR_LF}\")\n @flush_queue << :sub\n unsubscribe(sid, 1)\n\n sub.synchronize do\n # Publish the request and then wait for the response...\n publish(subject, payload, inbox)\n\n with_nats_timeout(timeout) do\n future.wait(timeout)\n end\n end\n response = sub.response\n\n response\n end", "def subscribeack(channel, ack)\n @ws.send(get_subscribe_object(channel, increment_cnt).to_json)\n @channels << channel\n @acks[@cnt] = [channel, ack]\n end", "def test_subscribe\n jid = 'foo@example.com'\n @roster.deliver_subscription_request(jid)\n assert_equal([jid], @roster.accepted_subscriptions)\n end", "def subscribe!\n Subscription.transaction do\n subscription = create_stripe_subscription!\n store.subscriptions.create!(\n customer: user,\n stripe_plan_id: stripe_plan_id,\n stripe_id: subscription.id,\n first_date: Date.today,\n status: :active\n )\n end\n end", "def configure_subscription(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('options',{'node' => node_id, 'jid'=>subscribee},\n connection.build_submit_form(form)\n )\n )\n )\n\n send_iq_stanza_fibered iq\n end", "def create_inbound_subscription(destination_address, options)\n query = options.merge({ :destination_address => destination_address })\n \n Response.new self.class.post(\"/smsmessaging/inbound/subscriptions\", \n :basic_auth => @auth,\n :body => camelcase_keys(query),\n :headers => SMSIFIED_HTTP_HEADERS\n )\n\n end", "def headers\n {\n :subject => \"Subscription Request\"\n }\n end", "def ack(msg_info)\n end", "def subscribe(options, &block)\n subscriptions.create(options, &block)\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 subscription\n ensure_connection\n @consumers.find(&:subscription)\n end", "def subscribe(&blk)\n pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribe')\n connection.send_stanza pres, &blk\n end", "def create_subscription topic, subscription_name, options = {}\n updated_option = construct_create_subscription_options topic, subscription_name, options\n subscriber.create_subscription(**updated_option)\n end", "def grant_subscribe client, &block\n control_request(\"grant_subscribe\", client, &block)\n end", "def initialize(connection, messageId)\n @connection = connection\n @respEnvelope = OpenSSL::ASN1::Sequence([\n OpenSSL::ASN1::Integer(messageId),\n # protocolOp,\n # controls [0] OPTIONAL,\n ])\n @schema = @connection.opt[:schema]\n @server = @connection.opt[:server]\n @rescount = 0\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_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(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(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 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" ]
[ "0.55870736", "0.55790424", "0.54074484", "0.5380273", "0.53647137", "0.5324904", "0.5308", "0.5260508", "0.5181441", "0.49778032", "0.49193686", "0.49107003", "0.48726657", "0.481885", "0.47889104", "0.4776266", "0.4776266", "0.47730666", "0.47506678", "0.47465703", "0.47461888", "0.47458687", "0.4738096", "0.46930036", "0.46860835", "0.46416408", "0.46056908", "0.46017775", "0.4588609", "0.45835155", "0.45748904", "0.45583108", "0.45550483", "0.45489016", "0.45251185", "0.44903323", "0.4483391", "0.4482904", "0.4478767", "0.44666404", "0.44628707", "0.4445915", "0.44296047", "0.44278282", "0.44196063", "0.44118434", "0.44105035", "0.43902564", "0.4389742", "0.4386211", "0.43689597", "0.43662992", "0.43558338", "0.43468457", "0.43330175", "0.43162093", "0.42936838", "0.42923477", "0.42870283", "0.4281484", "0.42730948", "0.42699686", "0.42673212", "0.42608032", "0.42357847", "0.42168704", "0.42147467", "0.42134893", "0.42099515", "0.42086983", "0.42061275", "0.4201661", "0.4195497", "0.4182985", "0.41815877", "0.417268", "0.41666344", "0.4163619", "0.41608253", "0.41528612", "0.41525498", "0.41455206", "0.41407973", "0.41365394", "0.4135883", "0.41224176", "0.41147387", "0.41096595", "0.41094673", "0.41091177", "0.41038427", "0.41016075", "0.41013446", "0.40946448", "0.4093784", "0.40854645", "0.40840816", "0.4081348", "0.40803707", "0.40780237" ]
0.6750201
0
Creates an ACK frame
def ack_frame *args create_ack_or_nack 'ACK', args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ack(opts={})\n\t\t\t# Set delivery tag\n\t\t\tdelivery_tag = opts.delete(:delivery_tag)\n\t\t\tdelivery_tag ||= self.delivery_tag\n\t\t\traise Bunny::AcknowledgementError, \"No delivery tag received\" unless delivery_tag\n\t\t\t\n client.send_frame(\n Qrack::Protocol09::Basic::Ack.new({:delivery_tag => delivery_tag, :multiple => false}.merge(opts))\n )\n\n\t\t\t# reset delivery tag\n\t\t\tself.delivery_tag = nil if self.delivery_tag == delivery_tag\n end", "def send_ack\n sock.put('+')\n vprint_status('Sending ack...')\n end", "def nack_frame *args\n create_ack_or_nack 'NACK', args\n end", "def ack(opts = {})\n # Set delivery tag\n if delivery_tag.nil? and opts[:delivery_tag].nil?\n raise Bunny::AcknowledgementError, \"No delivery tag received\"\n else\n self.delivery_tag = opts[:delivery_tag] if delivery_tag.nil?\n end\n\n opts = {:delivery_tag => delivery_tag, :multiple => false}.merge(opts)\n\n client.send_frame(Qrack::Protocol::Basic::Ack.new(opts))\n\n # reset delivery tag\n self.delivery_tag = nil\n end", "def ack msgid\n send_frame \"ACK\", 'message-id'=> msgid\n end", "def ack\n @mq.callback do\n @mq.send Protocol::Basic::Ack.new({ :delivery_tag => @header_obj.properties[:delivery_tag] })\n end\n end", "def ack(msg_info)\n end", "def ACK08=(arg)", "def ACK05=(arg)", "def ACK01=(arg)", "def acknowledge_frame sequence_number\n @stats[:acks_sent] += 1\n\n puts \"Acking #{sequence_number}\"\n\n expected_frame = (@next_frame % @options[:window_size]) + (@options[:window_size] * (@window % 2))\n max_frame = @options[:window_size] * ((@window % 2) + 1)\n\n # Can we write out something in our buffer?\n if expected_frame == sequence_number\n cur_seq_num = sequence_number\n\n while cur_seq_num < max_frame and not @buffer[cur_seq_num].nil? do\n # Get contents of the buffer\n buffer = @buffer[cur_seq_num]\n break if buffer == \"\"\n\n # Write out the buffer\n puts \"WRITING #{@current_frame}\"\n @file.write buffer\n\n # Clear memory\n @buffer[cur_seq_num] = \"\"\n @buffer_len -= 1 if @options[:implementation] == :selective_repeat\n\n # Consider the next frame\n cur_seq_num += 1\n @current_frame += 1\n @next_frame += 1 \n @delivered += @options[:frame_size]\n end\n end\n\n# if (@delivered % (@options[:frame_size] * @options[:window_size])) == 0\n blah_frame = @next_frame % (@options[:window_size] * 2)\n blah_frame = (@options[:window_size]*2) if blah_frame == 0 and max_frame == (@options[:window_size]*2)\n if blah_frame == max_frame\n puts \"Window received.\"\n receive_next_window\n end\n\n if drop_ack? and not done?\n puts \"Dropping Ack\"\n @stats[:acks_dropped] += 1\n return\n end\n\n if (sequence_number+1) == (@options[:window_size] * 2)\n @socket.puts \"ACK 0 #{@number}\"\n else\n @socket.puts \"ACK #{sequence_number+1} #{@number}\"\n end\n\n if @next_frame == @total_frames\n puts \"Delivered\"\n done\n\n unless @file.is_a? StringIO\n stop_timeout\n @file.close\n @file = nil\n end\n end\n end", "def test_creating_receive_ACK_message\n test_string = @mf.hex_string_to_string(\"82 00 82\")\n test_message = @msg_fac.new_incoming_message(test_string)\n assert_kind_of(HAIthermo::Message::ReceiveACK, test_message)\n end", "def ACK10=(arg)", "def ACK07=(arg)", "def ACK04=(arg)", "def ACK06=(arg)", "def ack\n unless acked?\n @acked = true\n @connection.future(:ack, delivery_info.delivery_tag).value\n end\n end", "def ACK09=(arg)", "def ACK03=(arg)", "def screencast_frame_ack(session_id:)\n {\n method: \"Page.screencastFrameAck\",\n params: { sessionId: session_id }.compact\n }\n end", "def nacknowledge_frame sequence_number\n @stats[:naks_sent] += 1\n\n # Already acked?\n return if @buffer[sequence_number] == \"\"\n\n @buffer[sequence_number] = nil\n\n # If GO_BACK_N algorithm, then we expect to receive all of the\n # frames again\n expected_frame = (@next_frame % @options[:window_size]) + (@options[:window_size] * (@window % 2))\n\n if @options[:implementation] == :go_back\n next_frame = ((@window * @options[:window_size]) + (sequence_number % @options[:window_size]))\n @next_frame = [next_frame, @next_frame].min\n @current_frame = @next_frame\n\n # Undo work done\n \n max_frame = @options[:window_size] * ((@window % 2) + 1)\n (expected_frame+1..max_frame).each do |i|\n @buffer[i] = nil\n end\n end\n\n if drop_ack?\n @stats[:naks_dropped] += 1\n puts \"Dropped NAK\"\n return\n end\n\n puts \"NAK #{sequence_number}\"\n @socket.puts \"NAK #{sequence_number} #{@number}\"\n\n # we received a response, so good\n reset_timeout\n end", "def ACK02=(arg)", "def emitack(event, object, ack)\n @ws.send(get_emit_ack_object(event, object, increment_cnt).to_json)\n @acks[@cnt] = [event, ack]\n end", "def test_client_ack_with_symbol_12\n if @conn.protocol != Stomp::SPL_12\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # The ACK frame MUST include an id header matching the ack header \n # of the MESSAGE being acknowledged.\n @conn.ack msg.headers['ack']\n }\n checkEmsg(@conn)\n end", "def receive_acknowledgement sequence_number\n @stats[:acks_received] += 1\n\n frame_acknowledged = sequence_number-1\n if frame_acknowledged == -1\n frame_acknowledged = (@options[:window_size] * 2) - 1\n end\n puts \"Frame #{frame_acknowledged} ACK'd\"\n\n perform_acknowledgement frame_acknowledged\n end", "def ack(subscription_headers, message)\n #p [:ack, message.headers[\"message-id\"]]\n if message.headers[\"message-id\"].to_s.strip != \"\" && subscription_headers[\"ack\"].to_s == \"client\"\n SMQueue.dbg { [:smqueue, :ack, :message, message].inspect }\n connection.ack message.headers[\"message-id\"], { }\n else\n SMQueue.dbg { [:smqueue, :ack, :not_acknowledging, message].inspect }\n end\n if ENV['PAUSE_SMQUEUE']\n $stderr.print \"press enter to continue> \"\n $stderr.flush\n $stdin.gets\n end\n end", "def ack?\n Capp::TCP_ACK == flags & Capp::TCP_ACK\n end", "def replyWithAck?(pduPacket)\n\n Utils_visiona.verifyInput(CFDP::PDUPacket, pduPacket.class)\n return unless isclass2?\n\n status = (@finishType.nil? ? 1 : 2)\n sourceID = MYID\n destinationID = DESTINATIONID\n direction = 0\n\n # This is a received PDU.\n case pduPacket.pduPayload\n when CFDP::PDUEOF\n \n # I only receive EOF packets in DOWNLINK events\n return unless @type.eql?(\"DOWNLINK\")\n direction = 1\n sourceID = destinationID\n destinationID = MYID\n when CFDP::PDUFinished\n\n # I only receive FINISHED packets in UPLINK events\n return unless @type.eql?(\"UPLINK\")\n # use default values from function start\n else\n return\n end\n\n ackPdu = CFDP.generatePDU(\"ACK\", directiveCode:pduPacket.pduPayload.class.class_variable_get(:@@fdCode),\n directiveSubtypeCode:0, conditionCode:pduPacket.pduPayload.conditionCode, transactionStatus:status,\n direction:direction, transmissionMode:0, sourceID:sourceID, destinationID:destinationID,\n sequenceNumber:pduPacket.pduHeader.sequenceNumber)\n\n writeLog(\"Generated ACK PDU: #{ackPdu.pack.to_s}\")\n CFDP::CFDPEngine.instance.insertIntoBuffer(ackPdu)\n end", "def ack=(ack)\n raise 'Invalid ack flag. true or false expected' unless\n [true, false].include? ack\n @message[:ack] = ack\n end", "def ack(msg)\n return unless msg.sub\n msg.sub.synchronize do\n ack_proto = STAN::Protocol::Ack.new({\n subject: msg.proto.subject,\n sequence: msg.proto.sequence\n }).to_proto\n nats.publish(msg.sub.ack_inbox, ack_proto)\n end\n end", "def test_client_ack_with_symbol_11\n if @conn.protocol != Stomp::SPL_11\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has two REQUIRED headers: message-id, which MUST contain a value \n # matching the message-id for the MESSAGE being acknowledged and \n # subscription, which MUST be set to match the value of the subscription's \n # id header.\n @conn.ack msg.headers['message-id'], :subscription => msg.headers['subscription']\n }\n checkEmsg(@conn)\n end", "def acknowledge()\n\t\tend", "def req_ack(clk_e,req,ack,port)\n rst_req_ack(clk_e,nil,req,ack,port)\n end", "def test_client_ack_with_symbol_10\n if @conn.protocol != Stomp::SPL_10\n assert true\n return\n end\n queue = make_destination()\n @conn.subscribe queue, :ack => :client\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_10\"\n msg = @conn.receive\n assert_nothing_raised {\n # ACK has one required header, message-id, which must contain a value \n # matching the message-id for the MESSAGE being acknowledged.\n @conn.ack msg.headers['message-id']\n }\n checkEmsg(@conn)\n end", "def send_ack(spark)\n return unless ['request', :request].include? spark[:type]\n ack_msg = spark.merge sent_to: spark[:sender], sender: channel\n hsdq_send_ack ack_msg\n end", "def ack!\n @manager.ack(self)\n self\n end", "def create_packet\n lock = (@type == :ack ? true : false)\n payload = @pool.get_payload(@hwaddr,lock)\n return :noboot if payload[:netboot] == 'false'\n params = {\n\top: $DHCP_OP_REPLY,\n\txid: @msg.xid,\n\tchaddr: @msg.chaddr,\n\tyiaddr: payload[:ipaddr],\n\tsiaddr: IPAddr.new(payload[:dhcp_server].join('.')).to_i,\n\tfname: payload[:filename],\n\toptions: [\n\t REPLY_TYPES[@type],\n\t ServerIdentifierOption.new({payload: payload[:dhcp_server]}),\n\t DomainNameOption.new({payload: payload[:domainname]}),\n\t DomainNameServerOption.new({payload: payload[:dns_server]}),\n\t IPAddressLeaseTimeOption.new({payload: payload[:lease_time]}),\n\t SubnetMaskOption.new({payload: payload[:subnet_mask]}),\n\t RouterOption.new({payload: payload[:gateway]})\n\t]\n }\n Message.new(params).pack\n end", "def acknowledge\n api_call(\"acknowledge\")\n self\n end", "def acknowledge\n # do nothing\n end", "def acked?; all_status?(:ack); end", "def enable_xack\n getok('XACK ON')\n @xack = true\n end", "def ping\n if @type == :receiving\n # Receive packets\n header = @socket.readline\n header.match /^(\\d+)\\s+(.+)\\s+(.+)$/\n sequence_number = $1.to_i\n check = $2\n file_number = $3.to_i\n\n return if file_number != @number\n\n # ACK anything if we have received the file\n if done?\n response = receive_frame sequence_number\n\n @stats[:acks_sent] += 1\n if (sequence_number+1) == (@options[:window_size] * 2)\n @socket.puts \"ACK 0 #{@number}\"\n else\n @socket.puts \"ACK #{sequence_number+1} #{@number}\"\n end\n\n return\n end\n\n # Receive data\n response = receive_frame sequence_number\n if response == :redundant\n puts \"Reacknowledge!\"\n acknowledge_frame sequence_number\n return\n end\n\n # Perform checksum\n if response != :illegal\n sum = checksum sequence_number\n end\n\n # Append to file and send ACK, or send NAK\n if response == :illegal\n puts \"Out of order frame #{sequence_number}\"\n @stats[:out_of_order] += 1\n\n max_frame = @options[:window_size] * ((@window % 2) + 1)\n\n blah_frame = @next_frame % (@options[:window_size] * 2)\n blah_frame = (@options[:window_size]*2) if blah_frame == 0 and max_frame == (@options[:window_size]*2)\n nacknowledge_frame blah_frame\n elsif sum == check\n acknowledge_frame sequence_number\n else\n puts \"Corruption Detected\"\n @stats[:corrupted] += 1\n nacknowledge_frame sequence_number\n end\n else\n # Respond to acknowledgments\n ack = @socket.readline\n\n if ack.match /^ACK\\s+(\\d+)\\s+(\\d+)$/\n # Respond to ACK\n sequence_number = $1.to_i\n file_number = $2.to_i\n\n return if file_number != @number\n\n receive_acknowledgement sequence_number\n\n max_frame = @options[:window_size] * ((@window % 2) + 1)\n\n blah_frame = @next_frame % (@options[:window_size] * 2)\n blah_frame = (@options[:window_size]*2) if blah_frame == 0 and max_frame == (@options[:window_size]*2)\n if blah_frame == max_frame\n # window has been acknowledged\n send_next_window\n elsif @next_frame == @total_frames\n puts \"MEH\"\n stop_timeout\n end\n elsif ack.match /^NAK\\s+(\\d+)\\s+(\\d+)$/\n # Respond to NAK\n file_number = $2.to_i\n\n return if file_number != @number\n\n sequence_number = $1.to_i\n puts \"Frame #{sequence_number} NAK\"\n receive_nacknowledgement sequence_number\n end\n end\n end", "def basic_nack(delivery_tag, multiple: false, requeue: false)\n write_bytes FrameBytes.basic_nack(@id, delivery_tag, multiple, requeue)\n nil\n end", "def ack_block(cid)\n ws = @ws\n lambda do |error, data|\n ws.send(get_ack_object(error, data, cid))\n end\n end", "def hsdq_send_ack(message)\n hsdq_send(message.merge(type: :ack))\n end", "def create_fake_message(h, mask, aad, ct, ptxor)\n ctx = ct.xor(ptxor)\n tag = msg_blocks(aad, ctx).eval(h) + mask\n [aad, ctx, tag.to_i]\n end", "def parse_body(buffer)\n super(buffer)\n @connack_flags = shift_bits(buffer)\n unless @connack_flags[1, 7] == [false, false, false, false, false, false, false]\n raise ProtocolException, 'Invalid flags in Connack variable header'\n end\n @return_code = shift_byte(buffer)\n\n return if buffer.empty?\n raise ProtocolException, 'Extra bytes at end of Connect Acknowledgment packet'\n end", "def ack(device_uuid, ack_keys)\n validate_device!(device_uuid)\n raise ArgumentError, \"ack_keys must not be nil and an array\" unless ack_keys && ack_keys.is_a?(Array)\n return true if ack_keys.empty?\n\n payload = {\n :ack_keys => ack_keys.map(&:to_s)\n }\n status, _, _ = @client.post('/sync/ack', payload, build_headers(device_uuid))\n status == 202\n end", "def get_ack_probe()\n tcp_ack_probe = get_tcp_packet()\n tcp_ack_probe.tcp_flags.syn = 0\n tcp_ack_probe.tcp_flags.ack = 1\n\n return tcp_ack_probe\n end", "def ack(multiple = false)\n @channel.acknowledge(@method.delivery_tag, multiple)\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 tcp_send(command, body = nil)\n @seq += 1\n header = {\n 'Command' => command.to_s.gsub('_', '-'),\n 'Seq' => seq\n }\n\n buff = MessagePack::Packer.new\n buff.write(header)\n buff.write(body) unless body.nil?\n\n res = socket.write(buff.to_str) unless buff.to_str.empty?\n @requests[seq] = { header: header, ack?: false }\n seq\n end", "def hsdq_ack(message, context); placeholder; end", "def gen_packet type, payload\n length = payload.size\n number = Thread.current[:number]\n Thread.current[:number] = number + 1\n \"@ABCD\" + [type,length,number].pack('CS>I>').force_encoding(ENCODING) + payload\nend", "def create_withdrawal\n # body = {\n # cmd: \"create_withdrawal\"\n # }\n\n end", "def tcp_send(command, body = nil)\n @seq += 1\n header = {\n 'Command' => command.to_s.gsub('_', '-'),\n 'Seq' => seq\n }\n Log.info(\"#{__method__}|Header: #{header.inspect}\")\n buff = MessagePack::Buffer.new\n buff << header.to_msgpack\n buff << body.to_msgpack unless body.nil?\n res = socket.send(buff.to_str, 0)\n Log.info(\"#{__method__}|Res: #{res.inspect}\")\n @requests[seq] = { header: header, ack?: false }\n seq\n end", "def nack\n @action = :nack\n end", "def encode_body(buffer)\n buffer << action.to_msgpack\n end", "def generate(frame)\n bytes = Buffer.new\n length = 0\n\n frame[:flags] ||= []\n frame[:stream] ||= 0\n\n case frame[:type]\n when :data\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n\n when :headers\n if frame[:priority]\n frame[:flags] += [:priority] if !frame[:flags].include? :priority\n end\n\n if frame[:flags].include? :priority\n bytes << [frame[:priority] & RBIT].pack(UINT32)\n length += 4\n end\n\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n\n when :priority\n bytes << [frame[:priority] & RBIT].pack(UINT32)\n length += 4\n\n when :rst_stream\n bytes << pack_error(frame[:error])\n length += 4\n\n when :settings\n if frame[:stream] != 0\n raise CompressionError.new(\"Invalid stream ID (#{frame[:stream]})\")\n end\n\n frame[:payload].each do |(k,v)|\n if !k.is_a? Integer\n k = DEFINED_SETTINGS[k]\n\n if k.nil?\n raise CompressionError.new(\"Unknown settings ID for #{k}\")\n end\n end\n\n bytes << [k & RBYTE].pack(UINT32)\n bytes << [v].pack(UINT32)\n length += 8\n end\n\n when :push_promise\n bytes << [frame[:promise_stream] & RBIT].pack(UINT32)\n bytes << frame[:payload]\n length += 4 + frame[:payload].bytesize\n\n when :ping\n if frame[:payload].bytesize != 8\n raise CompressionError.new(\"Invalid payload size \\\n (#{frame[:payload].size} != 8 bytes)\")\n end\n bytes << frame[:payload]\n length += 8\n\n when :goaway\n bytes << [frame[:last_stream] & RBIT].pack(UINT32)\n bytes << pack_error(frame[:error])\n length += 8\n\n if frame[:payload]\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n end\n\n when :window_update\n bytes << [frame[:increment] & RBIT].pack(UINT32)\n length += 4\n\n when :continuation\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n end\n\n frame[:length] = length\n bytes.prepend(commonHeader(frame))\n end", "def ack_message( tag, success, try_again=true )\n\t\treturn unless self.acknowledge\n\n\t\tchannel = self.consumer.channel\n\n\t\tif success\n\t\t\tself.log.debug \"ACKing message %s\" % [ tag ]\n\t\t\tchannel.acknowledge( tag )\n\t\telse\n\t\t\tself.log.debug \"NACKing message %s %s retry\" % [ tag, try_again ? 'with' : 'without' ]\n\t\t\tchannel.reject( tag, try_again )\n\t\tend\n\n\t\treturn success\n\tend", "def encode_body\n body = ''\n body += encode_bits(@connack_flags)\n body += encode_bytes(@return_code.to_i)\n body\n end", "def create_ad(umsg,sock)\n channel = umsg[1]\n msg = umsg - umsg[0..2]\n if @channels.include? channel\n msg = {:id => 0 ,:channel => channel, :ad => msg.join(\" \"), :time => Time.now}\n ad_id = @@connection.insert_advice(msg[:ad],msg[:channel])\n msg[:id] = ad_id\n @msg_queue.push(msg)\n sock.write(\"Message successfully created. Channel => #{channel}\\n\")\n send_channel_msg(msg)\n else\n sock.write(\"Channel doesnt exist\\n\")\n end\n end", "def create_b2bua_request(session, orig_request=session.irequest, rip=SipperConfigurator[:DefaultRIP], \n rp=SipperConfigurator[:DefaultRP])\n peer_session = get_or_create_peer_session(session, rip, rp)\n if peer_session.initial_state?\n r = peer_session.create_initial_request(orig_request.method, orig_request.uri)\n r.copy_from(orig_request, :from, :to, :route, :content, :content_type, :path, :service_route, :privacy, :referred_by, :p_asserted_identity)\n r.from.tag = \"3\"\n else\n if(orig_request.method == \"CANCEL\")\n r = peer_session.create_cancel\n elsif(orig_request.method == \"ACK\")\n r = peer_session.create_ack\n else\n r = peer_session.create_subsequent_request(orig_request.method)\n end \n r.copy_from(orig_request, :content, :content_type)\n end \n return r\n end", "def push(b)\n \n timeNow = Time.now\n \n if (@time - timeNow) > @tio\n @state = :idle \n end\n \n @time = timeNow\n \n case @state\n when :idle\n \n if b == Frame::FRAME_CHAR\n @state = :fsize_b1\n @rx = \"\"\n @info = \"\"\n end\n \n when :fsize_b1\n \n checksum_init\n checksum_next(b)\n @rx << b\n \n if (b & 0xf0) != 0xa0\n \n if b != FRAME::FRAME_CHAR\n\n log_error \"first byte of frame is invalid\"\n @state = :start_frame;\n \n end\n \n else\n \n @frame_size = ( (b & 0x7) << 8 )\n @segment = ( ((b & 0x8) == 0x8) ? true : false )\n @state = :fsize_b2\n \n end\n \n when :fsize_b2\n\n checksum_next(b)\n @rx << b\n\n @frame_size |= b \n\n if @frame_size < 6\n log_error \"frame will be too short\"\n @state = :start_frame\n else\n @state = :dest_b1\n end\n \n when :dest_b1\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @dest = OneByte.new(b >> 1)\n @state = :src_b1\n else\n @state = :dest_b2\n end\n \n when :dest_b2\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @dest = TwoByte.new(@rx[-2].to_i >> 1, b >> 1)\n @state = :src_b1\n else\n @state = :dest_b3\n end\n \n when :dest_b3\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n log_error \"invalid address length\"\n @state = :idle\n else\n @state = :dest_b4\n end\n \n when :dest_b4\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n @dest = FourByte.new((@rx[-4].to_i << 8) | @rx[-3].to_i, (@rx[-2].to_i << 8) | b)\n @state = :src_b1\n else\n log_error \"invalid address length\"\n @state = :idle\n end\n \n when :src_b1\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @src = OneByte.new(b >> 1)\n @state = :control\n else\n @state = :src_b2\n end\n \n when :src_b2\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @src = TwoByte.new(@rx[-2].to_i >> 1, b >> 1)\n @state = :control\n else\n @state = :src_b3\n end\n \n when :src_b3\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n log_error \"invalid address length\"\n @state = :idle\n else\n @state = :src_b4\n end\n \n when :src_b4\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n @src = FourByte.new((@rx[-4].to_i << 8) | @rx[-3].to_i, (@rx[-2].to_i << 8) | b)\n @state = :control\n else\n log_error \"invalid address length\"\n @state = :idle\n end\n \n when :control\n \n checksum_next(b)\n @rx << b\n @control = b\n @state = :hcs_b1\n \n when :hcs_b1\n \n checksum_next(b)\n @rx << b \n @state = :hcs_b2\n \n when :hcs_b2\n \n checksum_next(b)\n @rx << b \n \n if @fcs != 0xf0b8\n \n log_error \"invalid HCS\"\n @state = :start_frame\n \n elsif @frame_size == @rx.size\n \n @state = :end_frame\n \n else\n \n @state = :info\n \n end\n \n when :info\n \n checksum_next(b)\n @rx << b \n @info << b \n \n if @rx.size == (@frame_size - 2)\n \n @state = :fcs_b1\n \n end\n \n when :fcs_b1\n \n checksum_next(b)\n @rx << b \n @state = :fcs_b2\n \n when :fcs_b2\n \n checksum_next(b)\n @rx << b \n @state = :end_frame\n \n when :end_frame\n \n if b == Frame::FRAME_CHAR\n \n if @fcs == 0xf0b8\n \n begin\n \n f = Frame.from_decoder(self)\n \n # todo enforce rules for which frames are allowed certain fields\n \n yield(f) if block_given?\n \n rescue => e\n log_error \"#{e.exception}: #{e.message}\"\n log_error e.backtrace.join(\"\\n\")\n end\n \n else\n \n log_error \"invalid fcs\"\n \n end\n \n else\n \n log_error \"expecting end of frame\"\n \n end\n \n @state = :idle\n \n end\n \n self\n \n end", "def makePacket(destIP, sourceIP, type, seqNum, ackNum)\n\tpacket = Packet.new\n\n\tpacket.destIP = destIP\n\tpacket.sourceIP = sourceIP\n\tpacket.type = type\n\tpacket.seqNum = seqNum\n\tpacket.ackNum = ackNum\n\n\tif(type == 0)\n\t\tpacket.data = \"This is ack #{ackNum}\"\n\telsif(type == 1)\n\t\tpacket.data = \"This is packet #{seqNum}\"\n\telse\n\t\tpacket.data = \"This is an EOT\"\n\tend\n\t\t\n\n\treturn packet\nend", "def create_packet(lookup_host, transaction_ID) \n packet = [transaction_ID, FLAGS, QUESTIONS, ANSWERS, AUTHORITY_RRS, ADDITIONAL_RRS].pack(\"S>S>S>S>S>S>\")\n packet += encode_lookup_host(lookup_host)\n packet += [TYPE_A, CLASS_IN].pack(\"S>S>\")\n \n return packet\nend", "def create_arp_reply message\nend", "def acknowledge\n attrs = {\n :acknowledged => true,\n :acknowledged_at => Time.now()\n }\n self.update_attributes(attrs)\n end", "def heartbeat_frame\n OnStomp::Components::Frame.new\n end", "def publishack(channel, data, ack)\n @ws.send(get_publish_object(channel, data, increment_cnt).to_json)\n @acks[@cnt] = [channel, ack]\n end", "def encode_body(buffer)\n buffer << prior_action_ids.to_msgpack\n end", "def send_heartbeat(sequence)\n send_packet(Opcodes::HEARTBEAT, sequence)\n end", "def create_reply\n msg = self.dup\n msg.performative = \"agree\"\n msg.receiver = msg.sender\n msg.sender = aid\n msg.in_reply_to = msg.reply_with\n msg\n end", "def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n\n return if buffer.empty?\n raise ProtocolException, 'Extra bytes at end of Publish Acknowledgment packet'\n end", "def acknowledge(authcode = nil)\n payload = raw\n\n uri = URI.parse(<%= class_name %>.notification_confirmation_url)\n\n request = Net::HTTP::Post.new(uri.path)\n\n request['Content-Length'] = \"#{payload.size}\"\n request['User-Agent'] = \"Active Merchant -- http://activemerchant.org/\"\n request['Content-Type'] = \"application/x-www-form-urlencoded\"\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_strict\n http.use_ssl = true\n\n response = http.request(request, payload)\n\n # Replace with the appropriate codes\n raise StandardError.new(\"Faulty <%= class_name %> result: #{response.body}\") unless [\"AUTHORISED\", \"DECLINED\"].include?(response.body)\n response.body == \"AUTHORISED\"\n end", "def handle_heartbeat_ack(_payload)\n @heartbeat_acked = true\n end", "def get_ack_from_syn_ack(syn_ack)\n ack = get_ack_probe()\n ack.ip_saddr = syn_ack.ip_daddr\n ack.ip_daddr = syn_ack.ip_saddr\n ack.eth_saddr = syn_ack.eth_daddr\n ack.eth_daddr = syn_ack.eth_saddr\n ack.tcp_sport = syn_ack.tcp_dport\n ack.tcp_dport = syn_ack.tcp_sport\n ack.tcp_ack = syn_ack.tcp_seq+1\n ack.tcp_seq = syn_ack.tcp_ack\n ack.tcp_win = 183\n\n return ack\n end", "def rst_req_ack(clk_e,rst,req,ack,port)\n if clk_e then\n # Ensures clk_e is an event.\n clk_e = clk_e.posedge unless clk_e.is_a?(Event)\n par(clk_e) do\n # Handle the reset.\n hif(rst) { port.reset } if rst\n ack <= 0\n # Control the start of the task.\n hif(req) { port.run }\n # Control the end of the task: set ack to 1.\n port.finish { ack <= 1 }\n end\n else\n par do\n # Handle the reset\n hif(rst) { port.reset } if rst\n # Control the start of the task.\n hif(req) { port.run }\n ack <= 0\n # Control the end of the task: set ack to 1.\n port.finish { ack <= 1 }\n end\n end\n end", "def enqueue_packet(payload)\n # try to compress the packet\n payload = client.compress(payload)\n\n # the length of the packet, minus the padding\n actual_length = 4 + payload.bytesize + 1\n\n # compute the padding length\n padding_length = client.block_size - (actual_length % client.block_size)\n padding_length += client.block_size if padding_length < 4\n\n # compute the packet length (sans the length field itself)\n packet_length = payload.bytesize + padding_length + 1\n\n if packet_length < 16\n padding_length += client.block_size\n packet_length = payload.bytesize + padding_length + 1\n end\n\n padding = Array.new(padding_length) { rand(256) }.pack(\"C*\")\n\n unencrypted_data = [packet_length, padding_length, payload, padding].pack(\"NCA*A*\")\n mac = client.hmac.digest([client.sequence_number, unencrypted_data].pack(\"NA*\"))\n\n encrypted_data = client.update_cipher(unencrypted_data) << client.final_cipher\n message = \"#{encrypted_data}#{mac}\"\n\n debug { \"queueing packet nr #{client.sequence_number} type #{payload.getbyte(0)} len #{packet_length}\" }\n\n client.increment(packet_length)\n direct_write(message)\n\n self\n end", "def order_acknowledgement(hash)\n # example use: order_acknowledgement(amazon_order_id: '112-2598432-0713054', merchant_order_id: 336, status: 'Success', items: {'47979057082330' => '438'})\n # order_acknowledgement(amazon_order_id: '112-2598432-0713054', merchant_order_id: 336, status: 'Success')\n # order acknowledgment is done by sending an XML \"feed\" to Amazon\n # as of this writing, XML schema docs are available at:\n # https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/XML_Documentation_Intl.pdf\n # https://images-na.ssl-images-amazon.com/images/G/01/mwsportal/doc/en_US/bde/MWSFeedsApiReference._V372272627_.pdf\n xml = \"\"\n builder = Builder::XmlMarkup.new(:indent => 2, :target => xml)\n builder.instruct! # <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n builder.AmazonEnvelope(:\"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\", :\"xsi:noNamespaceSchemaLocation\" => \"amzn-envelope.xsd\") do |env|\n env.Header do |head|\n head.DocumentVersion('1.01')\n head.MerchantIdentifier(@connection.seller_id)\n end\n env.MessageType('OrderAcknowledgement')\n env.Message do |mes|\n mes.MessageID('1')\n mes.OrderAcknowledgement do |oa|\n oa.AmazonOrderID(hash[:amazon_order_id])\n oa.MerchantOrderID(hash[:merchant_order_id]) unless hash[:merchant_order_id].blank?\n oa.StatusCode(hash[:status])\n (hash[:items] || {}).each do |item_code, merchant_item_id|\n oa.Item do |item|\n item.AmazonOrderItemCode(item_code)\n item.MerchantOrderItemID(merchant_item_id) unless merchant_item_id.blank?\n end\n end\n end\n end\n end\n\n submit_feed('_POST_ORDER_ACKNOWLEDGEMENT_DATA_', xml)\n end", "def acknowledge(delivery_tag)\n @channel.acknowledge(delivery_tag)\n\n self\n end", "def send_goaway(error_code = 0, message = \"\")\n\t\t\t\tframe = GoawayFrame.new\n\t\t\t\tframe.pack @remote_stream_id, error_code, message\n\t\t\t\t\n\t\t\t\twrite_frame(frame)\n\t\t\tensure\n\t\t\t\tself.close!\n\t\t\tend", "def build_challenge_tx(server:, client:, anchor_name:, timeout: 300)\n Stellar::SEP10.build_challenge_tx(\n server: server, client: client, anchor_name: anchor_name, timeout: timeout\n )\n end", "def acknowledge\n payload = @raw\n noti_confirm = Alipay.notification_confirmation_url\n noti_confirm += (\"partner=\" + Alipay::ACCOUNT.to_s + \"&notify_id=\" + notify_id)\n PAYMENT_LOG.info \"===============acknowledge init by jumaimai ============\"\n PAYMENT_LOG.info noti_confirm \n uri = URI.parse(noti_confirm)\n result = Net::HTTP.get(uri)\n PAYMENT_LOG.info \"---------acknowledge result #{result} ----------------\"\n result == \"true\"\n end", "def build_status_request(options)\n datetimestamp = create_time_stamp\n message = datetimestamp + @options[:login] + SUB_ID + options[:transaction_id]\n tokenCode = sign_message(@options[:pem], @options[:password], message)\n\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.tag! 'AcquirerStatusReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do\n xml.tag! 'createDateTimeStamp', datetimestamp\n xml.tag! 'Merchant' do\n xml.tag! 'merchantID', @options[:login]\n xml.tag! 'subID', SUB_ID\n xml.tag! 'authentication' , AUTHENTICATION_TYPE\n xml.tag! 'token', token\n xml.tag! 'tokenCode', tokenCode\n end\n xml.tag! 'Transaction' do\n xml.tag! 'transactionID', options[:transaction_id]\n end\n end\n xml.target!\n end", "def create\n params_hash = {\n 'x_login' => @x_login,\n 'x_trans_key' => @x_trans_key,\n 'x_invoice' => invoice,\n 'x_amount' => amount,\n 'x_iduser' => iduser,\n 'x_bank' => bank,\n 'x_country' => country,\n 'x_sub_code' => sub_code,\n 'type' => response_type\n }\n\n message_to_control = \"#{invoice}D#{amount}P#{iduser}A\"\n\n sha256 = OpenSSL::Digest::SHA256.new\n control = OpenSSL::HMAC.hexdigest(sha256, [@secret_key].pack('A*'), [message_to_control].pack('A*'))\n control = control.upcase\n\n params_hash['control'] = control\n params_hash['x_currency'] = currency if currency\n params_hash['x_description'] = description if description\n params_hash['x_cpf'] = cpf if cpf\n params_hash['x_return'] = return_url if return_url\n params_hash['x_confirmation'] = confirmation_url if confirmation_url\n\n astro_curl(@astro_urls['create'], params_hash)\n end", "def << data\n\n # put the data into the buffer, as\n # we might be replaying\n if data\n @buffer << data\n end\n\n # Don't do work if we don't have to\n if @buffer.length < 2\n return\n end\n\n # decode the first 2 bytes, with\n # opcode, lengthgth, masking bit, and frag bit\n h1, h2 = @buffer.unpack(\"CC\")\n\n # check the fragmentation bit to see\n # if this is a message fragment\n fin = ((h1 & 0x80) == 0x80)\n\n # used to keep track of our position in the buffer\n offset = 2\n\n # see above for possible opcodes\n opcode = (h1 & 0x0F)\n\n # the leading length idicator\n length = (h2 & 0x7F)\n\n # masking bit, is the data masked with\n # a specified masking key?\n masked = ((h2 & 0x80) == 0x80)\n\n # Find errors and fail fast\n if h1 & 0b01110000 != 0\n return emit :error, 1002, \"RSV bits must be 0\"\n end\n\n if opcode > 7\n if !fin\n return emit :error, 1002, \"Control frame cannot be fragmented\"\n elsif length > 125\n return emit :error, 1002, \"Control frame is too large #{length}\"\n elsif opcode > 0xA\n return emit :error, 1002, \"Unexpected reserved opcode #{opcode}\"\n elsif opcode == CLOSE && length == 1\n return emit :error, 1002, \"Close control frame with payload of length 1\"\n end\n else\n if opcode != CONTINUATION && opcode != TEXT_FRAME && opcode != BINARY_FRAME\n return emit :error, 1002, \"Unexpected reserved opcode #{opcode}\"\n end\n end\n\n # Get the actual size of the payload\n if length > 125\n if length == 126\n length = @buffer.unpack(\"@#{offset}n\").first\n offset += 2\n else\n length = @buffer.unpack(\"@#{offset}L!>\").first\n offset += 8\n end\n end\n\n # unpack the masking key\n if masked\n key = @buffer.unpack(\"@#{offset}N\").first\n offset += 4\n end\n\n # replay on next frame\n if @buffer.size < (length + offset)\n return false\n end\n\n # Read the important bits\n payload = @buffer.unpack(\"@#{offset}C#{length}\")\n\n # Unmask the data if it\"s masked\n if masked\n payload.bytesize.times do |i|\n payload[i] = ((payload[i] ^ (key >> ((3 - (i % 4)) * 8))) & 0xFF)\n end\n end\n \n payload = payload.pack(\"C*\")\n\n case opcode\n when CONTINUATION\n\n # We shouldn't get a contination without\n # knowing whether or not it's binary or text\n unless @fragmented\n return emit :error, 1002, \"Unexepected continuation\"\n end\n\n if @fragmented == :text\n @chunks << payload.force_encoding(\"UTF-8\")\n else\n @chunks << payload\n end\n\n if fin\n if @fragmented == :text && !valid_utf8?(@chunks)\n return emit :error, 1007, \"Invalid UTF\"\n end\n\n emit :frame, @chunks, @fragmented == :binary\n @chunks = nil\n @fragmented = false\n end\n\n when TEXT_FRAME\n # We shouldn't get a text frame when we\n # are expecting a continuation\n if @fragmented\n return emit :error, 1002, \"Unexepected frame\"\n end\n\n # emit or buffer\n if fin\n unless valid_utf8?(payload)\n return emit :error, 1007, \"Invalid UTF Hmm\"\n end\n\n emit :frame, payload, false\n else\n @chunks = payload.force_encoding(\"UTF-8\")\n @fragmented = :text\n end\n\n when BINARY_FRAME\n # We shouldn't get a text frame when we\n # are expecting a continuation\n if @fragmented\n return emit :error, 1002, \"Unexepected frame\"\n end\n\n # emit or buffer\n if fin\n emit :frame, payload, true\n else\n @chunks = payload\n @fragmented = :binary\n end\n\n when CLOSE\n code, explain = payload.unpack(\"nA*\")\n if explain && !valid_utf8?(explain)\n emit :close, 1007\n else\n emit :close, response_close_code(code)\n end\n\n when PING\n emit :ping, payload\n\n when PONG\n emit :pong, payload\n\n end\n\n # Remove data we made use of and call back\n # TODO: remove recursion\n @buffer = @buffer[offset + length..-1] || \"\"\n if not @buffer.empty?\n self << nil\n end\n\n end", "def assemble\n [length / 0x100, length % 0x100,\n @type_value,\n @flags_value,\n @stream_id].pack(\"nCCCN\") << @payload\n end", "def unaway\n @socket << \"AWAY\"\n end", "def create_shipment(origin, destination, packages, options={})\n origin, destination = upsified_location(origin), upsified_location(destination)\n options = @options.merge(options)\n packages = Array(packages)\n access_request = build_access_request\n ship_confirm_request = build_ship_confirm(origin, destination, packages, options)\n response = commit(:shipconfirm, save_request(access_request.gsub(\"\\n\",\"\") + ship_confirm_request.gsub(\"\\n\",\"\")), (options[:test] || false))\n parse_ship_confirm_response(origin, destination, packages, response, options)\n end", "def acknowledge(authcode = nil)\n true\n end", "def frame_tx(frame, idx_tx, cnt = 32)\n tx_f = frame.create_frame\n if_tx = $dut.if_list[idx_tx]\n frame_log(false, \"Tx\", idx_tx, tx_f, cnt)\n if_tx.tx(tx_f)\n sleep(0.1)\nend", "def make_arp_packet(target_ip)\n params = @targets[target_ip]\n mac = params[:mac] || Config.instance.hwaddr(@iface)\n\n target_mac = params[:target_mac] || Utils.arp(target_ip)\n\n Packet.gen('Eth', dst: target_mac, src: mac)\n .add('ARP', op: 'reply', sha: mac, spa: params[:spoofed_ip],\n tha: target_mac, tpa: target_ip)\n end", "def send_header(apndp, rnw, address)\n addr = address >> 2\n parity = apndp ^ rnw ^ (addr >> 3) ^ (addr >> 2) & (0x01) ^ (addr >> 1) & (0x01) ^ addr & 0x01\n\n cc '[SWD] -----------------------------------------------------------------'\n cc '[SWD] | Start | AP | Read | AD[2] | AD[3] | Par | Stop | Park |'\n cc \"[SWD] | 1 | #{apndp} | #{rnw} | #{addr[0]} | #{addr[1]} | #{parity[0]} | 0 | 1 |\"\n cc '[SWD] -----------------------------------------------------------------'\n swd_clk.drive(1)\n swd_dio.drive!(1) # send start bit (always 1)\n swd_dio.drive!(apndp) # send apndp bit\n swd_dio.drive!(rnw) # send rnw bit\n swd_dio.drive!(addr[0]) # send address[2] bit\n swd_dio.drive!(addr[1]) # send address[3] bit\n swd_dio.drive!(parity[0]) # send parity bit\n swd_dio.drive!(0) # send stop bit\n swd_dio.drive!(1) # send park bit\n swd_dio.dont_care\n end", "def acknowledge(enquiry)\n @enquiry = enquiry\n\n mail :to => enquiry.email, :subject => \"B&B availability request for Bull Farm Oast\"\n end", "def send_frame sequence_number\n if @sent[sequence_number] == 0\n @sent[sequence_number] = 1\n @buffer_len += 1\n\n if @buffer_len > @max_buffer_len\n @max_buffer_len = @buffer_len\n end\n end\n\n puts \"Sending frame #{sequence_number}\"\n @stats[:frames_sent] += 1\n\n if drop?\n @stats[:frames_dropped] += 1\n puts \"Dropped Frame\"\n return\n end\n\n # send from buffer\n @socket.puts \"#{sequence_number} #{checksum sequence_number} #{@number}\"\n\n to_send = String.new(@buffer[sequence_number])\n if rand(100) < @options[:error_rate] * 100\n @stats[:corrupted] += 1\n puts to_send.length\n puts to_send.getbyte(0)\n to_send.setbyte(0, to_send.getbyte(0) ^ 255)\n end\n\n # timeout for acknowledgement\n reset_timeout\n @socket.write to_send\n end", "def schedule_hangup(params)\n path = @version + '/Call/Hangup/Schedule/'\n method = 'POST'\n return request(path, method, params)\n end", "def receive_nacknowledgement sequence_number\n @stats[:naks_received] += 1\n\n if @buffer[sequence_number] == \"\"\n return\n end\n\n # resend frame\n\n expected_frame = (@next_frame % @options[:window_size]) + (@options[:window_size] * (@window % 2))\n max_frame = @options[:window_size] * ((@window % 2) + 1)\n min_frame = @options[:window_size] * ((@window % 2))\n\n if sequence_number >= max_frame or sequence_number < min_frame\n return\n end\n\n if @options[:implementation] == :go_back\n next_frame = ((@window * @options[:window_size]) + (sequence_number % @options[:window_size]))\n @next_frame = [next_frame, @next_frame].min\n @current_frame = @next_frame\n\n # Undo work done\n \n max_frame = @options[:window_size] * ((@window % 2) + 1)\n else\n send_frame sequence_number\n end\n end", "def acknowledge(delivery_tag)\n @channel.acknowledge(delivery_tag)\n\n self\n end", "def send_packet(payload); end" ]
[ "0.65102285", "0.6487016", "0.6350764", "0.63146967", "0.62166655", "0.6072652", "0.6046227", "0.5995287", "0.58656776", "0.58335435", "0.5818466", "0.5782469", "0.5761721", "0.57331836", "0.5656255", "0.5650389", "0.56393814", "0.5625183", "0.55410886", "0.54408187", "0.5410028", "0.53984857", "0.5388187", "0.5344132", "0.53255504", "0.5302028", "0.52966887", "0.5261811", "0.52455074", "0.52369714", "0.515666", "0.5147714", "0.5125496", "0.5108582", "0.5066515", "0.50409156", "0.5025103", "0.50024235", "0.49956504", "0.4972917", "0.49510112", "0.49473527", "0.49200076", "0.49038056", "0.48845476", "0.4862036", "0.48561272", "0.48488835", "0.48445478", "0.4843494", "0.4840437", "0.4840287", "0.48359397", "0.4810461", "0.47713804", "0.4750945", "0.47410434", "0.47408763", "0.47295463", "0.47110203", "0.46864417", "0.46848246", "0.4682829", "0.46763206", "0.46638894", "0.4663035", "0.46613505", "0.46570662", "0.46513617", "0.46436587", "0.46165764", "0.46156973", "0.46017396", "0.45933884", "0.4586411", "0.4563575", "0.45395702", "0.45188478", "0.45170635", "0.45169157", "0.45168695", "0.45156375", "0.45131576", "0.45111385", "0.44815123", "0.44793355", "0.44780877", "0.4457288", "0.44364715", "0.4433763", "0.44253793", "0.44207838", "0.4415092", "0.440334", "0.4399702", "0.43942565", "0.43936056", "0.43892705", "0.43778232", "0.437664" ]
0.780006
0
Creates an NACK frame
def nack_frame *args create_ack_or_nack 'NACK', args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ack_frame *args\n create_ack_or_nack 'ACK', args\n end", "def gen_packet type, payload\n length = payload.size\n number = Thread.current[:number]\n Thread.current[:number] = number + 1\n \"@ABCD\" + [type,length,number].pack('CS>I>').force_encoding(ENCODING) + payload\nend", "def nacknowledge_frame sequence_number\n @stats[:naks_sent] += 1\n\n # Already acked?\n return if @buffer[sequence_number] == \"\"\n\n @buffer[sequence_number] = nil\n\n # If GO_BACK_N algorithm, then we expect to receive all of the\n # frames again\n expected_frame = (@next_frame % @options[:window_size]) + (@options[:window_size] * (@window % 2))\n\n if @options[:implementation] == :go_back\n next_frame = ((@window * @options[:window_size]) + (sequence_number % @options[:window_size]))\n @next_frame = [next_frame, @next_frame].min\n @current_frame = @next_frame\n\n # Undo work done\n \n max_frame = @options[:window_size] * ((@window % 2) + 1)\n (expected_frame+1..max_frame).each do |i|\n @buffer[i] = nil\n end\n end\n\n if drop_ack?\n @stats[:naks_dropped] += 1\n puts \"Dropped NAK\"\n return\n end\n\n puts \"NAK #{sequence_number}\"\n @socket.puts \"NAK #{sequence_number} #{@number}\"\n\n # we received a response, so good\n reset_timeout\n end", "def generate(frame)\n bytes = Buffer.new\n length = 0\n\n frame[:flags] ||= []\n frame[:stream] ||= 0\n\n case frame[:type]\n when :data\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n\n when :headers\n if frame[:priority]\n frame[:flags] += [:priority] if !frame[:flags].include? :priority\n end\n\n if frame[:flags].include? :priority\n bytes << [frame[:priority] & RBIT].pack(UINT32)\n length += 4\n end\n\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n\n when :priority\n bytes << [frame[:priority] & RBIT].pack(UINT32)\n length += 4\n\n when :rst_stream\n bytes << pack_error(frame[:error])\n length += 4\n\n when :settings\n if frame[:stream] != 0\n raise CompressionError.new(\"Invalid stream ID (#{frame[:stream]})\")\n end\n\n frame[:payload].each do |(k,v)|\n if !k.is_a? Integer\n k = DEFINED_SETTINGS[k]\n\n if k.nil?\n raise CompressionError.new(\"Unknown settings ID for #{k}\")\n end\n end\n\n bytes << [k & RBYTE].pack(UINT32)\n bytes << [v].pack(UINT32)\n length += 8\n end\n\n when :push_promise\n bytes << [frame[:promise_stream] & RBIT].pack(UINT32)\n bytes << frame[:payload]\n length += 4 + frame[:payload].bytesize\n\n when :ping\n if frame[:payload].bytesize != 8\n raise CompressionError.new(\"Invalid payload size \\\n (#{frame[:payload].size} != 8 bytes)\")\n end\n bytes << frame[:payload]\n length += 8\n\n when :goaway\n bytes << [frame[:last_stream] & RBIT].pack(UINT32)\n bytes << pack_error(frame[:error])\n length += 8\n\n if frame[:payload]\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n end\n\n when :window_update\n bytes << [frame[:increment] & RBIT].pack(UINT32)\n length += 4\n\n when :continuation\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n end\n\n frame[:length] = length\n bytes.prepend(commonHeader(frame))\n end", "def create_packet\n lock = (@type == :ack ? true : false)\n payload = @pool.get_payload(@hwaddr,lock)\n return :noboot if payload[:netboot] == 'false'\n params = {\n\top: $DHCP_OP_REPLY,\n\txid: @msg.xid,\n\tchaddr: @msg.chaddr,\n\tyiaddr: payload[:ipaddr],\n\tsiaddr: IPAddr.new(payload[:dhcp_server].join('.')).to_i,\n\tfname: payload[:filename],\n\toptions: [\n\t REPLY_TYPES[@type],\n\t ServerIdentifierOption.new({payload: payload[:dhcp_server]}),\n\t DomainNameOption.new({payload: payload[:domainname]}),\n\t DomainNameServerOption.new({payload: payload[:dns_server]}),\n\t IPAddressLeaseTimeOption.new({payload: payload[:lease_time]}),\n\t SubnetMaskOption.new({payload: payload[:subnet_mask]}),\n\t RouterOption.new({payload: payload[:gateway]})\n\t]\n }\n Message.new(params).pack\n end", "def create_packet(lookup_host, transaction_ID) \n packet = [transaction_ID, FLAGS, QUESTIONS, ANSWERS, AUTHORITY_RRS, ADDITIONAL_RRS].pack(\"S>S>S>S>S>S>\")\n packet += encode_lookup_host(lookup_host)\n packet += [TYPE_A, CLASS_IN].pack(\"S>S>\")\n \n return packet\nend", "def makePacket(destIP, sourceIP, type, seqNum, ackNum)\n\tpacket = Packet.new\n\n\tpacket.destIP = destIP\n\tpacket.sourceIP = sourceIP\n\tpacket.type = type\n\tpacket.seqNum = seqNum\n\tpacket.ackNum = ackNum\n\n\tif(type == 0)\n\t\tpacket.data = \"This is ack #{ackNum}\"\n\telsif(type == 1)\n\t\tpacket.data = \"This is packet #{seqNum}\"\n\telse\n\t\tpacket.data = \"This is an EOT\"\n\tend\n\t\t\n\n\treturn packet\nend", "def push(packet); end", "def write_frame_nonblock frame\n ser = serializer.frame_to_bytes frame\n push_write_buffer ser, frame\n end", "def push(b)\n \n timeNow = Time.now\n \n if (@time - timeNow) > @tio\n @state = :idle \n end\n \n @time = timeNow\n \n case @state\n when :idle\n \n if b == Frame::FRAME_CHAR\n @state = :fsize_b1\n @rx = \"\"\n @info = \"\"\n end\n \n when :fsize_b1\n \n checksum_init\n checksum_next(b)\n @rx << b\n \n if (b & 0xf0) != 0xa0\n \n if b != FRAME::FRAME_CHAR\n\n log_error \"first byte of frame is invalid\"\n @state = :start_frame;\n \n end\n \n else\n \n @frame_size = ( (b & 0x7) << 8 )\n @segment = ( ((b & 0x8) == 0x8) ? true : false )\n @state = :fsize_b2\n \n end\n \n when :fsize_b2\n\n checksum_next(b)\n @rx << b\n\n @frame_size |= b \n\n if @frame_size < 6\n log_error \"frame will be too short\"\n @state = :start_frame\n else\n @state = :dest_b1\n end\n \n when :dest_b1\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @dest = OneByte.new(b >> 1)\n @state = :src_b1\n else\n @state = :dest_b2\n end\n \n when :dest_b2\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @dest = TwoByte.new(@rx[-2].to_i >> 1, b >> 1)\n @state = :src_b1\n else\n @state = :dest_b3\n end\n \n when :dest_b3\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n log_error \"invalid address length\"\n @state = :idle\n else\n @state = :dest_b4\n end\n \n when :dest_b4\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n @dest = FourByte.new((@rx[-4].to_i << 8) | @rx[-3].to_i, (@rx[-2].to_i << 8) | b)\n @state = :src_b1\n else\n log_error \"invalid address length\"\n @state = :idle\n end\n \n when :src_b1\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @src = OneByte.new(b >> 1)\n @state = :control\n else\n @state = :src_b2\n end\n \n when :src_b2\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @src = TwoByte.new(@rx[-2].to_i >> 1, b >> 1)\n @state = :control\n else\n @state = :src_b3\n end\n \n when :src_b3\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n log_error \"invalid address length\"\n @state = :idle\n else\n @state = :src_b4\n end\n \n when :src_b4\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n @src = FourByte.new((@rx[-4].to_i << 8) | @rx[-3].to_i, (@rx[-2].to_i << 8) | b)\n @state = :control\n else\n log_error \"invalid address length\"\n @state = :idle\n end\n \n when :control\n \n checksum_next(b)\n @rx << b\n @control = b\n @state = :hcs_b1\n \n when :hcs_b1\n \n checksum_next(b)\n @rx << b \n @state = :hcs_b2\n \n when :hcs_b2\n \n checksum_next(b)\n @rx << b \n \n if @fcs != 0xf0b8\n \n log_error \"invalid HCS\"\n @state = :start_frame\n \n elsif @frame_size == @rx.size\n \n @state = :end_frame\n \n else\n \n @state = :info\n \n end\n \n when :info\n \n checksum_next(b)\n @rx << b \n @info << b \n \n if @rx.size == (@frame_size - 2)\n \n @state = :fcs_b1\n \n end\n \n when :fcs_b1\n \n checksum_next(b)\n @rx << b \n @state = :fcs_b2\n \n when :fcs_b2\n \n checksum_next(b)\n @rx << b \n @state = :end_frame\n \n when :end_frame\n \n if b == Frame::FRAME_CHAR\n \n if @fcs == 0xf0b8\n \n begin\n \n f = Frame.from_decoder(self)\n \n # todo enforce rules for which frames are allowed certain fields\n \n yield(f) if block_given?\n \n rescue => e\n log_error \"#{e.exception}: #{e.message}\"\n log_error e.backtrace.join(\"\\n\")\n end\n \n else\n \n log_error \"invalid fcs\"\n \n end\n \n else\n \n log_error \"expecting end of frame\"\n \n end\n \n @state = :idle\n \n end\n \n self\n \n end", "def pack\n end", "def build(args={})\n klass = FRAME_TYPE_MAP[args[:type].to_i]\n if(klass == FrameType::Response)\n klass.new(:response => args[:data])\n elsif(klass == FrameType::Error)\n klass.new(:error => args[:data])\n elsif(klass == FrameType::Message)\n unpacked = args[:data].unpack(\"Q>s>a16a#{args[:size]}\")\n klass.new(\n Hash[*([:timestamp, :attempts, :message_id, :message].zip(unpacked).flatten)]\n )\n else\n raise TypeError.new \"Unknown frame type received: #{args[:type].inspect} - #{klass.inspect}\"\n end\n end", "def build_packet\n return [@request_id, @command_type, @string1, @string2].pack(\"VVa#{@string1.length}a2\")\n end", "def make_websocket_frame( opts={} )\n\t\topts = TEST_WEBSOCKET_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_WEBSOCKET_HEADERS )\n\n\t\tMongrel2.log.debug \"WebSocket frame, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def make_websocket_frame( opts={} )\n\t\topts = TEST_WEBSOCKET_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_WEBSOCKET_HEADERS )\n\n\t\tMongrel2.log.debug \"WebSocket frame, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def generate\n blake160_bin = [blake160[2..-1]].pack(\"H*\")\n type = [\"01\"].pack(\"H*\")\n bin_idx = [\"P2PH\".each_char.map { |c| c.ord.to_s(16) }.join].pack(\"H*\")\n payload = type + bin_idx + blake160_bin\n ConvertAddress.encode(@prefix, payload)\n end", "def create_begin\n buffer.allocate(4 + @_model.fbe_size)\n end", "def create_begin\n buffer.allocate(4 + @_model.fbe_size)\n end", "def create_begin\n buffer.allocate(4 + @_model.fbe_size)\n end", "def create_begin\n buffer.allocate(4 + @_model.fbe_size)\n end", "def create_frame\n @frame = Sprite.new(@viewport)\n end", "def create\n @net_rack = NetRack.new(net_rack_params)\n\n respond_to do |format|\n if @net_rack.save\n format.html { redirect_to @net_rack, notice: 'Net rack was successfully created.' }\n format.json { render :show, status: :created, location: @net_rack }\n else\n format.html { render :new }\n format.json { render json: @net_rack.errors, status: :unprocessable_entity }\n end\n end\n end", "def basic_nack(delivery_tag, multiple: false, requeue: false)\n write_bytes FrameBytes.basic_nack(@id, delivery_tag, multiple, requeue)\n nil\n end", "def send_packet(payload); end", "def assemble\n [length / 0x100, length % 0x100,\n @type_value,\n @flags_value,\n @stream_id].pack(\"nCCCN\") << @payload\n end", "def make_header\n\t\t\theader = nil\n\t\t\tlength = self.payload.size\n\n\t\t\tself.log.debug \"Making wire protocol header for payload of %d bytes\" % [ length ]\n\n\t\t\t# Pack the frame according to its size\n\t\t\tif length >= 2**16\n\t\t\t\tself.log.debug \" giant size, using 8-byte (64-bit int) length field\"\n\t\t\t\theader = [ self.flags, 127, length ].pack( 'c2q>' )\n\t\t\telsif length > 125\n\t\t\t\tself.log.debug \" big size, using 2-byte (16-bit int) length field\"\n\t\t\t\theader = [ self.flags, 126, length ].pack( 'c2n' )\n\t\t\telse\n\t\t\t\tself.log.debug \" small size, using payload length field\"\n\t\t\t\theader = [ self.flags, length ].pack( 'c2' )\n\t\t\tend\n\n\t\t\tself.log.debug \" header is: 0: %02x %02x\" % header.unpack('C*')\n\t\t\treturn header\n\t\tend", "def pack tl, tm, th, ch, cl, n\nraw = [tl, tm, th, ch, cl, n].pack \"NnnCCa6\"\nret = new raw\nret.freeze\nret\nend", "def ACK05=(arg)", "def packed()\n header = self.version.chr + \n @type.chr + \n @seq_no.chr + \n @flags.chr + \n TacacsPlus.pack_int_net(@session_id,4) + \n TacacsPlus.pack_int_net(@length,4)\n return(header)\n end", "def create_frame\n @current_frame = {\n :vlocks => {},\n :parent_frame => current_frame\n }\n end", "def acknowledge_frame sequence_number\n @stats[:acks_sent] += 1\n\n puts \"Acking #{sequence_number}\"\n\n expected_frame = (@next_frame % @options[:window_size]) + (@options[:window_size] * (@window % 2))\n max_frame = @options[:window_size] * ((@window % 2) + 1)\n\n # Can we write out something in our buffer?\n if expected_frame == sequence_number\n cur_seq_num = sequence_number\n\n while cur_seq_num < max_frame and not @buffer[cur_seq_num].nil? do\n # Get contents of the buffer\n buffer = @buffer[cur_seq_num]\n break if buffer == \"\"\n\n # Write out the buffer\n puts \"WRITING #{@current_frame}\"\n @file.write buffer\n\n # Clear memory\n @buffer[cur_seq_num] = \"\"\n @buffer_len -= 1 if @options[:implementation] == :selective_repeat\n\n # Consider the next frame\n cur_seq_num += 1\n @current_frame += 1\n @next_frame += 1 \n @delivered += @options[:frame_size]\n end\n end\n\n# if (@delivered % (@options[:frame_size] * @options[:window_size])) == 0\n blah_frame = @next_frame % (@options[:window_size] * 2)\n blah_frame = (@options[:window_size]*2) if blah_frame == 0 and max_frame == (@options[:window_size]*2)\n if blah_frame == max_frame\n puts \"Window received.\"\n receive_next_window\n end\n\n if drop_ack? and not done?\n puts \"Dropping Ack\"\n @stats[:acks_dropped] += 1\n return\n end\n\n if (sequence_number+1) == (@options[:window_size] * 2)\n @socket.puts \"ACK 0 #{@number}\"\n else\n @socket.puts \"ACK #{sequence_number+1} #{@number}\"\n end\n\n if @next_frame == @total_frames\n puts \"Delivered\"\n done\n\n unless @file.is_a? StringIO\n stop_timeout\n @file.close\n @file = nil\n end\n end\n end", "def build_response_packet\n rpacket = RCon::Packet::Source.new\n total_size = 0\n request_id = 0\n type = 0\n response = \"\"\n message = \"\"\n message2 = \"\"\n\n tmp = @socket.recv(4)\n if tmp.nil?\n return nil\n end\n size = tmp.unpack(\"V1\")\n tmp = @socket.recv(size[0])\n request_id, type, message, message2 = tmp.unpack(\"V1V1a*a*\")\n total_size = size[0]\n \n #puts \"size: \"+size.to_s \n #puts \"type: \"+type.to_s\n #puts \"message: \"+message\n #puts \"message2: \"+message2\n \n rpacket.packet_size = total_size\n rpacket.request_id = request_id\n rpacket.command_type = type\n \n # strip nulls (this is actually the end of string1 and string2)\n message.sub! /\\x00\\x00$/, \"\"\n message2.sub! /\\x00\\x00$/, \"\"\n rpacket.string1 = message\n rpacket.string2 = message2\n return rpacket\n end", "def like\n n_prop(:pkt).previous_amount = n_prop(:pkt).amount || 0\n n_prop(:pkt).amount = 1\n create\n end", "def frame(options)\n set RGhost::Frame.new(options)\n end", "def create_nsxt\n #-----------------------------------------------------------------------\n # Get NSX parameters needed to create the network\n #-----------------------------------------------------------------------\n ls_name = self['NAME']\n ls_description = self['TEMPLATE/DESCRIPTION']\n tz_id = self['TEMPLATE/NSX_TZ_ID']\n rep_mode = self['TEMPLATE/NSX_REP_MODE']\n admin_status = self['TEMPLATE/NSX_ADMIN_STATUS']\n\n #-----------------------------------------------------------------------\n # Use first cluster/dc to create the virtual wire\n #-----------------------------------------------------------------------\n host_id = @cluster[0][:hid]\n uuid = @cluster[0][:uuid]\n dc = @cluster[0][:dc]\n\n nsx_client = NSXDriver::NSXClient.new_from_id(host_id)\n\n opaque_spec = %(\n {\n \"transport_zone_id\": \"#{tz_id}\",\n \"replication_mode\": \"#{rep_mode}\",\n \"admin_state\": \"#{admin_status}\",\n \"display_name\": \"#{ls_name}\",\n \"description\": \"#{ls_description}\"\n }\n )\n\n lsw = NSXDriver::OpaqueNetwork.new(nsx_client, nil, tz_id, opaque_spec)\n\n vnet_ref = dc.nsx_network(lsw.ls_id,\n VCenterDriver::Network::NETWORK_TYPE_NSXT)\n\n \"VCENTER_NET_REF = '#{vnet_ref}'\\n\"\\\n \"VCENTER_INSTANCE_ID = '#{uuid}'\\n\"\\\n \"NSX_ID = '#{lsw.ls_id}'\\n\"\\\n \"NSX_VNI = '#{lsw.ls_vni}'\\n\"\\\n \"BRIDGE = '#{lsw.ls_name}'\\n\"\n end", "def makePacket(dest_ip, src_ip, type, seqNum, ackNum, data)\n\tpacket = Packet.new\n\n\tpacket.dest_ip = dest_ip\n\tpacket.src_ip = src_ip\n\tpacket.type = type\n\tpacket.seqNum = seqNum\n\tpacket.ackNum = ackNum\n\tpacket.data = data\n\n\treturn packet\nend", "def test_creating_receive_ACK_message\n test_string = @mf.hex_string_to_string(\"82 00 82\")\n test_message = @msg_fac.new_incoming_message(test_string)\n assert_kind_of(HAIthermo::Message::ReceiveACK, test_message)\n end", "def initialize( * )\n\t\t\tsuper\n\n\t\t\tpayload = self.body.read\n\t\t\tself.body.rewind\n\n\t\t\t@frame = Mongrel2::WebSocket::Frame.new( payload, self.headers.flags )\n\t\tend", "def heartbeat_frame\n OnStomp::Components::Frame.new\n end", "def packed()\n body = @status.chr + \n @flags.chr + \n TacacsPlus.pack_int_net(@server_msg_len,2) + \n TacacsPlus.pack_int_net(@data_len,2) \n \n body << @server_msg if (@server_msg)\n body << @data if (@data) \n return(body)\n end", "def accept_kexinit(packet); end", "def create_bag_sprite\n @bag_sprite = BagSprite.new(@viewport, @pocket_indexes)\n @bag_sprite.index = @socket_index\n end", "def ACK08=(arg)", "def reply_packet(pack)\n rep = pack.dup\n rep.eth_dst, rep.eth_src = rep.eth_src, rep.eth_dst\n rep.ip_dst, rep.ip_src = rep.ip_src, rep.ip_dst\n if pack.is_udp?\n rep.udp_dst, rep.udp_src = rep.udp_src, rep.udp_dst\n else\n rep.tcp_dst, rep.tcp_src = rep.tcp_src, rep.tcp_dst\n end\n rep.ip_id = StructFu::Int16.new(rand(2**16))\n return rep\n end", "def prepare_parsed_frame frame\n force_body_encoding frame\n end", "def send_frame sequence_number\n if @sent[sequence_number] == 0\n @sent[sequence_number] = 1\n @buffer_len += 1\n\n if @buffer_len > @max_buffer_len\n @max_buffer_len = @buffer_len\n end\n end\n\n puts \"Sending frame #{sequence_number}\"\n @stats[:frames_sent] += 1\n\n if drop?\n @stats[:frames_dropped] += 1\n puts \"Dropped Frame\"\n return\n end\n\n # send from buffer\n @socket.puts \"#{sequence_number} #{checksum sequence_number} #{@number}\"\n\n to_send = String.new(@buffer[sequence_number])\n if rand(100) < @options[:error_rate] * 100\n @stats[:corrupted] += 1\n puts to_send.length\n puts to_send.getbyte(0)\n to_send.setbyte(0, to_send.getbyte(0) ^ 255)\n end\n\n # timeout for acknowledgement\n reset_timeout\n @socket.write to_send\n end", "def frame_tx(frame, idx_tx, cnt = 32)\n tx_f = frame.create_frame\n if_tx = $dut.if_list[idx_tx]\n frame_log(false, \"Tx\", idx_tx, tx_f, cnt)\n if_tx.tx(tx_f)\n sleep(0.1)\nend", "def prepare_parsed_frame frame\n end", "def inject(frame)\n @sock.send(frame, 0)\n end", "def inject(frame)\n\t\t@sock.send(frame, 0)\n\tend", "def inject(frame)\n\t\t@sock.send(frame, 0)\n\tend", "def channel_open(packet); end", "def ACK04=(arg)", "def make_tcpmsghdr(data)\r\n\t\tlen = data.length\r\n\t\t# The server doesn't like packets that are bigger...\r\n\t\traise RuntimeError, 'Length too big' if (len > 0x1000)\r\n\t\tlen /= 8\r\n\r\n\t\t# Pack the pieces in ...\r\n\t\tpkt = [\r\n\t\t\t1,0,0,0, # rep, ver, verMinor, pad\r\n\t\t\t0xb00bface, # session id (nice)\r\n\t\t\tdata.length + 16, # msg len\r\n\t\t\t0x20534d4d, # seal (\"MMS \")\r\n\t\t\tlen + 2, # chunkCount\r\n\t\t\t@pkts, 0, # seq, MBZ\r\n\t\t\trand(0xffffffff),rand(0xffffffff) # timeSent -- w/e\r\n\t\t].pack('CCCCVVVVvvVV')\r\n\r\n\t\t# Add the data\r\n\t\tpkt << data\r\n\r\n\t\t# Pad it to 8 bytes...\r\n\t\tleft = data.length % 8\r\n\t\tpkt << (\"\\x00\" * (8 - left)) if (left > 0)\r\n\r\n\t\tpkt\r\n\tend", "def create\r\n @pad = Pad.find(:first, :conditions => [\"id=?\", params[:frame][:pad_id]])\r\n @frame = Frame.new\r\n @frame.name = params[:frame][:name]\r\n @frame.pad_id = params[:frame][:pad_id]\r\n @frame.descr = params[:frame][:descr]\r\n @frame.image = params[:frame][:image]\r\n respond_to do |format|\r\n @pad.frames << @frame\r\n format.html { redirect_to @frame, notice: 'Frame was successfully created.' }\r\n format.json { render json: @frame, status: :created, location: @frame }\r\n end\r\n end", "def ACK10=(arg)", "def create\n @nvs_pack = NvsPack.new(params[:nvs_pack])\n\n respond_to do |format|\n if @nvs_pack.save\n format.html { redirect_to @nvs_pack, notice: 'Nvs pack was successfully created.' }\n format.json { render json: @nvs_pack, status: :created, location: @nvs_pack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nvs_pack.errors, status: :unprocessable_entity }\n end\n end\n end", "def build_packet(kind, type, payload, target, callback = false)\n kind_str = kind.to_s\n persistent = !!(kind_str =~ /persistent/)\n if kind_str =~ /push/\n packet = Push.new(type, payload)\n packet.selector = target[:selector] || :any if target.is_a?(Hash)\n packet.confirm = true if callback\n else\n packet = Request.new(type, payload)\n ttl = @options[:time_to_live]\n packet.expires_at = Time.now.to_i + ttl if !persistent && ttl && ttl != 0\n packet.selector = :any\n end\n packet.from = @identity\n packet.token = AgentIdentity.generate\n packet.persistent = persistent\n if target.is_a?(Hash)\n packet.tags = target[:tags] || []\n packet.scope = target[:scope]\n else\n packet.target = target\n end\n packet\n end", "def receive_nacknowledgement sequence_number\n @stats[:naks_received] += 1\n\n if @buffer[sequence_number] == \"\"\n return\n end\n\n # resend frame\n\n expected_frame = (@next_frame % @options[:window_size]) + (@options[:window_size] * (@window % 2))\n max_frame = @options[:window_size] * ((@window % 2) + 1)\n min_frame = @options[:window_size] * ((@window % 2))\n\n if sequence_number >= max_frame or sequence_number < min_frame\n return\n end\n\n if @options[:implementation] == :go_back\n next_frame = ((@window * @options[:window_size]) + (sequence_number % @options[:window_size]))\n @next_frame = [next_frame, @next_frame].min\n @current_frame = @next_frame\n\n # Undo work done\n \n max_frame = @options[:window_size] * ((@window % 2) + 1)\n else\n send_frame sequence_number\n end\n end", "def initialize( sender_id, conn_id, body='' )\n\t\t\t@frame = Mongrel2::WebSocket::Frame.new( body )\n\t\t\tsuper( sender_id, conn_id, @frame.payload )\n\t\tend", "def build_request\n b = builder\n build_authentication(b)\n b.instruct!\n \n b.LabelRecoveryRequest do\n b.Request do\n b.RequestAction \"LabelRecovery\"\n end\n \n b.LabelSpecification do\n b.LabelImageFormat do\n b.Code \"GIF\"\n end\n end\n \n b.Translate do\n b.LanguageCode \"eng\"\n b.DialectCode \"US\"\n b.Code \"01\"\n end\n \n b.TrackingNumber tracking_number\n end\n end", "def packed()\n body = TacacsPlus.pack_int_net(@server_msg_len,2) +\n TacacsPlus.pack_int_net(@data_len,2) + \n @status.chr\n \n body << @server_msg if (@server_msg)\n body << @data if (@data)\n\n return(body)\n end", "def make_command(msg_id, extra)\r\n\t\t# Two opcodes, get handled differently..\r\n\t\tcase msg_id\r\n\t\twhen 0x30001\r\n\t\t\tdata = [0xf0f0f0f0,0x0004000b,0x0003001c].pack('VVV')\r\n\r\n\t\twhen 0x30002\r\n\t\t\tdata = [0xf0f0f0f1,0xffffffff,0,0x989680,0x00000002].pack('VVVVV')\r\n\r\n\t\tend\r\n\r\n\t\t# Put some data on...\r\n\t\tdata << extra\r\n\r\n\t\t# Pad it to 8 bytes...\r\n\t\tleft = data.length % 8\r\n\t\tdata << (\"\\x00\" * (8 - left)) if (left > 0)\r\n\r\n\t\t# Combine the pieces..\r\n\t\tpkt = [\r\n\t\t\t(data.length / 8) + 1, # chunkLen\r\n\t\t\tmsg_id # msg ID\r\n\t\t].pack('VV')\r\n\t\tpkt << data\r\n\r\n\t\tpkt\r\n\tend", "def ACK09=(arg)", "def ack(opts={})\n\t\t\t# Set delivery tag\n\t\t\tdelivery_tag = opts.delete(:delivery_tag)\n\t\t\tdelivery_tag ||= self.delivery_tag\n\t\t\traise Bunny::AcknowledgementError, \"No delivery tag received\" unless delivery_tag\n\t\t\t\n client.send_frame(\n Qrack::Protocol09::Basic::Ack.new({:delivery_tag => delivery_tag, :multiple => false}.merge(opts))\n )\n\n\t\t\t# reset delivery tag\n\t\t\tself.delivery_tag = nil if self.delivery_tag == delivery_tag\n end", "def add_frame(frame)\n end", "def b_rdt_send message\n puts 'B Sending Data Unreliably...'\n packet = Packet.new\n packet.payload = message.data\n b_udt_send packet\nend", "def ACK03=(arg)", "def frame; end", "def build_request(msgs)\n path = @source_id.nil? ? \"/frames\" : \"/sources/#{@source_id}/frames\"\n req = Net::HTTP::Post.new(path)\n req['Authorization'] = authorization_payload\n req['Content-Type'] = CONTENT_TYPE\n req['User-Agent'] = USER_AGENT\n req.body = msgs.to_msgpack\n req\n end", "def get_packet\n\t\t\t\tfirst_number = read(1).unpack(\"C\")[0]\n\t\t\t\t# get the 'mask' property\n\t\t\t\tpacket_mask = first_number >> 6\n\t\t\t\t# get the 'frame1' property\n\t\t\t\tframe_number = first_number & 0x3F\n\t\t\t\tif frame_number == 0\n\t\t\t\t\t# if frame1 is equal to 0 then 'frame' is equal to 'frame2'\n\t\t\t\t\tframe_number = read(1).unpack(\"C\")[0]\n\t\t\t\telsif frame_number == 1\n\t\t\t\t\t# if frame1 is equal to 1 then 'frame' is equal to 'frame3'\n\t\t\t\t\tframe_number = read(2).unpack(\"n\")[0]\n\t\t\t\tend\n\t\t\t\t# init a 'frame stream' if it doesn't exist yet\n\t\t\t\tif ! @frames_in.has_key? frame_number\n\t\t\t\t\t@frames_in[frame_number] = Frame.new(0,0,0,0)\n\t\t\t\t\tif packet_mask != 0\n\t\t\t\t\t\traise StandardError, \"packet error\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t# for logging purpose\n\t\t\t\t@bytes_in += 1\n\t\t\t\t\n\t\t\t\t# reads the 'time', 'datasize', 'rtmpdatatype' and 'streamid' properties from the socket\n\t\t\t\t# and put them into the 'frame stream' archive\n\t\t\t\t\n\t\t\t\tcase packet_mask\n\t\t\t\twhen 0\n\t\t\t\t\t@frames_in[frame_number].timer = getMediumInt()\n\t\t\t\t\t@frames_in[frame_number].size = getMediumInt()\n\t\t\t\t\t@frames_in[frame_number].data_type = read(1).unpack(\"C\")[0]\n\t\t\t\t\t@frames_in[frame_number].obj = read(4).unpack(\"N\")[0]\n\t\t\t\t\t@bytes_in += 11\n\t\t\t\twhen 1\n\t\t\t\t\t@frames_in[frame_number].timer = getMediumInt()\n\t\t\t\t\t@frames_in[frame_number].size = getMediumInt()\n\t\t\t\t\t@frames_in[frame_number].data_type = read(1).unpack(\"C\")[0]\n\t\t\t\t\t@bytes_in += 7\n\t\t\t\twhen 2\n\t\t\t\t\t@frames_in[frame_number].timer = getMediumInt()\n\t\t\t\t\t@bytes_in += 3\n\t\t\t\twhen 3\n\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\n\t\t\t\tend\n\t\t\t\t# fix the CONNECTION_PACKET bug when its size is larger than 128 bytes (see caution 4.4.6)\n\t\t\t\tif ! @connected\n\t\t\t\t\tdata_length = @frames_in[frame_number].size\n\t\t\t\t\n\t\t\t\t\tif data_length < 129\n\t\t\t\t\t\tdata = read(data_length)\n\t\t\t\t\telsif data_length == 129\n\t\t\t\t\t\tdata = read(data_length+1)\n\t\t\t\t\t\tdata = data[0..-2]\n\t\t\t\t\telse data_length > 129\n\t\t\t\t\t\tdata = read(data_length+1)\n\t\t\t\t\t\tdata = data[0..127] << data[129..-1]\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tdata = read(@frames_in[frame_number].size)\n\t\t\t\tend\n\t\t\t\t# for logging purpose\n\t\t\t\t@bytes_in += data.length\n\t\t\t\t@msg_in += 1\n\t\t\t\t# return a RTMP_PACKET with all its properties (implicit ones included)\n\t\t\t\treturn RTMPPacket.new(\tframe_number,\n\t\t\t\t\t\t\t@frames_in[frame_number].timer,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t@frames_in[frame_number].data_type,\n\t\t\t\t\t\t\t@frames_in[frame_number].obj)\n\t\tend", "def ACK01=(arg)", "def create_nsxv\n #-----------------------------------------------------------------------\n # Get NSX parameters needed to create the network\n #-----------------------------------------------------------------------\n ls_name = self['NAME']\n ls_description = self['TEMPLATE/DESCRIPTION']\n tz_id = self['TEMPLATE/NSX_TZ_ID']\n rep_mode = self['TEMPLATE/NSX_REP_MODE']\n\n #-----------------------------------------------------------------------\n # Use first cluster/dc to create the virtual wire\n #-----------------------------------------------------------------------\n host_id = @cluster[0][:hid]\n uuid = @cluster[0][:uuid]\n\n nsx_client = NSXDriver::NSXClient.new_from_id(host_id)\n\n vwire_spec =\n \"<virtualWireCreateSpec>\\\n <name>#{ls_name}</name>\\\n <description>#{ls_description}</description>\\\n <tenantId>virtual wire tenant</tenantId>\\\n <controlPlaneMode>#{rep_mode}</controlPlaneMode>\\\n <guestVlanAllowed>false</guestVlanAllowed>\\\n </virtualWireCreateSpec>\"\n\n lsw = NSXDriver::VirtualWire.new(nsx_client, nil, tz_id, vwire_spec)\n\n \"VCENTER_NET_REF = '#{lsw.ls_vcenter_ref}'\\n\"\\\n \"VCENTER_INSTANCE_ID = '#{uuid}'\\n\"\\\n \"NSX_ID = '#{lsw.ls_id}'\\n\"\\\n \"NSX_VNI = '#{lsw.ls_vni}'\\n\"\\\n \"BRIDGE = '#{lsw.ls_name}'\\n\"\n end", "def build_client_algorithm_packet; end", "def ACK06=(arg)", "def enqueue_packet(payload); end", "def create_implicit_frame(flags)\n {}.tap do |memo|\n flags.each_pair do |key, val|\n memo[\"@#{key}\"] = [val]\n end\n end\n end", "def send_ack\n sock.put('+')\n vprint_status('Sending ack...')\n end", "def construct_pong\n msg = Protocol::Pong.new\n msg.ctime = DateTime.now\n msg.guid = @driver.guid\n msg.name = @driver.name\n msg.connection_count = @supernode_table.size\n Routing.update_ping_from_routing(msg,@driver.routing)\n msg\n end", "def send_header(apndp, rnw, address)\n addr = address >> 2\n parity = apndp ^ rnw ^ (addr >> 3) ^ (addr >> 2) & (0x01) ^ (addr >> 1) & (0x01) ^ addr & 0x01\n\n cc '[SWD] -----------------------------------------------------------------'\n cc '[SWD] | Start | AP | Read | AD[2] | AD[3] | Par | Stop | Park |'\n cc \"[SWD] | 1 | #{apndp} | #{rnw} | #{addr[0]} | #{addr[1]} | #{parity[0]} | 0 | 1 |\"\n cc '[SWD] -----------------------------------------------------------------'\n swd_clk.drive(1)\n swd_dio.drive!(1) # send start bit (always 1)\n swd_dio.drive!(apndp) # send apndp bit\n swd_dio.drive!(rnw) # send rnw bit\n swd_dio.drive!(addr[0]) # send address[2] bit\n swd_dio.drive!(addr[1]) # send address[3] bit\n swd_dio.drive!(parity[0]) # send parity bit\n swd_dio.drive!(0) # send stop bit\n swd_dio.drive!(1) # send park bit\n swd_dio.dont_care\n end", "def to_payload\n version.htb << [depth].pack('C') << parent_fingerprint.htb <<\n [number].pack('N') << chain_code << [0x00].pack('C') << key.priv_key.htb\n end", "def pack_box\n\t\t# @packages = ActiveShipping::Package.new((WEIGHT * 16), DIMENSIONS, UNITS)\n\t\t@packages = ActiveShipping::Package.new((WEIGHT * 16), DIMENSIONS, UNITS)\n\tend", "def ACK02=(arg)", "def createFrame(var_Object, var_Store)\n \n Common::Logger.print(Common::VAR_DEBUG, self, \"[createFrame]: Creating frame for [#{var_Object.to_s()}]\")\n \n binderList = createBinder(var_Object, var_Store)\n \n Common::Logger.print(Common::VAR_DEBUG, self, \"[createFrame]: Created binder list, lenght \" +\n \"[#{binderList.to_s()}], data [#{binderList.to_s()}]\")\n \n frame = Frame.new(binderList)\n \n Common::Logger.print(Common::VAR_DEBUG, self, \"[createFrame]: Created frame\\n[#{frame.to_s()}]\")\n \n return Frame.new(binderList)\n end", "def ACK07=(arg)", "def transmit packets, delay: 0.1\r\n Ionian::Socket.new host: \"#{SOUNDWEB_IP}:#{SOUNDWEB_PORT}\" do |socket|\r\n packets.each do |packet|\r\n socket.write packet.pack(packet.map { 'C' }.join)\r\n socket.flush\r\n sleep delay\r\n end\r\n end\r\nend", "def create_payload(name, lhost, lport, opts = \"\")\n\n pay = client.framework.payloads.create(name)\n pay.datastore['LHOST'] = lhost\n pay.datastore['LPORT'] = lport\n pay.datastore['EXITFUNC'] = 'thread'\n pay.available_space = 1.gigabyte # this is to generate a proper uuid and make the payload to work with the universal handler\n\n\n if not opts.blank?\n opts.split(\",\").each do |o|\n opt,val = o.split(\"=\",2)\n pay.datastore[opt] = val\n end\n end\n # Validate the options for the module\n pay.options.validate(pay.datastore)\n return pay\n end", "def build(*bytes)\n if is_sysex?(bytes)\n\n # if the 4th byte isn't status, we will just make this a Message object\n # -- this may need some tweaking\n message_class = get_message_class(bytes)\n\n if message_class.nil?\n Message.new(bytes)\n else\n build_typed_message(message_class, bytes)\n end\n end\n\n end", "def initialize\n @logger = Cabin::Channel.get\n @opcode = 0\n @masking_key = \"\"\n @flag_final_payload = 0\n @flag_mask = 0\n\n transition(:flags_and_opcode, 1)\n @buffer = \"\"\n @buffer.force_encoding(\"BINARY\")\n end", "def begin_create\n create_stack.push(true)\n end", "def create_fake_message(h, mask, aad, ct, ptxor)\n ctx = ct.xor(ptxor)\n tag = msg_blocks(aad, ctx).eval(h) + mask\n [aad, ctx, tag.to_i]\n end", "def create\n @snack = Snack.new(snack_params)\n\n respond_to do |format|\n if @snack.save\n format.html { redirect_to @snack, notice: 'Snack was successfully created.' }\n format.json { render :show, status: :created, location: @snack }\n else\n format.html { render :new }\n format.json { render json: @snack.errors, status: :unprocessable_entity }\n end\n end\n end", "def pack(p0) end", "def build_message(type, body, flags=NLM_F_REQUEST, seq=next_seq, pid=@pid)\n body = body.to_str\n header = [\n body.bytesize + NLMSGHDR_SIZE,\n type, flags, seq, pid\n ].pack(NLMSGHDR_PACK)\n # assume the header is already aligned\n header + body\n end", "def create_b2bua_request(session, orig_request=session.irequest, rip=SipperConfigurator[:DefaultRIP], \n rp=SipperConfigurator[:DefaultRP])\n peer_session = get_or_create_peer_session(session, rip, rp)\n if peer_session.initial_state?\n r = peer_session.create_initial_request(orig_request.method, orig_request.uri)\n r.copy_from(orig_request, :from, :to, :route, :content, :content_type, :path, :service_route, :privacy, :referred_by, :p_asserted_identity)\n r.from.tag = \"3\"\n else\n if(orig_request.method == \"CANCEL\")\n r = peer_session.create_cancel\n elsif(orig_request.method == \"ACK\")\n r = peer_session.create_ack\n else\n r = peer_session.create_subsequent_request(orig_request.method)\n end \n r.copy_from(orig_request, :content, :content_type)\n end \n return r\n end", "def ping\n if @type == :receiving\n # Receive packets\n header = @socket.readline\n header.match /^(\\d+)\\s+(.+)\\s+(.+)$/\n sequence_number = $1.to_i\n check = $2\n file_number = $3.to_i\n\n return if file_number != @number\n\n # ACK anything if we have received the file\n if done?\n response = receive_frame sequence_number\n\n @stats[:acks_sent] += 1\n if (sequence_number+1) == (@options[:window_size] * 2)\n @socket.puts \"ACK 0 #{@number}\"\n else\n @socket.puts \"ACK #{sequence_number+1} #{@number}\"\n end\n\n return\n end\n\n # Receive data\n response = receive_frame sequence_number\n if response == :redundant\n puts \"Reacknowledge!\"\n acknowledge_frame sequence_number\n return\n end\n\n # Perform checksum\n if response != :illegal\n sum = checksum sequence_number\n end\n\n # Append to file and send ACK, or send NAK\n if response == :illegal\n puts \"Out of order frame #{sequence_number}\"\n @stats[:out_of_order] += 1\n\n max_frame = @options[:window_size] * ((@window % 2) + 1)\n\n blah_frame = @next_frame % (@options[:window_size] * 2)\n blah_frame = (@options[:window_size]*2) if blah_frame == 0 and max_frame == (@options[:window_size]*2)\n nacknowledge_frame blah_frame\n elsif sum == check\n acknowledge_frame sequence_number\n else\n puts \"Corruption Detected\"\n @stats[:corrupted] += 1\n nacknowledge_frame sequence_number\n end\n else\n # Respond to acknowledgments\n ack = @socket.readline\n\n if ack.match /^ACK\\s+(\\d+)\\s+(\\d+)$/\n # Respond to ACK\n sequence_number = $1.to_i\n file_number = $2.to_i\n\n return if file_number != @number\n\n receive_acknowledgement sequence_number\n\n max_frame = @options[:window_size] * ((@window % 2) + 1)\n\n blah_frame = @next_frame % (@options[:window_size] * 2)\n blah_frame = (@options[:window_size]*2) if blah_frame == 0 and max_frame == (@options[:window_size]*2)\n if blah_frame == max_frame\n # window has been acknowledged\n send_next_window\n elsif @next_frame == @total_frames\n puts \"MEH\"\n stop_timeout\n end\n elsif ack.match /^NAK\\s+(\\d+)\\s+(\\d+)$/\n # Respond to NAK\n file_number = $2.to_i\n\n return if file_number != @number\n\n sequence_number = $1.to_i\n puts \"Frame #{sequence_number} NAK\"\n receive_nacknowledgement sequence_number\n end\n end\n end", "def build_response_packet\n rpacket = RCon::Packet::Source.new\n total_size = 0\n request_id = 0\n type = 0\n response = \"\"\n message = \"\"\n \n\n loop do\n break unless IO.select([@socket], nil, nil, 10)\n\n #\n # TODO: clean this up - read everything and then unpack.\n #\n\n tmp = @socket.recv(14)\n if tmp.nil?\n return nil\n end\n size, request_id, type, message = tmp.unpack(\"VVVa*\")\n total_size += size\n \n # special case for authentication\n break if message.sub! /\\x00\\x00$/, \"\"\n\n response << message\n\n # the 'size - 10' here accounts for the fact that we've snarfed 14 bytes,\n # the size (which is 4 bytes) is not counted, yet represents the rest\n # of the packet (which we have already taken 10 bytes from)\n\n tmp = @socket.recv(size - 10)\n response << tmp\n response.sub! /\\x00\\x00$/, \"\"\n end\n \n rpacket.packet_size = total_size\n rpacket.request_id = request_id\n rpacket.command_type = type\n \n # strip nulls (this is actually the end of string1 and string2)\n rpacket.string1 = response.sub /\\x00\\x00$/, \"\"\n return rpacket\n end", "def xml_start(process_card, &block)\n Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|\n xml.__send__('soap12:Envelope', soap_options) do\n xml.__send__('soap12:Body') do\n xml.__send__(\n process_card,\n xmlns: 'https://www.iatspayments.com/NetGate/',\n &block)\n end\n end\n end\n end", "def frame_rx(idx_rx, extract = false, cnt = 32)\n if_rx = $dut.if_list[idx_rx]\n rx_buf = if_rx.rx_buffer[0]\n rx_f = FrameRx.new\n if (rx_buf.nil?)\n Log.info(\"No frame on #{if_rx.ifname}\")\n else\n offset = 0\n if (extract)\n mac_len = ifh_len_get(1)\n ifh_len = ifh_len_get(2)\n offset = (mac_len + ifh_len)\n ifh = rx_buf[(mac_len..(offset - 1))].unpack('C*')\n for i in ifh_len..39\n ifh << 0\n end\n meta = {\n no_wait: false,\n chip_no: 0,\n xtr_qu: 0,\n etype: 0,\n fcs: 0,\n sw_tstamp: { hw_cnt: 0 },\n length: 0\n }\n rx_f.info = get_req(\"mesa_packet_rx_hdr_decode\", meta, ifh)\n end\n f = Frame.new(rx_buf[offset..-1])\n frame_log(false, \"Rx\", idx_rx, f, cnt)\n rx_f.frame = f\n end\n rx_f\nend", "def create_compound(name, size = 0)\n recorder = CompoundBuilder.new(name, self, size)\n yield(recorder) if block_given?\n recorder.build\n end" ]
[ "0.6508923", "0.5741221", "0.5615624", "0.561104", "0.5471409", "0.5460339", "0.5451302", "0.52467227", "0.520806", "0.51764727", "0.5139951", "0.5100133", "0.50859934", "0.5026159", "0.50260675", "0.5025573", "0.5017612", "0.5017612", "0.5017612", "0.5017612", "0.501504", "0.5011796", "0.5007915", "0.49981746", "0.49924988", "0.49922708", "0.49894997", "0.4977957", "0.4973086", "0.49618968", "0.49569324", "0.4953509", "0.4952181", "0.49484345", "0.49233282", "0.4893127", "0.48821494", "0.48772207", "0.487602", "0.48521957", "0.48497352", "0.48378122", "0.48280394", "0.48071146", "0.4794231", "0.47924554", "0.47910032", "0.47839066", "0.47777227", "0.475532", "0.4753942", "0.4753516", "0.47436368", "0.4737232", "0.4732678", "0.47291604", "0.47219828", "0.47143978", "0.47038138", "0.46976987", "0.46951938", "0.46930182", "0.4690633", "0.46834314", "0.46721", "0.46596777", "0.46592122", "0.4658564", "0.4652409", "0.46459872", "0.46365035", "0.46333286", "0.4628018", "0.46218705", "0.46184587", "0.4608284", "0.46034956", "0.45917577", "0.45904273", "0.45896682", "0.4587463", "0.45857266", "0.45840508", "0.45806476", "0.4575975", "0.45707038", "0.4557066", "0.4556751", "0.45563805", "0.45460084", "0.45392603", "0.4538682", "0.4534111", "0.45332238", "0.45323682", "0.4526651", "0.4526305", "0.45246938", "0.45239502", "0.45140028" ]
0.7034159
0
Creates a heartbeat frame (serialized as a single "\n" character)
def heartbeat_frame OnStomp::Components::Frame.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_heartbeat(sequence)\n send_packet(Opcodes::HEARTBEAT, sequence)\n end", "def save_heartbeat\n timestamp = Time.now.to_i\n store.zadd(\"hb:#{@client.uid}\", timestamp, [Time.now.to_s(:db), @payload].to_json)\n end", "def handle_heartbeat(_payload)\n send_packet(OPCODES[:HEARTBEAT], @session.seq)\n end", "def heartbeat\n me = WORKER_TEMPLATE.dup\n me['name'] = id\n @heartbeat_entry ||= write(me, @heartbeat_refresh + 10)\n @heartbeat_entry.renew(@heartbeat_refresh) unless @heartbeat_entry.canceled?\n end", "def create\n @heartbeat = Heartbeat.new(params[:heartbeat])\n\n respond_to do |format|\n if @heartbeat.save\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully created.' }\n format.json { render json: @heartbeat, status: :created, location: @heartbeat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end", "def handle_heartbeat(packet)\n end", "def create\n @heartbeat = Heartbeat.new(heartbeat_params)\n\n if @heartbeat.save\n render json: @heartbeat, status: :created, location: @heartbeat\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end", "def start_heartbeat\n @hb_received_at = Time.now\n send_heartbeat\n @heartbeat_timer = @reactor.periodical_timer(@heartbeat_interval) { send_heartbeat }\n end", "def set_heartbeat_timer(buffer)\n # Cancel @disconnect_timer.\n SockJS.debug \"Cancelling @disconnect_timer as we're about to send a heartbeat frame in 25s.\"\n @disconnect_timer.cancel if @disconnect_timer\n @disconnect_timer = nil\n\n @alive_checker.cancel if @alive_checker\n\n # Send heartbeat frame after 25s.\n @heartbeat_timer ||= EM::Timer.new(25) do\n # It's better as we know for sure that\n # clearing the buffer won't change it.\n SockJS.debug \"Sending heartbeat frame.\"\n begin\n self.finish\n rescue Exception => error\n # Nah these exceptions are OK ... let's figure out when they occur\n # and let's just not set the timer for such cases in the first place.\n SockJS.debug \"Exception when sending heartbeat frame: #{error.inspect}\"\n end\n end\n end", "def make_websocket_frame( opts={} )\n\t\topts = TEST_WEBSOCKET_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_WEBSOCKET_HEADERS )\n\n\t\tMongrel2.log.debug \"WebSocket frame, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def make_websocket_frame( opts={} )\n\t\topts = TEST_WEBSOCKET_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_WEBSOCKET_HEADERS )\n\n\t\tMongrel2.log.debug \"WebSocket frame, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\tdata = \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\t\treturn data.encode( 'binary' )\n\tend", "def alive\n @heartbeat = Heartbeat.create(heartbeats_params)\n if @heartbeat.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create heartbeat' }, status: :internal_server_error\n end\n end", "def send_tick\n msg = Erlang::Encoder.new\n msg.write_4 0\n msg.write ''\n send_data msg\n end", "def pong(str)\n heartbeat(0b10001010, str)\n end", "def heartbeat(method, str)\n raise Midori::Error::PingPongSizeTooLarge if str.size > 125\n @connection.send_data [method, str.size, str].pack(\"CCA#{str.size}\")\n end", "def send_message(sock,msg)\n msg.ftime = DateTime.now\n body = msg.to_yaml + CRLF\n sock.write(body)\n end", "def test_simulate_status_frame_with_timestamp\n\t\tmqtt_client = SinapseEPDSimulatorVodafone.new(:host => $MQTT_broker, :port => $normal_port, :username => $MQTT_user, :password => $MQTT_password)\n\t\tmqtt_client.connect()\n\t\t\n\t\t# Simulating EPD\n\t\t#result = mqtt_client.simulate_status_frame\n\t\t#assert_equal result[0], {:topic => \"LU/LUM/SEN\", :message => \"FFFFFF;30;1;90;150;220;60;0;60;60;0;60;50\"} # RAE: To Improve\n\n\t\t# EPD with data\n\t\ttimestamp = Time.now.to_i\n\t\tstatus_parameters = {\n\t\t\tid_radio: \"123456\",\n\t\t\ttemp: 30,\n\t\t\tstat: 1,\n\t\t\tdstat: 75,\n\t\t\tvoltage: 220,\n\t\t\tcurrent: 120,\n\t\t\tactive_power: 75,\n\t\t\treactive_power: 0,\n\t\t\tapparent_power: 75,\n\t\t\taggregated_active_energy: 150,\n\t\t\taggregated_reactive_energy: 0,\n\t\t\taggregated_apparent_energy: 150,\n\t\t\tfrequency: 50,\n timestamp: timestamp\n\t\t}\n\n\t\tresult = mqtt_client.simulate_status_frame(\"LU/LUM/SEN\", status_parameters)\n\t\tmsg_result = \"123456;30;1;75;120;220.0;75.0;0.0;75.0;150;0;150;50;\" + timestamp.to_s + \";\"\n\t\tassert_equal result[0], {:topic => \"LU/LUM/SEN\", :message => msg_result} # RAE: To Improve\n\n\t\tmqtt_client.disconnect()\n\n\tend", "def heartbeat\n end", "def heartbeat\n request(Resources::RESOURCE_HEARTBEAT, HTTP_METHOD_POST)\n end", "def new\n @heartbeat = Heartbeat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heartbeat }\n end\n end", "def make_headline(timestamp_str)\n\n delimiter = \": \"\n subject_width = @column - TIMESTAMP_STR_MAX_WIDTH - delimiter.size - 1\n\n subject = @repo.read(Textrepo::Timestamp.parse_s(timestamp_str))[0]\n prefix = '# '\n subject = prefix + subject.lstrip if subject[0, 2] != prefix\n\n ts_part = \"#{timestamp_str} \"[0..(TIMESTAMP_STR_MAX_WIDTH - 1)]\n sj_part = truncate_str(subject, subject_width)\n\n ts_part + delimiter + sj_part\n end", "def send_text_frame message\n log_system_debug \"sending text frame: payload_length=#{message.bytesize}\" if $oversip_debug\n\n frame = \"\".encode ::Encoding::BINARY\n\n # byte1 = OPCODE_TO_INT[:text] | 0b10000000 => 129\n #\n # - FIN bit set.\n # - RSV1-3 bits not set.\n # - opcode = 1\n frame << 129\n\n length = message.bytesize\n if length <= 125\n frame << length # since rsv4 is 0\n elsif length < 65536 # write 2 byte length\n frame << 126\n frame << [length].pack('n')\n else # write 8 byte length\n frame << 127\n frame << [length >> 32, length & 0xFFFFFFFF].pack(\"NN\")\n end\n\n if message.encoding == ::Encoding::BINARY\n frame << message\n else\n frame << message.force_encoding(::Encoding::BINARY)\n end\n\n @connection.send_data frame\n true\n end", "def frame(text, char)\n width = text.max { |a,b| a.length <=> b.length }.size + 4\n output = \"\" << \"#{char}\" * width << \"\\n\"\n text.each { |line| output << \"#{char} #{line}\" << \"%0#{width - line.size - 2}s\" % char << \"\\n\" }\n output << \"#{char}\" * width\nend", "def fmt(data)\n pkt = \"<190>1 \"\n pkt += \"#{data[:t].strftime(\"%Y-%m-%dT%H:%M:%S+00:00\")} \"\n pkt += \"#{@hostname} \"\n pkt += \"#{data[:token]} \"\n pkt += \"#{@procid} \"\n pkt += \"#{@msgid} \"\n pkt += \"#{@structured_data} \"\n pkt += data[:msg]\n \"#{pkt.size} #{pkt}\"\n end", "def build_heartbeat_config_file_for(node)\n write_to_file_for(\"heartbeat\", node) do\n servers = \"#{node.node_entry}\\n#{get_next_node(node).node_entry}\" rescue \"\"\n open(Application.heartbeat_config_file).read.strip ^ {:nodes => servers}\n end\n end", "def beat\n Logger.trace \"beat heart #{Zensu.node.id} #{Time.now.to_i}\"\n remote_publish(\"zensu.heartbeat\", Zensu.node.id, Zensu.config.router_endpoint, Time.now.to_i.to_s)\n end", "def cov_header(timestamp, metrics_h)\n now = Time.at(timestamp)\n <<-EOP\nCreated: #{now}\nTotal Coverage: #{metrics_h['covered_percent']}\nStrength: #{metrics_h['covered_strength']}\nCovered lines: #{metrics_h['covered_lines']}\nTotal lines: #{metrics_h['total_lines']}\nEOP\nend", "def heartbeat_entry\n \"#{name} #{ip} #{Application.managed_services}\"\n end", "def welcome_message\n bolt = <<~BOLT\n `.::-`\n `.-:///////-.`\n `-:////:. `-:///:- /ooo. .ooo/\n `.-:///::///:-` `-//: ymmm- :mmmy .---.\n :///:-. `.:////. -//: ymmm- :mmmy +mmm+\n ://. ///. -//: ymmm--/++/- `-/++/:` :mmmy-:smmms::-\n ://. ://. .://: ymmmdmmmmmmdo` .smmmmmmmmh: :mmmysmmmmmmmms\n ://. ://:///:-. ymmmh/--/hmmmy -mmmd/-.:hmmm+:mmmy.-smmms--.\n ://:.` .-////:-` ymmm- ymmm:hmmm- `dmmm/mmmy +mmm+\n `-:///:-..:///:-.` ymmm- ommm/dmmm` hmmm+mmmy +mmm+\n `.-:////:-` ymmm+ /mmmm.ommms` /mmmh:mmmy +mmmo\n `-.` ymmmmmhhmmmmd: ommmmhydmmmy`:mmmy -mmmmdhd\n oyyy+shddhs/` .+shddhy+- -yyyo .ohddhs\n\n\n BOLT\n example_cmd = if Bolt::Util.windows?\n \"Invoke-BoltCommand -Command 'hostname' -Targets localhost\"\n else\n \"bolt command run 'hostname' --target localhost\"\n end\n prev_cmd = String.new(\"bolt\")\n prev_cmd << \" #{@argv[0]}\" unless @argv.empty?\n\n message = <<~MSG\n 🎉 Welcome to Bolt #{VERSION}\n 😌 We're here to help bring order to the chaos\n 📖 Find our documentation at https://bolt.guide\n 🙋 Ask a question in #bolt on https://slack.puppet.com/\n 🔩 Contribute at https://github.com/puppetlabs/bolt/\n 💡 Not sure where to start? Try \"#{example_cmd}\"\n\n We only print this message once. Run \"#{prev_cmd}\" again for help text.\n MSG\n\n $stdout.print \"\\033[36m#{bolt}\\033[0m\"\n $stdout.print message\n end", "def heartbeat\n if check_heartbeat_acks\n unless @last_heartbeat_acked\n # We're in a bad situation - apparently the last heartbeat wasn't ACK'd, which means the connection is likely\n # a zombie. Reconnect\n LOGGER.warn('Last heartbeat was not acked, so this is a zombie connection! Reconnecting')\n\n # We can't send anything on zombie connections\n @pipe_broken = true\n reconnect\n return\n end\n\n @last_heartbeat_acked = false\n end\n\n send_heartbeat(@session ? @session.sequence : 0)\n end", "def poll_heartbeat_timeout\n now = Hastur::Util.timestamp\n delta = now - @last_heartbeat\n\n # perform heartbeat check\n if delta > @heartbeat\n @logger.debug \"Sending heartbeat\"\n\n msg = Hastur::Message::HB::Agent.new(\n :from => @uuid,\n :data => {\n :name => \"hastur.agent.heartbeat\",\n :value => delta,\n :timestamp => now,\n :labels => {\n :version => Hastur::SERVER_VERSION,\n :period => @heartbeat,\n }\n }\n )\n _send(msg)\n\n @last_heartbeat = now\n end\n end", "def header(message)\n puts \"\\n\"\n puts '+---'\n puts \"| #{message}\"\n puts '+---'\nend", "def ping(str)\n heartbeat(0b10001001, str)\n end", "def create_message token, trx_id, amount, timestamp\n @@function + \"\\n\" + token + \"\\n\" + trx_id + \"\\n\" + amount + \"\\n\" + timestamp\n end", "def write_frame_nonblock frame\n ser = serializer.frame_to_bytes frame\n push_write_buffer ser, frame\n end", "def build_hb_message(host,port,asg_name,domain,account,instance_id)\n timestamp=(Time.now.to_f * 1000.0).to_i # ts should be in ms\n metrics={:account=>account,:appId=>asg_name, :instanceID=>instance_id,:timestamp=>timestamp,:entryList=>[{:name=>\"METRIC_CPU\",:value=>0},{:name=>\"METRIC_CPU_DEMAND\",:value=>0},{:name=>\"METRIC_CPU_NUM\",:value=>1},{:name=>\"METRIC_MEM\",:value=>0},{:name=>\"METRIC_MEM_FREE\",:value=>0}]}\n hb={:host=>host,:port=>port.to_i,:uris=>[\"#{asg_name}.#{domain}\"],:tags=>{:metrics=>metrics}}\n hb.to_json\n end", "def gen_packet type, payload\n length = payload.size\n number = Thread.current[:number]\n Thread.current[:number] = number + 1\n \"@ABCD\" + [type,length,number].pack('CS>I>').force_encoding(ENCODING) + payload\nend", "def send_worker_heartbeat(worker)\n @reactor.log(:debug, \"#{@klass_name}, Heartbeat for worker [#{worker.identity}] on thread [#{Thread.current['reactor-name']}]\")\n @router.write(worker.return_address + @heartbeat_msg_klass.new.to_msgs)\n end", "def setup_heartbeat_timer; end", "def announce(announcement)\n puts \"\\n#{'=' * 76}\\n#{announcement}\\n#{'-' * 76}\"\nend", "def welcome_message\n puts \"\n ┏━━━┓━━━━┏┓━━━━━━━┏┓━━━━━━━━┏┓━\n ┃┏━┓┃━━━━┃┃━━━━━━━┃┃━━━━━━━┏┛┗┓\n ┃┗━┛┃┏┓┏┓┃┗━┓┏┓━┏┓┃┃━┏┓┏━━┓┗┓┏┛\n ┃┏┓┏┛┃┃┃┃┃┏┓┃┃┃━┃┃┃┃━┣┫┃━━┫━┃┃━\n ┃┃┃┗┓┃┗┛┃┃┗┛┃┃┗━┛┃┃┗┓┃┃┣━━┃━┃┗┓\n ┗┛┗━┛┗━━┛┗━━┛┗━┓┏┛┗━┛┗┛┗━━┛━┗━┛\n ━━━━━━━━━━━━━┏━┛┃━━━━━━━━━━━━━━\n ━━━━━━━━━━━━━┗━━┛━━━━━━━━━━━━━━\n\n \".center(100).colorize(:cyan)\n sleep 2\n end", "def frame(text, char)\n length = text.max{|x| x.length}.length + 4\n ret=[]\n ret.push(char*length)\n\n text.each{|x| ret.push(\"#{char} #{x}#{\" \"*(x.length+4-(length))} #{char}\")}\n ret.push(char*length)\n ret.each{|x| puts x}\nend", "def add_heartbeat(event)\n Record.with(collection: \"#{self.class.name.demodulize.downcase}_heartbeat\") do |m|\n m.make!(event.merge(proprietor: { \"#{self.class.name.demodulize.downcase}_id\".to_sym => id }))\n end\n end", "def make_tcpmsghdr(data)\r\n\t\tlen = data.length\r\n\t\t# The server doesn't like packets that are bigger...\r\n\t\traise RuntimeError, 'Length too big' if (len > 0x1000)\r\n\t\tlen /= 8\r\n\r\n\t\t# Pack the pieces in ...\r\n\t\tpkt = [\r\n\t\t\t1,0,0,0, # rep, ver, verMinor, pad\r\n\t\t\t0xb00bface, # session id (nice)\r\n\t\t\tdata.length + 16, # msg len\r\n\t\t\t0x20534d4d, # seal (\"MMS \")\r\n\t\t\tlen + 2, # chunkCount\r\n\t\t\t@pkts, 0, # seq, MBZ\r\n\t\t\trand(0xffffffff),rand(0xffffffff) # timeSent -- w/e\r\n\t\t].pack('CCCCVVVVvvVV')\r\n\r\n\t\t# Add the data\r\n\t\tpkt << data\r\n\r\n\t\t# Pad it to 8 bytes...\r\n\t\tleft = data.length % 8\r\n\t\tpkt << (\"\\x00\" * (8 - left)) if (left > 0)\r\n\r\n\t\tpkt\r\n\tend", "def create_body\n @body = @suntime_text.text.concat(\"\\n\")\n @body.concat(@temperature_text.text).concat(\"\\n\")\n @body.concat(@wind_text.text).concat(\"\\n\")\n @body.concat(@rain_text.text)\n nil\n end", "def frame(text, char)\n\n longest_word_length = (text.map { |w| w.length }.max)\n frame_width = longest_word_length + 4\n\n frame_top_bottom = char*(frame_width)\n frame_arr = []\n\n #top of frame\n frame_arr.push(\"#{frame_top_bottom}\\n\")\n\n #middle of frame (content and the sides of the frame)\n text.each do |word|\n diff = longest_word_length - word.length\n spaces = ' '*diff\n frame_arr.push(\"#{char} #{word} #{spaces}#{char}\\n\")\n end\n\n #bottom of frame\n frame_arr.push(\"#{frame_top_bottom}\")\n frame_arr.join\nend", "def banner(msg)\n puts \"\\n #{'*' * (msg.size + 6)}\"\n puts \" * #{msg} *\"\n puts \" #{'*' * (msg.size + 6)}\\n\"\nend", "def enable_heartbeat(interval = 60, &blk)\n raise 'This API endpoint cannot be used over HTTP.' unless block_given?\n\n websocket.subscribe :setheartbeat, params: { interval: interval }, &blk\n end", "def to_s()\n var_Message = \" ENVS Frame:\"\n \n if(@VAR_BINDER_LIST == nil)\n return var_Message += \" nil\"\n end\n\n var_Message += \"\\n\"\n \n @VAR_BINDER_LIST.each {|binder| var_Message += \" \" + binder.to_s() + \"\\n\"}\n \n return var_Message\n end", "def frame_description(b); end", "def format_realtime message\n message[\"dsb\"] = message[\"dsb\"].to_i\n \n message[\"tmpr\"] = message[\"tmpr\"].to_f if message[\"tmpr\"]\n message[\"tmprC\"] = message[\"tmprC\"].to_f if message[\"tmprC\"]\n message[\"tmprF\"] = message[\"tmprF\"].to_f if message[\"tmprF\"]\n \n message[\"sensor_num\"] = message.delete(\"sensor\").to_i\n message[\"sensor_type\"] = message.delete(\"type\").to_i\n\n message[\"time\"] = Time.parse(message[\"time\"])\n message[\"radio_id\"] = message.delete(\"id\").to_i\n\n total_watts = 0\n # Format the channel watts\n if ch1 = message.delete(\"ch1\")\n message[\"ch1_watts\"] = ch1[\"watts\"].to_i \n total_watts += message[\"ch1_watts\"]\n end\n if ch2 = message.delete(\"ch2\")\n message[\"ch2_watts\"] = ch2[\"watts\"].to_i\n total_watts += message[\"ch2_watts\"]\n end\n if ch3 = message.delete(\"ch3\")\n message[\"ch3_watts\"] = ch3[\"watts\"].to_i \n total_watts += message[\"ch3_watts\"]\n end\n\n message[\"total_watts\"] = total_watts\n \n message\n end", "def create\n for i in 1 .. (@canvas_height - 1) do\n @buffer.append(i, \" \" * (@canvas_width - 1))\n end\n end", "def raise_heartbeat_event\n raise_event(HeartbeatEvent.new(self))\n end", "def congrats_message\n puts \" ___________\"\n sleep 0.1\n puts \" '._==_==_=_.'\"\n sleep 0.1\n puts \" .-\\: /-.\"\n sleep 0.1\n puts \" | (|:. |) |\"\n sleep 0.1\n puts \" '-|:. |-'\"\n sleep 0.1\n puts \" \\::. /\"\n sleep 0.1\n puts \" '::. .'\"\n sleep 0.1\n puts \" ) (\"\n sleep 0.1\n puts \" _.' '._\"\n sleep 0.1\n puts ' `\"\"\"\"\"\"\"`'\n end", "def nack_frame *args\n create_ack_or_nack 'NACK', args\n end", "def process_heartbeats(data, reply, subject)\n # No payload assumed, just reply to the heartbeat.\n nats.publish(reply, '')\n end", "def create_heartbeat\n heartbeat = Thread.new do\n begin\n hb = {:data => {:hb => true}, :user_id => nil}\n ActiveRecord::Base.connection_pool.with_connection do |connection|\n conn = connection.instance_variable_get(:@connection)\n loop do\n opened_boards = $redis.lrange(\"opened_board_ids\", 0, -1)\n puts 'Currently HeartBeating towards channels: #{opened_boards}'\n puts opened_boards\n opened_boards.each do |board_id|\n conn.async_exec \"NOTIFY boards_#{board_id}, '#{hb.to_json}'\"\n end\n sleep 20.seconds\n end\n end\n ensure\n end\n end\nend", "def framed(code)\n \"\\\\begin{framed_shaded}\\n#{code}\\n\\\\end{framed_shaded}\"\n end", "def display\n\t\tr_str = \"Message: \"\n\t\t(@length / 5).times { |i| r_str += \"#{@string[(i * 5)...(i * 5) + 5]} \" }\n\t\tputs r_str\n\tend", "def test_simulate_status_frame\n\t\tmqtt_client = SinapseEPDSimulatorVodafone.new(:host => $MQTT_broker, :port => $normal_port, :username => $MQTT_user, :password => $MQTT_password)\n\t\tmqtt_client.connect()\n\t\t\n\t\t# Simulating EPD\n\t\t#result = mqtt_client.simulate_status_frame\n\t\t#assert_equal result[0], {:topic => \"LU/LUM/SEN\", :message => \"FFFFFF;30;1;90;150;220;60;0;60;60;0;60;50\"} # RAE: To Improve\n\n\t\t# EPD with data\n\t\tstatus_parameters = {\n\t\t\tid_radio: \"123456\",\n\t\t\ttemp: 30,\n\t\t\tstat: 1,\n\t\t\tdstat: 75,\n\t\t\tvoltage: 220,\n\t\t\tcurrent: 120,\n\t\t\tactive_power: 75,\n\t\t\treactive_power: 0,\n\t\t\tapparent_power: 75,\n\t\t\taggregated_active_energy: 150,\n\t\t\taggregated_reactive_energy: 0,\n\t\t\taggregated_apparent_energy: 150,\n\t\t\tfrequency: 50\n\t\t}\n\n\t\tresult = mqtt_client.simulate_status_frame(\"LU/LUM/SEN\", status_parameters)\n\t\tassert_equal result[0], {:topic => \"LU/LUM/SEN\", :message => \"123456;30;1;75;120;220.0;75.0;0.0;75.0;150;0;150;50;\"} # RAE: To Improve\n\n\t\tmqtt_client.disconnect()\n\n\tend", "def serialize_old_format\n buf = [version].pack('V')\n buf << Bitcoin.pack_var_int(inputs.length) << inputs.map(&:to_payload).join\n buf << Bitcoin.pack_var_int(outputs.length) << outputs.map(&:to_payload).join\n buf << [lock_time].pack('V')\n buf\n end", "def encode_body\n body = ''\n\n if @version == '3.1.0'\n raise 'Client identifier too short while serialising packet' if @client_id.nil? || @client_id.bytesize < 1\n raise 'Client identifier too long when serialising packet' if @client_id.bytesize > 23\n end\n\n body += encode_string(@protocol_name)\n body += encode_bytes(@protocol_level.to_i)\n\n if @keep_alive < 0\n raise 'Invalid keep-alive value: cannot be less than 0'\n end\n\n # Set the Connect flags\n @connect_flags = 0\n @connect_flags |= 0x02 if @clean_session\n @connect_flags |= 0x04 unless @will_topic.nil?\n @connect_flags |= ((@will_qos & 0x03) << 3)\n @connect_flags |= 0x20 if @will_retain\n @connect_flags |= 0x40 unless @password.nil?\n @connect_flags |= 0x80 unless @username.nil?\n body += encode_bytes(@connect_flags)\n\n body += encode_short(@keep_alive)\n body += encode_string(@client_id)\n unless will_topic.nil?\n body += encode_string(@will_topic)\n # The MQTT v3.1 specification says that the payload is a UTF-8 string\n body += encode_string(@will_payload)\n end\n body += encode_string(@username) unless @username.nil?\n body += encode_string(@password) unless @password.nil?\n body\n end", "def beat\n if params[:key]\n @server = Server.find_by_key params[:key]\n @server.beat_counter += 1\n else\n @server = Server.new\n @server.key ||= Digest::MD5.hexdigest(rand.to_s)\n @server.beat_counter = 1\n end\n \n @server.hostname = params[:hostname] || request.remote_ip\n @server.port = (params[:port] || 28997).to_i\n @server.title = params[:title] || \"New Server\"\n @server.game_mode = nil\n \n if @server.save\n render :text => @server.key\n else\n render :text => 'Error saving record', :status => 500\n end\n end", "def hockey_message(title, link, version)\n\n message = \"\\n++++++++++++++++++++++++++++++++\\n\" +\n title + \" \\n\" +\n \"Ссылка: \" + link + \" \\n\" +\n \"Версия: \" + version +\n \" \\n++++++++++++++++++++++++++++++++\"\n\nend", "def show_frame()\n\n 2.times {puts \" \"}\n puts \" ______ \"\n puts \" | | \"\n puts \" | | \"\n puts \" | O \"\n puts \" | /|\\\\ \"\n puts \" | / \\\\ \"\n puts \" | \"\n puts \" ____|____ \"\n 2.times {puts \" \"}\n\nend", "def initialize(args)\n @args = args\n @hb = @args[:hb]\n @crlf = \"\\r\\n\"\n end", "def heartbeat_command\n logger.debug(\"heartbeat_command: enter \")\n logger.debug(client.observers_overview.join(\", \"))\n begin\n client.refresh_observers_if_needed\n client.update_cluster if client.status == :down\n client.get(\"foo\")\n rescue Exception => e\n client.status = :down\n logger.debug \"heartbeat - #{e.message} #{e.backtrace}\"\n end\n sleep freq\n end", "def format(tag, time, record)\n [tag, time, record].to_msgpack\n end", "def banner(msg, color: GREEN)\n msg = \"#{msg} \".ljust(72, ' ')\n msg = \"[#{Time.new.strftime('%H:%M:%S')}] #{msg}\"\n msg = \"#{color}#{msg}#{RESET}\" if $stdout.tty?\n puts msg\n end", "def begin_frame(frame_time_ticks: nil, interval: nil, no_display_updates: nil, screenshot: nil)\n {\n method: \"HeadlessExperimental.beginFrame\",\n params: { frameTimeTicks: frame_time_ticks, interval: interval, noDisplayUpdates: no_display_updates, screenshot: screenshot }.compact\n }\n end", "def event_display_line(msg, room)\n msg.replace(\"#{Time.now.strftime(@var[:timestamp])}#{msg}\") if msg\nend", "def setup_heartbeat_timer\n @heartbeat_timer ||= event_loop.timer(BEAT_INTERVAL) do\n event_loop.post { connections.each(&:beat) }\n end\n end", "def process_heartbeat(message)\n @reactor.log(:debug, \"#{@klass_name}, Worker [#{@service_name}] received HB from broker at [#{@hb_received_at}].\")\n end", "def test_conn_1p_0110\n @conn.disconnect\n #\n cha = get_conn_headers() \n cha[\"heart-beat\"] = \"0,0\" # No heartbeats\n conn = nil\n conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)\n good_data = [\n \"\\x41\\xc3\\xb1\\x42\",\n \"\\xc2\\x80\", # 2 byte characters\n \"\\xc2\\xbf\",\n \"\\xdf\\x80\",\n \"\\xdf\\xbf\",\n \"\\xe0\\xa0\\x80\", # 3 byte characters\n \"\\xe0\\xbf\\x80\",\n \"\\xe0\\xa0\\xbf\",\n \"\\xe0\\xbf\\xbf\",\n \"\\xf1\\x80\\x80\\x80\", # 4 byte characters\n \"\\xf1\\xbf\\xbf\\xbf\",\n \"\\xf2\\x80\\x80\\x80\",\n \"\\xf2\\xbf\\xbf\\xbf\",\n \"\\xf3\\x80\\x80\\x80\",\n \"\\xf3\\xbf\\xbf\\xbf\",\n ]\n good_data.each do |string|\n assert conn.valid_utf8?(string), \"good unicode specs 01: #{string}\"\n end\n conn.disconnect\n end", "def send_frame sequence_number\n if @sent[sequence_number] == 0\n @sent[sequence_number] = 1\n @buffer_len += 1\n\n if @buffer_len > @max_buffer_len\n @max_buffer_len = @buffer_len\n end\n end\n\n puts \"Sending frame #{sequence_number}\"\n @stats[:frames_sent] += 1\n\n if drop?\n @stats[:frames_dropped] += 1\n puts \"Dropped Frame\"\n return\n end\n\n # send from buffer\n @socket.puts \"#{sequence_number} #{checksum sequence_number} #{@number}\"\n\n to_send = String.new(@buffer[sequence_number])\n if rand(100) < @options[:error_rate] * 100\n @stats[:corrupted] += 1\n puts to_send.length\n puts to_send.getbyte(0)\n to_send.setbyte(0, to_send.getbyte(0) ^ 255)\n end\n\n # timeout for acknowledgement\n reset_timeout\n @socket.write to_send\n end", "def format(tag, time, record)\n @log.trace \"Buffering #{tag}\"\n [tag, record].to_msgpack\n end", "def make_message message\n prefix = \"#{@file_name}:\".dup\n\n tk = peek_tk\n prefix << \"#{tk[:line_no]}:#{tk[:char_no]}:\" if tk\n\n \"#{prefix} #{message}\"\n end", "def send_control(msg)\n text = JSON.dump(msg)\n dbg(\"-> #{text}\")\n $stdout.write(\"#{text.length+1}\\n\\n#{text}\")\n $stdout.flush\nend", "def response_line\n \"#{Protocol::NAME}/#{@version} #{@code} #{@message}#{Protocol::CRLF}\"\n end", "def start_heartbeat\n\t\tself.log.info \"Starting heartbeat timer.\"\n\t\t@heartbeat_timer = self.reactor.add_periodic_timer( self.class.heartbeat_rate ) do\n\t\t\tself.cull_idle_sockets\n\t\t\tself.ping_all_sockets\n\t\tend\n\tend", "def send_message(message)\n @socket.write(message)\n @socket.write(\"\\004\")\n end", "def format(tag, time, record)\n return [tag, record].to_msgpack\n end", "def format(tag, time, record)\n return [tag, record].to_msgpack\n end", "def handle_hello(payload)\n LOGGER.info { 'Connected' }\n @heartbeat_interval = payload[:d][:heartbeat_interval] / 1000\n @heartbeat_thread = Thread.new { heartbeat_loop }\n if @session.seq\n send_resume\n else\n send_identify\n end\n end", "def format(tag, time, record)\n [tag, time, record].to_msgpack\n end", "def test_conn_1p_0120\n @conn.disconnect\n #\n cha = get_conn_headers() \n cha[\"heart-beat\"] = \"0,0\" # No heartbeats\n conn = nil\n conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)\n bad_data = [\n \"\\x41\\xc2\\xc3\\xb1\\x42\",\n \"\\xed\\xa0\\x80\", # UTF-16 surrogate halves\n \"\\xed\\xad\\xbf\",\n \"\\xed\\xae\\x80\",\n \"\\xed\\xaf\\xbf\",\n \"\\xed\\xb0\\x80\",\n \"\\xed\\xbe\\x80\",\n \"\\xed\\xbf\\xbf\",\n \"\\xc0\", # Single bytes\n \"\\xc1\",\n \"\\xf5\",\"\\xf6\",\"\\xf7\",\"\\xf8\",\"\\xf9\",\"\\xfa\",\"\\xfb\",\"\\xfc\",\n \"\\xfd\",\"\\xfe\",\"\\xff\",\n \"\\xc0\\x80\", # Not shortest representation\n \"\\xc1\\x80\",\n \"\\xc0\\x30\",\n \"\\xc1\\x30\",\n \"\\xe0\\x80\\x80\",\n \"\\xf0\\x80\\x80\\x80\",\n ]\n bad_data.each do |string|\n assert !conn.valid_utf8?(string), \"bad unicode specs 01: #{string}\"\n end\n conn.disconnect\n end", "def to_s; \"<Block #{length}>\"; 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 send(message)\n header = [message.length].pack(\"N\")\n $stdout.print(header, message)\n $stdout.flush\nend", "def message body\r\n checksum = body.reduce(0) { |a, byte| a ^ byte }\r\n \r\n [\r\n STX,\r\n *(body + [checksum]).map { |byte|\r\n # Escape special bytes in a message.\r\n # @see \"London DI Kit.pdf\" page 4\r\n SPECIAL_BYTES.include?(byte) ? [ESC, byte + 0x80] : byte\r\n }.flatten,\r\n ETX\r\n ]\r\nend", "def send_handshake_response(socket, ws_accept)\n\tsocket << \"HTTP/1.1 101 Switching Protocols\\r\\n\" +\n\t\"Upgrade: websocket\\r\\n\" +\n\t\"Connection: Upgrade\\r\\n\" +\n\t\"Sec-WebSocket-Accept: #{ws_accept}\\r\\n\"\n end", "def generate(frame)\n bytes = Buffer.new\n length = 0\n\n frame[:flags] ||= []\n frame[:stream] ||= 0\n\n case frame[:type]\n when :data\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n\n when :headers\n if frame[:priority]\n frame[:flags] += [:priority] if !frame[:flags].include? :priority\n end\n\n if frame[:flags].include? :priority\n bytes << [frame[:priority] & RBIT].pack(UINT32)\n length += 4\n end\n\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n\n when :priority\n bytes << [frame[:priority] & RBIT].pack(UINT32)\n length += 4\n\n when :rst_stream\n bytes << pack_error(frame[:error])\n length += 4\n\n when :settings\n if frame[:stream] != 0\n raise CompressionError.new(\"Invalid stream ID (#{frame[:stream]})\")\n end\n\n frame[:payload].each do |(k,v)|\n if !k.is_a? Integer\n k = DEFINED_SETTINGS[k]\n\n if k.nil?\n raise CompressionError.new(\"Unknown settings ID for #{k}\")\n end\n end\n\n bytes << [k & RBYTE].pack(UINT32)\n bytes << [v].pack(UINT32)\n length += 8\n end\n\n when :push_promise\n bytes << [frame[:promise_stream] & RBIT].pack(UINT32)\n bytes << frame[:payload]\n length += 4 + frame[:payload].bytesize\n\n when :ping\n if frame[:payload].bytesize != 8\n raise CompressionError.new(\"Invalid payload size \\\n (#{frame[:payload].size} != 8 bytes)\")\n end\n bytes << frame[:payload]\n length += 8\n\n when :goaway\n bytes << [frame[:last_stream] & RBIT].pack(UINT32)\n bytes << pack_error(frame[:error])\n length += 8\n\n if frame[:payload]\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n end\n\n when :window_update\n bytes << [frame[:increment] & RBIT].pack(UINT32)\n length += 4\n\n when :continuation\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n end\n\n frame[:length] = length\n bytes.prepend(commonHeader(frame))\n end", "def create\n\n respond_to do |format|\n if @time_frame.save\n format.html { redirect_to time_frames_path, notice: 'Time frame was successfully created.' }\n format.json { render json: @time_frame, status: :created, location: @time_frame }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_frame.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_message(data); end", "def create_message(data); end", "def tell(command, params = {})\n msg_id = Random.new.rand(2**16)\n @connection.write({ method: command, params: params, id: msg_id }.to_json)\n end", "def header( body = '' )\n %[ #!/usr/sbin/dtrace -ZFs \n #pragma D option quiet\\n\n #pragma D option dynvarsize=64m\\n\n #pragma D option bufsize=16m\\n\n #{body}\\n ]\n end", "def test_conn_11h_0060\n @conn.disconnect\n #\n cha = get_conn_headers()\n cha[\"heart-beat\"] = \"a,10\" # Bad header Heartbeats\n conn = nil\n assert_raise Stomp::Error::InvalidHeartBeatHeaderError do\n conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)\n end\n end", "def encode\n\n # Set defaults if necessary\n HEADER_DEFAULTS.each do |k, v|\n send(\"#{k}=\", v) if instance_variable_get(\"@#{k}\").nil?\n end\n\n h_type = HEADER_LENGTHS.invert[header_length]\n\n buffer = Buffer.new\n buffer.write_bitfield [h_type, 2], [channel_id, 6]\n\n if header_length >= 4\n buffer.write_uint24_be timestamp\n end\n\n if header_length >= 8\n buffer.write_uint24_be body_length\n buffer.write_uint8 message_type_id\n end\n\n if header_length == 12\n buffer.write_uint32_le message_stream_id\n end\n\n buffer.string\n end", "def handle_heartbeat_ack(_payload)\n @heartbeat_acked = true\n end" ]
[ "0.599535", "0.5900252", "0.57715", "0.56977063", "0.5687411", "0.5641977", "0.5555416", "0.554638", "0.54458064", "0.54110134", "0.54101676", "0.5333949", "0.5303429", "0.52913487", "0.5267683", "0.5169766", "0.51461494", "0.5113312", "0.5075621", "0.50172395", "0.50087696", "0.49981984", "0.4971725", "0.49707156", "0.49109426", "0.49019283", "0.48917514", "0.48852098", "0.48599398", "0.48583513", "0.4851656", "0.48384145", "0.47640646", "0.47581327", "0.47555596", "0.47519115", "0.47476602", "0.4746669", "0.4744003", "0.47394273", "0.4683127", "0.46713066", "0.46694466", "0.46679875", "0.4660912", "0.4657974", "0.464262", "0.46420133", "0.4639399", "0.46297377", "0.46284845", "0.46143135", "0.4609332", "0.46062452", "0.45922425", "0.45844284", "0.45799276", "0.45671046", "0.45629838", "0.4560404", "0.45562163", "0.45497584", "0.45448825", "0.45338443", "0.4531786", "0.45243177", "0.4523765", "0.45234692", "0.45225674", "0.45063254", "0.45001933", "0.44988465", "0.4492654", "0.44816822", "0.44808924", "0.44784763", "0.4473434", "0.44723985", "0.44657376", "0.44487584", "0.44421008", "0.4436497", "0.4436497", "0.4433963", "0.44288367", "0.44069603", "0.4402191", "0.44017944", "0.43998978", "0.43984815", "0.43934074", "0.4388153", "0.43866232", "0.438413", "0.438413", "0.4381601", "0.43704012", "0.43682095", "0.43644282", "0.4357712" ]
0.65995765
0
tyear, tmonth, tweek assigned where setting spent_on attributes these attributes make time aggregations easier
def spent_on=(date) super self.tyear = spent_on ? spent_on.year : nil self.tmonth = spent_on ? spent_on.month : nil self.tweek = spent_on ? spent_on.cweek : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spent_on=(date)\n super\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil\n self.spent_from = date\n self.spent_to = self.spent_from.advance(:hours=>hours) if self.spent_from && hours\n end", "def spent_on=(date)\n super\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil\n end", "def spent_on=(date)\n super\n if spent_on.is_a?(Time)\n self.spent_on = spent_on.to_date\n end\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil\n end", "def spent_hours_for_issue_and_user_this_month\n return @spent_hours_for_issue_and_user_this_month if defined?(@spent_hours_for_issue_and_user_this_month)\n\n @spent_hours_for_issue_and_user_this_month = nil\n\n return @spent_hours_for_issue_and_user_this_month if issue_id.blank? || user_id.blank?\n\n date_filter = Date.today\n\n @spent_hours_for_issue_and_user_this_month = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month).\n sum(:hours)\n end", "def spent_hours_for_user_this_month\n return @spent_hours_for_user_this_month if defined?(@spent_hours_for_user_this_month)\n\n @spent_hours_for_user_this_month = nil\n\n return @spent_hours_for_user_this_month if user_id.blank?\n\n date_filter = Date.today\n\n @spent_hours_for_user_this_month = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month).\n sum(:hours)\n end", "def spent_hours_for_issue_and_user_previous_month\n return @spent_hours_for_issue_and_user_previous_month if defined?(@spent_hours_for_issue_and_user_previous_month)\n\n @spent_hours_for_issue_and_user_previous_month = nil\n\n return @spent_hours_for_issue_and_user_previous_month if issue_id.blank? || user_id.blank?\n\n date_filter = Date.today.prev_month\n\n @spent_hours_for_issue_and_user_previous_month = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month).\n sum(:hours)\n end", "def spent_hours_for_issue_this_month\n return @spent_hours_for_issue_this_month if defined?(@spent_hours_for_issue_this_month)\n\n @spent_hours_for_issue_this_month = nil\n\n return @spent_hours_for_issue_this_month if issue_id.blank?\n\n date_filter = Date.today\n\n @spent_hours_for_issue_this_month = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month).\n sum(:hours)\n end", "def set_attributes\n @total=0\n @week_total=0\n days=(@finish-@start).to_i + 1 #/60/60/24+1 \n if (7-@start.wday) < days and days < 8\n @total+=total_hours(@start.wday,@finish.wday)\n @week_total=@total\n else\n @total+=total_hours(@start.wday,6)\n days -= (7-@start.wday)\n @total+=total_hours(0,@finish.wday)\n days-=(@finish.wday+1)\n @week_total=@total if days==0\n week_total=total_hours(0,6)\n @total+=week_total * days / 7\n @week_total=week_total if days != 0\n end\n end", "def group_matter_time_spent(col)\n total_data,table_headers,conditions,data = {},{},{},[]\n if params[:report][:summarize_by] == \"lead_lawyer\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:employee_user_id).each do |label,matters|\n \n key = nil\n matters.each do|matter|\n key = matter.get_lawyer_name unless key\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n actual_duration = @dur_setng_is_one100th ? one_hundredth_timediffernce(e.actual_duration) : one_tenth_timediffernce(e.actual_duration)\n bill_hours += actual_duration\n end\n \n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.contact ? matter.contact.name : \"\",matter.contact ? matter.contact.accounts[0] ? matter.contact.accounts[0].name : \"\" : \"\",matter.matter_no,matter.matter_category,matter.matter_status ? matter.matter_status.alvalue : \"\",rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n \n conditions[key] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[key] = data\n sum_hrs(conditions,key)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n \n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:label_client),t(:label_Account),t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"#{t(:text_projected)} #{t(:text_hour)}\"]\n elsif params[:report][:summarize_by] == \"client\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:contact_id).each do |label,matters|\n key = nil\n matters.each do|matter|\n key = matter.contact ? matter.contact.name : nil unless key\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.get_lawyer_name,matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"\" : \"\",matter.matter_no,matter.matter_category,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n\n conditions[key] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[key] = data\n sum_hrs(conditions,key)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n\n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:text_select_lawyer),\"#{t(:label_Account)}\",t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n elsif params[:report][:summarize_by] == \"account\"\n ehrs,bhrs,rhrs = 0,0,0\n matters = col.collect do |matter|\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n account = matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"None\" : \"None\"\n [matter.name,matter.get_lawyer_name,matter.contact ? matter.contact.name : \"\",matter.matter_no,matter.matter_category,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours),account]\n end\n matters_hash = {}\n matters.each do |matter|\n key = matter.pop\n if matters_hash.has_key?(key)\n matters_hash[key] << matter\n else\n matters_hash[key] = [matter]\n end\n end\n matters_hash.each do |label,matters|\n matters.each do |matter|\n ehrs += matter[-3].to_f\n bhrs += matter[-2].to_f\n rhrs += matter[-1].to_f\n end\n conditions[label] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[label] = matters\n sum_hrs(conditions,label)\n end\n \n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:text_select_lawyer),t(:label_client),t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n elsif params[:report][:summarize_by] == \"lit_type\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:matter_category).each do |label,matters|\n matters.each do|matter|\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.contact ? matter.contact.name : \"\",matter.get_lawyer_name,matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"\" : \"\",matter.matter_no,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n label = label.try(:capitalize)\n conditions[label] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[label] = data\n sum_hrs(conditions,label)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n\n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:label_client),t(:text_select_lawyer),\"#{t(:label_Account)}\",t(:text_matter_id),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n end\n alignment = {0=> :left,1=> :left,2=> :left,3=> :center,4=> :center,5=>:center,6=> :center,7=> :center,8=> :center} if params[:format] == \"pdf\"\n [total_data,table_headers,conditions,column_widths,alignment]\n end", "def worktype_tracking(begda,endda)\n teams=Team.find(:all)\n curdate = begda\n wt_total = []\n until curdate > endda do\n teams.each do |team|\n wt_team_month = calculate_worktype_distribution(curdate,team.id)\n # get the total time and calculate percentages\n sum_of_times_booked = 0\n wt_team_month.keys.each do |wt|\n sum_of_times_booked += wt_team_month[wt][:daysbooked]\n end\n\n wt_team_month.keys.each do |wt|\n perc = (wt_team_month[wt][:daysbooked] / sum_of_times_booked)*100\n wt_total << { :month => Date::ABBR_MONTHNAMES[curdate.month], \n :team_id => team.id,\n :worktype_id => wt,\n :daysbooked => wt_team_month[wt][:daysbooked],\n :perc => perc} \n end\n end\n\n curdate = curdate >> 1\n end\n return wt_total\n end", "def monthly_timesheet\n \n end", "def trend_points_for_creation_date(obj)\n if obj.created_at > 1.day.ago then 50\n elsif obj.created_at > 1.week.ago then 25\n elsif obj.created_at > 2.weeks.ago then 10\n elsif obj.created_at > 3.weeks.ago then 3\n else 0\n end\nend", "def print\n current_ts = Timesheet.find(params[:current_ts_id])\n if params[:weekof].present?\n weekof = Date.parse(params[:weekof]) \n else\n weekof = Date.today\n end\n name = User.current.firstname\n wage = User.current.wage.amount.to_s\n current = Date.today\n\n #TODO change the name of the default scopes on TimeEntry for dates, they need to express that the collection includes the dates indicated.\n usrtiments = TimeEntry.foruser(User.current).after(weekof).before(weekof + 6.days) #this use of before and after is cool\n\n mon = (usrtiments.select {|t| t.spent_on == weekof}).inject(0) {|sum, x| sum + x.hours}\n tue = (usrtiments.select {|t| t.spent_on == (weekof + 1)}).inject(0) {|sum, x| sum + x.hours} \n wed = (usrtiments.select {|t| t.spent_on == (weekof + 2)}).inject(0) {|sum, x| sum + x.hours}\n thu = (usrtiments.select {|t| t.spent_on == (weekof + 3)}).inject(0) {|sum, x| sum + x.hours}\n fri = (usrtiments.select {|t| t.spent_on == (weekof + 4)}).inject(0) {|sum, x| sum + x.hours}\n sat = (usrtiments.select {|t| t.spent_on == (weekof + 5)}).inject(0) {|sum, x| sum + x.hours}\n sun = (usrtiments.select {|t| t.spent_on == (weekof + 6)}).inject(0) {|sum, x| sum + x.hours}\n\n hours = mon + tue + wed + thu + fri + sat + sun\n status =\"\"\n\n #need to check for valid datetime instead of nil\n if current_ts.paid != nil\n status = \"Paid\"\n elsif current_ts.paid == nil && current_ts.submitted != nil\n status = \"Submitted, but not paid\"\n else\n status = \"Not submitted and not paid\"\n end\n\n if hours == 0 || hours > 100\n #flash[:warning] = 'You do not have any hours for the specified week! Add hours to print a timecard.'\n flash[:warning] = 'Error, error! Either you are printing a timesheet with no need for payment or you got some wiring loose and logged too many hours.'\n redirect_to :action => 'employee_index' #potential problem with this when admin uses it\n else #method in timesheethelper\n send_data (generate_timesheet_pdf(name, wage, current, weekof, mon, tue, wed, thu, fri, sat, sun,status),\n :filename => name + \"_timecard_from_\" + weekof.to_s + \"_to_\" + (weekof + 6.days).to_s + \".pdf\",\n :type => \"application/pdf\")\n end\n end", "def spent_hours_for_issue_and_user\n return @spent_hours_for_issue_and_user if defined?(@spent_hours_for_issue_and_user)\n\n @spent_hours_for_issue_and_user = nil\n\n return @spent_hours_for_issue_and_user if issue_id.blank? || user_id.blank?\n\n @spent_hours_for_issue_and_user = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n sum(:hours)\n end", "def spent_hours_for_user_previous_month\n return @spent_hours_for_user_previous_month if defined?(@spent_hours_for_user_previous_month)\n\n @spent_hours_for_user_previous_month = nil\n\n return @spent_hours_for_user_previous_month if user_id.blank?\n\n date_filter = Date.today.prev_month\n\n @spent_hours_for_user_previous_month = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month).\n sum(:hours)\n end", "def calculate_week_time\n week_begin = DateTime.now.utc.beginning_of_week\n deadline = DateTime.now.utc.end_of_week\n self.commits.where(\"begin_time > ? and end_time < ?\", week_begin, deadline).sum(:spent_time)\n end", "def setup_timetable\n # Create a hash of free times for output rendering\n @free_times = [{}, {}, {}, {}, {}, {}, {}]\n @person.free_times.each do |ft|\n ft.start_time.step(ft.end_time + (ft.end_time % Timetable::INTERVAL), Timetable::INTERVAL) do |time|\n css_class = ft.css_class.present? ? ft.css_class : 'good'\n @free_times[ft.day_of_week][time] = css_class\n end\n end\n # raise @free_times.inspect\n end", "def revenue_data(kind = '')\n range = case kind.presence || 'this_year'\n when 'this_year'\n Date.today.beginning_of_year..Date.today\n when 'past_year'\n 1.year.ago.beginning_of_year.to_date..1.year.ago.end_of_year.to_date\n when '6_months_ago'\n 5.months.ago.beginning_of_month.to_date..Date.today\n end\n range.select{|d| d.day == 1}.map{|d| [d.strftime('%Y-%m'), mentor_payments.where(payment_at: d.beginning_of_day..d.end_of_month.end_of_day).sum('payments.amount')] }.to_h\n end", "def deviation_hours_for_issue_and_user_this_month\n return @deviation_hours_for_issue_and_user_this_month if defined?(@deviation_hours_for_issue_and_user_this_month)\n\n @deviation_hours_for_issue_and_user_this_month = nil\n\n return @deviation_hours_for_issue_and_user_this_month if user_id.blank?\n\n date_filter = Date.today\n\n scope_for_time_entries = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.deviation_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @deviation_hours_for_issue_and_user_this_month = cf.format.cast_total_value(cf, total)\n end", "def calculated_spend_by_month\n return if !organisation.respond_to?(:payments) || organisation.payments.count == 0\n res_hsh = {}\n group_by = case ActiveRecord::Base.connection.adapter_name\n when 'MySQL'\n # https://github.com/django/django/blob/master/django/db/backends/mysql/base.py#L207\n \"CAST(DATE_FORMAT(date, '%Y-%m-01 00:00:00') AS DATETIME)\"\n else # PostgreSQL\n # https://github.com/django/django/blob/master/django/db/backends/postgresql_psycopg2/operations.py#L35\n \"DATE_TRUNC('month', date)\"\n end\n ft_sums = organisation.payments.sum(:value, :conditions => {:date_fuzziness => nil}, :group => group_by).to_a\n fuzzy_sums = organisation.payments.all(:select => 'SUM(value) AS value, date, date_fuzziness', :conditions => \"date_fuzziness IS NOT NULL\", :group => 'date, date_fuzziness')\n\n fuzzy_sums.each{ |fs| ft_sums += fs.averaged_date_and_value }\n\n ft_sums.each do |ft_sum|\n res_hsh[ft_sum.first.to_date.beginning_of_month] = res_hsh[ft_sum.first.to_date.beginning_of_month].to_f + ft_sum.last\n end\n\n months_with_vals = res_hsh.sort\n \n first_month, last_month = months_with_vals.first, months_with_vals.last\n spend_by_month_array(first_month.first, last_month.first, months_with_vals)\n end", "def group_time_accounted_hash(params,tcol)\r\n lookup_activities = current_company.company_activity_types\r\n activities = ReportsHelper.get_lookups(lookup_activities)\r\n conditions,data,total_data,table_headers = {},[],{},[]\r\n duration,billamount,discount,override,finalamount = 0,0,0,0,0\r\n if params[:report][:selected] == \"matter\"\r\n\r\n tcol.group_by(&:matter_id).each do|label,col|\r\n key = nil\r\n client = nil\r\n col.each do |obj|\r\n @dur_setng_is_one100th ? actual_duration = one_hundredth_timediffernce(obj.actual_duration) : actual_duration = one_tenth_timediffernce(obj.actual_duration)\r\n if !key and obj.matter\r\n key = obj.matter.clipped_name\r\n client = \" Contact : \" + (obj.matter.contact ? obj.matter.contact.name : \"\")\r\n end\r\n duration += actual_duration.to_f if actual_duration\r\n billamount = billamount + (obj.actual_activity_rate * actual_duration.to_f)\r\n discount += obj.billing_percent if obj.billing_percent\r\n override += obj.final_billed_amount if obj.billing_method_type == 3\r\n finalamount += obj.final_billed_amount if obj.final_billed_amount\r\n\r\n\r\n data << [obj.time_entry_date,obj.performer.try(:full_name).try(:titleize),actual_duration,activities[obj.activity_type],obj.is_billable ? \"Yes\" : \"No\",obj.actual_activity_rate,obj.actual_activity_rate * actual_duration.to_f,obj.billing_percent,obj.billing_method_type == 3 ? obj.final_billed_amount : '',obj.final_billed_amount]\r\n end\r\n next unless key\r\n total_data[key] = data\r\n conditions[key] = client\r\n\r\n data = []\r\n end\r\n conditions[:entries] = [duration,billamount,discount,override,finalamount]\r\n column_widths = { 0 => 60, 1 => 80, 2 => 80 , 3 => 120 , 4 => 60 , 5 => 60 , 6 => 60 ,7 => 70 , 8 => 60 , 9 => 60}\r\n table_headers = [t(:label_date),t(:text_lawyer),t(:label_duration_hrs),t(:text_activity_type),t(:text_billable),\"Rate/hr($)\",\"#{t(:text_bill)} #{t(:text_amt)}\",t(:text_discount_p),\"#{t(:text_override)} #{t(:text_amt)}\",\"#{t(:label_final_bill)} #{t(:text_amt)}\"]\r\n alignment = { 0 => :right, 1 => :right} if params[:format] == \"pdf\"\r\n elsif params[:report][:selected] == \"contact\"\r\n tcol.group_by(&:contact_id).each do|label,col|\r\n key = nil\r\n\r\n col.each do |obj|\r\n @dur_setng_is_one100th ? actual_duration = one_hundredth_timediffernce(obj.actual_duration) : actual_duration = one_tenth_timediffernce(obj.actual_duration)\r\n if !key and obj.contact\r\n key = obj.contact.name\r\n\r\n end\r\n duration += actual_duration.to_f if actual_duration\r\n billamount = billamount + (obj.actual_activity_rate * actual_duration.to_f)\r\n discount += obj.billing_percent if obj.billing_percent\r\n override += obj.final_billed_amount if obj.billing_method_type == 3\r\n finalamount += obj.final_billed_amount if obj.final_billed_amount\r\n\r\n data << [obj.time_entry_date,obj.performer.try(:full_name).try(:titleize),obj.matter ? obj.matter.clipped_name : \"\",actual_duration,activities[obj.activity_type],obj.is_billable ? \"Yes\" : \"No\",obj.actual_activity_rate,obj.actual_activity_rate * actual_duration.to_f,obj.billing_percent,obj.billing_method_type == 3 ? obj.final_billed_amount : '',obj.final_billed_amount]\r\n end\r\n next unless key\r\n total_data[key] = data\r\n\r\n data = []\r\n end\r\n conditions[:entries] = [duration,billamount,discount,override,finalamount]\r\n column_widths = { 0 => 60, 1 => 80, 2 => 80 , 3 => 60 , 4 => 80 , 5 => 60 , 6 => 60 ,7 => 60 , 8 => 70 , 9 => 60,10 => 60}\r\n table_headers = [t(:label_date),t(:text_lawyer),t(:text_matter),t(:label_duration_hrs),t(:text_activity_type),t(:text_billable),\"#{t(:label_rate_hr)}\",\"#{t(:text_bill)} #{t(:text_amt)}\",t(:text_discount_p),\"#{t(:text_override)} #{t(:text_amt)}\",\"#{t(:label_final_bill)} #{t(:text_amt)}\"]\r\n end\r\n\r\n [total_data,conditions,table_headers,column_widths, alignment]\r\n\r\n end", "def total_timesheet\n if self.shifts.any?\n hours = self.shifts.sum(:time_worked)\n if hours > 40\n self.reg_hours = 40\n self.ot_hours = hours - 40\n ot_rate = job.pay_rate * 1.5\n self.gross_pay = job.pay_rate * self.reg_hours + self.ot_hours * ot_rate\n else\n pay = job.pay_rate * hours\n self.reg_hours = hours\n self.ot_hours = 0\n self.gross_pay = pay\n self.total_bill = pay * job.mark_up\n \n end\n end\n end", "def date_spent=(date_spent)\n\t write_attribute(:date_spent, date_spent)\n \t self.month_name = Date::MONTHNAMES[date_spent.month]\n\t self.month_id = date_spent.strftime(\"%m\").to_i\n\t self.week_id = date_spent.strftime(\"%w\").to_i\n\t self.year = date_spent.strftime(\"%y\").to_i\n end", "def monthly_stake\n bets.not_combo.monthly_stake + combo_bets.monthly_stake\n end", "def group_time_billed(tcol)\r\n conditions,data,total_data,table_headers = {},[],{},[]\r\n #Grouping by Lawyer\r\n hours,billedhrs,amt = 0,0,0\r\n tcol.group_by(&:employee_user_id).each_value do|col|\r\n \r\n key = nil\r\n array = []\r\n #Grouping by Time entry to calculate total hours billed for particular tima entry date for individual lawywer\r\n col.group_by(&:time_entry_date).each do |label,gcol|\r\n\r\n t_hours,billable_hours,famount = 0,0,0\r\n \r\n gcol.each do|obj|\r\n @dur_setng_is_one100th ? actual_duration = one_hundredth_timediffernce(obj.actual_duration) : actual_duration = one_tenth_timediffernce(obj.actual_duration)\r\n key = obj.performer.try(:full_name).try(:titleize) unless key\r\n t_hours += actual_duration.to_f\r\n if obj.is_billable #if billable\r\n billable_hours += actual_duration.to_f\r\n end\r\n famount += obj.final_billed_amount\r\n \r\n end\r\n if t_hours == billable_hours\r\n billpercent = \"100 %\"\r\n elsif billable_hours == 0\r\n billpercent = \"\"\r\n else\r\n billpercent = ((billable_hours/t_hours.to_f) * 100).roundf2(2).to_s + \" %\"\r\n end\r\n hours += t_hours\r\n billedhrs += billable_hours\r\n amt += famount\r\n data << [label.to_s,t_hours,billable_hours,billpercent,famount]\r\n unless conditions[key]\r\n conditions[key] = [t_hours,billable_hours,famount]\r\n else\r\n conditions[key][0] += t_hours\r\n conditions[key][1] += billable_hours\r\n conditions[key][2] += famount\r\n end #storing each tables result data\r\n end\r\n total_data[key] = data\r\n data = []\r\n end\r\n conditions[:expenses] = [hours,billedhrs,amt]\r\n column_widths = { 0 => 100, 1 => 100, 2 => 100 , 3 => 100,4 => 100 }\r\n alignment = { 0 => :center, 1 => :center, 2 => :center , 3 => :center,4 => :center }\r\n table_headers = [t(:label_date),\"#{t(:text_hour)} #{t(:text_accounted)}\",t(:text_hoursbilled),t(:text_hoursbilledpercent),t(:text_amt)]\r\n [total_data,conditions,table_headers,column_widths,alignment]\r\n end", "def flight_miles_tally\n get_tally_by_flight_column_name(\"flight_miles\")\n end", "def billable_hours_for_issue_and_user_this_month\n return @billable_hours_for_issue_and_user_this_month if defined?(@billable_hours_for_issue_and_user_this_month)\n\n @billable_hours_for_issue_and_user_this_month = nil\n\n return @billable_hours_for_issue_and_user_this_month if issue_id.blank? || user_id.blank?\n\n date_filter = Date.today\n\n scope_for_time_entries = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.billable_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @billable_hours_for_issue_and_user_this_month = cf.format.cast_total_value(cf, total)\n end", "def performance\n # QUOTES\n @quotes_count = Quote.where(created_at: [1.year.ago..Time.zone.now]).group_by_month(:created_at, time_zone: Time.zone).count\n @quotes_one_year_ago = Quote.where(created_at: [2.year.ago..1.year.ago.end_of_month]).group_by_month(:created_at, time_zone: Time.zone).count\n @quotes_two_years_ago = Quote.where(created_at: [3.year.ago..2.year.ago.end_of_month]).group_by_month(:created_at, time_zone: Time.zone).count\n\n @quotes_one_year_ago = align_chartkick_dates(@quotes_one_year_ago, 1)\n @quotes_two_years_ago = align_chartkick_dates(@quotes_two_years_ago, 2)\n\n @quote_dates = [\n {name: Time.now.year, data: @quotes_count},\n {name: 1.year.ago.year, data: @quotes_one_year_ago},\n {name: 2.years.ago.year, data: @quotes_two_years_ago}\n ]\n\n\n # ORDERS\n @orders_count = Order.where(created_at: [1.year.ago..Time.zone.now]).group_by_month(:created_at, time_zone: Time.zone).count\n @orders_one_year_ago = Order.where(created_at: [2.year.ago..1.year.ago.end_of_month]).group_by_month(:created_at, time_zone: Time.zone).count\n @orders_two_years_ago = Order.where(created_at: [3.year.ago..2.year.ago.end_of_month]).group_by_month(:created_at, time_zone: Time.zone).count\n\n @orders_one_year_ago = align_chartkick_dates(@orders_one_year_ago, 1)\n @orders_two_years_ago = align_chartkick_dates(@orders_two_years_ago, 2)\n\n @order_dates = [\n {name: Time.now.year, data: @orders_count},\n {name: 1.year.ago.year, data: @orders_one_year_ago},\n {name: 2.years.ago.year, data: @orders_two_years_ago},\n ]\n\n end", "def worktype_cumul(begda,endda)\n teams=Team.find(:all)\n wt_total = []\n teams.each do |team|\n curdate = begda\n wt_team = {}\n until curdate > endda do\n wt_month = calculate_worktype_distribution(curdate,team.id)\n wt_month.keys.each do |wt|\n if wt_team[wt].nil?\n wt_team[wt] = { :daysbooked => wt_month[wt][:daysbooked] }\n else\n\t wt_team[wt][:daysbooked] = wt_team[wt][:daysbooked] + wt_month[wt][:daysbooked] \n end\n end\n curdate = curdate >> 1\n end\n # get the total time and calculate percentages\n sum_of_times_booked = 0\n wt_team.keys.each do |wt|\n sum_of_times_booked += wt_team[wt][:daysbooked]\n end\n\n wt_team.keys.each do |wt|\n perc = (wt_team[wt][:daysbooked]/sum_of_times_booked)*100\n wt_total << { :team_id => team.id,\n :worktype_id => wt,\n :daysbooked => wt_team[wt][:daysbooked],\n :perc => perc }\n end\n end\n return wt_total\n end", "def spent_hours_for_user\n return @spent_hours_for_user if defined?(@spent_hours_for_user)\n\n @spent_hours_for_user = nil\n\n return @spent_hours_for_user if user_id.blank?\n\n @spent_hours_for_user = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id).sum(:hours)\n end", "def utilisation(start_date = 1.month.ago, end_date = Date.today)\n all_timings = timings.submitted_timings.where(started_at: start_date...end_date)\n .joins(:task)\n\n external_tracked_time = all_timings.where(tasks: { count_towards_time_worked: true })\n .where(clients: { internal: false })\n .joins(project: :client)\n .sum(&:duration_minutes)\n .to_f\n\n total_tracked_time = all_timings.sum(&:duration_minutes).to_f\n\n ((external_tracked_time / total_tracked_time) * 100.0).round(2)\n end", "def new_total_tb_w2yrs(start_date=Time.now, end_date=Time.now, section=nil)\n value = []\n\n start_date = @@start_date.to_date.strftime('%Y-%m-%d 00:00:00')\n end_date = @@end_date.to_date.strftime('%Y-%m-%d 23:59:59')\n\n patients = FlatCohortTable.find_by_sql(\"SELECT ftc.patient_id FROM flat_cohort_table ftc\n LEFT OUTER JOIN flat_table1 ft1 ON ft1.patient_id = ftc.patient_id\n WHERE ftc.date_enrolled >= '#{start_date}'\n AND ftc.date_enrolled <= '#{end_date}'\n AND (ft1.pulmonary_tuberculosis_last_2_years = 'Yes' OR\n ft1.who_stages_criteria_present = 'Tuberculosis (PTB or EPTB) within the last 2 years')\n GROUP BY ftc.patient_id\").collect{|p| p.patient_id}\n\n\n value = patients unless patients.blank?\n end", "def record_totals\n workout_hash = Hash.new\n current_user.workouts.each do |w|\n # Today, This Week, This Month, This Year, Total [x2 for time & distance]\n inner_array = [\n w.sum_field_by_time_range(:duration, method(:this_day)),\n w.sum_field_by_time_range(:duration, method(:this_week)),\n w.sum_field_by_time_range(:duration, method(:this_month)),\n w.sum_field_by_time_range(:duration, method(:this_year)),\n w.sum_field_by_time_range(:duration, method(:total)),\n w.sum_field_by_time_range(:distance, method(:this_day)),\n w.sum_field_by_time_range(:distance, method(:this_week)),\n w.sum_field_by_time_range(:distance, method(:this_month)),\n w.sum_field_by_time_range(:distance, method(:this_year)),\n w.sum_field_by_time_range(:distance, method(:total))\n ]\n workout_hash[w] = inner_array\n end\n return workout_hash\n end", "def billable_hours_for_issue_and_user_previous_month\n return @billable_hours_for_issue_and_user_previous_month if defined?(@billable_hours_for_issue_and_user_previous_month)\n\n @billable_hours_for_issue_and_user_previous_month = nil\n\n return @billable_hours_for_issue_and_user_previous_month if issue_id.blank? || user_id.blank?\n\n date_filter = Date.today.prev_month\n\n scope_for_time_entries = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.billable_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @billable_hours_for_issue_and_user_previous_month = cf.format.cast_total_value(cf, total)\n end", "def spent_hours_for_issue_previous_month\n return @spent_hours_for_issue_previous_month if defined?(@spent_hours_for_issue_previous_month)\n\n @spent_hours_for_issue_previous_month = nil\n\n return @spent_hours_for_issue_previous_month if issue_id.blank?\n\n date_filter = Date.today.prev_month\n\n @spent_hours_for_issue_previous_month = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month).\n sum(:hours)\n end", "def calculate(enterprise_id, trend_type, ts = Time.now.floor)\n args = {\n enterprise_id: enterprise_id,\n ts: ts,\n type: trend_type\n }\n\n klass = @trend_for.constantize\n hitsResult = klass.public_send(:where, args)\n trends = hitsResult.map { |h| counter2trend(h) }\n\n # group trends as per the time of their happening and rank them on their\n # score\n grouped_trends = trends.group_by { |x| x.ts }\n grouped_trends.each do |_ts, trendlist|\n sorted_trendlist = trendlist.sort_by { |x| x.score }\n sorted_trendlist.each_with_index do |trend, index|\n trend.rank = index\n trend.type = trend_type\n trend.save!\n end\n end\n end", "def calculate_worktype_distribution(report_date, team_id = '*')\n\n if report_date then\n month = get_month_beg_end(report_date)\n begda = month[:first_day]\n endda = month[:last_day]\n else\n begda = Date::strptime('1900-01-01')\n endda = Date::strptime('9999-12-31')\n end\n \n #Find the date of the last BW upload for the given period\n last_report_date = Projecttrack::maximum('reportdate', :conditions => [\"yearmonth <= ? and yearmonth >= ?\",endda, begda]) \n \n #Calculate the days booked from the last BW data set\n tracks = Projecttrack::find(:all, :conditions => [\"yearmonth <= ? and yearmonth >= ? and reportdate = ?\",endda, begda, last_report_date])\n\n wt_distrib = {}\n\n tracks.each do |track|\n if (team_id == '*') or (track.team_id.to_s == team_id.to_s) then\n wt = Project.find_by_id(track.project_id).worktype_id\n if wt_distrib[wt].nil?\n wt_distrib[wt] = { :daysbooked => track.daysbooked }\n else\n\t wt_distrib[wt][:daysbooked] = wt_distrib[wt][:daysbooked] + track.daysbooked \n end\n end\n end\n return wt_distrib\n end", "def billable_hours_for_user_this_month\n return @billable_hours_for_user_this_month if defined?(@billable_hours_for_user_this_month)\n\n @billable_hours_for_user_this_month = nil\n\n return @billable_hours_for_user_this_month if user_id.blank?\n\n date_filter = Date.today\n\n scope_for_time_entries = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.billable_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @billable_hours_for_user_this_month = cf.format.cast_total_value(cf, total)\n end", "def deviation_hours_for_issue_and_user_previous_month\n return @deviation_hours_for_issue_and_user_previous_month if defined?(@deviation_hours_for_issue_and_user_previous_month)\n\n @deviation_hours_for_issue_and_user_previous_month = nil\n\n return @deviation_hours_for_issue_and_user_previous_month if user_id.blank?\n\n date_filter = Date.today.prev_month\n\n scope_for_time_entries = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.deviation_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @deviation_hours_for_issue_and_user_previous_month = cf.format.cast_total_value(cf, total)\n end", "def all_suite_times; end", "def all_suite_times; end", "def one_time_occupation_detail(month, year)\n\n date_from = Date.civil(year, month, 1)\n date_to = Date.civil(year, month, -1)\n result = {}\n\n # Get planned activities\n condition = Conditions::JoinComparison.new('$and',\n [Conditions::Comparison.new(:date,'$gte', date_from),\n Conditions::Comparison.new(:date,'$lte', date_to)\n ])\n planned_activities = condition.build_datamapper(::Yito::Model::Booking::PlannedActivity).all(\n :order => [:date, :time, :activity_code]\n )\n\n # Build the structure\n activities = ::Yito::Model::Booking::Activity.all(#:active => true,\n :occurence => :one_time,\n :date_from.gte => date_from,\n :date_from.lte => date_to)\n\n activities.each do |activity|\n\n # Build item prices hash\n item_prices = {}\n if activity.number_of_item_price > 0\n (1..activity.number_of_item_price).each do |item_price|\n item_prices.store(item_price, 0)\n end\n end\n\n # Fill with the activity turns\n activity_detail = {}\n activity.one_time_timetable.each do |turn|\n # Build days hash\n days = {}\n (1..(date_to.day)).each do |day|\n date = Date.civil(year, month, day)\n modified_capacity = planned_activities.select do |item|\n item.date.strftime('%Y-%m-%d') == date.strftime('%Y-%m-%d') and\n item.time == turn and\n item.activity_code == activity.code\n end\n real_capacity = modified_capacity.size > 0 ? modified_capacity.first.capacity : activity.capacity\n\n if activity.start_date?(date)\n days.store(day, {quantity: (item_prices.empty? ? 0 : item_prices.clone),\n pending_confirmation: (item_prices.empty? ? 0 : item_prices.clone),\n capacity: real_capacity,\n planned: true})\n else\n days.store(day, {quantity: '-',\n pending_confirmation: (item_prices.empty? ? 0 : item_prices.clone),\n capacity: real_capacity,\n planned: false})\n end\n end\n activity_detail.store(turn, days)\n end\n\n # Store the item\n result.store(activity.code, {name: activity.name,\n capacity: activity.capacity,\n price_literals: activity.price_definition_detail,\n number_of_item_price: activity.number_of_item_price,\n occupation: activity_detail})\n end\n\n sql =<<-SQL\n select o_i.item_id, o_i.date, o_i.time, o_i.item_price_type, CAST (o_i.status AS UNSIGNED) as status, sum(quantity) as quantity\n from orderds_order_items o_i\n join orderds_orders o on o.id = o_i.order_id\n join bookds_activities a on a.code = o_i.item_id \n where o.status NOT IN (3) and o_i.date >= ? and o_i.date <= ? and \n a.occurence IN (1)\n group by o_i.item_id, o_i.date, o_i.time, o_i.item_price_type, o_i.status\n SQL\n\n # Fill with the orders\n\n orders = repository.adapter.select(sql, date_from, date_to)\n\n orders.each do |order|\n if result[order.item_id] and\n result[order.item_id][:occupation] and\n result[order.item_id][:occupation][order.time] and\n result[order.item_id][:occupation][order.time][order.date.day] and\n result[order.item_id][:occupation][order.time][order.date.day][:quantity][order.item_price_type] and\n result[order.item_id][:occupation][order.time][order.date.day][:pending_confirmation][order.item_price_type]\n result[order.item_id][:occupation][order.time][order.date.day][:pending_confirmation][order.item_price_type] += order.quantity if order.status == 1\n result[order.item_id][:occupation][order.time][order.date.day][:quantity][order.item_price_type] += order.quantity if order.status == 2\n end\n end\n\n return result\n\n end", "def deviation_hours_for_user_this_month\n return @deviation_hours_for_user_this_month if defined?(@deviation_hours_for_user_this_month)\n\n @deviation_hours_for_user_this_month = nil\n\n return @deviation_hours_for_user_this_month if user_id.blank?\n\n date_filter = Date.today\n\n scope_for_time_entries = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.deviation_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @deviation_hours_for_user_this_month = cf.format.cast_total_value(cf, total)\n end", "def project_costs(proj)\n Issue.cross_project_scope(proj, 'descendants')\n .select('spent_on, SUM(hours) AS sum_hours')\n .where(\"#{SQL_COM}\")\n .joins(:time_entries)\n .group(:spent_on)\n .collect { |issue| [issue.spent_on.to_date, issue.sum_hours] }\n end", "def group_time_accounted_array(params,tcol)\r\n \r\n conditions,data,table_headers,duration = {},[],[],0\r\n \r\n \r\n lookup_activities = current_company.company_activity_types\r\n activities = ReportsHelper.get_lookups(lookup_activities)\r\n\r\n if params[:report][:selected] == \"all\"\r\n billamount,discount,override,finalamount,num_discount = 0,0,0,0,0\r\n tcol.each do |obj|\r\n @dur_setng_is_one100th ? actual_duration = one_hundredth_timediffernce(obj.actual_duration) : actual_duration = one_tenth_timediffernce(obj.actual_duration)\r\n\r\n duration += actual_duration.to_f if actual_duration\r\n unless obj.is_internal\r\n billamount = billamount + (obj.actual_activity_rate * actual_duration.to_f)\r\n# discount += obj.billing_percent if obj.billing_percent\r\n if obj.billing_percent\r\n discount += obj.billing_percent\r\n num_discount += 1\r\n end\r\n override += obj.final_billed_amount if obj.billing_method_type == 3\r\n finalamount += obj.final_billed_amount if obj.final_billed_amount\r\n end\r\n\r\n unless obj.is_internal #Not Internal\r\n data << [obj.time_entry_date,obj.performer.try(:full_name).try(:titleize),obj.contact ? obj.contact.name : \"\",obj.matter ? obj.matter.clipped_name : \"\",\"No\",actual_duration,activities[obj.activity_type],obj.is_billable ? \"Yes\" : \"No\",obj.actual_activity_rate,obj.actual_activity_rate * actual_duration.to_f,obj.billing_percent,obj.billing_method_type == 3 ? obj.final_billed_amount : '',obj.final_billed_amount]\r\n else\r\n data << [obj.time_entry_date,obj.performer.try(:full_name).try(:titleize), \"N.A\",\"N.A\",\"Yes\",actual_duration,activities[obj.activity_type],\"N.A\",\"N.A\",\"N.A\",\"N.A\",\"N.A\",\"N.A\"]\r\n end\r\n end\r\n # This condition applied to avoid 0/0 = (Not A Number) with ref to Bug -Bug #7108 Shows junk value in T&E PDF report --Rahul P.\r\n if (discount>0 and num_discount>0)\r\n discount = (discount.to_f/num_discount.to_f)\r\n else\r\n discount = 0\r\n end\r\n #raise discount.inspect\r\n conditions[:table_width] = 750\r\n conditions[:all_entries] = [duration,billamount,discount,override,finalamount]\r\n column_widths = { 0 => 60, 1 => 60, 2 => 60 , 3 => 60 , 4 => 40 , 5 => 70 , 6 => 60 ,7 => 40 , 8 => 60 , 9 => 60,10 => 60,11 => 60 , 12 => 60}\r\n table_headers = [t(:label_date),t(:text_lawyer),t(:label_client),t(:text_matter),t(:label_internal),t(:label_duration_hrs),t(:text_activity_type),t(:text_billable),\"#{t(:label_rate_hr)}\",\"#{t(:text_bill)} #{t(:text_amt)}\",t(:text_discount_p),\"#{t(:text_override)} #{t(:text_amt)}\",\"#{t(:label_final_bill)} #{t(:text_amt)}\"]\r\n alignment = { 0 => :center, 1 => :left,2 => :left, 3 => :left,4 => :center,6 => :left, 7 => :center,10=>:center} if params[:format] == \"pdf\"\r\n \r\n elsif params[:report][:selected] == \"internal\"\r\n \r\n \r\n tcol.each do |obj|\r\n @dur_setng_is_one100th ? actual_duration = one_hundredth_timediffernce(obj.actual_duration) : actual_duration = one_tenth_timediffernce(obj.actual_duration)\r\n duration += actual_duration.to_f if obj.actual_duration\r\n data << [obj.time_entry_date,obj.performer.try(:full_name).try(:titleize),actual_duration,activities[obj.activity_type]]\r\n end\r\n conditions[:internal_entries] = [duration]\r\n table_headers = [t(:label_date),t(:text_lawyer),t(:label_duration_hrs),t(:text_activity_type)]\r\n column_widths = { 0 => 100, 1 => 100, 2 => 100 , 3 => 100} \r\n end\r\n \r\n [data,conditions,table_headers,column_widths, alignment]\r\n \r\n end", "def tenders_ultimate(start, num, day)\n\nend", "def spent_hours\n @spent_hours ||= time_entries.sum(:hours) || 0\n end", "def get_base_wages_for_month(month)\n events_worked = Distribution.get_events_worked(self.id)\n \n events_in_month = Event.events_in_month_ids(month)\n\n set_of_events = Event.get_event_ids_from_objects(events_worked)\n \n # This uses \"&\" (intersection) to compare the event ids from the month\n # and the events the employee has worked\n # events_employee_worked_this_month is an Array of event ids\n events_employee_worked_this_month = set_of_events & events_in_month\n \n paid_events = Event.event_ids_to_objects(events_employee_worked_this_month)\n Event.calc_wages_for_set_of_events(paid_events)\n end", "def calculate_scores_and_attendabilities\n @scores = {}\n @attendabilities = {}\n \n @daily_slots[:monday].each do |monday_hour|\n @daily_slots[:wednesday].each do |wednesday_hour|\n @scores[[monday_hour, wednesday_hour]] = score_for_pair(monday_hour, wednesday_hour)\n @attendabilities[[monday_hour, wednesday_hour]] = attendability_for_pair(monday_hour, wednesday_hour)\n end\n end\n end", "def multiple_dates_occupation_detail(month, year)\n\n date_from = Date.civil(year, month, 1)\n date_to = Date.civil(year, month, -1)\n result = {}\n\n # Get planned activities\n condition = Conditions::JoinComparison.new('$and',\n [Conditions::Comparison.new(:date,'$gte', date_from),\n Conditions::Comparison.new(:date,'$lte', date_to)\n ])\n planned_activities = condition.build_datamapper(::Yito::Model::Booking::PlannedActivity).all(\n :order => [:date, :time, :activity_code]\n )\n\n # Build the structure\n activities = ::Yito::Model::Booking::Activity.all(#:active => true,\n :occurence => :multiple_dates,\n 'activity_dates.date_from.gte'.to_sym => date_from,\n 'activity_dates.date_from.lte'.to_sym => date_to)\n\n activities.each do |activity|\n\n # Build item prices hash\n item_prices = {}\n if activity.number_of_item_price > 0\n (1..activity.number_of_item_price).each do |item_price|\n item_prices.store(item_price, 0)\n end\n end\n\n # Fill with the activity turns\n activity_detail = {}\n activity.multiple_dates_timetable.each do |turn|\n # Build days hash\n days = {}\n (1..(date_to.day)).each do |day|\n date = Date.civil(year, month, day)\n modified_capacity = planned_activities.select do |item|\n item.date.strftime('%Y-%m-%d') == date.strftime('%Y-%m-%d') and\n item.time == turn and\n item.activity_code == activity.code\n end\n real_capacity = modified_capacity.size > 0 ? modified_capacity.first.capacity : activity.capacity\n\n if activity.start_date?(date)\n days.store(day, {quantity: (item_prices.empty? ? 0 : item_prices.clone),\n pending_confirmation: (item_prices.empty? ? 0 : item_prices.clone),\n capacity: real_capacity,\n planned: true})\n else\n days.store(day, {quantity: '-',\n pending_confirmation: (item_prices.empty? ? 0 : item_prices.clone),\n capacity: real_capacity,\n planned: false})\n end\n end\n activity_detail.store(turn, days)\n end\n\n # Store the item\n result.store(activity.code, {name: activity.name,\n capacity: activity.capacity,\n price_literals: activity.price_definition_detail,\n number_of_item_price: activity.number_of_item_price,\n occupation: activity_detail})\n end\n\n sql =<<-SQL\n select o_i.item_id, o_i.date, o_i.time, o_i.item_price_type, CAST (o_i.status AS UNSIGNED) as status, sum(quantity) as quantity\n from orderds_order_items o_i\n join orderds_orders o on o.id = o_i.order_id\n join bookds_activities a on a.code = o_i.item_id \n where o.status NOT IN (3) and o_i.date >= ? and o_i.date <= ? and \n a.occurence IN (2)\n group by o_i.item_id, o_i.date, o_i.time, o_i.item_price_type, o_i.status\n SQL\n\n # Fill with the orders\n\n orders = repository.adapter.select(sql, date_from, date_to)\n\n orders.each do |order|\n if result[order.item_id] and\n result[order.item_id][:occupation] and\n result[order.item_id][:occupation][order.time] and\n result[order.item_id][:occupation][order.time][order.date.day] and\n result[order.item_id][:occupation][order.time][order.date.day][:quantity][order.item_price_type] and\n result[order.item_id][:occupation][order.time][order.date.day][:pending_confirmation][order.item_price_type]\n result[order.item_id][:occupation][order.time][order.date.day][:pending_confirmation][order.item_price_type] += order.quantity if order.status == 1\n result[order.item_id][:occupation][order.time][order.date.day][:quantity][order.item_price_type] += order.quantity if order.status == 2\n end\n end\n\n return result\n\n end", "def set_worktype\n @worktype = current_ou.worktypes.find(params[:id])\n @worktype.on_duty_at=@worktype.on_duty_at.strftime('%H:%M')\n @worktype.off_duty_at=@worktype.off_duty_at.strftime('%H:%M')\n end", "def date_time_attribute_get(instance, name)\n if value = instance.send(:\"formatted_#{name}\")\n { name => value, \"formatted_#{name}\" => value }\n else\n {}\n end\n end", "def dates\n\t\t@times = { \n\t\t\t:haiti=>{\n\t\t\t\t:one_week_before=>\tTime.new(2010,01,5),\n\t\t\t\t:event\t\t\t=>\tTime.new(2010,01,12),\n\t\t\t\t:one_week_after\t=>\tTime.new(2010,01,19),\n\t\t\t\t:dw_end\t\t\t=>\tTime.new(2010,02,12)\n\t\t\t},\n\n\t\t\t:philippines=>{ \n\t\t\t\t:one_week_before=>\tTime.new(2013,11,1),\n\t\t\t\t:event\t\t\t=>\tTime.new(2013,11,8),\n\t\t\t\t:one_week_after\t=>\tTime.new(2013,11,15),\n\t\t\t\t:dw_end\t\t\t=>\tTime.new(2013,12,8)\n\t\t\t},\n\t\t\t:phil=>{ \n\t\t\t\t:one_week_before=>\tTime.new(2013,11,1),\n\t\t\t\t:event\t\t\t=>\tTime.new(2013,11,8),\n\t\t\t\t:one_week_after\t=>\tTime.new(2013,11,15),\n\t\t\t\t:dw_end\t\t\t=>\tTime.new(2013,12,8)\n\t\t\t}\n\t\t}\n\tend", "def hours_for_all_users(month_nr: nil, year: nil, of_kind:)\n require 'ostruct'\n sum = []\n if month_nr && year\n users.each do |u|\n sum_hours_for_user(user: u, month_nr: month_nr, year: year, of_kind: of_kind)\n hour = build_sum_for_user(u)\n sum << hour unless hour.blank?\n end\n else\n users.each do |u|\n sum_hours_for_user_total(user: u, of_kind: of_kind)\n hour = build_sum_for_user(u)\n sum << hour unless hour.blank?\n end\n end\n sum\n end", "def align_times\n # if booking the same day, then starts_at is in one minute from now.\n earliest_possible_starts_at = ( self.starts_at.to_date == Date.today ) ? ( DateTime.now + 1.minute ) : self.starts_at.beginning_of_day\n self.attributes = {\n starts_at: earliest_possible_starts_at,\n ends_at: self.ends_at.end_of_day\n }\n end", "def setup_earning_tests\n start_date = Date.today\n i = 0\n Order.find(:all).each do |o|\n o.update_attributes({\n :created_on => start_date - i.months,\n :order_status_code_id => 7,\n :affiliate => @jm\n })\n i += 1\n end\n end", "def calculate_time_from_to_cost\n\n time_cost = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_price', '0')\n if time_cost != '0'\n\n # Check if the reservation correspond to the main season or not\n main_season_month_from = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.month_from', 1).to_i\n main_season_day_from = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.day_from', 1).to_i\n main_season_month_to = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.month_to', 12).to_i\n main_season_day_to = SystemConfiguration::Variable.get_value('booking.pickup_return_main_season.day_to', 31).to_i\n\n if main_season_month_from == 1 and main_season_day_from == 1 and main_season_month_to == 12 and main_season_day_to == 31\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else\n # JAN DIC\n # -------------------------------------\n # ^=======================^\n # from to\n if main_season_month_from <= main_season_month_to or \n (main_season_month_from == main_season_month_to and main_season_day_from <= main_season_day_to) \n if (@date_from.month >= main_season_month_from or \n (@date_from.month == main_season_month_from and @date_from.day >= main_season_day_from)) and\n (@date_to.month <= main_season_month_to or \n (@date_to.month == main_season_month_to and @date_to.day <= main_season_day_to)) # In main season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else # Out of season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_of_season','0').to_i\n end\n else\n # JAN DIC\n # -------------------------------------\n # ======^ ^======\n # to from\n if ((@date_from.month >= main_season_month_from or\n (@date_from.month == main_season_month_from and @date_from.day >= main_season_day_from)) or\n (@date_from.month <= main_season_month_to or \n (@date_from.month == main_season_month_to and @date_from.day <= main_season_day_to))\n ) and\n ((@date_to.month >= main_season_month_from or\n (@date_to.month == main_season_month_from and @date_to.day >= main_season_day_from)) or\n (@date_to.month <= main_season_month_to or\n (@date_to.month == main_season_month_to and @date_to.day <= main_season_day_to))) # In main season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable','0').to_i\n else # Out of season\n timetable_id = SystemConfiguration::Variable.get_value('booking.pickup_return_timetable_out_of_season','0').to_i\n end\n end\n end\n\n #p \"timetable_id: #{timetable_id} -- main season: #{main_season_day_from}-#{main_season_month_from} #{main_season_day_to}-#{main_season_month_to}\"\n\n time_cost = BigDecimal.new(time_cost)\n if timetable_id > 0\n if timetable = ::Yito::Model::Calendar::Timetable.get(timetable_id)\n @time_from_cost = calculate_time_cost(@date_from, @time_from, time_cost, timetable)\n @time_to_cost = calculate_time_cost(@date_to, @time_to, time_cost, timetable)\n end\n end\n\n end\n end", "def thirty_minute_yoga_classes\n end", "def time_based_attribute\n return @time_based_attribute\n end", "def hours_spent\n hours_spent = 0\n project_tasks.each do |project_task|\n hours_spent += project_task.hours_spent\n end\n hours_spent\n end", "def calculate!\n # When expanding the application to support multi-week pay periods, this code must be modified\n minutes_this_week = []\n daily_limit = 8 * 60 # in minutes\n weekly_limit = 40 * 60 # in minutes\n\n entries = employee_entries.reload # TODO: sort logic here \n \n entries.each do |e|\n duration = e.duration || 0\n date = e.payroll_worked_date = e.ticket.first_employee_entry\n \n minutes_this_week[e.employee_id] ||= { total: 0 }\n minutes_this_week[e.employee_id][date] ||= 0\n minutes_this_week[e.employee_id][date] += duration\n minutes_this_week[e.employee_id][:total] += duration\n \n overtime_today = minutes_this_week[e.employee_id][date] - daily_limit\n overtime_this_week = minutes_this_week[e.employee_id][:total] - weekly_limit\n overtime_max = [overtime_today, overtime_this_week, 0].max\n \n e.payroll_duration_standard = duration - overtime_max\n e.payroll_duration_standard = 0 if e.payroll_duration_standard < 0\n e.payroll_duration_overtime = duration - e.payroll_duration_standard\n \n e.payroll_bill_to = e.ticket.bill_to\n e.payroll_job_id = e.ticket.job_id\n e.payroll_status = if e.on_the_job? and e.payroll_job_id\n :bill_to_job\n else\n :overhead\n end\n e.payroll_pay_rate = if e.ticket.job\n e.ticket.pay_rate\n else\n :day_pay\n end\n \n e.payroll_category_string = \"#{e.employee_id} - #{e.payroll_bill_to} - #{e.payroll_job_id} - #{e.payroll_pay_rate} - #{e.payroll_status}\"\n \n e.save!\n end\n end", "def total_annual_rent_collected\n units.map { |unit| unit.is_vacant ? 0 : unit.monthly_rent }.reduce(:+) * 12\n end", "def hours_sold_for\n @project.hours_sold_for\n end", "def hours_per_week= (hours_per_week)\n # fill in later\n end", "def charts_data_for(project)\n charts_data = {}\n\n ### chart project hours ### \n\n # time period\n from = project.created_at.to_date\n to = project.due_at.to_date + 1.week\n charts_data[:project_hours_from] = from \n charts_data[:project_hours_to] = to\n\n # prepare data \n charts_data[:project_hours] = groups_total_hours(project.records, from, to, 30) \n\n ### chart tasks span ###\n\n # time period\n from = project.created_at.to_date\n to = project.due_at.to_date + 1.week\n charts_data[:tasks_span_from] = from \n charts_data[:tasks_span_to] = to\n\n # prepare data \n tasks_span = []\n tasks = project.tasks\n tasks.each do |task|\n records = task.records\n #\n # task expected time span from task creation to due\n # task practical time span from first record creation to last record creation\n #\n tasks_span << {task: 'Task '+(task.tag+1).to_s, create: task.created_at.to_date, due: task.due_at.to_date,\n start: records.minimum(\"created_at\").to_date, finish: records.maximum(\"created_at\").to_date}\n end\n\n # add extra data for the whole project\n records = project.records\n tasks_span.unshift({task: 'Project', create: project.created_at.to_date, due: project.due_at.to_date,\n start: records.minimum(\"created_at\").to_date, finish: records.maximum(\"created_at\").to_date})\n\n charts_data[:tasks_span] = tasks_span\n\n ### chart tasks hours ###\n\n # prepare data \n tasks_hours = []\n #\n # at least one task has to be specified on the project creation\n #\n tasks = project.tasks\n tasks.each do |task|\n tasks_hours << {task: task.name, total_hours: task.records.sum(\"hours\")}\n end\n charts_data[:tasks_hours] = tasks_hours\n\n ### chart tasks submission ###\n\n # time period\n from = project.created_at.to_date\n to = project.due_at.to_date + 1.week\n charts_data[:tasks_submission_from] = from \n charts_data[:tasks_submission_to] = to\n\n # prepare data \n tasks_submission = []\n #\n # at least one task has to be specified on the project creation\n #\n tasks = project.tasks\n tasks.each do |task|\n # records (submitted by all team members) are grouped with task\n records = task.records.where(\"records.created_at >= ?\", from)\n records.each do |record|\n tasks_submission << {task: task.name, date: record.created_at.to_date, \n time: record.created_at.strftime(\"%H-%M-%S\"), hours: record.hours}\n end\n end\n charts_data[:tasks_submission] = tasks_submission\n\n charts_data.to_json\n end", "def trendable\n key :type, Integer\n key :ts, Time\n key :rank, Integer\n\n key :score, Float\n key :uid, String\n\n generate_aggregators { |ts, method|\n trendtype = method_names_type_counter(method)\n aggregate_and_create trendtype, ts\n }\n\n end", "def getFundAppriciationOverTime(port, start_date, end_date)\r\n\r\n\t\t\r\n\r\n\tend", "def hash_args\n [@month, @day_of_week] + super\n end", "def get_time_swam\r\n Timing.new( @summary.individuals.time_swam )\r\n end", "def stats_by_date from_date, to_date\n events_by_date = campaign_finance_transactions.group(:sub_type)\n .select(:sub_type)\n .group(:transaction_date)\n .select(:transaction_date)\n .sum(:amount)\n\n types = campaign_finance_transactions.select(:sub_type).uniq.pluck(:sub_type)\n\n (from_date..to_date).map{ |date|\n {\n date: date,\n }.merge(\n types.reduce(Hash.new) {|hash, type|\n hash[type.to_sym] = events_by_date[[type, date]]\n hash\n }\n )\n }\n end", "def billable_hours_for_issue_this_month\n return @billable_hours_for_issue_this_month if defined?(@billable_hours_for_issue_this_month)\n\n @billable_hours_for_issue_this_month = nil\n\n return @billable_hours_for_issue_this_month if issue_id.blank?\n\n date_filter = Date.today\n\n scope_for_time_entries = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.billable_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @billable_hours_for_issue_this_month = cf.format.cast_total_value(cf, total)\n end", "def deviation_hours_for_issue_this_month\n return @deviation_hours_for_issue_this_month if defined?(@deviation_hours_for_issue_this_month)\n\n @deviation_hours_for_issue_this_month = nil\n\n return @deviation_hours_for_issue_this_month if issue_id.blank?\n\n date_filter = Date.today\n\n scope_for_time_entries = TimeEntry.\n where(:issue_id => self.issue_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.deviation_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @deviation_hours_for_issue_this_month = cf.format.cast_total_value(cf, total)\n end", "def time_based_attribute=(value)\n @time_based_attribute = value\n end", "def calorie_sum_by_day\n\n end", "def class_commit_monthly_timeline class_name, events\n class_month_dates = events.select {|e| e.class_name == class_name }.map(&:date).map(&:month_start)\n spread(class_month_dates.freq, month_range(class_month_dates.min, class_month_dates.max))\nend", "def work_per_month(ary_work)\n nary = ary_work.group_by{ |t| \n t[:date] \n }.transform_values { |tasks|\n tasks.reduce(0) { |sum, t|\n sum + t[:time] \n }\n }.to_a.group_by { |e|\n e[0][0..6]\n }.transform_values { |tasks|\n tasks.reduce(0) { |sum, t|\n sum + t[1] \n } / tasks.length\n }\nend", "def recalculate_all_time_total\n\t\t# Returns yearly total records in order to sum totals\n\t\t@yearly_totals = self.yearly_totals\n\t\tself.update_columns(:mileage_total => @yearly_totals.sum(:mileage_total), :time_in_seconds => @yearly_totals.sum(:time_in_seconds), :number_of_runs => @yearly_totals.sum(:number_of_runs), :elevation_gain => @yearly_totals.sum(:elevation_gain))\n\tend", "def assign_types\n @schedule[0].cost = :travel\n @schedule.each_cons(3) do |days|\n days[1].cost =\n if days[0].date + 1 == days[1].date && days[1].date+ 1 == days[2].date\n :full\n else\n :travel\n end\n end\n @schedule[-1].cost = :travel\n end", "def get_cost\n time_range = {}\n if reserv_range.end.day - reserv_range.begin.day == 1\n time_range[reserv_range.begin.wday] = (\n ((reserv_range.begin.hour * 60 + reserv_range.begin.min) / 60.0)...24.0\n )\n\n time_range[reserv_range.end.wday] = (0.0...(reserv_range.end.hour * 60 + reserv_range.end.min) / 60.0)\n else\n time_range[reserv_range.end.wday] = (((reserv_range.begin.hour * 60 + reserv_range.begin.min) / 60.0)...(reserv_range.end.hour * 60 + reserv_range.end.min) / 60.0)\n end\n\n cost_sum = 0\n\n time_range.each do |wday, tr|\n billings = Billing\n .select(\n \"numrange(start_time, end_time) * numrange(#{tr.begin},#{tr.end}) as period, cost_cents, cost_currency\"\n )\n .where(\n 'numrange(start_time, end_time) && numrange(:start, :end) AND day_type = :day_type AND sauna_id = :sauna_id',\n start: tr.begin,\n end: tr.end,\n day_type: wday,\n sauna_id: sauna_id\n )\n\n # puts billings.to_sql\n\n billings.each do |bill|\n cost_sum += (bill.period.end - bill.period.begin) * bill.cost_cents\n end\n end\n\n cost_sum\n end", "def income_this_month\n Sale.past_month.sum(:total)\n end", "def total_spent_hours\n @total_spent_hours ||= TimeEntry.where(:meeting_id => id).sum(:hours).to_f\n end", "def tally_params\n params.require(:tally).permit(:total_time_m, :total_time_s, :total_time_ms, :total_points, :total_faults, :title, :qualifying_score, :qualifying_scores, :event_ids => [], :entrant_ids => [] )\n end", "def calculate_and_build_metlife_premium_tables\n (20..65).each do |metlife_age|\n @metlife_age = metlife_age\n key = \"#{@rate[:plan_id]},#{@rate[:effective_date].to_date.year}\"\n rating_area = @rate[:rate_area_id]\n @results[key] << {\n age: metlife_age,\n start_on: @rate[:effective_date],\n end_on: @rate[:expiration_date],\n cost: calculate_metlife_cost,\n rating_area: rating_area\n }\n end\n end", "def metric_model_for_timespan\n\n time_diff = (@from - @to).to_i\n if time_diff >= 180.days # If 6 months or more, return weekly averages.\n Sherlock::Models::MetricAvg1w\n elsif time_diff >= 90.days # If 3 months or more, return daily averages.\n Sherlock::Models::MetricAvg1d\n elsif time_diff >= 30 # If one month or more, return hourly averages.\n Sherlock::Models::MetricAvg1h\n elsif time_diff >= 1.day # If one day or more, return 5 minute averages.\n Sherlock::Models::MetricAvg5m\n else # If none of the above, just use the raw Metric model.\n Sherlock::Models::Metric\n end\n\n end", "def timespan_attributes=(timespan_attrs)\n self.timespan ? self.timespan.update_attributes(timespan_attrs) : self.build_timespan(timespan_attrs)\n end", "def billable_hours_for_user_previous_month\n return @billable_hours_for_user_previous_month if defined?(@billable_hours_for_user_previous_month)\n\n @billable_hours_for_user_previous_month = nil\n\n return @billable_hours_for_user_previous_month if user_id.blank?\n\n date_filter = Date.today.prev_month\n\n scope_for_time_entries = TimeEntry.\n where(:project_id => self.project_id).\n where(:user_id => self.user_id).\n where(:tyear => date_filter.year).\n where(:tmonth => date_filter.month)\n\n cf = self.class.billable_custom_field\n total = cf.format.total_for_scope(cf, scope_for_time_entries)\n @billable_hours_for_user_previous_month = cf.format.cast_total_value(cf, total)\n end", "def date_time_attribute_set(instance, name, attributes)\n return unless attributes.key?(name) || attributes.key?(\"formatted_#{name}\")\n\n value = attributes[name] || attributes[\"formatted_#{name}\"]\n\n instance.send(:\"formatted_#{name}=\", value)\n end", "def driver1_pay_day(ride_share_rides)\n pay_hash = Hash.new(0)\n day_hash = Hash.new(0)\n ride_share_rides.each do |trip_info|\n trip_info.values[0].each do |x|\n day_hash[x[:date]] += x[:cost]\n pay_hash[trip_info.keys[0]] = day_hash\n end\n end\n return pay_hash\nend", "def hourly_totals(emoji)\n hour_zero = self.last_hour.where(emoji: emoji).pluck(:created_at).size\n hour_one = self.last_hour_plus_one.where(emoji: emoji).pluck(:created_at).size\n hour_two = self.last_hour_plus_two.where(emoji: emoji).pluck(:created_at).size\n hour_three = self.last_hour_plus_three.where(emoji: emoji).pluck(:created_at).size\n hour_four = self.last_hour_plus_four.where(emoji: emoji).pluck(:created_at).size\n some_days = [hour_zero, hour_one, hour_two, hour_three, hour_four]\n end", "def monthly\n end", "def propagate_start_and_end_times\n if @start_time && @start_time != shift.start_time\n self.starts_at = twenty_four_hour_time(@start_time)\n else\n self.starts_at = nil\n end\n if @end_time && @end_time != shift.end_time\n self.ends_at = twenty_four_hour_time(@end_time)\n else\n self.ends_at = nil\n end\n end", "def worktype_adhoc(begda,endda)\n teams=Team.find(:all)\n curdate = begda\n ad_hoc = []\n until curdate > endda do\n teams.each do |team|\n team_ad_hoc = team.ad_hoc_work(curdate)\n \n ad_hoc << { :month => Date::ABBR_MONTHNAMES[curdate.month], \n :team_id => team.id,\n :adhoc_tasks => team_ad_hoc[:tasks],\n :adhoc_perc => team_ad_hoc[:percentage],\n } \n \n end\n\n curdate = curdate >> 1\n end\n return ad_hoc\n end", "def report_time_spent(entry)\n if Setting.plugin_redmine_spent_time_in_issue_description['time_format'].eql? 'human'\n humanized_time(entry.hours)\n else\n entry.hours\n end\n end", "def totals_by_month_year\n revenue = Hash.new { |hash, key| hash[key] = {} }\n leases_by_year.each do |lease|\n lease.each do |year, months|\n months.each do |month, rent|\n revenue[year][month] ? revenue[year][month] += rent : revenue[year][month] = rent\n end\n end\n end\n revenue\n end", "def patient_monthly_costs_during_dh\n\t$pt_costs_monthy_during_dh = []\n\n\t$pokitdok_call.each do |drug|\t\n\t\t#Patient pays no more than 45% of ⇒ plan’s cost for covered brand-name prescription drugs + pharmacy’s dispensing fee\n\t\tif drug['tier'] == 1\n\t\t\t$pt_costs_monthy_during_dh << (drug['retail']['total_cost_30_day']['amount'].to_f * 0.58)\n\n\t\t#patient pays 58% of cost, 58% of cost goes toward geting out of donut hole\t\t\t\n\t\telsif drug['tier'] == 2 \n\t\t\t$pt_costs_monthy_during_dh << (drug['retail']['total_cost_30_day']['amount'].to_f * 0.45)\n\t\telsif drug['tier'] == 3\n\t\t\t$pt_costs_monthy_during_dh << (drug['retail']['total_cost_30_day']['amount'].to_f * 0.45)\n\t\telse\n\t\t\t$pt_costs_monthy_during_dh << drug['retail']['total_cost_30_day']['amount'].to_f\n\t\tend\n\tend\n\n\t$pt_costs_monthy_during_dh.inject(:+).round(2)\nend", "def theatre_revenue\n self.ticket_purchases.sum(:sales_total)\n end", "def income_this_week\n Sale.past_week.sum(:total)\n end", "def total_owed\n self.appointments.sum(:cost)\n end", "def consolidate_day\n t = Time.zone.local(2012,12,10);\n\n two_days_ago = t - 2.days\n one_days_ago = t - 1.day\n\n last_couple_days = self.energy_data.where(:year => t.year, :month => t.month, :day => one_days_ago.day) #we're 1-indexed\n dayofInterest = self.energy_data.where(:year => t.year, :month => t.month, :day => t.day, :hour => (1..(t.hour+1))) #we're 1-indexed\n @dayTotals = Array.new\n count = 0\n\n hour_sim = 0\n\n #previous couple days\n last_couple_days.each do |day|\n @dayTotals[count] = [Time.utc(day.year,day.month,day.day,day.hour).to_i*1000, day.power]\n count = count + 1\n end\n\n # create array with [hour, power]\n dayofInterest.each do |day|\n last_hour = day.hour\n @dayTotals[count] = [Time.utc(day.year,day.month,day.day,day.hour).to_i*1000, day.power]\n count = count + 1\n end\n\n @dayTotals\n end", "def getSetupTimeTechnician\n technicians = User.all.pluck(:id)\n #get modules for autumn, spring and both\n sem_aut = Dropdown.where(drop_down: 'semester', value: 'Autumn').first\n sem_spr = Dropdown.where(drop_down: 'semester', value: 'Spring').first\n sem_both = Dropdown.where(drop_down: 'semester', value: 'Both').first\n \n autumnModules = UniModule.where(semester_id: sem_aut.id).pluck(:id)\n springModules = UniModule.where(semester_id: sem_spr.id).pluck(:id)\n bothModules = UniModule.where(semester_id: sem_both.id).pluck(:id)\n\n setupTimeAutumn = []\n setupTimeSpring = []\n\n technicians.each do |tech|\n actTech = ActivityTech.where(tech_lead_id: tech).pluck(:activity_id)\n actTechU = ActivityTech.where(tech_ustudy_id: tech).pluck(:activity_id)\n actTech = actTech + actTechU\n\n #Get durations of activites that belong to modules in both semesters\n activitiesB = Activity.where(id: actTech, uni_module_id: bothModules).pluck(:id)\n activities_ttB = ActivityTimetable.where(activity_id: activitiesB).pluck(:series_setup_time)\n \n #add the durations to the totals for autumn and spring\n sumA = 0\n sumS = 0\n activities_ttB.each do |time|\n unless time.nil?\n sumA = sumA + (time/60.0)\n sumS = sumS + (time/60.0)\n end\n end\n\n #get the setup time\n activities_ttB = ActivityTimetable.where(activity_id: activitiesB).pluck(:setup_time)\n \n #add the durations to the totals for autumn and spring\n activities_ttB.each do |time|\n unless time.nil?\n sumA = sumA + (time/60.0)\n sumS = sumS + (time/60.0)\n end \n end\n\n\n\n\n #Get durations of activites that belong to modules in autumn semesters\n activitiesA = Activity.where(id: actTech, uni_module_id: autumnModules).pluck(:id)\n activities_ttA = ActivityTimetable.where(activity_id: activitiesA).pluck(:series_setup_time)\n \n #add the durations to the totals for autumn\n activities_ttA.each do |time|\n unless time.nil?\n sumA = sumA + (time/60.0)\n end\n end\n\n #get the setup time\n activities_ttA = ActivityTimetable.where(activity_id: activitiesA).pluck(:setup_time)\n \n #add the durations to the totals for autumn\n activities_ttA.each do |time|\n unless time.nil?\n sumA = sumA + (time/60.0)\n end \n end\n\n techName = User.find(tech).display_name\n if sumA != 0 then\n setupTimeAutumn.push([techName, sumA])\n end\n\n\n #Get durations of activites that belong to modules in spring semesters\n activitiesS = Activity.where(id: actTech, uni_module_id: springModules).pluck(:id)\n activities_ttS = ActivityTimetable.where(activity_id: activitiesS).pluck(:series_setup_time)\n \n #add the durations to the totals for spring\n activities_ttS.each do |time|\n unless time.nil?\n sumS = sumS + (time/60.0)\n end\n end\n\n #get the setup time\n activities_ttS = ActivityTimetable.where(activity_id: activitiesS).pluck(:setup_time)\n \n #add the durations to the totals for spring\n activities_ttS.each do |time|\n unless time.nil?\n sumS = sumS + (time/60.0)\n end\n end\n \n if sumS != 0 then\n setupTimeSpring.push([techName, sumS])\n end\n\n\n\n end\n return setupTimeAutumn, setupTimeSpring\n end" ]
[ "0.6525233", "0.6523704", "0.6403977", "0.6160838", "0.5894229", "0.5734933", "0.5646814", "0.56262475", "0.5550448", "0.552101", "0.54953843", "0.5461707", "0.54507524", "0.5431598", "0.5400899", "0.5361746", "0.53082275", "0.5303204", "0.53031826", "0.5294604", "0.52906287", "0.5284", "0.52670085", "0.5261265", "0.52589804", "0.5232539", "0.5231633", "0.522925", "0.521262", "0.5180549", "0.5116802", "0.5110731", "0.51071906", "0.5098886", "0.50947857", "0.50876385", "0.50738263", "0.5062948", "0.50591785", "0.50573117", "0.50573117", "0.5041595", "0.50415903", "0.50377935", "0.503705", "0.5033477", "0.50280094", "0.50199074", "0.5010023", "0.5008451", "0.5004398", "0.5000757", "0.49942744", "0.49885955", "0.49795145", "0.49770847", "0.49669784", "0.4965084", "0.4962734", "0.49567118", "0.495302", "0.4952894", "0.49521643", "0.49453166", "0.4943998", "0.49357677", "0.49353316", "0.49275985", "0.49275923", "0.49259236", "0.49230793", "0.49051833", "0.49031746", "0.4899857", "0.488854", "0.4884806", "0.48826706", "0.4870596", "0.4868999", "0.4868007", "0.4867395", "0.48651505", "0.4847167", "0.48325622", "0.4832343", "0.48298106", "0.48286176", "0.4825846", "0.48225927", "0.48186392", "0.4814056", "0.48131916", "0.4808261", "0.4806394", "0.47997645", "0.47993922", "0.47866827", "0.47856012", "0.4784054", "0.4781424" ]
0.66099507
0
say bay to everybody
def say_bye if @names.nil? puts "..." elsif @names.respond_to?("join") # join the list elements puts "Goodbye #{@names.join(", ")}. Come back soon!" else puts "Goodbye #{@names}. Come back soon!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shout\n 'Yay!'\n end", "def bark\n say('ouah ouah')\n nil\n end", "def bark\n puts \"woof!\"\n end", "def breathe\n \"i get oxygen from the water\"\n end", "def shout message, title = \"Battlecry\", priority = 0, sticky = false\n @allies.each do |ally|\n ally.notify \"battlecry\", title, message, priority, sticky\n end\n end", "def ring_bell\n\t\tputs 'Beep beep!'\n\tend", "def bark\n puts \"woof!\"\n end", "def bark\n puts \"woof!\"\n end", "def thats_all\n\t puts \"\"\n\t puts \"\"\n\t puts \"Thanks for using Grocery List 3000!\"\n\t puts \"\"\n puts \"\"\n\tend", "def ring_bell\n p \"Beep beep!\"\n end", "def say_name\n puts \"Bonsly!\"\n end", "def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\n end", "def sayHi\n\t\tputs(greet)\n\tend", "def notify_business\n business.add_message_to_queue(\"Hey #{business.name}, we've just deposited #{amount} into your account! Thanks for being great!\")\n end", "def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\n end", "def breathe\n\t\t@breaths = @meters * 2\n\t\t@breaths.times do puts \"anf \"\n\t\tend\n\t\tputs \"Breathed #{@breaths} times\"\n\t\tputs \"Total calories burnt: #{burntcals(@meters)}\"\n\tend", "def bye_message\n message = \"Panacea's work is done, enjoy!\"\n say \"\\n\\n\\e[34m#{message}\\e[0m\"\n end", "def bake\n \"Baking the cookie\"\n end", "def say_goodbye\n\t\tgoodbye = \"Thanks for playing the Virtual Crazy\" +\n\t\t\t\t\"8-Ball game!\\n\\n\"\n\tend", "def potty\n puts \"*goes to litterbox*\"\n end", "def bark\n puts \"woof\"\n end", "def bark\n puts \"woof!\"\n end", "def fly\n\t\tputs \"The \" + @company + @type + @year + \"Cockpit good for take off.\"\n\tend", "def bark \n puts \"woof!\"\n end", "def bark\n p \"woof!\"\n end", "def bark\n p \"woof!\"\n end", "def say\n send_text \"You just said: #{params}\"\n end", "def bully\n if self.name[0,1] == \"J\"\n # binding.pry\n self.budget -= 150\n # binding.pry\n return \"The bully stole half of my money!\"\n else\n return \"AHH i'm running away!\"\n end\n end", "def bark(visitor)\n puts \"My dog is barking at #{visitor}\"\n end", "def bark\n puts \"woof woof!\"\n end", "def say_name\n puts \"Bellossom!\"\n end", "def say_goodbye\r\n goodbye = \"Thanks for playing the Virtual Crazy 8-Ball game!\\n\\n\" +\r\n \"By Corey Hicks\\n\" +\r\n \"https://www.bruin.bellevue.edu\"\r\n puts goodbye\r\n end", "def on_bid(bid)\r\n warn \"Bid \" + bid.to_s\r\n end", "def pour_bottle?; true end", "def goodbye\n puts Rainbow(\"Thanks for visiting. Goodbye...\").indianred.bright.underline\n end", "def familySecret()\r\n puts \"I know the secret of our family\"\r\n end", "def check_bingo\n\t\t\n\tend", "def eat_and_bake\n puts bake\n eat\n end", "def cook\n @burger.thaw\n @burger.make_patty\n @burger.grill\n end", "def speak\n \tputs \"Ho, Ho, Ho! Haaaaaappy holidays!\"\n end", "def batten_hatches\n puts \"Batten the hatches\"\n end", "def bark\n puts \"woof!\"\n end", "def speak\r\n\t\tputs \"Ho, ho, ho! Merry Christmas and Haaaappy holidays to all!\"\r\n\tend", "def say_hi\n\t\tputs 'saying hi'\n\tend", "def bounce_with(message); end", "def bounce_with(message); end", "def away(message = nil)\n send_data(\"AWAY \" + (message ? \":#{message}\" : \"\"))\n end", "def speak\r\n puts \"Ho, ho, ho! Haaappy holidays!\"\r\n end", "def say_hello (name, health=0)\n\t\t\t\t\"Ich bin #{name} mit einem Wert von #{health}\"\n\t\t\tend", "def say(*_args)\n end", "def speak\n\t\t\tputs \"#{@name} said Ho, ho, ho! Haaaappy holidays!\"\n\t\tend", "def saymessage\n puts \"hi programers\"\n puts \"I am hungy\"\nend", "def goodbye(drink)\n puts \"Here is your #{drink}, see you next time\"\n end", "def cartman_says(offensive_message)\n puts offensive_message #fix\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def cartman_says(offensive_message)\n puts offensive_message\nend", "def speak\n\t\tputs \"Haaaappy holidays!! Ho, ho, ho!\"\n\tend", "def bark \n puts \"Woof!\"\n end", "def boomtown!\n e = ArgumentError.new(\"BOOMTOWN\")\n report(e)\n end", "def what_up2(say, *bros)\n bros.each { |bro| puts \"#{say}\" + \"! \" + \"#{bro}!\" }\nend", "def say_goodbye\r\n\t\tgoodbye = \"Thanks for playing the Virtual Crazy 8-Ball game! \\n\\n\" +\r\n\t\t\"Student: T. J. Flesher \\n\\nhttp://www.bellevue.edu/\"\t\t\r\n\t\tputs goodbye\r\n\tend", "def breathe_fire\n puts @fiery_sfx\n end", "def company_bought(company, buyer); end", "def yell\n \"Who's the boss? I'm the boss!\"\n end", "def speak\r\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\r\n\tend", "def say_hello\t\t\t\t\t\n puts \"Dire Bonjour peut sauver des meres !\" \t\t#Petite référence à VALD\nend", "def bang!\n \"bang!ed method\"\n end", "def speak\r\n\t\t# Prints holiday greeting\r\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\r\n\tend", "def ring_bell\n puts @bell\n end", "def away(text = nil)\n raw text.nil? ? \"AWAY\\r\\n\" : \"AWAY :#{text}\\r\\n\"\n end", "def stweet\n\n end", "def stweet\n\n end", "def speak\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\n\tend", "def speak\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\n\tend", "def speak\n\t\tputs \"Ho, ho, ho! Haaaappy holidays!\"\n\tend", "def speak\n \"#{name} says Assalaam alaykum\"\n end", "def send_moola!\n # @todo\n end", "def pay_blinds\n @dealer.pay(@game.small_blind)\n @under_the_gun.pay(@game.big_blind)\n end", "def speak\n p \"Ho, ho, ho! Haaaappy holidays!\"\n end", "def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\n end", "def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\n end", "def speak()\n puts \"Ho, ho, ho! Haaaappy holidays!\"\n end", "def hit_ebay\n self.gimmie_the_goods(self.ebay_grab)\n end", "def speak\n\t`say 'I am a product.`\nend", "def bixsby_say_to_all(message)\n @connections[:clients].each do |client_session, client|\n p client\n formatted_response = package_response(client_session, message)\n client.puts(formatted_response)\n end\n end", "def stanza(bottles)\n\t\tputs \"#{translate bottles} #{bottle bottles} of beer on the wall,\"\n\t\tputs \"#{translate bottles} #{bottle bottles} of beer,\" \n\n\t\tputs \"Take one down, pass it around,\"\n\t\tputs \"#{translate bottles-1} #{bottle bottles-1} of beer on the wall.\"\n\tend", "def say_hello\n\t\"Ich bin #{@name} mit einem Wert von #{@health}.\"\n\tend" ]
[ "0.6785067", "0.6651768", "0.6388682", "0.63749725", "0.63710916", "0.6198532", "0.61901444", "0.6164843", "0.6145666", "0.61204815", "0.6118213", "0.6113019", "0.6091014", "0.60821676", "0.6056109", "0.6051375", "0.6014789", "0.6014313", "0.6009798", "0.6008327", "0.600365", "0.5984721", "0.5977904", "0.5957278", "0.5937196", "0.5937196", "0.5929005", "0.5924151", "0.592318", "0.5914232", "0.5911059", "0.5901817", "0.58942026", "0.58918595", "0.5886907", "0.5875647", "0.5866709", "0.5862622", "0.58499384", "0.5846777", "0.58462346", "0.5842545", "0.584174", "0.5840727", "0.5833366", "0.5833366", "0.58308095", "0.5830735", "0.58267194", "0.58240217", "0.5817389", "0.58148766", "0.5813514", "0.5805494", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.5798102", "0.57808286", "0.5777792", "0.5765222", "0.57639426", "0.5754152", "0.5747581", "0.57432044", "0.5742757", "0.57404953", "0.5735738", "0.57335037", "0.57300764", "0.57226974", "0.5720286", "0.5711289", "0.5711289", "0.5711029", "0.5711029", "0.5711029", "0.57071245", "0.5703978", "0.5702467", "0.569602", "0.5689794", "0.5689794", "0.5682217", "0.5680233", "0.56791675", "0.5679069", "0.5675226", "0.5658611" ]
0.0
-1
If Pro user passes validations (email, password, etc.), then call Stripe and tell it to set up a subscription upon charging the customer's card. Stripe responds back with customer data. Store customer.id as the customer token and save the user.
def save_with_subscription if valid? customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token) self.stripe_customer_token = customer.id save! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_with_subscription\n #If user data passes validations, then call Stripe with user information\n #to get a new subscription created upon charging their card\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n self.stripe_customer_token = customer.id\n save!\n end\n end", "def save_with_subscription\n if valid?\n customer = Stripe::Customer.create(description: email, card: stripe_card_token)\n self.stripe_customer_token = customer.id\n save! \n end\n end", "def create_subscription\n subscription = nil\n stripe_call do\n local_plan = Plan.active.find(@params[:user][:plan_id])\n return false if local_plan.nil?\n stripe_plan = Stripe::Plan.retrieve(local_plan.stripe_id)\n # If the plan has a trial time, it does not need a stripe token to create a subscription\n # We assume you have a trial time > 0. Otherwise there will be 2 customers created for\n # each subscribed customer. One at registration and another when subscribing.\n subscription = customer.subscriptions.create(\n source: @params[:stripeToken],\n plan: stripe_plan.id\n )\n end\n return false if subscription.nil?\n\n user_attributes_to_update = {\n stripe_id: customer.id,\n stripe_subscription_id: subscription.id\n }\n assign_card_details(user_attributes_to_update, @params)\n @user.update(user_attributes_to_update)\n end", "def save_with_subscription\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n # save customer id in DB with response\n self.stripe_customer_token = customer.id \n # runs save\n save!\n end\n end", "def subscribe\n # Find the user to pay.\n user = User.find( params[:id] )\n\n # Calculate the fee percentage that applies to\n # all invoices for this subscription.\n fee_percent = (Rails.application.secrets.fee_percentage * 100).to_i\n begin\n if user.stripe_customer_id\n customer = Stripe::Customer.retrieve(user.stripe_customer_id)\n customer.coupon = 'ahip200off'\n customer.save\n\n customer.subscriptions.create({:plan => params[:plan]})\n #customer.application_fee_percent = fee_percent\n # customer.save\n else\n # Create a customer and subscribe them to a plan\n # in one shot.\n # Normally after this you would store customer.id\n # in your database so that you can keep track of\n # the subscription status/etc. Here we're just\n # fire-and-forgetting it.\n customer = Stripe::Customer.create(\n {\n card: params[:token],\n email: current_user.email,\n plan: params[:plan],\n application_fee_percent: fee_percent,\n metadata: {name: user.name},\n # coupon: 'ahip200off',\n },\n user.secret_key\n )\n user.stripe_customer_id = customer.id\n user.save!\n\n end\n flash[:notice] = \"Subscribed! <a target='_blank' rel='app-owner' href='https://dashboard.stripe.com/test/customers/#{customer.id}'>View in dashboard &raquo;</a>\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to user_path( user )\n end", "def save_withsubscription\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n self.stripe_card_token = customer.id\n save!\n end\n end", "def create\n customer = Stripe::Customer.create({\n :description => current_user.id,\n :email => current_user.email,\n :card => params[:stripeToken],\n })\n\n current_user.stripe_id = customer.id\n current_user.save!\n\n Stripe::Charge.create(\n :customer => current_user.stripe_id,\n :amount => 250,\n :description => 'Fantasy Rocket Monthly Subscription',\n :currency => 'usd',\n )\n\n current_user.create_subscription!\n redirect_to params[:redirect_to] || root_url, notice: \"Thanks! You're now subscribed.\"\n rescue Stripe::CardError => e\n redirect_to new_subscriptions_url, alert: e.message\n end", "def save_with_payment\n # if valid (ruby)\n if valid?\n # create a variable that stores all of the values from the form as well as a new stripe_card_token that will be returned from stripe\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n # set a variable that is equal to the id attribute of the customer object that was created above\n # save all of this to the User database\n # needed to run a migration to add AddStripeCustomerTokenToUsers column to User database\n self.stripe_customer_token = customer.id # User.stripe_customer_token = ....\n save!\n end\n end", "def save_with_payment\n if valid? # We did added some validation to make sure user filled in properly ::contact.rb\n # After Stripe get this info, Stripe will do the charging, this method comes from Stripe gem\n # Stripe will return an id after charging\n customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token) # Stripe had upgrade their API from card: -> source:\n # Set a property to the user after received the id Stripe returned(stripe will return customer hash)\n # 'self' means the target of this function, in this case is User, and we set a new atribute stripe_customer_token to User. \n self.stripe_customer_token = customer.id # Setting stripe_customer_token to Stripe::customer.id \n save!\n end\n \n end", "def update_stripe\n Stripe.api_key = \"sk_test_fVKfBEBDcWPZl5mLFk44KBJX\"\n \n # create the charge on Stripe's servers - this will charge the user's card\n if customer = Stripe::Customer.create(\n :card => stripe_token,\n :plan => \"basic_plan\",\n :description => email\n )\n \n User.update(user_id, :status => 'paid', :stripe_customer_id => customer.id)\n end\n end", "def create\n @user = User.new(params[:user])\n @user.customer = Customer.new(params[:user][:customer_attributes])\n @user.origin = Origin.find_by_code(cookies[:origin]) if (cookies[:origin] and !Origin.find_by_code(cookies[:origin]).nil?)\n @user.partner_id = partner\n @quietly_create = params[:quietly_create] || false\n \n if User.exists?(:email => @user.email)\n flash[:error] = \"<img src='/images/logo.png' align='left' width='99' style='margin: 0pt 10px 10px 0pt; position: relative; top: -12px;'/><strong>This email is already registered with WTD</strong>. <br/><br/>Forgot your password? You can <a href='/forgot_password'>reset your password here</a>.\"\n redirect_to login_path and return\n end\n \n # setup promo code from params\n if !params[:referral_code].blank? and PromotionCode.exists?(:code => params[:referral_code])\n @promotion_code = PromotionCode.find_by_code(params[:referral_code])\n elsif !session[:stored_promotion_code_id].blank? and PromotionCode.find(session[:stored_promotion_code_id])\n @promotion_code = PromotionCode.find(session[:stored_promotion_code_id])\n else\n @promotion_code = nil\n end\n\n # quiet create extras\n if @quietly_create\n # @user.email_confirmation = @user.email if @user.email_confirmation.blank?\n @user.password = @user.temporary_password\n @user.password_confirmation = @user.password\n @user.quietly_created = true\n @user.customer.quietly_created = true\n end\n\n # add survey question if present\n session[:survey_question_value] = params[:survey_question_value] unless params[:survey_question_value].blank?\n \n # update subscriptions and tracking analytics\n if @user.update_subscriptions(request.referrer, nil, true)\n session[:new_subscriber] = true\n session[:new_subscriber_email] = @user.email\n end\n \n \n # check promo code and attempt to save user\n if !@promotion_code.nil? and !@promotion_code.redeemable?\n flash[:error] = 'Sorry, but that promo code is not redeemable!'\n render :action => 'new'\n elsif @user.save \n flash[:notice] = \"<strong>Success! You're officially part of the WTD family.</strong>\" unless @quietly_create\n \n # trigger analytics to track\n session[:new_user] = true\n session[:new_subscriber_user_id] = @user.id\n\n # check referrals and credits\n unless @promotion_code.nil?\n unless @promotion_code.bad_referral?(@user.id)\n @credit = Credit.new\n @credit.promotion_code_id = @promotion_code.id\n @credit.value = @promotion_code.value\n @credit.user_id = @user.id\n @credit.referrer_user_id = @promotion_code.user_id\n @credit.save\n else\n flash[:error] = \"Sorry, but there seems to be something wrong with your referral. Please check back in an hour or email us at support@sowhatsthedeal.com.\"\n end\n end\n \n flash[:notice] = params[:flash_notice] || \"Welcome, you are now officially part of the WTD family!\"\n flash[:notice] += \"<br/><br/><strong>Please <a href='/users/change_password'>choose a password</a> to complete your WTD account.</strong>\" if @user.quietly_created?\n flash[:notice] = \"Thanks for signing up for Half Price DC\" if partner == 3\n redirect_to session[:return_to] ? session[:return_to] : my_account_path\n else\n @user.password = \"\"\n @user.password_confirmation = \"\"\n flash[:error] = \"<strong>Be sure to include your first name, last name and a valid email address</strong>. <br/><br/>Remember, If you subscribed to our newsletter, you already have an account. Forgot your password? You can <a href='/forgot_password'>reset your password here</a>.\" if @user.errors.empty?\n session[:return_to] ? redirect_to(session[:return_to]) : render(:action => 'new')\n end\n end", "def create\n customer = StripeTool.create_customer(email: params[:stripeEmail], stripe_token: params[:stripeToken])\n\n\tcharge = StripeTool.create_charge(customer_id: customer.id, amount: @amount, description: @description)\n\n current_user.stripe_id = customer.id\n\n\treceipt = Charge.new charge_stripe_token: charge.id, price: @amount, description: @description)\n\n\tif Charge.save\n\n\telse\n\n\tend", "def create_stripe_customer_and_subscription(user)\n begin\n s_customer = Stripe::Customer.create(description: user.first_name, card: self.stripe_card_token, email: user.email)\n stripe_customer = StripeCustomer.create(object: s_customer.object, description: s_customer.description, livemode: s_customer.livemode, created_timestamp: s_customer.created, reference_id: s_customer.id, user_id: self.user_id)\n customer = Stripe::Customer.retrieve(stripe_customer.reference_id)\n \n if user.plan_name == \"school_closing_date\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"school_closing daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"school_closing_date\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"school_closing all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"christmas_break\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"xmas daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"christmas_break\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"Xmas all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id) \n elsif user.plan_name == \"spring_break\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"spring break daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"spring_break\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"spring break all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id) \n elsif user.plan_name == \"charlotte\" || user.plan_name == \"noresmen_cheer\"\n \n stripe_charge = Stripe::Charge.create(amount: stripe_football_amount(user), currency: \"usd\", customer: s_customer.id, description: \"Charge For Charlotte\")\n user.stripe_charges.create(amount: stripe_football_amount(user), currency: \"usd\", description: \"Charlotte\", stripe_customer_id: stripe_customer.id)\n \n elsif user.plan_name == \"eden\" || user.plan_name == \"noresmen_cheer\"\n \n stripe_charge = Stripe::Charge.create(amount: stripe_football_amount(user), currency: \"usd\", customer: s_customer.id, description: \"Charge for Eden\")\n user.stripe_charges.create(amount: stripe_football_amount(user), currency: \"usd\", description: \"Eden\", stripe_customer_id: stripe_customer.id)\n\n elsif user.plan_name == \"early_bird\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_early_bird_amount(user), currency: \"usd\", customer: s_customer.id, description: \"EarlyBird\")\n user.stripe_charges.create(amount: stripe_early_bird_amount(user), currency: \"usd\", description: \"EarlyBird\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"wffull\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_wffull_amount(user), currency: \"usd\", customer: s_customer.id, description: \"WFF FULL DAY\")\n user.stripe_charges.create(amount: stripe_wffull_amount(user), currency: \"usd\", description: \"WFF FULL\", stripe_customer_id: stripe_customer.id) \n\n elsif user.plan_name == \"wffhalf\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_wffhalf_amount(user), currency: \"usd\", customer: s_customer.id, description: \"WFF HALF DAY\")\n user.stripe_charges.create(amount: stripe_wffhalf_amount(user), currency: \"usd\", description: \"WFF HALF DAY\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"nonfull\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_nonfull_amount(user), currency: \"usd\", customer: s_customer.id, description: \"NON FULL DAY\")\n user.stripe_charges.create(amount: stripe_nonfull_amount(user), currency: \"usd\", description: \"NON FULL DAY\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"nonhalf\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_nonhalf_amount(user), currency: \"usd\", customer: s_customer.id, description: \"NON HALF DAY\")\n user.stripe_charges.create(amount: stripe_nonhalf_amount(user), currency: \"usd\", description: \"NON HALF DAY\", stripe_customer_id: stripe_customer.id) \n\n else\n \n \n subscription = customer.subscriptions.create(:plan => payment_discount(user.plan_name))\n user.subscriptions.create(stripe_card_token: subscription.id,plan_name: user.plan_name, stripe_customer_id: stripe_customer.id)\n end\n rescue Exception => e\n end\n end", "def save_with_payment\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token)\n self.stripe_customer_token = customer.id\n save!\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n @user.update_attribute(:token, SecureRandom.hex(6))\n RegistrationMailer.registration_confirmation(@user, new_email_confirmation_url(token: @user.token)).deliver\n if( @user.account == \"premium\")\n redirect_to new_charge_path :user, @user\n else\n redirect_to root_path, notice: \"An email has been sent to your account. Please click the link in the email to verify address and complete your registration.\"\n end\n else\n flash[:error] = \"Error creating new user. Please try again.\"\n render :new\n end\n\n end", "def create_customer\n input_param = params[:user] || params[:customer]\n if input_param\n input_param.delete(:password)\n input_param.delete(:password_confirmation)\n input_param.delete(:username)\n if current_user.is_a?(Referral) && input_param[:profile_attributes].present?\n input_param[:referral_category_id] = current_user.referral_category_id\n input_param[:profile_attributes][:referal_id] = current_user.code\n input_param[:profile_attributes][:referal] = current_user.referral_category.name if current_user.referral_category\n end\n end\n\n @customer = Customer.find_or_initialize_by_email(input_param[:email])\n @membership_order = Membership.find(session[:current_premium_id]) if session[:current_premium_id]\n \n if @customer.update_attributes(input_param)\n order.orderable = @customer\n # CustomerMailer.delay.welcome_email(@customer)\n CustomerMailer.delay.welcome_email_admin(@customer)\n \n if order.save && session[:current_premium_id].present?\n redirect_to extra_manage_orders_path\n else\n redirect_to premium_manage_orders_path\n end\n else\n @customer = Customer.new(input_param)\n flash[:errors] = @customer.errors.full_messages.uniq.join(', ')\n prepare_customer_form\n render :new\n end\n end", "def purchase_events_new_stripe_customer\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost]\n\n if create_customer_and_purchase_existing_user(token, @number, cost, coupon) # this is almost like create_customer_purchase, except have flash.nows in that helper\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n redirect_to current_user\n else\n redirect_to existing_user_purchase_path\n end \n\nend", "def create\n @new_sign_up = false #don't call alias again, but do call identify from here on\n Stripe.api_key = ENV['STRIPE_SECRET_KEY']\n\n unless ( params[:card].present? && params[:card][:card_number].present? &&\n params[:card][:exp_year].present? && params[:card][:exp_month].present? &&\n params[:card][:cvc].present? && params[:card][:plan_id].present? &&\n params[:phone].present? && params[:customer_card_name].present?\n )\n\n puts \"-----StripeCC - Missing Fields In Form\"\n flash.now[:alert] = \"Missing Details - All Fields are compulsory\"\n @name = params[:customer_card_name]\n @phone = params[:phone]\n render 'users/payment'\n return\n end\n\n \t\t@error = current_user.create_stripe_subscription(subscription_params)\n\n\t \tif @error.present?\n\t \t\tflash.now[:alert] = @error\n\t \t\tlogger.warn(\"=========Stripe Controller - Transaction Failure=========\")\n @transaction = Transaction.new( :user_id => current_user.id,\n :payment_service => \"Stripe\",\n :trans_type => \"Failed\",\n :stripe_callback_data => @error\n )\n unless @transaction.save\n puts \"-----StripeCC - Our Transaction Did Not Save on Stripe Fail\"\n end\n\n # back to payment screen:\n\t \t\trender 'users/payment'\n\n\t \telse #success\n\t \t\tflash.now[:notice] = \"Subscription Successfull\"\n\t \t\tlogger.warn(\"=========Transaction Successfull=========\")\n @transaction = Transaction.where(:user_id => current_user.id).order(\"id DESC\").first\n if @transaction.present?\n @transaction.update_attributes(\n :payment_service => \"Stripe\",\n :trans_type => \"Recurring\"\n )\n else\n puts \"-----StripeCC - Our Transaction Did Not Save on Stripe Success\"\n end\n\n namearray = (params[:customer_card_name]).split(' ', 2)\n save_user = current_user.update_attributes(:phone => (params[:phone]),\n :first_name => namearray.first, :last_name => namearray.last)\n puts \">>> current user did not save email and name.\" if save_user == false\n\n\t \t\tredirect_to submit_bill_path, :notice => \"Subscription Successful.\"\n\t end\n\n end", "def create\n @Payment = Payment.new\n @Payment.user_id = current_user\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => (25 * 100).floor,\n :currency => \"usd\",\n :card => token\n )\n flash[:notice] = \"Thanks for purchasing!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n\n @Payment.stripe_id = charge.id\n @Payment.amount = charge.amount\n\n if current_user.subscribed != true\n current_user.subscribed = true\n current_user.credit = 25.00\n else\n current_user.credit = current_user.credit + 25.00\n end\n\n current_user.save\n redirect_to caves_path\n end", "def purchase_sub_existing_card\n @plan = params[:sub][:plan] #integer corresponding to my_plan_id\n @events_number = params[:sub][:events_number]\n @code = params[:sub][:code]\n @new_price = params[:sub][:new_price]\n\n # retrieve stripe customer object yet again\n if !current_user.customer_id.blank?\n c = Stripe::Customer.retrieve(current_user.customer_id)\n end \n \n if is_valid_sub_coupon(@code) \n\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => @plan, :coupon => @code)\n else\n c.update_subscription(:plan => @plan, :trial_end => (Date.today + 1.day).to_time.to_i, :coupon => @code) \n end \n #create new subscription object in my database\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\n @sub.events_remaining = @events_number\n @sub.coupon = @code\n @sub.save \n\n #create receipt\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \n @r.save\n\n #mail receipt\n UserMailer.sub_receipt(current_user, @r).deliver\n\n else\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => @plan)\n else\n c.update_subscription(:plan => @plan, :trial_end => (Date.today + 1.day).to_time.to_i) \n end \n #create new subscription object in my database\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\n @sub.events_remaining = @events_number\n @sub.save \n\n #create receipt\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \n @r.save\n\n #mail receipt\n UserMailer.sub_receipt(current_user, @r).deliver\n end \n\n\n flash[:success] = \"Thank you! You are now subscribed to the #{Plan.find_by_my_plan_id(@plan).name.titleize} plan!\"\n redirect_to current_user\n\n #rescue Stripe::StripeError => e # THIS CODE WORKS!!! NEEED TO FIGURE OUT HOW EXACTLY\n # logger.error \"Stripe error while creating subscription w/o active sub for existing user with card on file (purchase_sub_existing_card)\"\n # flash[:error] = \"Something went wrong. Please try again or contact us!\"\n # redirect_to current_user\n\nend", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\n Stripe.api_key = ENV[\"STRIPE_SECRET_KEY\"]\n\n stripe_customer = Stripe::Customer.create(\n :email => @user.email,\n )\n @user.stripe_id = stripe_customer.id\n end", "def create\n # set up Stripe session\n Stripe.api_key = YAML.load_file(\"#{Rails.root}/config/stripe.yml\")[Rails.env][:secret_key]\n\n @account_type = AccountType.find params[:account_type_id]\n @account = Account.new({ :account_type_id => @account_type.id, name: account_params[:name] })\n\n user = User.new(user_params)\n unless user.valid?\n flash[:notice] = 'User invalid'\n render :new\n return\n end\n\n # Get the credit card details submitted by the form\n customer = create_stripe_customer(params[:stripeToken], user.email)\n\n @account.stripe_customer_id = customer.id\n\n begin\n # Create the charge on Stripe's servers - this will charge the user's card\n subscription = customer.subscriptions.create(:plan => @account_type.stripe_subscription_plan)\n @account.recurrence_at = Time.at(subscription.start.to_i).utc.strftime('%d')\n\n rescue Exception => e\n # The card has been declined\n flash[:notice] = e.message\n render :new\n return\n end\n\n respond_to do |format|\n begin\n @account.save\n user.save\n AccountUser.create({ :account_id => @account.id, :user_id => user.id })\n\n format.html { redirect_to confirm_email_path, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n rescue Exception => e\n flash[:notice] = e.message\n format.html { render :new }\n format.json { render json: e.message, status: :unprocessable_entity }\n end\n end\n # respond_to do |format|\n # if @account.save\n # if user.save\n # AccountUser.create({ :account_id => @account.id, :user_id => user.id })\n # else\n # format.html { render :new }\n # format.json { render json: user.errors, status: :unprocessable_entity }\n # end\n # format.html { redirect_to confirm_email_path, notice: 'Account was successfully created.' }\n # format.json { render :show, status: :created, location: @account }\n # else\n # format.html { render :new }\n # format.json { render json: @account.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update_card_and_new_subscription(token, plan, code) # plan is now a my_plan_id\n #should be a customer_id b/c downstream from option in which user has an existing stripe customer id\n c = Stripe::Customer.retrieve(current_user.customer_id)\n \n\n #updates customer with new card\n c.card = token\n c.save\n\n if !code.nil? && is_valid_sub_coupon(code) \n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => plan, :coupon => code)\n else #this shouldn't happen b/c in an upstream controller, set code to nil if has_trialed\n c.update_subscription(:plan => plan, :trial_end => (Date.today + 1.day).to_time.to_i, :coupon => code)\n end \n else\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => plan)\n else\n c.update_subscription(:plan => plan, :trial_end => (Date.today + 1.day).to_time.to_i)\n end \n end \n\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n \n rescue Stripe::CardError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n rescue Stripe::StripeError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n end", "def create_stripe\n # Order created by promotions#order and passed to merchant/orders/order_form\n # Cases: 1) not a customer; saving card\n # 2) not a customer; not saving card\n # 3) customer; using saved card\n # 4) customer; using new card and saving it\n # 5) customer; using new card and not saving it\n #\n # NOTE: I'm saving the associated user object in the orders controller, instead of trying to do it in the User model\n # I think it makes more sense to isolate all the Stripe stuff here, than have it scattered through models.\n # I also removed Stripe code from the Order model. It is all in the controller and User model (where it belongs).\n\n @stripe_customer = @order.user.stripe_customer_obj\n\n # Calculate total charge, adjusting for macho bucks. Do we need to charge the card?\n total_charge = @order.total_cost - @order.user.total_macho_bucks\n if total_charge > 0\n # We need to charge the credit card \n if @stripe_customer.nil?\n charge_success = false\n \n if params[:save_card] == 'true'\n # case 1\n @stripe_customer = Stripe::Customer.create(:email => @order.email,\n :description => @order.description,\n :card => @order.stripe_card_token)\n \n # Not in attr_accessible for security; must assign explicitly\n @order.user.stripe_id = @stripe_customer.id\n if @order.user.save\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n else\n flash[:notice] = \"Card could not be saved.\"\n charge_success = charge_card(@order, total_charge)\n end\n else \n # case 2\n charge_success = charge_card(@order, total_charge)\n end\n else\n # get existing customer\n if params[:new_card] == 'true'\n if params[:save_card] == 'true'\n # case 4\n # Update the card information for an existing customer\n @stripe_customer.card = @order.stripe_card_token\n @stripe_customer.save\n \n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n else\n # case 5\n charge_success = charge_card(@order, total_charge)\n end\n else\n # case 3\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n end\n end\n else\n # No charge necessary\n charge_success = true\n # Validated, so it has to be there\n @order.transaction_id = Order::MACHO_BUCKS_TRANSACTION_ID\n end\n \n # Charge operation should either succeed or throw an exception\n if charge_success\n # If the charge was successful, order will have charge_id (validated on save)\n if @order.save\n # After saving the order, create the associated vouchers using the promotion strategy\n # status defaults to Available; uuid is created upon save\n if @order.promotion.strategy.generate_vouchers(@order)\n flash[:notice] = I18n.t('order_successful')\n \n # If everything worked (voucher(s) saved), send the email\n # Products are handled differently in the mailer\n UserMailer.delay.promotion_order_email(@order)\n @order.user.log_activity(@order)\n \n # Debit the Macho Bucks. Usually 0, but possible they had more bucks than it cost\n # In the pathological case where they have negative macho bucks, the card was charged extra. That has to be cleared as well.\n # So we have to check for != 0, not > 0\n if @order.user.total_macho_bucks != 0\n deduction = @order.user.total_macho_bucks < 0 ? @order.user.total_macho_bucks : [@order.user.total_macho_bucks, @order.total_cost].min\n bucks = @order.build_macho_buck(:user_id => @order.user.id, :amount => -deduction, :notes => \"Credited on order: #{@order.description}\")\n if !bucks.save\n flash[:alert] = 'Unable to apply macho bucks!'\n end\n UserMailer.delay.macho_bucks_order_email(bucks)\n end\n \n redirect_to merchant_order_path(@order) and return\n end\n else\n @order.errors.add :base, \"Could not save order.\"\n end\n end\n\n # Should never get here, put theoretically possible if orders don't validate somehow; avoid template error\n render 'new' \n \n # Don't need a begin inside a def\n rescue Stripe::InvalidRequestError => error\n logger.error \"Stripe error while creating customer: #{error.message}\"\n @order.errors.add :base, \"There was a problem with your credit card. #{error.message}\"\n @promotion = @order.promotion\n render 'promotions/order'\n \n rescue Stripe::CardError => error\n logger.error \"Stripe error: #{error.message}\"\n @order.errors.add :base, \"There was a problem with your credit card. #{error.message}\"\n @promotion = @order.promotion\n render 'promotions/order'\n end", "def create_stripe_customer!\n Stripe::Customer.create(\n email: user.email,\n description: store.name,\n source: stripe_source_id\n )\n end", "def subscription_checkout\n\n @code = params[:couponCode]\n\n if !@code.blank?\n @discount = @code\n\n if @discount.nil?\n flash[:error] = 'Coupon code is not valid or expired.'\n redirect_to pricing_path\n return\n end\n\n charge_metadata = {\n :coupon_code => @code,\n :coupon_discount => (@discount * 100).to_s + \"%\"\n }\n end\n\n charge_metadata ||= {}\n\n plan_id = params[:plan_id]\n plan = Stripe::Plan.retrieve(plan_id)\n #This should be created on signup.\n customer = Stripe::Customer.create(\n #:description => \"Customer for test@example.com\",\n :source => params[:stripeToken],\n :email => current_user.email\n )\n\n user = current_user\n user.stripe_id = customer.id\n user.subscribed = true\n user.save\n\n # Save this in your DB and associate with the user;s email\n stripe_subscription = customer.subscriptions.create(:plan => plan.id, :coupon => @discount)\n\n flash[:notice] = \"Successfully Subscribed!\"\n redirect_to '/dashboard'\n end", "def create\n plan = params[\"payment\"][\"plan\"]\n plan=\"premium_monthly\" if plan.empty?\n stripe_token = params[:payment][:stripe_customer_token]\n cardHolderName = params[\"cardHolderName\"]\n email = params[\"payment\"][\"email\"]\n flag = false\n\n if stripe_token\n begin\n @payment = current_user.payments.new(payment_params)\n customer = current_user.do_transaction(params[:payment_type], stripe_token, plan, cardHolderName, email)\n if customer\n @payment.stripe_customer_token = customer.id\n subcripted_detail = customer.subscriptions[\"data\"][0]\n flash[:notice] = 'Card charged successfully'\n else\n flag = true\n flash[:alert] = 'Some error happened while charging you, please double check your card details'\n end\n rescue Stripe::APIError => e\n flash[:alert] = e\n flag = true\n end\n else\n flag = true\n flash[:alert] = 'You did not submit the form correctly'\n end\n\n if flag\n render new_payment_path({plan: plan, error: e})\n end\n\n respond_to do |format|\n if @payment.save\n plan = Payment.plans[plan]\n current_user.update_attributes(subscription: plan, remaining_days: -1, stripe_customer_id: customer.id, is_paid_user: true)\n NotificationMailer.monthly_subscription_email(current_user, subcripted_detail).deliver_now\n format.html { redirect_to \"/users/edit\", notice: 'Payment made successfully.'}\n format.json { render json: @payment, status: :created, location: @payment }\n end\n end\n\n end", "def create\n @payment = Payment.new(payment_params)\n\n @amount = @payment.amount * 100\n\n Stripe.api_key = 'sk_test_CfSPVwqeJbuCxJSnCDcXuKRG';\n\n begin\n if current_user.stripe_customer_id.present?\n @customer = Stripe::Customer.retrieve(current_user.stripe_customer_id) \n else\n card_details = {}\n card_details[:name] = payment_params[:first_name]\n card_details[:number] = payment_params[:credit_card_number]\n card_details[:cvc] = payment_params[:card_security_code]\n card_details[:exp_month] = payment_params[:expiration_month]\n card_details[:exp_year] = payment_params[:expiration_year]\n\n @card = Stripe::Token.create(card: card_details)\n \n @customer = Stripe::Customer.create(\n :email => current_user.email,\n :card => @card.id\n )\n\n if @customer.present?\n current_user.stripe_customer_id = @customer.id\n current_user.save!\n end\n end\n\n\n @charge = Stripe::Charge.create(\n :customer => @customer.id,\n :amount => @amount,\n :description => 'Autopass payment',\n :currency => 'usd'\n )\n\n if @payment.save\n redirect_to success_payment_path(@payment), notice: 'Payment was successfully created. Vender will be notified.'\n end\n rescue Stripe::CardError => e\n redirect_to \"/siteparking/sitepayments/#{@payment.parking.token}\"\n flash[:error] = e.message\n end \n\n\n end", "def success\n if params[:reference].present?\n\n paystackObj = Paystack.new(ENV['PAYSTACK_PUBLIC_KEY'], ENV['PAYSTACK_PRIVATE_KEY'])\n\n subscriptions = PaystackSubscriptions.new(paystackObj)\n result = subscriptions.create(\n\n :customer => current_user.email,\n :plan => \"PLN_96ws6ovviw8028d\", #plan id\n :amount => 200000 #in KOBO\n\n \n )\n\n\n u = current_user\n u.subscribed = true\n u.subscription_code = code\n u.email_token = token\n u.save!\n \n else\n redirect_to new_subscription_path, notice: \"Error Making Payment, Try Again\"\n\n end\n end", "def create\n params.permit(:interval, :plan, :stripeEmail, :stripeToken)\n if current_user\n @user = current_user\n begin\n customer = Stripe::Customer.create(\n :email => params[:stripeEmail],\n :source => params[:stripeToken],\n :plan => params[:plan]\n )\n if @user.plan.nil? || @user.plan != params[:plan]\n case params[:interval]\n when \"month\"\n active_date_increment = Time.now + 1.month\n when \"year\"\n active_date_increment = Time.now + 1.year\n when \"week\"\n active_date_increment = Time.now + 1.week\n end\n @user.update_attributes!(\n stripe_customer_id: customer.id,\n active_until: active_date_increment,\n plan: params[:plan],\n stripe_token: params[:stripeToken]\n )\n end\n redirect_to @user\n rescue\n puts \"Unable to register customer with Stripe: #{params[:stripeEmail]}\"\n flash[:alert] = \"There was an error processing the payment. Please try again.\"\n redirect_to plan_path(Stripe::Plan.retrieve(params[:plan]))\n end\n end\n end", "def postfill!(customer)\n self.price = customer.subscription.plan.amount / 100\n self.stripe_id = customer.id\n self.exp_month = customer.active_card.exp_month\n self.exp_year = customer.active_card.exp_year\n self.last4 = customer.active_card.last4\n self.status = \"active\"\n self.save!\n self\n end", "def purchase_events_new_stripe_couple\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost]\n\n if create_customer_and_purchase_existing_user(token, @number, cost, coupon) # this is almost like create_customer_purchase, except have flash.nows in that helper\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n redirect_to current_user\n else\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\n end \n\nend", "def purchase_sub_not_stripe_customer\n token = params[:stripeToken]\n @plan = params[:plan] #integer corresponding to my_plan_id\n @events_number = params[:events_number] #not being used right now because create_customer helper finds the events_number form the plan object via @plan argument\n @code = params[:code] \n @new_price = params[:new_price]\n event_type = \"voicegems\"\n\n if create_customer(token, @plan, @code, @new_price, event_type) #using the same helper as when a new user signs up as a customer\n #record stripe's (?) customer_id for this user\n # this helper is in users helper\n \n redirect_to current_user\n else\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)\n #These above are required to properly render purchase_sub_existing. Not changing below to redirect because the create_customer helper is creating Flash.nows, not Flashs, and this helper also being used in for totally new customers/users\n render 'purchase_sub_existing'\n end \n\n\nend", "def create\n @user.account = Account.new if @user.account.nil?\n\n if @user.account.save_with_stripe(params)\n redirect_to user_url(@user), notice: 'Account was successfully created.'\n else\n handle_account_errors(@user, params)\n render :new\n end\n end", "def save_with_payment\n if valid?\n @amount = (amount * 100)\n customer = Stripe::Customer.create(description: email, card: stripe_card_token)\n charge = Stripe::Charge.create(\n :customer => customer.id,\n :amount => @amount,\n :description => 'Food bank donation',\n :currency => 'usd'\n )\n self.stripe_customer_token = customer.id\n save!\n end\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n errors.add :base, \"There was a problem with your credit card.\"\n false\n end", "def process_payment_unlimitess\n customer = Stripe::Customer.create email: email, card: token\n update_stripe_customer_id(customer)\n Stripe::Subscription.create customer: customer.id,\n items: [\n {price: 'price_1IndU1Bje2Voz8401SdrQuM0'},\n ]\n\n# customer = Stripe::Customer.create email: email, card: token\n# Stripe::Charge.create customer: customer.id,\n# amount: 10000,\n# description: 'Premium',\n# currency: 'usd'\n end", "def charge_user_via_invoice\n customer_id = stripe_user_customer_id\n return unless customer_id.present?\n\n invoice = create_invoice(customer_id)\n create_invoice_items_for_dpc(customer_id, invoice.id)\n resource.identifier.payment_id = invoice.id\n resource.identifier.payment_type = stripe_user_waiver? ? 'waiver' : 'stripe'\n resource.identifier.save\n invoice.send_invoice\n end", "def create_stripe_subscription(card_details)\n @error = \"\"\n\t\tbegin\n\t\t\tcustomer = Stripe::Customer.create(\n\t\t\t\t:email => self.email,\n\t\t \t\t## if you are using the js to fetch the stripe_card_token change the ':card => card_details[\"stripe_card_token\"]' ##\n\t\t \t\t:card => {\n\t\t \t\t\t:number => card_details[\"card_number\"],\n\t\t \t\t\t:exp_month => card_details[\"exp_month\"],\n\t\t \t\t\t:exp_year => card_details[\"exp_year\"],\n\t\t \t\t\t:cvc => card_details[\"cvc\"]\n },\n\t\t\t :plan => card_details[\"plan_id\"]\n )\n\n \t\tputs \"==Customer_id : ====#{customer.id}============\"\n puts \"--------------User Model Stripe Customer Object: \" + customer.inspect\n @transaction = Transaction.new( :user_id => self.id,\n :payment_service => \"Stripe\",\n :trans_type => \"CreateStripeCustomer\",\n :stripe_id => customer.id,\n :last4 => customer.cards.data.first['last4'],\n :brand => customer.cards.data.first['brand'],\n :funding => customer.cards.data.first['funding'],\n :exp_month => customer.cards.data.first['exp_month'],\n :exp_year => customer.cards.data.first['exp_year']\n )\n unless @transaction.save\n puts \"-----UserModel - Stripe - Our Transaction Did Not Save on Stripe Fail\"\n end\n\n\t \trescue Stripe::StripeError => e\n logger.warn(\"====#{e.message}==\")\n puts \"====User-Model - Stripe Transaction Failed Due to #{e.message}=====\"\n @error = (\"card error: \" + e.message)\n # Transaction Error Record Created In Controller\n # @transaction = Transaction.new( :user_id => self.id,\n # :payment_service => \"Stripe\",\n # :trans_type => \"Failed\",\n # :stripe_callback_data => @error\n # )\n # unless @transaction.save\n # puts \"-----UserModel - Stripe - Our Transaction Did Not Save on Stripe Fail\"\n # end\n\t\tend\n\t\treturn @error\n\n end", "def subscribe!\n Subscription.transaction do\n subscription = create_stripe_subscription!\n store.subscriptions.create!(\n customer: user,\n stripe_plan_id: stripe_plan_id,\n stripe_id: subscription.id,\n first_date: Date.today,\n status: :active\n )\n end\n end", "def create_stripe_customer(token)\n Stripe.api_key = 'sk_test_xvxhe0dUKfbGI2MJOWOg1N8j'\n\n begin \n customer = Stripe::Customer.create(\n card: token,\n description: self.email\n )\n\n self.update(stripe_customer_id: customer.id)\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to sub_request_path\n end\n end", "def update_subscription\n success = stripe_call do\n customer = Stripe::Customer.retrieve(@user.stripe_id)\n subscription = customer.subscriptions.retrieve(@user.stripe_subscription_id)\n subscription.source = @params[:stripeToken] if @params[:stripeToken]\n # Update plan if one is provided, otherwise use user's existing plan\n # TODO providing plan_id is untested\n plan_stripe_id = @params[:plan_id] ? Plan.find(@params[:plan_id]).stripe_id : @user.plan.stripe_id\n subscription.items = [{\n id: subscription.items.data[0].id,\n plan: plan_stripe_id\n }]\n subscription.save\n end\n return false unless success\n user_attributes_to_update = {}\n # This is updated by the stripe webhook customer.updated\n # But we can update it here for a faster optimistic 'response'\n assign_card_details(user_attributes_to_update, @params)\n user_attributes_to_update[:plan_id] = @params[:plan_id].to_i if @params[:plan_id]\n @user.update(user_attributes_to_update) if user_attributes_to_update.any?\n return true if success\n end", "def create\n customer = Stripe::Customer.create(\n email: current_user.email,\n card: params[:stripeToken]\n )\n # Changes the user role to premium\n charge = Stripe::Charge.create(\n customer: customer.id, \n amount: amount_for_upgrade,\n description: \"Premium Membership! - #{current_user.email}\",\n currency: 'usd'\n )\n\n # @param: customer, the string representation of the customer id\n # @param: amount, an integer represenation of amount \n # @param: description, the string representation of description \n # @param: currency, the string representation of currancy\n\n current_user.update_attribute(:role, 'premium')\n flash[:notice] = \"Thanks for upgrading your account!, #{current_user.email}! \"\n redirect_to wikis_path(current_user) \n\n# Rescue block catches and displays error \n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_charge_path\nend", "def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save and @user.payment == \"paypal\"\n response = EXPRESS_GATEWAY.setup_purchase(@user.calculate_total_in_cents,\n :ip => request.remote_ip,\n :return_url => new_order_url,\n :cancel_return_url => orders_url,\n :currency => \"USD\",\n :description => \"Sms affirmation service - $#{\"%.2f\" % (@user.calculate_total_in_cents / 100 ) }\",\n )\n\n @user.update(:payment_token => response.token)\n redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) and return\n format.html { redirect_to new_user_path, notice: 'Your SMS Subscription has been activated.' }\n format.json { render action: 'show', status: :created, location: @user }\n else\n @user.terms = false\n\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def pay\n Stripe.api_key = Constants::STRIPE_API_SECRET_KEY\n\n # Get the credit card details submitted by the form\n token = params[:stripeToken]\n\n # Create a charge: this will charge the user's card\n begin\n #Keep this as a sample of basic Stripe payment\n # charge = Stripe::Charge.create(\n # :amount => 500, # Amount in cents\n # :currency => \"usd\",\n # :source => token,\n # :description => \"Example charge\",\n # :metadata => {\"order_id\" => \"6735\"}\n # )\n\n #If the current_user has no stripe_customer_id in the DB, that means this is the first time he provide\n #their bank account info, so let's create a Stripe Customer on the cloud to store their bank info for\n #use it later.\n if current_user.stripe_customer_id.blank?\n customer = Stripe::Customer.create(\n card: token,\n description: \"#{current_user.email}-#{current_user.display_name}\",\n email: current_user.email\n )\n customer_id = customer.id\n else\n customer = Stripe::Customer.retrieve(current_user.stripe_customer_id)\n customer_id = current_user.stripe_customer_id\n end\n # Stripe::Charge.create(\n # amount: cart_total_price, # $15.00 this time\n # currency: 'usd',\n # customer: customer_id\n # )\n\n #TODO I know this is ugly but it can define less functions, we can optimize this later\n @card = {card_number: (\"*****#{params[:card_number][-4..-1]}\" rescue nil) || \"*****#{customer[:sources][:data].first[:last4]}\",\n cvv: params[:cvv] || \"\",\n exp_date: \"#{params[:exp_year] || customer[:sources][:data].first[:exp_year]}-\n #{params[:exp_month] || customer[:sources][:data].first[:exp_month]}\",\n card_holder_name: params[:card_holder_name] || \"\"}\n PaymentMailer.payment_success(current_user, @card).deliver_now\n PaymentMailer.send_essay(current_user, session[:cart]).deliver_now\n session[:cart] = nil\n # save the customer ID in your database so you can use it later\n current_user.update_column(\"stripe_customer_id\", customer_id)\n rescue Stripe::CardError => e\n @transaction_falied = true\n # The card has been declined\n PaymentMailer.payment_failed(current_user, @card).deliver_now\n end\n render 'payment_confirmation'\n end", "def create\n @subscription = Subscription.new(subscription_params)\n\n @subscription.sub_create(current_user,subscription_params[:stripe_plan_id],subscription_params[:coupon_code])\n\n # Create a subscription with the following information:\n #\n # 1) Customer Account\n # 2) Subscription Type (GOLD, Silver, etc.)\n # 3) Discount Coupom (if applicable)\n\n if @subscription.save\n redirect_to @subscription, notice: 'Subscription was successfully created.'\n else\n @verrors = @subscription.errors.full_messages\n render 'new'\n end\n end", "def create_account\n @customer = Customer.find params[:id]\n fail unless @customer.email == params[:customer][:email]\n @customer.update_attributes!(customer_params)\n @customer_session = Authentication::CustomerSession.new(\n email: @customer.email,\n password: customer_params[:password]\n )\n @customer_session.save!\n end", "def charge!\n self.class.transaction do\n return if used_comp?\n if subscriber.blank?\n # something happened where the attached user no longer exists....\n # do not do anything, but log it so the admin can decide what to do?\n Freemium.log_subscription_msg(self, \"Subscriber (id: #{subscriber_id}, type: #{subscriber_type}) is no longer found. Deleting this subscription (id: #{self.id}).\")\n self.destroy\n return\n end\n \n if billing_key.blank?\n expire_after_grace! #if self.expires_on.blank? || self.expires_on <= Date.today\n return \n end\n # attempt to bill (use gateway)\n transaction = Freemium.gateway.charge(billing_key, subscription_plan.rate)\n Freemium.log_subscription_msg(self, transaction)\n transaction.success? ? receive_payment!(transaction.amount) : expire_after_grace!\n end\n end", "def charge\r\n if paypal?\r\n if (@response = paypal.get_profile_details(billing_id)).success?\r\n next_billing_date = Time.parse(@response.params['next_billing_date'])\r\n if next_billing_date > Time.now.utc\r\n update_attributes(:next_renewal_at => next_billing_date, :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount) unless amount == 0\r\n true\r\n else\r\n false\r\n end\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n else\r\n if amount == 0 || (@response = gateway.purchase(amount_in_pennies, billing_id)).success?\r\n update_attributes(:next_renewal_at => self.next_renewal_at.advance(:months => self.renewal_period), :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount, :transaction_id => @response.authorization) unless amount == 0\r\n true\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n end\r\n end", "def changesub_existinguser\n @plan = params[:sub][:plan] # this is an integer corresponding to my_plan_id\n @planobject = Plan.find_by_my_plan_id(@plan)\n @events_number = @planobject.events_number \n @code = params[:sub][:code]\n\n if is_valid_sub_coupon(@code) && !@planobject.nil?\n @coupon = Coupon.find_by_name(@code)\n @new_price = @planobject.monthly_cost_cents * (100 - @coupon.percent_off)/100\n flash.now[:success] = \"Your promo code has been applied!\"\n else #could not find that coupon\n @code = nil \n @coupon = nil \n @new_price = nil\n end\n\n if !current_user.customer_id.blank?\n c = Stripe::Customer.retrieve(current_user.customer_id)\n @last4 = c.cards.data.first.last4\n @cardtype = c.cards.data.first.type\n end \n\n render action: 'purchase_sub_existing_choose'\n\nend", "def create_stripe_account\n unless stripe_token.present? || Rails.env.test?\n customer = Stripe::Customer.create(description: \"User ID: #{id}\", email: email)\n update_columns(stripe_token: customer.id)\n end\n end", "def purchase_sub_new_card\n token = params[:stripeToken]\n @plan = params[:plan] #integer corresponding to my_plan_id\n @events_number = params[:events_number] \n @code = params[:code]\n @new_price = params[:new_price]\n\n if update_card_and_new_subscription(token, @plan, @code)\n c = Stripe::Customer.retrieve(current_user.customer_id)\n \n #create new subscription object in my database\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\n @sub.events_remaining = @events_number\n @sub.coupon = @code \n @sub.save \n\n #create receipt\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \n @r.save\n\n #mail receipt\n UserMailer.sub_receipt(current_user, @r).deliver\n\n flash[:success] = \"Thank you for subscribing to the #{Plan.find_by_my_plan_id(@plan).name.titleize} plan!\"\n redirect_to current_user\n\n else\n redirect_to purchase_sub_existing_path\n end \n\n\nend", "def subscribe!(params)\n raise Errors::AlreadySubscribedError if subscribed?\n raise Errors::StripeCustomerExistsError if stripe_customer_id\n\n customer = ::Stripe::Customer.create(\n source: params[:stripe_token],\n plan: params[:subscription_plan_id] || SlackRubyBotServer::Stripe.config.subscription_plan_id,\n email: params[:stripe_email],\n metadata: {\n id: id,\n team_id: team_id,\n name: name,\n domain: domain\n }\n )\n\n update_attributes!(\n subscribed: true,\n subscribed_at: Time.now.utc,\n stripe_customer_id: customer['id'],\n subscription_expired_at: nil,\n subscription_past_due_at: nil,\n subscription_past_due_informed_at: nil\n )\n\n customer\n end", "def update_card_and_subscription(token, plan) # plan is now a my_plan_id\n \n c = Stripe::Customer.retrieve(current_user.customer_id) #have this in the enveloping controller action as well, because of the 'undefined variable c' error i was getting from the 4000000000000341 card test\n\n #updates customer with new card\n c.card = token\n c.save\n\n #updates subscription plan in stripe \n c.update_subscription(:plan => plan, :prorate => true)\n\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n \n rescue Stripe::CardError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n rescue Stripe::StripeError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n end", "def create\n\n # @stripe_account = StripeAccount.new(stripe_account_params)\n # @user = User.find(params[:user_id])\n # @stripe_account.user_id = current_user.id\n\n @user = (current_user || current_affiliate)\n @stripe_account = @user.build_stripe_account(stripe_account_params)\n\n\n\n acct = Stripe::Account.create({\n :country => \"US\",\n :type => \"custom\",\n legal_entity: {\n first_name: stripe_account_params[:first_name].capitalize,\n last_name: stripe_account_params[:last_name].capitalize,\n type: stripe_account_params[:account_type],\n dob: {\n day: stripe_account_params[:dob_day],\n month: stripe_account_params[:dob_month],\n year: stripe_account_params[:dob_year]\n },\n address: {\n line1: stripe_account_params[:address_line1],\n city: stripe_account_params[:address_city],\n state: stripe_account_params[:address_state],\n postal_code: stripe_account_params[:address_postal]\n },\n ssn_last_4: stripe_account_params[:ssn_last_4]\n },\n tos_acceptance: {\n date: Time.now.to_i,\n ip: request.remote_ip\n }\n\n })\n\n @stripe_account.acct_id = acct.id\n # @user.stripe_token = acct.id\n\n\n\n respond_to do |format|\n\n # @user = User.find(params[:id])\n\n if @stripe_account.save!\n # && @user.save\n\n\n\n\n format.html { redirect_to new_bank_account_path, notice: 'Stripe account was successfully created.' }\n format.json { render :show, status: :created, location: @stripe_account }\n\n\n else\n format.html { render :new }\n format.json { render json: @stripe_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_with_payment discount_code\n if valid?\n customer = Stripe::Customer.create(description: user.name, email: user.email, plan: plan.name.parameterize.underscore, card: stripe_card_token, coupon: discount_code.try(:code))\n user.update_column(:stripe_customer_token, customer.id)\n user.create_discount_code_user(discount_code_id: discount_code.id) unless discount_code.nil?\n save!\n end\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n errors.add :base, \"There was a problem with your credit card.\"\n false\n end", "def pay\n # Find the user to pay.\n captain = User.find( params[:id] )\n\n # Charge amount owed over .971 to account for Stripe fee. This needs to be done here because the fee is being charged to the captain, so he needs to charge his players extra to account for the money being taken out of his take.\n amount = session[:amount_owed]/0.971\n # Calculate the fee amount that goes to the application.\n fee = (amount * Rails.application.secrets.fee_percentage).to_i\n\n begin\n charge_attrs = {\n amount: amount,\n currency: user.currency,\n source: params[:token],\n description: \"Test Charge via Stripe Connect\",\n application_fee: fee,\n destination: captain.stripe_user_id\n }\n\n # case params[:charge_on]\n # when 'connected'\n # p charge_attrs\n # # Use the user-to-be-paid's access token\n # # to make the charge directly on their account\n # charge = Stripe::Charge.create( charge_attrs, user.secret_key )\n # when 'platform'\n # # Use the platform's access token, and specify the\n # # connected account's user id as the destination so that\n # # the charge is transferred to their account.\n # charge_attrs[:destination] = user.stripe_user_id\n charge = Stripe::Charge.create( charge_attrs )\n # end\n\n flash[:notice] = \"Charged successfully! <a target='_blank' rel='#{params[:charge_on]}-account' href='https://dashboard.stripe.com/test/payments/#{charge.id}'>View in dashboard &raquo;</a>\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to session[:saved_url]\n end", "def create_subscription(credit_card, options = {})\n\n u = self.user\n options[:order_id] = number # currently just loading a date\n options[:email] = u.email\n options[:address] = {\n :first_name => u.first_name,\n :last_name => u.last_name,\n :address1 => u.street_address1,\n :address2 => (u.street_address2 || \"\"),\n :company => (u.company || \"\"),\n :city => u.city,\n :state => u.us_state,\n :zip => u.zip,\n :country => 'United States',\n :phone => u.primary_phone\n }\n\n subscription = OrderTransaction.generate_yearly_subscription(credit_card, options)\n self.save!\n order_transactions << subscription\n\n if subscription.success?\n self.payment_captured!\n else\n self.transaction_declined!\n end\n\n subscription\n end", "def create\n # Amount in cents\n @amount = params[:price].to_i * 100\n \n customer = Stripe::Customer.create(\n :email => params[:stripeEmail],\n :source => params[:stripeToken]\n )\n \n charge = Stripe::Charge.create(\n :customer => customer.id,\n :amount => @amount,\n :description => 'Rails Stripe customer',\n :currency => 'aud'\n )\n \n set_available_to_false(params[:product_id])\n add_user_balance(params[:price])\n redirect_to root_path\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_charge_path\n end", "def create\n payer_email = params[:payer_email]\n txn_type = params[:txn_type] # subscr_failed, subscr_cancel, subscr_payment, subscr_signup, subscr_eot, subscr_modify\n \n if params[:reason_code] == 'refund'\n # TODO: just notify me that somebody refunded, keep their is_customer flag set to true\n else\n # add/flag customer\n u = User.find_or_create_by_email(payer_email)\n u.first_name = params[:first_name] # overwrite whatever we've got with Paypal's info\n u.last_name = params[:last_name]\n u.password = 'temporary'\n u.is_customer = true\n u.save\n CustomerMailer.deliver_purchase_complete(u) # send them a link\n AdminMailer.deliver_purchase_notification(u) # let me know they were added\n subject = 'Customer added'\n end\n \n render :text => 'OK'\n end", "def create\n tpauth = Authentication.find session[:customer_oauth_id]\n if tpauth\n @customer = Customer.new(params[:customer])\n if Customer.count == 0\n # The first customer has administrative privileges.\n @customer.add_roles([:admin])\n end\n @customer.authentications << tpauth\n @customer.save\n session[:customer_id] = @customer.id\n redirect_to edit_customer_registration_path(@customer), :notice => \"Signed In!\"\n else\n redirect_to customer_sign_in_path, \"You need to authenticate first.\"\n end\n end", "def create\n sub_id = params[:spree_user][:sub_type].blank? ? \"1\" : params[:spree_user][:sub_type]\n coupon_code = params[:spree_user][:coupon_code]\n @cart = Cart.new\n @user = build_resource(user_params_list)\n\n credit_card_params = params[:spree_user][:creditcards_attributes][\"0\"]\n respond_to do |format|\n format.js do\n if @user.valid?\n billing_address = @user.addresses.last\n result = Creditcard.create_customer_and_creditcard_over_braintree(billing_address, @user.email,credit_card_params)\n @success = result.success? ? true : false\n puts \"i am in user success with params#{@success} and #{billing_address}\"\n\n\n if @success && @user.save\n customer =result.customer\n @credit_card_details = Creditcard.update_creditcard(customer.credit_cards.first, @user.id)\n @user.push_subscription_and_customer_id(sub_id, customer.id)\n @cart.prepare_cart(@user.id, sub_id)\n @user.update_bill_and_ship_address_details\n @user.update_address_type_and_name_fields\n\n #####code for creating new orders#####\n # first order\n plan_price = Subscription.where(id: sub_id).first.plan_price.to_f\n @order_1 = place_order_registration(sub_id, FIRST_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, request.remote_ip, plan_price)\n new_token_1 = @order_1.get_unique_ID\n new_token_subscr = Spree::Order.get_unique_subscription_token\n #entry in user subscription\n\n coupon = Coupon.get_briantree_discount_id_and_calculate_final_amount(plan_price, coupon_code)\n\n if coupon.present?\n user_subscription_id = UserSubscription.create_user_subscription(sub_id, @user.id, new_token_subscr, coupon[\"id\"])\n sub_result = Subscription.place_subscription_with_coupon(@order_1.delivery_date, @order_1.subscription_id, @credit_card_details.id, new_token_subscr, coupon)\n @order_1.update_attributes(coupon_id: coupon[\"id\"])\n Coupon.raise_counter(coupon[\"id\"])\n else\n user_subscription_id = UserSubscription.create_user_subscription(sub_id, @user.id, new_token_subscr)\n sub_result = Subscription.place_subscription_without_coupon(@order_1.delivery_date, @order_1.subscription_id, @credit_card_details.id, new_token_subscr)\n end\n\n @order_1.update_attributes(number: new_token_1, user_subscription_id: user_subscription_id, subscription_token: new_token_subscr)\n\n # second order\n @order_2 = place_order_registration(sub_id, SECOND_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, plan_price)\n new_token_2 = @order_2.get_unique_ID\n @order_2.update_attributes(number: new_token_2, subscription_token: new_token_subscr, user_subscription_id: user_subscription_id)\n\n # third order\n @order_3 = place_order_registration(sub_id, THIRD_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, plan_price)\n new_token_3 = @order_3.get_unique_ID\n @order_3.update_attributes(number: new_token_3, subscription_token: new_token_subscr, user_subscription_id: user_subscription_id)\n\n #creating new line-items-default\n\n create_new_line_items(sub_id,@order_1)\n create_new_line_items(sub_id,@order_2)\n create_new_line_items(sub_id,@order_3)\n\n @order_1.update_total_and_item_total #reupdated total & item_total as its changed by is_pushed = 1 , in push notification method.\n @order_2.update_total_and_item_total\n @order_3.update_total_and_item_total\n ######################################\n\n sign_in(:spree_user, @user)\n session[:spree_user_signup] = true\n #MyMailer.notify_user_after_registration(current_user).deliver\n result = signup_mail_params(@order_1)\n VeganMailer.signup_email(result).deliver\n\n result = vendor_email_params(@order_1)\n VeganMailer.vendor_email(result).deliver\n\n render js: %(window.location.href='/spree/orders/snack_queue') and return\n\n else\n @user.destroy\n @user.remove_errormessages_added_by_spree\n @user.errors.add(:creditcards,\"invalid credit card details\")\n end\n else\n \n end\n end\n end\n\n end", "def create\n \n @customer = Customer.new(customer_params)\n @user = current_user\n respond_to do |format|\n if @customer.save\n @customer.update!(user_id: @user.id)\n format.html { redirect_to customers_path, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #create a random key to identify the new customer\n customer_id = Array.new(8/2) { rand(256) }.pack('C*').unpack('H*').first\n\n # The APP_CONFIG value comes from app_config.yml in the Config dir\n @subscription = Subscription.new(params[:subscription])\n\n #maybe this should be in the model?\n @subscription.plan_id = APP_CONFIG[:subscription_token]\n @subscription.customer_id = customer_id\n @subscription.sub_id = \"#{Time.now.strftime(\"%Y%m%d%H%M%s\")}\"\n # First try to create the customer in BrainTree's vault, if successful then save the subscription record.\n # I'd like this process improved to so it's using error handling instead of flash messages\n @result = Braintree::Customer.create(\n :id => customer_id,\n :first_name => params[:subscription][\"billing_first_name\"],\n :last_name => params[:subscription][\"billing_last_name\"],\n :company => params[:subscription][\"billing_company\"],\n :credit_card => {\n :cardholder_name => params[:subscription][\"credit_card_name\"],\n :number => params[:subscription][\"credit_card_number\"],\n :token => @subscription.sub_id,\n :expiration_date => \"#{params[:subscription][\"credit_card_month\"]}/#{params[:subscription][\"credit_card_year\"]}\",\n :cvv => params[:subscription][\"credit_card_cvv_code\"],\n :billing_address => {\n :street_address => params[:subscription][\"billing_address\"],\n :extended_address =>params[:subscription][\"billing_address2\"],\n :locality => params[:subscription][\"billing_city\"],\n :region => params[:subscription][\"billing_state\"],\n :postal_code => params[:subscription][\"billing_zipcode\"],\n :country_code_numeric => params[:subscription][\"billing_country\"]\n }\n }\n )\n if @result.success?\n if create_subscription( @subscription.sub_id, params[:subscription][\"fee\"])\n @merchant = Merchant.find(session[:merchant_id])\n @merchant.update_attributes(:customer_id => customer_id)\n # I removed all the respond_to code, I don't think I'll be using XML formating, shoudl all the respond_do code be removed?\n if @subscription.save\n redirect_to(:controller => 'subscriptions', :action => 'index', :notice => 'Subscription was successfully created.')\n else\n render :action => \"new\"\n end\n else\n render :action => \"new\"\n end\n else\n #was not able to create the customer, display error messages\n render :action => \"new\"\n end\n end", "def purchase_events_existing_card\n\n @number = params[:peu][:number]\n coupon = params[:peu][:coupon] # this is the coupon name/code, a string\n cost = params[:peu][:cost] #in cents\n\n # retrieve stripe customer object (downstream from user having a customer_id)\n c = Stripe::Customer.retrieve(current_user.customer_id)\n \n if existing_customer_purchase_events_existing_card(@number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n #if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n #end \n flash[:success] = \"Thank you! You have purchased an additional #{@number} event pages.\"\n redirect_to current_user\n else #errors in processing the card shouldn't usually happen, because the card was originally ok. Can test by using stripes card number that binds to customer but does not charge correctly.\n # YES THE REDIRECT WORKS WITH THAT STRIPE TESTING NUMBER\n redirect_to existing_user_purchase_path\n end \n\n\n \nend", "def create\n @return_path = new_subscription_path\n\n redirect_to subscriptions_path and return unless current_plan\n render 'new' and return unless current_user\n\n current_user.update_stripe_card!(params[:stripe_card_token]) unless params[:stripe_card_token].blank?\n current_user.apply_coupon!(current_coupon.id) if current_coupon\n current_user.set_offer_and_subscription_plan!(current_offer, current_plan) if current_offer && current_plan\n\n unless current_user.stripe_subscription_active?\n Rails.logger.debug \"current_user.stripe_subscription_active? is false\"\n render 'new' and return\n end\n\n Resque.enqueue(UpdateMailChimp, current_user.email, :subscriber)\n\n Rails.logger.info \"Subscription updated.\"\n \n clear_subscription_data\n process_new_subscription_analytics\n\n redirect_to subscription_confirm_path\n\n rescue Stripe::StripeError => e\n error = e.json_body[:error]\n\n # this POST happens twice. The first time through, the user hasn't entered any form data and we don't want to show bogus errors.\n unless params[:stripe_customer_id].nil? # first pass through won't include stripe_customer_id as a param\n Rails.logger.error error[:message]\n flash.alert = error[:message]\n end\n \n render 'new'\n\n rescue => e\n Rails.logger.error e.message\n flash.alert = \"M2222\"#e.message\n\n render 'new'\n\n end", "def thank_you\n user = session[:user]\n user.zip = params[:zip]\n \n start_date = Date.today\n start_date += 61\n \n response = create_autorrecuring_subscription(start_date, user, params[:card_number], params[:month], params[:year], \n params[:cvc], params[:card_type], params[:city], params[:state],\n params[:billing_address_1], params[:billing_address_2])\n if response.success?\n session[:errors] = nil\n session[:user] = nil\n user.arb_subscription_id = response.subscription_id\n user.arb_status = AuthorizeNet::ARB::Subscription::Status::ACTIVE\n user.billing_information_id = user.add_billing_information(params[:fullname], params[:billing_address_1] ,\n params[:billing_address_2], params[:city], params[:state],\n params[:zip]).id\n user.save\n else\n puts \"Failed to make purchase. \" + response.response_reason_code + \" - \" + response.response_reason_text\n user.errors.clear()\n user.errors.add(:transaction, response.response_reason_text)\n session[:errors] = user.errors\n redirect_to admin_signup_step3_path\n end \n\n \n end", "def save_with_stripe(params)\n account_valid = true\n begin\n\n if (account_valid = is_valid(params))\n # Create a stripe customer\n Stripe.api_key = ENV['API_KEY']\n\n customer = Stripe::Customer.create(\n :description => \"#{ACCOUNT_NAME} customer account.\",\n :card => params[:account][:stripe_cc_token],\n :email => params[:cardholder_email]\n )\n\n load_customer_info(customer)\n self.status = ACTIVE\n\n # Attempt to save the record\n account_valid = self.save ? true : false\n end\n\n rescue Stripe::StripeError => stripe_error\n account_valid = stripe_error_handler(stripe_error, INACTIVE)\n end\n\n return account_valid\n end", "def new_customer\n @org = Organisation.find_by(permalink: params[:organisation_id])\n @customer = Customer.new\n\n Stripe.api_key = ENV[\"STRIPE_SECRET_KEY\"]\n end", "def create_as_stripe_customer(options = {})\n raise Reji::CustomerAlreadyCreatedError.exists(self) if stripe_id?\n\n options[:email] = stripe_email if !options.key?('email') && stripe_email\n\n # Here we will create the customer instance on Stripe and store the ID of the\n # user from Stripe. This ID will correspond with the Stripe user instances\n # and allow us to retrieve users from Stripe later when we need to work.\n customer = Stripe::Customer.create(\n options, stripe_options\n )\n\n update({ stripe_id: customer.id })\n\n customer\n end", "def create_customer(customer_data)\n ::Stripe::Customer.create(customer_data)\n end", "def purchase_events_new_card\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost] #in cents\n\n if update_card_and_purchase(token, @number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n flash[:success] = \"Thank you! You have purchased an additional #{@number} event pages.\"\n redirect_to current_user\n else\n redirect_to existing_user_purchase_path\n end \nend", "def save_and_charge\n # Check our data if it's valid\n if self.valid?\n #If if it's valid, charge\n Stripe::Charge.create(amount: self.total_price, currency: \"USD\", source: self.stripe_token, description: \"Order for #{self.email}\")\n\n self.save\n\n else\n false # Not valid, show error\n end\n\n rescue Stripe::CardError => e\n # This is coming from stripe documentation\n @message = e.json_body[:error][:message]\n\n # Beside validation errors, we can create our own errors\n self.errors.add(:stripe_token, @message)\n\n # Return false to our controller\n false\n\n end", "def managed\n connector = StripeManaged.new(current_customer)\n account = connector.create_account!(\n params[:country], params[:tos] == 'on', request.remote_ip\n )\n\n if account\n flash[:notice] = \"Managed StripeAccount account created! <a target='_blank' rel='platform-account' href='https://dashboard.stripe.com/test/applications/users/#{account.id}'>View in dashboard &raquo;</a>\"\n else\n flash[:alert] = 'Unable to create StripeAccount account!'\n end\n redirect_to customer_path(current_customer)\n end", "def pay\n # Find the user to pay.\n user = User.find( params[:id] )\n\n # Charge $10.\n amount = 1000\n # Calculate the fee amount that goes to the application.\n fee = (amount * Rails.application.secrets.fee_percentage).to_i\n\n begin\n charge = Stripe::Charge.create(\n {\n amount: amount,\n currency: user.currency,\n card: params[:token],\n description: \"Test Charge via Stripe Connect\",\n application_fee: fee\n },\n\n # Use the user-to-be-paid's access token\n # to make the charge.\n user.secret_key\n )\n flash[:notice] = \"Charged successfully! <a target='_blank' rel='connected-account' href='https://dashboard.stripe.com/test/payments/#{charge.id}'>View in dashboard &raquo;</a>\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to user_path( user )\n end", "def newcustomercreate_trial\n@user = User.new(params[:user]) #replaced code below so when hit this url directly, don't get a nil error\n\n # @user = User.new\n # @user.email = params[:user][:email]\n # @user.password=params[:user][:password]\n # @user.password_confirmation=params[:user][:password_confirmation]\n # @user.first_name = params[:user][:first_name]\n # @user.last_name = params[:user][:last_name]\n # @user.company = params[:user][:company]\n # @user.event_type = params[:user][:event_type]\n #this will pass in the @plan value into the stripenewcustomer_purchase page via the render 'stripenewcustomer_purchase' below (changed this from redirect, wasn't sure that would work)\n\n\n if @user.save\n\n sign_in @user\n # since user is new, won't have any PO with user_id; might have floating PO's with this email for some event, but those would be caught later when customer signs in for those events\n # when creates an event, can invite himself (at that email) to create a PO for that event for himself\n flash[:success] = \"Welcome to VoiceGems! Please contact us with any questions about how to make the most of this service.\"\n \n # render 'stripe_vgtrial' # i think @number defined in this action is being used on the stripenewcustomer_purchase rendering\n # redirect_to welcome_path # a welcome page to explain to them what to do\n create_vg_trial_without_stripe \n redirect_to welcome_path\n else\n\n if User.find_by_email(@user.email)#if the user already exists, tell them to try logging in to the right\n flash[:error] = \"You are already registered on our site. Please sign in to purchase event pages under your Accounts tab.\"\n redirect_to root_path\n else\n render action: 'newcustomer_trial'\n end \n\n end \n\nend", "def create\n if user_params[:password_confirmation]\n user = User.create!(user_params)\n\n session[:user_id] = user.id\n session[:expiration_time] = Time.now + 6*60*60 # 6 hours until expiration\n \n response = { message: Message.account_created }\n json_response(response, :created)\n else\n response = { message: Message.password_confirmation_missing}\n json_response(response, :not_acceptable)\n end\n end", "def create\n\n\t\t# Get the credit card details submitted by the form\n\t\ttoken = params[:stripeToken]\n\n\t\t# Amount in cents\n\t\t@amount = 500\n\n\t\tcustomer = Stripe::Customer.create(\n\t\t\t:email => 'example@stripe.com',\n\t\t\t:card => params[:stripeToken]\n\t\t)\n\n\t\t# Create the charge on Stripe's servers - this will charge the user's card\n\t\tcharge = Stripe::Charge.create(\n\t\t\t:customer => customer.id,\n\t\t\t:amount => @amount,\n\t\t\t:description => 'Rails Stripe customer',\n\t\t\t:currency => 'usd',\n\t\t\t:card => token\n\t\t)\n\n\trescue Stripe::CardError => e\n\t flash[:error] = e.message\n\t redirect_to charges_path\n\tend", "def create\n @credit_card = current_user.credit_cards.new(credit_card_params)\n\n current_user._create_stripe_customer_id\n # We want to retrieve the customer from Stripe\n # Then add the new card to the customer\n begin\n customer = Stripe::Customer.retrieve(current_user.stripe_customer_id)\n card = customer.sources.create(:source => params[:stripeToken])\n rescue Stripe::CardError => e\n # Since it's a decline, Stripe::CardError will be caught\n body = e.json_body\n err = body[:error][:message]\n redirect_to :back, notice: \"#{err}\"\n else\n customer.default_source = card.id\n customer.save\n @credit_card.stripe_card_id = card.id\n @credit_card.last_four = card.last4\n\n if @credit_card.save\n unless session[:pending_session_counselor_id].present?\n redirect_to user_dashboard_path, notice: 'Credit card was successfully created.'\n else\n redirect_to new_counseling_session_path, notice: 'You are almost done. Now you can finalize your session.'\n end\n else\n render :new\n end\n end\n end", "def create(params)\n If(Hr.find(params[:user_id])) do |hr|\n customer = Stripe::Customer.create(source: params[:stripe][:token])\n hr.update_attribute(:stripe_id, customer.id)\n hr.update_attribute(:last_four_digits, customer.sources.data.first.last4)\n end\n end", "def new_customer_registration(user, token)\n @current_user = user\n @token = token\n mail(to: user[:email], subject: 'Registration Successful – Please Verify Your Email Address')\n end", "def purchase_events_existing_card_couple\n\n @number = params[:peu][:number]\n coupon = params[:peu][:coupon] # this is the coupon name/code, a string\n cost = params[:peu][:cost]\n\n # retrieve stripe customer object (downstream from user having a customer_id)\n c = Stripe::Customer.retrieve(current_user.customer_id)\n \n if existing_customer_purchase_events_existing_card(@number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n #if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n #end \n flash[:success] = \"Thank you! You have purchased #{@number} VoiceGems pages.\"\n redirect_to current_user\n else #errors in processing the card shouldn't usually happen, because the card was originally ok. Can test by using stripes card number that binds to customer but does not charge correctly.\n # YES THE REDIRECT WORKS WITH THAT STRIPE TESTING NUMBER\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\n end \n\nend", "def create_charge\n customer = Stripe::Customer.create(\n :email => params[:stripeEmail],\n :card => params[:stripeToken]\n )\n\n charge = Stripe::Charge.create(\n :customer => customer.id,\n :amount => Deal.find(current_consumer.orders.last[:deal_id]).price.to_i * 100,\n :description => 'Prlayvous Ticket',\n :currency => 'usd'\n )\n\n #After paying with Stripe, consumers are prompt to confirm their shipping address.\n redirect_to edit_consumer_order_path(current_consumer, @order)\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to charges_path\n end", "def activate\n \n # Subscription vitals\n customer_ref = params[:SubscriptionReferrer]\n plan_ref = params[:ProductPath].sub(\"/\", \"\")\n subscription_ref = params[:SubscriptionReference]\n \n # subscription info\n status = params[:SubscriptionStatus].to_s.downcase.strip\n end_date = params[:SubscriptionEndDate]\n next_period_date = params[:SubscriptionNextPeriodDate]\n status_reason = params[:SubscriptionStatusReason]\n total_price = params[:SubscriptionTotalPriceValue]\n \n user = User.find(customer_ref)\n plan = Plan.find_by_fastspring_reference(plan_ref)\n \n raise \"Received subscription activation but the subscription status is not 'active', but is rather: '#{status}'\" unless status == \"active\"\n raise \"Received subscription activation for #{user.id} but couldn't find a matching plan: #{plan_ref}\" unless plan\n raise \"Received subscription activation for #{user.id} but they already have an active subscription with reference #{user.active_subscription.reference}\" if user.subscribed?\n\n Subscription.create!(\n user: user,\n reference: subscription_ref,\n end_date: end_date,\n next_period_date: next_period_date,\n status: status,\n status_reason: status_reason,\n total_price: total_price,\n currency: params[:SubscriptionTotalPriceCurrency]\n )\n user.plan = plan\n user.save!\n\n render nothing: true, status: 200\n end", "def create\n #to avoid unwanted/unsafe requests we replace params[:user]\n @user = User.new(user_params)\n if @user.save\n # =WANT THEM TO ACTIVATE ACCOUNT FIRST\n @user.send_activation_email\n flash[:info] = \"Please check your email to activate your account.\"\n redirect_to root_url\n #logs in a user after they make account\n # log_in(@user)\n # flash[:success] = \"Welcome to Twitter Clone!\"\n #redirect_to @user\n else\n render 'new'\n end\n end", "def create\n @customer = User.new(customer_params)\n @customer.authority = 'customer'\n respond_to do |format|\n if @customer.save\n if !current_user\n log_in @customer, :customer\n end\n format.html {redirect_to customer_path(@customer), notice: 'Customer was successfully created.'}\n format.json {render :show, status: :created, location: @customer}\n else\n format.html {render :new}\n format.json {render json: @customer.errors, status: :unprocessable_entity}\n end\n end\n end", "def stripe_customer_subscription_created(event, req)\n stripe_customer_subscription_updated(event, req)\n end", "def create\n\n @charge = Charge.new(charge_params)\n \n customer = StripeTool.create_customer(email: params[:stripeEmail], \n stripe_token: params[:stripeToken])\n\n charge = StripeTool.create_charge(customer_id: customer.id, \n amount: (@charge.amount*100).to_i,\n description: @charge.topic)\n\n @charge.stripe_id = customer.id\n \n\n respond_to do |format|\n if @charge.save\n if @charge.owner_type == \"User\"\n format.html { redirect_to user_path(:id => @charge.owner_id, :topic => \"personen_charges\"), notice: (I18n.t :thxpayment) }\n end\n if @charge.owner_type == \"Company\"\n format.html { redirect_to company_path(:id => @charge.owner_id, :topic => \"institutionen_charges\"), notice: 'Charge was successfully created.' }\n end\n format.json { render :show, status: :created, location: @charge }\n else\n format.html { render :new }\n format.json { render json: @charge.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to user_path(:id => @charge.owner_id, :topic => \"personen_charges\"), notice: (:I18n.t :nopayment)\n \n end", "def purchase_events_new_card_couple\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost]\n\n if update_card_and_purchase(token, @number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n flash[:success] = \"Thank you! You have purchased #{@number} VoiceGems Pages.\"\n redirect_to current_user\n else\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\n end \nend", "def create_user_account\n User.create!(email: self.email, password: self.customer)\n # user = User.new do |u|\n # u.email = email\n # u.password = customer\n # u.save\n # end\n end", "def post_billing(req)\n with_stripe_error_handlers do\n customer = Stripe::Customer.retrieve(@dealership.customer_id)\n customer.card = posted['stripeToken']\n customer.save\n req.session['billing_flash_msg'] = \"Card updated successfully.\"\n redirect \"/admin/#{@dealership.slug}/billing\"\n end\n end", "def pay\n @card = Creditcard.new(creditcard_params)\n\n user = current_user\n\n if @card.valid?\n result = Creditcard.create_only_creditcard_over_braintree(user.braintree_customer_id, @card)\n @braintree_cc_return = result.success? ? result.credit_card : nil\n end\n\n\n if @braintree_cc_return.present?\n @card.save\n @card.update_attributes(user_id: user.id)\n @card = Creditcard.update_creditcard(@braintree_cc_return, user.id)\n end\n\n end", "def create\n if params[:type] == StripePaymentGatewayProfile::Events::SUBSCRIPTION_UPDATED\n\n # hackity mchacks a lot. use a singleton? hmm.\n event = StripePaymentGatewayProfile.new.webhook_event_with_stripe_key(AppConfiguration.get('stripe.secret_key'), params[:id])\n\n if event\n\n subscription = event.data.values[0]\n previous_values = event.data.values[1]\n if event.type == StripePaymentGatewayProfile::Events::SUBSCRIPTION_UPDATED\n profile = StripePaymentGatewayProfile.by_vendor_id(subscription['customer']).first\n if profile && profile.subscribable?\n profile.reload_remote\n if !previous_values['status'].blank? && previous_values['status'] != subscription['status'] && !profile.active_plan?\n profile.payment_gateway_profilable.notify_inactive!\n end\n else\n # Found event, but not the customer record. dismiss the event,\n # but remember in our system that we messed up.\n DetectedError.create(\"Received webhook for customer that we didn't handle: #{subscription.customer}\")\n end\n end\n\n head :ok\n else\n # not existent event\n head :not_found\n end\n else\n\n # this is a trade off. on the one hand, lets attackers identify this end and DOS us. on the other hand,\n # we don't recognize this hook...we don't care.\n # todo: build this stripe key retrieval into the mfe.\n head :ok\n\n end\n end", "def handle_unpaid_customer(customer_subscription)\n\t\tsubscription = Subscription.find_by_stripe_customer_token(customer_subscription.customer)\n\t\tsubscription.status = false\n\t\tsubscription.status_info = customer_subscription.status\n\t\tsubscription.save!\n\n\t\tuser = subscription.user\n\t\tNotifyMailer.delay.account_expired(user)\n\t\tNotifyMailer.delay.update_grapevine_team(user, \"User has been set to UNPAID status\")\n\tend", "def create\n @user = User.find_by_email_and_activated(params[:user][:email], false) # We can only register a user that hasn't been activated yet.\n \n if @user\n # Cases 2 and 3.\n params[:user].delete(:email) # They can't arbitrarily change their email address.\n @user.update_attributes(params[:user])\n else\n # Case 1.\n @user = User.new(params[:user].merge({:perishable_token => \"\"}))\n @user.reset_perishable_token!\n end\n \n # This is true when a user finishes their registration from a link in their email (Case 3),\n # which means we don't need to send an activation link.\n if params[:token] && User.find_using_perishable_token(params[:token], 0) == @user\n activate\n else\n # Cases 1 and 2. \n # Saving without session maintenance to skip\n # auto-login which can't happen here because\n # the user has not yet been activated\n if @user.save_without_session_maintenance\n @user.deliver_activation_instructions\n flash[:notice] = 'Registration successful. Please check your email to activate your account.'\n redirect_to shares_path\n else\n flash[:error] = 'Registration failed. Please try again.'\n redirect_to root_path\n end\n end\n end", "def create\n super do |resource| #super means inherit the 'create' action, but then extend it\n if params[:plan]\n #is there a parameter called param?\n resource.plan_id = params[:plan] #resource means user in this case. So take whatever is in the form and set this users plan to be that plan id\n if(resource.plan_id == 2) #so if the form is coming from the pro form, then don't just save the user. We also wanyt to keep the plan id. run the function that we create called save_with_subscription\n resource.save_with_subscription #write a user created function in the model. So in this case models/user.rb\n #the save is done in the model.\n else\n #otherwise just save as normal devise save\n resource.save\n end\n end\n end\n end", "def create\n @registration = Registration.new(registration_params)\n\n # Amount in cents\n @amount = @registration.subtype == 'team' ? 9000 : 5000\n\n # Disabled for now,\n # customer = Stripe::Customer.create(\n # :email => params[:stripeEmail],\n # :source => params[:stripeToken]\n # )\n #\n # charge = Stripe::Charge.create(\n # :customer => customer.id,\n # :amount => @amount,\n # :description => 'EnergyX Resolve To Row',\n # :currency => 'usd'\n # )\n #\n # @registration.is_paid = true if customer && charge\n # @registration.stripe_customer_id = customer.id\n # @registration.stripe_charge_id = charge.id\n\n respond_to do |format|\n if @registration.save\n format.html { redirect_to @registration, notice: 'We have successfully created your registration! You card HAS NOT BEEN CHARGED. Please Print this page for your records.' }\n format.json { render :show, status: :created, location: @registration }\n else\n format.html { render :new }\n format.json { render json: @registration.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_registration_path(@registration)\n end", "def create\n @purchase = Purchase.new purchase_attributes\n if @purchase.save\n @ok = true\n renewed = Purchase.find_by_id params[:renewed_id]\n if renewed\n renewed.users.each do |u|\n u.purchase_id = @purchase.id\n u.save\n Notification.send_to(\n u.id,\n I18n.t('notifications.account.renewed.title'),\n I18n.t('notifications.account.renewed.message', :expiration_date => TimeConvert.to_string(@purchase.expiration_date)),\n ''\n )\n end\n renewed.expiration_date = Time.zone.now\n renewed.save\n end\n else\n @ok = false\n @errors = @purchase.errors.messages.keys\n @errors << :ssn_code if @errors.include?(:base)\n end\n end", "def change_subscription\n\tbounce_free_account\n\n\t@subs = current_user.subscriptions \n\tif @subs && !@subs.active.blank?\n\t@s = @subs.active.first\n\t@s_year = @s.created_at + 365.days\n\t#@c = Stripe::Customer.retrieve(@s.customer_id)\n\telse #this should not happen - be careful to make sure every customer has a subscription; or at least if they have a \n\t\t# cancel subsciption link, there is an active subscription to be canceled. \n\tredirect_to current_user, notice: 'You have no active subscriptions.'\n\t # return false is this line needed to end the action?\n\tend \n\n\t# users first (oldest) subscription, for displaying free trial information\n\t@firstsub = @subs.first\n\t@firstsub_end = @firstsub.created_at + 14.days\n\n\t#@plan = Plan.find_by_name(@s.plan_id) #this would be better for easily retrieving other associated plan info; but could have just used @s.plan_id for the plan name\n\tif !@s.my_plan_id.nil? # so that @plan isn't nil, which would cause problems in the view \n\t@plan = Plan.find_by_my_plan_id(@s.my_plan_id) # NOTE THAT @PLAN IS THE PLANOBJECT\n\t\t\t\t#see if active subscription has a coupon associated with it\n\t\t\t\tif !@s.coupon.nil? && Coupon.find_by_name(@s.coupon)\n\t\t\t\t\t@coupon = Coupon.find_by_name(@s.coupon)\n\t\t\t\t\t@code = @coupon.name\n\t\t\t\t\t@new_price = @plan.monthly_cost_cents * (100 - @coupon.percent_off)/100\n\t\t\t\telse\n\t\t\t\t\t@coupon = nil \n\t\t\t\t\t@code = nil\n\t\t\t\t\t@new_price = nil \n\t\t\t\tend \n\telse\n\t\t@plan = nil\n\t\t@coupon = nil \n\t\t@code = nil \n\t @new_price = nil \n\tend \n\nend", "def create\n\t\t#Prepare the models\n\t\t@subscription = Subscription.new(\n\t\t\tcampaign_id: @subscribed.active_campaign.id,\n\t\t\tshipping_country: params[:subscription][:shipping_country],\n\t\t\tget_reward: params[:subscription][:get_reward],\n\t\t\tfunding_type: params[:subscription][:funding_type],\n\t\t\tamount: params[:subscription][:amount],\n\t\t\tsubscriber_id: @subscriber.id,\n\t\t\tsubscribed_id: @subscribed.id,\n\t\t\tcurrency: 'usd',\n\t\t\tcampaign_funding_type: @subscribed.active_campaign.funding_type\n\t\t)\n\t\tif params[:subscription][:majorpost_id]\n\t\t\t@subscription.majorpost_id = params[:subscription][:majorpost_id]\n\t\tend\n\t\tif params[:subscription][:upper_limit]\n\t\t\t@subscription.upper_limit = params[:subscription][:upper_limit]\n\t\tend\n\t\tif params[:subscription][:cards_attributes]\n\t\t\tadd_card\n\t\tend\n\t\t#Charge if charge\n\t\tif @subscription.funding_type == 'one_time'\n\t\t\t#Charge the card now\n\t\t\tsubscribe_through_stripe\n\t\telse\n\t\t\t#Do not charge the card\n\t\t\tsubscription_post_payment\n\t\tend\n\trescue Stripe::CardError => e\n\t\t# Since it's a decline, Stripe::CardError will be caught\n\t\tbody = e.json_body\n\t\terr = body[:error]\n\n\t\tputs \"Status is: #{e.http_status}\"\n\t\tputs \"Type is: #{err[:type]}\"\n\t\tputs \"Code is: #{err[:code]}\"\n\t\t# param is '' in this case\n\t\tputs \"Param is: #{err[:param]}\"\n\t\tputs \"Message is: #{err[:message]}\"\n\t\t#Show to the user\n\t\tflash[:error] = \"#{err[:message]}\"\n\t\tredirect_to how_i_pay_user_studio_wallets_path(@subscriber.username)\n\trescue Stripe::RateLimitError => e\n\t\t# Too many requests made to the API too quickly\n\t\tflash[:error] = t('errors.messages.too_many_requests')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::InvalidRequestError => e\n\t\t# Invalid parameters were supplied to Stripe's API\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::AuthenticationError => e\n\t\t# Authentication with Stripe's API failed\n\t\t# (maybe you changed API keys recently)\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::APIConnectionError => e\n\t\t# Network communication with Stripe failed\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::StripeError => e\n\t\t# Display a very generic error to the user, and maybe send\n\t\t# yourself an email\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue \n\t\t# General rescue\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\tend", "def create\n @cart = Cart.find(params[:cart_id].to_i)\n token = params[:stripeToken]\n #payment old changes\n # if @cart.instant_total_price_cents != 0\n # begin\n # puts \"Processing payment\"\n # if params[:payment_method].blank? or params[:payment_method] == \"card\"\n # sub = Subscription.find_by(user_id: current_user.id, stripe_customer_token: token)\n # if sub.nil?\n # last4 = params[:last4]\n # exp_year = params[:exp_year]\n # exp_month = params[:exp_month]\n # subscription = Subscription.new(stripe_customer_token: token, user_id: current_user.id,last4: last4,exp_year: exp_year,exp_month: exp_month)\n # new_sub = Order.save_with_payment(params[:email],token,current_user.name,@cart.instant_total_price_cents)\n # subscription.stripe_user_id = new_sub\n # subscription.save\n # else\n # Order.payment_only(current_user.name,@cart.instant_total_price_cents,sub.stripe_user_id)\n # end\n # else\n # account = current_user.bank_accounts.first\n # if account.stripe_user_id.nil?\n # account.stripe_user_id = Order.save_with_payment(params[:email],account.stripe_customer_token,current_user.name,@cart.instant_total_price_cents)\n # account.save\n # else\n # Order.payment_only(current_user.name,@cart.instant_total_price_cents,account.stripe_user_id)\n # end\n # end\n # rescue => e\n # puts \"Payment failed\"\n # puts e\n # ExceptionNotifier.notify_exception e\n # render json: {\"error\":\"Payment was unsuccessful\"}, status: :unprocessable_entity and return\n # end\n # end\n\n address_type = params[:address_type].nil? ? \"user\" : params[:address_type]\n if params[:old_address_id].blank?\n current_user.addresses.create!(first_name: params[:first_name], last_name: params[:last_name], mobile: params[:mobile], line_1: params[:line_1], line_2: params[:line_2], line_3: params[:line_3], city: params[:city], state: params[:state], address_type: address_type, pincode: params[:pincode].to_i, name: \"shipping\")\n else\n puts \"Address found. Updating it\"\n address = Address.find params[:old_address_id]\n address.updated_at = DateTime.now\n address.save\n end\n\n CartItem.where(cart: @cart).group_by(&:provider).each do |provider,cart_items_all|\n cart_items_instant = cart_items_all.select {|ci| ci.product.storefront_option == true}\n cart_items_invoice = cart_items_all.select {|ci| ci.product.storefront_option == false}\n [cart_items_instant,cart_items_invoice].each do |cart_items|\n if cart_items.length > 0\n @order = Order.new\n @order.first_name = params[:first_name]\n @order.last_name = params[:last_name]\n @order.mobile_number = params[:mobile_number]\n @order.email = params[:email]\n @order.order_date = DateTime.now\n @order.total_price_cents = 0\n @order.user = current_user\n @order.save!\n # if cart_items.first.product.storefront_option\n # @order.status = :unpaid\n # @order.save!\n # end\n\n cart_items.each do |cart_item|\n @order.total_price_cents += cart_item.price_cents * cart_item.quantity\n order_item = @order.order_items.new(price_cents: cart_item.price_cents, product: cart_item.product, quantity: cart_item.quantity,provider: cart_item.provider)\n cart_item.destroy\n end\n\n @order.recalcuate_order_total\n @order.addresses.create!(first_name: params[:first_name], last_name: params[:last_name], mobile: params[:mobile], line_1: params[:line_1], line_2: params[:line_2], line_3: params[:line_3], city: params[:city], state: params[:state], address_type: address_type, pincode: params[:pincode].to_i, name: \"shipping\")\n SupplierMailer.order_email(@order).deliver_later\n end\n end\n end\n\n respond_to do |format|\n format.html { render json: @order.id, status: :ok }\n format.json { render json: @order.id, status: :ok}\n end\n end" ]
[ "0.8166746", "0.7665318", "0.7586758", "0.75683373", "0.75390834", "0.7518053", "0.74716955", "0.7392793", "0.7294338", "0.72191966", "0.72115946", "0.7128112", "0.712692", "0.70379615", "0.7009483", "0.69722223", "0.69667715", "0.69576347", "0.68969506", "0.6877924", "0.68738455", "0.6838514", "0.6808635", "0.68085533", "0.6794398", "0.67791283", "0.6754727", "0.6663394", "0.6660503", "0.66594195", "0.66379404", "0.6633256", "0.6625867", "0.6624655", "0.66234833", "0.66179913", "0.6612186", "0.66033965", "0.660339", "0.65842515", "0.6571633", "0.6565765", "0.6551454", "0.6551", "0.65377724", "0.6517199", "0.65123665", "0.65093195", "0.64928615", "0.6486056", "0.6476452", "0.64489985", "0.64424413", "0.64421034", "0.6438776", "0.6414931", "0.6403593", "0.63806343", "0.6379774", "0.6367634", "0.6363081", "0.6326799", "0.6320511", "0.63159084", "0.6310064", "0.6306572", "0.6304497", "0.629161", "0.6284527", "0.6279491", "0.6274226", "0.6261975", "0.6256208", "0.6247529", "0.62385696", "0.6223252", "0.6216851", "0.62160146", "0.62079746", "0.6206411", "0.620528", "0.6201498", "0.62009394", "0.61999726", "0.6190837", "0.6184518", "0.6182206", "0.6181689", "0.61795604", "0.6172749", "0.616085", "0.6141751", "0.61415803", "0.61397487", "0.6138544", "0.6137542", "0.6135", "0.61321133", "0.61263144", "0.61133295" ]
0.7624558
2
The default security delegates to ActiveRecordPermissions. You may override the method to customize.
def batch_create_authorized?(record = nil) authorized_for?(:crud_type => :create) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n if current_user.admin?\n # Role management\n # don't allow :destroy, :edit, :create\n # - destroy adds a 'delete' button that\n # - could be clicked accidentally\n # - would be very infrequently used (if ever)\n # - implications of edit are unclear for associated actions\n # - create is meaningless without associating actions which happens in code.\n can [:read, :add_user, :remove_user], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end", "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role if current_user.admin?\n\n can [:fa_overview], ActiveFedora::Base\n can [:advanced], ActiveFedora::Base\n can [:streets], ActiveFedora::Base\n can [:pdf_page], ActiveFedora::Base\n can [:pdf_page_metadata], ActiveFedora::Base\n can [:bookreader], ActiveFedora::Base\n can [:imageviewer], ActiveFedora::Base\n can [:streetsviewer], ActiveFedora::Base\n can [:fa_series], ActiveFedora::Base\n can [:audio_transcriptonly], ActiveFedora::Base\n can [:video_transcriptonly], ActiveFedora::Base\n end", "def custom_permissions\n discover_permissions\n export_sets_permissions\n batches_permissions\n preservation_events_permissions\n end", "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end", "def custom_permissions\n if current_user.admin?\n can :manage, :all\n end\n end", "def custom_permissions\n can [:file_status, :stage, :unstage], FileSet\n\n if current_user.ingest_from_external_sources?\n end\n\n if current_user.manage_users?\n can [:show, :add_user, :remove_user, :index], Role\n end\n\n if current_user.manage_roles?\n can [:create, :show, :index, :edit, :update, :destroy], Role\n end\n\n if current_user.run_fixity_checks?\n can [:fixity], FileSet\n end\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end", "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n # Admin user can create works of all work types\n can :create, curation_concerns_models\n end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end", "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n# if current_user.contentadmin?\n# can [:create, :destroy], GwWork\n# can [:create, :destroy], GwEtd\n# end\n end", "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\nif current_user.admin?\n\t can [:create, :show, :add_user, :remove_user, :index], Role\n\t end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n\n\n end", "def custom_permissions\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n can [:create], Collection\n can [:discover], Hydra::AccessControls::Embargo\n can [:discover], Hydra::AccessControls::Lease\n can [:create], [ CurationConcerns.config.curation_concerns ]\n can [:destroy], ActiveFedora::Base\n can [:permissions], [ CurationConcerns.config.curation_concerns ]\n end\n\n # Limits deleting objects to a the admin user\n #\n #if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n #end\n\n if current_user.has_role?('collection.manager')\n # can [:create, :show, :index, :edit, :update, :destroy], Collection\n can [:create], Collection\n end\n\n if current_user.has_role?('collection.depositor') or current_user.has_group_role?('collection.depositor')\n # can [:create, :show, :index, :edit, :update, :destroy], [ CurationConcerns.configuration.curation_concerns ]\n can [:create], [ CurationConcerns.config.curation_concerns ]\n # can [:show], Collection\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end", "def custom_permissions\n alias_action :show, :manifest, to: :read\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\n roles.each do |role|\n send \"#{role}_permissions\" if current_user.send \"#{role}?\"\n end\n end", "def custom_permissions\n alias_action :show, :manifest, to: :read\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\n roles.each do |role|\n send \"#{role}_permissions\" if current_user.send \"#{role}?\"\n end\n end", "def custom_permissions # rubocop:disable Metrics/CyclomaticComplexity\n can :read, ApplicationPresenter, &:can_read?\n can :read, UsersPresenter, &:can_read?\n can :read, UserPresenter, &:can_read?\n can :read, RolesPresenter, &:can_read?\n can :read, RolePresenter, &:can_read?\n\n can :read, Press\n\n grant_press_analyst_abiltites if press_analyst?\n grant_press_editor_abilities if press_editor?\n grant_press_admin_abilities if platform_admin? || press_admin?\n grant_platform_admin_abilities if platform_admin?\n end", "def load_permissions\n authorize! :manage, :all\n end", "def custom_permissions\n #Collection Manager Permissions\n #Higher power than edit user...[Dont want edit users to be able to DELETE a COLLECTION??, (Delete a DO?)]\n if current_user.applicable_policy?(SETTING_POLICY_COLLECTION_MANAGER)\n #Marked as being able to :manage_collection\n can :manage_collection_flag, :all\n can :create, [DRI::Batch, DRI::GenericFile]\n end\n\n\n #Admin Permissions\n if current_user.applicable_policy?(SETTING_POLICY_ADMIN)\n can :admin_flag, :all\n #Disabled for now..\n can :manage, :all\n end\n\n #Create_do flag (alias for :edit collection)\n can :create_do, String do |pid|\n test_create(pid)\n end\n\n can :create_do, DRI::Batch do |collection|\n test_create(collection)\n end\n end", "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n\n if user_groups.include? ['all_project_writers']\n can [:create], PulStore::Base\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end\n\n if user_groups.include? ['lae_project_writers']\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end \n\n if user_groups.include? ['all_project_writers']\n can [:destroy], PulStore::Base\n end\n\n if user_groups.include? ['lae_project_readers', 'all_project_readers' ]\n can [:show], PulStore::Base\n end\n end", "def custom_permissions\n if admin?\n can [:confirm_delete], ActiveFedora::Base\n can [:allow_downloads, :prevent_downloads], AdminSet\n\n can :manage, Spotlight::HomePage\n can :manage, Spotlight::Exhibit\n end\n\n can :read, Spotlight::HomePage\n can :read, Spotlight::Exhibit\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end", "def paranoid_permissions\n true\n end", "def custom_permissions\n if user_groups.include?(\"admin\")\n can :manage, :all\n end\n end", "def standard_authorized_user_rights\n public_access + protected_access \n end", "def custom_permissions\n can [:create], Account\n end", "def custom_permissions\n can [:create], Account\n end", "def load_permissions \n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]} \n end", "def set_permissions\n self.permissions ||= \"guest\"\n end", "def smart?; self.permission_level = 2; end", "def permission_set\n if attributes[\"InheritedSecurity\"]\n supersite.permission_set\n else\n PermissionSet.new(self)\n end\n end", "def write_permission_check(*args)\n # Don't prevent writes if creating a new object (anyone should be able to do this)\n return unless self.exist?\n\n if LinkedData.settings.enable_security\n user = nil\n options_hash = {}\n args.each {|e| options_hash.merge!(e) if e.is_a?(Hash)}\n user = options_hash[:user]\n\n # Allow a passed option to short-cut the security process\n return if options_hash[:override_security]\n\n user ||= Thread.current[:remote_user]\n\n reference_object = self\n\n # If we have a modified object, we should do the security check\n # on the original. This allows a user to change the ownsership of\n # an object without having to add the owner and have the new owner\n # remove the original owner.\n reference_object = self.class.find(self.id).first if self.modified?\n\n # Allow everyone to write\n return if reference_object.access_for_all?\n\n # Load attributes needed by security\n if reference_object.access_control_load?\n # Only load ones that aren't loaded so we don't overwrite changes\n not_loaded = []\n reference_object.access_control_load_attrs.each do |attr|\n not_loaded << attr unless reference_object.loaded_attributes.include?(attr)\n end\n reference_object.bring(*not_loaded) unless not_loaded.empty?\n end\n\n writable = reference_object.writable?(user)\n raise LinkedData::Security::WriteAccessDeniedError, \"Write access denied: #{reference_object.id}\" unless writable\n end\n end", "def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end", "def load_permissions\n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\n end", "def load_permissions\n \n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\n end", "def has_permission?\n return true if administrator?\n \n # Load the Model based on the controller name\n klass = self.controller_name.classify.constantize\n \n # Load the possible parent requested\n @parents = (klass.has_parent?) ? get_parents_from_request_params(klass, params) : nil\n \n # Load the resource requested\n if params[:id]\n if [\"index\", \"destroy\", \"update\"].include?(params[:action]) && klass.respond_to?(:in_set)\n @resource = klass.in_set(params[:id])\n @resource = @resource.first if @resource.size == 1\n else\n @resource = klass.find(params[:id])\n end\n end\n \n # Let's let the Model decide what is acceptable\n # NOTE: It is still the concrete controller's job to filter inaccessible resources (accessed via the index)!\n # This presumably happens in the with_parent named scope\n \n authorized = case params[:action]\n when \"edit\", \"update\"\n if !@resource.is_a?(Array)\n return @resource.updatable_by?(current_user, @parents) # this is 'returned' to authorized\n end\n \n verify_set_accessablility(@resource, :updatable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for update.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"destroy\" \n if !@resource.is_a?(Array)\n return @resource.deletable_by?(current_user, @parents)\n end\n \n verify_set_accessablility(@resource, :deletable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for deletion.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"index\" then klass.indexable_by?(current_user, @parents)\n when \"new\", \"create\" then klass.creatable_by?(current_user, @parents)\n when \"show\" then @resource.readable_by?(current_user, @parents)\n else check_non_restful_route(current_user, klass, @resource, @parents)\n end\n \n permission_denied unless authorized\n \n #rescue NoMethodError => e\n # Misconfiguration: A RESTful_ACL specific method is missing.\n #raise_error(klass, e)\n #rescue\n # Failsafe: If any funny business is going on, log and redirect\n #routing_error\n #end\n end", "def permits_write_access_for(user)\n end", "def set_default_permissions!\n # Always allow to read the id\n let :read, :id\n # These shouldn't change after the first save.\n let :write, [ :id, :created_at ], :if => :new?\n # These can always change.\n let :write, :updated_at\n end", "def permitted?(model_name, requested_flags = 0)\n return false if self.kind != Kind::ROLE\n return true if admin?\n\n p = self.model_permissions.find_by_model(model_name)\n if requested_flags == 0\n p\n else\n p && p.permitted?(requested_flags)\n end\n end", "def my_permissions\n @my_permissions ||= self.roles.map {|r| r.permissions.map {|p| p.name}}.flatten.freeze\n end", "def permissions_policy(&block); end", "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n # TODO: This area looks like it needs to be refactored.\n\n if current_user.admin?\n editor_abilities\n upload_abilities\n publish_abilities\n roles_abilities\n hard_delete_abilities\n import_admin_abilities\n user_abilities\n group_abilities\n can [:create, :destroy, :update], FeaturedWork\n can [:manage], Hydra::Admin::Collection\n\n can :create, TinymceAsset\n can [:create, :update], ContentBlock\n can :read, ContentBlock\n can :characterize, GenericFile\n end\n\n\n if current_user.manager?\n upload_abilities\n publish_abilities\n roles_abilities\n import_user_abilities\n can [:manage], Hydra::Admin::Collection do |admin_set|\n # Can manage admin sets within their assigned unit.\n current_user.osul_groups.include? admin_set.unit_group\n end\n can [:manage], Osul::Group do |group|\n # Can manage the groups the user is in or the groups of the units a user is assigned to.\n current_user.osul_groups.include? group or current_user.osul_groups.include? group.unit\n end\n can [:create], Osul::Group\n can [:create, :destroy, :update], FeaturedWork\n end\n\n if current_user.data_entry?\n upload_abilities\n publish_abilities\n no_admin_set_abilities\n end\n\n if current_user.data_entry_student?\n upload_abilities\n no_admin_set_abilities\n end\n\n unless current_user.public?\n can :view_full, GenericFile\n end\n\n if current_user.role.nil?\n no_file_abilities\n no_admin_set_abilities\n end\n end", "def build_permissions(perms, other)\n perms.permits! :read\n perms.permits! :write if self == other\n end", "def permissions\n @resource_permissions\n end", "def admin_permissions\n can [:manage], :all\n end", "def admin_permissions\n can [:manage], :all\n end", "def mass_assignment_authorizer(role = :default)\n if accessible == :all\n self.class.protected_attributes\n else\n super + (accessible || [])\n end\n end", "def set_perms\n self.perms = Access.for_user(self)\n end", "def permissions\n attribute_prop(5)\n end", "def deny_all_access\n @permissions = 0\n end", "def user_permission\n has_controller_permission?('user')\n end", "def permits_read_acccess_for(user)\n end", "def enforce_delete_permissions\n enforce_edit_permissions\n end", "def permission\n Ricer::Irc::Permission.by_permission(self.permissions, authenticated?)\n end", "def setable_permissions\n setable_permissions = Erp::AccessControl.permissions - Erp::AccessControl.public_permissions\n setable_permissions -= Erp::AccessControl.members_only_permissions if builtin == BUILTIN_NON_MEMBER\n setable_permissions -= Erp::AccessControl.loggedin_only_permissions if builtin == BUILTIN_ANONYMOUS\n setable_permissions\n end", "def project_permissions\n user.project_permissions(rule.project)\n end", "def standard_authorized_user_rights\n Lockdown::System.public_access + Lockdown::System.protected_access \n end", "def permissions = {}", "def make_permission_protected(name)\n permission(name).is_protected\n end", "def permissions( force_reload = false )\n\n # Two levels of joins here, so can't use has_many :through\n if force_reload\n @permissions = nil \n @permissions_by_class_and_op = {}\n end\n\n cond_str = 'role_id in ' + self.class.role_assigned_cond( '?' )\n if !instance_variable_defined?(\"@permissions\") || @permissions.nil?\n @permissions ||= Permission.where([cond_str, self]).to_a\n end\n\n return @permissions\n end", "def define_global_privileges\n can :read, Project, public_can_view?: true\n can :index, Project\n can :read, Group\n end", "def permissions\n User.do_find_permissions session_id: kb_session_id\n end", "def role\n permission_type\n end", "def permitted_to! (privilege, options = {} )\n options = {\n :user => Authorization.current_user,\n :object => self\n }.merge(options)\n\nlogger.debug \"Checking for: #{self.class.name}\"\n\n Authorization::Engine.instance.permit!(privilege,\n {:user => options[:user],\n :object => options[:object]})\n end", "def can_change( record, type = '*' )\n name, type = get_name_and_type_from_param( record, type )\n self.permissions['allowed'] << [ name, type ]\n end", "def access_rights_for_permission(perm)\n sym = Lockdown.get_symbol(perm)\n\n permissions[sym]\n rescue \n raise SecurityError, \"Permission requested is not defined: #{sym}\"\n end", "def permissions\n Roles.type_map[role_type].permissions\n end", "def require_other_permission\n respond_to_permission_error\n end", "def permissions=(value)\n @permissions = value\n end", "def can?(permission)\n permissions.include?(permission.to_s) || super_admin?\n end", "def add_user_permission(u)\n\t\t\n\tend", "def permission_for (collection)\n permission = Permission.find_or_create_by_user_id_and_collection_id(self.id, collection.id)\n end", "def apply_superuser_permissions(permission_types)\n []\n end", "def model_actions(perms)\n ActiveRecord::Base.descendants.each do |m|\n next unless m.respond_to?(:permission_definition)\n next if m.permission_definition.nil? || m.permission_definition == {}\n perms << PermissionsGenerator.new(m)\n end\n return perms\nend", "def permissions\n Rails.cache.fetch(\"permissions_#{self.id}\", expire_in: 1.month) do\n self.roles.map(&:permissions).flatten\n end\n end", "def overall_permissions(thing)\n global_permissions.merge!(permissions_for(thing))\n end", "def required_permission\n #\n # return the permission record if we have the Permission model\n #\n @required_permission ||= defined?(Permission) ? wulin_permits_required_permission : OpenStruct.new(name: [controller_name, action_name].join(\"#\"))\n end", "def set_acl_statement\n super\n end", "def custom_permissions\n\n campus = \"bakersfield\" if current_user.email.include?(\"bakersfield.edu\")\n campus = \"chancellor\" if current_user.email.include?(\"calstate.edu\")\n campus = \"channel\" if current_user.email.include?(\"ci.edu\")\n campus = \"chico\" if current_user.email.include?(\"chico.edu\")\n campus = \"dominguez\" if current_user.email.include?(\"dh.edu\")\n campus = \"eastbay\" if current_user.email.include?(\"eb.edu\")\n campus = \"fresno\" if current_user.email.include?(\"fresno.edu\")\n campus = \"fullerton\" if current_user.email.include?(\"fullerton.edu\")\n campus = \"humboldt\" if current_user.email.include?(\"humboldt.edu\")\n campus = \"longbeach\" if current_user.email.include?(\"lb.edu\")\n campus = \"losangeles\" if current_user.email.include?(\"la.edu\")\n campus = \"maritime\" if current_user.email.include?(\"maritime.edu\")\n campus = \"mlml\" if current_user.email.include?(\"mlml.edu\")\n campus = \"northridge\" if current_user.email.include?(\"northridge.edu\")\n campus = \"pomona\" if current_user.email.include?(\"bronco.edu\")\n campus = \"sacramento\" if current_user.email.include?(\"sacramento.edu\")\n campus = \"sanfrancisco\" if current_user.email.include?(\"sf.edu\")\n campus = \"sanmarcos\" if current_user.email.include?(\"sanmarcos.edu\")\n campus = \"sonoma\" if current_user.email.include?(\"sonoma.edu\")\n campus = \"stanislaus\" if current_user.email.include?(\"stanislaus.edu\")\n\n user_groups.push(campus)\n\n # admin\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end", "def permission_mapping\n super.merge(\n {\n 'index_role_screen' => 'index',\n 'index_role_field' => 'index',\n 'index_user_screen' => 'index',\n 'index_user_field' => 'index',\n 'fetch_row' => 'index'\n }\n )\n end", "def readonly_user\n super\n end", "def custom_permissions_read(_notebook, _user, _use_admin=false)\n true\n end", "def user_permissions\n if current_user.id == params[:id].to_i\n @user = User.find(params[:id])\n else\n flash[:danger] = 'Unauthorized action.'\n redirect_to edit_user_path(current_user) \n end\n end", "def permitted?; end", "def permission_proxy\n @authorizable_permission_proxy ||= Authorizable::Proxy.new(self)\n end", "def default(user)\n puts \"Rights: default\"\n # can :read, :all # doesn't do that ! We will authorize each actions\n can :read, [Doc, Gallery, Image, Place]\n can :manage, User, :id => user.id\n cannot :destroy, User, :id => user.id\n\n can :read, ForumCategory, [\"role <= ?\", user.role] do |forum_category|\n forum_category.role <= user.role\n end\n\n can :read, Forum, [\"role <= ?\", user.role] do |forum|\n if (forum.role <= user.role)\n can :read, Topic\n can :read, Message\n true\n else\n false\n end\n end\n\n # can read users profiles\n can :read, User\n\n # special actions\n can :mark_all_read, Forum\n end", "def authorize_admin!\n authorize! :manage, :all\n end", "def enforce_access_controls(opts={})\n controller_action = params[:action].to_s\n delegate_method = \"enforce_#{controller_action}_permissions\"\n if self.respond_to?(delegate_method.to_sym, true)\n self.send(delegate_method.to_sym)\n else\n true\n end\n end", "def permissions\n read_attribute(:permissions) || {}\n end", "def authorize (permission_name)\n self.allowances.detect {|a| a.permission.name == permission_name.to_s}\n end", "def check_permissions\n authorize! :create, Employee\n end", "def add_permissions\n [\"License\", \"Archive\", \"Contract\"].each do |doc|\n klass = doc.constantize\n doc_id = \"#{doc.downcase}_id\".to_sym\n permissions = self.send(\"#{doc.downcase.pluralize.singularize}_permissions\".to_sym)\n klass.find(:all).each { |record|\n permissions.create doc_id => record.id, :ycrole_id => self.id,\n :can_read => false, :can_write => false\n }\n end\n end", "def effective_permissions\n source = self\n\n while source.inherit && source.forum.parent\n source = source.forum.parent.forum_permissions.find_by(group: group)\n end\n\n source = group if source.inherit\n\n source\n end", "def set_access(*args)\n options = args.extract_options!\n options[:object] ||= Array(@_controller).first.to_s.singularize.to_sym if @_controller.present?\n permissions.add(*args, options)\n end", "def restore_permissions; end", "def restore_permissions; end", "def effective_roles_authorization_level(controller, role, resource)\n authorization_method = EffectiveResources.authorization_method\n\n raise('expected an authorization method') unless (authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol))\n return :unknown unless (controller.current_user rescue nil).respond_to?(:roles=)\n\n # Store the current ability (cancan support) and roles\n current_ability = controller.instance_variable_get(:@current_ability)\n current_user = controller.instance_variable_get(:@current_user)\n current_user_roles = controller.current_user.roles\n\n # Set up the user, so the check is done with the desired permission level\n controller.instance_variable_set(:@current_ability, nil)\n\n level = nil\n\n case role\n when :signed_in\n controller.current_user.roles = []\n when :public\n controller.instance_variable_set(:@current_user, nil)\n\n if defined?(EffectiveLogging)\n EffectiveLogging.supressed { (controller.request.env['warden'].set_user(false) rescue nil) }\n else\n (controller.request.env['warden'].set_user(false) rescue nil)\n end\n else\n controller.current_user.roles = [role]\n end\n\n # Find the actual authorization level\n level = effective_roles_item_authorization_level(controller, role, resource, authorization_method)\n\n # Restore the existing current_user stuff\n if role == :public\n ActiveRecord::Base.transaction do\n if defined?(EffectiveLogging)\n EffectiveLogging.supressed { (controller.request.env['warden'].set_user(current_user) rescue nil) }\n else\n (controller.request.env['warden'].set_user(current_user) rescue nil)\n end\n\n raise ActiveRecord::Rollback\n end\n end\n\n controller.instance_variable_set(:@current_ability, current_ability)\n controller.instance_variable_set(:@current_user, current_user)\n controller.current_user.roles = current_user_roles\n\n level\n end", "def can?(*args)\n permissions.can?(*args)\n end", "def authorize_inherited_resource!\n authorize! :show, parent if parent?\n authorize! authorizable_action, authorize_resource? ? resource : resource_class\n end", "def check_write_access(obj)\n return obj unless LinkedData.settings.enable_security\n if obj.is_a?(LinkedData::Models::Base) && obj.write_restricted?\n writable = obj.writable?(env[\"REMOTE_USER\"])\n error 403, \"Access denied for this resource\" unless writable\n end\n end", "def filter_access!\n treat_as get_current_role\n end", "def can_do_member_scoped_actions\n can :show, :all\n can :edit, :all\n can :destroy, :all\n can :history, :all\n can :show_in_app, :all\n can :clone, :all\n # can :nested_set, :all\n can :nestable, :all\n can :change_state, :all\n end", "def role_permissions=(value)\n @role_permissions = value\n end", "def permissions\n return @permissions\n end", "def build_permissions(perms, other)\n perms.permits! :read\n\n if self == other\n perms.permits! :write\n elsif other.admin?\n perms.permits! :write\n end\n end", "def everyone(read, write)\n apply(PUBLIC, read, write)\n permissions[PUBLIC]\n end" ]
[ "0.7124058", "0.70427585", "0.6954191", "0.69149697", "0.6909459", "0.6890503", "0.68741816", "0.6855458", "0.68015546", "0.6762293", "0.66815597", "0.66815597", "0.6657583", "0.6640195", "0.6627914", "0.66278124", "0.6593337", "0.64492166", "0.64396954", "0.64392996", "0.6315201", "0.6315201", "0.63095075", "0.6278138", "0.6235062", "0.6220439", "0.6216728", "0.62075436", "0.6189672", "0.61532354", "0.6152184", "0.6147287", "0.6130627", "0.6115335", "0.608766", "0.60838884", "0.6064977", "0.6052751", "0.60269153", "0.6020001", "0.6020001", "0.60028356", "0.60021436", "0.5998134", "0.5994391", "0.5986655", "0.59793115", "0.5974346", "0.5967649", "0.59665316", "0.592944", "0.59270465", "0.58969057", "0.589072", "0.5864652", "0.5863857", "0.5795321", "0.578898", "0.57750213", "0.57723695", "0.5770938", "0.5763758", "0.5760234", "0.5751763", "0.57502776", "0.57502186", "0.5747722", "0.57413733", "0.5733787", "0.573319", "0.57017004", "0.56990373", "0.56962395", "0.5695053", "0.5694021", "0.56920457", "0.56903553", "0.5652278", "0.56487584", "0.564229", "0.5635702", "0.56307256", "0.5630705", "0.56256294", "0.56251633", "0.56249714", "0.5624051", "0.5620177", "0.5618885", "0.56182003", "0.56182003", "0.5617081", "0.561568", "0.56140167", "0.56109643", "0.5608456", "0.560806", "0.56023973", "0.559919", "0.55984443", "0.55951214" ]
0.0
-1
Checks given file against pattern. file File, Pathname or String
def matches?(path) return false if path.nil? send match_method, Pathname.new(path) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_match_in_file(pattern, file)\n File.file?(file) ? assert_match(pattern, File.read(file)) : assert_file_exists(file)\n end", "def pattern_match(file, pattern)\n case\n when pattern.is_a?(Regexp)\n return file.match(pattern)\n when pattern.is_a?(String)\n return File.fnmatch(pattern, file)\n when pattern.is_a?(Proc)\n return pattern.call(file)\n when pattern.is_a?(Rake::FileTask)\n return pattern.to_s.match(file)\n else\n raise \"Cannot interpret pattern #{pattern}\"\n end\n end", "def assert_match_in_file(pattern, file)\n assert File.exist?(file), \"File '#{file}' does not exist!\"\n assert_match pattern, File.read(file)\n end", "def assert_match_in_file(pattern, file)\n assert File.exist?(file), \"File '#{file}' does not exist!\"\n assert_match pattern, File.read(file)\n end", "def file_contains(filename, pattern)\n unless pattern.kind_of?(Regexp)\n pattern = Regexp.new(pattern)\n end\n detected = nil\n File.open(filename) { |f|\n detected = f.detect { |line|\n line =~ pattern\n }\n }\n ! detected.nil?\n end", "def file_match(file)\n end", "def fnmatch(pattern, *args) File.fnmatch(pattern, path, *args) end", "def fnmatch?( pattern, *args ) File.fnmatch?( pattern, self, *args ) end", "def fnmatch?(pattern, *args) File.fnmatch?(pattern, @path, *args) end", "def fnmatch(pattern, *args) File.fnmatch(pattern, @path, *args) end", "def fnmatch?(pattern, *args) File.fnmatch?(pattern, path, *args) end", "def fnmatch( pattern, *args ) File.fnmatch( pattern, self, *args ) end", "def match_against filename\n @regexp.match(filename)\n end", "def filename_matches_pattern?(filename)\n @file_matchers.each do |pattern|\n return true if File.fnmatch(pattern, filename)\n end\n return false\n end", "def is_valid_file_name?(filename)\n return $filepattern.match(filename)\nend", "def matching_file_regex\n file_regex ? file_regex : /\\.js$/\n end", "def validate_file(file)\n end", "def matches_filename?(filename)\r\n basename = File.basename(filename)\r\n @glob_patterns.any? {|pattern| File.fnmatch pattern, basename.downcase}\r\n end", "def check_file_patterns\n FILE_PATTERNS.each do |attr_name|\n if respond_to?(\"_validate_#{attr_name}\", true)\n send(\"_validate_#{attr_name}\")\n else\n validate_nonempty_patterns(attr_name, :error)\n end\n end\n\n _validate_header_mappings_dir\n if consumer.spec.root?\n _validate_license\n _validate_module_map\n end\n end", "def search_file(pattern, file)\n node = ast_from_file(file)\n search node, pattern\n end", "def matches_path?(pattern, path)\n File.fnmatch?(\n pattern, path,\n File::FNM_PATHNAME | # Wildcard doesn't match separator\n File::FNM_DOTMATCH # Wildcards match dotfiles\n )\n end", "def file_pattern(name)\n if name.to_s !~ FILE_PATTERN_NAME_REGEX\n raise ArgumentError.new(\"A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }\")\n end\n get_config_val(@file_patterns, name)\n end", "def matches_file?(f)\r\n @magics.any? {|m| m =~ f }\r\n end", "def file_pattern( pattern )\n self.class_eval { @file_pattern = pattern }\n end", "def matches_path?(pattern, path); end", "def valid_file?(path)\n case path\n when %r|/abcdef$|, %r|^\\./tmp/db/\\w+?/database.yml$|\n return false\n end\n return true\n end", "def matches?(file); matches_exprs?(file,[@reg_expr]); end", "def gsub_file_with_match_check(relative_destination, regexp, *args, &block)\n path = destination_path(relative_destination)\n matches = File.read(path).match(regexp)\n raise \"Regexp not found in #{relative_destination}\\n called from #{caller.first}\" unless matches\n gsub_file(relative_destination, regexp, *args, &block)\nend", "def grep_file(file_path, grep_pattern)\n logc(\"method: #{__method__}, params: #{file_path}, #{grep_pattern}\")\n\n # with File.open(file_path, 'r').each.grep(grep_pattern) possible invalid byte sequence in UTF-8 (ArgumentError)\n # so we use \"match\" to check if line match pattern and 'scrub' to skip bad encoding symbols\n res = []\n File.open(file_path, 'r').each {|line| res << line if line.scrub.match(grep_pattern)}\n return res\nend", "def glob_matches?(rule)\n File.fnmatch?(rule, @host_name)\n end", "def check(filename)\r\n check_special(filename) ||\r\n open(filename) { |f|\r\n check_magics_gt80(f) ||\r\n check_globs(filename) ||\r\n check_magics_lt80(f) ||\r\n check_default(f)\r\n }\r\n end", "def only(files,patterns)\n if !patterns.kind_of?(Array)\n patterns = [patterns]\n end\n files.select do |file|\n matches = false\n patterns.each do |pattern|\n if File.fnmatch(pattern,file)\n matches = true\n break\n end\n end\n matches\n end\n end", "def matchFn(filename)\n\treturn [\".txt\", \".pdf\"].include? File.extname(filename)\nend", "def matcher(pattern)\n case pattern\n when Regexp then lambda{|p| p =~ pattern}\n when String then lambda{|p| File.fnmatch?(pattern, p)}\n when Proc then pattern\n else raise ArgumentError, \"Expected a Regexp, String, or Proc\"\n end\n end", "def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end", "def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end", "def match(pattern, flags = 0)\n\t\t\t\tpath = pattern.start_with?('/') ? full_path : relative_path\n\t\t\t\t\n\t\t\t\treturn File.fnmatch(pattern, path, flags)\n\t\t\tend", "def valid_file_name\n (@file_name.match(/((\\d)|([a-zA-Z])|(_))*.log/).to_s == @file_name)\n end", "def relevant_file?(file)\n file.end_with?('_spec.rb')\n end", "def test_file\n assert_pattern_match [ \"/directory\", \"component.vwf\", nil, nil ], \"/directory/component.vwf/\"\n end", "def validate_file(file)\n if file.respond_to? :read\n src = file.read\n else\n src = read_local_file(file)\n end \n\n return validate_text(src)\n end", "def matched_in_patternfile?(filepath, matchthis)\n\n patternlist = []\n\n begin\n open(filepath).each do |l|\n l.chomp!\n\n next if l =~ /^$/\n next if l =~ /^#/\n\n if l =~ /^\\s*(\\S+)/\n m = Regexp.last_match\n log(\"found a non-comment line, transforming [#{l}] into [#{m[1]}]\")\n l.gsub!(l,m[1])\n else\n next l\n end\n\n pattern = %r{#{l}}\n patternlist << pattern\n log(\"appending [#{pattern}] to patternlist for [#{filepath}]\")\n end\n rescue StandardError\n log(\"Problem reading #{filepath}: #{$!}\",:err)\n exit(1)\n end\n\n log(\"list of patterns for #{filepath}: #{patternlist}\")\n\n if matchthis =~ Regexp.union(patternlist)\n log(\"matched #{$~} in #{matchthis}, returning true\")\n return true\n\n else # hostname didn't match anything in patternlist\n log(\"#{matchthis} unmatched, returning false\")\n return nil\n end\n\n end", "def validate_file_patterns\n attributes = DSL.attributes.values.select(&:file_patterns?)\n attributes.each do |attrb|\n patterns = consumer.send(attrb.name)\n if patterns.is_a?(Hash)\n patterns = patterns.values.flatten(1)\n end\n patterns.each do |pattern|\n if pattern.start_with?('/')\n error \"File patterns must be relative and cannot start with a \" \\\n \"slash (#{attrb.name}).\"\n end\n end\n end\n end", "def check\n file_nil\n if @file.end_with?(\".txt\")\n if File.exist?(@file)\n @f = Command_File.new(@file)\n else\n raise \"File \\\"#{@file}\\\" does not Exist\n Please choose a \\\".txt\\\" file that exists\"\n end\n else\n raise \"Invalid Input File \\\"#{@file}\\\"\n File must end in \\\".txt\\\"\"\n end\n end", "def filepath_match?(path, *acceptable_matches)\n acceptable_matches.any? { |match| path.fnmatch?(match, File::FNM_EXTGLOB) }\n end", "def filepath_match?(path, *acceptable_matches)\n acceptable_matches.any? { |match| path.fnmatch?(match, File::FNM_EXTGLOB) }\n end", "def validate_file_patterns\n attributes = DSL.attributes.values.select(&:file_patterns?)\n attributes.each do |attrb|\n patterns = consumer.send(attrb.name)\n if patterns.is_a?(Hash)\n patterns = patterns.values.flatten(1)\n end\n patterns.each do |pattern|\n if pattern.start_with?('/')\n error '[File Patterns] File patterns must be relative ' \\\n \"and cannot start with a slash (#{attrb.name}).\"\n end\n end\n end\n end", "def music_file(file)\n ext_list = $config[\"music_file\"][\"media_extentions\"].gsub(/,/,\"|\")\n \n ext = \".*\\.(#{ext_list})$\" \n name = \"\"\n\n $config['music_file']['regex'].each do |pattern|\n if file =~ /.*#{pattern}#{ext}/i\n name = $1 if $1\n return false if name =~ /^sample/i\n return true\n end\n end\n return false\nend", "def check_file\n @files.each do |file|\n case \n when file.fnmatch(\"*Verbale autorizzativo*\") then check_verbale(estrai_allegato(file))\n when file.fnmatch(\"*Prezzi_Offerte*\") then check_controllo_offerte(file)\n when file.fnmatch(\"*Validate_Eni*\") then check_offerte(file)\n when file.fnmatch(\"*Esitate_Eni*\") then check_offerte(file)\n when file.fnmatch(\"*ProgrFisica*\") then check_offerte_pce(file)\n when file.fnmatch(\"*Scheduling & Bilateral Program*\") then check_scheduling_bilateral(file)\n when file.fnmatch(\"*tool autorizzazione offerte belpex*\") then check_tool_belgio(file)\n when file.fnmatch(\"*Export E-prog46_ita.xls\") then check_tool_olanda(file) \n when file.fnmatch(\"*Validate_*_*.docx\") then check_validate_epex(file) \n when file.fnmatch(\"*Esitate_Francia_*.csv\") then check_esitate_epex(file)\n when file.fnmatch(\"*Esitate_Germania_*.csv\") then check_esitate_epex(file) \n when file.fnmatch(\"*Esitate_Svizzera_*.csv\") then check_esitate_epex(file) \n else\n\n end\n end\n end", "def contain?(filename); end", "def matches(_ext); end", "def matches(_ext); end", "def glob_match (filenames, pattern)\n\t# Escape the '*', '?', and '.' characters\n\tpattern.gsub!(/[\\*\\?\\.]/, '*' => '.*', '?' => '.', '.' => '\\.') \t\n\tregex = Regexp.new(pattern)\n\t#select returns a new array\n\tfilenames.select do |filename|\n\t\tfilename =~ regex\n\tend\nend", "def file_patterns_errors_for_spec(spec, file, platform_name)\n Dir.chdir(config.project_pods_root + spec.name ) do\n messages = []\n messages += check_spec_files_exists(spec, :source_files, platform_name, '*.{h,m,mm,c,cpp}')\n messages += check_spec_files_exists(spec, :resources, platform_name)\n messages << \"license[:file] = '#{spec.license[:file]}' -> did not match any file\" if spec.license[:file] && Pathname.pwd.glob(spec.license[:file]).empty?\n messages.compact\n end\n end", "def accept_file(file, name, kind)\n logger.debug \"FileHelper is accepting file: filename=#{file.filename}, name=#{name}, kind=#{kind}\"\n\n fm = FileMagic.new(FileMagic::MAGIC_MIME)\n mime = fm.file file.tempfile.path\n logger.debug \"#{name} has MIME type: #{mime}\"\n\n valid = true\n\n case kind\n when 'image'\n accept = [\"image/png\", \"image/gif\", \"image/bmp\", \"image/tiff\", \"image/jpeg\", \"image/x-ms-bmp\"]\n when 'code'\n accept = [\"text/x-pascal\", \"text/x-c\", \"text/x-c++\", \"text/plain\", \"text/\"]\n when 'document'\n accept = [ # -- one day\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n # --\"application/msword\",\n \"application/pdf\" ]\n valid = pdf_valid? file.tempfile.path\n else\n logger.error \"Unknown type '#{kind}' provided for '#{name}'\"\n return false\n end\n\n # result is true when...\n mime.start_with?(*accept) && valid\n end", "def matches?(cmd)\n files_match? && file_content_match?\n end", "def file?(path)\n eval(FILE_CHECK, binding, __FILE__, FILE_CHECK_LINE)\n nil\nend", "def check_file?(path)\n Actions.check_file path\n rescue FileError\n false\n else true\n end", "def glob_match(filenames, pattern)\n pattern = pattern.gsub(/[\\*\\?\\.]/, '*' => '.*', '.' => '\\.', '?' => '.')\n regex = Regexp.new(pattern)\n filenames.select do |filename|\n filename =~ regex\n end\nend", "def is_match?(file)\n return Match.new file, 'No Destinatin for file'\n end", "def validate_file(file_path)\n if file_path.respond_to? :read\n src = file_path.read\n else\n src = read_local_file(file_path)\n end\n return validate_text(src)\n end", "def validate_file(filename)\n return true\nend", "def doc_file?(file)\n DOC_FILES.any? do |doc|\n doc.is_a?(Regexp) ? doc.match(file) : doc == file\n end\n end", "def glob_match(filenames, pattern)\n\t\n\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\n\n\treturn filenames.select{|i| i.match(/#{newPattern}/)}\n\t\nend", "def match?(path)\n path =~ to_regexp\n end", "def match_folder(name, patterns = '*')\n Array(patterns).any? do |pattern|\n if pattern.is_a?(String)\n File.fnmatch(pattern.downcase, name.downcase)\n elsif pattern.is_a?(Regexp)\n name =~ pattern\n else\n nil\n end\n end\n end", "def file?(f)\n File.file? f\n end", "def ruby_grep(filename, pattern)\n regexp = Regexp.new(pattern)\n File.open(filename, 'r') do |file|\n file.each_line {|line| puts line if regexp =~ line}\n end\nend", "def content_exists(file, regex, mode)\n\tooo = File.stat(file)\n\toatime=foo.atime #atime before edit\n\tomtime=foo.mtime #mtime before edit\n\n\tif mode.to_i == 1\n\t\tf = File.open(file, 'r')\n\telse\n\t\tf = File.open(file, 'rb') #Open file in binary mode (utmp/wtmp/etc)\n\tend\n\tfoo = f.readlines #Read file into array we can search through as wel like\n\tf.close\n\tif foo.to_s.match(/#{regex}/im) #Check for needle in haystack :p\n\t\tif mode.to_i == 1\n\t\t\tputs \"#{HC}#{FGRN}Found in Non-Binary File#{FWHT}: #{file}#{RS}\"\n\t\telse\n\t\t\tputs \"#{HC}#{FGRN}Found in Binary File#{FWHT}: #{file}#{RS}\"\n\t\tend\n\t\tocc = foo.to_s.scan(/#{regex}/im).count #How many times does it occur in file?\n\t\tputs \"\\t#{FGRN}Number of Occurances#{FWHT}: #{occ}#{RS}\"\n\tend\n\n\tFile.utime(oatime, omtime, file) #Keep timestamp preserved\nend", "def validFile? filename\n if !filename.kind_of? String\n return false\n elsif File.exists? filename\n return File.readable? filename\n else\n return false\n end\nend", "def matching_file(spec, path) # :doc:\n glob = \"#{@lib_dirs[spec.object_id]}/#{path}#{SUFFIX_PATTERN}\"\n return true unless Dir[glob].select { |f| File.file?(f) }.empty?\n end", "def matches_patterns(relative_path, patterns)\n patterns.each do |pattern|\n if relative_path.fnmatch?(pattern)\n return true\n end\n end\n return false\n end", "def single?(file)\n file !~ /\\*/\n end", "def check_file(filename)\n lines = []\n line_num = 0\n # Get tags to search in file\n pattern = define_regexp\n # Read lines of file\n File.open(filename, 'r') do |file|\n file.each_line do |line|\n line_num += 1\n lines << [line_num, line] if line =~ /#{pattern}/i\n end\n end\n # Report results in json file\n report_results(filename, lines, 'tags') if @options[:report]\n # Print results if required\n unless @options[:quiet] || lines.empty?\n puts\n @options[:jenkins] ?\n puts(\"=== #{filename} ===\") :\n puts(\"=== #{filename} ===\".bold)\n print_tags(lines)\n end\n 0\n end", "def match?(path)\n @regex.match?(path)\n end", "def replace(pattern, replacement, file)\n was = sftp.file.open(file, \"r\") { |f| f.read }\n found = case pattern\n when :all, :any, :everything\n log \"replace \\e[1m%s\\e[0m in '%s'\" % [pattern, file]\n true\n when Regexp\n log \"replace \\e[1m%s\\e[0m in '%s'\" % [pattern.inspect, file]\n replacement = was.gsub(pattern, replacement)\n was =~ pattern\n when String\n log \"replace \\e[1m%s\\e[0m in '%s'\" % [\"String\", file]\n replacement = was.gsub(pattern, replacement)\n was.include?(pattern)\n else raise \"%s is not a valid. You can use a String, Regexp or :all, :any and :everything\" % pattern.inspect\n end\n\n if found\n sftp.file.open(file, \"w\") { |f| f.write replacement }\n else\n log \"\\e[31m '%s' does not include your \\e[1mpattern\\e[0m\" % file unless was =~ pattern\n end\n end", "def valid_file?(file)\n case file\n when 'exclude.exclude', 'include.include',\n 'include_exclude.exclude', 'include_exclude.include',\n 'env_exclude.env.exclude', 'env_include.env.include',\n 'include_env_exclude.include', 'include_env_exclude.env.exclude',\n 'include_exclude_env_include.exclude',\n 'include_exclude_env_exclude.include',\n 'include_env_include_env_exclude.env.exclude',\n 'exclude_env_include.exclude',\n 'exclude_env_include.env.include',\n /^include_env_include\\..*include$/,\n /^include_exclude_env_include\\..*include$/,\n /^include_exclude_env_exclude\\..*exclude$/,\n /^include_env_include_env_exclude\\..*include$/,\n /^exclude_env_exclude\\..*exclude$/,\n /^env_include_env_exclude\\.env\\./,\n /^exclude_env_include_env_exclude\\.(env\\.|exclude$)/,\n /^include_exclude_env_include_env_exclude\\./,\n /^env_symbol\\..*include$/\n return true\n when /^default\\./, /^exclude\\./, /^include\\./,\n /^env_exclude\\./, /^env_include\\./, /^include_env_include\\./,\n /^include_env_exclude\\./, /^include_exclude_env_include\\./,\n /^include_exclude_env_exclude\\./, /^exclude_env_include\\./,\n /^include_env_include_env_exclude\\./, /^exclude_env_exclude\\./,\n /^env_include_env_exclude\\./, /^exclude_env_include_env_exclude/,\n /^env_symbol\\./\n return false\n end\n\n # Raise an error if the file was not handled by existing logic.\n raise \"Invalid file (#{file}) specified in #{__method__}.\"\n end", "def file_matches_criteria?(full_path)\n full_path.file? && proper_ext?(full_path) &&\n !LokaliseRails.skip_file_export.call(full_path)\n end", "def matches(ext); end", "def match?( path )\n path_matcher =~ path\n end", "def validate_file(file_path)\n if file_path.respond_to? :read\n src = file_path.read\n else\n src = read_local_file(file_path)\n end \n # we force the :post mode otherwise it fails for\n # big files\n return validate_text(src, :post)\n end", "def capture_file(pattern, file)\n node = ast_from_file(file)\n capture node, pattern\n end", "def matches?(pattern); end", "def valid_file_type filename\n # avoid hacks that break out of single quotes echoed to shell\n filename.gsub!(\"'\", '')\n `file '#{filename}'`.split(':').last.downcase =~ Regexp.union(*valid_file_types)\n end", "def check_format(file)\n \tbegin\n content = file_content(file)\n content = content.split(\"\\n\").reject { |c| c.empty? }\n read_file(content)\n rescue\n raise_error ERROR_READING_FILE\n end\n end", "def check_file_existence (file_path)\n \"[ -f '#{file_path}' ]\"\n end", "def filter_files(pattern)\n regexp=Regexp.new(pattern || '.*')\n @filtered_files=@files.inject([]) do |matches,file| \n file_without_basepath=file[@basepath.length .. -1]\n matches << file if file_without_basepath=~regexp\n matches\n end\n @table.reloadData\n end", "def match(pattern); end", "def =~(options)\n options && options[:file].respond_to?(:open) ? true : false\n end", "def valid?\n # is it a valid pattern (i.e. does not contain funny characters)? @TODO\n # all characters are valid, except for the /, directory limiter., files cannot start with a dot (hidden files)\n # is the file a web-savvy image?\n valid_types = ['image/jpeg', 'image/png', 'image/gif']\n return false unless valid_types.include? @entry.metadata.mime_type\n # does the file have thumbnails?\n return false unless @entry.metadata.thumb_exists\n # is the file not the special, reserved thumb.*? (see thumb_for_dir)\n # @TODO: return false if basename.match /^thumb\\.[A-z]*$/\n return true\n end", "def find_file_by_text (start_dir, file_mask=\"*.*\", text_pattern='')\n match_files = Dir[ File.join(start_dir.split(/\\\\/), \"**\", file_mask)]\n if match_files.length > 0\n file_path = nil\n match_files.each do |file|\n matching_text = File.read(file).include?(text_pattern) rescue false\n if matching_text\n file_path = file\n break\n end\n end\n p \"#{file_path ? 'First searching file is: '+file_path : 'No files found'}\"\n else\n \"No files with mask '#{file_mask}' in directory '#{start_dir}'\"\n end\n end", "def test_file(path)\n return File.file?(path)\nend", "def whitelist_file(file)\n file = Regexp.new(file) unless file.is_a?(Regexp)\n whitelist_files << file\n whitelist_files.dup\n end", "def filter(file, fixture)\n # return ['affix_InterveningEmpty.json'].include?(File.basename(file))\n # File.basename(file) =~ /bugreports_greek/i\n # File.basename(file) =~ /sort_stripmark/i\n # return File.basename(file) =~ /^date_rawparsesimpledate/i\n true\nend", "def file?(name)\n File.file?(path(name))\n end", "def valid_file?(file,type)\n\tif type == \"csv\"\n\t\tif file.nil?\n\t\t\tputs \"Please provide a source .csv file\"\n\t\t\texit 0\n\t\tend\n\tend\n\tif !File.exists?(file)\n\t\tputs \"#{file} doesn't seem to exist. Please check\\nyour file path and try again.\"\n\t\texit 0\n\tend\n\ttrue\nend", "def file?(file_path)\n nlst(file_path)[0] == file_path\n end", "def check\n prefix = File.basename(@file)\n if File.exist?(@file)\n @message = \"#{prefix} : Expected file exists\"\n true\n else\n @message = \"#{prefix} : Expected file not found.\"\n false\n end\n end", "def scan_file(source_path, filename)\n found = 0\n File.open(source_path) do |source_file|\n source_file.each do |line|\n if line.include?(MAGIC_STRING)\n found += 1\n end\n end\n end\n\n if found == 0\n @stats.record_no_tag(filename, source_path)\n elsif found == 1\n @stats.record_tag(filename)\n else\n raise(\"File contains #{found} license lines: #{source_path}\")\n end\n end", "def check_file(path)\n raise Error, \"The path '#{path}' does not exist or is not a file\" unless path.file? || attrs[:exists] == false\n end", "def user_path?(file); end" ]
[ "0.79040873", "0.7767663", "0.76429737", "0.76429737", "0.7590968", "0.7568827", "0.7403286", "0.7375396", "0.73636085", "0.7363439", "0.7358617", "0.7326869", "0.7273945", "0.7269795", "0.7238025", "0.6862911", "0.68055886", "0.6743549", "0.6728241", "0.66884166", "0.6675093", "0.6653235", "0.6576527", "0.6548926", "0.6543279", "0.648704", "0.64228153", "0.6417274", "0.6408644", "0.63953525", "0.6373208", "0.63664865", "0.6366071", "0.6348171", "0.628341", "0.628341", "0.6257425", "0.6219057", "0.6213776", "0.62120414", "0.6209805", "0.6204705", "0.6187954", "0.6182593", "0.61798555", "0.61798555", "0.61789584", "0.6174286", "0.61536515", "0.61442995", "0.6141073", "0.6141073", "0.61215436", "0.6116957", "0.61150265", "0.6113575", "0.61111933", "0.60989046", "0.6092424", "0.60879904", "0.60763025", "0.6043449", "0.6012909", "0.5998234", "0.59977925", "0.59867334", "0.59781486", "0.59718806", "0.59716934", "0.5966373", "0.59617513", "0.59460914", "0.5940775", "0.5939083", "0.593737", "0.5928927", "0.5920568", "0.59139985", "0.5909214", "0.5905697", "0.5896314", "0.5890101", "0.5887249", "0.58824915", "0.58808404", "0.58591664", "0.5849631", "0.58466077", "0.5844259", "0.582351", "0.58223397", "0.58166903", "0.5798955", "0.5783257", "0.5783222", "0.57816815", "0.57760787", "0.5766191", "0.5755416", "0.57457507", "0.57445884" ]
0.0
-1
GET /stay_times GET /stay_times.json
def index @stay_times = StayTime.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end", "def index\n @tea_times = TeaTime.all\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n format.json { render json: @tea_times }\n end\n end", "def index\n render json: {time: Time.now}\n end", "def show\n @time_gap = TimeGap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_gap }\n end\n end", "def hours\n render json: Pings::Selector.new.hours(params)\n end", "def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end", "def index\n @mealtimes = Mealtime.all\n end", "def index\n @time_entry ||= current_user.time_entries.build(\n :tdate => Date.today\n )\n \n @time_entries = current_firm.all_time_entries\n\n respond_to do |format|\n format.html { render :index }# index.html.erb\n format.json { render json: @time_entries }\n end\n end", "def show\n render json: @timer\n end", "def index\n @timecards = TimeCard.all\n render :json => @timecards.to_json(:include => :time_entry), status: :ok\n end", "def query_times_graphs\n controller = params[:controller_name]\n action = params[:action_name]\n data = redis(logger: true).zrangebyscore(\"request_timings/total/by_action/#{controller}##{action}\",\n 1.month.ago.to_i, '+inf',\n with_scores: true)\n .map { |y, x| [x.to_f, y.to_f] }\n throw 'No Data' if data.nil? || data.empty?\n smoothed = moving_avg(data)\n final = (params[:raw].present? ? data : smoothed).map { |x, y| [Time.at(x.to_i).to_datetime, y] }\n render json: [\n { name: 'Timings', data: final }\n ]\n end", "def index\n @timers = Timer.all\n\n render json: @timers\n end", "def index\n\n @hurdle_times = HurdleTime.order('time, hurdle_match_id, lane')\n\n if params[:hurdle_match_id]\n @hurdle_times = @hurdle_times.where(:hurdle_match_id => params[:hurdle_match_id])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hurdle_times }\n end\n end", "def show\n\n trip = Trip.find(params[:id])\n\n departureOrder = LineStation.find_by_station_id(trip.departureStation_id).order\n arrivalOrder = LineStation.find_by_station_id(trip.arrivalStation_id).order\n\n lineStations = LineStation.where(:order => departureOrder..arrivalOrder)\n lineStations = lineStations.where(:line_id => trip.line_id)\n if departureOrder < arrivalOrder\n lineStations.order('order ASC')\n else\n lineStations.order('order DESC')\n end\n\n times = Array.new\n currentTime = trip.beginTime\n lineStations.each do |ls|\n \n station = Station.find(ls.station_id)\n train = Train.find(trip.train_id)\n\n times << { :station => station, :time => currentTime.strftime('%H:%M') }\n\n timeElapsed = ls.distance.to_f / train.velocity\n currentTime = currentTime + timeElapsed.hours\n end\n\n render :json => { :trip => trip, :times => times }\n\n end", "def index\n @location_times = LocationTime.all\n end", "def open_appointments\n date = Date.parse(params[:date])\n clinic = Clinic.find(params[:clinic_id])\n doctor = Doctor.find(params[:doctor_id])\n # @times = doctor.open_appointment_times(date)\n @times = clinic.open_appointment_times(date, doctor)\n if @times.is_a?(Hash)\n render json: {status: 1, error: @times[:error]}\n else\n render json: { status: 0, times: @times }\n end\n #@appointment = Appointment.new\n #render json: {open_times: @open_times}\n # render json: {times: [\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\n\n end", "def index\n date_range = unix_date(params[:date])\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\n # render :json => @timeslots.as_json(only: [])\n end", "def show\n render :json => @timecard.to_json(:include => :time_entry), status: :ok\n end", "def index\n @timeslots = Timeslot.all\n end", "def index\n @timeslots = Timeslot.all\n end", "def index\n @allocated_times = AllocatedTime.all\n end", "def index\n @session_times = SessionTime.all\n end", "def index\n @cooking_times = CookingTime.all\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clock_time }\n end\n end", "def index\n @clock = @employee.clock_in_out\n render json: @clock\n end", "def index\n @wait_times = WaitTime.all\n end", "def index\n schedules = Schedule.where(trip_id: params[:trip_id])\n respond_with schedules\n end", "def index\n @working_start_times = WorkingStartTime.all\n end", "def index\n @meeting_times = MeetingTime.order(:time).all\n end", "def index\n @time_of_days = TimeOfDay.all\n end", "def getTimes()\n return @times\n end", "def index\n @timetables = Timetable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timetables }\n end\n end", "def index\n @vehicle_realtimes = VehicleRealtime.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\n end\n end", "def index\n @jobtimes = current_company.jobtimes.find_all_by_job_id(params[:job_id])\n respond_to do |format|\n format.xml {render :xml => @jobtimes }\n format.json { render :json => @jobtimes }\n end\n end", "def time_trackings\n Easybill::Api::TimeTrackings\n end", "def index\n @timings = Timing.all\n end", "def index\n @announces = Announce.not_finished.order(\"stime DESC\")\n\t\t@pannounces = Announce.finished.last_24_hours.limit(20).order(\"etime DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @announces }\n end\n end", "def chatting_time(*args)\n @client.get \"#{@path}/chatting_time\", Hash[*args]\n end", "def index\n @times_games = TimesGame.all\n end", "def index\n @section_times = SectionTime.all\n end", "def index\r\n @clocks = ClockResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @clocks }\r\n end\r\n end", "def index\n streaks = Streak.active.all\n render_jsonapi(streaks)\n end", "def index\n @poi_times = PoiTime.all\n end", "def index\n @day_timeslots = DayTimeslot.all\n end", "def index\n @appointments = Appointment.all \n render json: @appointments\n end", "def index\n @class_times = ClassTime.all\n end", "def index\n @reservations = @user.reservations\n @reservations_json = []\n @reservations.each do |r|\n ro = r\n r = r.as_json\n %w{arrived email no_show owner_id}.each {|k| r.delete(k)}\n r[:start_time] = ro.start_time_format\n r[:end_time] = ro.end_time_format\n @reservations_json << r\n end\n\n render json: @reservations_json, status: 200 \n end", "def station_times(name, mins)\n ier = IERailGet.new(\"getStationDataByNameXML_withNumMins?StationDesc=#{name}&NumMins=#{mins}\", \"arrayofobjstationdata\", \"objstationdata\")\n \n ier.response.map { |sd| StationData.new(sd) }\n end", "def show\n @stop_time = StopTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stop_time }\n end\n end", "def index\n ok_request current_user, %w(user, opinion_polls, opinion_polls.time_slots)\n end", "def index\n @p_times = PTime.all\n end", "def region_slots\n if(current_user.customer_id?)\n @timeslots = Timeslot.where(\"region_id = ?\", current_user.customer.region_id)\n else\n @timeslots = Timeslot.where(\"region_id = ?\", current_user.driver.region_id)\n end\n render json: @timeslot, status: 200\n end", "def index\n @cal_times = CalTime.paginate(page: params[:page])\n end", "def show\n @working_time = WorkingTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @working_time }\n end\n end", "def index\n @tombstone_timeholds = TombstoneTimehold.all\n end", "def get_data_for_time_span()\n set_schedule_query_params\n\n @t1 = Time.at(@t1.to_i)\n @t2 = Time.at(@t2.to_i)\n\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\n\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\n\n json_adjustments\n end", "def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end", "def dates\n render json: @standings\n end", "def work_schedules\n @work_schedules = WorkSchedule.all\n\n render json: @work_schedules.to_json\n end", "def index\n if !time_slot_params[:start].present? && !time_slot_params[:end].present?\n @appointments = Appointment.all\n else\n #time_slot_params[:start], time_slot_params[:end]\n @appointments = Appointment.in_time_slot_only(time_slot_params).all\n end\n render :json => @appointments, :status => :ok\n end", "def index\n @hour_logs = HourLog.all\n render json: @hour_logs, status: 200\n end", "def index\n vehicle_id = params[:vehicle_id]\n shift_date = Date.today\n\n begin\n @shifts = Shift.by_vehicle_and_date(vehicle_id, shift_date)\n rescue\n errors = \"Error\"\n render json: errors.to_json, status: 400\n return\n end\n\n respond_with(@shifts)\n\n # render json: trips, status: :ok\n end", "def index\n @hours = Hour.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hours }\n end\n end", "def show\n @where_to_stay = WhereToStay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @where_to_stay }\n end\n end", "def index\n @timecard = Timecard.find(params[:timecard_id])\n render :json => Hour.timecard_hours(@timecard)\n end", "def index\n render json: meeting.all\n end", "def show\n @student = Student.find(params[:id])\n @times = times\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def create\n @stay_time = StayTime.new(stay_time_params)\n\n respond_to do |format|\n if @stay_time.save\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' }\n format.json { render :show, status: :created, location: @stay_time }\n else\n format.html { render :new }\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @meal_time = MealTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meal_time }\n end\n end", "def show\n @hurdle_time = HurdleTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hurdle_time }\n end\n end", "def show\n @service_time = ServiceTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service_time }\n end\n end", "def index\n workouts = @ws.workouts\n render json: workouts\n end", "def showtimes_json(day)\n showtimes_by_cinemas_json(CONST::WORD_DAY_HASH[day]).to_json\n end", "def show\n @wait_time = WaitTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wait_time }\n end\n end", "def index\n @regimes = Regime.all\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @regimes }\n # end\n end", "def index\n @slots = Slot.opening_hours.where(:company_id => current_user.company.id)\n @slots = @slots.sort { |a, b| a.cwday <=> b.cwday }\n\n @blockers = Slot.blockers.where(:company_id => current_user.company.id)\n @blockers = @blockers.sort { |a, b| a.cwday <=> b.cwday }\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: { slots: @slots, blockers: @blockers } }\n end\n end", "def index\n @title = t('view.shifts.index_title')\n \n if params[:pay_pending_shifts_for_user_between]\n param = params[:pay_pending_shifts_for_user_between]\n start, finish = make_datetime_range(\n from: param[:start], to: param[:finish]\n ).map(&:to_date)\n\n user = User.find(param[:user_id])\n @shifts = user.shifts.pending_between(start, finish)\n else\n @shifts = shifts_scope.order('start DESC').paginate(\n page: params[:page], per_page: lines_per_page\n )\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shifts }\n end\n end", "def index\n set_user\n @time_offs = TimeOff.all\n end", "def index\n @delivery_times = DeliveryTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @delivery_times }\n end\n end", "def schedule\n @users = User.includes(:shifts => :position).where(shifts: {show: @current_show}).order(\"users.first_name, users.last_name, shifts.updated_at\")\n @start = @current_show.start - 4.5.hours\n @end = @current_show.start + 7.5.hours\n @shift_data = Hash[@users.map { |u| u.shifts }.flatten.map { |s| [s.id, { url: shift_path(s, :json), start_time: s.start_time, end_time: s.end_time }] }]\n\n respond_to do |format|\n format.html\n format.json { render 'schedule' }\n end\n end", "def index\n @course_timings = CourseTiming.all\n end", "def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end", "def show\n @restaurant = Restaurant.find(params[:id])\n @reservation = Reservation.new\n @image_tag_string = \"/assets/slideshow-rest.jpg\"\n\n @google_map = \"http://maps.google.com/maps/api/staticmap?key=AIzaSyC77WBfl-zki0vS7h9zyKyYg3htKcERvuo&size=400x300\"\n @google_map << \"&markers=icon:http://i42.tinypic.com/rj2txf.png%7C#{@restaurant.lat}%2C#{@restaurant.lng}\"\n @google_map << '&sensor=false&zoom=16'\n\n @today = true\n if @restaurant.inventories.available.size >= 3\n @times = @restaurant.inventories.available.limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\n else\n @today = false\n @times = @restaurant.inventories.available((Time.zone.today + 1.day), \"00:00\").limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\n end\n\n @times = [\"18:30\",\"19:00\",\"19:30\"]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant }\n end\n end", "def stops\n get '/gtfs/stops'\n end", "def days\n @trainings = Training.all\n @activities = Activity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trainings }\n end\n end", "def index\n @timed_tasks = TimedTask.all\n end", "def index\n #@shifts = Shift.all\n @shifts = Shift.where(tenant_id: current_tenant.id)\n render json: {\n message: 'Your Shift',\n shifttransaction: @shift\n }\n end", "def index\n @timecharts = Timechart.find(:all, order: \"stop_time DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timecharts }\n end\n end", "def show\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_off_request }\n end\n end", "def index\n @scheduled_appointments = ScheduledAppointment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scheduled_appointments }\n end\n end", "def index\n\n if params[:meeting_id]\n @meeting = Meeting.find(params[:meeting_id])\n end\n\n respond_to do |f|\n f.json {\n @meetings = Meeting\n start_p = Time.parse(params[:start])\n end_p = Time.parse(params[:end])\n @meetings = @meetings.where(\"start_at > ?\", params[:start])\n if start_p and end_p\n duration = end_p - start_p\n @meetings = @meetings.where(\"duration < ?\", duration)\n end\n\n render :json => @meetings.map{|m|\n {\n :id => m.id,\n :title => m.label,\n :start => m.start_at,\n :end => m.end_at,\n :url => \"/reunions/#{m.id}.js\",\n color: '#D42700',\n textColor: 'white'\n }\n }\n }\n f.html\n end\n end", "def goals\n get(\"/user/#{@user_id}/activities/goals/daily.json\")\n end", "def index\n @timesheets = Timesheet.all\n render json: @timesheets\n end", "def index\n @workout_days = WorkoutDay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workout_days }\n end\n end", "def goals\n get(\"/user/#{@user_id}/activities/goals/daily.json\")\n end", "def index\n trips = Trip.all\n render json: trips\n end", "def index\n if current_doctor.present?\n @availibility_time_slots = current_doctor.availibility_time_slots\n else\n @availibility_time_slots = AvailibilityTimeSlot.all\n end\n end", "def index\n respond_to do |format|\n format.html\n format.json {\n\n render :json => TimeOff.joins('LEFT OUTER JOIN request_types ON time_offs.request_type_id = request_types.id')\n .joins('INNER JOIN users ON time_offs.user_id = users.id')\n .select(\n 'time_offs.id,\n time_offs.request_start_date,\n time_offs.request_end_date,\n time_offs.status,\n time_offs.comments,\n users.name as users_name,\n request_types.name as request_type_name') }\n end\n end", "def index\n @timers = Timer.all\n @load_push = true\n\n @write_right = userCould :timer\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timers }\n end\n end", "def index\n @trip_schedules = TripSchedule.all\n end" ]
[ "0.66211087", "0.63165516", "0.6313331", "0.6311019", "0.62858325", "0.6283367", "0.62432575", "0.6238713", "0.62150556", "0.6213193", "0.6212546", "0.6203579", "0.62031066", "0.616202", "0.61575663", "0.6142375", "0.61341816", "0.612905", "0.6113712", "0.6113712", "0.6102728", "0.6096498", "0.60754645", "0.6056405", "0.6045273", "0.60075766", "0.59995395", "0.59892344", "0.5986988", "0.59824556", "0.59811115", "0.5979923", "0.59673095", "0.5949065", "0.59384114", "0.5935644", "0.5931015", "0.5922557", "0.5921649", "0.5914588", "0.590357", "0.58898044", "0.5887441", "0.58829236", "0.5880038", "0.58720446", "0.58717144", "0.5867209", "0.5861266", "0.5859719", "0.58573174", "0.5850239", "0.58498895", "0.58401", "0.5835706", "0.5822799", "0.58211184", "0.58150584", "0.5803993", "0.5800533", "0.5787348", "0.57797897", "0.5775032", "0.57629585", "0.5759606", "0.5758356", "0.5756584", "0.575208", "0.57422143", "0.5740982", "0.57385874", "0.5735396", "0.57230955", "0.5720771", "0.5719829", "0.571978", "0.57144105", "0.5708345", "0.5706722", "0.5705671", "0.5705125", "0.57041544", "0.5703877", "0.56931394", "0.5692799", "0.56902176", "0.5686381", "0.56817585", "0.5676591", "0.5673124", "0.5671317", "0.56708896", "0.5670852", "0.56707865", "0.56703115", "0.56642365", "0.5662852", "0.5659484", "0.56556964", "0.56491315" ]
0.75969326
0
GET /stay_times/1 GET /stay_times/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @stay_times = StayTime.all\n end", "def show\n @time_gap = TimeGap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_gap }\n end\n end", "def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end", "def index\n render json: {time: Time.now}\n end", "def show\n render json: @timer\n end", "def show\n @working_time = WorkingTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @working_time }\n end\n end", "def show\n @stop_time = StopTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stop_time }\n end\n end", "def index\n @time_entry ||= current_user.time_entries.build(\n :tdate => Date.today\n )\n \n @time_entries = current_firm.all_time_entries\n\n respond_to do |format|\n format.html { render :index }# index.html.erb\n format.json { render json: @time_entries }\n end\n end", "def index\n @mealtimes = Mealtime.all\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clock_time }\n end\n end", "def show\n @meal_time = MealTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meal_time }\n end\n end", "def show\n render :json => @timecard.to_json(:include => :time_entry), status: :ok\n end", "def hours\n render json: Pings::Selector.new.hours(params)\n end", "def show\n @service_time = ServiceTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service_time }\n end\n end", "def show\n\n trip = Trip.find(params[:id])\n\n departureOrder = LineStation.find_by_station_id(trip.departureStation_id).order\n arrivalOrder = LineStation.find_by_station_id(trip.arrivalStation_id).order\n\n lineStations = LineStation.where(:order => departureOrder..arrivalOrder)\n lineStations = lineStations.where(:line_id => trip.line_id)\n if departureOrder < arrivalOrder\n lineStations.order('order ASC')\n else\n lineStations.order('order DESC')\n end\n\n times = Array.new\n currentTime = trip.beginTime\n lineStations.each do |ls|\n \n station = Station.find(ls.station_id)\n train = Train.find(trip.train_id)\n\n times << { :station => station, :time => currentTime.strftime('%H:%M') }\n\n timeElapsed = ls.distance.to_f / train.velocity\n currentTime = currentTime + timeElapsed.hours\n end\n\n render :json => { :trip => trip, :times => times }\n\n end", "def index\n\n @hurdle_times = HurdleTime.order('time, hurdle_match_id, lane')\n\n if params[:hurdle_match_id]\n @hurdle_times = @hurdle_times.where(:hurdle_match_id => params[:hurdle_match_id])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hurdle_times }\n end\n end", "def show\n @hurdle_time = HurdleTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hurdle_time }\n end\n end", "def open_appointments\n date = Date.parse(params[:date])\n clinic = Clinic.find(params[:clinic_id])\n doctor = Doctor.find(params[:doctor_id])\n # @times = doctor.open_appointment_times(date)\n @times = clinic.open_appointment_times(date, doctor)\n if @times.is_a?(Hash)\n render json: {status: 1, error: @times[:error]}\n else\n render json: { status: 0, times: @times }\n end\n #@appointment = Appointment.new\n #render json: {open_times: @open_times}\n # render json: {times: [\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\n\n end", "def index\n @timers = Timer.all\n\n render json: @timers\n end", "def show\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_off_request }\n end\n end", "def index\n @tea_times = TeaTime.all\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n format.json { render json: @tea_times }\n end\n end", "def index\n schedules = Schedule.where(trip_id: params[:trip_id])\n respond_with schedules\n end", "def show\n @timer = Timer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timer }\n end\n end", "def show\n @wait_time = WaitTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wait_time }\n end\n end", "def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end", "def show\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_entry }\n end\n end", "def show\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_entry }\n end\n end", "def show\n @timetable = Timetable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timetable }\n end\n end", "def show\n @timetable = Timetable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timetable }\n end\n end", "def show\n @my_time_trial = MyTimeTrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @my_time_trial }\n end\n end", "def index\n @timecards = TimeCard.all\n render :json => @timecards.to_json(:include => :time_entry), status: :ok\n end", "def show\n @nursing_time = NursingTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nursing_time }\n end\n end", "def index\n @clock = @employee.clock_in_out\n render json: @clock\n end", "def show\n @time_log = TimeLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_log }\n end\n end", "def show\n @one_time_stop = OneTimeStop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @one_time_stop }\n end\n end", "def index\n @timeslots = Timeslot.all\n end", "def index\n @timeslots = Timeslot.all\n end", "def index\n @timetables = Timetable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timetables }\n end\n end", "def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end", "def index\n @location_times = LocationTime.all\n end", "def show\n @time_slot = TimeSlot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_slot }\n end\n end", "def show\n @clinic_timing = ClinicTiming.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinic_timing }\n end\n end", "def index\n @timings = Timing.all\n end", "def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end", "def index\n date_range = unix_date(params[:date])\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\n # render :json => @timeslots.as_json(only: [])\n end", "def show\n @student = Student.find(params[:id])\n @times = times\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end", "def show\n @where_to_stay = WhereToStay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @where_to_stay }\n end\n end", "def index\n @appointments = Appointment.all \n render json: @appointments\n end", "def index\n @vehicle_realtimes = VehicleRealtime.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\n end\n end", "def show\n @timeentry = Timeentry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timeentry }\n end\n end", "def index\r\n @clocks = ClockResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @clocks }\r\n end\r\n end", "def index\n @jobtimes = current_company.jobtimes.find_all_by_job_id(params[:job_id])\n respond_to do |format|\n format.xml {render :xml => @jobtimes }\n format.json { render :json => @jobtimes }\n end\n end", "def index\n @hours = Hour.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hours }\n end\n end", "def show\n @time_record = TimeRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_record }\n end\n end", "def show\n @time_record = TimeRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_record }\n end\n end", "def index\n @working_start_times = WorkingStartTime.all\n end", "def show\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daytime }\n end\n end", "def show\n @restaurant = Restaurant.find(params[:id])\n @reservation = Reservation.new\n @image_tag_string = \"/assets/slideshow-rest.jpg\"\n\n @google_map = \"http://maps.google.com/maps/api/staticmap?key=AIzaSyC77WBfl-zki0vS7h9zyKyYg3htKcERvuo&size=400x300\"\n @google_map << \"&markers=icon:http://i42.tinypic.com/rj2txf.png%7C#{@restaurant.lat}%2C#{@restaurant.lng}\"\n @google_map << '&sensor=false&zoom=16'\n\n @today = true\n if @restaurant.inventories.available.size >= 3\n @times = @restaurant.inventories.available.limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\n else\n @today = false\n @times = @restaurant.inventories.available((Time.zone.today + 1.day), \"00:00\").limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\n end\n\n @times = [\"18:30\",\"19:00\",\"19:30\"]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant }\n end\n end", "def show\n @schedule = Schedule.find_by_id(params[:id])\n if @schedule\n #schedule_appointments = @schedule.appointments\n render json: @schedule,status: :ok\n else\n render json: {errorMessage:\"no schedule with id: #{params[:id]}\"}, status: :not_found\n end\n end", "def index\n @cooking_times = CookingTime.all\n end", "def index\n @announces = Announce.not_finished.order(\"stime DESC\")\n\t\t@pannounces = Announce.finished.last_24_hours.limit(20).order(\"etime DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @announces }\n end\n end", "def index\n @regimes = Regime.all\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @regimes }\n # end\n end", "def show\n @planned_time = PlannedTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planned_time }\n end\n end", "def new\n @working_time = WorkingTime.new\n @working_time.time_table_id = current_user.time_tables[0].id\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @working_time }\n end\n end", "def index\n @session_times = SessionTime.all\n end", "def index\n @poi_times = PoiTime.all\n end", "def index\n streaks = Streak.active.all\n render_jsonapi(streaks)\n end", "def index\n vehicle_id = params[:vehicle_id]\n shift_date = Date.today\n\n begin\n @shifts = Shift.by_vehicle_and_date(vehicle_id, shift_date)\n rescue\n errors = \"Error\"\n render json: errors.to_json, status: 400\n return\n end\n\n respond_with(@shifts)\n\n # render json: trips, status: :ok\n end", "def index\n @hour_logs = HourLog.all\n render json: @hour_logs, status: 200\n end", "def index\n render json: meeting.all\n end", "def index\n @allocated_times = AllocatedTime.all\n end", "def create\n @stay_time = StayTime.new(stay_time_params)\n\n respond_to do |format|\n if @stay_time.save\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' }\n format.json { render :show, status: :created, location: @stay_time }\n else\n format.html { render :new }\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @offset_time = OffsetTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offset_time }\n end\n end", "def show\n @planning_time = PlanningTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planning_time }\n end\n end", "def new\n @time_gap = TimeGap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_gap }\n end\n end", "def show\n @receiver_time = ReceiverTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receiver_time }\n end\n end", "def show\n @time_section = TimeSection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_section }\n end\n end", "def index\n @times_games = TimesGame.all\n end", "def index\n @timecard = Timecard.find(params[:timecard_id])\n render :json => Hour.timecard_hours(@timecard)\n end", "def query_times_graphs\n controller = params[:controller_name]\n action = params[:action_name]\n data = redis(logger: true).zrangebyscore(\"request_timings/total/by_action/#{controller}##{action}\",\n 1.month.ago.to_i, '+inf',\n with_scores: true)\n .map { |y, x| [x.to_f, y.to_f] }\n throw 'No Data' if data.nil? || data.empty?\n smoothed = moving_avg(data)\n final = (params[:raw].present? ? data : smoothed).map { |x, y| [Time.at(x.to_i).to_datetime, y] }\n render json: [\n { name: 'Timings', data: final }\n ]\n end", "def index\n @time_of_days = TimeOfDay.all\n end", "def index\n @meeting_times = MeetingTime.order(:time).all\n end", "def get_data_for_time_span()\n set_schedule_query_params\n\n @t1 = Time.at(@t1.to_i)\n @t2 = Time.at(@t2.to_i)\n\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\n\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\n\n json_adjustments\n end", "def index\n @p_times = PTime.all\n end", "def show\n @hotel_stay = HotelStay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotel_stay }\n end\n end", "def index\n @section_times = SectionTime.all\n end", "def station_times(name, mins)\n ier = IERailGet.new(\"getStationDataByNameXML_withNumMins?StationDesc=#{name}&NumMins=#{mins}\", \"arrayofobjstationdata\", \"objstationdata\")\n \n ier.response.map { |sd| StationData.new(sd) }\n end", "def index\n @day_timeslots = DayTimeslot.all\n end", "def index\n @class_times = ClassTime.all\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_frame }\n end\n end", "def new\n @my_time_trial = MyTimeTrial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @my_time_trial }\n end\n end", "def index\n @wait_times = WaitTime.all\n end", "def show\n @time_track = TimeTrack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_track }\n end\n end", "def show\n @time_point = TimePoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_point }\n end\n end", "def index\n respond_to do |format|\n format.html\n format.json {\n\n render :json => TimeOff.joins('LEFT OUTER JOIN request_types ON time_offs.request_type_id = request_types.id')\n .joins('INNER JOIN users ON time_offs.user_id = users.id')\n .select(\n 'time_offs.id,\n time_offs.request_start_date,\n time_offs.request_end_date,\n time_offs.status,\n time_offs.comments,\n users.name as users_name,\n request_types.name as request_type_name') }\n end\n end", "def index\n #@shifts = Shift.all\n @shifts = Shift.where(tenant_id: current_tenant.id)\n render json: {\n message: 'Your Shift',\n shifttransaction: @shift\n }\n end", "def chatting_time(*args)\n @client.get \"#{@path}/chatting_time\", Hash[*args]\n end", "def show\n @breadcrumb = 'read'\n @time_record = TimeRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_record }\n end\n end", "def index\n trips = Trip.all\n render json: trips\n end", "def index\n set_user\n @time_offs = TimeOff.all\n end", "def index\n @scheduled_appointments = ScheduledAppointment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scheduled_appointments }\n end\n end" ]
[ "0.7261846", "0.66732365", "0.6581946", "0.6489677", "0.64342993", "0.63616824", "0.6351887", "0.63425845", "0.6285759", "0.6273774", "0.62598795", "0.6255119", "0.6237478", "0.6222978", "0.6222819", "0.6222181", "0.6218224", "0.61824906", "0.617852", "0.61682594", "0.6140876", "0.613861", "0.6134875", "0.61264247", "0.61250496", "0.6123458", "0.6123458", "0.61207294", "0.61207294", "0.61146325", "0.6087947", "0.6071389", "0.607096", "0.60696346", "0.6060806", "0.6050552", "0.6050552", "0.6044928", "0.6032198", "0.60087717", "0.60036755", "0.5992558", "0.5988538", "0.5982633", "0.5966836", "0.59623057", "0.5960554", "0.5954478", "0.59444714", "0.59372807", "0.5917964", "0.59162", "0.5908882", "0.59045666", "0.59045666", "0.589154", "0.5891122", "0.58701503", "0.58604354", "0.58587116", "0.58564943", "0.5854692", "0.5851696", "0.5851195", "0.58459073", "0.5844174", "0.5834008", "0.5827395", "0.58242035", "0.58200246", "0.58158904", "0.5812353", "0.5812084", "0.58070534", "0.5806551", "0.5796599", "0.57933366", "0.5793268", "0.57913387", "0.57791203", "0.57759553", "0.5775642", "0.57737696", "0.57536083", "0.57488555", "0.5743656", "0.5743358", "0.5742512", "0.57380706", "0.5731987", "0.5730328", "0.5725145", "0.57240796", "0.5723337", "0.57160664", "0.57144946", "0.57076985", "0.57060075", "0.5699461", "0.5695938", "0.56943196" ]
0.0
-1
POST /stay_times POST /stay_times.json
def create @stay_time = StayTime.new(stay_time_params) respond_to do |format| if @stay_time.save format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' } format.json { render :show, status: :created, location: @stay_time } else format.html { render :new } format.json { render json: @stay_time.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stay_time_params\n params.require(:stay_time).permit(:arrive_date, :leave_date, :nationality, :country_stay, :day_stay)\n end", "def index\n @stay_times = StayTime.all\n end", "def create\n @timing = Timing.new(params[:timing].slice(:start, :stop, :days, :parent_class, :parent_id, :active))\n if @timing.save\n render json: @timing\n else\n render json: { error: 'error: could not save timing' }\n end\n end", "def create\n @time_gap = TimeGap.new(params[:time_gap])\n\n respond_to do |format|\n if @time_gap.save\n format.html { redirect_to @time_gap, notice: 'Time gap was successfully created.' }\n format.json { render json: @time_gap, status: :created, location: @time_gap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_gap.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n busy_shifts = params[:busy_shift]\n if busy_shifts\n busy_shifts[:day].length.times do |index|\n day = busy_shifts[:day][index]\n start_time = busy_shifts[:start_time][index]\n end_time = busy_shifts[:end_time][index]\n @busy_shifts = current_user.busy_shifts.create(:day => day, :start_time => start_time, :end_time => end_time)\n end\n render json: current_user.busy_shifts\n else\n render json: {errors: \"Could not create busy shifts there was a error\"}\n end\n end", "def create\n cnt = params[:tutor_availability][:repeat].to_i - 1\n params[:tutor_availability].delete :repeat\n @tutor_availability = TutorAvailability.new(params[:tutor_availability])\n\n respond_to do |format|\n if @tutor_availability.save\n if cnt > 0\n for i in 1..cnt\n new_ta = TutorAvailability.new(params[:tutor_availability])\n new_ta.start_time = @tutor_availability.start_time + 604800*i\n new_ta.save\n end\n end\n format.html { redirect_to tutor_availabilities_path, notice: 'Tutor availability was successfully created.' }\n format.json { render json: @tutor_availability, status: :created, location: @tutor_availability }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutor_availability.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end", "def create\n @working_time = WorkingTime.new(params[:working_time])\n\n respond_to do |format|\n if current_user.time_tables[0].working_times << @working_time\n format.html { redirect_to time_tables_path }\n format.json { render json: @working_time, status: :created, location: @working_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @working_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @patient = Patient.find(params[:patient_id])\n @schedule = @patient.schedules.create(params[:schedule])\n\n # TODO can improve it to use nested attributes\n params[:pill_time].each do |pill_time|\n @schedule.pill_times.build(pill_time)\n end\n\n @pill_times = @schedule.pill_times\n\n respond_to do |format|\n if @schedule.save\n format.html { redirect_to [@patient, @schedule],\n notice: 'Schedule was successfully created.' }\n format.json { render json: @schedule,\n status: :created,\n location: [@patient, @schedule] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workSegment = @workday.workSegments.last\n puts @workSegment.workday.dayDate\n # if @workSegment.timePunches.count == 0\n # @currentStatus = false\n # else\n # @lastTimePunch = @workSegment.timePunches.last\n # @currentStatus = @lastTimePunch.status\n # end\n\n @time_punch = @workSegment.timePunches.new(punch: Time.current, status: true)\n\n respond_to do |format|\n if @time_punch.save\n format.html { redirect_to dashboard_path, notice: 'Time punch was successfully created.' }\n # format.json { render :show, status: :created, location: @time_punch }\n else\n format.html { redirect_to dashboard_path, notice: 'clock record was not created(from tp controller).' }\n # format.json { render json: @time_punch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_tracker = TimeTracker.new({ started_at: Time.current, status: 'running' }.merge(time_tracker_params))\n\n respond_to do |format|\n if @time_tracker.save\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully created.' }\n format.json { render :show, status: :created, location: @time_tracker }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @timeslot = Timeslot.new(timeslot_params)\n @timeslot.save!\n render :json => @timeslot.as_json\n end", "def create\n @stime = Stime.new(stime_params)\n\n respond_to do |format|\n if @stime.save\n format.html { redirect_to @stime, notice: 'Stime was successfully created.' }\n format.json { render :show, status: :created, location: @stime }\n else\n format.html { render :new }\n format.json { render json: @stime.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cooking_time = CookingTime.new(cooking_time_params)\n\n respond_to do |format|\n if @cooking_time.save\n format.html { redirect_to cooking_times_path, notice: 'Cooking time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cooking_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @cooking_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @allocated_time = AllocatedTime.new(allocated_time_params)\n\n respond_to do |format|\n if @allocated_time.save\n format.html { redirect_to @allocated_time, notice: 'Allocated time was successfully created.' }\n format.json { render :show, status: :created, location: @allocated_time }\n else\n format.html { render :new }\n format.json { render json: @allocated_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def open_appointments\n date = Date.parse(params[:date])\n clinic = Clinic.find(params[:clinic_id])\n doctor = Doctor.find(params[:doctor_id])\n # @times = doctor.open_appointment_times(date)\n @times = clinic.open_appointment_times(date, doctor)\n if @times.is_a?(Hash)\n render json: {status: 1, error: @times[:error]}\n else\n render json: { status: 0, times: @times }\n end\n #@appointment = Appointment.new\n #render json: {open_times: @open_times}\n # render json: {times: [\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\n\n end", "def create\n @work_time = WorkTime.new(work_time_params)\n\n respond_to do |format|\n if @work_time.save\n format.html { redirect_to @work_time, notice: 'Work time was successfully created.' }\n format.json { render :show, status: :created, location: @work_time }\n else\n format.html { render :new }\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_time_request\n TimeRequest.create(\n time: [ Time.new(2000, 1, 1, 14, 0, 0, \"+00:00\").utc, Time.new(2000, 1, 1, 13, 0, 0, \"+00:00\").utc, Time.new(2000, 1, 1, 12, 0, 0, \"+00:00\").utc ].sample,\n reservation: Reservation.all.sample,\n check_in: [true, false].sample,\n status: 'pending'\n )\nend", "def create\n @wait_time = WaitTime.new(params[:wait_time])\n\n respond_to do |format|\n if @wait_time.save\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully created.' }\n format.json { render json: @wait_time, status: :created, location: @wait_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stay_time.update(stay_time_params)\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully updated.' }\n format.json { render :show, status: :ok, location: @stay_time }\n else\n format.html { render :edit }\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @stop_time = StopTime.new(params[:stop_time])\n\n respond_to do |format|\n if @stop_time.save\n format.html { redirect_to @stop_time, notice: 'Stop time was successfully created.' }\n format.json { render json: @stop_time, status: :created, location: @stop_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stop_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @wait_time = WaitTime.new(wait_time_params)\n\n respond_to do |format|\n if @wait_time.save\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully created.' }\n format.json { render :show, status: :created, location: @wait_time }\n else\n format.html { render :new }\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meal_time = MealTime.new(params[:meal_time])\n\n respond_to do |format|\n if @meal_time.save\n format.html { redirect_to @meal_time, notice: 'Meal time was successfully created.' }\n format.json { render json: @meal_time, status: :created, location: @meal_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meal_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_registration = TimeRegistration.create(time_registration_params)\n respond_to do |format|\n if @time_registration.save\n format.json { render :show, status: :created, location: @time_registration }\n else\n format.json { render json: @time_registration.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_of_day = TimeOfDay.new(time_of_day_params)\n\n respond_to do |format|\n if @time_of_day.save\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully created.' }\n format.json { render :show, status: :created, location: @time_of_day }\n else\n format.html { render :new }\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @downtime = Downtime.new(downtime_params)\n\n respond_to do |format|\n if @downtime.save\n format.html { redirect_to @downtime, notice: 'Downtime was successfully created.' }\n format.json { render action: 'show', status: :created, location: @downtime }\n else\n format.html { render action: 'new' }\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting_time = MeetingTime.new(meeting_time_params)\n\n respond_to do |format|\n if @meeting_time.save\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @meeting_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def postEntityOpening_times( entity_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, closed, closed_public_holidays)\n params = Hash.new\n params['entity_id'] = entity_id\n params['monday'] = monday\n params['tuesday'] = tuesday\n params['wednesday'] = wednesday\n params['thursday'] = thursday\n params['friday'] = friday\n params['saturday'] = saturday\n params['sunday'] = sunday\n params['closed'] = closed\n params['closed_public_holidays'] = closed_public_holidays\n return doCurl(\"post\",\"/entity/opening_times\",params)\n end", "def stay_night_params\n params.require(:stay_night).permit(:today, :city_id, :hotel_id, :rate, :comment)\n end", "def create\n @nursing_time = NursingTime.new(params[:nursing_time])\n\n respond_to do |format|\n if @nursing_time.save\n format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully created.' }\n format.json { render json: @nursing_time, status: :created, location: @nursing_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nursing_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_slot = TimeSlot.new(time_slot_params)\n\n if @time_slot.save\n render :show, status: :created, location: @time_slot\n else\n render json: @time_slot.errors, status: :unprocessable_entity\n end\n end", "def create\n @timing = Timing.new(timing_params)\n\n if @timing.save\n render :show, status: :created, location: @timing\n else\n render json: @timing.errors, status: :unprocessable_entity\n end\n end", "def create\n @punchtime = current_user.punchtimes.build(punchtime_params)\n respond_to do |format|\n if @punchtime.save\n format.html { redirect_to( current_user, notice: 'Punchtime was successfully created.') }\n format.json { render :show, status: :created, location: @punchtime }\n else\n format.html { render :new }\n format.json { render json: @punchtime.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_slot = TimeSlot.new(params[:time_slot])\n @time_slot.user_id = current_identity.user_id\n\t@recurrence_array = []\n respond_to do |format|\n if @time_slot.save\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully created.' }\n format.json { render json: @time_slot, status: :created, location: @time_slot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end", "def stime_params\n params.require(:stime).permit(:time, :meet_id, :swimmer_id, :stroke_id)\n end", "def create\n @work_order_time = WorkOrderTime.new(work_order_time_params)\n\n respond_to do |format|\n if @work_order_time.save\n format.html { redirect_to @work_order_time, notice: 'Work order time was successfully created.' }\n format.json { render :show, status: :created, location: @work_order_time }\n else\n format.html { render :new }\n format.json { render json: @work_order_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @service_time = ServiceTime.new(params[:service_time])\n\n respond_to do |format|\n if @service_time.save\n format.html { redirect_to @service_time, notice: 'Service time was successfully created.' }\n format.json { render json: @service_time, status: :created, location: @service_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @service_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @timeslot = Timeslot.new(timeslot_params)\n\n if @timeslot.save\n render :show, status: :created, location: @timeslot\n else\n render json: @timeslot.errors, status: :unprocessable_entity\n end\n end", "def create\n @my_time_trial = MyTimeTrial.new(params[:my_time_trial])\n\n respond_to do |format|\n if @my_time_trial.save\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully created.' }\n format.json { render :json => @my_time_trial, :status => :created, :location => @my_time_trial }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def maketime\n\n openingtime = OpeningTime.new do |u|\n u.day = params[:opening_times][:day]\n u.from = \"9:00\"\n u.to = \"12 Noon\"\n u.on = true\n u.position = params[:opening_times][:position]\n \n \n end\n openingtime.save\n redirect_to \"/\"\n end", "def create\n @time_slot = TimeSlot.create(time_slot_params)\n\n respond_to do |format|\n if @time_slot.save\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully created.' }\n format.json { render :show, status: :created, location: @time_slot }\n else\n format.html { render :new }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @time_gap = TimeGap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_gap }\n end\n end", "def create\n @tombstone_timehold = TombstoneTimehold.new(tombstone_timehold_params)\n\n respond_to do |format|\n if @tombstone_timehold.save\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully created.' }\n format.json { render :show, status: :created, location: @tombstone_timehold }\n else\n format.html { render :new }\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @p_time = PTime.new(p_time_params)\n\n respond_to do |format|\n if @p_time.save\n format.html { redirect_to @p_time, notice: 'P time was successfully created.' }\n format.json { render :show, status: :created, location: @p_time }\n else\n format.html { render :new }\n format.json { render json: @p_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_clock = TimeClock.new(time_clock_params)\n\n respond_to do |format|\n if @time_clock.save\n format.html { redirect_to time_sheet_index_path(@time_clock), notice: 'Time clock entry was successfully created.' }\n format.json { render action: 'show', status: :created, location: @time_clock }\n else\n format.html { render action: 'new' }\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ride = Ride.new(ride_params)\n @ride.assembly_time = params[:ride][:assembly_time]\n @ride.destination_time = params[:ride][:destination_time]\n @ride.check_points = params[:ride][:check_points]\n if @ride.save\n @ride.delay.call_notification(I18n.t('Notification.ride_created'), I18n.t('Email.ride_created'))\n render json: @ride, status: :created\n else\n render json: @ride.errors, status: :unprocessable_entity\n end\n end", "def create\n @schedule = Schedule.new(params[:schedule])\n times =[]\n count_days = 0\n days = params[:day].join(\", \") if params[:day]\n (0..6).each do |i|\n if params[:hour][i].present? && params[:minute][i].present?\n times<< \"#{params[:hour][i]}:#{ params[:minute][i]}\"\n end\n end\n\n count_days = params[:day].count if params[:day]\n count_times = times.count\n\n if count_days == count_times\n\n if count_days && count_times != 0\n times = times.join(\", \")\n @schedule.day = days\n @schedule.time = times\n end\n respond_to do |format|\n if @schedule.save\n format.html { redirect_to @schedule, notice: 'Schedule was successfully created.' }\n format.json { render json: @schedule, status: :created, location: @schedule }\n else\n format.html { render action: \"new\" }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n\n else\n #redirect_to new_schedule_path, notice: \"даныне введены некорректно (день-время)\"\n render action: \"new\"\n end\n end", "def create\n @day_timeslot = DayTimeslot.new(day_timeslot_params)\n\n respond_to do |format|\n if @day_timeslot.save\n format.html { redirect_to @day_timeslot, notice: 'Day timeslot was successfully created.' }\n format.json { render action: 'show', status: :created, location: @day_timeslot }\n else\n format.html { render action: 'new' }\n format.json { render json: @day_timeslot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @planned_time = PlannedTime.new(params[:planned_time])\n\n respond_to do |format|\n if @planned_time.save\n format.html { redirect_to @planned_time, notice: 'Planned time was successfully created.' }\n format.json { render json: @planned_time, status: :created, location: @planned_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @planned_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @timeslot = Timeslot.new(timeslot_params)\n @current_faculty = Faculty.where(email: current_user.email).first\n @timeslot.faculty_id = @current_faculty.id\n @timeslot.title = \"Timeslot Available for #{@current_faculty.full_name}\"\n @timeslot.end = (@timeslot.start.to_time + 1.hours).to_datetime\n @timeslot.save\n\n respond_to do |format|\n if @timeslot.save\n format.json {render :json => @timeslot}\n else\n format.json {render :status => 400}\n end\n end\n end", "def create\n @time_entry = TimeEntry.new(time_entry_params)\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render :show, status: :created, location: @time_entry }\n else\n format.html { render :new }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @time_entry ||= current_user.time_entries.build(\n :tdate => Date.today\n )\n \n @time_entries = current_firm.all_time_entries\n\n respond_to do |format|\n format.html { render :index }# index.html.erb\n format.json { render json: @time_entries }\n end\n end", "def create\n @timetable = Timetable.new(params[:timetable])\n\n respond_to do |format|\n if @timetable.save\n format.html { redirect_to @timetable, notice: 'Timetable was successfully created.' }\n format.json { render json: @timetable, status: :created, location: @timetable }\n else\n format.html { render action: \"new\" }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_entry = TimeEntry.new(params[:time_entry])\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render json: @time_entry, status: :created, location: @time_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_entry = TimeEntry.new(params[:time_entry])\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render json: @time_entry, status: :created, location: @time_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_entry = TimeEntry.new(params[:time_entry])\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render json: @time_entry, status: :created, location: @time_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @timer = Timer.new(timer_params)\n\n if @timer.save\n render json: @timer, status: :created, location: @timer\n else\n render json: @timer.errors, status: :unprocessable_entity\n end\n end", "def new\n @patient = Patient.find(params[:patient_id])\n current_schedule = @patient.current_schedule\n if current_schedule\n current_schedule.terminated_at = Date.today\n current_schedule.save\n end\n @schedule = @patient.schedules.build\n @pill_times = [@schedule.pill_times.build]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @schedule }\n end\n end", "def destroy\n @stay_time.destroy\n respond_to do |format|\n format.html { redirect_to stay_times_url, notice: 'Stay time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @session_time = SessionTime.new(session_time_params)\n\n respond_to do |format|\n if @session_time.save\n format.html { redirect_to @session_time, notice: 'Session time was successfully created.' }\n format.json { render :show, status: :created, location: @session_time }\n else\n format.html { render :new }\n format.json { render json: @session_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n \t\t\t@teetime = Teetime.new teetime_params\n\n \t\t\tif @teetime.save\n\n \t\t\t\trender json: @teetime,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend", "def create\n @location_time = LocationTime.new(location_time_params)\n\n respond_to do |format|\n if @location_time.save\n format.html { redirect_to @location_time, notice: 'Location time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @location_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @location_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @poi_time = PoiTime.new(poi_time_params)\n\n respond_to do |format|\n if @poi_time.save\n format.html { redirect_to @poi_time, notice: 'Poi time was successfully created.' }\n format.json { render :show, status: :created, location: @poi_time }\n else\n format.html { render :new }\n format.json { render json: @poi_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_record = WorkTimeRecord.new(time_record_params)\n\n respond_to do |format|\n if @time_record.save\n format.html { redirect_to @time_record, notice: 'Time record was successfully created.' }\n format.json { render :show, status: :created, location: @time_record }\n else\n format.html { render :new }\n format.json { render json: @time_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @timed_task = TimedTask.new(timed_task_params)\n\n respond_to do |format|\n if @timed_task.save\n format.html { redirect_to @timed_task, notice: 'Timed task was successfully created.' }\n format.json { render :show, status: :created, location: @timed_task }\n else\n format.html { render :new }\n format.json { render json: @timed_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @timeslot = current_event.timeslots.new(params[:timeslot])\n \n respond_to do |format|\n if @timeslot.save\n flash[:notice] = 'Timeslot was successfully created.'\n format.html { redirect_to(timeslots_url) }\n format.xml { render :xml => @timeslot, :status => :created, :location => @timeslot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @timeslot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n description = params[:description]\n \n timestamp = params[:timestamp]\n total_sleep_seconds = params[:total_sleep]\n deep_sleep_seconds = params[:deep]\n light_sleep_seconds = params[:light]\n awake_seconds = params[:awake]\n \n if timestamp.nil? || total_sleep_seconds.nil?\n \n puts 'timestamp is nil or total_sleep_seconds is nil :('\n \n else\n \n total_sleep = total_sleep_seconds / 60.0\n deep = deep_sleep_seconds / 60.0\n light = light_sleep_seconds / 60.0\n awake = awake_seconds / 60.0\n \n post_to_twitter = false\n post_to_facebook = false\n \n # FellAsleepAt is formatted: August 23, 2013 at 11:01PM\n # Convert to Runkeeper's preferred format: Sat, 1 Jan 2011 00:00:00\n timestamp_datetime = DateTime.parse(timestamp)\n formatted_timestamp = timestamp_datetime.strftime(\"%a, %d %b %Y %H:%M:%S\")\n \n json_hash['timestamp'] = formatted_timestamp\n json_hash['total_sleep'] = deep\n json_hash['deep'] = deep\n json_hash['light'] = light\n json_hash['awake'] = awake\n json_hash['post_to_twitter'] = post_to_twitter\n json_hash['post_to_facebook'] = post_to_facebook\n \n url = 'https://api.runkeeper.com/sleep'\n \n uri = URI.parse(url)\n \n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri)\n request[\"Authorization\"] = \"Bearer \" + RUNKEEPER_ACCESS_TOKEN\n request[\"Content-Type\"] = \"application/vnd.com.runkeeper.NewSleep+json\"\n request.body = json_hash.to_json\n \n response = http.request(request)\n \n puts response.body\n \n end\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n \n end", "def wait_time_params\n params.require(:wait_time).permit(:restaurant_id, :party_size, :minutes, :checked_at)\n end", "def trip_params\n params.require(:trip).permit(:starts_on, :ends_on, :name, :location, {:item_ids => []})\n end", "def create\n @time_record = TimeRecord.new(params[:time_record])\n @time_record.value = (@time_record.ended_at - @time_record.started_at) / 1.hour\n @time_record.recorded_on = @time_record.started_at.to_date\n\n respond_to do |format|\n if @time_record.save\n format.html { redirect_to time_records_path, notice: 'Time record was successfully created.' }\n format.json { render json: @time_record.to_json, status: :created, location: @time_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_record.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def times_game_params\n params.require(:times_game).permit(:point, :sta)\n end", "def tombstone_timehold_params\n params.require(:tombstone_timehold).permit(:tombstoneJSON, :permanent, :rating)\n end", "def create\n @planning_time = PlanningTime.new(params[:planning_time])\n\n respond_to do |format|\n if @planning_time.save\n format.html { redirect_to @planning_time, notice: 'Planning time was successfully created.' }\n format.json { render json: @planning_time, status: :created, location: @planning_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @planning_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n attendance_params[:checkin] = attendance_params[:checkin].to_time\n attendance_params[:checkout] = attendance_params[:checkout].to_time\n attendance_params[:attendance_date] = attendance_params[:attendance_date].to_date\n\n r = @api.create_attendance(attendance_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to attendances_url, notice: 'Attendance was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to attendances_url, alert: response['message']}\n end\n end\n end", "def create\n @timetable = Timetable.new(timetable_params)\n\n respond_to do |format|\n if @timetable.save\n format.html { redirect_to request.referer, notice: 'Timetable was successfully created.' }\n format.json { render :show, status: :created, location: @timetable }\n else\n format.html { render :new }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @working_start_time = WorkingStartTime.new(working_start_time_params)\n\n respond_to do |format|\n if @working_start_time.save\n format.html { redirect_to @working_start_time, notice: 'Working start time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @working_start_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @working_start_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_day\n trip = Trip.find(params[:id])\n offset = 0\n trip.days.all.each do |day|\n offset += 1\n end\n @day = Day.new({\"date\" => trip.beginning + offset , \"trip\" => trip})\n trip.update_attribute(:duration, trip.attributes['duration'] + 1)\n trip.save\n respond_to do |format|\n if @day.save\n format.html { redirect_to trip, notice: 'Day was successfully created.' }\n format.json { render :show, status: :created, location: @day }\n else\n format.html { render home_path }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @appointment = Appointment.new(appointment_params)\n if @appointment.starts_at != nil\n @appointment.ends_at = @appointment.starts_at + 30.minutes\n end\n respond_to do |format|\n if @appointment.save\n format.html { redirect_to new_appointment_path, notice: 'Agendamento realizado.' }\n format.json { render :show, status: :created, location: @appointment }\n else\n format.html { render :schedule }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @order_break_time = OrderBreakTime.new(order_break_time_params)\n\n respond_to do |format|\n if @order_break_time.save\n format.html { redirect_to @order_break_time, notice: 'Order break time was successfully created.' }\n format.json { render 'show', status: :created, location: @order_break_time }\n else\n format.html { render 'new' }\n format.json { render json: @order_break_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hotel_stay = HotelStay.new(params[:hotel_stay])\n\n respond_to do |format|\n if @hotel_stay.save\n format.html { redirect_to @hotel_stay, notice: 'Hotel stay was successfully created.' }\n format.json { render json: @hotel_stay, status: :created, location: @hotel_stay }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hotel_stay.errors, status: :unprocessable_entity }\n end\n end\n end", "def timecontroll_params\n params.require(:timecontroll).permit(:start, :end, :gap)\n end", "def create\n @daytime = Daytime.new(params[:daytime])\n\n respond_to do |format|\n if @daytime.save\n format.html { redirect_to @daytime, notice: 'Daytime was successfully created.' }\n format.json { render json: @daytime, status: :created, location: @daytime }\n else\n format.html { render action: \"new\" }\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @transaction = Transaction.new(transaction_params)\n @transaction.update(user_id: session[:user_id])\n @transaction.update(status: 'Scheduled')\n\n @timingsList = []\n @datesList = []\n @timings = Timing.find_by_sql(\"SELECT day, hours, minutes, ampm FROM timings\")\n @timings.each do |timing|\n timing.day = date_of_next(timing.day).strftime(\"%d %b %Y\") + \" - \" + timing.hours + \":\" + timing.minutes + \" \" + timing.ampm\n @timingsList.push([timing.day, timing.day])\n end\n for i in 0..9\n @datesList.push([(Date.today+i).strftime(\"%d %b %Y\"), (Date.today+i).strftime(\"%d %b %Y\")])\n end\n\n respond_to do |format|\n if @transaction.save\n format.html { redirect_to transactions_path, notice: 'Transaction was successfully created.' }\n format.json { render :show, status: :created, location: @transaction }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @drop_route_start_time = DropRouteStartTime.new(drop_route_start_time_params)\n\n respond_to do |format|\n if @drop_route_start_time.save\n format.html { redirect_to drop_route_start_times_path, notice: 'Drop route start time was successfully created.' }\n format.json { render :show, status: :created, location: @drop_route_start_time }\n else\n format.html { render :new }\n format.json { render json: @drop_route_start_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trip_schedule = TripSchedule.new(trip_schedule_params)\n\n respond_to do |format|\n if @trip_schedule.save\n format.html { redirect_to @trip_schedule, notice: 'Trip schedule was successfully created.' }\n format.json { render :show, status: :created, location: @trip_schedule }\n else\n format.html { render :new }\n format.json { render json: @trip_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:pay_day] && params[:start_day] && params[:end_day]\n ::TimeEntry.where(pay_day: params[:pay_day]).update_all(pay_day: nil)\n ::TimeEntry.where(\"day>=? AND day<=?\",params[:start_day],params[:end_day]).update_all(pay_day: params[:pay_day])\n end\n redirect_to \"/time/#{params[:start_day]}\"\n end", "def create\n @user = User.find(params[:user_id])\n @clock_time = @user.clock_times.new(params[:clock_time])\n\n time_in_to_update = get_time_to_update(params[\"use_current\"], params[:clock_time], \"in\")\n\n\n @clock_time.in = time_in_to_update\n\n respond_to do |format|\n if @clock_time.save\n format.html { redirect_to @user, notice: 'You have successfully clocked in' }\n format.json { render json: @clock_time, status: :created, location: @clock_time }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @clock_time.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def transit_times(shipment, options:, debug: false)\n request = FriendlyShipping::Request.new(\n url: API_BASE + API_PATHS[:transit_times],\n http_method: \"POST\",\n body: SerializeTransitTimesRequest.call(shipment: shipment, options: options).to_json,\n headers: request_headers,\n debug: debug\n )\n client.post(request).bind do |response|\n ParseTransitTimesResponse.call(request: request, response: response)\n end\n end", "def create\n @disatance_and_time = DisatanceAndTime.new(disatance_and_time_params)\n\n respond_to do |format|\n if @disatance_and_time.save\n format.html { redirect_to @disatance_and_time, notice: 'Disatance and time was successfully created.' }\n format.json { render :show, status: :created, location: @disatance_and_time }\n else\n format.html { render :new }\n format.json { render json: @disatance_and_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @selected_time = SelectedTime.new(selected_time_params)\n\n respond_to do |format|\n if @selected_time.save\n format.html { redirect_to @selected_time, notice: 'Selected time was successfully created.' }\n format.json { render :show, status: :created, location: @selected_time }\n else\n format.html { render :new }\n format.json { render json: @selected_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @start_time = params[:start_time].to_datetime.strftime(\"%Y-%m-%d %H:%M:%S\")\n @end_time = params[:end_time].to_datetime.strftime(\"%Y-%m-%d %H:%M:%S\")\n @service = params[:service_item_id]\n\n @hours = params[:hours]\n @minutes = params[:minutes]\n @seconds = params[:seconds]\n\n @quantity = @hours.to_s+':'+@minutes.to_s+':'+@seconds.to_s\n \n @jobtime = Jobtime.new(:start_time => @start_time, :end_time => @end_time,:qty => @quantity,:company_id => current_login.id,:job_id => params[:job_id],:jobsite_id => params[:jobsite_id],:customer_id => params[:customer_id],:user => current_login.name, :timetype => \"Actual Time\", :service => @service)\n \n if @jobtime.save(:validate => false)\n response_message = {:message => \"Jobtime successfully created.\", :jobtime => @jobtime}\n else\n response_message = {:message => \"Jobtime creation failed. Please try again.\"} \n end\n \n respond_to do |format|\n format.xml { render :xml => response_message }\n format.json { render :json => response_message }\n end\n end", "def jobtime_shedule\n @jobtime = Jobtime.new(params[:jobtime])\n\n @qty = @jobtime.qty.to_i.hours\n @item = Item.find(@jobtime.service)\n\n #calculate end_time\n @jobtime.end_time = @jobtime.start_time+@qty\n\n #calculate cost\n @jobtime.cost = @item.unit_cost * @qty\n\n #calculate price\n if(@jobtime.billable.present?)\n @jobtime.price = @item.unit_price * @qty\n else\n @jobtime.price = 0\n end\n puts @jobtime.errors.inspect\n if @jobtime.save\n response_message = {:message => \"Time was scheduled successfully.\",:jobtime => @jobtime }\n else\n response_message = {:message => \"Please try again.\"}\n end\n respond_to do |format|\n format.xml{render :xml => response_message }\n format.json{render :json => response_message }\n end\n end", "def new\n @travel_datum = TravelDatum.new\n @travel_datum.start_time = Time.now.beginning_of_day + 9.hours\n @travel_datum.end_of_business_time = Time.now.beginning_of_day+17.hours\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @travel_datum }\n format.xml { render :xml => @travel_data }\n end\n end", "def create\n @trip = Trip.new(trip_params)\n @trip.session_id = session.id\n @trip.user_id = current_user.id\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip.parent || @trip, notice: 'Trip was successfully created.', change: 'list' }\n format.json { render action: 'show', status: :created, location: @trip, day: 1 }\n else\n format.html { render action: 'new' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @receiver_time = ReceiverTime.new(params[:receiver_time])\n\n respond_to do |format|\n if @receiver_time.save\n format.html { redirect_to @receiver_time, notice: 'Receiver time was successfully created.' }\n format.json { render json: @receiver_time, status: :created, location: @receiver_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @receiver_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def lession_time_params\n params.require(:lession_time).permit(:day, :start_at, :end_at)\n end", "def outing_params\n params.require(:outing).permit(:day, :location_id, :time)\n end", "def create\n @time_table = TimeTable.new(time_table_params)\n \n session.delete(:return_to)\n session[:return_to] ||= request.referer\n\n respond_to do |format|\n if @time_table.save\n format.html { redirect_to session.delete(:return_to), notice: 'Time table was successfully created.' }\n format.json { render :show, status: :created, location: @time_table }\n else\n format.html { render :new }\n format.json { render json: @time_table.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_treinador = TimeTreinador.new(time_treinador_params)\n @time_treinador.treinador = @treinador\n\n respond_to do |format|\n if @time_treinador.save\n format.html { redirect_to @time_treinador, notice: 'Time criado com sucesso' }\n format.json { render :show, status: :created, location: @time_treinador }\n else\n format.html { render :new }\n format.json { render json: @time_treinador.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n set_user\n @time_off = TimeOff.new(time_off_params)\n\n respond_to do |format|\n if @time_off.save\n format.html { redirect_to user_time_off_path(@user, @time_off), notice: 'Time off was successfully created.' }\n format.json { render action: 'show', status: :created, location: @time_off }\n else\n format.html { render action: 'new' }\n format.json { render json: @time_off.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6601063", "0.6519595", "0.62858284", "0.6268728", "0.6266317", "0.62011385", "0.617307", "0.6168958", "0.6111555", "0.60858476", "0.60694796", "0.6050281", "0.6019576", "0.60107577", "0.5925939", "0.5908032", "0.5900547", "0.58972186", "0.5892104", "0.5891286", "0.5875553", "0.58427113", "0.5817103", "0.58074206", "0.58049953", "0.5779078", "0.57777137", "0.57768315", "0.5767359", "0.57642305", "0.5756684", "0.57406586", "0.57384115", "0.5732428", "0.5726115", "0.5713898", "0.5711512", "0.57095164", "0.5705558", "0.57006735", "0.56968296", "0.56876373", "0.5687127", "0.566431", "0.565074", "0.5646809", "0.56417114", "0.56376374", "0.56353974", "0.56348974", "0.5634356", "0.5629803", "0.5618873", "0.5614667", "0.5614667", "0.5614667", "0.56078017", "0.56063914", "0.5604064", "0.56030947", "0.5594199", "0.558876", "0.5588386", "0.5579173", "0.55713063", "0.5569495", "0.5562344", "0.5560884", "0.55590624", "0.5551713", "0.55497605", "0.5541079", "0.55365926", "0.5536257", "0.5529784", "0.5516563", "0.5511722", "0.5510665", "0.5502391", "0.5500826", "0.54958165", "0.5480089", "0.54735965", "0.5468077", "0.5463031", "0.5461822", "0.5457979", "0.5455413", "0.54534596", "0.54481894", "0.5439358", "0.5428978", "0.5424497", "0.541937", "0.5417964", "0.541616", "0.5415978", "0.5411887", "0.54117924", "0.5410409" ]
0.7005587
0
PATCH/PUT /stay_times/1 PATCH/PUT /stay_times/1.json
def update respond_to do |format| if @stay_time.update(stay_time_params) format.html { redirect_to @stay_time, notice: 'Stay time was successfully updated.' } format.json { render :show, status: :ok, location: @stay_time } else format.html { render :edit } format.json { render json: @stay_time.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @patient = Patient.find(params[:patient_id])\n @schedule = @patient.schedules.find(params[:id])\n @pill_times = @schedule.pill_times\n\n # TODO can improve it to use nested attributes\n if params[:pill_time]\n params[:pill_time].each_with_index do |pill_time, idx|\n if @pill_times[idx]\n @pill_times[idx].update_attributes(pill_time)\n else\n @pill_times.create(pill_time)\n end\n end\n end\n\n # remove unused pill times\n if params[:pill_time]\n diff = @pill_times.size - params[:pill_time].size\n @pill_times.destroy(@pill_times.last(diff)) if diff > 0\n end\n\n respond_to do |format|\n if @schedule.update_attributes(params[:schedule])\n format.html { redirect_to [@patient, @schedule],\n notice: 'Schedule was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schedule.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_gap = TimeGap.find(params[:id])\n\n respond_to do |format|\n if @time_gap.update_attributes(params[:time_gap])\n format.html { redirect_to @time_gap, notice: 'Time gap was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_gap.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @timing = Timing.find(params[:id])\n if @timing.update_attributes(params[:timing].slice(:start, :stop, :days, :active))\n render json: @timing\n else\n render json: { error: 'error: could not update timing' }\n end\n end", "def update\n @meal_time = MealTime.find(params[:id])\n\n respond_to do |format|\n if @meal_time.update_attributes(params[:meal_time])\n format.html { redirect_to @meal_time, notice: 'Meal time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meal_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cooking_time.update(cooking_time_params)\n format.html { redirect_to cooking_times_path, notice: 'Cooking time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cooking_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @working_time = WorkingTime.find(params[:id])\n\n respond_to do |format|\n if @working_time.update_attributes(params[:working_time])\n format.html { redirect_to time_tables_path }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @working_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task.update(task_params)\n @task.whenever_reset unless task_params[:every].blank? && task_params[:at].blank?\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meeting_time.update(meeting_time_params)\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stime.update(stime_params)\n format.html { redirect_to @stime, notice: 'Stime was successfully updated.' }\n format.json { render :show, status: :ok, location: @stime }\n else\n format.html { render :edit }\n format.json { render json: @stime.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:task][:time] = parse_task_time(params[:task][:time], params[:anytime][:anytime])\n \n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(tasks_url, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @my_time_trial = MyTimeTrial.find(params[:id])\n\n respond_to do |format|\n if @my_time_trial.update_attributes(params[:my_time_trial])\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @wait_time = WaitTime.find(params[:id])\n\n respond_to do |format|\n if @wait_time.update_attributes(params[:wait_time])\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n if @time_off_request.update_attributes(params[:time_off_request])\n format.html { redirect_to admin_time_off_requests_url, notice: 'Time off request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_off_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_clock.update(time_clock_params)\n format.html { redirect_to time_sheet_index_path(@time_clock), notice: 'Time clock entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @service_time = ServiceTime.find(params[:id])\n\n respond_to do |format|\n if @service_time.update_attributes(params[:service_time])\n format.html { redirect_to @service_time, notice: 'Service time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @service_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n if @teetime.update(teetime_params)\n\n render json: @teetime,status: :ok\n\n else\n\n render json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\n\n end\n\n \t\tend", "def update\n @time_entry = current_firm.all_time_entries.find(params[:id])\n\n respond_to do |format|\n if @time_entry.update_attributes(params[:time_entry])\n format.html { redirect_to firm_time_entry_path(current_firm, @time_entry), notice: 'Time entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { index }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @timeslot.update(timeslot_params)\n render :show, status: :ok, location: @timeslot\n else\n render json: @timeslot.errors, status: :unprocessable_entity\n end\n end", "def update\n if @can_edit\n\n # Clear out all other blocks\n @timetable.free_times.destroy_all\n times = JSON::Parser.new(params[:times]).parse\n\n # There's an array for each day of the week\n times.each_with_index do |day, i|\n # Each day of the week then has a list of blocks\n day.each_with_index do |block, j|\n unless block.empty?\n # Each block has a start time and an end time for a free block\n @timetable.free_times.create(:start_time => block[0], :end_time => block[1], :day_of_week => i, :weight => block[2], :css_class => block[3])\n end\n end\n end\n\n @person ||= get_person\n @timetable.update_attributes(:updated_by_person_id => @my.id)\n @timetable.touch\n return if @signup\n\n flash[:notice] = I18n.t('timetable.save_confirm')\n\n elsif !@can_edit\n flash[:notice] = I18n.t('timetable.not_allowed_update')\n end\n\n respond_to do |format|\n format.html { redirect_to(person_timetable_path(@timetable.person, @timetable)) }\n format.js\n format.xml { head :ok }\n end\n end", "def update\n respond_to do |format|\n if @time_slot.update(time_slot_params)\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_slot }\n else\n format.html { render :edit }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @one_time_stop = OneTimeStop.find(params[:id])\n\n respond_to do |format|\n if @one_time_stop.update_attributes(params[:one_time_stop])\n format.html { redirect_to @one_time_stop, notice: 'One time stop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @one_time_stop.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @where_to_stay = WhereToStay.find(params[:id])\n\n respond_to do |format|\n if @where_to_stay.update_attributes(params[:where_to_stay])\n format.html { redirect_to @where_to_stay, notice: 'Where to stay was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @where_to_stay.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @timeslot = current_event.timeslots.find(params[:id])\n respond_to do |format|\n @timeslot.start_time_will_change!\n @timeslot.slot_date_will_change!\n if @timeslot.update_attributes(params[:timeslot])\n flash[:notice] = \"Timeslot was successfully updated.\"\n format.html { redirect_to(timeslots_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @timeslot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @downtime.update(downtime_params)\n format.html { redirect_to @downtime, notice: 'Downtime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poi_time.update(poi_time_params)\n format.html { redirect_to @poi_time, notice: 'Poi time was successfully updated.' }\n format.json { render :show, status: :ok, location: @poi_time }\n else\n format.html { render :edit }\n format.json { render json: @poi_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @timeslot.update(timeslot_params)\n format.html { redirect_to @timeslot, notice: 'Timeslot was successfully updated.' }\n format.json { render :show, status: :ok, location: @timeslot }\n else\n format.html { render :edit }\n format.json { render json: @timeslot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location_time.update(location_time_params)\n format.html { redirect_to @location_time, notice: 'Location time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @time_slot.update(time_slot_params)\n render :show, status: :ok, location: @time_slot\n else\n render json: @time_slot.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @wait_time.update(wait_time_params)\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully updated.' }\n format.json { render :show, status: :ok, location: @wait_time }\n else\n format.html { render :edit }\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @working_start_time.update(working_start_time_params)\n format.html { redirect_to @working_start_time, notice: 'Working start time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @working_start_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @job = @shift.job\n # @employee = @shift.employee\n # time = @shift.time_out || @shift.time_in\n # @shift.week = time.to_datetime\n\n respond_to do |format|\n if @shift.update(shift_params)\n format.html { redirect_to company_shift_path(@shift), notice: 'Shift was successfully updated.' }\n format.json { render :show, status: :ok, location: @shift }\n else\n format.html { render :edit }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stop_time = StopTime.find(params[:id])\n\n respond_to do |format|\n if @stop_time.update_attributes(params[:stop_time])\n format.html { redirect_to @stop_time, notice: 'Stop time was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stop_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work_time.update(work_time_params)\n format.html { redirect_to @work_time, notice: 'Work time was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_time }\n else\n format.html { render :edit }\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cal_time.update(cal_time_params)\n format.html { redirect_to @cal_time, notice: 'Cal time was successfully updated.' }\n format.json { render :show, status: :ok, location: @cal_time }\n else\n format.html { render :edit }\n format.json { render json: @cal_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_of_day.update(time_of_day_params)\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_of_day }\n else\n format.html { render :edit }\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_punch.update(time_punch_params)\n format.html { redirect_to @time_punch, notice: 'Time punch was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_punch }\n else\n format.html { render :edit }\n format.json { render json: @time_punch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @site = Site.first\n @first_time = @site.first_time\n respond_to do |format|\n if @first_time.update(first_time_params)\n format.html { redirect_to backstage_index_path, notice: 'first_time was successfully updated.' }\n # format.json { render :show, status: :ok, location: @first_time }\n else\n format.html { render :edit }\n # format.json { render json: @first_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_trial.update(time_trial_params)\n format.html { redirect_to @time_trial, notice: 'Time trial was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_trial }\n else\n format.html { render :edit }\n format.json { render json: @time_trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @timing.update(timing_params)\n render :show, status: :ok, location: @timing\n else\n render json: @timing.errors, status: :unprocessable_entity\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n @meeting.meeting_time = params[:meeting][:meeting_time]\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to club_meeting_path(params[:club_id],@meeting), notice: 'Meeting was successfully updated.' }\n format.json { head :ok }\n \n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n \n end\n end\n end", "def update\n @hurdle_time = HurdleTime.find(params[:id])\n\n time = (params[:time][:minutes].to_i * 60) + params[:time][:seconds].to_i\n if params[:hurdle_time]\n params[:hurdle_time].store :time, time\n else\n params[:hurdle_time] = {}.store :time, time\n end\n\n respond_to do |format|\n if @hurdle_time.update_attributes(params[:hurdle_time])\n format.html { redirect_to hurdle_match_hurdle_times_path(@hurdle_time.hurdle_match), notice: 'Hurdle time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hurdle_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day_timeslot.update(day_timeslot_params)\n format.html { redirect_to @day_timeslot, notice: 'Day timeslot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @day_timeslot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n begin\n @appointment = Appointment.find(params[:id])\n rescue\n respond_info('error', 'internal_server_error', 'Update Appointment Failed', :internal_server_error)\n return\n end\n if @appointment.update(appointment_params)\n render :json => @appointments, :status => :no_content #HTTP status code: 204 No Content\n else\n render json: @appointment.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n self.unuse_pto_hours\n if @time_off_instance.update(time_off_instance_params)\n self.use_pto_hours\n format.html { redirect_to @time_off_instance, notice: 'Time off instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_off_instance }\n else\n format.html { render :edit }\n format.json { render json: @time_off_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end", "def update\n\n params[:appointment]['scheduled_at(5i)'] = '0'\n\n @appointment.scheduled_at = DateTime.new(params[:appointment]['scheduled_at(1i)'].to_i,\n params[:appointment]['scheduled_at(2i)'].to_i,\n params[:appointment]['scheduled_at(3i)'].to_i,\n params[:appointment]['scheduled_at(4i)'].to_i,\n params[:appointment]['scheduled_at(5i)'].to_i, 0)\n\n check_for_errors if params[:staff_ids].present?\n\n if @appointment.errors.present?\n render :json => {:success => false, :html => render_to_string(:partial => \"/appointments/errors\")}.to_json\n else\n if @appointment.update(appointment_params)\n create_appointment_users if params[:staff_ids].present?\n flash[:notice]= 'Appointment was successfully updated.'\n render :json => {:success => true,\n :html => render_to_string(:partial => \"/appointments/calandar\"),\n :flash => render_to_string(:partial => \"layouts/flash\")}.to_json\n else\n render :json => {:success => false, :html => render_to_string(:partial => \"/appointments/errors\")}.to_json\n end\n end\n\n end", "def update\n respond_to do |format|\n if @order_break_time.update(order_break_time_params)\n format.html { redirect_to @order_break_time, notice: 'Order break time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render 'edit' }\n format.json { render json: @order_break_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_clock = TimeClock.find(params[:id])\n respond_to do |format|\n if @time_clock.update(time_clock_params)\n format.html { redirect_to @time_clock.user }\n format.json { render :show, status: :ok, location: @time_clock }\n else\n format.html { render :edit }\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\n end\n @time_clock.billed = 0\n @time_clock.hours = time_diff(@time_clock.clock_in, @time_clock.clock_out)\n @time_clock.save!\n end\n end", "def update\n params[:thing][:time] = @thing.time + params[:thing][:time].to_f if @thing.time\n\n respond_to do |format|\n if @thing.update(thing_params)\n format.html { redirect_to things_url, notice: 'The thing was updated.' }\n format.json { render :show, status: :ok, location: @thing }\n\n # Realtime push\n message = {:channel => '/things', :data => { :name => @thing.name, :time => @thing.time}}\n uri = URI.parse(\"http://localhost:9292/faye\")\n Net::HTTP.post_form(uri, :message => message.to_json)\n else\n format.html { render :edit }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @nursing_time = NursingTime.find(params[:id])\n\n respond_to do |format|\n if @nursing_time.update_attributes(params[:nursing_time])\n format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nursing_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @timed_task.update(timed_task_params)\n format.html { redirect_to @timed_task, notice: 'Timed task was successfully updated.' }\n format.json { render :show, status: :ok, location: @timed_task }\n else\n format.html { render :edit }\n format.json { render json: @timed_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @timetable = Timetable.find(params[:id])\n\n respond_to do |format|\n if @timetable.update_attributes(params[:timetable])\n format.html { redirect_to @timetable, notice: 'Timetable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @allocated_time.update(allocated_time_params)\n format.html { redirect_to @allocated_time, notice: 'Allocated time was successfully updated.' }\n format.json { render :show, status: :ok, location: @allocated_time }\n else\n format.html { render :edit }\n format.json { render json: @allocated_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trip_schedule.update(trip_schedule_params)\n format.html { redirect_to @trip_schedule, notice: 'Trip schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_schedule }\n else\n format.html { render :edit }\n format.json { render json: @trip_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work_order_time.update(work_order_time_params)\n format.html { redirect_to @work_order_time, notice: 'Work order time was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_order_time }\n else\n format.html { render :edit }\n format.json { render json: @work_order_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_entry.update(time_entry_params)\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_entry }\n else\n format.html { render :edit }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_slot = TimeSlot.find(params[:id])\n @recurrence_array = @time_slot.recurrence_pattern.split(//)\n respond_to do |format|\n if @time_slot.update_attributes(params[:time_slot])\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @p_time.update(p_time_params)\n format.html { redirect_to @p_time, notice: 'P time was successfully updated.' }\n format.json { render :show, status: :ok, location: @p_time }\n else\n format.html { render :edit }\n format.json { render json: @p_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @timetable.update(timetable_params)\n format.html { redirect_to request.referer, notice: 'Timetable was successfully updated.' }\n format.json { render :show, status: :ok, location: @timetable }\n else\n format.html { render :edit }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if UpdateTeaTime.call(@tea_time, tea_time_params)\n format.html { redirect_to profile_path, notice: 'Tea time was successfully updated.' }\n format.json { render json: @tea_time, status: :ok, location: @tea_time }\n else\n format.html { render :edit }\n format.json { render json: @tea_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @offset_time = OffsetTime.find(params[:id])\n\n respond_to do |format|\n if @offset_time.update_attributes(params[:offset_time])\n format.html { redirect_to @offset_time, notice: 'Offset time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @offset_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_control.update(time_control_params)\n format.html { redirect_to @time_control, notice: 'Time control was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @time_control.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n if @time_entry.update_attributes(params[:time_entry])\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n if @time_entry.update_attributes(params[:time_entry])\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n [:in_time, :out_time].each do |i|\n if shift_params[i] =~ /^[0-9]{1,2}:[0-9]{2}[ap]m$/\n params[:shift][i] = @shift.start_time.to_date.to_s(:db) + \" \" + shift_params[i]\n puts params[:shift][i]\n end\n end\n\n respond_to do |format|\n if @shift.update(shift_params)\n format.html { redirect_to :shifts, notice: 'Shift was successfully updated.' }\n format.json { render :show, status: :ok, location: @shift }\n else\n format.html { render :edit }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @timer = Timer.find(params[:id])\n\n respond_to do |format|\n if @timer.update_attributes(params[:timer])\n format.html { redirect_to @timer, notice: 'Timer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @selected_time.update(selected_time_params)\n format.html { redirect_to @selected_time, notice: 'Selected time was successfully updated.' }\n format.json { render :show, status: :ok, location: @selected_time }\n else\n format.html { render :edit }\n format.json { render json: @selected_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @appointment.check_updated_params(appointment_params)\n if @appointment.update(appointment_params)\n render json: @appointment, status: 200\n else\n render json: @appointment.errors, status: 422\n end\n else\n p \"did not work\"\n end\n end", "def update\n operation = params[:operation]\n case operation\n when 'set_best_time'\n resp = @@serv.set_best_time(params['escape_room_id'], params['best_time'])\n render json: { success: resp.success, message: resp.message }, status: :ok\n else\n render json: { success: false, message: 'Operation can not be preformed' }, status: :bad_request\n end\n end", "def update\n @timetable = Timetable.find(params[:id])\n\n respond_to do |format|\n if @timetable.update_attributes(timetable_params)\n format.html { redirect_to @timetable, notice: 'Timetable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_tracker.update(time_tracker_params)\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_tracker }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @planned_time = PlannedTime.find(params[:id])\n\n respond_to do |format|\n if @planned_time.update_attributes(params[:planned_time])\n format.html { redirect_to @planned_time, notice: 'Planned time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @planned_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @planning_time = PlanningTime.find(params[:id])\n\n respond_to do |format|\n if @planning_time.update_attributes(params[:planning_time])\n format.html { redirect_to @planning_time, notice: 'Planning time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @planning_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @punchtime.update(punchtime_params)\n format.html { redirect_to current_user, notice: 'Punchtime was successfully updated.' }\n format.json { render :show, status: :ok, location: @punchtime }\n else\n format.html { render :edit }\n format.json { render json: @punchtime.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @availibility_time_slot.update(availibility_time_slot_params)\n format.html { redirect_to @availibility_time_slot, notice: 'Availibility time slot was successfully updated.' }\n format.json { render :show, status: :ok, location: @availibility_time_slot }\n else\n format.html { render :edit }\n format.json { render json: @availibility_time_slot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n set_appointments_patients\n respond_to do |format|\n if @appointment.update(just_appointment_params)\n format.html { redirect_to @appointment, notice: 'Appointment was successfully updated.' }\n format.json { render :show, status: :ok, location: @appointment }\n else\n format.html { render :edit }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @drop_route_start_time.update(drop_route_start_time_params)\n format.html { redirect_to drop_route_start_times_path, notice: 'Drop route start time was successfully updated.' }\n format.json { render :show, status: :ok, location: @drop_route_start_time }\n else\n format.html { render :edit }\n format.json { render json: @drop_route_start_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @appointment = Appointment.find(params[:id])\n str_datetime = params[:datetime].to_datetime\n # @appointment.date = DateTime.strptime(params[:appointment][:datetime], \"%m-%d-%Y\")\n @appointment.date = str_datetime\n @appointment.time = str_datetime\n @appointment.description = params[:appointment][:description]\n\n respond_to do |format|\n if @appointment.save()\n format.html { redirect_to manager_appointment_path(@appointment), notice: 'Appointment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @big_time_entry.update(big_time_entry_params)\n format.html { redirect_to @big_time_entry, notice: 'Big time entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @big_time_entry }\n else\n format.html { render :edit }\n format.json { render json: @big_time_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @receiver_time = ReceiverTime.find(params[:id])\n\n respond_to do |format|\n if @receiver_time.update_attributes(params[:receiver_time])\n format.html { redirect_to @receiver_time, notice: 'Receiver time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @receiver_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @scheduled_appointment = ScheduledAppointment.find(params[:id])\n\n respond_to do |format|\n if @scheduled_appointment.update_attributes(params.require(:scheduled_appointment).permit(:actual_date_time, :date_time, :purpose, :status, :store_id, :vehicle_id))\n format.html { redirect_to scheduled_appointments_url,\n notice: 'ScheduledAppointment was successfully updated.' }\n format.json { head :no_content }\n else\n prepFormVariables(@scheduled_appointment)\n format.html { render action: \"edit\" }\n format.json { render json: @scheduled_appointment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tombstone_timehold.update(tombstone_timehold_params)\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully updated.' }\n format.json { render :show, status: :ok, location: @tombstone_timehold }\n else\n format.html { render :edit }\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:user_id])\n @clock_time = @user.clock_times.find(params[:id])\n\n time_in_to_update = get_time_to_update(params[\"use_current\"], params[:clock_time], \"in\")\n\n @clock_time.in = time_in_to_update\n\n time_out_to_update = get_time_to_update(params[\"use_current_out\"], params[:clock_time], \"out\")\n\n if !time_out_to_update.nil?\n @clock_time.out = time_out_to_update\n end\n\n respond_to do |format|\n if @clock_time.update_attributes(params[:clock_time])\n format.html { redirect_to @user, notice: 'Your clock in time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clock_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tap.update(tap_params)\n format.html { redirect_to taps_path, notice: 'Tap was successfully updated.' }\n format.json { head :no_content }\n else\n format.json { render json: @tap.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @class_time.update(class_time_params)\n format.html { redirect_to @class_time, notice: 'Class time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @class_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @request_meeting = RequestMeeting.find(params[:id])\n\n respond_to do |format|\n if @request_meeting.update_attributes(params[:request_meeting])\n format.html { redirect_to @request_meeting, notice: 'Request meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request_meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_slot = TimeSlot.find(params[:id])\n\n respond_to do |format|\n if @time_slot.update_attributes(params[:time_slot])\n flash[:notice] = 'TimeSlot was successfully updated.'\n format.html { redirect_to(@time_slot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @time_slot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @hotel_stay = HotelStay.find(params[:id])\n\n respond_to do |format|\n if @hotel_stay.update_attributes(params[:hotel_stay])\n format.html { redirect_to @hotel_stay, notice: 'Hotel stay was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hotel_stay.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_registration.update(time_registration_params)\n format.html { redirect_to @time_registration, notice: 'Time registration was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_registration }\n else\n format.html { render :edit }\n format.json { render json: @time_registration.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_section = TimeSection.find(params[:id])\n\n respond_to do |format|\n if @time_section.update_attributes(params[:time_section])\n format.html { redirect_to @time_section, notice: 'Time section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n if @daytime.update_attributes(params[:daytime])\n format.html { redirect_to @daytime, notice: 'Daytime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @appointment.update(appointment_params)\n format.html { redirect_to @appointment, notice: 'Appointment was successfully updated.' }\n format.json { render :show, status: :ok, location: @appointment }\n else\n format.html { render :edit }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\nend", "def update\n @time_task = TimeTask.find(params[:id])\n\n respond_to do |format|\n if @time_task.update_attributes(params[:time_task])\n flash[:notice] = 'TimeTask was successfully updated.'\n format.html { redirect_to(@time_task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @time_task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @timer = Timer.find(params[:id])\n\n if @timer.update(timer_params)\n head :no_content\n else\n render json: @timer.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n @past_request.received_help = true\n if @past_request.update(past_request_params)\n format.html { redirect_to requests_path, notice: \"You spent #{time_ago_in_words(Time.now - (Time.now - @past_request.created_at), include_seconds: true)}\" }\n format.json { render :show, status: :ok, location: @past_request }\n else\n format.html { render :edit }\n format.json { render json: @past_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n data = schedule_params\n data[:update_at] = Time.now\n if @schedule.update(data)\n format.html { redirect_to @schedule, notice: 'Schedule ha sido actualizado.' }\n format.json { render :index, status: :ok, location: @schedule }\n else\n format.html { render :edit }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work_time = WorkTime.find(params[:id])\n\n # checks if work time is successfully updated in the database\n if @work_time.update(work_time_params)\n # if updated successfully, controller issues a response according to the format given\n respond_to do |format|\n # HTML redirects the user back to the work time index and makes a notice that editing was successful\n format.html { redirect_to api_work_time_path, notice: \"Successfully edited work time!\" }\n # JSON renders the work time updated in JSON\n format.json { render json: @work_time, status: :ok }\n # XML renders the work time updated in XML\n format.xml { render xml: @work_time, status: :ok }\n end\n else\n # if errors occured like wrong information/wrong format and so on, issues a response according to format\n respond_to do |format|\n # HTML redirects the user back to the work time edit page and shows a list of errors encountered\n format.html { redirect_to edit_api_work_time_path, notice: @work_times.errors.full_messages }\n # JSON renders all errors made and shows it in JSON and gives a negative response\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\n # XML renders all errors made and shows it in XML and gives a negative response\n format.xml { render xml: @work_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @providers_opening_time.update(providers_opening_time_params)\n format.html { redirect_to providers_opening_times_path, notice: 'Opening time was successfully updated.' }\n format.json { render :show, status: :ok, location: @providers_opening_time }\n else\n format.html { render :edit }\n format.json { render json: @providers_opening_time.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_treinador.update(time_treinador_params)\n format.html { redirect_to @time_treinador, notice: 'Time alterado com sucesso' }\n format.json { render :show, status: :ok, location: @time_treinador }\n else\n format.html { render :edit }\n format.json { render json: @time_treinador.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.from_param(params[:event_id])\n @time_table = @event.time_tables.where(:permalink => params[:id]).first\n success = params[:time_table] && params[:time_table][:times] && \n @time_table.update_attributes(:times => JSON.parse(params[:time_table][:times]))\n success ? update_success : update_failure\n rescue JSON::ParserError\n update_failure\n end" ]
[ "0.6653054", "0.66524994", "0.6601323", "0.6582362", "0.6573549", "0.65660256", "0.6546499", "0.6529287", "0.6527774", "0.6489228", "0.6447293", "0.64378303", "0.6422342", "0.641576", "0.6414202", "0.6411619", "0.6408857", "0.6397323", "0.639375", "0.6386395", "0.6381744", "0.63801914", "0.6353734", "0.63528013", "0.6350535", "0.6349531", "0.6335187", "0.633248", "0.63109475", "0.62985986", "0.629333", "0.62913203", "0.6288821", "0.62772816", "0.627409", "0.6268616", "0.6267601", "0.62648135", "0.6245133", "0.6243057", "0.6228353", "0.6223843", "0.6219732", "0.62190855", "0.6216214", "0.6202801", "0.62007004", "0.6200237", "0.61851424", "0.61793613", "0.61691856", "0.6161513", "0.6160769", "0.6158495", "0.61536473", "0.61479235", "0.6142414", "0.6137027", "0.6135917", "0.6130264", "0.6129659", "0.61285955", "0.6127055", "0.6127055", "0.6121312", "0.61206263", "0.6111371", "0.6107174", "0.60868716", "0.6086108", "0.6071882", "0.60707706", "0.606296", "0.6062796", "0.6061714", "0.6060584", "0.60540825", "0.605114", "0.6046673", "0.6038729", "0.6033487", "0.60327446", "0.6032353", "0.60319555", "0.60197574", "0.60192704", "0.6018504", "0.6014657", "0.5996531", "0.5994654", "0.5993393", "0.5991575", "0.5990629", "0.5986251", "0.59852797", "0.5984254", "0.5978703", "0.5978264", "0.59779626", "0.59766966" ]
0.7227714
0
DELETE /stay_times/1 DELETE /stay_times/1.json
def destroy @stay_time.destroy respond_to do |format| format.html { redirect_to stay_times_url, notice: 'Stay time was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @time_gap = TimeGap.find(params[:id])\n @time_gap.destroy\n\n respond_to do |format|\n format.html { redirect_to time_gaps_url }\n format.json { head :ok }\n end\n end", "def destroy\n @meal_time = MealTime.find(params[:id])\n @meal_time.destroy\n\n respond_to do |format|\n format.html { redirect_to meal_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hurdle_time = HurdleTime.find(params[:id])\n @hurdle_time.destroy\n\n respond_to do |format|\n format.html { redirect_to hurdle_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cooking_time.destroy\n respond_to do |format|\n format.html { redirect_to cooking_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @downtime.destroy\n respond_to do |format|\n format.html { redirect_to downtimes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stime.destroy\n respond_to do |format|\n format.html { redirect_to stimes_url, notice: 'Stime was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @service_time = ServiceTime.find(params[:id])\n @service_time.destroy\n\n respond_to do |format|\n format.html { redirect_to service_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nursing_time = NursingTime.find(params[:id])\n @nursing_time.destroy\n\n respond_to do |format|\n format.html { redirect_to nursing_times_url }\n format.json { head :ok }\n end\n end", "def destroy\n @wait_time = WaitTime.find(params[:id])\n @wait_time.destroy\n\n respond_to do |format|\n format.html { redirect_to wait_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting_time.destroy\n respond_to do |format|\n format.html { redirect_to meeting_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_clock.destroy\n respond_to do |format|\n format.html { redirect_to time_sheet_index_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_time_trial = MyTimeTrial.find(params[:id])\n @my_time_trial.destroy\n\n respond_to do |format|\n format.html { redirect_to my_time_trials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @daytime = Daytime.find(params[:id])\n @daytime.destroy\n\n respond_to do |format|\n format.html { redirect_to daytimes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location_time.destroy\n respond_to do |format|\n format.html { redirect_to location_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_of_day.destroy\n respond_to do |format|\n format.html { redirect_to time_of_days_url, notice: 'Time of day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @where_to_stay = WhereToStay.find(params[:id])\n @where_to_stay.destroy\n\n respond_to do |format|\n format.html { redirect_to where_to_stays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @allocated_time.destroy\n respond_to do |format|\n format.html { redirect_to allocated_times_url, notice: 'Allocated time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_off_request = TimeOffRequest.find(params[:id])\n @time_off_request.destroy\n \n respond_to do |format|\n format.html { redirect_to admin_time_off_requests_url}\n format.json { head :ok }\n end\n end", "def destroy\n @stay_night.destroy\n respond_to do |format|\n format.html { redirect_to stay_nights_url }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @one_time_stop = OneTimeStop.find(params[:id])\n @one_time_stop.destroy\n\n respond_to do |format|\n format.html { redirect_to one_time_stops_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @working_start_time.destroy\n respond_to do |format|\n format.html { redirect_to working_start_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_timeslot.destroy\n respond_to do |format|\n format.html { redirect_to day_timeslots_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stop_time = StopTime.find(params[:id])\n @stop_time.destroy\n\n respond_to do |format|\n format.html { redirect_to stop_times_url }\n format.json { head :ok }\n end\n end", "def destroy\n @order_break_time.destroy\n respond_to do |format|\n format.html { redirect_to order_break_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @disatance_and_time.destroy\n respond_to do |format|\n format.html { redirect_to disatance_and_times_url, notice: 'Disatance and time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poi_time.destroy\n respond_to do |format|\n format.html { redirect_to poi_times_url, notice: 'Poi time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cal_time.destroy\n respond_to do |format|\n format.html { redirect_to cal_times_url, notice: 'Cal time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_entry = TimeEntry.with_deleted.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to time_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_trial.destroy\n respond_to do |format|\n format.html { redirect_to '/admin', notice: 'Time trial was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_entry = current_firm.all_time_entries.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to params[:ret] || firm_time_entries_path(current_firm) }\n format.json { head :ok }\n end\n end", "def destroy\n @time_log = TimeLog.find(params[:id])\n @time_log.destroy\n\n respond_to do |format|\n format.html { redirect_to time_logs_url }\n format.json { head :ok }\n end\n end", "def deleteEntityOpening_times( entity_id)\n params = Hash.new\n params['entity_id'] = entity_id\n return doCurl(\"delete\",\"/entity/opening_times\",params)\n end", "def destroy\n @hotel_stay = HotelStay.find(params[:id])\n @hotel_stay.destroy\n\n respond_to do |format|\n format.html { redirect_to hotel_stays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @working_time = WorkingTime.find(params[:id])\n @working_time.destroy\n\n respond_to do |format|\n format.html { redirect_to time_tables_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_slot = TimeSlot.find(params[:id])\n @time_slot.destroy\n\n respond_to do |format|\n format.html { redirect_to time_slots_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @wait_time.destroy\n respond_to do |format|\n format.html { redirect_to wait_times_url, notice: 'Wait time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @class_time.destroy\n respond_to do |format|\n format.html { redirect_to class_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @planning_time = PlanningTime.find(params[:id])\n @planning_time.destroy\n\n respond_to do |format|\n format.html { redirect_to planning_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_entry = TimeEntry.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to time_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_entry = TimeEntry.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to time_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @timeslot.destroy\n respond_to do |format|\n format.html { redirect_to timeslots_url, notice: 'Timeslot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @member_time = MemberTime.find(params[:id])\n @member_time.destroy\n\n respond_to do |format|\n format.html { redirect_to member_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @titletime.destroy\n respond_to do |format|\n format.html { redirect_to titletimes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @showtime.destroy\n respond_to do |format|\n format.html { redirect_to showtimes_url, notice: \"Showtime was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_entry.destroy\n respond_to do |format|\n format.html { redirect_to time_entries_url, notice: 'Time entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @timetable = Timetable.find(params[:id])\n @timetable.destroy\n\n respond_to do |format|\n format.html { redirect_to timetables_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tombstone_timehold.destroy\n respond_to do |format|\n format.html { redirect_to tombstone_timeholds_url, notice: 'Tombstone timehold was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_period.destroy\n format.json { head :no_content }\n end", "def destroy\n @section_time.destroy\n respond_to do |format|\n format.html { redirect_to section_times_url, notice: 'Section time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @p_time.destroy\n respond_to do |format|\n format.html { redirect_to p_times_url, notice: 'P time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #Uncomment this if for some reason users should be able to delete TTs\n #@tea_time.destroy\n respond_to do |format|\n format.html { render text: \"I can't let you do that, #{current_user.name}\" }\n format.json { head 403 }\n end\n end", "def destroy\n @selected_time.destroy\n respond_to do |format|\n format.html { redirect_to selected_times_url, notice: 'Selected time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @offset_time = OffsetTime.find(params[:id])\n @offset_time.destroy\n\n respond_to do |format|\n format.html { redirect_to offset_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_section = TimeSection.find(params[:id])\n @time_section.destroy\n\n respond_to do |format|\n format.html { redirect_to time_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end", "def destroy\n\n if @teetime.destroy\n\n render json: {teetime: {id: params[:id].to_i}},status: :ok\n\n else\n\n render json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\n\n end\n\n \t\tend", "def destroy\n @timelog.destroy\n respond_to do |format|\n format.html { redirect_to timelogs_url, notice: 'Timelog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_slots_list.destroy\n respond_to do |format|\n format.html { redirect_to time_slots_lists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mealtime.destroy\n respond_to do |format|\n format.html { redirect_to mealtimes_url, notice: 'Mealtime was successfully destroyed.' }\n end\n end", "def destroy\n @work_time.destroy\n respond_to do |format|\n format.html { redirect_to work_times_url, notice: 'Work time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment.destroy\n head 204\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @time_record = TimeRecord.find(params[:id])\n @time_record.destroy\n\n respond_to do |format|\n format.html { redirect_to time_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_record = TimeRecord.find(params[:id])\n @time_record.destroy\n\n respond_to do |format|\n format.html { redirect_to time_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_slot.destroy\n respond_to do |format|\n format.html { redirect_to time_slots_url, notice: 'Time slot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_visitor = TimeVisitor.find(params[:id])\n @time_visitor.destroy\n\n respond_to do |format|\n format.html { redirect_to tour_visitor_time_visitors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @timeentry = Timeentry.find(params[:id])\n @timeentry.destroy\n\n respond_to do |format|\n format.html { redirect_to timeentries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_record.destroy\n respond_to do |format|\n format.html { redirect_to time_records_url, notice: 'Time record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @clinic_timing = ClinicTiming.find(params[:id])\n @clinic_timing.destroy\n\n respond_to do |format|\n format.html { redirect_to clinic_timings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @drop_route_start_time.destroy\n respond_to do |format|\n format.html { redirect_to drop_route_start_times_url, notice: 'Drop route start time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @time_table.destroy\n respond_to do |format|\n format.html { redirect_to time_tables_url, notice: 'Time table was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @downtime_record.destroy\n respond_to do |format|\n format.html { redirect_to downtime_records_url, notice: '成功删除.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @timetable_entry.destroy\n respond_to do |format|\n format.html { redirect_to timetable_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n puts @iot_datum.count\n if @iot_datum.count > 0\n @deleted_rec = IotDatum.new\n @deleted_rec.workbench_number = @iot_datum.workbench_number\n @deleted_rec.part_number = @iot_datum.part_number\n @deleted_rec.target = @iot_datum.target\n @deleted_rec.lot_size = @iot_datum.lot_size\n @deleted_rec.employee_name = @iot_datum.employee_name\n @deleted_rec.shift = @iot_datum.shift\n @deleted_rec.device_id = @iot_datum.device_id\n @deleted_rec.count = @iot_datum.count\n @deleted_rec.status = 'Deleted'\n @deleted_rec.save!\n @iot_datum.destroy\n else\n @iot_datum.destroy\n end\n respond_to do |format|\n format.html { redirect_to iot_data_url, notice: 'Planner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @timecontroll.destroy\n respond_to do |format|\n format.html { redirect_to timecontrolls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_line.destroy\n respond_to do |format|\n format.html { redirect_to time_lines_url, notice: 'Time line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @doctor_timing = DoctorTiming.find(params[:id])\n @doctor_timing.destroy\n\n respond_to do |format|\n format.html { redirect_to doctor_timings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @timed_task.destroy\n respond_to do |format|\n format.html { redirect_to timed_tasks_url, notice: 'Timed task was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n set_user\n @time_off.destroy\n respond_to do |format|\n format.html { redirect_to user_time_offs_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 @downtime_type.destroy\n respond_to do |format|\n format.html { redirect_to downtime_types_url, notice: '成功删除.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @big_time_entry.destroy\n respond_to do |format|\n format.html { redirect_to big_time_entries_url, notice: 'Big time entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_task = TimeTask.find(params[:id])\n @time_task.destroy\n\n respond_to do |format|\n format.html { redirect_to(time_tasks_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @now.destroy\n respond_to do |format|\n format.html { redirect_to nows_url, notice: 'Now was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n self.unuse_pto_hours\n @time_off_instance.destroy\n respond_to do |format|\n format.html { redirect_to time_off_instances_url, notice: 'Time off instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @beat = Beat.find(params[:id])\n @beat.destroy\n\n respond_to do |format|\n format.html { redirect_to beats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @planned_time = PlannedTime.find(params[:id])\n @planned_time.destroy\n\n respond_to do |format|\n format.html { redirect_to planned_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @timeslot = current_event.timeslots.find(params[:id])\n @timeslot.destroy\n\n respond_to do |format|\n format.html { redirect_to(timeslots_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @time_block.destroy\n respond_to do |format|\n format.html { redirect_to time_blocks_url, notice: 'Time block was successfully destroyed.' }\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 delete(path, params)\n parse_response @client[path].delete(:params => params)\n end", "def destroy\n check_admin\n @time_balance = TimeBalance.find(params[:id])\n @time_balance.destroy\n\n respond_to do |format|\n format.html { redirect_to time_balances_url }\n format.json { head :ok }\n end\n end", "def destroy\n @timetable.destroy\n respond_to do |format|\n format.html { redirect_to timetables_url, notice: 'Timetable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_punch.destroy\n respond_to do |format|\n format.html { redirect_to time_punches_url, notice: 'Time punch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @receiver_time = ReceiverTime.find(params[:id])\n @receiver_time.destroy\n\n respond_to do |format|\n format.html { redirect_to receiver_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_time = WorkTime.find(params[:id])\n @work_time.destroy\n # after deleting, controller issues a response according to the format given\n respond_to do |format|\n # HTML redirects back to work time index and shows the notice\n format.html { redirect_to api_work_times_path, notice: \"Successfully deleted work time!\" }\n # JSON will just give a deleted response\n format.json { head :no_content }\n # XML will just give a deleted response\n format.xml { head :no_content }\n end\n end", "def destroy\n @stay.destroy\n end" ]
[ "0.7226604", "0.69612134", "0.6939054", "0.6817791", "0.681168", "0.6803863", "0.67897755", "0.6786757", "0.6783543", "0.6771888", "0.6769168", "0.6741878", "0.67337954", "0.6730354", "0.66895", "0.6688952", "0.6681023", "0.66767806", "0.66705346", "0.6667793", "0.66658086", "0.66479504", "0.66271615", "0.66242707", "0.6619212", "0.6610823", "0.6597983", "0.6596513", "0.6596408", "0.6595423", "0.6592631", "0.6590447", "0.6575402", "0.6575282", "0.65720695", "0.656644", "0.655881", "0.65538365", "0.6537909", "0.6529713", "0.6529713", "0.65233874", "0.6519638", "0.65126234", "0.65110797", "0.65105844", "0.65102386", "0.6488335", "0.64779884", "0.64761925", "0.6475635", "0.64744455", "0.64710516", "0.64661807", "0.6463887", "0.6463216", "0.64594096", "0.6455315", "0.64522165", "0.6441454", "0.64411396", "0.6439136", "0.6432285", "0.64310557", "0.64310557", "0.6429203", "0.6423224", "0.6421499", "0.6415421", "0.64136106", "0.6411741", "0.6411016", "0.64040124", "0.63996327", "0.6398035", "0.6385433", "0.63786983", "0.63774335", "0.6377047", "0.63747513", "0.63697886", "0.6368996", "0.63660955", "0.6359253", "0.63572097", "0.63535446", "0.6352894", "0.6351936", "0.63496035", "0.63473177", "0.63468695", "0.63467634", "0.6345951", "0.6341486", "0.6339213", "0.633783", "0.633613", "0.6333864", "0.6327428", "0.63249385" ]
0.74384403
0
Use callbacks to share common setup or constraints between actions.
def set_stay_time @stay_time = StayTime.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def stay_time_params params.require(:stay_time).permit(:arrive_date, :leave_date, :nationality, :country_stay, :day_stay) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\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 allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\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 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 user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\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 whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_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 safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\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 user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; 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 quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "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 url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n 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 user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\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 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 url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
rubocop:enable Metrics/MethodLength rubocop:disable Metrics/MethodLength
def deny_encryption_using_incorrect_key_statement( bucket_name, kms_key_arn ) { effect: 'Deny', principal: '*', action: 's3:PutObject', resource: "arn:aws:s3:::#{bucket_name}/*", condition: { 'StringNotEqualsIfExists' => { 's3:x-amz-server-side-encryption-aws-kms-key-id' => kms_key_arn } } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def schubert; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def refutal()\n end", "def custom; end", "def custom; end", "def offences_by; end", "def suivre; end", "def strategy; end", "def used?; end", "def private_method\n end", "def operations; end", "def operations; end", "def isolated; end", "def isolated; end", "def intensifier; end", "def extra; end", "def internal; end", "def missing; end", "def formation; end", "def who_we_are\r\n end", "def initialize\n\n end", "def initialize\n\n end", "def overrides; end", "def celebration; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize\n \n end", "def villian; end", "def ignores; end", "def initialize\n \n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def spec; end", "def spec; end", "def initialize\n super()\n end", "def anchored; end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def initialize\n\t\t\n\tend", "def weber; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def terpene; end", "def same; end", "def operation; end", "def verdi; end", "def common\n \n end", "def initialize() end", "def wrapper; end", "def missing?; end", "def initialize\r\n\r\n end", "def relatorios\n end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def internship_passed; end", "def processor; end", "def ignore; end", "def returns; end", "def identify; end", "def appraisals; end", "def appraisals; end", "def init; end", "def init; end", "def init; end", "def init; end", "def initialize\n # nothing here for now\n end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def sitemaps; end", "def under_construction\n end" ]
[ "0.78097546", "0.6550692", "0.6393907", "0.6393907", "0.63413805", "0.6341239", "0.6341239", "0.6341239", "0.6341239", "0.63261473", "0.6132386", "0.6132386", "0.6035665", "0.60181385", "0.59858197", "0.597906", "0.59612405", "0.58933866", "0.58933866", "0.5888103", "0.5888103", "0.5863022", "0.5837961", "0.58362275", "0.5806279", "0.5795523", "0.5794152", "0.5791959", "0.5791959", "0.5769047", "0.5761127", "0.5760442", "0.5760442", "0.5760442", "0.5760442", "0.5760442", "0.5760442", "0.5760442", "0.5760442", "0.5760442", "0.5760442", "0.5760442", "0.5757446", "0.57485706", "0.57399124", "0.5737555", "0.572034", "0.572034", "0.572034", "0.57172394", "0.57172394", "0.5709601", "0.5702412", "0.5697405", "0.5697405", "0.5697405", "0.5697405", "0.5697184", "0.5695819", "0.5695533", "0.5695533", "0.5680522", "0.5680522", "0.5680522", "0.5680522", "0.5680522", "0.5680522", "0.5680522", "0.5680522", "0.5680522", "0.5680522", "0.56670296", "0.566359", "0.5655269", "0.56464344", "0.56259644", "0.5616344", "0.56120664", "0.5611277", "0.56054115", "0.56052166", "0.5599771", "0.5599771", "0.5599771", "0.5599771", "0.55996317", "0.5598495", "0.5589104", "0.5588666", "0.5585893", "0.5581739", "0.5581739", "0.5581481", "0.5581481", "0.5581481", "0.5581481", "0.55735034", "0.55711466", "0.55711466", "0.55611944", "0.5558025" ]
0.0
-1
rubocop:enable Metrics/MethodLength rubocop:disable Metrics/MethodLength
def deny_un_encrypted_inflight_operations_statement( bucket_name ) { effect: 'Deny', principal: '*', action: 's3:*', resource: "arn:aws:s3:::#{bucket_name}/*", condition: { 'Bool' => { 'aws:SecureTransport' => 'false' } } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def refutal()\n end", "def custom; end", "def custom; end", "def offences_by; end", "def suivre; end", "def strategy; end", "def used?; end", "def private_method\n end", "def operations; end", "def operations; end", "def isolated; end", "def isolated; end", "def intensifier; end", "def extra; end", "def internal; end", "def missing; end", "def formation; end", "def who_we_are\r\n end", "def initialize\n\n end", "def initialize\n\n end", "def overrides; end", "def celebration; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize\n \n end", "def villian; end", "def ignores; end", "def initialize\n \n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def spec; end", "def spec; end", "def initialize\n super()\n end", "def anchored; end", "def initialize\n\t\t\n\tend", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def weber; end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def terpene; end", "def same; end", "def operation; end", "def verdi; end", "def common\n \n end", "def initialize() end", "def wrapper; end", "def missing?; end", "def initialize\r\n\r\n end", "def relatorios\n end", "def internship_passed; end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def processor; end", "def returns; end", "def ignore; end", "def identify; end", "def init; end", "def init; end", "def init; end", "def init; end", "def appraisals; end", "def appraisals; end", "def initialize\n # nothing here for now\n end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def sitemaps; end", "def under_construction\n end" ]
[ "0.781014", "0.6551781", "0.63943195", "0.63943195", "0.63432074", "0.63432074", "0.63432074", "0.63432074", "0.6342304", "0.632547", "0.61320364", "0.61320364", "0.6036338", "0.601888", "0.5986253", "0.5978609", "0.5960824", "0.589437", "0.589437", "0.5888722", "0.5888722", "0.58635813", "0.583836", "0.58364916", "0.5806411", "0.5796488", "0.5794451", "0.5792431", "0.5792431", "0.57694495", "0.57617295", "0.5761488", "0.5761488", "0.5761488", "0.5761488", "0.5761488", "0.5761488", "0.5761488", "0.5761488", "0.5761488", "0.5761488", "0.5761488", "0.5758301", "0.57489896", "0.5740668", "0.5738773", "0.5720218", "0.5720218", "0.5720218", "0.5717897", "0.5717897", "0.570929", "0.5703585", "0.5698848", "0.5698099", "0.5698099", "0.5698099", "0.5698099", "0.5696275", "0.5696275", "0.5695931", "0.5680935", "0.5680935", "0.5680935", "0.5680935", "0.5680935", "0.5680935", "0.5680935", "0.5680935", "0.5680935", "0.5680935", "0.56683034", "0.5664958", "0.5655457", "0.564768", "0.56269085", "0.5617756", "0.5612248", "0.56111354", "0.5606687", "0.5605637", "0.56006247", "0.5599622", "0.5599622", "0.5599622", "0.5599622", "0.55989754", "0.5589023", "0.5588836", "0.5587438", "0.55828524", "0.55828524", "0.55828524", "0.55828524", "0.5580421", "0.5580421", "0.5573223", "0.55724686", "0.55724686", "0.5561573", "0.55586284" ]
0.0
-1
Returns a list of open hours grouped by same days
def grouped_open_hours open_hours = [] start_day = nil end_day = nil current_period = nil standard_hours.sort.each_with_index do |o, i| if not o.open? period = "Stengt" else period = I18n.l(o.open_time, format: :time) + " - " + I18n.l(o.close_time, format: :time) end # Track day if start_day == nil start_day = o.day current_period = period end # Previous group ended, add it if period != current_period day = I18n.t("days.#{start_day}") if end_day != nil day += " - " + I18n.t("days.#{end_day}") end # Hverdager custom string if start_day == "monday" and end_day == "friday" day = "Hverdager" end open_hours.append([day, current_period]) current_period = period start_day = o.day end_day = nil end # Update period end if start_day != o.day end_day = o.day end # Last day closes period if i >= standard_hours.count - 1 day = I18n.t("days.#{start_day}") if end_day != nil day += " - " + I18n.t("days.#{o.day}") end open_hours.append([day, current_period]) end end open_hours end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grouped_office_hours\n merged_hours.map { |hash_list|\n days = if hash_list.length == 1\n hash_list.first[:day]\n elsif hash_list.length > 1\n \"#{hash_list.first[:day]} - #{hash_list.last[:day]}\"\n end\n {:hours => hash_list.first[:hours],\n :day => days }\n }.delete_if {|hash| hash[:hours].blank? }\n end", "def opening_hours\n hours = @data[:godziny_pracy]\n keys = {weekdays: :dni_robocze, saturdays: :soboty, sundays: :niedz_i_sw}\n Hash[\n keys.map do |h, x|\n value = unless hours[x].nil?\n [hours[x][:godziny].to_s, hours[x][:uwagi].to_s]\n end\n\n [h, value]\n end\n ]\n end", "def group_by_hour\n group_by { |e| e.timestamp.hour }\n end", "def each_open_day\n each do |day, times|\n unless times.empty?\n yield day, times\n end\n end\n end", "def get_hours_array hours\n hours_array = []\n hours.each { |h| hours_array << h.date }\n return hours_array\n end", "def show\n @open_hours = Hash.new\n @place.open_times.each do |schedule|\n @open_hours[schedule.day] = \"#{schedule.open_time.strftime('%l:%M %P')} - #{schedule.close_time.strftime('%l:%M %P')}\"\n end\n end", "def grid\n Date::DAYNAMES.map do |name|\n daily_hours = send(name.downcase)\n HOURS.map do |hour|\n daily_hours.include? hour\n end\n end\n end", "def open_close_times(date)\n open_close = @open_close[as_string(date)] || @open_close[as_sym(date)] || @default_open_close\n open_close.collect { |h| Time.parse(\"#{as_string(date)} #{h}\") }\n end", "def show_opening_hours(times, formatted_times, event_date)\n result = 'Not Open Today'\n event_day = transformToFourSquareDay(event_date.in_time_zone.wday)\n times.each_with_index do |time, index|\n unless time.days.index(event_day).nil?\n result = formatted_times[index].open[0].renderedTime\n end\n end\n result\n end", "def hours_in_day(*hours)\n @test_time = @time if @test_time.nil?\n x_in_list_of_y(@test_time.hour, Configuration.parse_range(hours).flatten)\n end", "def trucks_currently_open\n trucks = self.class.get_truck_data\n date = self.class.get_time\n\n trucks_open_now = []\n trucks.each do |truck|\n if date.strftime('%H:%M') <= truck[\"end24\"] && \n date.strftime('%H:%M') > truck[\"start24\"]\n trucks_open_now << truck[\"applicant\"]\n end \n end\n p trucks_open_now\n end", "def hours\n @hours ||= []\n return @hours if !@hours.empty?\n src['hours'].each{|h| @hours << Stormglass::Hour.new(h) }\n @hours\n end", "def hourly_totals(emoji)\n hour_zero = self.last_hour.where(emoji: emoji).pluck(:created_at).size\n hour_one = self.last_hour_plus_one.where(emoji: emoji).pluck(:created_at).size\n hour_two = self.last_hour_plus_two.where(emoji: emoji).pluck(:created_at).size\n hour_three = self.last_hour_plus_three.where(emoji: emoji).pluck(:created_at).size\n hour_four = self.last_hour_plus_four.where(emoji: emoji).pluck(:created_at).size\n some_days = [hour_zero, hour_one, hour_two, hour_three, hour_four]\n end", "def closed(day)\n week.each do |weekday,hours_array|\n if day == weekday \n week[weekday] = [\"closed\"]\n \n end\n end\n end", "def open?\n return false if close_today?\n today = self.time_tables.find_by(day_of_week: Time.now.wday)\n (today.opened_at...today.closed_at).include?(Time.now.hour)\nend", "def hour_events(selected_day, hour, events)\n h = hour.split(\":\")\n hour_end = \"#{h[0]}:59\"\n events.select { |e| e.start_time.to_date == selected_day && (e.start_time.to_time.strftime(\"%H:%M\") >= hour) && (e.start_time.to_time.strftime(\"%H:%M\") < hour_end) }\n end", "def open_slots_for_select(date)\n open_slots(date).map do |slot|\n [\"#{slot.starts_at.strftime('%d/%m/%Y, %H:%M ')}\", slot.starts_at]\n end\n end", "def index\n @open_hours = OpenHour.all\n end", "def next_weeks_open_house_dates(open_house_dow)\n now = Time.now\n dates = []\n (0...7).each do |day_offset|\n days = day_offset*24*60*60\n date = now + days\n if open_house_dow.include?(date.wday)\n dates << now + days\n end\n end\n dates\n end", "def day_meetings\n days = []\n @course.weekdays.each_char.each_with_index do |w, i|\n days.push(DAYS_AS_SYM[i]) if w.to_i == 1\n end\n days\n end", "def hour_of_day(*hours)\n merge(hour: hours)\n end", "def days\n return self.day_shifts.keys\n end", "def group_by_day\n\n\tend", "def get_worked_hours_hash hours_array, hash\n first_hour_pos = 0\n hours_array.each do |hour|\n if is_different_day? hour.day, hours_array[first_hour_pos].day\n current_day = hours_array[first_hour_pos]\n first_hour_pos = hours_array.index(hour)\n worked_hours = get_worked_hours(current_day, hours_array[first_hour_pos - 1])\n hash = build_hash hash, current_day, worked_hours, hours_array[first_hour_pos - 1]\n elsif hours_array.index(hour) == hours_array.size - 1\n worked_hours = get_worked_hours(hours_array[first_hour_pos], hours_array[hours_array.size - 1])\n hash = build_hash hash, hours_array[first_hour_pos], worked_hours, hours_array[hours_array.size - 1]\n end\n end\n return hash\n end", "def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end", "def group_by_day\n group_by { |e| e.timestamp.strftime '%Y-%m-%d' }\n end", "def hours_for(hours)\n return 'closed' if hours.blank?\n\n hours.reduce '' do |memo, time_range|\n midnight = Time.current.midnight\n start_time = midnight.since(time_range.begin).strftime(TIME_FORMAT).strip\n end_time = midnight.since(time_range.end).strftime(TIME_FORMAT).strip\n\n memo + \"#{memo.empty? ? '' : ', '}#{start_time} to #{end_time}\"\n end\n end", "def remaining_hours_by_day\n values_by_day(0, true) { |x| model.remaining_hours_for_day_number(x) }\n end", "def trucks_open_today\n trucks = self.class.get_truck_data\n date = self.class.get_time\n\n trucks_today = []\n trucks.each do |truck|\n if date.strftime(\"%A\") == truck[\"dayofweekstr\"]\n trucks_today << truck[\"applicant\"]\n end \n end\n p trucks_today\n end", "def hours( calculator )\n a = []\n a << terse_hours( calculator.total ) if ( @report.include_totals )\n a << terse_hours( calculator.committed ) if ( @report.include_committed )\n a << terse_hours( calculator.not_committed ) if ( @report.include_not_committed )\n return a\n end", "def day_times\n @day_times ||= available_times.map(&:day_time)\n @day_times\n end", "def neighborhood_openings(start_date, end_date)\n openings = []\n self.listings.each do |listing|\n listing.reservations.each do |r|\n booked_dates = r.checkin..r.checkout\n unless booked_dates === start_date || booked_dates === end_date\n openings << listing\n end\n end\n end\n return openings\n end", "def events_on_day(day_num)\n events = []\n event.each { |e| events << e if e.days.include? day_num }\n events.sort_by(&:start_time)\n end", "def attendance_logs_by_date\n attendance_logs.group_by { |al| al.occured_at.strftime(\"%F\") }\n end", "def hour_of_day(hours, *extras)\n merge(hour: hours.array_concat(extras))\n end", "def meetings_on(day)\n ((@ending_meetings_by_days[day] || []) + (@starting_meetings_by_days[day] || [])).uniq.sort_by {|meeting| meeting.start_date}\n end", "def days_assigned\r\n days_assigned = []\r\n self.groups.each {|g| days_assigned.push(g.day)}\r\n return days_assigned\r\n end", "def events_on(day)\n ((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq\n end", "def neighborhood_openings(start_date, end_date)\n openings(start_date, end_date)\n end", "def to_a\n (first_calendar_day..last_calendar_day).to_a.in_groups_of(7)\n end", "def grouped_happening_cases(this)\n\t\t\tsession_id_list = []\n\t\t\tthis.offering_sessions.each do |os|\n\t\t\t\tsession_id_list << os.id\n\t\t\tend\n\n\t\t\tsorted_happening_cases = HappeningCase.where(happening_type: \"OfferingSession\", happening_id: session_id_list).group_by(&:date_and_time)\n\t\tend", "def time_rows\n rows = []\n (0..NUM_HALF_HOURS-1).each do |half_hour|\n cols = []\n row = content_tag :tr do\n cols << hour_cell(half_hour)\n cols << minute_cell(half_hour)\n (0..(num_days-1)).each do |day|\n cols << event_cells(half_hour,day)\n end\n cols.join.html_safe\n end\n rows << row\n end\n rows.join.html_safe\n end", "def public_holidays_to_array\n holidays = []\n public_holidays&.each do |day, meta|\n next if !meta\n next if !meta['active']\n next if meta['removed']\n\n holidays.push Date.parse(day)\n end\n holidays\n end", "def index\n @day_hours = DayHour.all\n end", "def openings_on(date)\n events = openings.starts_on(date).to_a\n events.present? ? events : recurrent_openings_for(date)\n end", "def hours\n _nudge[0]\n end", "def how_many_available_on(day, hour)\n who_is_available_on(day, hour).size\n end", "def day_events(date, events)\n events.select { |e| e.start_time.to_date == date }.sort_by { |e| e.start_time }\n end", "def day\n @client = Client.new\n @title = @current_user.name\n @view = 'day'\n # TODO is Date.parse in current time zone? If not add.\n @date = params[:date].nil? ? Date.current : Date.parse(params[:date])\n # TODO: brakeman is warning of security problem with this line\n @nav_title = @date.strftime(NAV_TITLE[@view.to_sym])\n # TODO: should employees stay or go?\n @employees = [1]\n\n @appointments_by_hour = Hash.new\n r = Appointment.where(time: @date.in_time_zone.beginning_of_day..@date.in_time_zone.end_of_day).order(:time).includes(:client)\n r.each do |appointment| #.order(:time).group_by(&:time)\n k = appointment.time.hour\n if @appointments_by_hour.has_key?(k)\n @appointments_by_hour[k].push(appointment)\n else\n @appointments_by_hour[k] = [appointment]\n end\n end\n\n render 'index'\n end", "def duplicate_days\r\n duplicates = 0\r\n dup_hash(self.days_assigned).each_value{|v| duplicates += v}\r\n return duplicates\r\n end", "def days\n attendances.order(date: :asc).map(&:date)\n end", "def opening_hour\n 11\n end", "def hours_per_day(entries)\n hours_per_day = Hash.new(0.0)\n entries.each do |entry|\n hours_per_day[entry[:start].to_date] += (entry[:end] - entry[:start]) / 3600.0\n end\n hours_per_day\nend", "def groups_total_hours(records, from, to, rows)\n groups_total_hours = []\n # days difference between rows\n days = ((to - from) / rows).to_i + 1\n (0..rows-1).each do |i|\n i_from = to - (i+1) * days\n i_to = to - i * days\n # break if time period of current row is out of time area delimited by from and to \n break if from > i_to\n date = i_to - days / 2\n total_hours = records.where(\"date(records.created_at) > ? and date(records.created_at) <= ?\", i_from, i_to).sum(\"hours\")\n groups_total_hours << {date: date, total_hours: total_hours}\n end\n groups_total_hours \n end", "def events_seven_days()\n events = []\n today = Date.today\n for i in 0..6 do\n events += events_by_date(today + i)\n end\n return events\nend", "def get_work_days\n puts \"Getting work days...\"\n work_days = []\n biweek = get_biweek\n week_1 = @schedule[biweek[0]].compact.uniq\n week_2 = @schedule[biweek[1]].compact.uniq\n\n @schedule.each_with_index do |row, i|\n DAYS.each_with_index do |day, j|\n date = ( i < biweek[1] ? week_1[j] : week_2[j] )\n day_name = day[:day]\n name = row[day[:name]]\n hours = row[day[:hours]]\n if name && hours && name.downcase.include?(@person.downcase)\n work_days.push({\n :name => @person,\n :date => get_date(date, hours)\n })\n end\n end\n end\n puts \"Work days:\\n#{work_days}\"\n return work_days\nend", "def opening(day)\n Time.now.utc.midnight\n .advance(seconds: opening_second(day)).strftime('%H:%M')\n end", "def requests_per_hour\n group_by_hour.map { |hour, ents|\n [hour, ents.size]\n }.sort { |a,b|\n a[0] <=> b[0]\n }\n end", "def opening_hour\n 11 # 11am\n end", "def timeslots\n data['timeslots'].map { |ts|\n Timeslot.new(\n Time.at(ts['start_date']),\n Time.at(ts['end_date'] || ts['start_date']),\n data['timezone']\n )\n }.reject(&:finished?).sort_by(&:start_date)\n end", "def list_of_days_worked_out\n array = []\n workouts = Workout.all.find_all do |workout| \n workout.user_id == self.id \n end\n dates = workouts.each do |workout|\n array << workout.date\n end\n array\n end", "def hour_select_array(hour, end_time = false)\n # makes list for time selector in Visits view\n hour = DateTime.now.hour if hour == -1\n array = ((hour-4)..(hour+1)).to_a\n hour >= 12 ? array.delete_if { |a| a < 12 } : array.delete_if { |a| a >= 12 }\n array.map! { |h| h < 0 ? h + 24 : h }\n end_time ? [-1] + array : array\nend", "def index\n @grouped_schedule_places = SchedulePlace.all\n .order(:weekday_id, :start_time).group_by{ |sp| sp.weekday.name }\n @weekdays = Weekday.all.map { |wd| [wd.name, wd.id] }\n end", "def find_open_dates(pages)\n open_dates = Hash.new([])\n\n pages.each do |page|\n page.search(\"a.avail\").each do |link|\n site = link.parent.parent.at_css(\"td.sn div.siteListLabel a\").text.to_sym\n url = link.attr('href')\n\n if open_dates[site].empty?\n open_dates[site] = [url]\n else\n open_dates[site] << url\n end\n end\n end\n\n open_dates\n end", "def days_worked\n days = account.account_setting.working_days\n Hash[days.map { |k,v| [k, (v == \"1\")] }]\n end", "def users_by_day(days=30)\n joins(:code_cell)\n .where('executions.updated_at > ?', days.days.ago)\n .select('COUNT(DISTINCT(user_id)) AS count, DATE(executions.updated_at) AS day')\n .group('day')\n .map {|e| [e.day, e.count]}\n .sort_by {|day, _count| day}\n .to_h\n end", "def commit_time_line events\n events.map(&:date).uniq.sort.each_cons(2).map {|before,after| [before, (after.to_i - before.to_i) / (60 * 60 * 24)] }\nend", "def all_matchday_times\n all_matches = fetch_matches\n matchtimes = Hash[(1..38).collect { |md| [md, []] }]\n all_matches.each do |m|\n matchtimes[m['matchday']].push(m['utcDate'])\n end\n matchtimes\n end", "def calls_by_hour\n gmt_offset = Time.now.getlocal.gmt_offset\n select = \"EXTRACT(HOUR FROM contacts.arrived + '#{gmt_offset} seconds') AS hour, COUNT(*) AS count\"\n data = answered_contacts.select(select).group('hour')\n\n result = Array.new(24, 0)\n data.each { |d| result[(d['hour'])] = d['count'] }\n result\n end", "def employees\n times.map(&:employee).uniq\n end", "def weekdays\n if @range\n first = WEEKDAYS.find {|key,val| key.include? @range.first }.last.first\n last = WEEKDAYS.find {|key,val| key.include? @range.last }.last.last\n return (first..last).to_a\n else\n output = []\n @tokens.each do |token|\n WEEKDAYS.each_pair do |labels,wdays|\n output.concat(wdays) and break if labels.include?(token)\n end\n end\n output\n end\n end", "def graph_by_day(array)\n if array.empty?\n graph = [[Time.now, 0]]\n else\n array.sort!{|x,y| x.created_at <=> y.created_at}\n finish = array.last.created_at + 1.day\n start = array.first.created_at - 1.day\n days = []\n day = start.midnight\n while day < finish.midnight\n days << day\n day += 1.day\n end\n graph = days.map{|day| [day, array.select{|object| object.created_at > day && object.created_at < day + 1.day}.count]}\n end\n end", "def neighborhood_openings(start_date, end_date)\n self.listings.select {|l| l.reservations.where(\"checkout < start_date OR checkin > end_date\")}\n end", "def happy_hour\n event_display(\"It's HAPPY HOUR! Everybody let's loose.\")\n group_event_hash_creator({soft_skills: 2, wellbeing: 2})\n end", "def consolidate_day\n t = Time.zone.local(2012,12,10);\n\n two_days_ago = t - 2.days\n one_days_ago = t - 1.day\n\n last_couple_days = self.energy_data.where(:year => t.year, :month => t.month, :day => one_days_ago.day) #we're 1-indexed\n dayofInterest = self.energy_data.where(:year => t.year, :month => t.month, :day => t.day, :hour => (1..(t.hour+1))) #we're 1-indexed\n @dayTotals = Array.new\n count = 0\n\n hour_sim = 0\n\n #previous couple days\n last_couple_days.each do |day|\n @dayTotals[count] = [Time.utc(day.year,day.month,day.day,day.hour).to_i*1000, day.power]\n count = count + 1\n end\n\n # create array with [hour, power]\n dayofInterest.each do |day|\n last_hour = day.hour\n @dayTotals[count] = [Time.utc(day.year,day.month,day.day,day.hour).to_i*1000, day.power]\n count = count + 1\n end\n\n @dayTotals\n end", "def day_sort\n days_arry = []\n @all_days_arr = [] \n @coordinator_classes.order('day asc,time asc').group_by(&:day).each do |day,gp_class| \n if day.to_i == 0 \n days_arry << {:day => day, :gp_class => gp_class }\n else \n @all_days_arr << {:day => day, :gp_class => gp_class}\n end \n end\n @all_days_arr = @all_days_arr + days_arry\n end", "def index\n @events = Event.where('event_start >= ?', Date.today).order(:event_start, :time_begin)\n @date_events_hash = @events.group_by(&:event_start)\n end", "def in_transit_days\n \tresult = []\n \tdelivery_duration.times do |num|\n active_day = num_to_day((day_to_num(self.order_day) + num) % 7)\n \t\tresult << active_day if active_day != self.order_day && active_day != self.delivery_day\n \tend\n \tresult\n end", "def open_occurrences(days_out = 90, date_start = Time.zone.now)\n schedule = IceCube::Schedule.new(date_start)\n date_end = date_start + days_out.days\n\n # add a recurrence for each business day\n business_days.each do |bd|\n day = bd.name.downcase.to_sym\n schedule.add_recurrence_rule IceCube::Rule.weekly.day(day)\n end\n\n return schedule.occurrences(date_end)\n end", "def day_info(date)\n {\n date: date,\n current_period: @user.critical_periods.has_date(date).first,\n close_periods: @user.critical_periods.near_by_date(date).all.to_a,\n }\n end", "def hourly\n (0..23).collect { |h| redis.get(\"#{prefix_hourly}:#{Time.now.year}:#{Time.now.month}:#{Time.now.day}:#{h}\").to_i }\n end", "def events_in_period\n t0 = start.midnight\n tf = finish.end_of_day\n\n events = []\n while t0 < tf\n t1 = [t0.advance(days: 21), tf].min\n events.concat(dog.stream(t0, t1, tags: @job_tags)[1]['events'])\n t0 = t1\n end\n events\n end", "def get_work_intervals(intervals)\n intervals\n .group_by do |interval|\n interval.time_in.to_date\n end\n .values\n end", "def index\n @operating_hours = OperatingHour.all\n end", "def get_repeated\n if self.repeated.nil?\n return nil\n end\n\n days = Array.new\n DAY_VALUES.each do |k,v|\n if (self.repeated % v) == 0\n days << k\n end\n end\n\n return days\n end", "def all_potential_meetings\n meetings = []\n day_meetings.each do |day|\n @timeline_week_count.times do |wk|\n meetings << (@beginning_of_first_week + wk.weeks).date_of_upcoming(day)\n end\n end\n meetings.sort\n end", "def days_of_week_array\n dow = days_of_week_hash\n\n @days_of_week_array ||= [\n dow[:sunday],\n dow[:monday],\n dow[:tuesday],\n dow[:wednesday],\n dow[:thursday],\n dow[:friday],\n dow[:saturday]\n ]\n end", "def hours\n response[\"hours\"]\n end", "def time_range_for(open_time, close_time)\n content_tag :span, class: 'opening-hours' do\n \"#{hour_content_for(open_time, 'opens-at')} - \" \\\n \"#{hour_content_for(close_time, 'closes-at')}\".html_safe\n end\n end", "def group_entries entries\n @time_cache ||= {}\n entries.group_by do |title, _|\n begin\n time = @time_cache[title]\n (time || parse_date(title)).strftime '%Y-%m-%d'\n rescue NoMethodError, ArgumentError\n time, = title.split ' ', 2\n parse_date(time).strftime '%Y-%m-%d'\n end\n end\n end", "def get_list_for(day, hour, dayname, today)\n months = [_(:january), _(:february), _(:march), _(:april), _(:may), _(:june),\n _(:july), _(:august), _(:september), _(:october), _(:november), _(:december)]\n nobroad = \" #{_(:no_broadcast_on)}\"\n broad = \"#{_(:broadcast_on)}\"\n\n aday = DatesSchedule.get_day(@language, day)\n if aday.kind_of?(Array) and !aday.blank?\n d = aday[0].d\n m = aday[0].m - 1\n else\n d = 1\n m = 0\n end\n dm = \"#{d} #{months[m]}\"\n\n alist = Listing.get_day(@language, day)\n return \"<h3>#{nobroad} #{dayname}, #{dm}</h3>\" if alist.blank?\n list = \"<h3>#{broad} #{dayname}, #{dm}</h3>\"\n alist.each_with_index { |item, index|\n time = sprintf(\"<div class='time'>%02d:%02d - %s</div>\",\n item.start_time / 100,\n item.start_time % 100,\n calc_end_time(item.start_time, item.duration))\n title = item.title.gsub '[\\r\\n]', ''\n title.gsub! '<div>', ''\n title.gsub! '</div>', ''\n descr = item.descr.gsub '[\\r\\n]', ''\n descr.gsub!(/href=([^\"])(\\S+)/, 'href=\"\\1\\2\" ')\n descr.gsub!('target=_blank', 'class=\"target_blank\"')\n descr.gsub!('target=\"_blank\"', 'class=\"target_blank\"')\n descr.gsub!('&main', '&amp;main')\n descr.gsub!('<br>', '<br/>')\n descr.gsub!(/<font\\s+color\\s*=\\s*[\"\\'](\\w+)[\"\\']>/, '<span style=\"color:\\1\">')\n descr.gsub!(/<font\\s+color\\s*=\\s*[\"\\'](#[0-9A-Fa-f]+)[\"\\']>/, '<span style=\"color:\\1\">')\n descr.gsub!('</font>', '</span>')\n list += \"<div class='item#{index % 2}'>#{time}<div class='title icon-plus'>#{title}</div><div style='display:none;' class='descr'>#{descr}</div></div>\"\n }\n\n list + '<div class=\"item2\">&nbsp;</div>'\n end", "def get_agenda\n courses = get_courses_info\n agenda = [[], [], [], [], [], [], []]\n courses.each do |c|\n\t c['groups'].each do |g|\n\t next if not g['selected']\n\t g['hours'].each do |h|\n\t\t d = h['date_start'].to_time;\n\t\t j = {}\n\t\t j['course'] = c['name']\n\t\t j['group'] = g\n\t\t j['hour'] = h\n\t\t # Insert in sorted way\n\t\t at = 0\n\t\t agenda[d.wday].each do |a|\n\t\t if a['hour']['date_start'].to_time > d\n\t\t\t break\n\t\t end\n\t\t at = at +1\n\t\t end\n\t\t agenda[d.wday].insert(at, j)\n\t end\n\t end\n end\n agenda\n end", "def daytime_intervals(s, e, day_start = 8, day_end = 21)\n def hours(x)\n x / 24.0\n end\n\n result = []\n\n # Temporary start and end variables. These are shifted around inplace.\n ts = s\n te = e\n\n while ts < e\n # Move ts forward in time as necessary until it is inside the time range\n unless (day_start...day_end).cover?(ts.hour)\n # Advance ts to next break\n if ts.hour < day_start\n ts += hours(day_start - ts.hour)\n else\n ts += hours(24 + day_start - ts.hour)\n end\n end\n\n # ts is in range now, check te\n if (day_start..day_end).cover?(te.hour) && te.to_date == ts.to_date\n # both ts and te are in range, so add the interval and reset both\n # variables\n result << [ts, te].map(&:to_s)\n ts = te\n te = e\n else\n # Modify te to be in range, the interval will be picked up on the next\n # loop assuming all variables are still valid.\n te = ts\n te += hours(day_end - ts.hour)\n end\n end\n\n result\nend", "def time_entries(options = {})\n entries = []\n time_invested(options).groups.each { |g| entries << g[\"time_entries\"] }\n\n process_list_response( entries.flatten , Unfuddled::TimeEntry )\n end", "def grouped_by_interval( range )\n grouped = Hash.new {|h,k| h[k] = [] }\n all.each { |r| r.period_in_seconds.step( range ) { |i| grouped[i/(range)] << r } }\n grouped\n end", "def hours\n\n today = Date.today\n hours = {}\n #if @traveler.is_visitor? or @traveler.is_api_guest? #Return a wide range of hours\n if not @traveler or not @traveler.registered?\n (0..30).each do |n|\n hours[(today + n).to_s] = {open: \"07:00\", close: \"22:00\"}\n end\n\n else # This is not a guest, check to see if the traveler is registered with a service\n\n # NOTE(wilsonj806) For now this implementation does not let registered users\n #...book trips on weekends. Eventually we want to change that so they can do so\n\n if @traveler.booking_profiles.count > 0 #This user is registered with a service\n booking_profile = @traveler.booking_profiles.first\n service = booking_profile.service\n\n min_notice_days = (service.booking_details[:min_days] || 2).to_i\n max_notice_days = (service.booking_details[:max_days] || 14).to_i\n\n \n if service.booking_details[:trusted_users] and booking_profile.external_user_id.in? service.booking_details.try(:[], :trusted_users).split(',').map{ |x| x.strip }\n (1..21).each do |n|\n hours[(today + n).to_s] = {open: \"00:00\", close: \"23:59\"}\n end\n elsif service.schedules.count > 0 #This user's service has listed hours. This is the most common case.\n \n #Find out if we are past the cutoff for today. If so, start counting from tomorrow\n if service.booking_details[:cutoff_time] and (Time.now.in_time_zone.seconds_since_midnight > service.booking_details[:cutoff_time].to_i)\n day = Time.now + 1.days \n else\n day = Time.now\n end\n \n biz_days_count = 0\n (0..max_notice_days).each do |n|\n if service.open_on_day? day\n if biz_days_count >= min_notice_days\n schedule = service.schedules.where(day: day.wday).first\n if schedule\n hours[day.strftime('%Y-%m-%d')] = {open: schedule.schedule_time_to_military_string(schedule.start_time), \n close: schedule.schedule_time_to_military_string(schedule.end_time)}\n end\n end\n biz_days_count += 1\n end\n day = day + 1.days \n end\n\n else #This user is registered with a service, but that service has not entered any hours\n\n (min_notice_days..max_notice_days).each do |n|\n unless (today + n).saturday? or (today + n).sunday?\n hours[(today + n).to_s] = {open: \"08:00\", close: \"17:00\"}\n end\n end\n\n end\n\n else #This user is logged in but isn't registered with a service\n\n (1..14).each do |n|\n unless (today + n).saturday? or (today + n).sunday?\n hours[(today + n).to_s] = {open: \"08:00\", close: \"17:00\"}\n end\n end\n\n end # if #traveler.user_profile.user_services.count > 0\n end # if @travler.is_visitor\n\n render status: 200, json: hours\n\n end", "def days() 24 * hours end", "def groupByDate(bridges)\n datehash = Hash.new\n\n bridges.each do |ips|\n ips.values.each do |measurements|\n measurements.each do |m|\n time = Date.strptime(m[\"start_time\"].to_s, '%s')\n \n datehash[time] ? datehash[time].push(m) : datehash[time] = [m]\n end\n end\n end\n\n return datehash\n end", "def weekdays\n value.each_char.map { |c| WEEKDAYS.index(c) }\n end", "def recurrent_openings_for(date)\n recurrence_date = openings.recurrent(date).maximum(:starts_at)\n recurrence_date ? openings.starts_on(recurrence_date).to_a : []\n end" ]
[ "0.70517796", "0.69048524", "0.6768556", "0.6492265", "0.64917797", "0.63770425", "0.63338524", "0.6316042", "0.6208983", "0.61528325", "0.61422634", "0.6134684", "0.6125631", "0.60609424", "0.60586065", "0.60343283", "0.601223", "0.59675455", "0.5867969", "0.581537", "0.581267", "0.5801489", "0.57857394", "0.576555", "0.5741301", "0.57211304", "0.5716467", "0.57102394", "0.57062435", "0.56804526", "0.5673617", "0.56447166", "0.5568243", "0.5540107", "0.55091494", "0.5498602", "0.5491404", "0.54882866", "0.5452253", "0.5435216", "0.54200625", "0.54094744", "0.5381056", "0.5360606", "0.53439736", "0.5336803", "0.5332598", "0.5330416", "0.529555", "0.52892184", "0.5280672", "0.52793634", "0.52717865", "0.5259559", "0.5254363", "0.5251113", "0.5225537", "0.5220374", "0.52069616", "0.52023834", "0.51917154", "0.5190179", "0.5186871", "0.518423", "0.5175941", "0.5171248", "0.51699483", "0.51548487", "0.5149951", "0.514524", "0.51419723", "0.5128551", "0.5127157", "0.51229036", "0.5119997", "0.51154405", "0.51151735", "0.5109049", "0.510744", "0.51025844", "0.51023304", "0.5101508", "0.5091196", "0.50897884", "0.5086252", "0.50835824", "0.50833577", "0.5072039", "0.5062961", "0.50554645", "0.50508547", "0.50447834", "0.50297034", "0.50266916", "0.50083977", "0.5006642", "0.5004198", "0.5002816", "0.49949136", "0.4991754" ]
0.8231436
0
right now this only gets one user out of the params, but recipients can be modified to support multiple users conversation subject params are hardcoded in the view right now but this setup will take arbitrary input
def create recipients = User.where(id: params['recipients']) || [User.find_by_id(params[:uid].keys.first)] conversation = current_user.send_message(recipients, params[:message][:body], params[:message][:subject]).conversation flash[:success] = (I18n.locale == :sw ? "Ujumbe wako umetumwa" : "Your message has been sent") redirect_to conversation_path(conversation) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_other_recipients(user)\n self.users.find(:all)\n end", "def recipients_user_params\n params.require(:recipients_user).permit(:recipient_id, :user_id)\n end", "def set_recipient\n @recipient = User.find params[:user_id]\n end", "def recipients\n @recipients ||= User.where(id: self.user_ids.split(/,/))\n end", "def participants\n recipients\n end", "def set_recipients_user\n @recipients_user = RecipientsUser.find(params[:id])\n end", "def participants\n return recipients\n end", "def recipient\n recipient = User.where(:uid => recipient_uid)\n recipient.first\nend", "def recipient_user_params\n params.require(:recipient_user).permit(:message_id, :user_id)\n end", "def get_recipients\n\n recipient_ids = params[:recipient_ids]\n\n recipients = current_user.recipients.where(\"recipients.id IN (:recipient_ids)\", recipient_ids: recipient_ids)\n respond_to do |format|\n format.json { render json: recipients }\n end\n\n end", "def recipient\n two_users = self.object.users.pluck(:id)\n two_users.reject{|i| i == current_user.id}\n end", "def recipient_users\n User.active.where(id: recipient_user_ids).all\n end", "def people(convo)\n @recipients = convo.conversation.users.where('user_id <> ?', current_user)\n end", "def recipients\n # load \"app/models/mail_tasks/recipient.rb\"\n load \"app/models/mail_tasks/recipients_conditions.rb\"\n \n if params[:ignore_do_not_contact]\n sql = nil\n else\n sql = \"do_not_contact = false\"\n end\n \n \n @recipients = MailTasks::RecipientsConditions.get_recipients( params[:conditions].values, sql )\n render :partial => \"mail_recipients\", :layout => false\n end", "def recipient; end", "def other_participants(user)\n all = recipients\n all.delete(user)\n all.delete(nil) # nil will appear when any of the user in the coversation is deleted later.\n all\n end", "def recipient(recipient_id)\n User.find recipient_id\n end", "def set_recipient_data\n return if recipient_data\n return unless recipient_user_ids&.present?\n\n self.recipient_data = if email?\n recipient_users_email\n elsif sms?\n recipient_users_sms\n end\n end", "def recipient_param\n params.require(:mail).fetch(:recipient, nil)\n end", "def recipients\n @recipients ||= User.find_all_by_id(recipient_ids)\n end", "def other_user(user)\n message = self.messages.first\n message.sender == user ? message.recipient : message.sender\n # I FEEL THIS METHOD COULD BE REWRITTEN IN A MORE EFFICIENT AND SUGAR WAY\n end", "def team_invite_params\n form_params = params.require(:team_invite).permit(:recipient)\n form_params[:recipient] = User.where(username: params[:team_invite][:recipient]).first\n form_params[:sender] = current_user\n form_params[:team] = current_team\n form_params\n end", "def receive_update\n @text = params[:text]\n user = User.find_by_email params[:sender]\n if user\n\n friendship = Friendship.where user_id: user\n\n # get the recipient\n recipients = []\n friendship.each do |f|\n recipients << f.friend.email\n end\n mention = @text.scan(/\\w+@\\w+.\\w+/i)\n recipients << mention.join(', ')\n\n # get the block user\n excludes = []\n subscribes = Subscribe.where user: user, block: true\n subscribes.each do |f|\n excludes << f.target.email\n end\n\n recipients = recipients.reject { |i| excludes.include?(i) }\n\n render json: { success: true, recipients: recipients }\n else\n render json: { success: false, message: \"Sender email not found\" }\n end\n end", "def participant_user(participant,school)\n @participant = participant\n @school = school\n admin_user_ids = Participant.where(\"school_id = ? and role_id < ?\",@school.id,3).all.map(&:user_id)\n schooladmins = User.where(id: admin_user_ids).all.map(&:email)\n @applicant = User.find(@participant.user_id)\n applicant_email = \"#{@applicant.fullname} <#{@applicant.email}>\"\n\n mail to: applicant_email,\n reply_to: schooladmins,\n subject: \"Thank you for your recent registration to \" + @school.name\n end", "def get_email_recipient\n user == chat.sender ? chat.recipient : chat.sender\n end", "def recipient(current_user)\n \tself.sender_id == current_user.id ? self.receiver : self.sender\n \tend", "def process\n if recipient_ids == :all_users\n process_for_all_users\n else\n process_by_recipient_ids\n end\n end", "def user_recipients\n @user_recipients ||= begin\n [recipients].flatten.compact.map do |identifier|\n identifier = clean_identifier(identifier)\n if system_identifiers.include?(identifier)\n identifier\n else\n key = user_keys[identifier]\n if key\n # will log a warning and return nil if the import fails\n import_key(identifier, key)\n else\n Logger.warn \\\n \"No public key was found in #keys for '#{identifier}'\"\n nil\n end\n end\n end.compact\n end\n end", "def show\n @chosen_recipient = Student.find_by(id: params[:to].to_i) if params[:to]\n end", "def request_string_with_recipients #:nodoc:#\n rec_strings = []\n recipients.each_with_index do |r, id|\n rec_strings << r.request_parameters.map{ |param, val|\n \"L_#{param.to_s.upcase}#{id}=#{escape(val)}\"\n }\n end\n request_string_without_recipients + '&' + rec_strings.flatten.join('&')\n end", "def create\n puts \"########## messages create #############\"\n recipients = params[:user_ids].split(',')\n puts recipients\n recipient_ids = recipients.collect{|i| i.to_i}\n \n @message = current_user.messages.new\n @message.subject = params[:message][:subject]\n if !@message.save\n flash[:notice] = 'Can not sent message.'\n return render :action => \"new\"\n end\n\n @conversation = @message.conversations.new\n @conversation.sender = current_user\n @conversation.content = params[:message][:conversation][:content]\n\n respond_to do |format|\n if @conversation.save\n MessageStatus.associate_user(@message, current_user, recipient_ids)\n format.html { redirect_to(messages_path, :notice => 'Message was successfully sent.') }\n format.xml { render :xml => @message, :status => :created, :location => @message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_recipient_user\n @recipient_user = RecipientUser.find(params[:id])\n end", "def create\n\n @message = current_user.messages.build\n @message.subject = params[:message][:subject]\n @message.body = params[:message][:body]\n# @message.to User.find_by_username(params[:message][:to])\n @message.to User.find(:all, :conditions=>[\"username IN (\\\"#{params[:message][:to].split(',').join(\"\\\",\\\"\")}\\\")\" ]) unless params[:message][:to].nil?\n\n\n respond_to do |format|\n if @message.save\n @message.deliver\n\n flash[:notice] = 'Message was successfully created.'\n format.html { redirect_to(@message) }\n format.xml { render :xml => @message, :status => :created, :location => @message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def recipient\n Recipient.find(payment_params[:recipient_id])\n end", "def recipient_params\n params.require(:recipient).permit(:name, :phone_number, :got_yaa_id, :email, :message_sent, :has_responded)\n end", "def email_players(recipient, params)\n \n subject = params[:email_subject]\n @text = params[:email_text]\n @game = Game.find(params[:game_id])\n @sender = User.find(params[:sender_id])\n \n mail :to => recipient, :subject => subject\n end", "def recipients_to_notify\n\t\tif self.which_user_ids_should_receive_notifications.blank?\n\t\t\t#puts \"which user ids is blank\"\n\t\t\t[Notification::Recipient.new(user_id: self.created_by_user_id.to_s)]\n\t\telse\n\t\t\t#puts \"it is not blank\"\n\t\t\tself.which_user_ids_should_receive_notifications[0..5].map{|user_id|\n\t\t\t\tNotification::Recipient.new(user_id: user_id)\n\t\t\t}\n\t\tend\n\tend", "def filtered_recipients\n return recipients unless mailable.respond_to?(:conversation)\n\n recipients.each_with_object([]) do |recipient, array|\n array << recipient if mailable.conversation.has_subscriber?(recipient)\n end\n end", "def conversation_params\n params.require(:conversation).permit(:participant_id).merge(user_id: current_user.id)\n end", "def message_params\n # Get messagebox_id\n usercontact = Usercontact.find_by(user_id: current_user.id, contacted_id: params[:user_to_id])\n params.permit(:content, :user_to_id).merge(user_from_id: current_user.id, messagebox_id: usercontact.messagebox_id)\n end", "def user\n if scope.id == object.sender_user_id\n object.recipient_user\n else\n object.sender_user\n end\n end", "def send_email(user, user_url)\n user.recipients.each do |recipient|\n @recipient = recipient\n @user = user\n @executor = user.executors.first\n @user_url = user_url\n mail( \n :to => @recipient.email,\n :subject => 'Our Condolences') do |format|\n format.html {render 'send_email' }\n format.text { render 'send_plain_email'}\n end\n end\n end", "def gather_recipients\n\t\tarr = (self.recipients_to_notify + self.recipients + self.additional_recipients).reject{|c| self.disable_recipient_ids.include? c.id.to_s}\n\t\tif arr.select{|c|\n\t\t\tc.user_id == self.created_by_user_id\n\t\t}.size == 0\n\t\t\tarr << Notification::Recipient.new(user_id: self.created_by_user_id)\n\t\tend\n\t\tarr\n\tend", "def private_conv_recipient(conversation)\n conversation.opposed_user(current_user)\n end", "def get_other_recipient(current_user)\n # if self.user1 == current_user ? self.user1 : self.user2; end\n if self.user1 == current_user\n self.user2\n else\n self.user1\n end\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 with(current_user)\n \tsender == current_user ? recipient : sender\n\tend", "def correspond\n @user = current_user\n @recipient = User.find(params[:id])\n @title = \"Email #{@recipient.name}\"\n if param_posted?(:original) #if user is responding to an original mail \n # @original and @original_subject will be availabe in the correspond view\n @original_title = session[:original_title]\n @original_body = session[:original_subject]\n end\n\n @message ||= Message.new({:subject=>\"\", :body=>\"\"})\n\n if param_posted?(:message)\n #if @message.update_attributes(params[:message])\n @message.subject = params[:message][:subject]\n @message.body = params[:message][:body]\n\n if @message.valid?\n #@body_sesson and @title_session will be available to mailer and it's correspond_message view\n @body_session = session[:original_message] #creating session in the controller \n @title_session = session[:original_title]\n #passing message params including session instances to be accessible in action mailer\n UserMailer.correspond_mail(@user, @recipient, @message, \n @body_session, @title_session).deliver\n flash[:success] = \"Email sent to #{@recipient.name}\"\n redirect_to profile_path(@recipient)\n end\n end\n\n end", "def recipient\n case self.class.to_s\n when \"Survey\"\n giver\n when \"User\"\n self\n else\n raise 'Not implemented.'\n end\n end", "def recipient_params\n params.require(:recipient).permit(:sca_name, :mundane_name, :is_group, :also_known_as, :formerly_known_as, :title, :pronouns, :heraldry, :heraldry_blazon, :mundane_bio, :sca_bio, :activities, :food_prefs)\n end", "def index\n # check if this current_user are involved in conversation\n if current_user == @conversation.sender || current_user == @conversation.recipient\n @other = current_user == @conversation.sender ? @conversation.recipient : @conversation.sender\n\n # 送信先のユーザー名を取得\n if current_user == @conversation.sender\n @recipient_user_name = @conversation.recipient.name\n else\n @recipient_user_name = @conversation.sender.name\n end\n\n @messages = @conversation.messages.order(\"created_at DESC\")\n else\n redirect_to conversations_path, alert: \"他人のメッセージにアクセスできません\"\n end\n\n end", "def exclude_sender_in_team_from_recognition_recipients\n sender_recipients = recognition_recipients.select {|rr| rr.user_id == sender&.id }\n if sender_recipients.any?{|rr| rr.team_id.present? } && sender_recipients.none?{|rr| rr.team_id.nil? }\n self.recognition_recipients = self.recognition_recipients.reject{|rr| rr.team_id.present? && rr.user_id == sender.id}\n end\n end", "def recipients\n Array.wrap(::User.find_by_user_key(@work.depositor))\n end", "def find_conversation!\n if params[:receiver_id]\n @receiver = User.find_by(id: params[:receiver_id])\n @conversation = Conversation.between(current_user.id, @receiver.id)[0]\n if @conversation\n redirect_to conversation_personal_messages_path(@conversation)\n else\n @conversation = Conversation.create(params.permit(:author_id, :receiver_id))\n redirect_to conversation_personal_messages_path(@conversation)\n end\n else\n @conversation = Conversation.find_by(id: params[:conversation_id])\n # redirect_to(root_path) unless @conversation && @conversation.participates?(current_user)\n end\nend", "def email_params\n params.require(:email).\n permit(:to, :subject, :body).\n merge(from: @user.to_s.downcase).tap do |params|\n params[:to] = params[:to].downcase\n end\n end", "def receive_email\n \n \n #if one of the to addresses matches us, use that one. todo - correctly handle mulitple emails, or correctly fail\n if params[:to].match(/group\\+(\\d+)@/) && @group = Group.find($1)\n from = params[:from]\n body = params[:plain].gsub(/^On .* wrote:$\\s*(^>.*$\\s*)+/,'') #strip out replies and whatnot\n\n if @sender = @group.students.find_by_email(from)\n @group.send_message(@sender.name+\": \"+body,@sender,[@group.user])\n elsif @group.user.email==from\n @group.send_message(@group.user.display_name+\": \"+body,@group.user)\n end\n end\n render :text => 'success', :status => 200\n end", "def recipients\n self.class.\n where(volunteer_id: self.volunteer_id, date: self.date, type: self.type).\n map(&:recipient)\n end", "def conversation_params\n params.require(:conversation).permit(:user_one_id, :user_two_id)\n end", "def other_user usr\n usr.id == user_id ? recipient : user\n end", "def recipients(params = {})\n @api.get(\"#{@api.path}/Group/#{@id}/Recipients\", params: params)\n end", "def index\n @recipients = @user.recipients\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @recipients }\n end\n end", "def show\n @recipient = @user.recipients.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @recipient }\n end\n end", "def recipient\n return @recipient\n end", "def get_email_recipients(resource)\n if resource.creators.present?\n email_recipients = resource.creators\n else\n email_recipients = [resource.contributor] unless resource.contributor.nil?\n end\n email_recipients = email_recipients - [ User.current_user.person ] unless email_recipients.nil?\n end", "def recipient_details (user)\n details = {:recipient_name => user.first_name}\n details.merge!(:student_name => alert_variables[:student_name][user.email]) if alert_variables[:student_name]\n details\n end", "def conversation_params\n params.require(:conversation).permit(:user1_id, :user2_id, :user1read, :user2read, messages_attributes: [:id, :conversation_id, :sender_id, :receiver_id, :text])\n end", "def restrict_to_participants\n # Get the message\n if (message = Message.find_by_id params[:id])\n # Return if the user is in the message\n return if [message.student, message.instructor].include? @auth_user\n end\n\n # Redirect to messages\n redirect_to messages_path\n end", "def compose_message\n @private_message = current_user.private_messages.new(\n :subject => params[:private_message][:subject], \n :body => params[:private_message][:body], \n :file_attachment_attributes => params[:private_message][:file_attachment_attributes], \n :username => current_user.username)\n \n # Before saving, evaluate (1) the message itself, (2) the presence of recipients, and (3) correctly chosen recipients\n unless params[:recipient_list].blank?\n @users = params[:recipient_list].split()\n @users.map {|n|\"'\" + n.strip + \"'\"} \n @users.each do |username|\n user = User.with_active.find_by_username(username)\n @private_message.errors.add(\"recipients\", \" includes a user, '\" + username + \"', that does not exist or is inactive\") unless user\n end\n else\n @private_message.errors.add(\"recipients\", \" must be chosen\")\n end\n end", "def get_recipients\n fail NotImplementedError\n end", "def additional_users_for_general_mailing\n [@role.user]\n end", "def conversation_params\n params[:conversation]\n end", "def conversation_params\n params[:conversation]\n end", "def recipient\n return self.unless_nil?('invitee.email', deliveries.unless_nil?('first.recipients', '') )\n end", "def index\n @recipients_users = RecipientsUser.all\n end", "def set_objects \n @recipient = Recipient.find(params[:recipient_id]) if params[:recipient_id]\n end", "def conversation_params\n params.require(:conversation).permit(:user_a_id, :conversation_id, :user_b_id)\n end", "def index\n # @messages = Message.all\n # @messages = Message.where(user_id: session[:user_id])\n\n @messages = Message.where(recipient: current_user[:email])\n @sent_messages = Message.where(user_id: session[:user_id])\n @username = current_user[:email]\n end", "def conversations\n Conversation.where(\"sender_id = ? or recipient_id = ?\",self.id,self.id)\n end", "def new\n @recipient = User.find_by_id(params[:id])\n end", "def show\n #@direct_message = DirectMessage.find(params[:id])\n \n r_name = User.find(@direct_message.recipient_id) \n \n @json_request = {recipient: r_name.name}\n respond_to do |format|\n #format.html # show.html.erb\n format.json { render json: @json_request }\n end\n end", "def recipient_emails\n recipients.map(&:first)\n end", "def sender\n user = User.find_by_id(sent_by)\n \"#{user.first_name} #{user.last_name}\"\n end", "def recipient\n return @recipient\n end", "def recipients(sender)\n participants.reject { |p| p.id == sender.id }\n end", "def create\n params[:message][:recipients].reject(&:blank?) if params[:message][:recipients].is_a? Array\n @recipients = @structure.user_profiles.find(params[:message][:recipients]) if params[:message].has_key? :recipients\n @recipients = (@recipients.is_a?(Array) ? @recipients.map(&:user) : @recipients.user)\n @receipt = @admin.send_message_with_label(@recipients, params[:message][:body], params[:message][:subject], Mailboxer::Label::CONVERSATION.id) if @recipients and @recipients.present? and params[:message][:body].present?\n @conversation = @receipt.conversation if @receipt\n respond_to do |format|\n if @conversation and @conversation.persisted?\n format.html { redirect_to params[:return_to] || pro_structure_conversation_path(@structure, @conversation), notice: 'Votre message a bien été envoyé' }\n format.js\n else\n @message = @admin.messages.build params[:message]\n @message.valid? # Triggers errors to appear\n @message.errors.add :recipients, :blank if @recipients.blank?\n format.html { render action: :new }\n format.js\n end\n end\n end", "def unique_recipients\n @unique_recipients ||= if config && notifications = config['notifications']\n notifications['recipients']\n else\n recipients = [committer_email, author_email, repository.owner_email]\n recipients.select(&:present?).join(',').split(',').map(&:strip).uniq.join(',')\n end\n end", "def show\n @message = @message\n @parent = Message.find_by_id(@reply_message_id)\n\n if @message.is_system_notification != 1\n @id = []\n @id << @message.user_id.to_s && @id << @message.to_user_id.to_s\n if !@id.include?(@current_user.id.to_s)\n redirect_to \"/contact_us\"\n end\n else\n @to_user_id_array = @message.to_user_id.split(\",\")\n if !@to_user_id_array.include?(@current_user.id.to_s)\n redirect_to \"/contact_us\"\n end\n end\n\n\n end", "def conversation_params\n params.require(:conversation).permit(:recipient_id, :sender_id)\n end", "def recipients\n Hancock::Request.send_get_request(\"/envelopes/#{envelope_id}/recipients\")\n end", "def user_connection_params\n params.require(:user_connection).permit(:recipient_user_id).\n merge!({\"sender_user_id\" => current_user.id, \"created_by\" => current_user.id, \"updated_by\" => current_user.id})\n end", "def receiver\n users[0].id.eql?(sent_by) ? users[1] : users[0]\n end", "def recipient=(value)\n @recipient = value\n end", "def conversations\n Conversation.where(\"sender_id = ? OR recipient_id = ?\", id,id)\n end", "def set_recipient\n end", "def author_request # :norobots:\n pass_query_params\n @object = AbstractModel.find_object(params[:type], params[:id].to_s)\n return unless request.method == \"POST\"\n subject = param_lookup([:email, :subject], \"\")\n content = param_lookup([:email, :content], \"\")\n (@object.authors + UserGroup.reviewers.users).uniq.each do |receiver|\n AuthorEmail.build(@user, receiver, @object, subject, content).deliver\n end\n flash_notice(:request_success.t)\n redirect_with_query(controller: @object.show_controller,\n action: @object.show_action, id: @object.id)\n end", "def contact_to(subject)\n sent_contacts.received_by(subject).first\n end", "def view!(recipient)\n valid_recipients = recipients.select{|r| r.receiver == recipient}\n raise Exception, \"not a valid recipient of this email\" if valid_recipients.empty?\n \n valid_recipients.each{|mr| mr.view!}\n recipient.reload # hate having to do this but I'm not sure how else to accomodate the updates due to caching(?)\n end", "def recipients\r\n @recipients ||= RecipientsController.new(configuration: @configuration)\r\n end", "def recipients_list\n to.split(/\\s*,\\s*/)\n end", "def set_recipient\n @recipient = Recipient.find(params[:id])\n end", "def conversation_params\n params.permit(:participants, participants: [])\n end" ]
[ "0.67741156", "0.66519594", "0.6598331", "0.6495169", "0.6494603", "0.63888913", "0.6386048", "0.638197", "0.6355738", "0.63543403", "0.6350996", "0.6293286", "0.6263963", "0.6210231", "0.6169928", "0.6108885", "0.6103873", "0.60995907", "0.6096281", "0.6055742", "0.6049496", "0.60043883", "0.59996", "0.5997326", "0.59893703", "0.5983056", "0.59795445", "0.59679234", "0.5952635", "0.5948046", "0.5935621", "0.5934202", "0.59299046", "0.5929284", "0.59291744", "0.5921497", "0.5900534", "0.58986735", "0.58792704", "0.5877019", "0.5876233", "0.58629817", "0.5855938", "0.58509934", "0.58489853", "0.58392805", "0.58314604", "0.5827948", "0.58223593", "0.58060414", "0.58032525", "0.58010364", "0.57989705", "0.5795121", "0.5792797", "0.57924545", "0.57894915", "0.5784021", "0.5777939", "0.5776673", "0.5770322", "0.5767277", "0.5763507", "0.5760485", "0.57579017", "0.57574785", "0.57516354", "0.5744565", "0.5743548", "0.5741061", "0.5733704", "0.5733704", "0.57061124", "0.570228", "0.5700785", "0.5696854", "0.56843454", "0.5681295", "0.5660979", "0.566028", "0.56601125", "0.56395555", "0.5634899", "0.56346506", "0.5634273", "0.5631291", "0.563057", "0.56265455", "0.56225234", "0.5621894", "0.56142217", "0.5612697", "0.5608027", "0.55990565", "0.5596477", "0.5595864", "0.55958074", "0.5595593", "0.5592324", "0.5590573", "0.5581116" ]
0.0
-1
subject is hardcoded in messages/new.html.erb but we can replace the hidden with a normal field if we want if someone really wants to modify the request they can set their own subject but whatever
def admin_message redirect_to root_path unless admin_user? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message_subject=(value)\n @message_subject = value\n end", "def subject\n self['subject'] || msg['subject']\n end", "def subject=(subject); @message_impl.setSubject subject; end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def subject=(text)\n current_div.text_field(:id=>\"comp-subject\").set text\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_subject\n @subject = Subject.find params[:subject_id]\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def subject=(value)\n @subject = value\n end", "def set_subject\n @subject = Subject.friendly.find(params[:id])\n end", "def subject\n message.subject\n end", "def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end", "def subject_and_status(message)\n tag = ''\n if message.receiver_deleted?\n tag = \" (Deleted)\"\n elsif message.read_at.nil? and params[:action] != \"outbox\"\n \"&middot; <strong>#{message.subject}</strong>\".html_safe\n else\n message.subject\n end\n end", "def subject=(string)\n set('Subject', string)\n end", "def set_subject_and_message(form, subject, message)\n raise Impostor::MissingTemplateMethodError.new(\"set_subject_and_message must be implemented\")\n end", "def message_subject\n return @message_subject\n end", "def subject_params\n params[:subject].permit(:name, :user_id, :user)\n end", "def set_subject\n @subject = Subject.find(params[:subject_id])\n end", "def subject_params\n #params.require(:subject).permit(:name, :category_id, :user_id, messages_attributes: [:id, :created_at, :update_at, :subject_id, :content, :user_id, :category_id])\n\tparams.require(:subject).permit(:name, :category_id, :user_id)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_subject\n @subject = params[:id] ? Subject.find(params[:id]) : Subject.new(subject_params)\n end", "def set_subject\n @subject = params[:id] ? Subject.find(params[:id]) : Subject.new(subject_params)\n end", "def subject_params\n params.fetch(:subject, {}).permit(:name)\n end", "def subject; @message_impl.getSubject; end", "def subject\n title \n end", "def subject_params\n params.require(:subject).permit(:title, :content)\n end", "def set_subject(subject)\n\t\tend", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def set_subject\r\n @subject = Subject.find(params[:id])\r\n end", "def get_subject\n\t\tend", "def set_subject\n @subject = Subject.find(params[:id])\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def setSubject(subject)\n @fields['subject'] = subject\n self\n end", "def title=(string)\n frm.text_field(:id=>\"subject\").set(string)\n end", "def set_subject\n\t\t\t@subject = Subject.find(params[:id])\n\t\tend", "def subject_params\n params.require(:subject).permit(:description, :text, :document_type_id, :deleted_at)\n end", "def subject\n @subject ||= \"(sans sujet)\"\n if @no_header_subject.nil?\n \"#{header_subject}#{@subject}\"\n else\n @subject\n end\n end", "def subject\n self['subject']\n end", "def subject() self.headers[\"Subject\"] || \"[NO SUBJECT]\" end", "def set_additional_subject\n @additional_subject = AdditionalSubject.find(params[:id])\n end", "def subject_name=(value)\n @subject_name = value\n end", "def message_subject\n active_div.div(:id=>\"inbox_show_message\").div(:class=>\"inbox_subject\").link.text\n end", "def subject_link_helper(text, rec_id, action)\n if action == 'show'\n action = user_message_path(current_user.id, rec_id)\n else\n action = edit_user_message_path(current_user.id, rec_id)\n end\n subject = (text.nil? || '' == text) ? '.............' : text\n new_subject = subject.length > 30 ? subject.slice(0..29) + '...' : subject\n html_options = {\n :title => subject,\n }\n link_to(new_subject, action, html_options)\n end", "def subject\n @options.fetch(:subject) { \"Invitation\" }\n end", "def subject_name\n subject_full_name\n end", "def show\n @subject = get_subject\n end", "def subject\n @subject\n end", "def subject\n @subject\n end", "def ezm_subject_and_status(message)\r\n if message.receiver_deleted?\r\n message.subject + \" (Deleted)\" \r\n elsif message.read_at.nil?\r\n message.subject + \" (Unread)\" \r\n else \r\n message.subject\r\n end\r\n end", "def subject_params\n params.require(:subject).permit(:index, :new, :create, :show, :update, :delete)\n end", "def subject_params\r\n params.require(:subject).permit(:code, :name, :description)\r\n end", "def subject_params\n params.require(:subject).permit(:name)\n end", "def subject_params\n params.require(:subject).permit(:name)\n end", "def subject_params\n params.require(:subject).permit(:name)\n end", "def new\n @subject = current_user.subjects.where(project_id: @project.id).new(subject_params)\n end", "def assign_canned_subject\n self.subject = canned_subject\n end", "def rezm_subject_and_status(message)\n if message.receiver_deleted?\n message.subject + \" (Deleted)\" \n elsif message.read_at.nil?\n message.subject + \" (Unread)\" \n else \n message.subject\n end\n end", "def set_subject\n begin\n @subject = Subject.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to access invalid subject #{params[:id]}\"\n @subject_not_found = true\n render json: {message: \"Illegal subject access request\"}, status: :unauthorized\n return\n else\n @subject_not_found = false\n end\n end", "def subject_params\n params.require(:subject).permit(:name, :title, :content, :cover, :position, :status, :remove_cover)\n end", "def subject_name\n return @subject_name\n end", "def subject_params\n params.require(:subject).permit(:name, :position, :visible, :created_at)\n end", "def open_subject_id_form\n click_subject_buttons('Subject ID')\n end", "def create\n \t@subject = Subject.new(subject_params)\n\n\trespond_to do |format|\n\t if @subject.valid? and !params[:content].empty?\n\t\t@subject.save\n\t\tfirst_message = Message.create(content: params[:content], user_id: current_user.id, subject_id: @subject.id)\t\n\n\t\tformat.html { redirect_to @subject, notice: 'Subject was successfully created.' }\n\t\tformat.json { render :show, status: :created, location: @subject }\n\t else\n\t\tsetup_new_subject_params\n\t\tif params[:content].empty?\n\t\t\t@missing_content = true\n\t\tend\n\t\tformat.html { render :new }\n\t\tformat.json { render json: @subject.errors, status: :unprocessable_entity }\n\t end\n\t end\n end", "def subject_params\n params.require(:subject).permit(:name, :course_id)\n end", "def subject=(subject)\n self.subjects = [subject]\n end", "def subject_with_formatting\n (self.subject.blank?) ? 'N/A' : self.subject\n end", "def subject\n @mail.subject\n end", "def subject_params\n params.require(:subject).permit(:experiment_id, :email, :phone_number,:name,:custom_field_1_value,:custom_field_2_value,:custom_field_3_value)\n end", "def data_subject=(value)\n @data_subject = value\n end", "def new\n @subject = Subject.new\n\n end" ]
[ "0.729674", "0.7173166", "0.71237373", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.6833999", "0.6727346", "0.672659", "0.66890943", "0.66677266", "0.66677266", "0.66677266", "0.66677266", "0.66677266", "0.66677266", "0.66447884", "0.6611799", "0.6590474", "0.6581054", "0.65664977", "0.65187824", "0.65086865", "0.6472249", "0.6471138", "0.6452306", "0.64472055", "0.6446153", "0.6444278", "0.6444278", "0.6440206", "0.6421219", "0.6405577", "0.6391454", "0.6382839", "0.6379795", "0.6379795", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63752574", "0.63671327", "0.6365992", "0.6363767", "0.6360464", "0.6360464", "0.6360464", "0.6360464", "0.63473314", "0.6336151", "0.63287383", "0.6325933", "0.63219255", "0.6299882", "0.6263147", "0.62556076", "0.62474215", "0.6239766", "0.62129366", "0.61875224", "0.6187126", "0.61476696", "0.61476696", "0.610959", "0.6100867", "0.6089854", "0.607856", "0.607856", "0.607856", "0.6070073", "0.6066297", "0.6052605", "0.60412645", "0.6038544", "0.60270625", "0.6011292", "0.6000928", "0.6000342", "0.5998671", "0.5986026", "0.59698284", "0.5961294", "0.5959779", "0.5941687", "0.59327817" ]
0.0
-1
GET /graphium/cities GET /graphium/cities.json
def index @graphium_cities = Graphium::City.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n neo = Neography::Rest.new\n r = neo.execute_query(\"START n=node(*) RETURN n;\")\n r[\"data\"].shift # first node is wacky\n @cities = r[\"data\"].map { |node|\n OpenStruct.new(node[0][\"data\"].merge(id: node[0][\"self\"].match(/node\\/(\\d+)$/)[1].to_i))\n }\n end", "def cities\n CS.get :us, :ca\n end", "def city\n fetch('dune.cities')\n end", "def cities\n cities = CS.cities(params[:id], :GB)\n if cities.blank?\n country = ISO3166::Country.find_country_by_alpha3(params[:id])\n cities = country_cites(country)\n return(render json: { message: I18n.t(:invalid_country) }) if cities.blank?\n end\n render json: cities\n end", "def city\n fetch('world_cup.cities')\n end", "def get_list_cities\n City.get_all_cities\n end", "def city\n fetch('dnd.cities')\n end", "def index\n @cities = City.all\n\n render json: @cities\n end", "def print_city_list\n\n # simply call the print_vertices function of the graph API\n @query.get_graph.each_key { |city| puts \"#{get_city_info(city,\"name\")}\"}\n\n end", "def show_cities\n\n @cities = City.where(\"country_id = ?\", params[:country_id])\n\n render json: @cities\n \n end", "def index\n @cities = CITIES\n end", "def cities\n galleries.map do |c|\n c.city\n end\n end", "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 index\n\n if params[:region_id]\n\n @regions = Region.where(id: params[:region_id])\n render json: @regions, include: [:cities], show_children: true\n\n elsif params[:ip]\n\n @iprange = Iprange.find_by_ip params[:ip]\n\n if @iprange\n\n render json: @iprange.city, include: [:region], show_parent: true\n\n else\n throw ActiveRecord::RecordNotFound\n end\n\n else\n\n @cities = City.all\n\n render json: @cities\n\n end\n end", "def geo\n\t\tciudad = params[:id]\n\t\t@ubication = City.where(id: ciudad)\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @ubication }\n\t\tend\n\tend", "def getAllCities\r\n result = []\r\n @vertex.each_value do |city|\r\n result << city.name\r\n end\r\n return result\r\n end", "def show\n render json: @city\n end", "def index\n @cities = City.where(state_id: params[:id])\n respond_to do |format|\n format.json { render :json => @cities.to_json }\n end\n end", "def test_get_all_cities\n \n test_map = ' { \"metros\" : [ {\n \"code\" : \"LON\" ,\n \"name\" : \"London\",\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"PAR\" ,\n \"name\" : \"Paris\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"LIM\" ,\n \"name\" : \"Lima\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1 \n } , {\n \"code\" : \"MOW\" ,\n \"name\" : \"Moscow\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } ] ,\n \"routes\" : [ {\n \"ports\" : [\"LON\" , \"PAR\"] ,\n \"distance\" : 2410\n } , {\n \"ports\" : [\"LON\" , \"MOW\"] ,\n \"distance\" : 4323\n } , {\n \"ports\" : [\"LIM\" , \"PAR\"] ,\n \"distance\" : 4323\n } ] } '\n graph = Graph.new()\n graph.parse_json_string(test_map)\n \n result = graph.get_all_cities()\n \n assert_equal( result.scan(/[A-Z]*, [A-Z]{3}/).size, 4)\n assert_equal( result.include?(\"London, LON\"), true )\n assert_equal( result.include?(\"Moscow, MOW\"), true )\n assert_equal( result.include?(\"Lima, LIM\"), true )\n assert_equal( result.include?(\"Paris, PAR\"), true )\n \n end", "def cities()\n sql = \"SELECT cities.* FROM cities WHERE country_id = $1\"\n values = [@id]\n cities = SqlRunner.run(sql, values)\n result = City.map_items(cities)\n return result\n end", "def cities\n galleries.map {|g| g.city}\n end", "def cities\n gallaries.map{|place| place.city}\n\n end", "def index\n if params[:country]\n country = Country.find_by_id(params[:country])\n if !country.nil?\n @cities = country.cities\n else\n flash[:error] = t(:country_not_found)\n @cities = nil\n end\n else\n return redirect_to countries_path\n end\n\n respond_to do |format|\n# format.html # index.html.erb\n format.json { render json: @cities }\n end\n end", "def index\n get_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cities }\n format.js\n end\n end", "def set_graphium_city\n @graphium_city = Graphium::City.find(params[:id])\n end", "def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend", "def index\n @user = User.find(params[:id])\n @cities = @user.cities\n render :index\n end", "def index\n get_paginated_cities\n if @cities.to_json \n History.create(:name => 'Kota', :status => 'Completed')\n render json: @cities.to_json\n else\n History.create(:name => 'Kota', :status => 'Failed')\n end\n end", "def index\n @state = State.find(params[:state_id])\n @cities = City.where(:state_id => params[:state_id]).paginate(:page => params[:page], :per_page => 10, :order => 'name')\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cities }\n end\n end", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n #undefined method `city' for \"New York\":String\n end", "def city\r\n\t\t\t@city ||= json[\"cit\"].to_s.capitalize\r\n\t\tend", "def index\n hash = cookies[:city_hash]\n @city = City.find_by(city_hash: hash)\n @units = @city.units\n\n render json: @units, status: :ok\n end", "def index\n @cities = City.all\n end", "def index\n @cities = City.all\n end", "def index\n @cities = City.all\n end", "def index\n @cities = City.all\n end", "def index\n @cities = City.all\n end", "def cities_in_state\n cities = State.find(params[:id]).cities.order(name: :asc)\n\n render json: cities.to_json(), status: :ok\n end", "def list_cities\n list_galleries.map do |gallery|\n gallery.city\n end\n end", "def index\n @m_cities = MCity.all\n end", "def api_request(city)\n url = \"https://jobs.github.com/positions.json?utf8=%E2%9C%93&description=&location=\"+city\n #Escape and parse URL for proper formatting.\n escaped_url = URI.escape(url)\n parsed_url = URI.parse(escaped_url)\n #Make the HTTP request.\n request = Net::HTTP.get(parsed_url)\n #Parse the JSON response.\n response = JSON.parse(request)\n #Returns all listings for the given city.\n return response\n end", "def stay_city\n # cities = Country.all.map{|country|country.cities}\n # cities.map{|city|city.name}\n end", "def cities\n Gallery.all.map{|list| list.city}\n end", "def index\n @world_cities = PhillyCrime.paginate(page: params[:page])\n end", "def index\n city_list = City.all\n puts city_list.inspect\n\n render json: city_list.to_json\n end", "def cities\n self.galleries.map do |gi|\n gi.city\n end\n end", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n end", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n end", "def city\n\t\tself.client.city\n\tend", "def cities\n galleries.map {|gallery| gallery.city}\n end", "def cities\n galleries.map {|gallery| gallery.city}\n end", "def new\n @cities=State.find_by_id(params[:body][:id]).cities.select(\"id, name\")\n render :json=>success1(:cities=>@cities)\n end", "def index\n @ezii_cities = EziiCity.all\n end", "def cities()\n \n url = \"http://servicos.cptec.inpe.br/XML/listaCidades\"\n \n cities = Array.new\n \n request ||= requestXml(url)\n \n request.xpath('//cidades/cidade').each do |cidadePath|\n \n cidade = Hash.new\n \n cidade[:id] = cidadePath.at_xpath('id').text.strip\n cidade[:uf] = cidadePath.at_xpath('uf').text.strip\n cidade[:nome] = cidadePath.at_xpath('nome').text.strip\n \n cities << cidade\n \n end\n \n cities\n \n end", "def create\n @graphium_city = Graphium::City.new(graphium_city_params)\n\n respond_to do |format|\n if @graphium_city.save\n format.html { redirect_to @graphium_city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @graphium_city }\n else\n format.html { render :new }\n format.json { render json: @graphium_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n\n@cities = City.all\n\nend", "def index\n @sitecities = Sitecity.includes(:events).order(\"name asc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sitecities }\n end\n end", "def cities()\n sql = \"SELECT cities.* FROM cities WHERE country_id = $1;\"\n values = [@id]\n city_list = SqlRunner.run(sql, values)\n return city_list.map{|city| City.new(city)}\n end", "def all_organisations_in_city(city)\n sparql = \"\n SELECT DISTINCT ?uri ?label\n WHERE \n {\n VALUES ?city { \\\"#{city}\\\" }\n GRAPH <http://data.artsapi.com/graph/organisations> {\n ?uri <http://data.artsapi.com/def/arts/locationCity> ?city .\n ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label .\n }\n }\n \"\n\n results = User.current_user.within { Tripod::SparqlClient::Query.select(sparql) }\n\n results.map { |r| [r[\"uri\"][\"value\"], r[\"label\"][\"value\"]] }\n end", "def getCityInfo(city)\r\n result = @vertex.find{ |code, cname| (code == city || cname.name == city)}\r\n\r\n if result.nil?\r\n puts \"There is no such city in CSAir.\"\r\n puts \"\"\r\n puts \"Please input 1 for list of all the cities CS Air travels to\"\r\n puts \"Please input 2 for specific information about a city in the CS Air network\"\r\n puts \"Please input 3 for the other statistics\"\r\n puts \"Please input 4 to Visualize CSAir's route map\"\r\n puts \"Please input 5 to exit\"\r\n else\r\n result[1].printVertex\r\n puts \"\"\r\n connectedCities(result[1].code)\r\n puts \"\"\r\n puts \"Please input 1 for list of all the cities CS Air travels to\"\r\n puts \"Please input 2 for specific information about a city in the CS Air network\"\r\n puts \"Please input 3 for the other statistics\"\r\n puts \"Please input 4 to Visualize CSAir's route map\"\r\n puts \"Please input 5 to exit\"\r\n end\r\n end", "def index\n @communities = @district.communities.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @communities }\n end\n end", "def index\n @cities = current_user.cities\n \n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def show\n @sitecity = Sitecity.find_by_url(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sitecity }\n end\n end", "def cities()\n sql=\"SELECT * FROM cities WHERE country_id = $1\"\n values = [@id]\n cities = SqlRunner.run(sql, values)\n return cities.map{|city| City.new(city)}\n end", "def cities opt, graph\n\n\tp opt, graph\n\t#first try all cities spread over USA, should be easy to figure out if the correct tour was picked\n\tcities = 'd,DC,77.01,38.90;l,Los_Angeles,118.25,34.05;c,Chicago,87.68,41.83;m,Memphis,89.97,35.11;h,Houston,95.36,29.76;\n\t\t\t\t L,Las_Vegas,115.17,36.12;k,Kansas_city,94.57,39.09;M,Miami,80.20,25.77;s,San_Fran,122.41,37.78;a,Dallas,96.79,32.77;\n\t\t\t \t n,Nashville,86.78,36.16;e,Detroit,83.04,42.33;p,Phoneix,112.06,33.45;D,Denver,104.99,39.73'\n\n\tloop_over cities: cities, pool_size: 30, graph: graph, vmirror: true, hmirror: true if opt == '1'\n\n\t#Now add sort of a loop in California\n\tcities += ';S,Sacramento,121.46,38.55;f,Fresno,119.76,36.75;A,San_jose,121.88,37.33;C,Carson_city,119.75,39.16'\n\tloop_over cities: cities, pool_size: 30, graph: graph, vmirror: true, hmirror: true if opt == '2'\n\n\t#Now try with randomly generated cities\n\tif opt == '3' or opt.nil?\n\t\tcities = nil\n\t\tloop_over cities: cities, pool_size: 30, graph: graph\n\tend\n\nend", "def graphium_city_params\n params.require(:graphium_city).permit(:name, :state, :state_code, :country, :country_code, :population, :osm_node_id)\n end", "def searchByCity\n\t\turl = request.original_url\n\t\t\n\t\tbegin\n\n\t\t\tprms = CGI.parse(URI.parse(url).query)\n\n\n\t\t\tresults = Doctor.where(\"city LIKE ?\", \"%#{prms['city'][0]}%\")\n\n\t\t\trender json: results\n\t\trescue Exception => e\n\t\t\trender json: { errors: \"Some errors\" }, status: 422\n\t\tend\n\tend", "def cities\n galleries.map do |gallery| \n gallery.city \n end\n end", "def print_city_info(code, graph_instance)\n city = graph_instance.node_hash[code]\n if(city == nil)\n puts \"Not a valid city code\"\n else\n puts \"Name : #{city.name}\"\n puts \"Code : #{city.code}\"\n puts \"Country : #{city.country}\" \n puts \"Continent : #{city.continent}\" \n puts \"Timezone : #{city.timezone}\"\n puts \"Coordinates : #{city.coordinates}\"\n puts \"Population : #{city.population}\"\n puts \"Region : #{city.region}\"\n puts \"Linked Cities :\\n\"\n city.linked_cities.each { |route|\n puts \"Distance : #{route.distance} to #{route.city}\"\n }\n end\nend", "def get_weather_json(city)\n api_url = \"http://api.openweathermap.org/data/2.5/weather?q=#{city}\"\n RestClient.get(api_url).to_str\nend", "def index # shows locations according to their cities\n @locs = Loc.where(city_id: @city.id).sorted\n end", "def all_countries \n\t\tself.class.get('/all')\n\tend", "def find_city\n\t\t\tif params[:country_id] && params[:state_id] && params[:city_id]\n\t\t\t\t# Walk the tree \n\t\t\t\tcity_category = Category.find_by_parent_uuid_and_url_part(@state.uuid, params[:city_id].downcase)\n\t\t\t\t@city = City.find(:first, :conditions => { :category_id => city_category.id })\n\t\t\tend\n\t\tend", "def find_city\n\t\t\tif params[:country_id] && params[:state_id] && params[:city_id]\n\t\t\t\t# Walk the tree \n\t\t\t\tcity_category = Category.find_by_parent_uuid_and_url_part(@state.uuid, params[:city_id].downcase)\n\t\t\t\t@city = City.find(:first, :conditions => { :category_id => city_category.id })\n\t\t\tend\n\t\tend", "def cities\n @topCities = City.includes(:country).where(\"cities.top='t'\").order(\"cities.name\")\n @topCountries = Country.where(\"name='United States'\").order(\"top desc\")\n end", "def index\n @cities = City.select(:id, :name, :locked, :stone, :wood, :win, :lose, :population).order(population: :desc).limit(30)\n @city_hash = cookies[:city_hash]\n end", "def city_weather\n self.class.get(\"/data/2.5/forecast\", @options)\n end", "def locations\n get('locations')\n end", "def index\n all_cities = City.all\n return json_response([]) unless newest_city = all_cities.sort_by(&:updated_at).last\n Rails.logger.info \"newest_city is #{newest_city.inspect}\"\n render_if_stale(all_cities, last_modified: newest_city.updated_at.utc, etag: newest_city) do |city_presenters|\n city_presenters.map(&:hash)\n end\n # explicitly setting the Cache-Control response header to public and max-age, to make the response cachable by proxy caches\n expires_in caching_time, public: true\n end", "def getCity\n @city\n end", "def connectedCities(code)\r\n puts \"Connected Cities are\"\r\n results = connectedRoutes(code)\r\n results.sort{ |i,j| i[1].distance <=> j[1].distance}.each do |route|\r\n city = @vertex[route[1].ports.join.gsub(code,'')]\r\n puts \"#{city.name} (#{city.code}) : #{route[1].distance}\"\r\n end\r\n end", "def get_city_info(city, infoKey)\n\n info_dict = @query.json_graph_api.get_vertex_data(city)\n return info_dict[infoKey]\n\n end", "def cities\n self.galleries.map do |g|\n g.city\n end\nend", "def maproutes(graph_instance)\n url ='http://www.gcmap.com/mapui?P='\n route_strings=''\n graph_instance.node_hash.each_key{ |key|\n linked = graph_instance.node_hash[key].linked_cities\n linked.each{ |tuple|\n route_strings = route_strings + \"#{key}-#{tuple.city},+\"\n }\n }\n Launchy.open(url+route_strings)\nend", "def store_all_cities(json_obj)\n cities = json_obj['metros'].each{ |city|\n timezone = city['timezone']\n country = city['country']\n name = city['name']\n code = city['code']\n population = city['population']\n continent = city['continent']\n coordinates = city['coordinates']\n region = city['region']\n linked_cities = []\n new_node = Node.new(code,name,country,continent,timezone,coordinates,population,region, linked_cities)\n node_hash[code] = new_node\n continent_hash[continent] << name\n }\n end", "def show\n @country = Country.includes(:regions).find(params[:id])\n @tours = Tour.search(params.merge({ region: @country.region_ids}))\n @attractions = @country.regions.map { |i| i.attractions }.flatten\n @hotels = @country.regions.map { |i| i.hotels }.flatten\n @photos = @country.regions.map { |i| i.gallery.photos if i.gallery }.flatten.uniq.compact\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @country }\n end\n end", "def choose_city(city_query)\n response_string = RestClient.get(\"https://api.teleport.org/api/cities/?search=#{city_query}&embed=city%3Asearch-results%2Fcity%3Aitem%2Fcity%3Aurban_area%2Fua%3Ascores\")\n response_hash = JSON.parse(response_string)\n if response_hash['_embedded']['city:search-results'].empty?\n puts \"No matches found!\n \\nBringing you back to the main menu!\\n \".cyan\n return nil\n elsif response_hash['_embedded']['city:search-results'].length == 1\n return response_hash['_embedded']['city:search-results'][0]\n else\n puts ''\n response_hash['_embedded']['city:search-results'].each_with_index do |city_hash, index|\n puts \"#{index + 1}. #{city_hash['_embedded']['city:item']['full_name']}\"\n end\n puts ''\n puts 'Please enter the number of the city you would like to view.'.green\n # #fix for invalid inputs\n input = gets.chomp.to_i\n return response_hash['_embedded']['city:search-results'][input - 1]\n end\nend", "def show\n @city = City.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @city }\n end\n end", "def get_city\n page = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n villes =[]\n page.xpath('//*[@class=\"lientxt\"]').each do |ville|\n villes << ville.text\n end\n return villes\n end", "def city(params={})\n address.cities(params).select { |city| city.ref == self.city_ref }.first.result\n end", "def index\n @addresses = Address.all.map { |a| [a.latitude, a.longitude, a.magnitude] }.flatten\n render json: [[\"Connectivity\",[@addresses]],[\"Population\",[@addresses]]]\n end", "def index\n @city = city\n @districts = city.districts\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @districts }\n end\n end", "def print_continent_cities(graph_instance)\n graph_instance.continent_hash.each_key { |key|\n continent = graph_instance.continent_hash[key]\n puts \"Cities in #{key} are - \"\n continent.each { |city|\n puts \"#{city}\"\n }\n }\nend", "def visit(city)\n marshaled_cities = Marshal.dump(cities + [city])\n IO.write(\"cities\", marshaled_cities)\n end", "def index\n @companies = Company.all\n @cities = City.all\n #render json: @companies\n render json: { :companies => @companies, :cities => @cities }\n end", "def show\n @cities = @state.cities\n @number_of_cities = @state.cities.count\n @pagy, @cities = pagy(@state.cities, items: 30)\n @page_title = @state.name\n end", "def getCity\n @city_id=ReceiverAddress.where(id: params[:address_id]).first.city_id\n @city=City.where(id: @city_id).first\n respond_to do |format|\n format.html\n format.json {render json: @city}\n end\n end", "def geo(id)\n get \"/geo/id/#{id}.json\"\n end", "def city\n data['City']\n end", "def doctors_and_cities\n cities_dict, doctor_dict = current_user.dictionaries.where(resource_type: [\"Doctors\", \"Cities\"])\n render json: {doctors: doctor_dict.words.select(:id, :body),\n cities: cities_dict.words.select(:id, :body)}\n end" ]
[ "0.7350134", "0.7333397", "0.7067631", "0.7065568", "0.68672746", "0.68098557", "0.67984647", "0.6751429", "0.6747969", "0.6618983", "0.6499412", "0.6432094", "0.6423962", "0.6411681", "0.6357759", "0.634278", "0.62999105", "0.6293347", "0.6292854", "0.626926", "0.62361985", "0.6232503", "0.6226957", "0.6221416", "0.6219626", "0.6207247", "0.6199186", "0.6172965", "0.6166889", "0.61650217", "0.61418295", "0.6134407", "0.61339974", "0.61339974", "0.61339974", "0.61339974", "0.61339974", "0.61131907", "0.6085649", "0.60787433", "0.60461605", "0.60425055", "0.60385627", "0.600563", "0.59996825", "0.5994943", "0.5992253", "0.5992253", "0.59909344", "0.5974895", "0.5974895", "0.59724355", "0.59608567", "0.5954155", "0.59514", "0.59473884", "0.5931293", "0.59298736", "0.5921598", "0.5898027", "0.5888221", "0.58836824", "0.58621967", "0.585911", "0.58526367", "0.58520705", "0.5851083", "0.5843017", "0.58340615", "0.58269876", "0.58047277", "0.5803418", "0.57980245", "0.57980245", "0.5793912", "0.5787659", "0.5786295", "0.5785359", "0.57760984", "0.5764502", "0.5754302", "0.5749276", "0.5748052", "0.5744292", "0.5738585", "0.5731981", "0.5717754", "0.56889755", "0.56871706", "0.56832254", "0.56812054", "0.5672834", "0.5672112", "0.5653299", "0.56503344", "0.5649749", "0.56447804", "0.56360155", "0.563551", "0.562668" ]
0.7864492
0
GET /graphium/cities/1 GET /graphium/cities/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @graphium_cities = Graphium::City.all\n end", "def index\n neo = Neography::Rest.new\n r = neo.execute_query(\"START n=node(*) RETURN n;\")\n r[\"data\"].shift # first node is wacky\n @cities = r[\"data\"].map { |node|\n OpenStruct.new(node[0][\"data\"].merge(id: node[0][\"self\"].match(/node\\/(\\d+)$/)[1].to_i))\n }\n end", "def cities\n CS.get :us, :ca\n end", "def cities\n cities = CS.cities(params[:id], :GB)\n if cities.blank?\n country = ISO3166::Country.find_country_by_alpha3(params[:id])\n cities = country_cites(country)\n return(render json: { message: I18n.t(:invalid_country) }) if cities.blank?\n end\n render json: cities\n end", "def city\n fetch('dune.cities')\n end", "def index\n @cities = City.all\n\n render json: @cities\n end", "def print_city_list\n\n # simply call the print_vertices function of the graph API\n @query.get_graph.each_key { |city| puts \"#{get_city_info(city,\"name\")}\"}\n\n end", "def show_cities\n\n @cities = City.where(\"country_id = ?\", params[:country_id])\n\n render json: @cities\n \n end", "def set_graphium_city\n @graphium_city = Graphium::City.find(params[:id])\n end", "def city\n fetch('dnd.cities')\n end", "def index\n\n if params[:region_id]\n\n @regions = Region.where(id: params[:region_id])\n render json: @regions, include: [:cities], show_children: true\n\n elsif params[:ip]\n\n @iprange = Iprange.find_by_ip params[:ip]\n\n if @iprange\n\n render json: @iprange.city, include: [:region], show_parent: true\n\n else\n throw ActiveRecord::RecordNotFound\n end\n\n else\n\n @cities = City.all\n\n render json: @cities\n\n end\n end", "def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend", "def city\n fetch('world_cup.cities')\n end", "def geo\n\t\tciudad = params[:id]\n\t\t@ubication = City.where(id: ciudad)\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @ubication }\n\t\tend\n\tend", "def show\n render json: @city\n end", "def test_get_all_cities\n \n test_map = ' { \"metros\" : [ {\n \"code\" : \"LON\" ,\n \"name\" : \"London\",\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"PAR\" ,\n \"name\" : \"Paris\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"LIM\" ,\n \"name\" : \"Lima\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1 \n } , {\n \"code\" : \"MOW\" ,\n \"name\" : \"Moscow\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } ] ,\n \"routes\" : [ {\n \"ports\" : [\"LON\" , \"PAR\"] ,\n \"distance\" : 2410\n } , {\n \"ports\" : [\"LON\" , \"MOW\"] ,\n \"distance\" : 4323\n } , {\n \"ports\" : [\"LIM\" , \"PAR\"] ,\n \"distance\" : 4323\n } ] } '\n graph = Graph.new()\n graph.parse_json_string(test_map)\n \n result = graph.get_all_cities()\n \n assert_equal( result.scan(/[A-Z]*, [A-Z]{3}/).size, 4)\n assert_equal( result.include?(\"London, LON\"), true )\n assert_equal( result.include?(\"Moscow, MOW\"), true )\n assert_equal( result.include?(\"Lima, LIM\"), true )\n assert_equal( result.include?(\"Paris, PAR\"), true )\n \n end", "def get_list_cities\n City.get_all_cities\n end", "def index\n @cities = City.where(state_id: params[:id])\n respond_to do |format|\n format.json { render :json => @cities.to_json }\n end\n end", "def index\n get_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cities }\n format.js\n end\n end", "def create\n @graphium_city = Graphium::City.new(graphium_city_params)\n\n respond_to do |format|\n if @graphium_city.save\n format.html { redirect_to @graphium_city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @graphium_city }\n else\n format.html { render :new }\n format.json { render json: @graphium_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @cities = CITIES\n end", "def index\n hash = cookies[:city_hash]\n @city = City.find_by(city_hash: hash)\n @units = @city.units\n\n render json: @units, status: :ok\n end", "def index\n get_paginated_cities\n if @cities.to_json \n History.create(:name => 'Kota', :status => 'Completed')\n render json: @cities.to_json\n else\n History.create(:name => 'Kota', :status => 'Failed')\n end\n end", "def index\n if params[:country]\n country = Country.find_by_id(params[:country])\n if !country.nil?\n @cities = country.cities\n else\n flash[:error] = t(:country_not_found)\n @cities = nil\n end\n else\n return redirect_to countries_path\n end\n\n respond_to do |format|\n# format.html # index.html.erb\n format.json { render json: @cities }\n end\n end", "def index\n @state = State.find(params[:state_id])\n @cities = City.where(:state_id => params[:state_id]).paginate(:page => params[:page], :per_page => 10, :order => 'name')\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cities }\n end\n end", "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 getAllCities\r\n result = []\r\n @vertex.each_value do |city|\r\n result << city.name\r\n end\r\n return result\r\n end", "def get_weather_json(city)\n api_url = \"http://api.openweathermap.org/data/2.5/weather?q=#{city}\"\n RestClient.get(api_url).to_str\nend", "def new\n @cities=State.find_by_id(params[:body][:id]).cities.select(\"id, name\")\n render :json=>success1(:cities=>@cities)\n end", "def show\n @sitecity = Sitecity.find_by_url(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sitecity }\n end\n end", "def geo(id)\n get \"/geo/id/#{id}.json\"\n end", "def index\n @user = User.find(params[:id])\n @cities = @user.cities\n render :index\n end", "def api_request(city)\n url = \"https://jobs.github.com/positions.json?utf8=%E2%9C%93&description=&location=\"+city\n #Escape and parse URL for proper formatting.\n escaped_url = URI.escape(url)\n parsed_url = URI.parse(escaped_url)\n #Make the HTTP request.\n request = Net::HTTP.get(parsed_url)\n #Parse the JSON response.\n response = JSON.parse(request)\n #Returns all listings for the given city.\n return response\n end", "def cities\n galleries.map do |c|\n c.city\n end\n end", "def index\n all_cities = City.all\n return json_response([]) unless newest_city = all_cities.sort_by(&:updated_at).last\n Rails.logger.info \"newest_city is #{newest_city.inspect}\"\n render_if_stale(all_cities, last_modified: newest_city.updated_at.utc, etag: newest_city) do |city_presenters|\n city_presenters.map(&:hash)\n end\n # explicitly setting the Cache-Control response header to public and max-age, to make the response cachable by proxy caches\n expires_in caching_time, public: true\n end", "def index\n city_list = City.all\n puts city_list.inspect\n\n render json: city_list.to_json\n end", "def choose_city(city_query)\n response_string = RestClient.get(\"https://api.teleport.org/api/cities/?search=#{city_query}&embed=city%3Asearch-results%2Fcity%3Aitem%2Fcity%3Aurban_area%2Fua%3Ascores\")\n response_hash = JSON.parse(response_string)\n if response_hash['_embedded']['city:search-results'].empty?\n puts \"No matches found!\n \\nBringing you back to the main menu!\\n \".cyan\n return nil\n elsif response_hash['_embedded']['city:search-results'].length == 1\n return response_hash['_embedded']['city:search-results'][0]\n else\n puts ''\n response_hash['_embedded']['city:search-results'].each_with_index do |city_hash, index|\n puts \"#{index + 1}. #{city_hash['_embedded']['city:item']['full_name']}\"\n end\n puts ''\n puts 'Please enter the number of the city you would like to view.'.green\n # #fix for invalid inputs\n input = gets.chomp.to_i\n return response_hash['_embedded']['city:search-results'][input - 1]\n end\nend", "def graphium_city_params\n params.require(:graphium_city).permit(:name, :state, :state_code, :country, :country_code, :population, :osm_node_id)\n end", "def index\n @communities = @district.communities.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @communities }\n end\n end", "def getCityInfo(city)\r\n result = @vertex.find{ |code, cname| (code == city || cname.name == city)}\r\n\r\n if result.nil?\r\n puts \"There is no such city in CSAir.\"\r\n puts \"\"\r\n puts \"Please input 1 for list of all the cities CS Air travels to\"\r\n puts \"Please input 2 for specific information about a city in the CS Air network\"\r\n puts \"Please input 3 for the other statistics\"\r\n puts \"Please input 4 to Visualize CSAir's route map\"\r\n puts \"Please input 5 to exit\"\r\n else\r\n result[1].printVertex\r\n puts \"\"\r\n connectedCities(result[1].code)\r\n puts \"\"\r\n puts \"Please input 1 for list of all the cities CS Air travels to\"\r\n puts \"Please input 2 for specific information about a city in the CS Air network\"\r\n puts \"Please input 3 for the other statistics\"\r\n puts \"Please input 4 to Visualize CSAir's route map\"\r\n puts \"Please input 5 to exit\"\r\n end\r\n end", "def show\n @country = Country.includes(:regions).find(params[:id])\n @tours = Tour.search(params.merge({ region: @country.region_ids}))\n @attractions = @country.regions.map { |i| i.attractions }.flatten\n @hotels = @country.regions.map { |i| i.hotels }.flatten\n @photos = @country.regions.map { |i| i.gallery.photos if i.gallery }.flatten.uniq.compact\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @country }\n end\n end", "def index\n @cities = City.all\n end", "def index\n @cities = City.all\n end", "def index\n @cities = City.all\n end", "def index\n @cities = City.all\n end", "def index\n @cities = City.all\n end", "def getCity\n @city_id=ReceiverAddress.where(id: params[:address_id]).first.city_id\n @city=City.where(id: @city_id).first\n respond_to do |format|\n format.html\n format.json {render json: @city}\n end\n end", "def city\r\n\t\t\t@city ||= json[\"cit\"].to_s.capitalize\r\n\t\tend", "def cities_in_state\n cities = State.find(params[:id]).cities.order(name: :asc)\n\n render json: cities.to_json(), status: :ok\n end", "def show\n @city = City.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @city }\n end\n end", "def city_weather\n self.class.get(\"/data/2.5/forecast\", @options)\n end", "def index\n @m_cities = MCity.all\n end", "def index\n @addresses = Address.all.map { |a| [a.latitude, a.longitude, a.magnitude] }.flatten\n render json: [[\"Connectivity\",[@addresses]],[\"Population\",[@addresses]]]\n end", "def show\n @county = Entity.where(id: params[:id]).where(entity_type: 'County').first\n respond_with(@county) do |format|\n format.geojson { render text: @county.to_geojson }\n end\n end", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n #undefined method `city' for \"New York\":String\n end", "def print_city_info(code, graph_instance)\n city = graph_instance.node_hash[code]\n if(city == nil)\n puts \"Not a valid city code\"\n else\n puts \"Name : #{city.name}\"\n puts \"Code : #{city.code}\"\n puts \"Country : #{city.country}\" \n puts \"Continent : #{city.continent}\" \n puts \"Timezone : #{city.timezone}\"\n puts \"Coordinates : #{city.coordinates}\"\n puts \"Population : #{city.population}\"\n puts \"Region : #{city.region}\"\n puts \"Linked Cities :\\n\"\n city.linked_cities.each { |route|\n puts \"Distance : #{route.distance} to #{route.city}\"\n }\n end\nend", "def city\n\t\tself.client.city\n\tend", "def show\n @city = City.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @city }\n end\n end", "def index\n @sitecities = Sitecity.includes(:events).order(\"name asc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sitecities }\n end\n end", "def cities()\n sql = \"SELECT cities.* FROM cities WHERE country_id = $1\"\n values = [@id]\n cities = SqlRunner.run(sql, values)\n result = City.map_items(cities)\n return result\n end", "def get_city_info(city, infoKey)\n\n info_dict = @query.json_graph_api.get_vertex_data(city)\n return info_dict[infoKey]\n\n end", "def all_countries \n\t\tself.class.get('/all')\n\tend", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def maproutes(graph_instance)\n url ='http://www.gcmap.com/mapui?P='\n route_strings=''\n graph_instance.node_hash.each_key{ |key|\n linked = graph_instance.node_hash[key].linked_cities\n linked.each{ |tuple|\n route_strings = route_strings + \"#{key}-#{tuple.city},+\"\n }\n }\n Launchy.open(url+route_strings)\nend", "def index\n @ezii_cities = EziiCity.all\n end", "def index\n @world_cities = PhillyCrime.paginate(page: params[:page])\n end", "def index\n\n@cities = City.all\n\nend", "def find_city\n\t\t\tif params[:country_id] && params[:state_id] && params[:city_id]\n\t\t\t\t# Walk the tree \n\t\t\t\tcity_category = Category.find_by_parent_uuid_and_url_part(@state.uuid, params[:city_id].downcase)\n\t\t\t\t@city = City.find(:first, :conditions => { :category_id => city_category.id })\n\t\t\tend\n\t\tend", "def find_city\n\t\t\tif params[:country_id] && params[:state_id] && params[:city_id]\n\t\t\t\t# Walk the tree \n\t\t\t\tcity_category = Category.find_by_parent_uuid_and_url_part(@state.uuid, params[:city_id].downcase)\n\t\t\t\t@city = City.find(:first, :conditions => { :category_id => city_category.id })\n\t\t\tend\n\t\tend", "def all_organisations_in_city(city)\n sparql = \"\n SELECT DISTINCT ?uri ?label\n WHERE \n {\n VALUES ?city { \\\"#{city}\\\" }\n GRAPH <http://data.artsapi.com/graph/organisations> {\n ?uri <http://data.artsapi.com/def/arts/locationCity> ?city .\n ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label .\n }\n }\n \"\n\n results = User.current_user.within { Tripod::SparqlClient::Query.select(sparql) }\n\n results.map { |r| [r[\"uri\"][\"value\"], r[\"label\"][\"value\"]] }\n end", "def cities\n gallaries.map{|place| place.city}\n\n end", "def show\n @city = City.find(params[:city_id])\n @city101 = @city.city101\n @ads = @city.ads.city101_125x125\n\n add_breadcrumb \"City 101\", city_101_path(@city)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @city101 }\n end\n end", "def cities\n Gallery.all.map{|list| list.city}\n end", "def new\n @country = Country.find(params[:country_id])\n @state = State.find(params[:state_id])\n @city = City.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @city }\n end\n end", "def create\n neo = Neography::Rest.new\n city = neo.create_node(params[:city])\n redirect_to cities_path\n end", "def cities\n galleries.map {|g| g.city}\n end", "def index\n @countries = Country.all\n\n render json: @countries\n end", "def get\n\tresponse = RestClient.get(country_url)\n\t@parsed_response = JSON.parse(response)\nend", "def by_state\n \tdata = City.where('state_id = ?', params[:state_id]).order(:name)\n \trespond_to do |format|\n \t\tformat.json {render :json => data, :status => 200}\n \tend\n end", "def cities opt, graph\n\n\tp opt, graph\n\t#first try all cities spread over USA, should be easy to figure out if the correct tour was picked\n\tcities = 'd,DC,77.01,38.90;l,Los_Angeles,118.25,34.05;c,Chicago,87.68,41.83;m,Memphis,89.97,35.11;h,Houston,95.36,29.76;\n\t\t\t\t L,Las_Vegas,115.17,36.12;k,Kansas_city,94.57,39.09;M,Miami,80.20,25.77;s,San_Fran,122.41,37.78;a,Dallas,96.79,32.77;\n\t\t\t \t n,Nashville,86.78,36.16;e,Detroit,83.04,42.33;p,Phoneix,112.06,33.45;D,Denver,104.99,39.73'\n\n\tloop_over cities: cities, pool_size: 30, graph: graph, vmirror: true, hmirror: true if opt == '1'\n\n\t#Now add sort of a loop in California\n\tcities += ';S,Sacramento,121.46,38.55;f,Fresno,119.76,36.75;A,San_jose,121.88,37.33;C,Carson_city,119.75,39.16'\n\tloop_over cities: cities, pool_size: 30, graph: graph, vmirror: true, hmirror: true if opt == '2'\n\n\t#Now try with randomly generated cities\n\tif opt == '3' or opt.nil?\n\t\tcities = nil\n\t\tloop_over cities: cities, pool_size: 30, graph: graph\n\tend\n\nend", "def list_cities\n list_galleries.map do |gallery|\n gallery.city\n end\n end", "def populate\n json = params[:cities]\n cities = populate_database(json)\n cities.each{ |city|\n if(City.find_by_name(city.name).nil?)\n City.create({:name => city.name,:state => city.state,:lat => city.lat,:lng => city.lng,:link => api_city_url(city.name)})\n photos = get_images_url(city.lat,city.lng)\n photos.each{ |photo|\n #url_photo = photo['photo_file_url'].sub! 'http', 'https'\n CityImage.create({:url =>photo['photo_file_url'],:city_id => city.name})\n }\n end\n }\n render json: cities.to_json\n end", "def get_weather\n weather_forecast = WeatherForecast.new(params[:location_id])\n response = weather_forecast.city_weather\n puts body = JSON.parse(response.body)\n \t@city = body['city']['name']\n \t@main_temperature_parameters = body['list'][0]['main']\n \trespond_to do |format|\n format.js\n format.json { render json: @main_temperature_parameters }\n \tend\n end", "def index\n @cities = current_user.cities\n \n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n @city = city\n @districts = city.districts\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @districts }\n end\n end", "def cities\n self.galleries.map do |gi|\n gi.city\n end\n end", "def stay_city\n # cities = Country.all.map{|country|country.cities}\n # cities.map{|city|city.name}\n end", "def searchByCity\n\t\turl = request.original_url\n\t\t\n\t\tbegin\n\n\t\t\tprms = CGI.parse(URI.parse(url).query)\n\n\n\t\t\tresults = Doctor.where(\"city LIKE ?\", \"%#{prms['city'][0]}%\")\n\n\t\t\trender json: results\n\t\trescue Exception => e\n\t\t\trender json: { errors: \"Some errors\" }, status: 422\n\t\tend\n\tend", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n end", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n end", "def index\n @communities = Community.all\n render json: {items: @communities}\n end", "def city_events(city)\n response = RestClient.get('https://app.ticketmaster.com/discovery/v2/events.json?city=' + city + '&apikey=' + $ticket_master_api_key)\n jason_response = JSON.parse(response)\nend", "def get_city\n @single_city_data[\"name\"]\n end", "def locations\n get('locations')\n end", "def in_country\n return json_response([]) if (country_cities = City.where(params.slice(:country))).blank?\n newest_city = country_cities.sort_by(&:updated_at).last\n Rails.logger.info \"newest_city is #{newest_city.inspect}\"\n render_if_stale(country_cities, last_modified: newest_city.updated_at.utc, etag: newest_city) do |city_presenters|\n city_presenters.map(&:hash)\n end\n # explicitly setting the Cache-Control response header to public and max-age, to make the response cachable by proxy caches\n expires_in caching_time, public: true\n end", "def show\n render json: @country\n end", "def country_api\n # endpoint = \"https://corona.lmao.ninja/countries\"\n endpoint = 'https://corona.lmao.ninja/v2/countries'\n response = HTTParty.get(endpoint)\n data = JSON.parse response.body\n res = data\n result =[]\n endpoint_all = \"https://corona.lmao.ninja/all\"\n response1 = HTTParty.get(endpoint_all)\n data1 = JSON.parse response1.body\n res1 = data1\n result<<{\n country: \"world\",\n cases: res1[\"cases\"],\n todayCases: res1[\"todayCases\"],\n deaths: res1[\"deaths\"],\n todayDeaths: res1[\"todayDeaths\"],\n recovered: res1[\"recovered\"],\n active: res1[\"active\"],\n critical: res1[\"critical\"],\n casesPerOneMillion: res1[\"casesPerOneMillion\"],\n deathsPerOneMillion: res1[\"deathsPerOneMillion\"],\n tests: res1[\"tests\"],\n testsPerOneMillion: res1[\"testsPerOneMillion\"],\n affectedCountries: res1[\"affectedCountries\"]\n }\n\n res.each do |country|\n result<<{\n country: country[\"country\"],\n lat: country[\"countryInfo\"][\"lat\"],\n long: country[\"countryInfo\"][\"long\"],\n flag: country[\"countryInfo\"][\"flag\"],\n cases: country[\"cases\"],\n todayCases: country[\"todayCases\"],\n deaths: country[\"deaths\"],\n todayDeaths: country[\"todayDeaths\"],\n recovered: country[\"recovered\"],\n active: country[\"active\"],\n critical: country[\"critical\"],\n casesPerOneMillion: country[\"casesPerOneMillion\"],\n deathsPerOneMillion: country[\"deathsPerOneMillion\"],\n tests: country[\"tests\"],\n testsPerOneMillion: country[\"testsPerOneMillion\"]\n }\n end\n render json: result\n end", "def set_ge_city_api\n # @ge_city_api = GeCityApi.find(params[:id])\n end", "def cities_count_by\n\n respond_to do |format|\n format.html\n format.json { render json: city_count_data.to_json }\n end\n end", "def getCity\n @city\n end", "def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html { render layout: false }\n format.json\n format.geojson\n end\n end" ]
[ "0.771884", "0.7206858", "0.68093234", "0.66432726", "0.6558376", "0.6531224", "0.64815676", "0.6453144", "0.6389224", "0.638217", "0.6376754", "0.6352371", "0.6347531", "0.63352", "0.6271009", "0.62321395", "0.6225589", "0.6203233", "0.6105522", "0.6102309", "0.607513", "0.6051507", "0.6035991", "0.60294664", "0.59592646", "0.59548366", "0.59492654", "0.59407943", "0.59383816", "0.59100217", "0.5899911", "0.5898002", "0.589594", "0.58946955", "0.5868508", "0.58612716", "0.5842022", "0.5829654", "0.58248967", "0.58157927", "0.5815722", "0.5793881", "0.5793881", "0.5793881", "0.5793881", "0.5793881", "0.5782491", "0.57796615", "0.5775039", "0.57731885", "0.57631785", "0.5756305", "0.57534283", "0.5737786", "0.5733503", "0.57320094", "0.5729744", "0.5709363", "0.5694162", "0.56906396", "0.568785", "0.5687678", "0.5675384", "0.5671583", "0.5647542", "0.5643548", "0.56209004", "0.561514", "0.561514", "0.56114465", "0.56096977", "0.5608535", "0.5606802", "0.56027806", "0.55936885", "0.55933094", "0.5590521", "0.55881053", "0.5576973", "0.557053", "0.555368", "0.5551642", "0.5547896", "0.5542489", "0.55385953", "0.55359316", "0.5526493", "0.55261594", "0.5517151", "0.5517151", "0.5516952", "0.5512695", "0.5510263", "0.55060655", "0.54967034", "0.549565", "0.5493665", "0.54900426", "0.54896146", "0.54869145", "0.5483361" ]
0.0
-1
POST /graphium/cities POST /graphium/cities.json
def create @graphium_city = Graphium::City.new(graphium_city_params) respond_to do |format| if @graphium_city.save format.html { redirect_to @graphium_city, notice: 'City was successfully created.' } format.json { render :show, status: :created, location: @graphium_city } else format.html { render :new } format.json { render json: @graphium_city.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n neo = Neography::Rest.new\n city = neo.create_node(params[:city])\n redirect_to cities_path\n end", "def graphium_city_params\n params.require(:graphium_city).permit(:name, :state, :state_code, :country, :country_code, :population, :osm_node_id)\n end", "def index\n @graphium_cities = Graphium::City.all\n end", "def create\n @city = City.create(params[:city])\n get_data\n end", "def index\n neo = Neography::Rest.new\n r = neo.execute_query(\"START n=node(*) RETURN n;\")\n r[\"data\"].shift # first node is wacky\n @cities = r[\"data\"].map { |node|\n OpenStruct.new(node[0][\"data\"].merge(id: node[0][\"self\"].match(/node\\/(\\d+)$/)[1].to_i))\n }\n end", "def visit(city)\n marshaled_cities = Marshal.dump(cities + [city])\n IO.write(\"cities\", marshaled_cities)\n end", "def create\n @city = City.new(city_params)\n\n if @city.save\n render json: @city, status: :created, location: @city\n # 'city model was successfully created.'\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end", "def create\n @city = City.new(params[:city])\n @city.state_id = params[:state_id]\n \n respond_to do |format|\n if @city.save\n format.html { redirect_to country_state_cities_path, :notice => t('controller_message.inserted') }\n format.json { render :json => @city, :status => :created, :location => @city }\n else\n @state = State.find(params[:state_id])\n @country = Country.find(@state.country_id)\n format.html { render :action => \"new\" }\n format.json { render :json => @city.errors, :status => :unprocessable_entity }\n end\n end\n end", "def store_all_cities(json_obj)\n cities = json_obj['metros'].each{ |city|\n timezone = city['timezone']\n country = city['country']\n name = city['name']\n code = city['code']\n population = city['population']\n continent = city['continent']\n coordinates = city['coordinates']\n region = city['region']\n linked_cities = []\n new_node = Node.new(code,name,country,continent,timezone,coordinates,population,region, linked_cities)\n node_hash[code] = new_node\n continent_hash[continent] << name\n }\n end", "def create\n @sitecity = Sitecity.new(params[:sitecity])\n\n respond_to do |format|\n if @sitecity.save\n format.html { redirect_to @sitecity, notice: t(:sitecity_create_success) }\n format.json { render json: @sitecity, status: :created, location: @sitecity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sitecity.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @cities=State.find_by_id(params[:body][:id]).cities.select(\"id, name\")\n render :json=>success1(:cities=>@cities)\n end", "def create\n @city = City.new(params[:city])\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render json: @city, status: :created, location: @city }\n else\n format.html { render action: \"new\" }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def cities\n cities = CS.cities(params[:id], :GB)\n if cities.blank?\n country = ISO3166::Country.find_country_by_alpha3(params[:id])\n cities = country_cites(country)\n return(render json: { message: I18n.t(:invalid_country) }) if cities.blank?\n end\n render json: cities\n end", "def create\n @region = Region.find(params[:region_id])\n @city = @region.cities.create(city_params)\n\n respond_to do |format|\n if @city.save\n format.js { flash[:success] = \"#{@city.city_desc} added successfully\" }\n else\n format.js { render :new }\n end\n end\n end", "def create\n @city = City.new(:name => city_params[:name].strip, :state_id => city_params[:state_id])\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render action: 'show', status: :created, location: @city }\n else\n format.html { render action: 'new' }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_graphium_city\n @graphium_city = Graphium::City.find(params[:id])\n end", "def create\n unless params[:country_id]\n @city = City.new(params[:city])\n @city.step=\"2\"\n state = State.find_by_id(params[:city][:state_id]) if params[:city][:state_id]\n @city.state = state\n if @city.save\n render :json=>{:response=>\"success\"}\n else\n render :json=>failure1(@city.errors)\n end\n end\n end", "def create\n @city = City.new(city_params)\n # respond json: @city\n respond_to do |format|\n if @city.save\n format.html { redirect_to dashboard_index_path, notice: 'City was successfully created.' }\n format.json { render action: 'show', status: :created, location: @city }\n else\n format.html { render action: 'new' }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @city = City.new(city_params)\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @city }\n else\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @city = City.new(city_params)\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @city }\n else\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @city = City.new(city_params)\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @city }\n else\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion International\", \"United States Fund for UNICEF\"]\n\tcharity_list.each do |charity|\n\t\tRestClient.post 'http://api.reimaginebanking.com/merchants?key=e0486a76005721ee6d86b140eaea2a40', { \"name\": \"#{charity}\"}.to_json, :content_type => :json, :accept => :json\n\tend\nend", "def create\n\nCity.create(\n name: params[:city][:name],\n population: params[:city][:population],\n best_food: params[:city][:best_food],\n image_url: params[:city][:image_url],\n must_see: params[:city][:must_see],\n image_url_see: params[:city][:image_url_see]\n)\n\nredirect_to cities_path\n\nend", "def create\n @city = City.new(city_params)\n @city.use_for_api=@city.attributes.slice('name', 'city_id', 'lat', 'lng', 'zip_code').to_a.detect { |a| !a[1].blank? }[0]\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @city }\n else\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def populate\n json = params[:cities]\n cities = populate_database(json)\n cities.each{ |city|\n if(City.find_by_name(city.name).nil?)\n City.create({:name => city.name,:state => city.state,:lat => city.lat,:lng => city.lng,:link => api_city_url(city.name)})\n photos = get_images_url(city.lat,city.lng)\n photos.each{ |photo|\n #url_photo = photo['photo_file_url'].sub! 'http', 'https'\n CityImage.create({:url =>photo['photo_file_url'],:city_id => city.name})\n }\n end\n }\n render json: cities.to_json\n end", "def create\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to(cities_path, :notice => t(\"screens.notice.successfully_created\")) }\n format.xml { render :xml => @city, :status => :created, :location => @city }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @city.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @world_city = WorldCity.new(world_city_params)\n\n respond_to do |format|\n if @world_city.save\n format.html { redirect_to @world_city, notice: 'World city was successfully created.' }\n format.json { render :show, status: :created, location: @world_city }\n else\n format.html { render :new }\n format.json { render json: @world_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @city = City.new(city_params)\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @city }\n else\n @page_title = 'New City'\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @locality = Locality.new(params[:locality])\n @provinces = Province.all\n\n respond_to do |format|\n if @locality.save\n format.html { redirect_to @locality, :notice => 'Locality was successfully created.' }\n format.json { render :json => @locality, :status => :created, :location => @locality }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @locality.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @country = Country.find_by_id(params[:city][:country_id])\n if !@country.nil?\n @region = @country.regions.find_by_id(params[:city][:region_id])\n if !@region.nil?\n @city = City.new(params[:city])\n else\n flash[:notice] = \"Region not found\"\n return redirect_to country_path(@country)\n end\n else\n flash[:notice] = \"Country not found\"\n return redirect_to countries_path\n end\n\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render json: @city, status: :created, location: @city }\n else\n format.html { render action: \"new\" }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def city_params\n params.require(:city).permit(:country_id, :name, :description, :latitude, :longitude)\n end", "def create\n @admin_city = Admin::City.new(admin_city_params)\n\n respond_to do |format|\n if @admin_city.save\n format.html { redirect_to admin_cities_url, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: admin_cities_url }\n else\n format.html { render :new }\n format.json { render json: @admin_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def city_params\n params.require(:city).permit(:name, :slug, :adjective, :workflow_state)\n end", "def index\n get_paginated_cities\n if @cities.to_json \n History.create(:name => 'Kota', :status => 'Completed')\n render json: @cities.to_json\n else\n History.create(:name => 'Kota', :status => 'Failed')\n end\n end", "def city_params\n params.require(:city).permit(:name, :country, :zip_code, :description, :weather_id)\n end", "def city_params\n params.require(:city).permit(:name, :code, :description, :state_id,\n :active, :lon, :lat, :radius)\n end", "def city_params\n params.require(:city).permit(:name, :zip_code, :lat, :lng, :city_id)\n end", "def create\n @city = City.find(params[:city_id])\n @city.excursions.create(excursion_params)\n\n redirect_to city_path(@city)\n end", "def index\n @cities = CITIES\n end", "def index\n @cities = City.all\n\n render json: @cities\n end", "def create\n @city_district = CityDistrict.new(params[:city_district])\n\n respond_to do |format|\n if @city_district.save\n format.html { redirect_to @city_district, :notice => 'City district was successfully created.' }\n format.json { render :json => @city_district, :status => :created, :location => @city_district }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @city_district.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @ge_city_api = GeCityApi.new(ge_city_api_params)\n\n respond_to do |format|\n if @ge_city_api.save\n format.html { redirect_to @ge_city_api, notice: 'Ge city api was successfully created.' }\n format.json { render :show, status: :created, location: @ge_city_api }\n else\n format.html { render :new }\n format.json { render json: @ge_city_api.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(cnpj, branch, contractId, body)\n self.class.post(\"/aldebaran-carriers/carriers/#{cnpj}/contracts/#{branch}/#{contractId}/regions\", :basic_auth => @auth, :body => body.to_json)\n end", "def city\n fetch('dnd.cities')\n end", "def world_city_params\n params.require(:world_city).permit(:country, :city, :accent_city, :region, :population, :latitude, :longitude)\n end", "def create\n @city = City.new(city_params)\n\n @city.status=\"inativo\"\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @city }\n else\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @city = City.new(city_params)\n region = Region.find(params.fetch(:region_id, 0).to_i)\n @city.region = region\n\n if @city.save\n render :show, status: :created\n else\n @message = @city.errors\n render :error, status: :unprocessable_entity\n end\n end", "def city_params\n params.require(:city).permit(:nombre, :presidente_mpal, :fecha, :prioridad, :observaciones, :image, :report_id, :district_id)\n end", "def create\n @m_city = MCity.new(m_city_params)\n\n respond_to do |format|\n if @m_city.save\n format.html { redirect_to @m_city, notice: 'M city was successfully created.' }\n format.json { render :show, status: :created, location: @m_city }\n else\n format.html { render :new }\n format.json { render json: @m_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ezii_city = EziiCity.new(ezii_city_params)\n\n respond_to do |format|\n if @ezii_city.save\n format.html { redirect_to @ezii_city, notice: 'Ezii city was successfully created.' }\n format.json { render :show, status: :created, location: @ezii_city }\n else\n format.html { render :new }\n format.json { render json: @ezii_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def city_params\n params.require(:city).permit(:city_desc, :region_id, :comment)\n end", "def city_params\n params.require(:city).permit(:search_id, :name, :state, :country, :lat, :long)\n end", "def city_params\n params.require(:city).permit(\n :name, \n :description, \n :photo, \n :country_id, \n :map, \n :year,\n :dates \n )\n end", "def create\n @visit = Visit.new(params[:visit])\n\n respond_to do |format|\n if @visit.save\n format.html { redirect_to(@visit, :notice => 'Visit was successfully created.') }\n format.xml { render :xml => @visit, :status => :created, :location => @visit }\n format.json { render :json => @visit, :status => :created, :location => @visit, :methods => [:city_state, :unemployment_rate, :match_country_name, :match_country_stat] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @visit.errors, :status => :unprocessable_entity }\n format.json { render :json => @visit.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @locations_city = Locations::City.new(params[:locations_city])\n index\n respond_to do |format|\n if @locations_city.save\n format.js { @notice = 'Registro guardado correctamente.' \n render 'index'\n }\n else\n format.js { @notice = 'Error al guardar el registro.' \n render action: \"new\"}\n end\n end\n end", "def city_params\n params.require(:city).permit(:kladr_code, :name, :kladr_type_short, :kladr_type, :latitude, :longitude, :region_id)\n end", "def create\n @city = City.new(params[:city])\n \n respond_to do |format|\n if @city.save\n current_user.cities<<@city\n City.update_city_cache\n format.html { redirect_to @city, notice: '城池创建成功。' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def new\n @country = Country.find(params[:country_id])\n @state = State.find(params[:state_id])\n @city = City.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @city }\n end\n end", "def create\n @city = City.first\n @idcity= @city.id\n @zone = Zone.new(zone_params)\n @zone.city_id = @idcity\n if @zone.save \n render json: { status: :created }\n else\n render json: @zone.errors, status: :unprocessable_entity\n end\n end", "def cities_in_state\n cities = State.find(params[:id]).cities.order(name: :asc)\n\n render json: cities.to_json(), status: :ok\n end", "def city_params\n params.require(:city).permit(:name, :state_id, :status)\n end", "def city_params\n params.require(:city).permit(:name, :state_id)\n end", "def city_params\n params[:city][:suggest_bounds] = JSON.parse(params[:city][:suggest_bounds])\n params.require(:city).permit(:name, :code, :time_zone, :suggest_bounds)\n end", "def city\n fetch('dune.cities')\n end", "def city_params\n params.require(:city).permit(:location, :city)\n end", "def save_city(api_city_data)\n unless city = City.find_by_name(api_city_data['name'])\n city_params = {\n :name => api_city_data['name'],\n :latitude => api_city_data['coord']['lat'],\n :longitude => api_city_data['coord']['lon'],\n :iso_code_alpha_2 => api_city_data['country'],\n :population => api_city_data['population']\n }\n\n city = City.new(city_params)\n unless city.save\n raise \"Cant save city\"\n end\n city\n end\n city\n end", "def build_graph(cities)\n cities.each do |c1|\n line = []\n cities.each do |c2|\n line.push (City.distance(c1,c2))\n end\n @graph.push line\n end\n end", "def create\n @city = City.new(city_params)\n\n respond_to do |format|\n if @city.save\n flash[:success] = 'Ciudad Creada Exitosamente'\n format.html { redirect_to @city }\n format.json { render :show, status: :created, location: @city }\n else\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @city = City.new\n get_data\n end", "def new\n @sitecity = Sitecity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitecity }\n end\n end", "def city_params\n params.require(:city).permit(:name, :description, :image, :status)\n end", "def create_children!\n all_cities = TSP.cities.keys\n\n #rejects the cities which have already been visited\n all_cities.reject!{|city_id| self.visited_this_tour.include?(city_id)}\n all_cities.each do |city_id|\n @children << Node.new(city_id, self)\n end\n end", "def destroy\n @graphium_city.destroy\n respond_to do |format|\n format.html { redirect_to graphium_cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def new\n @location = Location.new\n @location.build_series\n @city = @location.build_city\n \n set_site_entities @location\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def create\n @city = City.new(params[:city])\n @country = Country.find(params[:country_id])\n\n @city.country_id,@city.lang=@country.id,@country.lang\n @city.assign_idents\n managing_photos\n\n respond_to do |format|\n if @city.save\n flash[:notice] = 'Город добавлен.'\n format.html { redirect_to countries_path }\n format.xml { render :xml => @city, :status => :created, :location => @city }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @city.errors, :status => :unprocessable_entity }\n end\n end\n end", "def geo\n\t\tciudad = params[:id]\n\t\t@ubication = City.where(id: ciudad)\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @ubication }\n\t\tend\n\tend", "def city_params\n params.require(:city).permit(:name)\n end", "def index\n get_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cities }\n format.js\n end\n end", "def cities\n CS.get :us, :ca\n end", "def city_params\n params.require(:city).permit(:name, :address, :postcode, :telephone, :website, :email, :vision, :mission, :development_thrust)\n end", "def index\n @state = State.find(params[:state_id])\n @cities = City.where(:state_id => params[:state_id]).paginate(:page => params[:page], :per_page => 10, :order => 'name')\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cities }\n end\n end", "def city_params\n params.require(:city).permit(:name, :state_id)\n end", "def city_params\n params.require(:city).permit(:location, :startdate, :triporder)\n end", "def add(name, country, continent, timezone, coords, pop, region, node_city, edges=Array.new)\n node = Node.new(name, country, continent, timezone, coords, pop, region)\n @nodes[node_city] = node\n @edges[node_city] = edges\n self\n end", "def create\n hash = cookies[:city_hash]\n @city = City.find_by(city_hash: hash)\n\n if @city.blank?\n render json: {error: \"Can't find your ship\"}, status: :unprocessable_entity and return\n elsif (@city.units.count >= @city.max_army_amount)\n render json: {error: \"Unit amount limit exceeded\"}, status: :unprocessable_entity and return\n end\n\n create_unit_by_type params[:unit_type], @city\n\n end", "def cities()\n \n url = \"http://servicos.cptec.inpe.br/XML/listaCidades\"\n \n cities = Array.new\n \n request ||= requestXml(url)\n \n request.xpath('//cidades/cidade').each do |cidadePath|\n \n cidade = Hash.new\n \n cidade[:id] = cidadePath.at_xpath('id').text.strip\n cidade[:uf] = cidadePath.at_xpath('uf').text.strip\n cidade[:nome] = cidadePath.at_xpath('nome').text.strip\n \n cities << cidade\n \n end\n \n cities\n \n end", "def index\n @cities = City.where(state_id: params[:id])\n respond_to do |format|\n format.json { render :json => @cities.to_json }\n end\n end", "def index\n\n if params[:region_id]\n\n @regions = Region.where(id: params[:region_id])\n render json: @regions, include: [:cities], show_children: true\n\n elsif params[:ip]\n\n @iprange = Iprange.find_by_ip params[:ip]\n\n if @iprange\n\n render json: @iprange.city, include: [:region], show_parent: true\n\n else\n throw ActiveRecord::RecordNotFound\n end\n\n else\n\n @cities = City.all\n\n render json: @cities\n\n end\n end", "def new\n @city = City.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @city }\n end\n end", "def create\n city = Post.new(city_params)\n city.user_id = user_id\n if city.save\n redirect_to user_path user.username\n end\n end", "def city_params\n params.fetch(:city, {}).permit(:name, :country, :location_key)\n end", "def add_city(city_name='Toronto')\n city = City.find_by(name: city_name)\n self.cities << city\n end", "def city\n fetch('world_cup.cities')\n end", "def test_get_all_cities\n \n test_map = ' { \"metros\" : [ {\n \"code\" : \"LON\" ,\n \"name\" : \"London\",\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"PAR\" ,\n \"name\" : \"Paris\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"LIM\" ,\n \"name\" : \"Lima\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1 \n } , {\n \"code\" : \"MOW\" ,\n \"name\" : \"Moscow\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } ] ,\n \"routes\" : [ {\n \"ports\" : [\"LON\" , \"PAR\"] ,\n \"distance\" : 2410\n } , {\n \"ports\" : [\"LON\" , \"MOW\"] ,\n \"distance\" : 4323\n } , {\n \"ports\" : [\"LIM\" , \"PAR\"] ,\n \"distance\" : 4323\n } ] } '\n graph = Graph.new()\n graph.parse_json_string(test_map)\n \n result = graph.get_all_cities()\n \n assert_equal( result.scan(/[A-Z]*, [A-Z]{3}/).size, 4)\n assert_equal( result.include?(\"London, LON\"), true )\n assert_equal( result.include?(\"Moscow, MOW\"), true )\n assert_equal( result.include?(\"Lima, LIM\"), true )\n assert_equal( result.include?(\"Paris, PAR\"), true )\n \n end", "def m_city_params\n params.require(:m_city).permit(:pref_id, :city_name)\n end", "def create\n @counties = County.all\n\n @county = County.create(county_params)\n\n @states = State.all.order(:state_name)\n end", "def show_cities\n\n @cities = City.where(\"country_id = ?\", params[:country_id])\n\n render json: @cities\n \n end", "def city_params\n params.require(:city).permit(:name)\n end", "def create\n @city_b = CityB.new(city_b_params)\n\n respond_to do |format|\n if @city_b.save\n format.html { redirect_to @city_b, notice: 'City b was successfully created.' }\n format.json { render :show, status: :created, location: @city_b }\n else\n format.html { render :new }\n format.json { render json: @city_b.errors, status: :unprocessable_entity }\n end\n end\n end", "def city_params\n params[:city]\n end" ]
[ "0.72843736", "0.6981593", "0.66361165", "0.635568", "0.63230383", "0.6254943", "0.60747796", "0.60582554", "0.6043469", "0.599677", "0.5981062", "0.5971438", "0.5939756", "0.59395474", "0.5933267", "0.59171426", "0.5915548", "0.5906117", "0.5881162", "0.5881162", "0.5881162", "0.5857475", "0.58512735", "0.5784638", "0.57739186", "0.5756959", "0.57410485", "0.5741036", "0.5686764", "0.5681673", "0.5678148", "0.5674998", "0.5641142", "0.5628825", "0.56267166", "0.5620527", "0.56101155", "0.56045794", "0.56034774", "0.55958474", "0.55871755", "0.5571943", "0.5571109", "0.5565833", "0.5561852", "0.5548971", "0.55467504", "0.5545556", "0.55353606", "0.5520984", "0.55183953", "0.5510306", "0.5503007", "0.5493419", "0.5488863", "0.547783", "0.5446663", "0.54455394", "0.5444305", "0.54377794", "0.542966", "0.54153746", "0.5397548", "0.53906775", "0.53806007", "0.537069", "0.5367476", "0.5365845", "0.5353519", "0.53497285", "0.5346619", "0.5343208", "0.53411984", "0.5327462", "0.53238904", "0.5289039", "0.5285745", "0.52747965", "0.52741206", "0.5272044", "0.52673376", "0.52670646", "0.52504486", "0.5249391", "0.52430767", "0.5241676", "0.5228409", "0.52282256", "0.52209723", "0.5220521", "0.5214431", "0.52141905", "0.52038467", "0.51922965", "0.5169991", "0.516954", "0.5168158", "0.5164513", "0.51639664", "0.51639247" ]
0.7155015
1
PATCH/PUT /graphium/cities/1 PATCH/PUT /graphium/cities/1.json
def update respond_to do |format| if @graphium_city.update(graphium_city_params) format.html { redirect_to @graphium_city, notice: 'City was successfully updated.' } format.json { render :show, status: :ok, location: @graphium_city } else format.html { render :edit } format.json { render json: @graphium_city.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n if @city.update(city_params)\n render json: @city\n # 'city was successfully updated.'\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n @city = City.find(params[:id])\n if @city.update_attributes(:name=>params[:body][:name],:step=>\"1\")\n render :json=>{:response=>\"success\"}\n else\n render :json=>failure1(@city.errors)\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n @city = City.find(params[:id])\n @city.update_attributes(params[:city])\n get_data\n end", "def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n # checks if user is authorized\n if authorise(request)\n # operation parameter tells what put operation should be done on vertex\n operation = params[:operation]\n case operation\n when 'connection'\n update_connection(params[:from_vertex_id], params[:to_vertex_id])\n when 'transformation'\n update_transformation(params[:id], params[:pos_x], params[:pos_y], params[:width],\n params[:height], params[:z_index])\n when 'attribute'\n update_attribute(params[:id], params[:name], params[:estimated_time], params[:clue],\n params[:description])\n else\n render json: { success: false, message: 'Operation does not exist' }, status: :bad_request\n end\n else\n render json: { success: false, message: 'Unauthorized' }, status: 401\n end\n end", "def update\n respond_to do |format|\n \n if @city.update(:name => city_params[:name].strip, :state_id => city_params[:state_id])\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @city = City.find(params[:id])\n\n respond_to do |format|\n if @city.update_attributes(params[:city])\n format.html { redirect_to country_state_city_path, :notice => t('controller_message.updated') }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @city.errors, :status => :unprocessable_entity }\n end\n end\n end", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n respond_to do |format|\n if @city.update(city_params)\n format.html { redirect_to dashboard_index_path, notice: 'City was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @graph.update_attributes_from_request(update_params)\n head :no_content\n end", "def update\n @city = City.find_by_id(params[:id])\n\n respond_to do |format|\n if @city.update_attributes(params[:city])\n format.html { redirect_to @city, notice: t(:city_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n cities = @video_marketing_campaign_form.cities.present? ? Geobase::Locality.joins(\"LEFT OUTER JOIN geobase_regions ON geobase_regions.id = geobase_localities.primary_region_id\").where(\"geobase_localities.id in (#{@video_marketing_campaign_form.cities.to_s.gsub(/(\\[|\\])|\"/, '')})\").order(\"geobase_regions.name ASC, geobase_localities.name ASC\") : []\n @cities_json = cities.map { |e| {id: e.id, text: \"#{e.name}, #{e.try(:primary_region).try(:code).try(:split, '<sep/>').try(:first).to_s.gsub('US-', '')}\"} }\n respond_to do |format|\n if @video_marketing_campaign_form.update(video_marketing_campaign_form_params)\n format.html { redirect_to @video_marketing_campaign_form, notice: 'Video marketing campaign form was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @video_marketing_campaign_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @city = City.find(params[:id])\n\n respond_to do |format|\n if @city.update_attributes(params[:city])\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @ge_city_api.update(ge_city_api_params)\n format.html { redirect_to @ge_city_api, notice: 'Ge city api was successfully updated.' }\n format.json { render :show, status: :ok, location: @ge_city_api }\n else\n format.html { render :edit }\n format.json { render json: @ge_city_api.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def update(path)\n output { patch(path, params) }\n end", "def update\n\n respond_to do |format|\n if @city.update_attributes(params[:city])\n format.html { redirect_to(cities_path, :notice => t(\"screens.notice.successfully_updated\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @city.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @admin_geonode = Admin::Geonode.find(params[:id])\n\n respond_to do |format|\n if @admin_geonode.update_attributes(params[:admin_geonode])\n format.html { redirect_to @admin_geonode, notice: 'Geonode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_geonode.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n json_update(category,category_params, Category)\n end", "def update\n put :update\n end", "def update\n\t\tperson = Person.find_by_id(user_params[\"id\"])\n\t\tif person\n\t\t\tperson.favoriteCity = params[\"update\"]\n\t\t\tif person.save\n\t\t\t\trender json: {id: person.id, name: person.name, favoriteCity: person.favoriteCity}\n\t\t\telse\n\t\t\t\trender body: 'Person Invalid', status: 404\n\t\t\tend\n\t\telse\n\t\t\trender body: 'Person Not Found', status: 404\n\t\tend\n\tend", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end", "def update\n city_params = params.require(:city).permit(:name)\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update\n respond_to do |format|\n if @city.update(city_params)\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { render :show, status: :ok, location: @city }\n else\n format.html { render :edit }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @city.update(city_params)\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { render :show, status: :ok, location: @city }\n else\n format.html { render :edit }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @city.update(city_params)\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { render :show, status: :ok, location: @city }\n else\n format.html { render :edit }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @city.update(city_params)\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { render :show, status: :ok, location: @city }\n else\n format.html { render :edit }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @city.update(city_params)\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { render :show, status: :ok, location: @city }\n else\n format.html { render :edit }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @city.update(city_params)\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { render :show, status: :ok, location: @city }\n else\n format.html { render :edit }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @city.update(city_params)\n format.html { redirect_to @city, notice: 'City was successfully updated.' }\n format.json { render :show, status: :ok, location: @city }\n else\n @states = State.all\n @page_title = 'Edit City'\n format.html { render :edit }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @locality = Locality.find(params[:id])\n @provinces = Province.all\n\n respond_to do |format|\n if @locality.update_attributes(params[:locality])\n format.html { redirect_to @locality, :notice => 'Locality was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @locality.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(attributes)\n self.class.new(GeoIQ.put(\"#{path}.json\", attributes).parsed_response)\n end", "def update\n @region = Region.find(params[:region_id])\n respond_to do |format|\n if @city.update(city_params)\n format.js\n else\n format.js { render :edit }\n end\n end\n end", "def update\n @client.update(client_params)\n render json: @client\n end", "def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end", "def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end", "def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def edit_city\n user = current_user\n if user.admin?\n if !(params[:name].nil? || params[:country_name].nil? || params[:province_name].nil? || params[:state_name].nil?)\n city = City.where(id: params[:id]).first\n if (!city.nil?)\n city.update_attributes(\n name: params[:name],\n country_id: BSON::ObjectId.from_string(params[:country_id]),\n country_name: params[:country_name],\n province_id: BSON::ObjectId.from_string(params[:province_id]),\n province_name: params[:province_name],\n state_id: BSON::ObjectId.from_string(params[:state_id]),\n state_name: params[:state_name]\n )\n render json: {status: 'SUCCESS', message:'City updated', data:city},status: :ok\n else\n render json: {status: 'ERROR', message:'City not found', data:nil},status: :not_found\n end \n end \n elsif user.admin_country?\n if !(params[:name].nil? || params[:country_name].nil? || params[:province_name].nil? || params[:state_name].nil?)\n city = City.where(id: params[:id]).first\n if (!city.nil?)\n if (city[:country_id] == user['country_id'])\n city.update_attributes(\n name: params[:name],\n country_id: BSON::ObjectId.from_string(params[:country_id]),\n country_name: params[:country_name],\n province_id: BSON::ObjectId.from_string(params[:province_id]),\n province_name: params[:province_name],\n state_id: BSON::ObjectId.from_string(params[:state_id]),\n state_name: params[:state_name]\n )\n render json: {status: 'SUCCESS', message:'City updated', data:city},status: :ok\n else\n render json: {status: 'ERROR', message:'Action not allowed', data:nil},status: :not_found\n end\n else\n render json: {status: 'ERROR', message:'City not found', data:nil},status: :not_found\n end \n end\n end \n end", "def update\n @sitecity = Sitecity.find_by_url(params[:id])\n\n respond_to do |format|\n if @sitecity.update_attributes(params[:sitecity])\n format.html { redirect_to @sitecity, notice: t(:sitecity_update_success) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sitecity.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\ncity = City.find params[:id]\n\ncity.update(\n name: params[:city][:name],\n population: params[:city][:population],\n best_food: params[:city][:best_food],\n image_url: params[:city][:image_url],\n must_see: params[:city][:must_see],\n image_url_see: params[:city][:image_url_see]\n)\n\nredirect_to city_path(city.id)\n\nend", "def update\n respond_to do |format|\n if @world_city.update(world_city_params)\n format.html { redirect_to @world_city, notice: 'World city was successfully updated.' }\n format.json { render :show, status: :ok, location: @world_city }\n else\n format.html { render :edit }\n format.json { render json: @world_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def patch!\n request! :patch\n end", "def update\n @city = City.find(params[:id])\n @city.attributes=params[:city]\n @city_coord = CityCoord.find_or_create_by_city_ident_num(params[:city_coord][:city_ident_num])\n @city_coord.attributes =params[:city_coord]\n @city_coord.save\n managing_photos\n\n respond_to do |format|\n if @city.save!\n flash[:notice] = 'Город изменён.'\n format.html { redirect_to countries_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @city.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @country = Country.find(params[:id])\n if @country.update_attributes(:name=>params[:body][:country])\n render :json=>{:response=>\"success\"}\n else\n render :json=>failure1(@country.errors)\n end\n end", "def graphium_city_params\n params.require(:graphium_city).permit(:name, :state, :state_code, :country, :country_code, :population, :osm_node_id)\n end", "def set_graphium_city\n @graphium_city = Graphium::City.find(params[:id])\n end", "def update\n @node = Node.find(params[:id])\n @json = Node.all.to_gmaps4rails\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n @nodes = Node.where(:user_id => current_user[:id])\n @nodes.each do |node|\n node.jobnumber = nil\n node.vehicle_id = nil\n node.servicetime = nil\n node.tour_id = nil\n node.save\n end\n project = Project.where(:user_id => current_user[:id]).first\n project.optimized = false\n project.loading = false\n project.save\n format.html { redirect_to(nodes_path, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def update(name: nil)\n data = name.nil? ? {} : {name: name}\n cf_patch(path: \"/organizations/#{org_id}\", data: data)\n end", "def update\n @visit = Visit.find(params[:id])\n\n respond_to do |format|\n if @visit.update_attributes(params[:visit])\n format.json { head :no_content }\n else\n format.json { render json: @visit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend", "def patch(operation, path, value)\n response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])\n @client.response_handler(response)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def patch(path, opts = {})\n request(:patch, path, opts).body\n end", "def update\n \n \n\n #puts '*****************cartodb22************************'\n #response = HTTParty.get('https://cantina23.cartodb.com/api/v2/sql?q=SELECT name FROM premas_projects&api_key=83a1b3e6c95613255bef720617d34adb0a7b87c1')\n #puts response\n #puts '*****************cartodb22************************'\n\n #puts '*****************cartodb22************************'\n #response = HTTParty.get(\"https://cantina23.cartodb.com/api/v2/sql?q=UPDATE premas_projects SET value=33333 WHERE cartodb_id=2&api_key=83a1b3e6c95613255bef720617d34adb0a7b87c1\")\n #puts response\n #puts '*****************cartodb22************************'\n\n \n \n \n \n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @m_city.update(m_city_params)\n format.html { redirect_to @m_city, notice: 'M city was successfully updated.' }\n format.json { render :show, status: :ok, location: @m_city }\n else\n format.html { render :edit }\n format.json { render json: @m_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @locations_city = Locations::City.find(params[:id])\n index\n respond_to do |format|\n if @locations_city.update_attributes(params[:locations_city])\n format.js { @notice = 'Registro actualizado correctamente.' \n render 'index'\n }\n else\n format.js { \n @notice = \"Error al actualizar el registro\"\n render action: \"edit\" }\n end\n end\n end", "def put_update(options = {})\n options[:id] ||= @website.id\n options[:website] ||= @attributes\n\n put :update,options\n end", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end", "def put!\n request! :put\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def update\n respond_to do |format|\n if @ezii_city.update(ezii_city_params)\n format.html { redirect_to @ezii_city, notice: 'Ezii city was successfully updated.' }\n format.json { render :show, status: :ok, location: @ezii_city }\n else\n format.html { render :edit }\n format.json { render json: @ezii_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end", "def update_current_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n respond_to do |format|\n if @admin_city.update(admin_city_params)\n format.html { redirect_to admin_cities_url, notice: 'City was successfully updated.' }\n format.json { render :show, status: :ok, location: admin_cities_url }\n else\n format.html { render :edit }\n format.json { render json: @admin_city.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def update\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n if @clonet.update_attributes(params[:clonet])\n format.html { redirect_to @clonet, notice: 'Clonet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(attributes = {})\n set_all(attributes)\n ensure_client && ensure_uri\n response = @client.rest_put(@data['uri'], { 'Accept-Language' => 'en_US', 'body' => @data }, @api_version)\n @client.response_handler(response)\n self\n end", "def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def update\n @visit = Visit.find(params[:id])\n\n if @visit.update(visit_params)\n head :no_content\n else\n render json: @visit.errors, status: :unprocessable_entity\n end\n end", "def update\n @campus_food = CampusFood.find(params[:id])\n\t@campus_food.location = params[:tags]\n respond_to do |format|\n if @campus_food.update_attributes(params[:campus_food])\n format.html { redirect_to campus_foods_path, notice: 'Campus food was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @campus_food.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end" ]
[ "0.6442021", "0.61399406", "0.60396487", "0.6007295", "0.59603", "0.5939284", "0.59242314", "0.5900325", "0.5857155", "0.5848182", "0.58433634", "0.5836922", "0.58034754", "0.57885444", "0.578303", "0.57777816", "0.57711077", "0.5769961", "0.57688624", "0.57521904", "0.57385767", "0.57368433", "0.57328576", "0.5711346", "0.5711346", "0.5704357", "0.5696424", "0.56940126", "0.56834763", "0.5668725", "0.5659635", "0.5649477", "0.56365037", "0.56340617", "0.56103027", "0.5597656", "0.5597656", "0.5597656", "0.5597656", "0.5597656", "0.5597096", "0.55952907", "0.5592509", "0.55850226", "0.5577152", "0.5569911", "0.555466", "0.55464554", "0.5540312", "0.55253595", "0.55159414", "0.5514155", "0.5498503", "0.5486955", "0.54851514", "0.54742026", "0.54638433", "0.54609007", "0.5449342", "0.5449203", "0.5446159", "0.5440105", "0.5439125", "0.5430426", "0.5411207", "0.54004943", "0.53959244", "0.53919774", "0.5381242", "0.5381242", "0.5381242", "0.5375543", "0.53735065", "0.5372237", "0.5366364", "0.53662246", "0.5364153", "0.53497225", "0.5349682", "0.5349682", "0.5344555", "0.5344555", "0.5341233", "0.53400105", "0.53361017", "0.53316724", "0.53308225", "0.5330473", "0.5330473", "0.5318192", "0.53066003", "0.53035283", "0.53023136", "0.53019905", "0.52985317", "0.529017", "0.5282578", "0.5282578", "0.5282578", "0.5282578" ]
0.651353
0
DELETE /graphium/cities/1 DELETE /graphium/cities/1.json
def destroy @graphium_city.destroy respond_to do |format| format.html { redirect_to graphium_cities_url, notice: 'City was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete\n client.delete(\"/#{id}\")\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n @admin_geonode = Admin::Geonode.find(params[:id])\n @admin_geonode.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_geonodes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to country_state_cities_url, :notice => t('controller_message.deleted') }\n format.json { head :no_content }\n end\n end", "def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n head :no_content\n end", "def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to cities_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 @sitecity = Sitecity.find_by_url(params[:id])\n @sitecity.destroy\n\n respond_to do |format|\n format.html { redirect_to sitecities_url }\n format.json { head :no_content }\n end\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 delete\n request(:delete)\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to(countries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @visit.destroy\n\n head :no_content\n end", "def destroy\n @city = City.find(params[:id])\n @city.destroy\n get_data\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def delete(path)\n request(:delete, path)\n end", "def destroy\n @ge_city_api.destroy\n respond_to do |format|\n format.html { redirect_to ge_city_apis_url, notice: 'Ge city api was successfully destroyed.' }\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 delete(path)\n with_remote do |http|\n http.delete(path)\n end\n end", "def clear_graph(graphname)\n update(\"WITH <#{graphname}> DELETE { ?s ?p ?o } WHERE { ?s ?p ?o .}\")\nend", "def delete(path)\n make_call(mk_conn(path), :delete)\n end", "def delete(path)\n\t\trequest(path, :delete)\n\tend", "def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end", "def destroy\n @city.destroy\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete\n api(\"Delete\")\n end", "def destroy\n visit.destroy\n respond_with(visit)\n end", "def delete(path)\n request 'DELETE', path\n end", "def destroy\n @city_district = CityDistrict.find(params[:id])\n @city_district.destroy\n\n respond_to do |format|\n format.html { redirect_to city_districts_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 @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def destroy\n\nCity.destroy params[:id]\n\nredirect_to cities_path\n\nend", "def delete_json(url)\n JSON.parse(delete(url, :json, :json))\n end", "def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n @goal_categories = GoalCategory.all\n \n unless @visit.errors.any?\n @visit = @visit.client.visits.last\n end\n \n @client = Client.find(params[:client_id])\n @client.goals.each do |goal|\n if goal.goal_states.empty?\n goal.destroy()\n end\n end\n \n prepareShow()\n\n respond_to do |format|\n format.html { render :show }\n format.json { head :no_content }\n end\n end", "def destroy\n @mobile_user_city.destroy\n respond_to do |format|\n format.html { redirect_to mobile_user_cities_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n request(:delete, path)\n end", "def destroy\n @world_city.destroy\n respond_to do |format|\n format.html { redirect_to world_cities_url, notice: 'World city was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def destroy\n @ezii_city.destroy\n respond_to do |format|\n format.html { redirect_to ezii_cities_url, notice: 'Ezii city was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n delete_from_server single_url\n end", "def delete\n api_client.delete(url)\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n @visit.destroy\n respond_to do |format|\n format.html { redirect_to visits_url, notice: 'Visita eliminada con exito' }\n format.json { head :no_content }\n end\n end", "def destroy\n @city.destroy\n respond_to do |format|\n flash[:success] = 'Ciudad Eliminada Exitosamente'\n format.html { redirect_to cities_url }\n format.json { head :no_content }\n end\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end", "def delete(url)\n do_request(\"delete\", url)\n end", "def destroy\n @m_city.destroy\n respond_to do |format|\n format.html { redirect_to m_cities_url, notice: 'M city was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @council_district.destroy\n respond_to do |format|\n format.html { redirect_to council_districts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gpath = Gpath.find(params[:id])\n @gpath.destroy\n\n respond_to do |format|\n format.html { redirect_to gpaths_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Location.delete(params[\"id\"])\n end", "def destroy\n @graph.destroy\n\n respond_to do |format|\n format.html { redirect_to graphs_url }\n format.json { head :no_content }\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\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 @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.html { redirect_to visits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_city.destroy\n respond_to do |format|\n format.html { redirect_to admin_cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def destroy\n @graph.destroy\n respond_to do |format|\n format.html { redirect_to graphs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @climate = Climate.find(params[:id])\n @climate.destroy\n\n respond_to do |format|\n format.html { redirect_to climates_url }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.get(params[:id])\n @ganglia_graph.destroy\n\n respond_to do |format|\n format.html { redirect_to(ganglia_graphs_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\n end", "def destroy\n @country.destroy\n\n head :no_content\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def destroy\n @graph = Graph.find(params[:id])\n @graph.destroy\n \n Action.log :controller => params[:controller], :action => params[:action], :target_id => params[:id], :user => current_user\n\n respond_to do |format|\n format.html { redirect_to :root, notice: 'Graph was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def delete(url)\n call(url: url, action: :delete)\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @city_measurement = CityMeasurement.find(params[:id])\n @city_measurement.destroy\n\n respond_to do |format|\n format.html { redirect_to city_measurements_url }\n format.json { head :ok }\n end\n end", "def destroy\n # if authorise(request)\n operation = params[:operation]\n case operation\n when 'remove_vertex'\n delete_vertex(params[:id])\n when 'disconnect_vertex'\n delete_connection(params[:from_vertex_id], params[:to_vertex_id])\n else\n render json: { status: 'FAILED', message: 'Operation does not exist' }, status: :bad_request\n end\n # else\n # render json: { status: 'FAILED', message: 'Unauthorized' }, status: 401\n # end\n end", "def destroy\n @city_b.destroy\n respond_to do |format|\n format.html { redirect_to city_bs_url, notice: 'City b was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @city.destroy\n render text: '{\"success\": true}', status: :no_content, location: city_path(params[:version], @city.id)\n else\n Rails.logger.error \"cannot destroy city because there were errors deleting the city #{@city.attributes.inspect} ... #{@city.errors.to_hash}\"\n render(json: @city.errors, status: :bad_request)\n end\n end", "def orchio_delete_graph(kind, to_collection, to_key)\n response = client.send_request(\n :delete,\n inst_args(\n kind: kind,\n to_collection: to_collection,\n to_key: to_key,\n path: \"?purge=true\"\n ))\n orchio_status response, 204\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def destroy\n @cad_neighborhood = CadNeighborhood.find(params[:id])\n @cad_neighborhood.destroy\n\n respond_to do |format|\n format.html { redirect_to cad_neighborhoods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @visit.destroy\n respond_to do |format|\n format.html { redirect_to visits_url, notice: 'Visit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end" ]
[ "0.6828938", "0.67404467", "0.6609387", "0.65831393", "0.6540373", "0.6499345", "0.6491838", "0.6472032", "0.6430665", "0.642744", "0.641377", "0.6393286", "0.6391623", "0.6378624", "0.63537174", "0.6353204", "0.6331599", "0.63308287", "0.6330156", "0.6270522", "0.62668324", "0.6263925", "0.62561506", "0.62561506", "0.62561506", "0.62561506", "0.62559634", "0.6255823", "0.62451774", "0.6241527", "0.62404335", "0.6239073", "0.6228461", "0.622516", "0.62214684", "0.62194115", "0.6208736", "0.6208647", "0.6181342", "0.6181342", "0.6181342", "0.6181342", "0.6181342", "0.6177538", "0.61598605", "0.6158469", "0.6149924", "0.6145604", "0.61447626", "0.6122818", "0.6119461", "0.61168736", "0.61130375", "0.6108075", "0.61052525", "0.60972697", "0.60953945", "0.6095159", "0.60940635", "0.6089301", "0.60861975", "0.6079137", "0.607864", "0.6078313", "0.60722536", "0.6070808", "0.6067648", "0.60666484", "0.6060584", "0.6057825", "0.6057825", "0.6057825", "0.6057825", "0.6057825", "0.6057825", "0.6057825", "0.60516953", "0.60502213", "0.60471743", "0.6044927", "0.60425186", "0.60384166", "0.60279304", "0.60279304", "0.60279304", "0.60268337", "0.60235256", "0.60135823", "0.6004696", "0.6001444", "0.599792", "0.5997317", "0.5995579", "0.59932756", "0.59870845", "0.5985741", "0.5985741", "0.59799606", "0.5970824", "0.59667706" ]
0.73883075
0
Use callbacks to share common setup or constraints between actions.
def set_graphium_city @graphium_city = Graphium::City.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def graphium_city_params params.require(:graphium_city).permit(:name, :state, :state_code, :country, :country_code, :population, :osm_node_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\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 allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\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 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 user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\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 whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_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 safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\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 user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; 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 quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "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 url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n 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 user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\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 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 url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
=begin This is a comment block multiple lines doctest: First doctest >> "hello!" => "hello!" doctest: I have another method here >> hello => "hello" doctest: I pass david to hello and get "Hello David!" >> hello "David" => "hello David!" doctest: If I forget to capitalize the name it will capitalize for me >> hello 'david' => "hello David!" doctest: I can even ask a question by add "?" >> hello "Victor", "?" => "hello Victor?" =end This is also
def hello name = "", punctuation = "!" "hello #{name.capitalize}#{punctuation}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method # test comment\n# ^^^ meta.function.method.without-arguments.ruby keyword.control.def.ruby\n# ^^^^^^ meta.function.method.without-arguments.ruby entity.name.function.ruby\n# ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby\n# ^^^^^^^^^^^^^ comment.line.number-sign.ruby\n hello, world = [1,2]\n# ^^^^^ variable.other.ruby\n# ^ punctuation.separator.object.ruby\n# ^^^^^ variable.other.ruby\n# ^ keyword.operator.assignment.ruby\n# ^ punctuation.section.array.begin.ruby\n# ^ constant.numeric.ruby\n# ^ punctuation.separator.object.ruby\n# ^ constant.numeric.ruby\n# ^ punctuation.section.array.end.ruby\n end", "def docstring; end", "def docstring; end", "def docufy(src,i)\n m = /RM_[A-z0-9]+/.match(src[i])\n name = m[0]\n name = name.sub(\"RM_\",\"RedisModule_\")\n proto = src[i].sub(\"{\",\"\").strip+\";\\n\"\n proto = proto.sub(\"RM_\",\"RedisModule_\")\n proto = linebreak_proto(proto, \" \");\n # Add a link target with the function name. (We don't trust the exact id of\n # the generated one, which depends on the Markdown implementation.)\n puts \"<span id=\\\"#{name}\\\"></span>\\n\\n\"\n puts \"### `#{name}`\\n\\n\"\n puts \" #{proto}\\n\"\n puts \"**Available since:** #{$since[name] or \"unreleased\"}\\n\\n\"\n comment = \"\"\n while true\n i = i-1\n comment = src[i]+comment\n break if src[i] =~ /\\/\\*/\n end\n comment = markdown(comment)\n puts comment+\"\\n\\n\"\nend", "def inline_doctest(num)\n return num\nend", "def base_docstring; end", "def docstring=(_arg0); end", "def test_comment_full_name\n 't1_cce66qf'\nend", "def say_hello name # starts with a definition\n puts \"hello #{name}, nice to meet you\"\nend", "def comment(string); end", "def comment(string); end", "def comment(string); end", "def comment(string); end", "def test_it_can_parse_paragraph\nskip\nchisel = Chisel.new\ntext = '# My Life in Desserts\n\n## Chapter 1: The Beginning\n\n\"You just *have* to try the cheesecake,\" he said. \"Ever since it appeared in\n**Food & Wine** this place has been packed every night.\"'\nassert_equal \"<p>You just *have* to try the cheesecake,\" he said. \"Ever since it appeared in\n**Food & Wine** this place has been packed every night.<p>\", chisel.parse_paragraph(text)\nend", "def charm_failure\n slowly do\n\"\"\"\nDuncan barks, wags his tail, rolls over, does all his awesome tricks...\n\nBut the troll just looks on in disdain. \n\n'Go home, little dog, before I sqquish you.' \n\"\"\"\n end\n what_next\n end", "def test_perldoc\n assert_binop_equal :|, \"JA\", \" ph\\n\", \"japh\\n\"\n end", "def explanation\n end", "def test_dsl_4\n #-------------------------\n show Spock + Lizard + Rock\n #-------------------------\n assert_equal \\\n \"Lizard poisons Spock (winner Lizard)\\n\" \\\n \"Rock crushes Lizard (winner Rock)\\n\" \\\n \"Result = Rock\\n\", \\\n @out.string\n end", "def test_dsl_5\n #---------------------------\n show Spock + (Lizard + Rock)\n #---------------------------\n assert_equal \\\n \"Rock crushes Lizard (winner Rock)\\n\" \\\n \"Spock vaporizes Rock (winner Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def introduce_myself\n puts \"I am a world ruler\"\n puts \"I am filty rich\"\n puts \"I own a library\"\nend", "def what_it_does() \"Generate javadoc to '#{@name}' folder\" end", "def prescription_1\n\tputs \"*** Prescription 1 ***\"\n\tputs \"Use the TDD process to create and adjust your code's design in small, incremental steps.\\n\\n\"\nend", "def test_dsl_2\n #------------------\n show Spock + Lizard\n #------------------\n assert_equal \\\n \"Lizard poisons Spock (winner Lizard)\\n\" \\\n \"Result = Lizard\\n\", \\\n @out.string\n end", "def test_dsl_3\n #------------------\n show Spock - Lizard\n #------------------\n assert_equal \\\n \"Lizard poisons Spock (loser Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end", "def docstring_hash_flag; end", "def test_defun_command_2\n##### [my_command2]\n defun(:my_command2,\n :interactive => \"d\", :docstring => \"description...\") { |point|\n insert_string(\"Current point is #{point}.\"); newline\n }\n##### [/my_command2]\n assert_equal(\"d\", nth(1, commandp(:my_command2)))\n assert_equal(\"description...\", documentation(:my_command2))\n assert_equal(\"Current point is 1.\\n\",\n with_temp_buffer_string{ call_interactively(:my_command2) })\n end", "def get_greetings(name) # no needs parenthesis (please dont put comments on same line as def, just this one :))\n \"Hello #{name}\"\nend", "def create_docstring(macro_name, data, method_object = T.unsafe(nil)); end", "def introduce_myself\n puts \"My name is Anndony Quemag\"\n puts \"My age is 23\"\n puts \"Im work at kommit\"\nend", "def comment _args\n \"comment _args;\" \n end", "def test_dsl_6\n #--------------------------------------------\n show Rock + Paper + Scissors + Lizard + Spock\n #--------------------------------------------\n assert_equal \\\n \"Paper covers Rock (winner Paper)\\n\" \\\n \"Scissors cut Paper (winner Scissors)\\n\" \\\n \"Scissors decapitate Lizard (winner Scissors)\\n\" \\\n \"Spock smashes Scissors (winner Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end", "def doc!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 97 )\n\n type = DOC\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 887:5: '`' (~ ( '`' | '\\\\\\\\' | '#' ) | '\\\\\\\\' . | {...}? => INTERPOLATION | '#' )* '`'\n match( 0x60 )\n # at line 888:5: (~ ( '`' | '\\\\\\\\' | '#' ) | '\\\\\\\\' . | {...}? => INTERPOLATION | '#' )*\n while true # decision 13\n alt_13 = 5\n alt_13 = @dfa13.predict( @input )\n case alt_13\n when 1\n # at line 888:7: ~ ( '`' | '\\\\\\\\' | '#' )\n if @input.peek( 1 ).between?( 0x0, 0x22 ) || @input.peek( 1 ).between?( 0x24, 0x5b ) || @input.peek( 1 ).between?( 0x5d, 0x5f ) || @input.peek( 1 ).between?( 0x61, 0xff )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n when 2\n # at line 889:7: '\\\\\\\\' .\n match( 0x5c )\n match_any\n\n when 3\n # at line 890:7: {...}? => INTERPOLATION\n raise FailedPredicate( \"DOC\", \" at_interpolation? \" ) unless ( ( at_interpolation? ) )\n interpolation!\n # --> action\n type = DDOC \n # <-- action\n\n when 4\n # at line 891:7: '#'\n match( 0x23 )\n\n else\n break # out of loop for decision 13\n end\n end # loop for decision 13\n match( 0x60 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 97 )\n\n end", "def test_it_can_parse_two_lines\n skip\n chisel = Chisel.new\n text = \"# My Life in Desserts\n## Chapter 1: The Beginning\"\n assert_equal \"<h1>My Life in Desserts</h1>\n <h2>Chapter 1: The Beginning</h2>\", chisel.parse(text)\n end", "def test_dsl_7\n #--------------------------------------------\n show Rock - Paper - Scissors - Lizard - Spock\n #--------------------------------------------\n assert_equal \\\n \"Paper covers Rock (loser Rock)\\n\" \\\n \"Rock crushes Scissors (loser Scissors)\\n\" \\\n \"Scissors decapitate Lizard (loser Lizard)\\n\" \\\n \"Lizard poisons Spock (loser Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end", "def SomeClass explainMore\n p \"no comment\"\n end", "def build_verbatim margin\n verbatim = super\n\n verbatim.format = :ruby if @section == 'Examples'\n\n verbatim\n end", "def docstring\n object.docstring.tr(\"\\n\", \" \")\n end", "def rdoc_tutorial(parameter1, parameter2)\n parameter3, parameter4 = parameter1, parameter2\n yield parameter3, paramter4\n end", "def docstring_range; end", "def doc=(_arg0); end", "def doc=(_arg0); end", "def doc=(_arg0); end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments_section_title\r\n 'What are people saying?'\r\n end", "def pre #:doc:\n end", "def explain\n \n end", "def test_documentation_example\n # Building an automaton for the regular language a(ba)*\n # It's a deterministic one, so we enforce it!\n fa = Automaton.new do\n add_state(:initial => true)\n add_state(:accepting => true)\n connect(0,1,'a')\n connect(1,0,'b')\n end\n\n # And we now it accepts 'a b a b a', and rejects 'a b' as well as ''\n assert_equal(true, fa.accepts?('? a b a b a'))\n assert_equal(false,fa.accepts?('? a b'))\n assert_equal(true, fa.rejects?('?'))\n end", "def wookiee_sentence; end", "def description\n super + \", Mocha\"\n end", "def lex_en_line_comment=(_arg0); end", "def lex_en_line_comment=(_arg0); end", "def lex_en_line_comment=(_arg0); end", "def explain(options={})\n \"the #{options[:the]} says #{options[:says]}\"\nend", "def introduce_myself\n #method body\n puts \"'I am handsome'\"\n puts \"i am talented\"\n puts \"i am briliant\"\n puts \"i am amazing\"\n puts 'is talented'\n puts \"is charming\"\n\n #method body\n end", "def test_basic_syntax_11\neasy_test(<<W2TAGS____________,<<EXPECTED__________)\n#form-edit\n %input:item_id{type=\"text\"}\nW2TAGS____________\n<div id=\"form-edit\">\n <input name=\"item_id\" type=\"text\" />\n</div>\nEXPECTED__________\n end", "def start_comment(description = 'Description')\n str = \"#{@indent}/**\\n\"\n str += \"#{@indent} *\\t@brief\\t<##{description}#>\\n\"\n str \n end", "def sectionComment(sectionName)\r\n txt = sectionName.strip\r\n bar = \"\"\r\n # 6: 5 misc chars (// ) plus 1\r\n width = (@maxWidth - 6 - txt.length) / 2\r\n width.times do\r\n bar += \"+\"\r\n end\r\n\r\n header = <<EOF\r\n\r\n\r\n\r\n\r\n// #{bar} #{txt} #{bar}\r\n\r\nEOF\r\n\r\n header\r\n\r\n end", "def test_heredoc_method\n desired_output = <<-EOS.unindent\n This should contain no indents.\n\n It should be 3 lines long.\n EOS\n test_output = \"This should contain no indents.\\n\\nIt should be 3 lines long.\\n\"\n assert_equal(desired_output, test_output, \"Output must exactly match.\")\n end", "def q3_page\n\"\n\n\n\n\n\n\n\n\n\n What is your Food Mood?\n\n *-------------------* *-------------------* *-------------------*\n | | | | | |\n | | | | | |\n | | | | | |\n | Old Faves | | Surprise Me! | | Craving |\n | | | | | |\n | | | | | |\n | | | | | |\n *-------------------* *-------------------* *-------------------*\n\n 1: 2: Input your Craving:\n\nAnswer: \"\nend", "def get_comment(n, algebraic_structure)\n ret = <<EOS\n/**\n* Combine #{n} #{algebraic_structure}s into a product #{algebraic_structure}\n*/\nEOS\n ret.strip\nend", "def flatiron_title_descend_01\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n end", "def introduction(name)\n puts \"Hi, my name is #{name}.\\n\"\nend", "def say_hello(name=\"Ruby Programmer\")\n puts \"Hello #{name}!\"\nend", "def section_seperator\n puts <<EOF\n\n\n\n=========================\n=========================\nEOF\nend", "def docstring_range=(_arg0); end", "def hello name='World', punctuation='!'\n \"Hello #{name}#{punctuation}\"\nend", "def docstring_hash_flag=(_arg0); end", "def test_say_favourite_language()\n #Act\n # phrase = @student.say_favourite_language('Ruby')\n # #Assert\n assert_equal('I love Ruby', @student.say_favourite_language('Ruby'))\n end", "def test_method\n \"Here is the sample input\"\n end", "def say_hello(name=\"Ruby Programmer\")\n puts \"Hello #{name}!\"\nend", "def help\n puts <<-HEREDOC\n I accept the following commands:\n - help : displays this help message\n - list : displays a list of songs you can play\n - play : lets you choose a song to play\n - exit : exits this program\n HEREDOC\nend", "def create_comment(string, &block); end", "def create_comment(string, &block); end", "def one_line_description(opts={}) ; attributes['comments'] ; end", "def introduction_with_language (name = \"Dan\", language= \"Ember.js\")\n puts \"Hi, my name is #{name} and I am learning to program in #{language}.\"\nend" ]
[ "0.67439234", "0.66269255", "0.66269255", "0.65377855", "0.63451767", "0.6331137", "0.62547994", "0.607349", "0.605264", "0.6012091", "0.6012091", "0.6012091", "0.6012091", "0.60044634", "0.59976315", "0.5962581", "0.5867539", "0.58513296", "0.58308834", "0.5824357", "0.5824357", "0.5824357", "0.5824357", "0.5805657", "0.57635504", "0.57591534", "0.5756947", "0.5756093", "0.5755191", "0.5755027", "0.57332057", "0.572444", "0.57163113", "0.570287", "0.56730366", "0.5673006", "0.56718755", "0.5667262", "0.56547564", "0.5638121", "0.5610038", "0.56028837", "0.56010556", "0.5579282", "0.5579282", "0.5579282", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.557246", "0.55631226", "0.55631226", "0.55631226", "0.55631226", "0.55631226", "0.55609435", "0.5545505", "0.55422217", "0.5541486", "0.5524815", "0.5522407", "0.5522106", "0.5522106", "0.5522106", "0.55172646", "0.55110794", "0.5503155", "0.5501183", "0.54919016", "0.54870385", "0.54869604", "0.54808503", "0.54783326", "0.547808", "0.5473892", "0.5458743", "0.5454688", "0.5451155", "0.5450281", "0.5448657", "0.5447579", "0.54423493", "0.54412574", "0.5440906", "0.5440906", "0.54377675", "0.5421083" ]
0.55439585
70
Create a new container
def create response = post_request(URI.parse("http://"+Storage.find(cookies[:donabe_ip]).data+"/"+Storage.find(cookies[:current_tenant]).data+"/containers.json"), params[:container].to_json, Storage.find(cookies[:current_token]).data) json_respond response.body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_container\n\t\t\t\t@command.container_class.new\n\t\t\tend", "def create_new_container\n puts 'Start creating a new container..'\n host = get_available_host\n if host.nil?\n puts 'Could not found a host with limit enough to create more containers'\n return\n end\n puts \"getting an available port to #{host}\"\n port = get_available_port(host)\n if port.nil?\n puts 'Could not found an available port'\n return\n end\n\n puts \"using port #{port} from #{host}\"\n\n Docker.url = \"tcp://#{host}:#{@docker_port}/\"\n container = Docker::Container.create(\n 'Image' => \"#{@ws_image}\",\n 'ExposedPorts' => { \n '8070/tcp' => {}\n },\n 'HostConfig' => {\n 'CpuPeriod' => 25000,\n 'PortBindings' => {\n '8070/tcp' => [ { 'HostPort' => \"#{port}\" } ]\n }\n }\n )\n container.start\n register_container(host, port, container.id)\n end", "def create_container\n UI.important(\"Creating container: #{container_name}\")\n CpuLoadHandler.print_cpu_load\n begin\n container = create_container_call\n set_container_name(container)\n rescue StandardError\n UI.important(\"Something went wrong while creating: #{container_name}, will retry in #{@sleep_interval} seconds\")\n CpuLoadHandler.print_cpu_load\n @docker_commander.delete_container\n sleep @sleep_interval\n container = create_container_call\n set_container_name(container)\n end\n @container = get_container_instance(container)\n\n if @container.nil?\n sleep 3\n @container = get_container_instance(container)\n end\n end", "def create # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.create(@options[:container])\n if newcontainer.code == '201'\n puts \"Container #{@options[:container]} created\"\n else\n @util.response_handler(newcontainer)\n end \n end", "def create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end", "def create_container(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n uri = container_uri(name, query)\n\n headers = service_properties_headers\n\n add_metadata_to_headers(options[:metadata], headers) if options[:metadata]\n\n headers['x-ms-blob-public-access'] = options[:public_access_level].to_s if options[:public_access_level]\n\n response = call(:put, uri, nil, headers)\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.metadata = options[:metadata]\n container\n end", "def create_container_call\n # When CPU is under load we cannot create a healthy container\n CpuLoadHandler.wait_cpu_to_idle\n\n additional_env = ''\n environment_variables.each do |variable|\n additional_env += \" -e #{variable}\"\n end\n emulator_args = is_running_on_emulator ? \"-p #{no_vnc_port}:6080 -e DEVICE='#{device_name}'\" : ''\n emulator_args = \"#{emulator_args}#{additional_env}\"\n @docker_commander.start_container(emulator_args: emulator_args, docker_image: docker_image,\n core_amount: core_amount)\n end", "def create_container(name, options={})\n # Query\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Scheme + path\n uri = container_uri(name, query)\n\n # Headers\n headers = StorageService.common_headers\n StorageService.add_metadata_to_headers(options[:metadata], headers) if options[:metadata]\n headers['x-ms-blob-public-access'] = options[:public_access_level].to_s if options[:public_access_level]\n\n # Call\n response = call(:put, uri, nil, headers, options)\n\n # result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.metadata = options[:metadata]\n container\n end", "def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end", "def handle_create(event)\n @bus.request 'containers', 'created', event: event.json, container: container_info(event.id)\n end", "def create_container(container_type, element_type, size = 0)\n if element_type.respond_to?(:to_str)\n element_type = build(element_type)\n end\n return define_container(container_type.to_str, element_type, size)\n end", "def container\n return @container if defined? @container\n if @options[:reattach]\n all_containers = Docker::Container.all(all: true)\n all_containers.each do |container|\n if container.info['Image'] == @tag\n @container = Docker::Container.get(container.info['id'])\n end\n end\n begin\n @container = Docker::Container.create('Image' => @tag)\n rescue Docker::Error::NotFoundError\n puts \"Could not find an image with @tag #{@tag}\"\n return nil\n end\n elsif !ARGV.empty?\n @container = Docker::Container.create('Image' => @tag,\n 'Cmd' => ARGV,\n 'Env' => ['DISPLAY=:0'])\n elsif @options[:wayland]\n @container = Docker::Container.create('Image' => @tag,\n 'Env' => ['DISPLAY=:0'],\n 'Cmd' => ['startplasmacompositor'])\n else\n @container = Docker::Container.create('Image' => @tag,\n 'Env' => [\"DISPLAY=:#{xdisplay}\"])\n end\n @container\n end", "def create_container(container_body, opts = {})\n data, _status_code, _headers = create_container_with_http_info(container_body, opts)\n data\n end", "def create\n @container = current_user.containers.build(params[:container])\n \n respond_to do |format|\n if @container.save\n flash[:notice] = 'Container was successfully created.'\n format.html { redirect_to(@container) }\n format.xml { render :xml => @container, :status => :created, :location => @container }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_container(collection, container = nil)\n active_container = container\n if active_container.nil?\n active_container = {\n \"metadata\": [\n {\n \"key\": \"dc.title\",\n \"language\": \"en_US\",\n \"value\": \"Empty Container Document\"\n },\n {\n \"key\": \"dc.contributor.author\",\n \"language\": \"en_US\",\n \"value\": \"Data Services, Bobst Library\"\n }\n ]\n }\n end\n cmd = `curl -X POST -H \"Content-Type: application/json\" -H \"Accept: application/json\" -H \"rest-dspace-token: #{@token}\" -d '#{JSON.generate(active_container)}' #{ENV[\"FDA_REST_ENDPOINT\"]}/collections/#{collection}/items --insecure -s`\n return JSON.parse(cmd)\n end", "def run_container(port:, password:, name:)\n response_of_create = create_container(port: port, password: password, name: name)\n return unless response_of_create.success?\n\n container_id = JSON.parse(response_of_create.body).fetch('Id')\n start_container(container_id: container_id)\n rescue StandardError\n false\n end", "def container\n @container ||= find_or_create_container\n end", "def find_or_create_container\n unless connection.container_exists?(@config.container)\n connection.create_container(@config.container)\n end\n connection.container(@config.container)\n end", "def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end", "def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end", "def prepare_container\n exposed_ports = {}\n port_bindings = {}\n links = []\n\n # Build expose and port binding parameters\n if !@attributes[:ports].nil?\n @attributes[:ports].each do |port|\n exposed_ports[\"#{port.container_port}/tcp\"] = {}\n port_bindings[\"#{port.container_port}/tcp\"] = [{\n \"HostIp\" => port.host_ip || '',\n \"HostPort\" => port.host_port || ''\n }]\n end\n end\n\n # Build link parameters\n @dependencies.each do |dependency|\n links << \"#{dependency.stats['Id']}:#{dependency.attributes[:label]}\"\n end\n\n container_config = {\n Image: @attributes[:image],\n Cmd: @attributes[:command],\n Env: @attributes[:environment],\n Volumes: @attributes[:volumes],\n ExposedPorts: exposed_ports,\n HostConfig: {\n Links: links,\n PortBindings: port_bindings\n }\n }\n\n @container = Docker::Container.create(container_config)\n end", "def create_and_run_container args\n \t# update the timeout for the Excon Http Client\n \t# set the chunk size to enable streaming of log files\n ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}\n container = ::Docker::Container.create(\n \t\t'Image' => args[:image],\n \t\t'Cmd' => args[:command],\n \t\t\"Binds\" => args[:volumes],\n \t\t\"Env\" => args[:environment],\n \t\t'WorkingDir' => args[:working_directory],\n 'NetworkMode' => @network,\n 'name' => args[:name],\n 'PublishAllPorts' => true\n )\n\n output = ''\n\n unless args[:deamon] == true\n thread = Thread.new do\n container.attach(:stream => true, :stdin => nil, :stdout => true, :stderr => true, :logs => false, :tty => false) do\n |stream, chunk|\n if chunk.index('[ERROR]') != nil # deal with hidden characters\n @logger.error chunk.gsub(/\\[.*\\]/,'')\n else\n output += chunk.gsub(/\\[.*\\]/,'') if output == ''\n output += chunk.gsub(/\\[.*\\]/,'').prepend(\" \") unless output == ''\n @logger.debug chunk.gsub(/\\[.*\\]/,'')\n end\n end\n end\n end\n\n \n\n container.start\n \n thread.join unless args[:deamon] == true\n\n success = (container.json['State']['ExitCode'] == 0) ? true: false \n \n @logger.error(output) unless success \n\n \treturn container, success\n end", "def create_container(container_model, element_type, _size = nil, typename: nil, size: nil, **options)\n if container_model.respond_to?(:to_str)\n container_model = container_model_by_name(container_model)\n end\n element_type = validate_type_argument(element_type)\n\n size ||= _size\n typename ||= \"#{container_model.name}<#{element_type.name}>\"\n size = nil if size == 0\n size ||= container_model.size\n\n container_t = container_model.\n new_submodel(registry: self, typename: typename,\n deference: element_type, size: size, **options)\n register(container_t)\n container_t\n end", "def create\n begin\n #get the server chosen container_params[:server_id]\n @currentServer = Server.where(id: container_params[:server_id])\n Docker.url = 'tcp://' + @currentServer[0].ip + \":\" + @currentServer[0].port\n\n #create the container in docker\n if container_params[:exposed_port].blank?\n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image]\n ) \n else \n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image],\n 'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]\n }\n }\n )\n end\n\n #adds the container into the database\n @container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port], \n :host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')\n\n Docker.url = ''\n\n respond_to do |format|\n if @container.save\n Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save\n format.html { redirect_to root_path, notice: 'Container was successfully created.' }\n format.json { render :show, status: :created, location: @container }\n else\n format.html { render :new }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Docker::Error::ClientError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::NotFoundError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n end\n end", "def start_container(image, expose_port)\n container = Docker::Container.create('Image' => image, 'HostConfig' => {'PortBindings' => {\"#{expose_port}/tcp\" => [{}]}})\n container.start\n Container.new(container, expose_port)\nend", "def start_container(container_id: nil, container_name: nil)\n return if container_id.nil? && container_name.nil?\n\n id = container_id.nil? ? container_name : container_id\n conn.post(\"/containers/#{id}/start\")\n end", "def create_container_model(name)\n ModelKit::Types.validate_typename(name)\n container_model = ContainerType.new_submodel\n container_model.name = name\n register_container_model(container_model)\n container_model\n end", "def container\n @container ||= Container.new(spec[:containers].first)\n end", "def create(container)\n # If the caller has already set an id, trust it.\n container.assign_id!(new_uuid) unless container.id\n container.assign_org_id!(@org_id)\n container.update_timestamps!\n container.last_updated_by!(requester_authz_id)\n\n validate_before_create!(container)\n\n unless container.authz_id\n container.create_authz_object_as(requester_authz_id)\n end\n\n user_side_create(container)\n\n container.persisted!\n container\n end", "def create_nvidia_container(tag_name, image, volume_driver)\n puts \"-- Creating Docker Container\"\n container = Docker::Container.create(\n 'name' => tag_name,\n 'Image' => image,\n 'ExposedPorts' => { '9999/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n '8888/tcp' => [{ 'HostPort' => '9999', 'HostIP' => '0.0.0.0'}]\n },\n 'Devices' => [\n { 'PathOnHost' => '/dev/nvidiactl', 'PathInContainer' => '/dev/nvidiactl', 'CgroupPermissions' => 'rwm' },\n { 'PathOnHost' => '/dev/nvidia-uvm', 'PathInContainer' => '/dev/nvidia-uvm', 'CgroupPermissions' => 'rwm'},\n # { 'PathOnHost' => '/dev/nvidia-uvm-tools', 'PathInContainer' => '/dev/nvidia-uvm-tools', 'CgroupPermissions' => 'rwm' },\n { 'PathOnHost' => '/dev/nvidia0', 'PathInContainer' => '/dev/nvidia0', 'CgroupPermissions' => 'rwm' }\n ],\n 'VolumeDriver' => 'nvidia-docker',\n 'Mounts' => [\n { 'Target' => '/usr/local/nvidia', 'Source' => volume_driver, 'Type' => 'bind'}\n ]\n }\n )\n container.start\nend", "def setup_container\n assign_unique_vnc_port if port_factor && is_running_on_emulator\n\n if container_available?\n UI.important('Container was already started. Stopping and removing..')\n @docker_commander.delete_container\n end\n\n handle_ports_allocation if is_running_on_emulator && vnc_enabled\n\n pull_from_registry if @pull_latest_image\n\n # Make sure that network bridge for the current container is not already used\n @docker_commander.disconnect_network_bridge\n\n create_container\n\n if is_running_on_emulator && kvm_disabled?\n raise 'Linux requires GPU acceleration for running emulators, but KVM virtualization is not supported by your CPU. Exiting..'\n end\n\n container_state = wait_for_healthy_container\n\n if is_running_on_emulator && container_state\n connection_state = @emulator_commander.check_connection\n container_state = connection_state && connection_state\n end\n\n unless container_state\n UI.important(\"Will retry to create a healthy docker container after #{sleep_interval} seconds\")\n @docker_commander.delete_container\n sleep @sleep_interval\n create_container\n\n unless wait_for_healthy_container\n UI.important('Container is unhealthy. Exiting..')\n begin\n Actions.sh(\"docker logs #{container_name} --tail 200\")\n Actions.sh(\"docker exec -i #{container_name} cat /var/log/supervisor/docker-android.stderr.log\")\n Actions.sh(\"docker exec -i #{container_name} cat /var/log/supervisor/supervisord.log\")\n rescue StandardError\n # do nothing\n end\n # We use code \"2\" as we need something than just standard error code 1, so we can differentiate the next step in CI\n exit 2\n end\n\n if is_running_on_emulator && !@emulator_commander.check_connection\n UI.important('Cannot connect to emulator. Exiting..')\n exit 2\n end\n end\n\n if is_running_on_emulator\n @emulator_commander.disable_animations\n @emulator_commander.increase_logcat_storage\n end\n\n execute_pre_action if @pre_action\n end", "def build_containers_tree\n TreeBuilderContainers.new(\"containers_tree\", \"containers\", @sb)\n end", "def add_container(container)\n # Avoid duplicated labels on compose\n while @containers.has_key?(container.attributes[:label]) do\n container.attributes[:label].succ!\n end\n\n @containers[container.attributes[:label]] = container\n true\n end", "def initialize(container_name, compose)\n @container_name = container_name\n @compose = compose\n end", "def create(*args)\n self.exec(\"lxc-create\", *args)\n self.state\n end", "def set_new\n @container = Container.find(params[:container_id])\n @container_row = ContainerRow.new\n end", "def init(container)\n end", "def create_container_with_http_info(container_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.create_container ...'\n end\n # verify the required parameter 'container_body' is set\n if @api_client.config.client_side_validation && container_body.nil?\n fail ArgumentError, \"Missing the required parameter 'container_body' when calling ContainersApi.create_container\"\n end\n # resource path\n local_var_path = '/containers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(container_body) \n\n # return_type\n return_type = opts[:return_type] || 'Container' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#create_container\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create(options={})\n unless options[:ostemplate]\n # We need at least a valid ostemplate\n raise ArgumentError, \"Create requires argument :ostemplate.\"\n end\n\n cmd = \"#{@vzctl} create #{@ctid}\"\n\n options.each do |opt,val|\n cmd << \" --#{opt}\"\n cmd << \" #{val}\"\n end\n\n execute(cmd)\n\n Log.debug(\"Reading new container configuration file: #{@configfile}\")\n @config = Config.new(load_config_file)\n @config.add_observer(self)\n end", "def create\n @container_stack = ContainerStack.new(params[:container_stack])\n\n respond_to do |format|\n if @container_stack.save\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully created.' }\n format.json { render json: @container_stack, status: :created, location: @container_stack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end", "def container\n @container ||= Docker::Container.get(@name)\n rescue Docker::Error::NotFoundError\n @container = nil\n end", "def initialize(params = {}) # get a name from the \"new\" call, or set a default\n @current_model = false\n @containers = []\n @resources = []\n \n @uri = params.fetch(:uri, false) # this should be failure\n abort \"cannot create a Container with no identifier... I'm dying!\" unless @uri\n case @uri\n when String\n @uri = URI.parse(@uri)\n end\n \n @client = params.fetch(:client, self.client)\n @parent = params.fetch(:parent, self.parent)\n @toplevel_container = params.fetch(:top, self) # if there is no toplevel, then I must be!\n @init = params.fetch(:init, true)\n @debug = self.client.debug\n #now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n #@slug = params.fetch(:slug, now)\n \n if @init # should I initialize by reading the content\n init_folder\n end\n \n return self\n \n end", "def create(cli = false)\n $logger.info(\"Creating new gear #{@uuid} for application #{@app.name}\")\n\n if cli\n command = %Q(oo-devel-node app-create -c #{uuid} -a #{@app.uuid} --with-namespace #{@app.account.domain} --with-app-name #{@app.name} --with-secret-token=DEADBEEFDEADBEEFDEADBEEFDEADBEEF)\n $logger.info(%Q(Running #{command}))\n results = %x[#{command}]\n assert_equal(0, $?.exitstatus, %Q(#{command}\\n #{results}))\n end\n\n # Create the container object for use in the event listener later\n begin\n @container = OpenShift::Runtime::ApplicationContainer.new(@app.uuid, @uuid, nil, @app.name, @app.name, @app.account.domain, nil, nil)\n rescue Exception => e\n $logger.error(\"#{e.message}\\n#{e.backtrace}\")\n raise\n end\n\n unless cli\n @container.create('DEADBEEFDEADBEEFDEADBEEFDEADBEEF')\n end\n end", "def test_create\n skip 'requires root privs' unless Process.euid == 0\n assert Launch::Container.new('test', fake_plist)\n end", "def create\n @serverhascontainer = Serverhascontainer.new(serverhascontainer_params)\n\n respond_to do |format|\n if @serverhascontainer.save\n format.html { redirect_to @serverhascontainer, notice: 'Serverhascontainer was successfully created.' }\n format.json { render :show, status: :created, location: @serverhascontainer }\n else\n format.html { render :new }\n format.json { render json: @serverhascontainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_container_data\n # For container env_vars and image info.\n task_definition_arn = first_task.task_definition_arn # task is a method in the superclass: Ssh\n response = ecs.describe_task_definition(task_definition: task_definition_arn)\n task_definition = response.to_h[:task_definition]\n container_definition = task_definition[:container_definitions].first # assumes care about the first container definition\n env_file_data = env_file_data(container_definition[:environment])\n\n sonic_folder = \"/tmp/sonic\"\n FileUtils.mkdir_p(sonic_folder) unless File.exist?(sonic_folder)\n IO.write(\"/tmp/sonic/task-arn.txt\", task_arns.first)\n IO.write(\"/tmp/sonic/docker-image.txt\", container_definition[:image])\n IO.write(\"/tmp/sonic/env-file.txt\", env_file_data)\n FileUtils.cp_r(bash_scripts, \"/tmp/sonic\")\n end", "def vanilla_container(config, name, &proc)\n config.vm.define name do |node|\n node.vm.provider \"docker\" do |docker|\n docker.name = name\n docker.create_args = [\"--hostname=#{name}\", \"--network=elasticsearch\"]\n docker.build_dir = \"vanilla\"\n docker.has_ssh = true\n\n proc.call(docker) if block_given?\n end\n end\nend", "def set_container\n @container = Container.find(params[:id])\n end", "def set_container\n @container = Container.find(params[:id])\n end", "def user_side_create(container)\n container_hash = container.for_db\n container_row = map_to_row!(container_hash)\n\n execute_sql(:create, :container) do\n @connection.transaction do\n yield if block_given?\n table.insert(container_row)\n end\n end\n end", "def run config_hash, name=nil\n #byebug \n container = get_container_by_name name\n \n \n if container.nil?\n container = create config_hash, name\n else\n Brick::CLI::logger.info \"container #{name} has already existed.\"\n end\n \n Brick::CLI::logger.debug \"container #{container}.\"\n \n \n unless container.is_running?\n container.start(start_config(config_hash))\n else\n Brick::CLI::logger.info \"container #{name} is #{container.info[\"Status\"]}\"\n end\n \n container\n end", "def instantiate(object)\n if object.kind_of? Class and object < Container\n cont = object.new\n cache = Cache.new(cont)\n cont.cache = cache\n else\n raise ArgumentError, \"#{object} is not a Dissident::Container\"\n end\n end", "def create(name)\n object = new(name)\n @instances.push(object)\n object\n end", "def initialize_container_file\n container_file.create true if container_file && !container_file.exists?\n end", "def prepare_containers(storage_account_name, containers, is_default_storage_account)\n @logger.info(\"prepare_containers(#{storage_account_name}, #{containers}, #{is_default_storage_account})\")\n containers.each do |container|\n @logger.debug(\"Creating the container `#{container}' in the storage account `#{storage_account_name}'\")\n create_container(storage_account_name, container)\n end\n set_stemcell_container_acl_to_public(storage_account_name) if is_default_storage_account\n end", "def create\n @container_content = @container.container_contents.new(params[:container_content])\n\n respond_to do |format|\n if @container_content.save\n format.html { redirect_to(@container_content.container, :notice => 'Container content was successfully created.') }\n format.xml { render :xml => @container_content, :status => :created, :location => @container_content }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @container_content.errors, :status => :unprocessable_entity }\n end\n end\n end", "def containerize(\n project_name: '',\n project_id: 0,\n app: {}\n )\n\n puts \"#{__method__.to_s} enter\"\n\n # Where to push the docker image\n #docker_remote_registry_uri = \"\"\n #docker_remote_registry_uri = \"localhost:5000\" if server.compute_engine == 'minikube'\n #docker_remote_registry_uri = \"gcr.io/#{project_name}-#{project_id}\" if server.compute_engine == 'gce'\n\n\n app_name = \"#{project_name}-#{project_id}\"\n image_name = \"#{project_name}-#{project_id}\"\n\n\n docker_context_directory = docker_ready_context_directory(\n app_name: app_name,\n app_source_directory: app.source_url\n )\n\n passenger_prep(container_context_directory: docker_context_directory, app_types: app.type)\n\n dockerfile_contents = docker_ready_dockerfile(app_directory: app_name, app_types: app.type)\n\n make_file(\"#{docker_context_directory}/Dockerfile\", dockerfile_contents)\n\n\n\n docker_create_container_image(image_name: image_name, context_directory: docker_context_directory)\n\n container_info = { image_name: image_name }\n\n puts \"#{__method__.to_s} exit\"\n\n # Convert data structure (hashes and arrays) into a\n # dot notation accessable structure (ex. config.project.name)\n #\n return RecursiveOpenStruct.new(container_info, recurse_over_arrays: true )\n\nend", "def container\n # Check if @container exists\n raise 'Task was not started' unless container?\n\n # Return the container\n @container\n end", "def add_container(name, dimensions, max_tower_count)\n container = Container.new(name, dimensions, (max_tower_count || :unlimited))\n\n pile = find_pile_for(container)\n\n if pile\n pile.add(container)\n else\n pile = Pile.new(@dimensions)\n pile.add(container)\n if pile_fits?(pile)\n @piles << pile\n else\n return false\n end\n end\n\n true\n end", "def create\n @frame = Frame.new(frame_params)\n frame_storage = FrameStorage.find(params[:frame_storage_id].to_i)\n begin\n Frame.transaction do\n @frame.save\n frame_storage.update_attributes(:frame_id=>@frame.id)\n @frame.batch_create_boxer_storage\n end\n redirect_to @frame, notice: 'Container was successfully created.'\n rescue\n puts '创建架子规格及存储架子的空间出错!'\n render :new\n end\n\n end", "def container\n @container ||= Dry::Container.new\n end", "def create\n @level_container = LevelContainer.new(params[:level_container])\n\n respond_to do |format|\n if @level_container.save\n format.html { redirect_to @level_container, notice: 'Level container was successfully created.' }\n format.json { render json: @level_container, status: :created, location: @level_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @container = Container.new\n \n respond_to do |format|\n format.html { render :action => :edit }\n format.xml { render :action => :edit, :xml => @container }\n end\n end", "def setup_construct(opts = {})\n opts = opts.dup\n chdir = opts.fetch(:chdir, true)\n opts.delete(:keep_on_error) { false } # not used in setup\n container = create_construct(opts)\n container.maybe_change_dir(chdir)\n container\n end", "def container\n namespace + '_container'\n end", "def new\n @container_content = @container.container_contents.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @container_content }\n end\n end", "def create\n basedir = @config.get(\"GEAR_BASE_DIR\")\n\n token = \"#{@container_uuid}_#{@namespace}_#{@container_name}\"\n path = File.join(basedir, \".httpd.d\", token)\n\n FileUtils.rm_rf(path) if File.exist?(path)\n FileUtils.mkdir_p(path) \n end", "def create\n basedir = @config.get(\"GEAR_BASE_DIR\")\n\n token = \"#{@container_uuid}_#{@namespace}_#{@container_name}\"\n path = File.join(basedir, \".httpd.d\", token)\n\n FileUtils.rm_rf(path) if File.exist?(path)\n FileUtils.mkdir_p(path) \n end", "def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end", "def create\n notify_observers(:before_container_create)\n @user.create\n notify_observers(:after_container_create)\n end", "def build_block_container(*args, &block)\n options = args.extract_options!\n\n anonymous = false\n if args.first\n name = args.shift\n else\n name = self.anonymous_block_name\n anonymous = true\n end\n\n block_container = Blocks::Container.new\n block_container.name = name.to_sym\n block_container.options = options\n block_container.block = block\n block_container.anonymous = anonymous\n block_container\n end", "def default_container\n Container.create_character_default_containers(self.id)\n end", "def container(container_id)\n if container_id\n container = ::Docker::Container.send(:new, @dockerd, container_id)\n # return the container json if we can retrieve it.\n begin\n # check the container exists by querying its json\n container.json\n container\n # if the container doesn't exist we get an Excon 404\n rescue Excon::Errors::NotFound\n nil\n end\n else\n nil\n end\n end", "def createECSService\n puts \"Creating ECS service #{$CLUSTER_NAME}...\"\n puts `ecs-cli compose \\\n --project-name #{$CONTAINER_NAME} \\\n service up \\\n --region #{$REGION} \\\n --cluster #{$CLUSTER_NAME} \\\n --launch-type EC2 \\\n --target-group-arn #{$TARGET_GROUP_ARN} \\\n --container-name #{$CONTAINER_NAME} \\\n --container-port #{$CONTAINER_PORT} \\\n --role ecsServiceRole`\nend", "def start_container(container)\n populate_chef_secure_path\n Chef::Log.info(\"Starting container #{container.id}...\")\n container.start\n end", "def container_params\n params.require(:container).permit(:name, :container_name, :image)\n end", "def register(...)\n container.register(...)\n end", "def create\n @container_item = ContainerItem.new(container_item_params)\n respond_to do |format|\n if @container_item.save\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was successfully created.')}\n format.json { render json: @container_item, status: :created, location: @container_item }\n else\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was NOT successfully created.')}\n format.json { render json: @container_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_exists?\n skip 'requires root privs' unless Process.euid == 0\n\n c = Launch::Container.new('a-container-that-does-not-exist', fake_plist)\n refute c.exists?\n\n skip 'need to figure out a way to spawn a test container'\n #c = Launch::Container.new('a-container-that-exists')\n #assert c.exists?\n end", "def create(id, name: nil, type: :PRODUCTION, labels: nil, clusters: nil)\n end", "def create_container_and_configuration(p_args)\n\n # Create container\n tool_container = GuiUtils.create_child_form({\n\t\t\t\t:class => Ui_ToolDescriptionWidget,\n :flags => 0,\n\t\t\t\t:base_widget => CustomFontWidget.new(@tools_form),\n\t\t\t})\n\n # Create configuration\n tool_config = ToolConfiguration.new(p_args)\n\n # Return results\n { :container => tool_container, :config => tool_config }\n end", "def add_child new_level_type, new_designation, &block\n\t\t\t\t@logger.debug \"Creating child container under #{breadcrumbs}...\"\n\t\t\t\tif self[new_designation, new_level_type]\n\t\t\t\t\t@logger.warn \"Child already exists: [#new_level_type] #{new_designation}\"\n\t\t\t\t\traise\n\t\t\t\tend\n\t\t\t\tnew_child = Container.new(new_level_type, new_designation, &block)\n\t\t\t\tnew_child.parent = self\n\t\t\t\t@children << new_child\n\t\t\t\treturn new_child\n\t\t\tend", "def initialize(cmd, version = nil)\n\t\t@@containers ||= {}\n\t\tunless ENV['debug'] then\n\t\t\tstderr_fd = $stderr.fcntl(Fcntl::F_DUPFD)\n\t\t\tFile.open('/dev/null','w') {|fh| $stderr.reopen(fh)}\n\t\tend\n\n\t\t@data = {}\n\n\t\t@container = $docker.containers.create(\n\t\t\t'Image' => SDockerImage.id,\n\t\t\t'Hostname' => hostname,\n\t\t\t'Cmd' => ['sh','-c','exec `which sshd` -D']\n\t\t)\n\t\tputs \"Building container #{@container.id}\"\n\t\t@container.start\n\t\tTimeout.timeout(15) do\n\t\t\tsystem(*(sshcmd('true')))\n\t\t\tbreak if $?.exitstatus == 0\n\t\t\tsleep 1\n\t\tend\n\n\t\t@@containers[@container.id] = self\n\t\tself.class.sync\n\n\t\tputs \"Building package version=#{version}\"\n\t\tpackage_io = IO.popen(['rake','package',\"source=#{version}\",\"out=/dev/stdout\"],'r')\n\t\tsystem(*(sshcmd(\"mkdir /#{SDockerImage::PROJECT_NAME}; tar -xzC /#{SDockerImage::PROJECT_NAME} --strip-components=1\")), 0 => package_io)\n\t\tpackage_io.close\n\n\t\tputs \"Installing package\"\n\t\tcmd(\"bundle install --local\")\n\n\t\tputs \"Build complete\"\n\t\tif stderr_fd then\n\t\t\t$stderr.reopen(IO.new(stderr_fd))\n\t\tend\n\tend", "def create_params\n sample_storage_container_params\n end", "def create_volume(options)\n # Creating the volume is part of the server creation\n end", "def create_volume(options)\n # Creating the volume is part of the server creation\n end", "def create(template_dir)\n tmp_dir = Dir.mktmpdir(\"sle2docker\")\n tmp_template_dir = File.join(tmp_dir, \"template\")\n result_dir = File.join(tmp_dir, \"result\")\n\n FileUtils.cp_r(File.join(template_dir, \".\"), tmp_template_dir)\n FileUtils.mkdir_p(result_dir)\n\n template_file = find_template_file(tmp_template_dir)\n if template_file.end_with?('.erb')\n template = render_template(template_file)\n File.open(File.join(tmp_template_dir, \"config.xml\"), \"w\") do |file|\n file.write(template)\n end\n end\n\n docker_cmd = \"docker run --rm \"\n # dns entries - otherwise docker uses Google's DNS\n dns_entries.each do |entry|\n docker_cmd += \"--dns=#{entry} \"\n end\n # the HTTP proxy specified by the user\n if @options[:http_proxy]\n docker_cmd += \"-e http_proxy=#{@options[:http_proxy]} \"\n end\n # ensure kiwi cache is persistent\n docker_cmd += \"-v /var/cache/kiwi:/var/cache/kiwi \"\n # share build dir\n docker_cmd += \"-v #{tmp_dir}:/#{tmp_dir} \"\n # required because kiwi needs to bind mount /proc while creating the image\n docker_cmd += \"--privileged \"\n # the image to use\n docker_cmd += \"opensuse/kiwi \"\n # kiwi directives\n docker_cmd += \"--build #{tmp_template_dir} --type docker -d #{result_dir}\"\n begin\n puts \"Starting build process inside of Docker container\"\n if !system(docker_cmd)\n $stderr.printf(\"Something wrong happened during the build process\\n\")\n exit(1)\n end\n end\n Dir[File.join(result_dir, \"*.tbz\")].first\n end", "def handle_start(event)\n @bus.request 'containers', 'started', event: event.json, container: container_info(event.id)\n end", "def new\n @composition = Composition.new\n end", "def create\r\n \"new GMap2(document.getElementById(\\\"#{@container}\\\"))\"\r\n end", "def container\n cache or raise RuntimeError, \"no container known.\"\n end", "def commit(options = {})\n options.merge!('container' => self.id[0..7])\n hash = JSON.parse(connection.request(:post, '/commit', options))\n Docker::Image.send(:new, :id => hash['Id'], :connection => self.connection)\n end", "def new_for_creating_stack\n infra_id = params.require(:infrastructure_id)\n\n histories = CfTemplate.for_infra(infra_id)\n # TODO: 変数名変えたほうがいいんじゃ\n globals = CfTemplate.global\n\n render json: {\n histories: histories,\n globals: globals,\n } and return\n end", "def wrap_container( payload )\n\n raise Dossia::BadArgumentError, 'This method expects a Nokogiri NodeSet or Element' unless payload.class == Nokogiri::XML::NodeSet or payload.class == Nokogiri::XML::Element\n\n builder = Nokogiri::XML::Builder.new do |xml|\n \n xml.container(\n \"xmlns\" => \"http://www.dossia.org/v2.0/api\",\n \"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\", \n \"xsi:schemaLocation\" => \"http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd\"\n )\n\n end\n\n builder = Nokogiri::XML builder.to_xml\n\n if payload.class == Nokogiri::XML::NodeSet\n payload.each {|node| builder.xpath('//api:container', 'api' => 'http://www.dossia.org/v2.0/api').first.add_child node }\n else\n builder.xpath('//api:container', 'api' => 'http://www.dossia.org/v2.0/api').first.add_child payload\n end\n\n builder\n\n end", "def create_vm(cpu, ram, capacity, name, cluster)\n return nil if cluster.networks.empty?\n\n vm_config = creation_config(cpu, ram, capacity, add_prefix(name), cluster.networks.first)\n vm = @folder.CreateVM_Task(config: vm_config, pool: cluster.resource_pool).wait_for_completion\n VSphere::VirtualMachine.new vm, folder: self\n end", "def create(container_name, file_name, body = nil, args = {})\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :put,\n path: \"#{container_name}/#{file_name}\",\n expected: 201,\n params: {:body => body},\n headers: create_headers_from(args)\n )\n end", "def create!\n doc.kubernetes_release.builds = [builds(:docker_build)]\n Kubernetes::ReleaseDoc.create!(\n doc.attributes.except('id', 'resource_template').merge(kubernetes_release: doc.kubernetes_release)\n )\n end", "def start_test_container(test_result_container)\n test_result_container.tap do |container|\n logger.debug { \"Starting test container: #{container.name}\" }\n\n container.start = ResultUtils.timestamp\n @test_context.push(container)\n end\n end", "def volume_create(name)\n @log.info \"Creating volume #{name} from offering id #{DISK_OFFERING}...\"\n ret = @cloud_stack.create_volume(name, ZONE, DISK_OFFERING)\n id = ret[\"createvolumeresponse\"][\"jobid\"]\n wait_for_job id\n vol_id = ret[\"createvolumeresponse\"][\"id\"]\n @log.info \"Created volume id: #{vol_id}\"\n vol_id\n end", "def container\n container_class\n end" ]
[ "0.8050959", "0.7759408", "0.75600547", "0.7483288", "0.7433373", "0.7287367", "0.7167117", "0.7157914", "0.69227374", "0.6864827", "0.6809483", "0.677375", "0.6754265", "0.65922725", "0.6511134", "0.6481132", "0.64740473", "0.6472005", "0.6435453", "0.6435349", "0.6430055", "0.6350806", "0.6341328", "0.6312673", "0.62981945", "0.6247282", "0.62216085", "0.61973524", "0.6100338", "0.6076493", "0.59822494", "0.5975856", "0.59662646", "0.5960529", "0.5959097", "0.5952287", "0.59471416", "0.5933152", "0.5927132", "0.5868425", "0.585061", "0.5839559", "0.57947105", "0.57915056", "0.5785727", "0.5771275", "0.5763656", "0.5755471", "0.5755471", "0.57344216", "0.57262814", "0.5715471", "0.5704315", "0.56777394", "0.56693894", "0.5656174", "0.56535995", "0.56215143", "0.56177485", "0.560339", "0.55971605", "0.55948967", "0.5591888", "0.5577384", "0.5534589", "0.5530325", "0.5522974", "0.5522974", "0.5502487", "0.5496626", "0.5470279", "0.5446282", "0.54419017", "0.5436753", "0.5429626", "0.5384654", "0.53789204", "0.5366941", "0.5361186", "0.534271", "0.53417987", "0.5315646", "0.5302113", "0.52964467", "0.5288465", "0.5288465", "0.52881587", "0.5285391", "0.5277688", "0.52755404", "0.5273922", "0.52737176", "0.52696073", "0.5263136", "0.52617323", "0.5255275", "0.5245123", "0.52437264", "0.5239597", "0.5230526" ]
0.65848744
14
Link to kata: Description: Fix the function I created this function to add five to any number that was passed in to it and return the new value. It doesn't throw any errors but it returns the wrong number. Can you help me fix the function? Answer:
def addFive(num) num + 5 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_five num\n num + 5\nend", "def add_ten(number)\n number += 10\nend", "def sum_3_5(number) \r\n\tsum3 = 0\r\n\tsum5 = 0\r\n\tsum15 = 0\r\n\t0.step(number-1,3) do |num|\r\n\t\tsum3 += num\r\n\tend\r\n\t0.step(number-1,5) do |num|\r\n\t\tsum5 += num\r\n\tend\r\n\t0.step(number-1,15) do |num|\r\n\t\tsum15 += (num)\r\n\tend\r\n\treturn sum3 + sum5 - sum15\r\nend", "def add_numbers(input_number)\n $number += input_number\n return $number\nend", "def multiply_by_five(n)\n n.to_i * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def multiply_by_five(n)\n n * 5\nend", "def sum_of_fifth n\r\n n.to_s.split(\"\").map! {|i| (i.to_i)**5}.inject(:+)\r\nend", "def number_adder(n)\n n += 10\nend", "def add_up(num)\n return (1..num).inject(:+)\nend", "def addFive(num=5)\n return 5 + num\nend", "def multiply_by_five(n)\r\n n * 5\r\n end", "def round_to_next_5(n)\n while n%5 != 0\n n+=1\n end\n return n\nend", "def add_eight(number)\n number + 8\nend", "def add_eight(number)\n number + 8\nend", "def add_eight(number)\n number + 8\nend", "def add_eight(number)\n number + 8\nend", "def add_eight(number)\n number + 8\nend", "def add_eight(number)\n number + 8\nend", "def add_eight(number)\n number + 8\nend", "def add_eight(number)\n number + 8\nend", "def times_three_and_plus_five(number)\n number * 3 + 5\n end", "def solution(number)\n number -=1 and sum = 0 and for x in number.downto(0) do x%5 == 0 ? (sum = sum+x) : if(x%3 == 0) then sum = sum+x \n end end and return sum \nend", "def add(number)\n set_value(@value + number.to_i)\n end", "def sum_of_digits_to_fifth?(num)\n\tnum == num.to_s.split(//).map{|i| (i.to_i)**5}.reduce(:+)\nend", "def sum_to_n(n)\n # Your Code Here!\nend", "def z_function(number)\n return 0 if number < 5\n number/5 + z_function(number/5)\nend", "def add_up(integer)\n x = 0\n for i in 1..integer\n x+=i\n end \n puts x\n return x\nend", "def add_three(number)\n number + 3\n return number + 4\nend", "def compute_sum(number)\n total = 0\n 1.upto(number) { |value| total += value }\n total\nend", "def sum(num, total) => total += num", "def SimpleAdding(num)\nsum=0\n 1.upto(num) do |x|\n\tsum+=x\n\tend\n\t\nreturn sum\nend", "def add_two(x)\n\tx + 5\nend", "def add_it_up\n number = 2 + 2\n puts number\nend", "def sum(number)\n total = 0\n 1.upto(number) {|v| total += v }\n total\nend", "def divisible_by_3(number)\n sum = 0\n changing_value = 0\n until (changing_value >= number)\n if (changing_value % 5 == 0)\n sum = sum + changing_value\n\n end\n changing_value += 1\n end\n return sum\nend", "def add_three(number)\n return number + 3\nend", "def add_three(number)\n return number + 3\nend", "def add_three(number)\n return number + 3\nend", "def add_three(number)\n return number + 3\nend", "def add_up(num)\n\tsum = 0;\n\t(1..num).each { |x| sum += x }\n\tsum\nend", "def SimpleAdding(num\n total = 1.upto(num).reduce(&:+)\n total \nend", "def add_three(number)\n return number + 7\n number + 12\nend", "def sum_to(n)\n # if n < 2\n # 1\n # else\n # n + sum_to(n-1)\n # end\n return 1 if n < 2\n n + sum_to(n - 1)\nend", "def next_number(number)\n return number += 1\nend", "def SimpleAdding(num)\n\n # code goes here\n range_sum = *(1..num)\n return range_sum.inject(:+)\n \nend", "def plus_one(number)\n number + 1\nend", "def SimpleAdding(num)\n\n # code goes here\n range_num = *(1..num)\n return range_num.inject(:+)\n \nend", "def next_number(number)\n number.to_i\n return number+=1\nend", "def sum_to(n)\n return nil if n < 0\n return n if n == 0\n n += sum_to(n - 1)\nend", "def add_three(number)\n number + 3\nend", "def add_three(number)\n number + 3\nend", "def add_three(number)\n number + 3\nend", "def add_three(number)\n number + 3\n number + 4 \nend", "def sum(n)\n end", "def multiply_fifteen num\n num * 15\nend", "def mess_with_it(some_number)\n some_number += 8\nend", "def add_three(number)\n return number + 3\n number + 4\nend", "def add_three(number)\n return number + 3\n number + 4\nend", "def add_three(number)\n return number + 3\n number + 4\nend", "def add_three(number)\n return number + 3\n number + 4\nend", "def sumofint(target,maxValue,number)\n if target == 0\n print \"#{number}\\n\"\n else \n if maxValue > 1\n sumofint(target, maxValue-1, number)\n end\n if maxValue <= target\n\n sumofint(target-maxValue, maxValue, maxValue.to_s + \"+\" + number)\n\n end\n end\nend", "def add_three(n)\n n + 3\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n < 1\n n += sum_to(n - 1)\nend", "def simple_adding(num)\n (1..num).inject(:+)\nend", "def multisum(number)\n sum = 0\n\n 1.upto(number) { |i| sum += i if i % 3 == 0 || i % 5 == 0 }\n sum\nend", "def sum_to(n)\n return n if n == 1\n n + sum_to(n-1)\nend", "def fourth_method(number)\n\tnumber += 7 #number is scoped locally to the method\nend", "def multisum(number)\n (0..number).reduce { |sum, n| n % 5 == 0 || n % 3 == 0 ? sum + n : sum }\nend", "def nth(n)\n\tif n <= 0 \n\t\treturn 0 \n\tend \n\tif n == 1\n\t\treturn 17 \n\telse \n\t\treturn nth(n-1) + 5 \n\tend \nend", "def addition(number)\n (1..number).reduce(:+)\nend", "def multiples_of_3_and_5_recursive(num, sum = 0)\n return sum if num == 0\n\n num = num - 1\n\n if (num % 3 == 0) || (num % 5 == 0)\n sum += num\n end\n\n multiples_of_3_and_5_recursive(num, sum)\n\nend", "def compute_sum(number)\n (1..number).inject(:+)\nend", "def add_three_again(x)\r\n new_value = x + 3\r\n puts new_value # prints returned value\r\n new_value # == return new_value; implicitly returns\r\nend", "def add(first_number, second_number)\n return first_number + second_number\nend", "def add(first_number, second_number)\n return first_number + second_number\nend", "def add(first_number, second_number)\n return first_number + second_number\nend", "def addition(num)\n\treturn num+1\nend", "def add_two(number)\n number + 2 # res of last line will be returned\nend", "def recursion(x)\n return \"HEYO!\" if x >= 5\n puts x\n recursion(x += 1)\nend", "def SimpleAdding(num)\n (1..num).inject(:+)\nend", "def SimpleAdding(num)\n (1..num).inject(:+)\nend", "def add(n, p)\n return n + p\nend", "def add(first_number, second_number)\n return first_number + second_number\nend", "def plus_one(num_2)\n return num_2 +1\n\nend", "def next_number(num)\n return num += 1\nend", "def add(first_number, second_number)\n return first_number + second_number\nend", "def process_range(range)\n multi = multiple_of_3_and_5(range - 1)\n sum = addition(multi)\n\n puts sum\nend", "def next_number(number)\n return number +1\nend", "def sum_to(n)\n return nil if n < 1\n return n if n == 1\n \n n + sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 1\n return 1 if n == 1\n\n n + sum_to(n - 1) \nend", "def add_digits(number)\nend" ]
[ "0.76271623", "0.70259476", "0.70219594", "0.6982283", "0.69683284", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6888496", "0.68528074", "0.68372726", "0.68290305", "0.6823146", "0.68139154", "0.67745787", "0.67745787", "0.67745787", "0.67745787", "0.67745787", "0.67745787", "0.67745787", "0.67745787", "0.66956985", "0.6659514", "0.6606308", "0.6581522", "0.6580884", "0.65761185", "0.6556574", "0.65292716", "0.648619", "0.64806247", "0.6459995", "0.64533174", "0.6433652", "0.6433367", "0.6427698", "0.64241433", "0.64241433", "0.64241433", "0.64241433", "0.6404583", "0.63934183", "0.6378327", "0.6365692", "0.63642603", "0.6354859", "0.6352982", "0.6348846", "0.63349897", "0.63294506", "0.632883", "0.632883", "0.632883", "0.6327963", "0.6317851", "0.63152736", "0.63072175", "0.63014084", "0.63014084", "0.63014084", "0.63014084", "0.6301303", "0.628537", "0.6276296", "0.6272585", "0.62556815", "0.62498516", "0.62433594", "0.6239662", "0.62367725", "0.6236452", "0.62312365", "0.6214086", "0.6213635", "0.62117684", "0.62117684", "0.62117684", "0.6210246", "0.62090385", "0.62023747", "0.6197258", "0.6197258", "0.61932397", "0.6191114", "0.6188988", "0.61860734", "0.6180704", "0.61722636", "0.617144", "0.6168005", "0.61605036", "0.61591953" ]
0.76390034
0
GET /productors GET /productors.json
def index @productors = Productor.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n cycle_id: params[:cycle_id],\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n })\n render json: @products\n end\n end", "def index\n @products = @user.products\n # was @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def products\n request :public, :get, :products\n end", "def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend", "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def show\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @product }\n end\n end", "def user_products\n @products = current_user.products\n\n respond_to do |format|\n format.html\n format.json { render json: @products }\n end\n end", "def show\n \n @product = Product.find(params[:id])\n @vendors = @product.vendor(:all)\n #@vendors = Vendor.find(params[:id])\n #@vendors = Vendor.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n @products = Product.all\n render json: @products\n end", "def show\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n render json: @product\n end", "def products\n run(:get,\"/school_products\", [200])\n end", "def index\n \tproducts = Product.all\n \trender json: products\n \tend", "def show\n render json: @product\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventories }\n end\n end", "def index\n @products = Product.all\n @users = Product.find(:all)\n #--------amazon cloud search-----------------------------------------------------------\n #searcher = CloudSearch::Searcher.new\n #@resp = searcher.with_fields(:id, :actor, :director, :title, :year, :text_relevance)\n # .with_query(\"star wars\")\n # .search\n #--------------------------------------------------------------------------------------\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n format.xml { render :xml => @products }\n end\n end", "def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end", "def show\n @product = Product.find(params[:id])\n json_response(params)\n end", "def index\n begin\n @products = Product.all\n render json: @products, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end", "def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end", "def show\n render json: @product, status: 200\n end", "def index\n render :json => Producto.all\n end", "def index\n if current_user.admin?\n @products = Product.all\n else\n if current_user.private?\n @products = Product.where(owner_id: current_user.private_id)\n elsif current_user.business?\n @products = Product.where(owner_id: current_user.business_id)\n end\n\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def show\n @product_owner = ProductOwner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_owner }\n end\n end", "def show\n @product = Product.find(params[:id])\n @donor = Donor.all\n @event = Event.all\n @category = Category.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = @user.products.find(params[:id])\n # was @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end", "def show\n render :json => Producto.find(params[:id])\n end", "def show\n @supplier = Supplier.find(params[:id])\n @products = Product.where(:supplier_id => @supplier.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @supplier }\n end\n end", "def index\n @produtors = Produtor.all\n end", "def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end", "def index\n @orden_products = OrdenProduct.all\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def show\n json_response(@api_v1_product)\n end", "def index\n @electors = Elector.all\n\n render json: @electors\n end", "def index\n @products = Product.all\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end", "def show\n render json: @elector\n end", "def show\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onecompany_product }\n end\n end", "def index\n limit = params[:limit]&.to_i || 10\n page = params[:page]&.to_i || 0\n if params[:available] == \"1\"\n @products = Product.paginate(page, limit).available\n else\n @products = Product.paginate(page, limit)\n end\n render json: @products\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def show\n # is_my_resource(params[:id])\n\n # prossumerProductsIds = Prossumer.find(params[:id]).products.ids\n render json: ProductAuth.where({product_id: params[:id], group_id: params[:group_id]}).first.as_json(:include => :product)\n end", "def index\n #@products = Product.all\n @products = Product.paginate( :page => params[:page],\n :per_page => 40\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @user_interactive_products = UserInteractiveProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_interactive_products }\n end\n end", "def products\n FarMar::Product.by_vendor(id)\n end", "def products\n FarMar::Product.by_vendor(id)\n end", "def show\n @product = ProductProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def show\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n @producto = Producto.find(params[:id])\n render json: @usuario.productos.find(@producto.id)\n else\n \t @producto = Producto.find(params[:id])\n render json: @producto\n end\n end", "def index\n @ordered_products = OrderedProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordered_products }\n end\n end", "def index\n @products = @co.products\n end", "def getKind\n @products = Product.where(\"kind = ?\", params[:kind]).available.PriceOrder.paginate(page: params[:page], per_page: 5)\n render json: @products\n end", "def show\n @product = Product.find(params[:id])\n render json: @product, status: :ok\n end", "def products\n Product.find_by_vendor(@id)\n end", "def show\n @products = @vendor.products\n end", "def all\n @products = Product.get_list_active_products.page(params[:page]).per(10)\n if @products.present?\n @products\n else\n @object = 'product'\n render \"api/v1/errors/404\", status: 401\n end\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n render json: @product_management\n end", "def index\n @food_products = FoodProduct.all\n render json: @food_products\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def index\n # if current_user\n # @products = Product.all\n # else\n # render json: []\n # end\n @products = Product.all\n\n if params[:category] #this allows the user to search from the index by product NAME, nothing else\n category = Category.find_by(name: params[:category]) # or (\"name ILIKE ?\", \"%#{params[:category]}%\") #THIS WILL HANDLE CATEGORIES WITH SPACES\n @products = category.products\n end\n\n # if params[:search] #this allows the user to search from the index by product NAME, nothing else\n # @products = Product.where(\"categories.name ILIKE ?\", \"%#{params[:search]}%\")\n # end\n\n #@products = @products.order(price: :asc) #this orders the results by price in ascending order\n render \"index.json.jb\"\n end", "def show\n @products = @merk_lensa.products.order(\"created_at ASC\").paginate(:page => params[:page], :per_page => 9)\n end", "def get_products\n products = response['products']\n products_ops = []\n products.each_value do |value|\n product = {}\n product[:sku] = value['sku']\n product[:product_family] = value['productFamily']\n product[:pricing_list_id] = pricing_list.id\n attributes = value['attributes']\n product[:service_code] = attributes['servicecode']\n product[:location] = attributes['location']\n product[:location_type] = attributes['locationType']\n product[:usage_type] = attributes['usagetype']\n product[:operation] = attributes['operation']\n product[:request_description] = attributes['requestDescription']\n product[:request_type] = attributes['requestType']\n product[:service_name] = attributes['servicename']\n product[:pricing_list_id] = pricing_list.id\n product[:created_at] = Time.zone.now.utc\n product[:updated_at] = Time.zone.now.utc\n products_ops << product\n end\n products_ops\n end", "def show\n @related_product = RelatedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @related_product }\n end\n end", "def index\n @product_owners = ProductOwner.all\n end", "def show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def index\n @products = current_company.products.order('created_at desc').page(params[:page]).per(20)\n render json: @products, meta: {total_pages: @products.total_pages, total_count: @products.total_count}\n end", "def user_product_listings\n render json: @user.product_listings\n end", "def index\n @products = Product.all\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def index\n $products = Array.new\n @customers=Customer.all\n @cities=City.all\n $product=Product.new\n $receivers = Receiver.find(:all)\n $addresses=Array.new\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: $products }\n end\n end", "def index\n scope = Product.includes(:merchant, :brand, :category, :founder, :likers, comments: :user)\n scope = scope.order(updated_at: :desc)\n @products = paginate scope.all\n respond_to do |format|\n format.html\n format.json { render json: @products }\n end\n end", "def view_product\n to_json(\n only: [:id, :title, :description, :key_information],\n methods: [:photo_url, :net_mrp, :mrp_per_unit, :quantity],\n :include => {\n store: {\n only: [:name, :id],\n methods: [:full_address]\n }\n }\n )\n end", "def show\n @product = Product.find(params[:id])\n @photos = @product.photos\n\t@related_products = Product.where(\"category_id = ? and manufacturer_id = ? and id <> ?\", @product.category, @product.manufacturer,@product.id ).limit(6)\n @reviews = @product.reviews.paginate(:page => params[:page], :per_page => 10)\n @manufacturer_products = @product.manufacturer.products.where(\"id <> ?\",@product.id).limit(5) unless @product.manufacturer.nil?\n if (current_user != nil)\n @cart = User.find(session[:user_id]).cart\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def products\n Product.find_all_by_vendor_id(@id)\n end", "def show\n render json: @food_product\n end", "def show\n @ordered_product = OrderedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ordered_product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end" ]
[ "0.6741463", "0.67171097", "0.671549", "0.6692232", "0.6658295", "0.6645084", "0.6617059", "0.65588254", "0.65062225", "0.63921005", "0.6380967", "0.63795066", "0.63716406", "0.6369781", "0.63629127", "0.63590723", "0.6352903", "0.6352829", "0.63419574", "0.6332381", "0.6330889", "0.6325905", "0.6320308", "0.6308383", "0.6301289", "0.6300187", "0.6297863", "0.6280767", "0.62799627", "0.626767", "0.626575", "0.62564623", "0.6254821", "0.62263954", "0.6225888", "0.6225888", "0.6225888", "0.62156284", "0.6190696", "0.6190696", "0.6190696", "0.6190696", "0.6186504", "0.6180368", "0.61698073", "0.6151925", "0.6144194", "0.6144184", "0.6136622", "0.6135765", "0.6129989", "0.6126999", "0.6115462", "0.6112626", "0.6112626", "0.61115855", "0.61092955", "0.610671", "0.6105075", "0.60969716", "0.6091908", "0.60865664", "0.60851395", "0.6084271", "0.60753673", "0.60622865", "0.6056944", "0.6055489", "0.6040729", "0.6040319", "0.60275805", "0.6025718", "0.60206974", "0.6011986", "0.6010978", "0.60104465", "0.600989", "0.60062075", "0.59998065", "0.5997957", "0.5994794", "0.599353", "0.59868944", "0.5984872", "0.5982722", "0.59781486", "0.59781396", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125", "0.5978125" ]
0.724601
0
GET /productors/1 GET /productors/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @product }\n end\n end", "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def index\n @productors = Productor.all\n end", "def show\n @product = Product.find(params[:id])\n json_response(params)\n end", "def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n cycle_id: params[:cycle_id],\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n })\n render json: @products\n end\n end", "def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end", "def show\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onecompany_product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def show\n render :json => Producto.find(params[:id])\n end", "def show\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n \n @product = Product.find(params[:id])\n @vendors = @product.vendor(:all)\n #@vendors = Vendor.find(params[:id])\n #@vendors = Vendor.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n render json: @product, status: 200\n end", "def show\n @product = @user.products.find(params[:id])\n # was @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end", "def show\n json_response(@api_v1_product)\n end", "def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end", "def show\n render json: @product\n end", "def show\n @product = Product.find(params[:id])\n\n render json: @product\n end", "def show\n render json: @product\n end", "def show\n @product = Product.find(params[:id])\n render json: @product, status: :ok\n end", "def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end", "def index\n @products = @user.products\n # was @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def show\n @product = ProductProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend", "def show\n @product_owner = ProductOwner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_owner }\n end\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n # is_my_resource(params[:id])\n\n # prossumerProductsIds = Prossumer.find(params[:id]).products.ids\n render json: ProductAuth.where({product_id: params[:id], group_id: params[:group_id]}).first.as_json(:include => :product)\n end", "def show\n @product = Product.find(params[:id])\n @donor = Donor.all\n @event = Event.all\n @category = Category.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def user_products\n @products = current_user.products\n\n respond_to do |format|\n format.html\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n render json: @products\n end", "def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end", "def show\n @supplier = Supplier.find(params[:id])\n @products = Product.where(:supplier_id => @supplier.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @supplier }\n end\n end", "def show\n @related_product = RelatedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @related_product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=> @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end", "def products\n request :public, :get, :products\n end", "def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end", "def index\n render :json => Producto.all\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventories }\n end\n end", "def show\n puts \"the params are #{params}\" \n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produto }\n end\n end", "def show\n @product = Product.find(params[:id]) \n # @product_id = @product.id\n # @review = Review.find(@product_id)\n\n # @reviews = Review.where(:product_id => params[:id])\n @reviews = Review.where(:product_id => @product.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end", "def show\n @ordered_product = OrderedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ordered_product }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def show\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n @producto = Producto.find(params[:id])\n render json: @usuario.productos.find(@producto.id)\n else\n \t @producto = Producto.find(params[:id])\n render json: @producto\n end\n end", "def index\n \tproducts = Product.all\n \trender json: products\n \tend", "def show\n @venue_product = VenueProduct.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venue_product }\n end\n end", "def show\n render json: @product_management\n end", "def getKind\n @products = Product.where(\"kind = ?\", params[:kind]).available.PriceOrder.paginate(page: params[:page], per_page: 5)\n render json: @products\n end", "def show\n @product = Product.eager_loading.find_by_uuid(params[:id])\n\n respond_to do |format|\n format.html { redirect_to edit_shop_product_path(@product.shop_id, @product)}\n format.json { render json: @product.as_json(:include => {:product_variants => {:include => [:option_types,:pictures]}, :shipping_category => {}}, :methods => [:taxon_ids]) }\n end\n end", "def show\n render json: @food_product\n end", "def show\n @products = Product.find(params[:id])\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end", "def show\n if is_my_resource(@product.prossumer_id)\n render json: @product.as_json({\n cycle_id: params[:cycle_id],\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n })\n end\n end", "def show\n @review = Review.find(params[:id])\n @product = @review.product\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @review }\n end\n end", "def index\n @products = Product.all\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end", "def show\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @producto }\n end\n end", "def get_product\n @product = Product.find(params[:id])\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end", "def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end", "def show\n @user_interactive_product = UserInteractiveProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_interactive_product }\n end\n end", "def find(product_id, options = nil)\n request = Request.new(@client)\n path = \"/products/\" + CGI.escape(product_id) + \"\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"product\"]\n \n \n obj = Product.new(@client)\n return_values.push(obj.fill_with_data(body))\n \n\n \n return_values[0]\n end", "def show\n\n \n\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @producto }\n end\n end", "def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prod }\n end\n end", "def index\n begin\n @products = Product.all\n render json: @products, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end", "def show\n @home_searches_product = Home::Searches::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_searches_product }\n end\n end", "def find_resource\n if !params[:format].nil? && params[:format] == \"json\"\n begin\n p \"i came in\"\n p params[:id]\n Product.find_by_id(params[:id])\n rescue Exception => e\n error = error_response_method($e2)\n render :json => error\n end\n else\n Product.find_by_permalink!(params[:id])\n end\n end", "def show\n @product_lot = ProductLot.find(params[:id])\n render json: @product_lot, root: false\n end", "def get_product\n @product = Product.find_by_uuid(params[:product_id])\n if @product.nil?\n raise Repia::Errors::NotFound\n end\n end", "def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @prod }\n end\n end" ]
[ "0.7177513", "0.71620387", "0.69384587", "0.6872269", "0.6867054", "0.6861888", "0.68502027", "0.68350583", "0.6815497", "0.6780527", "0.67383075", "0.67305285", "0.67268795", "0.6717179", "0.6717163", "0.6713163", "0.67049307", "0.66973525", "0.6681537", "0.66773593", "0.6626525", "0.66251963", "0.66224504", "0.6589085", "0.65857244", "0.6584753", "0.6581753", "0.65234214", "0.65088534", "0.6499816", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.64997053", "0.6499636", "0.6477926", "0.64768094", "0.6470897", "0.6465588", "0.6463719", "0.64576894", "0.6455899", "0.6455899", "0.6455899", "0.6451685", "0.64475673", "0.64216644", "0.6421237", "0.64198035", "0.6410206", "0.63897306", "0.63760185", "0.63721734", "0.63511133", "0.6342475", "0.63350236", "0.63200873", "0.63149256", "0.631193", "0.6301748", "0.6300882", "0.63003576", "0.6299797", "0.6299797", "0.6299797", "0.6296347", "0.62913626", "0.62833923", "0.62741184", "0.6269887", "0.62678444", "0.62678444", "0.62678444", "0.62678444", "0.62672734", "0.6263853", "0.6262046", "0.62606764", "0.6260675", "0.62554365", "0.62468266", "0.6240116", "0.6233888", "0.62311304", "0.62273633" ]
0.0
-1
POST /productors POST /productors.json
def create @productor = Productor.new(productor_params) respond_to do |format| if @productor.save format.html { redirect_to @productor, notice: 'Productor was successfully created.' } format.json { render :show, status: :created, location: @productor } else format.html { render :new } format.json { render json: @productor.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n if params[:products]\n params[:products].each do |product|\n @product = Product.new(name: product[:name],\n brand: product[:brand],\n model: product[:model],\n sku: product[:sku],\n price: product[:price],\n desc: product[:desc])\n if !@product.save\n render json: @product.errors.full_messages, status: 422\n end\n end\n render 'api/products/index'\n else\n @product = Product.new(product_params)\n if @product.save\n render 'api/products/show'\n else\n render json: @product.errors.full_messages, status: 422\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.create!(product_params)\n json_response(@product, :created)\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n \n @orden_product = OrdenProduct.new(orden_product_params)\n \n respond_to do |format|\n if @orden_product.save\n format.html { redirect_to @orden_product, notice: 'Orden product was successfully created.' }\n format.json { render :show, status: :created, location: @orden_product }\n else\n format.html { render :new }\n format.json { render json: @orden_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = @collection.products.build(product_params)\n\n if @product.save\n render json: @product, status: :created#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(product_params)\n @product.user = current_api_v1_user\n respond_to do |format|\n if @product.save\n params[:product][:properties].try(:each) do |k,v|\n @product.product_properties.create(property: Property.find(k), value: v)\n end\n params[:product][:colors].try(:each) do |c|\n @product.colors.create(name: c[:name].downcase, code: c[:code])\n end\n params[:product][:photos].try(:each) do |c|\n @product.photos.create(image: c)\n end\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created}\n else\n format.html { render :new }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = @person.products.build(params[:model])\n\n respond_to do |format|\n if @product.save\n format.json { render :json => @product, :status => :created}\n else\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n product = Product.new(product_params)\n if product.save\n render json: ProductSerializer.new(product).serialized_json\n end\n end", "def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(params[:product])\n @manufacturers = Manufacturer.all\n @categories = Category.all\n respond_to do |format|\n if @product.save\n \n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @productonegocio = Productonegocio.new(params[:productonegocio])\n\n respond_to do |format|\n if @productonegocio.save\n format.html { redirect_to @productonegocio, notice: 'Productonegocio was successfully created.' }\n format.json { render json: @productonegocio, status: :created, location: @productonegocio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @productonegocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_owner = ProductOwner.new(params[:product_owner])\n\n respond_to do |format|\n if @product_owner.save\n format.html { redirect_to @product_owner, notice: 'Product owner was successfully created.' }\n format.json { render json: @product_owner, status: :created, location: @product_owner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = current_user.products.new(name: product_params[:name],description:product_params[:description],price:product_params[:price])\n @product.brand = Brand.find_by(brandName: product_params[:brand])\n @product.categories = Category.where(category:product_params[:category])\n respond_to do |format|\n if @product.save \n format.html { redirect_to new_product_location_path(@product), notice: \"Product was successfully created.\"}\n format.json { render json: @product}\n \n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n return unless product_params\n render json: Product.create_product(\n @product_params,\n category_list,\n @current_user.id\n ).simple_info, status: :created\n rescue => e\n render json: { error: e }, status: :bad_request\n end", "def create\n @product_owner = ProductOwner.new(product_owner_params)\n\n respond_to do |format|\n if @product_owner.save\n format.html { redirect_to @product_owner, notice: 'Product owner was successfully created.' }\n format.json { render :show, status: :created, location: @product_owner }\n else\n format.html { render :new }\n format.json { render json: @product_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @produtor = Produtor.new(produtor_params)\n\n respond_to do |format|\n if @produtor.save\n format.html { redirect_to @produtor, notice: 'Produtor was successfully created.' }\n format.json { render :show, status: :created, location: @produtor }\n else\n format.html { render :new }\n format.json { render json: @produtor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n if @product.save\n render json: {id: @product.id}\n else\n render json: {msg: @product.errors.full_messages.first}, status: :unprocessable_entity\n end\n end", "def create\n\n product_details = params.permit(:title, :inventory_count, :price)\n success = Product.create(product_details)\n\n render json: { success: success }\n end", "def create\n newProduct = Product.new(products_params)\n if newProduct.save\n msg = { status: 201 , product: newProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end", "def create\n @product = current_user.products.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n product_name = competitor_params[:title]\n honestbee_datas = get_honestbee_data (product_name)\n predict_catalog = get_predict_catalog ( product_name )\n save_data_in_postgres (predict_catalog)\n render :json => honestbee_datas\n end", "def create\n @product = current_vendor.vendor_products.new(vendor_product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to vendor_products_url, notice: 'product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = @productable.products.find(params[:product_id])\n ids = params[:products]\n reals = @productable.products.map(&:id) # Make a lambda with this\n present_prod = ids.select { |n| reals.include?(n) } # And this\n if @product.update(product_relations: present_prod)\n render json: @product, status: 200\n else\n render json: @product.errors, status: 422\n end\n end", "def create\n @product = Product.new(params[:product])\n respond_to do |format|\n if @product.save\n current_user.user_info.products.push @product\n Shopify.create @product\n format.html { redirect_to :action => 'index' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n #@product = Product.create(vendor_id: @vendor.id)\n #@vendor = Vendor.all\n #@product = @vendor.products.create(product_date :Time.now, vendor_id: @vendor.id)\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n @product.save\n set_products\n end", "def create\n @product = current_user.products.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n #permitted_columns = params[:products_purposes_relations].permit(:product_id, :purpose_id, :stars)\n # @products_purposes_relation = @product.products_purposes_relations.create(permitted_columns)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t('create_success') }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def create\n @related_product = RelatedProduct.new(params[:related_product])\n\n respond_to do |format|\n if @related_product.save\n format.html { redirect_to @related_product, notice: 'Related product was successfully created.' }\n format.json { render json: @related_product, status: :created, location: @related_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @related_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.build(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @supplier, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product,\n :notice=> 'Product was successfully created.' }\n format.json { render :json=> @product, :status=> :created,\n :location=> @product }\n else\n format.html { render :action=> \"new\" }\n format.json { render :json=> @product.errors,\n :status=> :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_path, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t(:product_created) }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n \n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @my_product = current_user.products.new(my_product_params)\n\n if @my_product.save\n render :show, status: :created\n else\n render json: @my_product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n p \"******************\"\n p product_params\n p \"******************\"\n\n\n @product = Product.new(product_params)\n @product.seller_id = current_user.id\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @productos_por_cliente = ProductosPorCliente.new(productos_por_cliente_params)\n\n respond_to do |format|\n if @productos_por_cliente.save\n format.html { redirect_to @productos_por_cliente, notice: 'Productos por cliente was successfully created.' }\n format.json { render :show, status: :created, location: @productos_por_cliente }\n else\n format.html { render :new }\n format.json { render json: @productos_por_cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product].merge :user_id => current_user.id)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to root_url, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(params[:product])\n @product.shop = Shop.find_by_uuid params[:shop_id]\n\n respond_to do |format|\n if @product.save!\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully created.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if @product.save\n render :show, status: :created, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = current_user.products.build(products_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Produkt utworzony pomyślnie' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = current_user.products.build(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @onecompany_product = Onecompany::Product.new(params[:onecompany_product])\n\n respond_to do |format|\n if @onecompany_product.save\n format.html { redirect_to @onecompany_product, notice: 'Product was successfully created.' }\n format.json { render json: @onecompany_product, status: :created, location: @onecompany_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @onecompany_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = @user.products.build(params[:product])\n # was @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to user_products_url(@user), notice: 'Product was successfully created.' }\n # format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @profesor = Profesor.new(profesor_params)\n\n if @profesor.save\n render json: @profesor, status: :created, location: @profesor\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.new(product_params)\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: products_url }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_product(product)\n request(product, \"product\", :post, {method: \"add\"})\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product,\n notice: 'Product was successfully created.' }\n format.json { render :show, status: :created,\n location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors,\n status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6713027", "0.6615665", "0.65932584", "0.65732664", "0.6542138", "0.6514128", "0.6510743", "0.6489597", "0.64563674", "0.6453787", "0.64093566", "0.6408194", "0.637801", "0.63757545", "0.63692707", "0.6295044", "0.62853426", "0.6271232", "0.6265685", "0.62552404", "0.62497705", "0.6225839", "0.6207268", "0.6206341", "0.61838675", "0.6175494", "0.6174121", "0.61680895", "0.6161545", "0.6149875", "0.6142175", "0.61390287", "0.61365736", "0.61224675", "0.61138767", "0.61138767", "0.61138767", "0.6105067", "0.6095116", "0.60900176", "0.6089839", "0.6084954", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6080496", "0.6064979", "0.60618454", "0.60601956", "0.60596657", "0.60570467", "0.605141", "0.6051097", "0.60427654", "0.6035664", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.602455", "0.6023982", "0.6023834", "0.6023115", "0.60229367", "0.6021344", "0.60209125", "0.6019756", "0.6018639", "0.6014922" ]
0.69069326
0
PATCH/PUT /productors/1 PATCH/PUT /productors/1.json
def update respond_to do |format| if @productor.update(productor_params) format.html { redirect_to @productor, notice: 'Productor was successfully updated.' } format.json { render :show, status: :ok, location: @productor } else format.html { render :edit } format.json { render json: @productor.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n if @onecompany_product.update_attributes(params[:onecompany_product])\n format.html { redirect_to @onecompany_product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @onecompany_product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n return unless product_params\n render json: @product.simple_info, status: :ok if @product.update!(@product_params)\n rescue => e\n render json: { error: e }, status: :ok\n end", "def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end", "def update\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:model])\n flash[:notice] = 'Product was successfully updated.'\n format.json { render :json=>nil }\n else\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product.assign_attributes object_params.reject{|_, v| v.blank?}\n # In a normal app we have a pre filled form of the object to update,\n # so when we do a PATCH (or PUT) we send all the attributes again,\n # in the API we permit to send any field to update, so we need to remove\n # all the blank params of the object to prevent validations triggers of\n # attributes that we don't send to update\n if @product.save\n render json: @product.to_json\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n if @product.update(product_params)\n render json: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n if @productonegocio.update_attributes(params[:productonegocio])\n format.html { redirect_to @productonegocio, notice: 'Productonegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @productonegocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n if @product.update(product_params)\n head :no_content\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def editProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.find(params[:id])\n status = p.update(name: params[:name], price: params[:price].to_f, category_id: params[:cat_id])\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end", "def update\n @product = Product.find(params[:id])\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @record = Product.find(params[:id])\n @record.update_attributes(params[:product])\n \n respond_to do |format|\n format.json {\n render json: {}\n }\n end\n end", "def update\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @supplier, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n @product.name_prefix = @product.name.first.upcase\n respond_to do |format|\n if @product.update_attributes(params[:product])\n\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.eager_loading.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully updated.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n updateProduct = Product.find_by_id(params[:id])\n updateProduct.update(products_params)\n if updateProduct != nil\n msg = { status: 200 , product: updateProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product,\n :notice=> 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json=> @product.errors,\n :status=> :unprocessable_entity }\n end\n end\n end", "def update\n @product.update(product_params)\n set_products\n end", "def update\n @product_owner = ProductOwner.find(params[:id])\n\n respond_to do |format|\n if @product_owner.update_attributes(params[:product_owner])\n format.html { redirect_to @product_owner, notice: 'Product owner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to edit_product_path(@product), notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: t(:product_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n respond_to do |format|\n @product.edit\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\t\trespond_to do |format|\n\t\t if @product.update_attributes(params[:product])\n\t\t\tif @product.photo.nil?\n\t\t\t\tphoto = Photo.find_by_product_id(@product.id)\n\t\t\t\t@product.update_attributes(:photo_id => photo.id) if !photo.nil?\n\t\t\tend\n\t\t\tformat.html { redirect_to @product, :notice => 'Успешно обновлено' }\n\t\t\tformat.json { head :no_content }\n\t\t else\n\t\t\tformat.html { render :action => \"edit\" }\n\t\t\tformat.json { render :json => @product.errors, :status => :unprocessable_entity }\n\t\t end\n\t\tend\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to products_path, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update!(product_params)\n format.html { redirect_to products_url, notice: 'Product was successfully updated.' }\n format.json { render json: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product_spec.update(product_spec_params)\n format.html { redirect_to @product_spec, notice: 'Product spec was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_spec }\n else\n format.html { render :edit }\n format.json { render json: @product_spec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n if @product.update_attributes(params[:product])\n respond_to do |format|\n format.html { redirect_to products_path, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end", "def update\n #Find product by productID\n @product = Product.find_by(productID: params[:id])\n \n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to products_path, notice: 'Product has been updated.' }\n format.json { render :index, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_product_info\n update_info = params[:product]\n market = Market.find(params[:place_id])\n product = market.products.find(update_info[:id])\n if product.update(update_info)\n response = {status: \"OK\", code: 200}\n else\n response = { status: \"Not Ok\", code: 201}\n end\n respond_to do |format|\n format.json{render json: response.to_json }\n end\n end", "def update\n if @product.update(product_params)\n render :show, status: :ok, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_product\n begin\n @api_v1_product = Product.find(params[:id])\n rescue => ex\n json_response({error: ex.message}, :not_found)\n end\n end", "def update\n @produto.update(produto_params)\n respond_with @produto\n end", "def update\n #@product = Product.find(params[:id]) #하단에서 미리 선언\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: '상품이 수정되었습니다.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unread\n\n @product = Product.find(params[:id])\n @sellers = Seller.all\n @branches = Branch.all\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to action: 'show', notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = Product.find(params[:id])\n if @product\n if @product.update(price: params[:price])\n render 'api/products/show'\n else\n render json: [\"Can only update price\"], status: 422\n end\n else\n render json: [\"Product not found\"], status: 422\n end\n end", "def update\n product_params = params.require(:product).\n permit(:id, :value)\n\n if product = Product.find_by(external_id: product_params[:id])\n product.value = product_params[:value]\n product.save\n render json: {}, status: :ok\n else\n\n render json: {\n errors: {\n message: \"product not found\",\n product_id: product_params[:id]\n }\n }, status: :unprocessable_entity\n end\n end", "def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Your product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def product_updates\n if params[\"product_id\"] == \"new\"\n @product = Product.new\n @product.florist_id = session[\"found_florist_id\"] \n else\n @product = Product.where(id: params[\"product_id\"]).first\n end\n @product.product_type= params[\"product_type\"]\n @product.name = params[\"product_name\"]\n if params[\"items_per_bunch\"] && params[\"items_per_bunch\"].to_f > 0\n @product.items_per_bunch = params[\"items_per_bunch\"].to_f * 100\n if params[\"cost_per_bunch\"] && params[\"cost_per_bunch\"].to_f > 0\n @product.cost_per_bunch = params[\"cost_per_bunch\"].to_f * 100.round(2)\n numerator = params[\"cost_per_bunch\"].to_f * 100.0.round(2)\n denominator = params[\"items_per_bunch\"].to_f * 100.0.round(2)\n \n @product.cost_for_one = (numerator / denominator).round(2)*100\n end\n end\n if params[\"markup\"] && params[\"markup\"].to_f >= 0 \n @product.markup = params[\"markup\"].to_f * 100\n end\n @product.status = params[\"status\"]\n if params[\"display_name\"] == \"\" || params[\"display_name\"] == nil\n @product.display_name = @product.name\n else\n @product.display_name = params[\"display_name\"]\n end\n @product.updated_by = Employee.where(id: session[\"found_user_id\"]).first.name\n @product.florist_id = session[\"found_florist_id\"]\n if @product.save\n redirect_to \"/product/#{@product.id}\" and return\n else\n render(:product_updates) and return\n end \n end", "def update\n respond_to do |format|\n if @product_owner.update(product_owner_params)\n format.html { redirect_to @product_owner, notice: 'Product owner was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_owner }\n else\n format.html { render :edit }\n format.json { render json: @product_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n if @producto.update_attributes(params[:producto])\n format.html { redirect_to @producto, notice: 'Producto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = @user.products.find(params[:id])\n # was @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to user_products_url(@user), notice: 'El producto fue creado exitosamente.' }\n # format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @product = current_user.user_info.products.find(params[:id])\n @product = Product.find(params[:id]) if current_user.user_info.admin \n respond_to do |format|\n if @product.update_attributes(params[:product])\n Shopify.modify @product\n format.html { redirect_to :action => 'index' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: \"Product was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6841503", "0.66668236", "0.6628461", "0.6572442", "0.6524781", "0.65049475", "0.6500295", "0.6495635", "0.6444946", "0.64427584", "0.6437838", "0.6423259", "0.6406662", "0.6405152", "0.63964087", "0.6387757", "0.637347", "0.6369127", "0.6369127", "0.63640547", "0.63625807", "0.63625115", "0.6351692", "0.6351554", "0.6351554", "0.63503176", "0.6348572", "0.6347275", "0.6347244", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63468844", "0.63384014", "0.63371146", "0.6331741", "0.63282263", "0.63246983", "0.630868", "0.62967944", "0.62924075", "0.62697214", "0.6267462", "0.6267462", "0.6267462", "0.6267462", "0.6267462", "0.62604064", "0.6248522", "0.62359804", "0.6215883", "0.62077266", "0.6193282", "0.6188437", "0.6185181", "0.61769223", "0.61768097", "0.6174617", "0.61737955", "0.61712277", "0.61688954", "0.6166213", "0.6164155", "0.61632943", "0.61577034", "0.6147928", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355", "0.61418355" ]
0.6493597
8
DELETE /productors/1 DELETE /productors/1.json
def destroy @productor.destroy respond_to do |format| format.html { redirect_to productors_url, notice: 'Productor was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @product = @person.products.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.json { render :json=>true }\n end\n end", "def destroy\n @onecompany_product = Onecompany::Product.find(params[:id])\n @onecompany_product.destroy\n\n respond_to do |format|\n format.html { redirect_to onecompany_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n product = Product.find(params[:id])\n product.destroy\n\n render json: { deleted: params[:id] }\n end", "def destroy\n p @product.destroy!\n render json: { result: 'deleted' }, status: :ok\n end", "def destroy\n @product.destroy\n render json: {}\n end", "def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end", "def destroy\n @productonegocio = Productonegocio.find(params[:id])\n @productonegocio.destroy\n\n respond_to do |format|\n format.html { redirect_to productonegocios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n\n render json: @product, status: :ok#, location: @collection\n end", "def destroy\n product = Product.find(params[:id])\n product.destroy\n render json: {id: product.id}\n end", "def destroy \n @product = current_user.user_info.products.find(params[:id])\n Shopify.delete @product\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product_owner = ProductOwner.find(params[:id])\n @product_owner.destroy\n\n respond_to do |format|\n format.html { redirect_to product_owners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @supplier = Supplier.find(params[:supplier_id])\n @product = @supplier.products.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to @supplier }\n format.json { head :no_content }\n end\n end", "def destroy\n @orden_product.destroy\n respond_to do |format|\n format.html { redirect_to orden_products_url, notice: 'Orden product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.delete!\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @produtor.destroy\n respond_to do |format|\n format.html { redirect_to produtors_url, notice: 'Produtor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to farmer_list_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n puts(\"you are in destroy \")\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\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 delete_product(id)\n @client.raw('delete', \"/ecommerce/products/#{id}\")\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\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 @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = @user.products.find(params[:id])\n #was @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to (user_products_path(@user)) }\n #was format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n begin\n @api_v1_product.destroy!\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete(options = nil)\n request = Request.new(@client)\n path = \"/products/\" + CGI.escape(@id) + \"\"\n data = {\n\n }\n\n response = Response.new(request.delete(path, data, options))\n return_values = Array.new\n \n return_values.push(response.success)\n\n \n return_values[0]\n end", "def destroy\n @product_name.destroy\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path) }\n format.json { head :no_content }\n end\n end", "def destroy\n @producto.destroy\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @produto = Produto.find(params[:id])\n @produto.destroy\n\n respond_to do |format|\n format.html { redirect_to produtos_url }\n format.json { head :ok }\n end\n end", "def deleteProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.find(params[:id])\n status = p.destroy\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: true, reason: error, data: \"\"}\n end", "def destroy\n @product = Product.find(params[:id])\n \n # Erase from product kits\n kits_products = KitsProduct.where(product_id: @product[:id])\n \n for product in kits_products\n product.destroy\n end\n \n company_id = @product[:company_id]\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/companies/products/\" + company_id.to_s) }\n format.xml { head :ok }\n end\n end", "def destroy\n unread\n\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\nend", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to admin_merchandise_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product1.destroy\n respond_to do |format|\n format.html { redirect_to product1s_url, notice: \"Product1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n #@product = Product.find(params[:id]) #하단에서 미리 선언\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @magento_product = MagentoProduct.find(params[:id])\n @magento_product.destroy\n\n respond_to do |format|\n format.html { redirect_to magento_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n authorize! :destroy, @product\n \n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id]).delete\n respond_to do |format|\n if @product.delete\n format.html {redirect_to @product, notice: \"Product was successfully deleted.\" }\n else\n format.json {render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @product.destroy\n\n head :no_content\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @os_product.destroy\n respond_to do |format|\n format.html { redirect_to os_products_url, notice: 'Os product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_product = TipoProduct.find(params[:id])\n @tipo_product.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product_owner.destroy\n respond_to do |format|\n format.html { redirect_to product_owners_url, notice: 'Product owner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n render json: {is_success: true, error_code: 200, message: \"Deleted Successfully\", result: @product}, status: 200\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @related_product = RelatedProduct.find(params[:id])\n @related_product.destroy\n\n respond_to do |format|\n format.html { redirect_to related_products_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prod = Prod.find(params[:id])\n @prod.destroy\n\n respond_to do |format|\n format.html { redirect_to prods_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def destroy\n @productos_por_cliente.destroy\n respond_to do |format|\n format.html { redirect_to productos_por_clientes_url, notice: 'Productos por cliente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reprodutor.destroy\n respond_to do |format|\n format.html { redirect_to reprodutores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: t('destroy_success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @e_commerce.destroy\n respond_to do |format|\n format.html { redirect_to e_commerces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @products_purposes_relation.destroy\n respond_to do |format|\n format.html { redirect_to products_purposes_relations_url, notice: t('destroy_success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @record = Product.find(params[:id])\n @record.trash\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to root_url(:item => 3), notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @groceryproduct.destroy\n respond_to do |format|\n format.html { redirect_to groceryproducts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_prod.destroy\n respond_to do |format|\n format.html { redirect_to recipe_prods_url, notice: 'Recipe prod was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7320538", "0.7290282", "0.72159845", "0.7169922", "0.71522564", "0.7148171", "0.71359265", "0.7120843", "0.6994942", "0.6965105", "0.6957253", "0.69516116", "0.69410175", "0.6939498", "0.69382334", "0.69382334", "0.69382334", "0.69269234", "0.68862873", "0.6878517", "0.6877487", "0.68755305", "0.6872554", "0.6869873", "0.6869873", "0.6869873", "0.6869873", "0.6869873", "0.6869873", "0.68688303", "0.6860188", "0.6860188", "0.6860188", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847747", "0.6847623", "0.68423206", "0.6834003", "0.68269354", "0.682563", "0.68194586", "0.6818465", "0.6802734", "0.67953813", "0.67923534", "0.67873716", "0.6781319", "0.6780901", "0.67761517", "0.67641073", "0.67581785", "0.6752882", "0.6751955", "0.6751143", "0.67456365", "0.6743389", "0.6743389", "0.67393523", "0.6734492", "0.67268836", "0.6726772", "0.6725723", "0.6724945", "0.6723216", "0.6722465", "0.67205375", "0.67167664", "0.67097336", "0.6708253", "0.6707371", "0.670588", "0.67022693", "0.668875", "0.6687838", "0.6685373" ]
0.7276151
2
Use callbacks to share common setup or constraints between actions.
def set_productor @productor = Productor.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def productor_params params.require(:productor).permit(:name, :country_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\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 allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\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 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 valid_params_request?; end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \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 whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_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 safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\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 user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; 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 quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "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 user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n 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 user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def url_whitelist; 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 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 admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def backend_user_params\n params.permit!\n end", "def url_params\n params[:url].permit(:full)\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.6981537", "0.67835593", "0.6748275", "0.67436063", "0.6736311", "0.65937173", "0.6503359", "0.6498499", "0.6482832", "0.6478776", "0.645703", "0.6439998", "0.63802195", "0.6377008", "0.6366287", "0.632018", "0.63016284", "0.63011277", "0.62932974", "0.62919617", "0.62905645", "0.6289235", "0.6283876", "0.62425834", "0.62410337", "0.6218672", "0.62151134", "0.62096137", "0.6192354", "0.6178057", "0.6177618", "0.61727077", "0.6162073", "0.6152049", "0.61515594", "0.61458135", "0.6122875", "0.61165285", "0.6107696", "0.6104097", "0.6091097", "0.6080201", "0.60699946", "0.6063739", "0.60206395", "0.60169303", "0.60134894", "0.601003", "0.6007347", "0.6007347", "0.6001054", "0.59997267", "0.5997844", "0.5991826", "0.5991213", "0.59911627", "0.5980111", "0.5967009", "0.59597385", "0.5958542", "0.595787", "0.5957425", "0.59522784", "0.5951228", "0.59423685", "0.5939385", "0.5939122", "0.5939122", "0.59325653", "0.5930178", "0.59248054", "0.59243476", "0.59164625", "0.59106", "0.59101933", "0.59084356", "0.5905666", "0.58975077", "0.58974737", "0.5895128", "0.58946574", "0.589308", "0.58916", "0.5885987", "0.58838505", "0.58792", "0.58723736", "0.58684355", "0.58677715", "0.5865701", "0.5865538", "0.5865288", "0.586385", "0.5862139", "0.58614355", "0.58593005", "0.5857459", "0.58541363", "0.58536613", "0.58520085", "0.585011" ]
0.0
-1
Constructor Allows us to build out the class properly
def initialize current_user @vrn = current_user.vrn @access = current_user.access_token @query = { "from": "2020-01-01", "to": "2021-01-01" } @headers = { # Authenication # Required to communicate with oAuth 'Accept': 'application/vnd.hmrc.1.0+json', 'Authorization': 'Bearer ' + @access, # Fraud headers # https://developer.service.hmrc.gov.uk/guides/fraud-prevention/connection-method/web-app-via-server/#gov-vendor-product-name 'Gov-Client-Connection-Method': 'WEB_APP_VIA_SERVER', 'Gov-Client-User-IDs': "vat-mtd=#{current_user.id}", 'Gov-Client-Timezone': "UTC#{Time.now.strftime("%:z")}", 'Gov-Vendor-Version': "vat-mtd=1.0.0" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def constructor; end", "def initialize\n \n end", "def initialize() end", "def initialize\r\n\r\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize(*_)\n super\n end", "def initialize\n\t\t\n\tend", "def initialize()\n end", "def initialize( * )\n super\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def construct\n end", "def initialize(*args)\n super\n end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def initialize\n end", "def initialize(*args)\n super\n end", "def initialize(*args)\n super\n end", "def initialize(*args)\n super\n end", "def initialize\n \n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize()\n # override parent\n end", "def initialize()\n\t\tend", "def initialize # rubocop:disable Lint/UselessMethodDefinition\n super()\n end", "def initialize # rubocop:disable Lint/UselessMethodDefinition\n super()\n end", "def initialize # rubocop:disable Lint/UselessMethodDefinition\n super()\n end", "def initialize(*args)\r\n super(*args)\r\n end", "def initialize()\r\n\r\n end", "def initialize()\n raise \"#{self.class.to_s} should not be instantiated directly.\"\n end", "def initialize\n \n end", "def initialize\n \n end", "def initialize\n super\n end", "def initialize\n super\n end", "def initialize\n init\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end" ]
[ "0.822296", "0.8161297", "0.77810293", "0.7763467", "0.7748298", "0.77391535", "0.77391535", "0.77391535", "0.77391535", "0.77391535", "0.77391535", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7676944", "0.7645184", "0.76279634", "0.76150906", "0.7567652", "0.7567652", "0.7567652", "0.7567652", "0.7567652", "0.7567652", "0.7567652", "0.7567652", "0.7567652", "0.7537803", "0.7537803", "0.7537803", "0.7537803", "0.7537803", "0.74974763", "0.74974763", "0.74974763", "0.74974763", "0.74974763", "0.74974763", "0.74974763", "0.74966085", "0.74908954", "0.74597883", "0.74597883", "0.74377525", "0.7412457", "0.7412457", "0.7412457", "0.74099296", "0.74070466", "0.74070466", "0.74070466", "0.74028915", "0.73981893", "0.7397351", "0.7397351", "0.7397351", "0.7388666", "0.73737705", "0.73631454", "0.7334034", "0.7334034", "0.7327482", "0.7327482", "0.72876155", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005", "0.72726005" ]
0.0
-1
Obligations This pulls down the submitted returns and gives us a periodKey (which we use to pull individual returns) The aim is to store all returns in a single table
def obligations self.class.get(url, { headers: @headers, query: @query }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def investment_return_from_ownership\n @initial_costs = {}\n @recuring_costs = {}\n @closing_costs = {}\n @home_appreciation = {}\n @costs_compare_sum = {}\n\n @rent_security_deposit = (@home_price/(12*@price_to_rent_ratio))*-1\n @costs_of_buying_house = {}\n @costs_of_buying_house[:rent] = (@home_price/(12*@price_to_rent_ratio)*0.25)*-1\n @costs_of_buying_house[:buy] = (@home_price*0.02467)*-1\n\n @initial_costs[:rent] = (@home_price/(12*@price_to_rent_ratio))*-1 + (@home_price/(12*@price_to_rent_ratio)*0.25)*-1\n @initial_costs[:buy] = @down_payment*-1 + (@home_price*0.02467)*-1\n\n @recuring_costs[:rent] = (@home_price/@price_to_rent_ratio*@mortgage_term*(1+0.025)**@mortgage_term+@home_price/@price_to_rent_ratio*@mortgage_term*0.0132)*-1\n @recuring_costs[:buy] =\n ((@monthly_exp_breakdown[:mortgage_principal][:total] + @monthly_exp_breakdown[:mortgage_interest][:total])*-1) + (@monthly_exp_breakdown[:property_tax][:total]*-1) + (@monthly_exp_breakdown[:home_insurance][:total]*-1) + (@monthly_exp_breakdown[:pmi_insurance][:total]*-1) + ((((1+0.054/12)**@number_of_payments-1)*@down_payment)*-1)\n\n @total_monthly_rents = (@home_price/@price_to_rent_ratio*@mortgage_term*(1+0.025)**@mortgage_term)\n @mortgage_payments = (@monthly_exp_breakdown[:mortgage_principal][:total] + @monthly_exp_breakdown[:mortgage_interest][:total])*-1\n @renter_insurance = (@home_price/@price_to_rent_ratio*@mortgage_term*0.0132)*-1\n @returns_for_investment = ((((1+0.054/12)**@number_of_payments-1)*@down_payment)*-1)\n\n @closing_costs[:rent] = 0.0\n @closing_costs[:buy] = (@home_price*0.03)*-1\n\n @home_appreciation[:rent] = @initial_costs[:rent]*-1\n @home_appreciation[:buy] = @home_price*(1.054)**@mortgage_term*0.85\n\n @costs_compare_sum[:rent] =(@initial_costs[:rent] + @recuring_costs[:rent] + @closing_costs[:rent] + @home_appreciation[:rent])\n @costs_compare_sum[:buy] = @initial_costs[:buy] + @recuring_costs[:buy] + @closing_costs[:buy] + @home_appreciation[:buy]\n\n if (@calculate_loan_payment<=750000)\n @mortgage_interest_deduction = (@calculate_monthly_payment*@number_of_payments-@calculate_loan_payment)/@mortgage_term\n else\n @mortgage_interest_deduction = ((@calculate_monthly_payment*@number_of_payments-@calculate_loan_payment)/@mortgage_term)*750000/@calculate_loan_payment\n end\n\n if (@costs_compare_sum[:buy].abs <=0)\n @costs_compare_sum[:benifit] = \"Buying is better than renting even if you could rent for free! In addition, you can save average #{ ActionController::Base.helpers.number_to_currency(@mortgage_interest_deduction.round(2)) } per year from your federal taxable income. Increase your profit by visiting our <a href='JavaScript:void(0);'>mortgage rates</a> and getting a more favorable mortgages.\"\n else\n if (@costs_compare_sum[:buy].abs >0 && @costs_compare_sum[:rent].abs > @costs_compare_sum[:buy].abs)\n @costs_compare_sum[:benifit] = \"Buying is cheaper than renting! You’ll earn an extra #{ActionController::Base.helpers.number_to_currency(((@costs_compare_sum[:buy] - @costs_compare_sum[:rent]).round(2)))} after #{@mortgage_term} years of buying a house. In addition, you can save average #{ActionController::Base.helpers.number_to_currency(@mortgage_interest_deduction.round(2))} per year from your federal taxable income. If you lower your mortgage interest rate, you could save more! Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> and find other favorable mortgages.\"\n else\n if (@costs_compare_sum[:buy].abs >0 && @costs_compare_sum[:rent].abs == @costs_compare_sum[:buy].abs )\n @costs_compare_sum[:benifit] = \"The cost of buying a house is about the same as renting a house for #{@mortgage_term} years! However, you could save more through lowering your mortgage interest rate. Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> to get more favorable mortgages.\"\n else\n @costs_compare_sum[:benifit] = \"You'd better to rent a house instead pf buying. Or you could lower your mortgage interest rate to save the cost of buying. Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> to get more favorable mortgages.\"\n end\n end\n end\n end", "def returns(periodKey)\n self.class.get(url(\"returns\", periodKey), headers: @headers )\n end", "def book_sales(period='enddate', basis, exclude)\n royalty_period = Period.where([\"currentperiod = ? and client_id = ?\", true, self.client_id])\n if period == 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, royalty_period.first.startdate, basis, exclude)\n else #if period isn't 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, \"1900-01-01\", basis, exclude)\n end\n end", "def returns(periodKey)\n self.class.get(url(\"liabilities\"), headers: @headers, query: @query )\n end", "def index\n @pay_periods = PayPeriod.all\n end", "def index\n @pay_periods = PayPeriod.all\n end", "def index\n @leave_applies = LeaveApply.all\n end", "def index\n @withdrawal_requests = WithdrawalRequest.all\n end", "def index\n #@spend_entries = SpendEntry.all\n end", "def book_royalty(period='enddate', basis=\"Net receipts\")\n royarray = []\n sales = self.book_sales(period, basis, false) # this calls the royalty calculation for net receipts\n sales.each do |sale|\n royarray << sale.royalty_by_band.inject(0) { |sum, i| sum + i.to_f unless i.nan? || i.nil? }\n end\n book_royalty = royarray.inject(0) { |sum, i| sum +i.to_f }\n end", "def index\n @receipt_periods = ReceiptPeriod.all\n end", "def gr_calcul_alloc(start_period, end_period, granularity, attribut, category_operation)\r\n\t\t\t\tentry_datas = []\r\n\t\t\t\tleave_table = []\r\n\r\n\t\t\t\tif attribut == 0 #project allocation\r\n\t\t\t\t\talloc_table = self.wl_table_allocation\t\r\n\t\t\t\telsif attribut == 5 #real_allocation\r\n\t\t\t\t\talloc_table = self.wl_table_allocation\t\r\n\t\t\t\t\tleave_project_id = RedmineLeavesHolidays::Setting.defaults_settings(:default_project_id)\r\n\t\t\t\t\tleave_table = self.user.get_logged_time(Project.find(leave_project_id), start_period, end_period)\r\n\t\t\t\telse# 1: total_allocation or 2: remaining allocation\r\n\t\t\t\t\talloc_table = self.wl_global_table_allocation\t\r\n\t\t\t\tend\r\n\r\n\t\t\t\tperiod = start_period..end_period\r\n\t\t\t\tcurrent_day = start_period\r\n\r\n\t\t\t\twhile current_day <= end_period\r\n\t\t\t\t\tdata_result = 0\r\n\t\t\t\t\tcase granularity #integer\r\n\t\t\t\t\twhen 1 # weekly\r\n\t\t\t\t\t\tend_recc_date = current_day.end_of_week\r\n\t\t\t\t\t\tend_recc_date = end_period if end_recc_date > end_period\r\n\r\n\t\t\t\t\t\tdata_result= self.average_for_period(alloc_table, leave_table, current_day, end_recc_date, attribut, category_operation)\t\r\n\t\t\t\t\t\tcurrent_day = end_recc_date+1 \r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\twhen 2 # monthly\r\n\t\t\t\t\t\tend_recc_date = current_day.end_of_month\r\n\t\t\t\t\t\tend_recc_date = end_period if end_recc_date > end_period\r\n\t\t\t\t\t\tdata_result= self.average_for_period(alloc_table, leave_table, current_day, end_recc_date, attribut, category_operation)\r\n\t\t\t\t\t\tcurrent_day = end_recc_date+1 \r\n\t\t\t\t\twhen 3 # quarterly\r\n\t\t\t\t\t\tend_recc_date = current_day.end_of_quarter\r\n\t\t\t\t\t\tend_recc_date = end_period if end_recc_date > end_period\r\n\t\t\t\t\t\tdata_result= self.average_for_period(alloc_table, leave_table, current_day, end_recc_date, attribut, category_operation)\r\n\t\t\t\t\t\tcurrent_day = end_recc_date+1 \r\n\t\t\t\t\twhen 4 # yearly\r\n\t\t\t\t\t\tend_recc_date = current_day.end_of_year\r\n\t\t\t\t\t\tend_recc_date = end_period if end_recc_date > end_period\r\n\t\t\t\t\t\tdata_result= self.average_for_period(alloc_table, leave_table, current_day, end_recc_date, attribut, category_operation)\r\n\t\t\t\t\t\tcurrent_day = end_recc_date+1 \r\n\t\t\t\t\telse #when 0 - daily\r\n\t\t\t\t\t\tcategory_operation = 0 # no need to do a average\r\n\t\t\t\t\t\tdata_result= self.average_for_period(alloc_table, leave_table, current_day, current_day, attribut, category_operation)\r\n\t\t\t\t\t\tcurrent_day = current_day+1\r\n\t\t\t\t\tend\r\n\t\t\t\t\tentry_datas << data_result\t\r\n\t\t\t\tend\r\n\r\n\t\t\t\treturn entry_datas\r\n\t\t\tend", "def index\n set_trading_account_budget_records_grid\n end", "def actions(rental)\n tot_com = price(rental) * 30 / 100\n start_date = DateTime.parse(rental[\"start_date\"])\n end_date = DateTime.parse(rental[\"end_date\"])\n duration = (end_date - start_date).to_i + 1\n insurance_fee = tot_com / 2 .to_i\n assistance_fee = duration * 100\n drivy_fee = tot_com - insurance_fee - assistance_fee\n\n debit_driver = {\"who\": \"driver\", \"type\": \"debit\", \"amount\": price(rental)}\n credit_owner = {\"who\": \"owner\", \"type\": \"credit\", \"amount\": (price(rental) - tot_com)}\n credit_insurance = {\"who\": \"insurance\", \"type\": \"credit\", \"amount\": insurance_fee}\n credit_assistance = {\"who\": \"assistance\", \"type\": \"credit\", \"amount\": assistance_fee}\n credit_drivy = {\"who\": \"drivy\", \"type\": \"credit\", \"amount\": drivy_fee}\n\n actions = [debit_driver, credit_owner, credit_insurance, credit_assistance, credit_drivy]\nend", "def payment_predictions\n @results = Project.payment_prediction_results(@account, params, @start_date, @end_date)\n @totals = Project.payment_prediction_totals(@account, params, @start_date, @end_date)\n end", "def index\n @financial_reports = @company.financial_reports.annual.recent.include_statements\n end", "def payment_data(period_data = 'this_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title] + UserGroup::PAYMENT_GOALS.values]\n range.each do |d| \n r = [d.beginning_of_day, (daily_report ? d.end_of_day : d.end_of_month.end_of_day)]\n d = [d.strftime(daily_report ? '%d' : '%Y-%m')]\n UserGroup::PAYMENT_GOALS.each{|k, v| d << res.where(payment_at: r[0]..r[1], goal: k).sum(:amount).to_f }\n data << d\n end\n data\n end", "def patentList\n \t# alice\n @assignee_name = JSON.parse(params[:assigneeName]).to_a\n @start_year = params[:beginTime].to_i\n @end_year = params[:endTime].to_i\n\n queryLike = \"WHERE `Assignee` LIKE '%\" + @assignee_name[0] + \"%'\"\n if(@assignee_name.count > 1)\n (1..@assignee_name.count-1).each do |i|\n queryLike = queryLike + \" OR `Assignee` LIKE '%\" + @assignee_name[i] + \"%' \"\n end\n end\n\n @patent = Array.new\n (@start_year..@end_year).each{ |i|\n @patent[i] = @db.query(\"SELECT `Patent_id`, `Title`, `Issued_date`, GROUP_CONCAT(Name) AS `Name` \n FROM `assignee_\" + i.to_s + \"`\n LEFT JOIN `patent_\" + i.to_s + \"`\n USING ( Patent_id ) \n LEFT JOIN `inventor_\" + i.to_s + \"`\n USING ( Patent_id ) \n \"+ queryLike +\"\n GROUP BY Patent_id\")\n }\n end", "def payments_report(period_data = 'last_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, 'Tithe', 'Pledge', 'Partner', 'Donation', 'Offertory', 'Payment']]\n range.each do |d| \n r = d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)\n data << [d.strftime(daily_report ? '%d' : '%Y-%m'), \n res.where(payment_at: r, goal: 'tithe').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'pledge').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'partner').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'donation').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'offertory').sum(:amount).to_f,\n res.where(payment_at: r, goal: nil).sum(:amount).to_f\n ]\n end\n data\n end", "def get_earnings\n get_historic_eps(1)\n end", "def index\n @payments = Payment.all\n \n @unit = current_user.unit\n \n @utility = UtilityCharge.all\n \n @utility_charge = current_user.unit.present? ? current_user.unit.latest_utility_charge : 0\n \n #Find the next month due from the paid_rents Table\n @paid_rent = PaidRent.all\n last_unpaid_rent_for_unit = PaidRent.where(paid: false, unit_id: @unit).first\n @current_due_date = last_unpaid_rent_for_unit.present? ? last_unpaid_rent_for_unit.date_due : nil\n \n #determine if security deposit has been paid and assign it a variable for use in the view \n @security_amount = current_user.unit.present? ? @unit.security_charge : 0\n \n end", "def index\n @benefit_requesteds = BenefitRequested.all\n end", "def ind_estud\n #@periodos = Periodo.find(:all)\n end", "def find_observations(security)\n security.corporate_actions.to_a\n end", "def index\n @warranties = Warranty.all\n\n end", "def investor\n end", "def income_list\n end", "def index\n @auto_bill_payments = @origin_acct.auto_bill_payments.sort {|a,b| a.dateToPay <=> b.dateToPay}\n end", "def reshare_lending_summary(model, institution, fiscal_year)\n\n # Get the prefix of the table for the reshare model\n prefix = table_name_prefix(model::Reshare)\n\n # Get the rollup of lending attempts\n model::Reshare::Transaction.connection.select_all(\n \"SELECT\n COALESCE(\n #{prefix}transactions.borrower, 'All Institutions'\n ) AS borrower,\n COUNT(DISTINCT #{prefix}transactions.request_id) AS total_requests,\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status = 'RES_COMPLETE'\n ) AS complete,\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status = 'RES_UNFILLED'\n ) as unfilled,\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status = 'RES_CANCELLED'\n ) AS cancelled,\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status NOT IN (\n 'RES_UNFILLED', 'RES_COMPLETE', 'RES_CANCELLED'\n )\n ) AS pending,\n ROUND(\n CAST(\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status = 'RES_COMPLETE'\n ) AS DECIMAL\n ) / NULLIF(\n CAST(\n COUNT(DISTINCT #{prefix}transactions.request_id) FILTER (\n WHERE #{prefix}transactions.lender_status IN (\n 'RES_COMPLETE', 'RES_UNFILLED', 'RES_CANCELLED'\n )\n ) AS DECIMAL\n ), 0\n ), 2\n ) AS fill_rate,\n ROUND(AVG(#{prefix}lending_turnarounds.time_to_fill) FILTER (\n WHERE #{prefix}transactions.lender_status != 'RES_UNFILLED'\n ), 2) AS average_time_to_fill,\n ROUND(AVG(#{prefix}lending_turnarounds.time_to_ship) FILTER (\n WHERE #{prefix}transactions.lender_status != 'RES_UNFILLED'\n ), 2) AS average_time_to_ship,\n ROUND(AVG(#{prefix}lending_turnarounds.time_to_receipt) FILTER (\n WHERE #{prefix}transactions.lender_status != 'RES_UNFILLED'\n ), 2) AS average_time_to_receipt,\n ROUND(AVG(#{prefix}lending_turnarounds.total_time) FILTER (\n WHERE #{prefix}transactions.lender_status != 'RES_UNFILLED'\n ), 2) AS average_turnaround\n FROM #{prefix}transactions\n LEFT JOIN #{prefix}lending_turnarounds\n ON #{prefix}lending_turnarounds.request_id = #{prefix}transactions.lender_id\n WHERE #{prefix}transactions.lender = '#{institution}'\n AND #{prefix}transactions.date_created\n BETWEEN '#{fiscal_year-1}-07-01' AND '#{fiscal_year}-06-30'\n GROUP BY ROLLUP (borrower)\n ORDER BY borrower NULLS FIRST;\"\n ).rows\n end", "def calculate_and_build_metlife_premium_tables\n (20..65).each do |metlife_age|\n @metlife_age = metlife_age\n key = \"#{@rate[:plan_id]},#{@rate[:effective_date].to_date.year}\"\n rating_area = @rate[:rate_area_id]\n @results[key] << {\n age: metlife_age,\n start_on: @rate[:effective_date],\n end_on: @rate[:expiration_date],\n cost: calculate_metlife_cost,\n rating_area: rating_area\n }\n end\n end", "def find_expirations\n expired_embargoes = []\n expiration_date = solrize_date(@date)\n\n @work_types.each do |work_type|\n expired_works = work_type.where(\"embargo_release_date_dtsi:[* TO #{RSolr.solr_escape(expiration_date)}]\")\n expired_embargoes << expired_works\n end\n\n expired_embargoes.flatten\n end", "def index\n @party_approvals = PartyApproval.all\n end", "def create_predicted_invoice\r\n invoice_selected = params[:invoice][\"invoice_selected\"]\r\n @imported_invoice = ImportedInvoice.find(invoice_selected)\r\n @predictable_billing_periods = @imported_invoice.retail_plan.predictable_billing_periods\r\n @predictable_billing_periods.each do |predictable_billing_period|\r\n if predictable_billing_period.to_s == params[:invoice][\"selected_date_period\"].to_s\r\n @date_period_selected = predictable_billing_period\r\n break\r\n end\r\n end\r\n\r\n if !invoice_selected.blank? && !@date_period_selected.blank?\r\n #Based on the selection of imported invoice from the user\r\n attributes = Marshal.load( Marshal.dump(@imported_invoice.attributes))\r\n attributes[\"start_date\"] = @date_period_selected[:start_date]\r\n attributes[\"end_date\"] = @date_period_selected[:end_date]\r\n @invoice = PredictedInvoice.new(attributes.except!(\"file\"))\r\n if @invoice.save\r\n respond_to do |format|\r\n format.html { render :show, notice: 'PredictedInvoice was successfully generated.' }\r\n format.json { render :show, status: :created, location: @invoice }\r\n return\r\n end\r\n else\r\n respond_to do |format|\r\n format.html { render :generateNew }\r\n format.json { render json: @invoice.errors, status: :unprocessable_entity }\r\n return\r\n end\r\n end\r\n else\r\n flash[:error] = \"Some Fields Are Missing, Please Fill in All Required Items!\"\r\n redirect_to predictNew_invoices_path\r\n end\r\n end", "def new_bill_params\n new_params = bill_params\n \n for x in (1..5) do\n #eval('new_params[:paid_date] = params[:bill][\"paid_date(#{x}i)\"].to_i ')\n eval('new_params.delete(\"paid_date(#{x}i)\")')\n end\n\n for x in (1..5) do\n #eval('new_params[:maturity_date] = params[:bill][\"maturity_date(#{x}i)\"].to_i ')\n eval('new_params.delete(\"maturity_date(#{x}i)\")')\n end\n \n new_params[:paid_date] = DateTime.new(params[:bill][\"paid_date(1i)\"].to_i, \n params[:bill][\"paid_date(2i)\"].to_i, \n params[:bill][\"paid_date(3i)\"].to_i, \n params[:bill][\"paid_date(4i)\"].to_i, \n params[:bill][\"paid_date(5i)\"].to_i)\n\n new_params[:maturity_date] = DateTime.new(params[:bill][\"maturity_date(1i)\"].to_i, \n params[:bill][\"maturity_date(2i)\"].to_i, \n params[:bill][\"maturity_date(3i)\"].to_i, \n params[:bill][\"maturity_date(4i)\"].to_i, \n params[:bill][\"maturity_date(5i)\"].to_i)\n\n new_params\n end", "def end_of_month_bill\n\t\tcalculate_interest(30) ### 30 should be replaced by days since last transaction\n\t\t@balance + @interest.reduce(:+)\n\tend", "def fetch_transactions_for(account, start_date: Date.today - 1.month, end_date: Date.today)\n from_date = start_date.strftime('%Y-%m-%d')\n\n custom_headers = {\n 'Content-Type' => 'application/json; charset=UTF-8',\n 'Contexto' => get_context\n }\n\n params = {\n \"peticionMovimientosKYOS\" => {\n \"numAsunto\" => account.iban,\n \"bancoAsunto\" => \"BANCO BILBAO VIZCAYA ARGENTARIA S.A\",\n \"fechaDesde\" => start_date.strftime(\"%Y%m%d\"),\n \"fechaHasta\" => end_date.strftime(\"%Y%m%d\"),\n \"concepto\" => [],\n \"importe_Desde\" => \"\",\n \"importe_Hasta\" => \"\",\n \"divisa\" => \"EUR\",\n \"paginacionTLSMT017\" => \"N000000000000+0000000000000000000\",\n \"paginacionTLSMT016\" => \"N00000000000+0000000000000000\",\n \"descargaInformes\" => false,\n \"numElem\" => 0,\n \"banco\" => \"1\",\n \"idioma\" => \"51\",\n \"formatoFecha\" => \"dd\\/MM\\/yyyy\",\n \"paginacionMOVDIA\" => \"1\",\n \"ultimaFechaPaginacionAnterior\" => \"\",\n \"ordenacion\" => \"DESC\"\n }\n }\n\n url = BASE_ENDPOINT + TRANSACTIONS_ENDPOINT\n\n transactions = []\n with_headers(custom_headers) do\n # Loop over pagination\n loop do\n json = JSON.parse(post(url, fields: params.to_json))['respuestamovimientos']\n\n if json['movimientos'].is_a?(Array)\n unless json['movimientos'].blank?\n transactions += json['movimientos'].map do |data|\n build_transaction(data, account)\n end\n \n params['peticionMovimientosKYOS']['paginacionMOVDIA'] = json['paginacionMOVDIA']\n params['peticionMovimientosKYOS']['paginacionTLSMT016'] = json['paginacionTLSMT016']\n params['peticionMovimientosKYOS']['paginacionTLSMT017'] = json['paginacionTLSMT017']\n end\n break unless (json['descripcion'] == 'More records available')\n elsif json['movimientos'].is_a?(Hash)\n # There was only 1 transaction for this query\n transactions << build_transaction(json['movimientos'], account)\n break\n else\n # No transactions\n break\n end\n end\n end\n\n transactions\n end", "def pay_all_bills\n #self.appointments.update_all(cost: 0)\n self.appointments.each {|a| a.paid}\n end", "def build_stock_return_data\n open_values = []\n close_values = []\n\n @values.dig(:values).map do |_codes, _date, open, _high, _low, close|\n open_values.push [open]\n close_values.push [close]\n end\n\n @open = calculate_average(open_values)\n @close = calculate_average(close_values)\n @stock_return = stock_return_formula\n end", "def index\n @appreciations = Appreciation.all\n end", "def company_onethings(start_date,period,interval)\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_all_company'])\n\t\t url_params = {\"period\" => period, \"start_date\" => start_date, \"interval\" => interval}\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 index\n @fund_company_investments = FundCompanyInvestment.all\n end", "def resultat_sectorise\n period.resultat(@account.sector_id)\n end", "def index\n d = Date.today\n @expenses = @household.expenses.monthly_statement(d.month, d.year).order(spent_at: :desc)\n end", "def get_recent_financial_info(start_date, end_date)\n recent_payments[Payment::PAYMENT_TYPE_MEMBER.to_sym] = Payment.member_fee.updated_in_date_range(start_date, end_date) # Payment.member_fee.where(status: 'betald', updated_at: start_date..end_date)\n recent_payments[Payment::PAYMENT_TYPE_BRANDING.to_sym] = Payment.branding_fee.updated_in_date_range(start_date, end_date) # where(status: 'betald', updated_at: start_date..end_date)\n\n recent_payments # return this to make testing easier\n end", "def get_payment_info_by_bibs_ledger(bib_ids, ledger, conn)\n results = {}\n bib_ids.each_slice(1000) do |segment|\n query = payment_info_by_bibs(segment, ledger)\n conn.exec(query, *segment) do |row|\n hash = {}\n bib_id = row[0]\n hash[:invoice_id] = row[1]\n hash[:vendor_code] = row[2]\n hash[:invoice_num] = row[3]\n hash[:voucher_num] = row[4]\n hash[:invoice_status] = row[5]\n hash[:status_date] = row[6]\n hash[:invoice_date] = row[7]\n hash[:conversion_rate] = row[8]\n hash[:reporting_fund] = row[9]\n hash[:allocated_fund] = row[10]\n hash[:invoice_line_amount] = row[11]\n hash[:percentage] = row[12]\n cost_share = hash[:invoice_line_amount] * (hash[:percentage] / 100_000_000.0)\n converted_cost_share = convert_currency(hash[:conversion_rate], cost_share)\n converted_total = convert_currency(hash[:conversion_rate], hash[:invoice_line_amount])\n hash[:converted_inv_line_amount] = converted_total\n hash[:converted_cost_share] = converted_cost_share\n hash[:account_number] = row[13]\n hash[:ledger] = row[14]\n results[bib_id] = [] unless results[bib_id]\n results[bib_id] << hash\n end\n end\n results\nend", "def group_matter_accounting_rpt(tcol,ecol)\r\n conditions,data,total_data,total_expenses,matter_name = {},[],{},{},nil\r\n lookup_activities = current_company.company_activity_types\r\n activities = ReportsHelper.get_lookups(lookup_activities)\r\n lookup_activities = Physical::Timeandexpenses::ExpenseType.find(:all)\r\n exp_activities = ReportsHelper.get_lookups(lookup_activities)\r\n tcol.group_by(&:matter_id).each_value do|col|\r\n key,contact = nil,nil\r\n duration,billamount,discount,override,markup,finalamount = 0.00,0.00,0.00,0.00,0.00,0.00\r\n col.each do |obj|\r\n @dur_setng_is_one100th ? actual_duration = one_hundredth_timediffernce(obj.actual_duration) : actual_duration = one_tenth_timediffernce(obj.actual_duration)\r\n next unless obj.matter\r\n key = obj.matter.clipped_name unless key\r\n matter_name = obj.matter.name unless matter_name\r\n contact = (obj.matter.contact ? obj.matter.contact.name : nil) unless contact\r\n duration += actual_duration.to_f if actual_duration\r\n billamount = billamount + (obj.actual_activity_rate * actual_duration.to_f)\r\n discount += obj.billing_percent if obj.billing_percent\r\n override += obj.final_billed_amount if obj.billing_method_type == 3\r\n finalamount += obj.final_billed_amount if obj.final_billed_amount \r\n data << [obj.time_entry_date.to_s,obj.performer.try(:full_name).try(:titleize),rounding(actual_duration.to_f),activities[obj.activity_type],obj.is_billable ? \"Yes\" : \"No\",rounding(obj.actual_activity_rate),rounding(obj.actual_activity_rate * actual_duration.to_f),rounding(obj.billing_percent),obj.billing_method_type == 3 ? rounding(obj.final_billed_amount) : '',rounding(obj.final_billed_amount)]\r\n end\r\n next unless key\r\n \r\n total_data[key] = data\r\n conditions[key] = [contact,rounding(duration),rounding(billamount),rounding(discount),rounding(override),rounding(finalamount),matter_name]\r\n data = []\r\n end\r\n\r\n ecol.group_by(&:matter_id).each_value do|col| \r\n key,contact = nil,nil\r\n override,finalamount,markupamt,bill_amount,disc_sum = 0.00,0.00,0.00,0.00,0.00\r\n col.each do |obj|\r\n next unless obj.matter\r\n bill_amount += obj.expense_amount if obj.expense_amount\r\n disc_sum += obj.billing_percent if obj.billing_percent\r\n override += obj.final_expense_amount if obj.billing_method_type == 3\r\n markupamt += obj.markup if obj.markup\r\n finalamount += obj.final_expense_amount if obj.final_expense_amount\r\n key = obj.matter.clipped_name unless key\r\n contact = (obj.matter.contact ? obj.matter.contact.name : nil) unless contact\r\n data << [obj.expense_entry_date.to_s,obj.performer.try(:full_name).try(:titleize),exp_activities[obj.expense_type],obj.is_billable ? \"Yes\" : \"No\",rounding(obj.expense_amount),rounding(obj.billing_percent),obj.billing_method_type == 3 ? rounding(obj.final_expense_amount) : '',markupamt,rounding(obj.final_expense_amount)]\r\n end\r\n next unless key\r\n \r\n total_expenses[key] = [data,rounding(override),rounding(finalamount),rounding(bill_amount),rounding(disc_sum),rounding(markupamt)]\r\n unless conditions.has_key?(key)\r\n conditions[key] = [contact]\r\n end\r\n data = []\r\n end\r\n [total_data,total_expenses,conditions]\r\n \r\n end", "def due\n @invoices = @account_invoices.where(invoices: { due_on_date: @start_date...@end_date })\n end", "def sample_data(investment)\n {\n buy_bank_rate: create(:bank_rate, \n base_currency: investment.base_currency,\n to_currency: investment.buy_currency),\n sell_bank_rate: create(:bank_rate, \n base_currency: investment.buy_currency,\n to_currency: investment.base_currency),\n hourly_rate: create(:hourly_rate,\n currency: investment.buy_currency,\n price: investment.buy_price,\n datetime: DateTime.now - 2.hour)\n }\n end", "def eob_open_claims(claims)\n str = \"<div class='claim_table'><h2>Open Claims:</h2>\"\n str += \"<table><tr><th></th><th>DOS</th><th>Patient</th><th>Provider</th><th>Group</th><th>Payor</th></tr>\"\n \n claims.each do |claim|\n str += \"<tr><td><input id='eob_insurance_billing_id_5' name='eob[insurance_billing_id]' type='radio' value='5' /></td>\" \n str += \"<td>#{claim.dos.strftime('%m/%d/%Y')}</td>\"\n str += \"<td>#{claim.patient.patient_name}</td>\"\n str += \"<td>#{claim.Provider.Provider_name}</td>\"\n str += \"<td>#{claim.group.group_name if claim.group}</td>\"\n str += \"<td>#{claim.insurance_company.name}</td></tr>\" \n end\n\n str += \"</table><div class='button'><input class='submit' name='commit' type='submit' value='Update Eob' /></div></div>\"\n return str.html_safe\n end", "def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end", "def index\n @inproceedings = Inproceedings.all\n end", "def eob_claim_sidebar(claim)\n str = \"<b>Submitted Claim:</b><br />\"\n str += \"<table>\"\n str += \"<tr><td>Claim Number:</td><td>#{claim.claim_number}</td></tr>\"\n str += \"<tr><th>Copay:</th><td>#{number_to_currency(claim.insurance_session.copay_amount)}</td></tr>\"\n str += \"<tr><th>Lab Charges:</th><td>$</td></tr>\"\n str += \"<tr><td>---------</td></tr>\"\n str += \"<tr><td>CPT</td><td>Charge</td></tr>\" \n claim.iprocedures.each do |procedure|\n str += \"<tr><td>#{procedure.cpt_code}</td><td>#{number_to_currency(procedure.total_charge)}</td></tr>\"\n end\n str += \"<tr><th>Sub Total:</th><td>#{number_to_currency(claim.insurance_billed)}</td></tr>\"\n str += \"<tr><td>---------</td></tr>\"\n if !claim.insurance_session.ins_allowed_amount.blank? && claim.insurance_session.ins_allowed_amount > 0 \n str += \"<tr><th>Allowed Amt:</th><td>#{number_to_currency(claim.insurance_session.ins_allowed_amount)}</td></tr>\"\n else\n str += \"<tr><th>Charges:</th><td>#{number_to_currency(claim.insurance_session.charges_for_service)}</td></tr>\"\n end\n str += \"<tr><th>Ins Paid:</th><td>#{number_to_currency(claim.insurance_session.ins_paid_amount)}</td></tr>\"\n str += \"<tr><th>Bal Bill Paid:</th><td>#{number_to_currency(claim.insurance_session.bal_bill_paid_amount.blank? ? 0 : claim.insurance_session.bal_bill_paid_amount)}</td></tr>\"\n str += \"<tr><th>Waived Fee:</th><td>#{number_to_currency(claim.insurance_session.waived_fee.blank? ? 0 : claim.insurance_session.waived_fee)}</td></tr>\"\n str += \"<tr><th>Balance Due:</th><td>#{number_to_currency(claim.insurance_session.balance_owed)}</td></tr>\"\n str += \"</table>\"\n return str.html_safe\n end", "def index\r\n @account_plans = AccountPlan.all\r\n @accounting_years=AccountingYear.all\r\n end", "def index\n @market_offerings = policy_scope(MarketOffering)\n end", "def ind_distr\n @periodos = Periodo.find(:all)\n end", "def group_matter_time_spent(col)\n total_data,table_headers,conditions,data = {},{},{},[]\n if params[:report][:summarize_by] == \"lead_lawyer\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:employee_user_id).each do |label,matters|\n \n key = nil\n matters.each do|matter|\n key = matter.get_lawyer_name unless key\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n actual_duration = @dur_setng_is_one100th ? one_hundredth_timediffernce(e.actual_duration) : one_tenth_timediffernce(e.actual_duration)\n bill_hours += actual_duration\n end\n \n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.contact ? matter.contact.name : \"\",matter.contact ? matter.contact.accounts[0] ? matter.contact.accounts[0].name : \"\" : \"\",matter.matter_no,matter.matter_category,matter.matter_status ? matter.matter_status.alvalue : \"\",rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n \n conditions[key] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[key] = data\n sum_hrs(conditions,key)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n \n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:label_client),t(:label_Account),t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"#{t(:text_projected)} #{t(:text_hour)}\"]\n elsif params[:report][:summarize_by] == \"client\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:contact_id).each do |label,matters|\n key = nil\n matters.each do|matter|\n key = matter.contact ? matter.contact.name : nil unless key\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.get_lawyer_name,matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"\" : \"\",matter.matter_no,matter.matter_category,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n\n conditions[key] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[key] = data\n sum_hrs(conditions,key)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n\n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:text_select_lawyer),\"#{t(:label_Account)}\",t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n elsif params[:report][:summarize_by] == \"account\"\n ehrs,bhrs,rhrs = 0,0,0\n matters = col.collect do |matter|\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n account = matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"None\" : \"None\"\n [matter.name,matter.get_lawyer_name,matter.contact ? matter.contact.name : \"\",matter.matter_no,matter.matter_category,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours),account]\n end\n matters_hash = {}\n matters.each do |matter|\n key = matter.pop\n if matters_hash.has_key?(key)\n matters_hash[key] << matter\n else\n matters_hash[key] = [matter]\n end\n end\n matters_hash.each do |label,matters|\n matters.each do |matter|\n ehrs += matter[-3].to_f\n bhrs += matter[-2].to_f\n rhrs += matter[-1].to_f\n end\n conditions[label] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[label] = matters\n sum_hrs(conditions,label)\n end\n \n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:text_select_lawyer),t(:label_client),t(:text_matter_id),t(:label_type),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n elsif params[:report][:summarize_by] == \"lit_type\"\n ehrs,bhrs,rhrs = 0,0,0\n col.group_by(&:matter_category).each do |label,matters|\n matters.each do|matter|\n est_hours = matter.estimated_hours ? matter.estimated_hours : 0\n bill_hours = 0\n matter.time_entries.select{|obj| obj.is_billable}.each do|e|\n bill_hours += e.actual_duration\n end\n rem_hours = (est_hours - bill_hours).abs\n ehrs += est_hours\n bhrs += bill_hours\n rhrs += rem_hours\n data << [matter.name,matter.contact ? matter.contact.name : \"\",matter.get_lawyer_name,matter.contact ? matter.contact.get_account ? matter.contact.get_account.name : \"\" : \"\",matter.matter_no,matter.matter_status.lvalue,rounding(est_hours),rounding(bill_hours),rounding(rem_hours)]\n end\n label = label.try(:capitalize)\n conditions[label] = [rounding(ehrs),rounding(bhrs),rounding(rhrs)]\n total_data[label] = data\n sum_hrs(conditions,label)\n ehrs,bhrs,rhrs = 0,0,0\n data = []\n\n end\n column_widths = {0=> 100,1=> 100,2=> 100,3=> 60,4=> 50,5=> 50,6=> 60,7=> 60,8=> 100}\n table_headers = [t(:label_matter),t(:label_client),t(:text_select_lawyer),\"#{t(:label_Account)}\",t(:text_matter_id),t(:label_status),t(:text_estimated_hours),\"#{t(:label_billable)} #{t(:text_hour)}\",\"Projected hours\"]\n end\n alignment = {0=> :left,1=> :left,2=> :left,3=> :center,4=> :center,5=>:center,6=> :center,7=> :center,8=> :center} if params[:format] == \"pdf\"\n [total_data,table_headers,conditions,column_widths,alignment]\n end", "def fundingdistribution\n @fundingdistribution = {}\n @sourceoffunds.each do |sof|\n @fundingdistribution[sof.name] = budget * (sof.percentage.to_f / 100)\n end\n @fundingdistribution \n end", "def index\n @hold_requests = HoldRequest.all\n end", "def getAllPeriods()\n aggregateQuery = [\n @dsObj.groupByPeriods(),\n {:$sort => {\"_id.fiscal_year\" => -1, \"_id.fiscal_quarter\" => -1, \"_id.fiscal_month\" => -1, \"_id.fiscal_week\" => -1}}\n ]\n aggregateCursor = @bookingDumpColl.aggregate(aggregateQuery)\n\n yearArray = []; quarterArray = []; monthArray = []; weekArray = [];\n periodsArray = [] \n periodDict = {}\n\n aggregateCursor.each do |doc|\n subDoc = doc[:_id]\n yearArray << subDoc[:fiscal_year]\n quarterArray << subDoc[:fiscal_quarter]\n monthArray << subDoc[:fiscal_month]\n weekArray << subDoc[:fiscal_week]\n periodDict = {\n :periods => {\n :year => subDoc[:fiscal_year],\n :quarter => subDoc[:fiscal_quarter],\n :month => subDoc[:fiscal_month],\n :week => subDoc[:fiscal_week]\n }\n }\n periodsArray << periodDict\n end\n yearArray = yearArray.uniq; yearArray = yearArray.sort\n quarterArray = quarterArray.uniq; quarterArray = quarterArray.sort\n monthArray = monthArray.uniq; monthArray = monthArray.sort\n weekArray = weekArray.uniq; weekArray = weekArray.sort\n\n arrayHash = {\n :yArray => yearArray,\n :qArray => quarterArray,\n :mArray => monthArray,\n :wArray => weekArray,\n :pArray => periodsArray\n }\n return arrayHash\n \n end", "def index\n @donation_record_actual_funds = DonationRecord::ActualFund.all\n end", "def reshare_monthly_fulfillment(model, institution, fiscal_year, get_borrowing)\n\n # Get the fiscal year ranges\n this_year, last_year = fiscal_year_ranges(fiscal_year)\n\n # Build the query to calculate monthly fulfillment\n output_query = model::Reshare::Transaction.select(:request_id).distinct\n .where(lender_status: 'RES_COMPLETE')\n .where(borrower_status: 'REQ_REQUEST_COMPLETE')\n .where(date_created: this_year)\n\n if get_borrowing\n output_query = output_query.where(borrower: institution)\n .group(:lender)\n else\n output_query = output_query.where(lender: institution)\n .group(:borrower)\n end\n\n result_map = output_query.group(\"CAST(EXTRACT (MONTH FROM date_created) AS int)\")\n .count\n\n # Get a list of display months for the column headings\n months = display_months(this_year).reverse()\n\n # Get a list of the institution names (row headings)\n institutions = reshare_institution_names(model)\n\n output_table = []\n # Add in the column headings\n output_table << [\"Institutions\"] + months.map{|m| Date::MONTHNAMES[m]}\n\n # Calculate the rollup of all institutions\n rollup = months.map{|m| [m,0]}.to_h\n result_map.each do |k,v|\n rollup[k[1]] = rollup.fetch(k[1] , 0) + v\n end\n output_table << [\"All Institutions\"] + rollup.values\n\n # Add in all the institutions\n institutions.each do |i|\n # Skip current institution\n next if i == institution\n\n row = [i]\n # Add in each month\n months.each do |m|\n row.append(result_map.fetch([i,m], 0))\n end\n # Add the row to the output table\n output_table << row\n end\n\n return output_table\n end", "def period_dataset_for_resource(resource, date_range)\n data = {}\n\n payments = resource.payments.in_range(date_range)\n expenses = resource.expenses.in_range(date_range)\n\n data['Payments'] = payments.sum(:amount)\n @organization.expense_categories.major.each do |ec|\n data[\"#{ec.name} Expenses\"] = expenses.where(expense_category_id: ec.id).sum(:amount)\n end\n\n data['Other Expenses'] = expenses.minor_expenses.sum(:amount)\n data['Profit'] = data['Payments'] - expenses.sum(:amount)\n data\n end", "def update_yearly_rents_and_calculate\n unless @lbtt_return.flbt_type == 'CONVEY'\n # if the lease dates are nil then we don't need to calculate either\n return true if @lbtt_return.lease_start_date.nil? || @lbtt_return.lease_end_date.nil?\n\n # Stores the previous calculated years, which is the number of rows of the rental years if it's found,\n # otherwise it'll default to 0.\n # Normally, when the user has already entered the lease dates and then came back to change it, the old array\n # where the yearly_rents are stored will still be the same until when it gets changed later in this method.\n # So that's where the 'previous' comes from.\n previous = @lbtt_return.yearly_rents.nil? ? 0 : @lbtt_return.yearly_rents.length\n\n update_yearly_rents_array(previous)\n end\n setup_transaction_dates_step\n update_tax_calculations\n end", "def get_expense_details\n @total_expenses = 0.0\n @billed_expenses = 0.0\n @expense_entries = {}\n @expense_entries = @saved_expense_entries\n for time_entry in @saved_time_entries\n @expense_entries += time_entry.tne_invoice_expense_entries\n end\n unless @expense_entries.empty?\n @total_expenses = @expense_entries.map(&:expense_amount).inject(0) do |total,amount|\n total + amount\n end\n @billed_expenses = @expense_entries.map(&:final_expense_amount).inject(0) do |total,amount|\n total + amount\n end\n @billed_expenses = @billed_expenses.to_f.roundf2(2)\n end\n end", "def new_order_returns\n record.new_order_returns\n end", "def index\n @deposit_channels = DepositChannel.all\n @withdraw_channels = WithdrawChannel.all\n @currencies = Currency.all.sort\n # @currencies = Currency.all.sort_by &:priority\n @deposits = current_user.deposits.includes(:payment_transaction).order('created_at desc').limit(1000)\n @accounts = current_user.accounts.enabled\n @withdraws = current_user.withdraws.order('created_at desc').limit(1000)\n @fund_sources = current_user.fund_sources\n @markets = Market.all\n\n commission_fees = AccountVersion.where(\" modifiable_type IN (?)\", %w(Trade Withdraw))\n @commission_fees = commission_fees.select('modifiable_type, currency, sum(fee) as total_fees').group('modifiable_type, currency')\n @commission_list = Commission.select('currency, sum(amount) as total_commission , modifiable_type as modifiable_type').group('currency,modifiable_type').where(modifiable_type: ['Withdraw', 'Trade'])\n @banks = Bank.all\n @id_document = current_user.id_document\n\n gon.jbuilder\n end", "def setup_yearly_rents\n model = load_step\n (0..@lbtt_return.yearly_rents.size - 1).each do |i|\n @lbtt_return.yearly_rents[i].rent ||= @lbtt_return.annual_rent\n end\n model\n end", "def index\r\n #@invoices = Invoice.all\r\n #@invoices = policy_scope(Invoice)\r\n @pagy, @invoices = pagy(policy_scope(Invoice.order(invoicedate: :desc)))\r\n end", "def myrewards\n @rewards = Reward.all.where(business: current_business)\n end", "def index\n @individual_company_investments = IndividualCompanyInvestment.all\n end", "def calcs_for_date_range(start_date, end_date, abandon_rate)\n puts \"\\tFrom #{start_date} to #{end_date} inclusive:\"\n\n total_registrations = WasteExemptionsEngine::Registration.where(\n created_at: start_date.beginning_of_day..end_date.end_of_day\n ).count\n total_registrations_s = number_with_delimiter(total_registrations)\n puts \"\\tTotal registrations: #{total_registrations}, of which:\"\n\n assisted_digital_registrations = WasteExemptionsEngine::Registration.where(\n created_at: start_date.beginning_of_day..end_date.end_of_day,\n assistance_mode: \"full\"\n ).count\n assisted_digital_registrations_s = number_with_delimiter(assisted_digital_registrations)\n puts \"\\t... assisted digital: #{assisted_digital_registrations_s}\"\n\n fully_digital_registrations = WasteExemptionsEngine::Registration.where(\n created_at: start_date.beginning_of_day..end_date.end_of_day,\n assistance_mode: nil\n ).count\n fully_digital_registrations_s = number_with_delimiter(fully_digital_registrations)\n puts \"\\t... fully digital: #{fully_digital_registrations}\"\n\n delta = total_registrations - assisted_digital_registrations - fully_digital_registrations\n puts \"\\t(delta of #{delta} is due to some registrations not having metaData.route set)\" unless delta.zero?\n\n abandon_rate_s = number_to_percentage(100.0 * abandon_rate, precision: 0)\n non_abandon_rate_s = number_to_percentage(100.0 * (1 - abandon_rate), precision: 0)\n\n total_registrations_started = (total_registrations / (1.0 - abandon_rate)).round(0)\n total_registrations_started_s = number_with_delimiter(total_registrations_started.to_i)\n\n total_registrations_completed = fully_digital_registrations + assisted_digital_registrations + delta\n total_registrations_completed_s = number_with_delimiter(total_registrations_completed)\n\n total_registrations_started_online = (fully_digital_registrations / (1.0 - abandon_rate)).round(0)\n total_registrations_started_online_s = number_with_delimiter(total_registrations_started_online)\n\n total_registrations_abandoned = total_registrations_started - total_registrations_completed\n total_registrations_abandoned_s = number_with_delimiter(total_registrations_abandoned)\n\n puts \"\\tSo including abandoned attempts, estimated orders started = \" \\\n \"#{total_registrations_s} / (1 - #{abandon_rate_s}) = #{total_registrations_started_s}, of which: \"\n puts \"\\t... completed: #{total_registrations_completed_s}\"\n puts \"\\t... abandoned: #{total_registrations_abandoned_s}\"\n\n puts \"\\nSummary:\"\n puts \"\\t1. Total number of transactions started and completed online only: #{fully_digital_registrations_s}\"\n puts \"\\t2. Total number of transactions started online: ESTIMATED: #{total_registrations_started_online_s}\"\n puts \"\\t\\t(Estimated dropoff rate for the last 30 days: #{abandon_rate_s}\"\n puts \"\\t\\t so estimated completion (non-abandoned) rate for the last 30 days: #{non_abandon_rate_s}\"\n puts \"\\t\\t so given #{fully_digital_registrations_s} fully digital orders, \" \\\n \"estimated total orders started online = \" \\\n \"(#{fully_digital_registrations_s}/#{non_abandon_rate_s}) = #{total_registrations_started_online_s})\"\n puts \"\\t3. Number of online claims: #{fully_digital_registrations_s}\"\n puts \"\\t4. Total number of claims (online + offline + unknown): \" \\\n \"#{fully_digital_registrations_s} + #{assisted_digital_registrations_s} + \" \\\n \"#{delta} = #{total_registrations_completed_s}\"\n\n puts \"====================================================================================================\"\n end", "def autoselect_all_possible_entries!\n if employee_entries.present?\n raise 'This PayrollPeriod already has employee_entries! Can’t autoselect_entries!'\n end\n \n entries = Ticket::EmployeeEntry.where(payroll_period_id: nil)\n\n tickets = Set.new\n entries.each do |entry|\n if entry.ticket.admin_approved?\n tickets << entry.ticket\n end\n end\n \n earliest_date = nil\n latest_date = nil\n\n tickets.each do |ticket|\n ticket.employee_entries.each do |employee_entry|\n if employee_entry.payroll_period\n raise 'autoselect_all_possible_entries! is working on a ticket that already has a payroll period. More nuanced control is required here.'\n end\n \n if (not earliest_date) or (earliest_date > employee_entry.time)\n earliest_date = employee_entry.time\n end\n if (not latest_date) or (latest_date < employee_entry.time)\n latest_date = employee_entry.time\n end\n \n employee_entry.payroll_period = self\n if not employee_entry.save\n raise employee_entry.errors.inspect\n end\n end\n end\n \n self.start_date = earliest_date\n self.end_date = latest_date\n self.save\n \n calculate!\n end", "def index\n @budget_approvers = BudgetApprover.all\n end", "def required_annual_savings\n needed_amount_less_savings / years_to_retirement\n end", "def getYoYTDBooking(dataDict)\n current, prev = 0.0, 0.0\n\n if dataDict.has_key? :prodSer\n queryObj = {\n :username => dataDict[:user],\n \"periods.prod_ser\" => dataDict[:prodSer],\n \"periods.year\" => dataDict[:maxYear],\n \"periods.quarter\" => nil,\n \"periods.month\" => nil,\n \"periods.week\" => nil,\n }\n else\n queryObj = {\n :username => dataDict[:user],\n \"periods.year\" => dataDict[:maxYear],\n \"periods.quarter\" => nil,\n \"periods.month\" => nil,\n \"periods.week\" => nil,\n }\n end # End of If condition to check if the key prodSer is there\n\n currentDoc = dataDict[:coll].find(queryObj)\n currentDoc.each do |doc|\n current = doc[dataDict[:symbol]][:yAxis][0]\n end\n tempTotal = 0.0\n dataDict[:prevMonth].times do |i|\n month = i + 1\n if dataDict.has_key? :prodSer\n queryObj2 = {\n :username => dataDict[:user],\n \"periods.prod_ser\" => dataDict[:prodSer],\n \"periods.year\" => dataDict[:prevYear].to_s,\n \"periods.month\" => month.to_s,\n \"periods.week\" => nil,\n }\n else\n queryObj2 = {\n :username => dataDict[:user],\n \"periods.year\" => dataDict[:prevYear].to_s,\n \"periods.month\" => month.to_s,\n \"periods.week\" => nil,\n }\n end # End of If condition to check if the key prodSer is there\n prevDoc = dataDict[:coll].find(queryObj2)\n prevDoc.each do |doc|\n tempTotal = doc[:tdBooking][:yAxis][0]\n end # End of prevYearDoc iteration\n prev += tempTotal\n end # End of Month iteration\n returnData = {\n :xAxis => [dataDict[:maxYear]],\n :yAxis => [ScalarCalculators.calculateGrowth(current, prev)],\n :current => [current],\n :prev => [prev],\n }\n return returnData\n end", "def index\n @financial_statements = FinancialStatement.all\n end", "def index\n @api_v1_mentorship_interests = Api::V1::MentorshipInterest.all\n end", "def get_all_payment_info_by_bibs(bib_ids, conn)\n results = {}\n bib_ids.each_slice(1000) do |segment|\n query = payment_info_by_bibs_all_ledgers(segment)\n conn.exec(query, *segment) do |row|\n hash = {}\n bib_id = row[0]\n hash[:invoice_id] = row[1]\n hash[:vendor_code] = row[2]\n hash[:invoice_num] = row[3]\n hash[:voucher_num] = row[4]\n hash[:invoice_status] = row[5]\n hash[:status_date] = row[6]\n hash[:invoice_date] = row[7]\n hash[:conversion_rate] = row[8]\n hash[:reporting_fund] = row[9]\n hash[:allocated_fund] = row[10]\n hash[:invoice_line_amount] = row[11]\n hash[:percentage] = row[12]\n cost_share = hash[:invoice_line_amount] * (hash[:percentage] / 100_000_000.0)\n converted_cost_share = convert_currency(hash[:conversion_rate], cost_share)\n converted_total = convert_currency(hash[:conversion_rate], hash[:invoice_line_amount])\n hash[:converted_inv_line_amount] = converted_total\n hash[:converted_cost_share] = converted_cost_share\n hash[:account_number] = row[13]\n hash[:ledger] = row[14]\n hash[:fiscal_period] = row[15]\n results[bib_id] = [] unless results[bib_id]\n results[bib_id] << hash\n end\n end\n results\nend", "def index\n if params[:transac_period]\n @params_period=params[:transac_period].to_i\n else\n @params_period=nil\n end\n @spendings=nil\n \n if @params_period!=6\n #return the start date based on params[:transac_period]. If there is no parameter, use 7 days ago as default.\n @start_date= return_start_date(@params_period)\n @spendings=Spending.find_spendings(@start_date,session[:user_id]).paginate(page:params[:page]) \n else\n @spendings=Spending.all.where(:user_id=>session[:user_id]).paginate(page:params[:page])\n if (@spendings.last)\n @start_date=@spendings.last.transaction_date_d\n end\n end\n # in case that user hasn't input anything in the specified period.\n if (@spendings!=nil &&@spendings.count>0)\n @start_date=@spendings.last.transaction_date_d\n @end_date=@spendings.first.transaction_date_d\n end\n @text=return_text(@params_period)\n # Advance search implementation\n \n if params[:id]\n @advance_search=AdvanceSearch.find(params[:id])\n @spendings=@advance_search.transactions.where(:user_id=>session[:user_id]).paginate(page:params[:page])\n if @spendings.count>0\n @start_date=@spendings.last.transaction_date_d\n @end_date=@spendings.first.transaction_date_d\n end\n #define class to display tab\n @normal_search_class=\"\"\n @advance_search_class=\"active\" \n # define class to display normal search form or advance_search form\n @normal_search_class2=\"no_display\"\n @advance_search_class2=\"\"\n else\n @advance_search=AdvanceSearch.new\n #define class to display tab\n @normal_search_class=\"active\"\n @advance_search_class=\"\" \n # define class to display normal search form or advance_search form\n @normal_search_class2=\"\"\n @advance_search_class2=\"no_display\"\n end\n \n respond_to do |format|\n format.html{}\n format.csv{send_data Spending.to_csv(@spendings)}\n format.xls\n end\n end", "def pending_approval_grace_period_transactions\n active_member_id_list = self.active_group_loan_memberships.map{|x| x.member_id }\n \n TransactionActivity.where(:member_id => active_member_id_list, \n :loan_id => self.id, \n :loan_type => LOAN_TYPE[:group_loan],\n :transaction_case => (GRACE_PERIOD_PAYMENT_START..GRACE_PERIOD_PAYMENT_END),\n :is_approved => false ,\n :is_deleted => false ,\n :is_canceled => false )\n \n \n \n end", "def index\n @automated_transactions = current_airport.automated_transactions\n end", "def create_join_table_ele(filter, all_savings)\n filter.each_with_index do |contract, index|\n JoinTableEleSimulationContract.create(ele_simulation: self, ele_contract: contract, savings: all_savings[index])\n end\n end", "def with_states\n selection = [arel_table[:period], *sums_with_states]\n arel = uncancelled_buyer_invoices\n .selecting { selection }\n .group(:period)\n .joins { line_items.outer } # This is a left outer joins so if no line items the columns will be set to NULL\n .reorder(period: :desc)\n result = connection.select_all(arel).extend(CastValues)\n result.cast_values(MonthlyRevenueRow)\n end", "def find_transactions\n transactions = Transaction.where(\"payer_id = ? or payee_id = ?\", self.id, self.id).reverse\n transactions.map do |transaction|\n receive_money = transaction.payee_id == self.id\n interested_id = receive_money ? transaction.payer_id : transaction.payee_id\n interested_user = User.select([:id, :email]).find(interested_id) rescue nil\n total_payed = transaction.payments.where(\"done_date IS NOT NULL\").pluck(:amount).sum\n total_debit = transaction.payments.pluck(:amount).sum\n @advance_percentage = total_debit != 0 ? ((total_payed / total_debit) * 100) : 0\n {object: transaction, receive_money: receive_money, interested: interested_user, status: transaction.state?, percentage: @advance_percentage}\n end\n end", "def pendings_search(current_projects, no, bill_no, project, c, s, street_name, bank_account, period, user, biller, issue_date, payday_limit)\n Bill.search do\n with(:invoice_status_id, 0..98)\n if !current_projects.blank?\n with :project_id, current_projects\n end\n\n # By invoice_no\n if !no.blank?\n if no.class == Array\n with(:invoice_ids, no)\n else\n with(:invoice_no).starting_with(no)\n end\n end\n # By raw invoice No\n # if !no.blank?\n # if no.class == Array\n # with :raw_invoice_no, no\n # else\n # with(:raw_invoice_no).starting_with(no)\n # end\n # end\n\n # By bill_no\n if !bill_no.blank?\n if bill_no.class == Array\n with :bill_no, bill_no\n else\n with(:bill_no).starting_with(bill_no)\n end\n end\n # By raw bill No\n # if !bill_no.blank?\n # if bill_no.class == Array\n # with :raw_bill_no, bill_no\n # else\n # with(:raw_bill_no).starting_with(bill_no)\n # end\n # end\n\n # by project\n if !project.blank?\n with :project_id, project\n end\n # Client\n # if !client.blank?\n # if client.class == Array\n # with :client_code_name_fiscal, client\n # else\n # with(:client_code_name_fiscal).starting_with(client)\n # end\n # end\n # if !c.empty?\n # with :client_ids, c\n # end\n if !c.blank?\n with :client_id, c\n end\n # Subscriber\n # if !subscriber.blank?\n # if subscriber.class == Array\n # with :subscriber_code_name_fiscal, subscriber\n # else\n # with(:subscriber_code_name_fiscal).starting_with(subscriber)\n # end\n # end\n # if !s.empty?\n # with :subscriber_ids, s\n # end\n if !s.blank?\n with :subscriber_id, s\n end\n # Supply address\n if !street_name.blank?\n if street_name.class == Array\n with :supply_address, street_name\n else\n with(:supply_address).starting_with(street_name)\n end\n end\n # if !street_name.blank?\n # with :supply_address, street_name\n # end\n # if !street_name.blank?\n # with :subscriber_id, street_name\n # end\n # Have active bank account?\n if (bank_account == true || bank_account == false)\n with :bank_account, bank_account\n end\n # Billing period\n if !period.blank?\n with :billing_period_id, period\n end\n # Created by (user)\n if !user.blank?\n with :created_by, user\n end\n # Biller\n if !biller.blank?\n with :biller_ids, biller\n end\n # Bill date\n if !issue_date.blank?\n with :bill_date, issue_date\n end\n # Payday limit\n if !payday_limit.blank?\n with :payday_limit, payday_limit\n end\n data_accessor_for(Bill).include = [{client: :client_bank_accounts}, :subscriber, :invoice_status, :payment_method, {invoices: [:invoice_type, :invoice_operation, {invoice_items: :tax_type}]}, :instalments]\n # field_list :id, :bill_no\n order_by :sort_no, :asc\n paginate :page => params[:bills_pending_page] || 1, :per_page => 10\n end\n end", "def offenses; end", "def offenses; end", "def offenses; end", "def generate_invoices\n companies = Company.all\n\n companies.each do |company|\n\n last = company.last_bill\n last ||= company.created_at.prev_month.to_date\n\n actual = last.next_month.end_of_month\n\n while actual < Date.today\n\n counter = 0\n company.users.each do |user|\n\n if user.role != ROOT\n last_period = user.periods.where(\"created_at <= :end_of_last_month\",{:end_of_last_month => actual}).order(\"created_at DESC\").first\n \n if !last_period.nil?\n unless last_period.state <= STATE[:inactive] && last_period.created_at <= actual.prev_month\n counter+=1\n end\n end\n end\n\n end\n\n if counter > 0\n bill = company.bills.build\n bill.value = counter\n bill.state = -1\n bill.month = actual\n bill.save\n end\n\n company.last_bill = actual\n company.save\n\n actual = actual.next_month.end_of_month\n end\n end\n \n redirect_to backoffice_bills_path\n end", "def index\n @tx_royalties = TxRoyalty.order(:start_date => 'asc').all\n end", "def financial_reports_table_hash(period_type)\n financial_reports = get_financial_reports(period_type)\n FinancialReport.statements_array.inject({}) do |the_hash, statement|\n the_hash[statement] = financial_statement_table_hash(statement, financial_reports)\n the_hash\n end\n end", "def get_companies_reporting_earnings_within days\n @earnings = robinhood_get(\"#{ROBINHOOD_API_URL}/marketdata/earnings/?range=#{days}day\")[\"results\"]\n end", "def bills_with_this_attributes(operation_id=1)\n Bill.joins(:invoices).where(invoices: {invoice_operation_id: operation_id, billing_period_id: billing_period, invoice_type_id: InvoiceType::WATER}, subscriber_id: subscriber_id)\n end", "def retirement_params\n params.require(:retirement).permit(:annual_savings, :year_of_retirement, :inital_savings, :intrest_rate, :retirement_estimate)\n end", "def index\n \n @quotations = Quotation.all\n \n# Auto update Date\n @quotations.each do |quotation|\n if quotation.approve==nil && quotation.cancel==false\n\t if Date.today.strftime(\"%d-%m-%Y\")==quotation.doc_date.strftime(\"%d-%m-%Y\")\n\t quotation.cancel=true\n\t quotation.approve=false\n\t quotation.update_attributes(params[quotation])\n\t end\n\t if Date.today.year==quotation.doc_date.year && Date.today.month>quotation.doc_date.month\n# \t quotation.doc_date==Date.today\n\t quotation.cancel=true\n\t quotation.approve=false\n\t quotation.update_attributes(params[quotation])\n\t end\n\t if Date.today.year==quotation.doc_date.year && Date.today.month==quotation.doc_date.month && Date.today.day>quotation.doc_date.day\n# \t quotation.doc_date==Date.today\n\t quotation.cancel=true\n\t quotation.approve=false \n\t quotation.update_attributes(params[quotation])\n\t end\n end\n end\n\n if (params[:col] == '1')\n if (params[:sort] == 'custname' && params[:direction]=='asc') \n\t @quotations = Quotation.joins(:customer).searchcustname(params[:search]).order('custname' + ' ' + 'asc').paginate(:per_page => 15, :page => params[:page])\n else if (params[:sort] == 'custname' && params[:direction]=='desc')\n\t @quotations = Quotation.joins(:customer).searchcustname(params[:search]).order('custname' + ' ' + 'desc').paginate(:per_page => 15, :page => params[:page])\n\t else\n\t @quotations = Quotation.joins(:customer).searchcustname(params[:search]).order(sort_column + ' ' + sort_direction).paginate(:per_page => 15, :page => params[:page])\n\t end\n end\n# @quotations = Quotation.joins(:customer).searchcustname(params[:search]).order(sort_column + ' ' + sort_direction).paginate(:per_page => 15, :page => params[:page])\n else if (params[:col] == '2')\n\t if (params[:sort] == 'custname' && params[:direction]=='asc') \n\t @quotations = Quotation.joins(:customer).searchtitle(params[:search]).order('custname' + ' ' + 'asc').paginate(:per_page => 15, :page => params[:page])\n\t else if (params[:sort] == 'custname' && params[:direction]=='desc')\n\t\t @quotations = Quotation.joins(:customer).searchtitle(params[:search]).order('custname' + ' ' + 'desc').paginate(:per_page => 15, :page => params[:page])\n\t else\n\t\t @quotations = Quotation.joins(:customer).searchtitle(params[:search]).order(sort_column + ' ' + sort_direction).paginate(:per_page => 15, :page => params[:page])\n\t end\n\t end\n \n# \t @quotations = Quotation.joins(:customer).searchtitle(params[:search]).order(sort_column + ' ' + sort_direction).paginate(:per_page => 15, :page => params[:page])\n\t else\n\t if (params[:sort] == 'custname' && params[:direction]=='asc') \n\t @quotations = Quotation.joins(:customer).search(params[:search]).order('custname' + ' ' + 'asc').paginate(:per_page => 15, :page => params[:page])\n\t else if (params[:sort] == 'custname' && params[:direction]=='desc')\n\t\t @quotations = Quotation.joins(:customer).search(params[:search]).order('custname' + ' ' + 'desc').paginate(:per_page => 15, :page => params[:page])\n\t\t else\n\t\t @quotations = Quotation.joins(:customer).search(params[:search]).order(sort_column + ' ' + sort_direction).paginate(:per_page => 15, :page => params[:page])\n\t\t end\n\t end\n# \t @quotations = Quotation.joins(:customer).search(params[:search]).order(sort_column + ' ' + sort_direction).paginate(:per_page => 15, :page => params[:page])\n\t end\n end\n \n cookies.delete :back_doc\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quotations }\n format.json { render :json => @quotations }\n end\n end", "def append_attendance_record commitments\n commitments_api_data = {};\n \n commitments.each do |commitment|\n commitment_members = commitment.members\n members = []\n commitment_members.each do |member|\n members.push(member.user_id)\n end\n hashed_commitment = commitment.as_json\n hashed_commitment[:attendance] = commitment_score(commitment)\n hashed_commitment[:joined] = commitment.user_has_joined?(current_user.id)\n hashed_commitment[:members] = members\n\n commitments_api_data[commitment[\"id\"]] = hashed_commitment\n end\n\n return commitments_api_data\n\n end", "def transactions_to_copy(start_date, end_date)\n transactions.between(start_date, end_date).unpaid\n end", "def fetch_year_start_prices(coins)\r\n \r\n coins.inject({}) do |r, coin| \r\n\r\n day1 = '01-01-' + @year.to_s\r\n puts 'coin: ' + coin.name.inspect if @debug\r\n \r\n begin\r\n \r\n #a = Coinmarketcap.get_historical_price(coin.name.gsub(/ /,'-'), \r\n # day1, day1)\r\n price = @cq.historical_price coin.symbol, day1\r\n \r\n rescue\r\n puts 'warning : ' + coin.name.inspect + ' ' + ($!).inspect\r\n end\r\n\r\n if price then\r\n \r\n r.merge({coin.name => price.to_f})\r\n else\r\n r\r\n end\r\n \r\n end\r\n \r\n end", "def sales_return_quantity_amount_in_period(start_date, end_date, branch_id)\n if branch_id.present?\n invoice_returns = invoice_return_line_items.\n select(\" sum(quantity * unit_rate) as total_stk_retrn_amount, sum(quantity) as total_stk_retrn_qty\").\n joins(:invoice_return).\n where(:invoice_returns => {:company_id=> self.company_id, :record_date => start_date..end_date, :branch_id => branch_id})\n else\n invoice_returns = invoice_return_line_items.\n select(\" sum(quantity * unit_rate) as total_stk_retrn_amount, sum(quantity) as total_stk_retrn_qty\").\n joins(:invoice_return).\n where(:invoice_returns => {:company_id=> self.company_id, :record_date => start_date..end_date})\n end\n end", "def seek #DESC by date.here\n \n args = {sort: \"-contribution_receipt_date\", api_key: API_KEY[:fec], committee_id: id, per_page: 100, last_index: @last_index, last_contribution_receipt_date: @last_date}\n json = JSONByURL.new(\"https://api.open.fec.gov/v1/schedules/schedule_a?\" + args.build_params)\n\n res = json.snag.json #fix \n\n #log page info, number results, last index retrieved\n donations = res[\"results\"]\n @record_count = res[\"pagination\"][\"count\"] if @record_count.nil? #initial population of instance variable that knows total records in dataset for user experience info\n if @save_record_info_to_db\n @committee.update(num_records_available: @record_count) #update committee with total available on first download this instance\n @save_record_info_to_db = false\n end\n\n @num_accessed += donations.count #Log how many records we have accessed so far so we don't download Nancy Pelosi's donor base from 1987 and blow our API KEY\n donations.select! {|d| d[\"is_individual\"]} #MUTATES ARRAY!!!! KEEPS ONLY WHERE FIELD is_individual = true, AVOIDING DUPLICATE RECORDS FROM INTERNAL MEMOS\n \n #build an array of hashes of 2-element hashes (:donation & :donor) to pass to save_donation method\n page = donations.map {|d| {:donation=> {amount: d[\"contribution_receipt_amount\"], date: d[\"contribution_receipt_date\"]}, :donor=> {zip: d[\"contributor_zip\"], name: d[\"contributor_name\"], street_1: d[\"contributor_street_1\"], street_2: d[\"contributor_street_2\"], employer: d[\"contributor_employer\"], state: d[\"contributor_state\"], city: d[\"contributor_city\"], occupation: d[\"contributor_occupation\"], line_number: d[\"line_number\"]}}} \n @last_index = res[\"pagination\"][\"last_indexes\"][\"last_index\"] #set pagination\n @last_date = res[\"pagination\"][\"last_indexes\"][\"last_contribution_receipt_date\"] #set pagination part 2\n \n # puts \"#{last_index} #{last_date}\"\n page.each {|item| save_donation(item)}\n pct_done = (@num_accessed.to_f / @stop_after * 100).round(1) #xx.x% format for progress downloading records per flags [flags to:do]\n puts \"#{pct_done}% complete. Downloaded #{@num_accessed} of #{@stop_after} from a total of #{@record_count} records.\"\n @num_accessed < @stop_after ? seek : @committee.update(last_date: @last_date, last_index: @last_index, num_records_downloaded: @num_accessed + (@committee.num_records_downloaded || 0)) #keep seeking.....if done, push last record retrieved into db\n # res #un-comment to view JSON data for this page\n end", "def make_preapproved_payments(preapproval_key)\n api.execute :Pay, payment_options(preapproval_key)\nend" ]
[ "0.55788493", "0.5526659", "0.5364657", "0.5314379", "0.52564836", "0.52564836", "0.52300346", "0.51366454", "0.51056856", "0.5060219", "0.5029897", "0.5006404", "0.50056744", "0.4975693", "0.4962308", "0.4939352", "0.4932089", "0.49260435", "0.49239206", "0.49226317", "0.49199247", "0.49154884", "0.49008226", "0.4898305", "0.48975933", "0.48969752", "0.48960283", "0.48941812", "0.48921192", "0.48834395", "0.4882973", "0.4881815", "0.48808944", "0.48792195", "0.487822", "0.4863155", "0.4862414", "0.4860163", "0.485511", "0.48433194", "0.48397073", "0.4834148", "0.48340082", "0.4830119", "0.48286408", "0.48243082", "0.48153123", "0.4815087", "0.48132795", "0.48130852", "0.4804329", "0.48034203", "0.4800575", "0.47999308", "0.47992203", "0.47952485", "0.47941005", "0.4767571", "0.47634384", "0.47627065", "0.47605878", "0.4752724", "0.47523", "0.47500303", "0.4733096", "0.47280747", "0.47226095", "0.471969", "0.47148353", "0.47145957", "0.4713843", "0.47129917", "0.47110555", "0.4709737", "0.47065663", "0.46991235", "0.46975833", "0.46907124", "0.46906728", "0.46905512", "0.4687075", "0.46866116", "0.4681619", "0.4671098", "0.46709764", "0.4667775", "0.4667775", "0.4667775", "0.46676356", "0.46663028", "0.46651155", "0.46626732", "0.4661066", "0.46606445", "0.4657943", "0.4657899", "0.46563497", "0.46521068", "0.4649146", "0.4646518", "0.4645099" ]
0.0
-1
Returns Allows us to get individual returns from the API
def returns(periodKey) self.class.get(url("returns", periodKey), headers: @headers ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def returns\n parsed {\n @returns\n }\n end", "def find_returns\n\t\tbus = Bus.find(params[:bus_id])\n\t\t@return_buses = bus.find_returns(params[:dep_id] == '0' ? true : false).select{|rb| (!rb.maximum_seats || rb.available_tickets(params[:dep_id] == '0' ? 'to_waterloo' : 'from_waterloo') > 0) && rb.date == params[:ret_date].to_date}.collect{|rb| [(params[:dep_id] != '0' ? 'UW Campus' : rb.destination.name) + ', ' + ((params[:dep_id] == '0') ? rb.arrive_time.strftime(\"%k:%M\") : rb.depart_time.strftime(\"%k:%M\")), rb.id]}\n\n\t\trender :partial => \"tickets/buying5\"\n\tend", "def returned(options = {})\n options = { returned_date: Date.current }.merge(options)\n request_params = {\n 'orderID' => order_id,\n 'cartItems' => { 'CartItem' => cart_items.map(&:to_hash) },\n 'returnedDate' => xml_date(options[:returned_date])\n }\n\n response = TaxCloud.client.request :returned, request_params\n TaxCloud::Responses::Returned.parse response\n end", "def find_vat_returns_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VatReturnApi.find_vat_returns ...'\n end\n # resource path\n local_var_path = '/vat_returns'\n\n # query parameters\n query_params = {}\n query_params[:'tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) if !opts[:'tags'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<VatReturn>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VatReturnApi#find_vat_returns\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def results\n response['data']\n end", "def returned(options = {})\n options = { :returned_date => Date.today }.merge(options)\n request_params = {\n 'orderID' => order_id,\n 'cartItems' => { 'CartItem' => cart_items.map(&:to_hash) },\n 'returnedDate' => options[:returned_date]\n }.merge(TaxCloud.auth_params)\n\n TaxCloud.client.request :returned, :body => request_params\n end", "def results\n return error if error?\n return response if response?\n end", "def fetch\n fetch_response.results\n end", "def return_all\n market_details = return_names.collect do |value|\n url = URI.parse \"http://search.ams.usda.gov/farmersmarkets/v1/data.svc/mktDetail?id=#{value['id']}\"\n result = JSON.parse(Net::HTTP.get(url) )\n value = value.merge(result.delete('marketdetails'))\n value\n end\n market_details\n end", "def new_order_returns\n record.new_order_returns\n end", "def index\n @gst_returns = GstReturn.all\n end", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def item_returns\n @item_returns ||= ItemReturn.refund_queue.\n where('line_item_id IS NOT NULL')\n end", "def results\n return error if error?\n response if response?\n end", "def return_values\n Calls.new(select(&:returned?))\n end", "def index\n @return_reasons = ReturnReason.all\n end", "def get_results\n\n # An internal counter to get the next\n # set of results from the API\n @result_count = 0\n\n # An array into which the API results can\n # be collected\n @results = []\n\n # Get the first set of results from the API\n json_response = self.query\n\n while true\n\n # Exit the loop if the API doesn't return\n # any results and set the \"skip\" attribute\n # to nil\n if json_response['result_count'] == 0\n self.skip= nil\n break\n end\n\n # Add the count of the returned results to the\n # internal result counter's current value\n @result_count += json_response['result_count']\n\n # Append the current results to the results\n # array\n @results << json_response['results']\n\n # Set the \"skip\" attribute to the value\n # on the internal result counter\n self.skip= @result_count\n\n # Get the next set of results from the API\n json_response = self.query\n\n # A simple progress bar\n print \"#\"\n\n end\n\n # Print the total result count to the console\n puts \"\\nFound #{@result_count} results.\"\n\n return @results\n\n end", "def raw_results\n results\n end", "def all\n response = RestClient.get(@all_url, params)\n parsed = JSON.parse(response)\n \n parsed['results']['result']\n end", "def index\n @tax_returns = TaxReturn.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tax_returns }\n end\n end", "def get_results(test_id)\n if !(/\\A\\d+\\z/ === test_id.to_s)\n print \"ERROR: get_results called with non-numeric :test_id = '#{test_id}'\\n\"\n exit -1\n end\n uri = \"get_results/#{test_id}\"\n begin\n @all_results = @tr_con.send_get(uri)\n rescue Exception => ex\n print \"EXCEPTION occurred on TestRail API 'send_get(#{uri})':\\n\"\n print \"\\t#{ex.message}\\n\"\n print \"\\tFailed to retrieve list of results; exiting\\n\"\n exit -1\n end\n @all_results.each_with_index do |next_result,ndx_result|\n print ' '*14\n print \" result-%02d:\" % [ndx_result+1]\n print \" id=%-3d\" % [next_result['id']]\n print \" test_id=%d\" % [next_result['test_id']]\n print \" comment=%s\" % [next_result['comment']]\n print \" defects=%s\" % [next_result['defects']]\n print \"\\n\"\n end\n return\nend", "def returns(periodKey)\n self.class.get(url(\"liabilities\"), headers: @headers, query: @query )\n end", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def get_Response()\n \t return @outputs[\"Response\"]\n \tend", "def main_page_api\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n # converts response to a Ruby hash \n @coins = JSON.parse(@response)\n @my_coins = [\"XLM\", \"BTC\", \"ADA\", \"STEEM\", \"ETH\"] \n end" ]
[ "0.69270486", "0.65126646", "0.6433455", "0.6315461", "0.6242207", "0.6183215", "0.61437607", "0.60923105", "0.6080625", "0.6005776", "0.5913505", "0.5892927", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.5892831", "0.5892831", "0.5892831", "0.5892831", "0.5892831", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.5891673", "0.588004", "0.5877737", "0.58700275", "0.58654535", "0.5842125", "0.583577", "0.58090955", "0.58075243", "0.57572687", "0.5743063", "0.5740329", "0.5740329", "0.5740329", "0.5740329", "0.5740329", "0.5740329", "0.5740329", "0.5740329", "0.5740329", "0.57088536" ]
0.7180429
0
Liabilities Shows money owed to HMRC
def returns(periodKey) self.class.get(url("liabilities"), headers: @headers, query: @query ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attack_bonus(lv)\n (110 * 3 * lv.to_f + 250) / 100 + 5\n end", "def wealth\n @gold + inventory_worth\n end", "def view_liability\n @liabilities = Liability.find(:all, :conditions => 'is_deleted = 0')\n @currency_type = currency\n end", "def owes_amount\n loans=@loans\n net_worth=@net_worth\n @balance = net_worth-loans\n print \"the balance is : \",balance,\"\\n\"\n is_developer_solvent?\n end", "def prepaid_liabilities_total\n voucher_groups.inject(Money.new(0)) { |sum, vg| sum + ( vg.cogs * vg.quantity ) }\n end", "def defense_bonus(lv)\n (80 * 3 * lv.to_f / 2 + 250) / 100 + 5\n end", "def loan_money(lender, lendee, value)\n for total in lender[:monies]\n total - value\n end\n return total\n for borrowed in lendee[:monies]\n borrowed + value\n end\n return borrowed\nend", "def credits; end", "def psh_bonuses(roll)\n case roll\n when 1..5\n @@skills << \"Brawling\"\n puts \"Brawling skill\"\n when 6..10\n @@skills << \"Stealth\"\n puts \"Stealth skill\"\n when 11..15\n @@skills << \"Weapons Expert\"\n puts \"Wpn expert!\"\n when 16..20\n @@skills << \"Dodge\"\n puts \"Dodge skill\"\n when 21..37\n @@endurance += 1\n @@strength += 1\n @@agility += 1\n @@accuracy += 1\n @@willpower += 1\n @@intelligence += 1\n @@perception += 1\n @@appearance += 1\n puts \"+1 to each attribute\"\n when 38..44\n @@endurance += (d(6) + d(6))\n puts \"+2d6 endurance\"\n when 45..51\n @@strength += (d(6) + d(6))\n puts \"+2d6 strength\"\n when 52..58\n @@agility += (d(6) + d(6))\n puts \"+2d6 agility\"\n when 59..65\n @@accuracy += (d(6) + d(6))\n puts \"+2d6 accuracy\"\n when 66..74\n @@intelligence += (d(6) + d(6) + d(6))\n puts \"+3d6 intelligence\"\n when 75..83\n @@willpower += (d(6) + d(6))\n puts \"+2d6 willpower\"\n when 84..90\n @@appearance += (d(6) + d(6) + d(6))\n puts \"+3d6 appearance\"\n when 91..97\n @@skills << \"Martial Arts\"\n puts \"Martial arts skill!\"\n when 98..99\n @@endurance += 2\n @@strength += 2\n @@agility += 2\n @@accuracy += 2\n @@willpower += 2\n @@intelligence += 2\n @@perception += 2\n @@appearance += 2\n puts \"+2 to each attribute\"\n when 100\n @@endurance += d(6)\n @@strength += d(6)\n @@agility += d(6)\n @@accuracy += d(6)\n @@willpower += d(6)\n @@intelligence += d(6)\n @@perception += d(6)\n @@appearance += d(6)\n puts \"JACKPOT -- +d6 to EACH Attribute!\"\n end\n\n end", "def character_achievements\r\n BnetApi::make_request('/wow/data/character/achievements')\r\n end", "def credits(shareholder)\n shareholder_effects(shareholder, :credit)\n end", "def loan_money(lender, lendee, amount)\nlender[:monies] -= amount\nlendee[:monies] += amount\nend", "def net_worth\n result = self.cash_on_hand\n self.holdings.each do |holding|\n share_price = holding.company.share_price\n result += share_price * holding.amount\n end\n @net_worth = result\n end", "def loyalty_allowance\n if @faculty.eligible_for_loyality_allowance?(@generation_date)\n ((component_criterias[:loyalty_allowance]/100)*basic) #* eligibility_fraction)\n end\n end", "def loan(lender, lendee, amount)\n lendee_balance = lendee[:monies] + amount\n lender_balance = lender[:monies] - amount\n return [lender_balance, lendee_balance]\nend", "def draw_hp_cost\n values = []\n values.push(item.hp_cost) if item.hp_cost > 0\n values.push(sprintf('%d%%', item.hp_cost_per)) if item.hp_cost_per > 0\n return if values.empty?\n draw_detail(Vocab.attribute(:hp_cost), values.join('+'))\n end", "def current_exp\n self.experience % 100\n end", "def gain_exp\n rate = Grade.rate(:exp)\n $game_party.all_members.each do |actor|\n actor.gain_exp_cpv($game_troop.exp_total, rate)\n end\n return $game_troop.exp_total * rate / 100\n end", "def shield_bonus\n 0\n end", "def update_exp_gain()\n if !@complete\n total_remaining = 0\n \n for i in 0 .. $game_party.members.size-1\n actor = $game_party.members[i]\n actor_exp = @actor_remaining_exp[i]\n \n if actor.dead? && !VICTORY_CONFIG::EXP_ON_DEATH\n actor_exp.remaining_exp = 0\n end\n \n total_remaining += actor_exp.remaining_exp\n \n if actor_exp.remaining_exp > 0\n last_level = actor.level\n last_skills = actor.skills\n \n if !@skipped\n \n if actor_exp.remaining_exp > actor_exp.tick_exp\n \n if actor_exp.tick_exp > actor.needed_exp && actor.needed_exp > 0\n \n exp_to_gain = actor.needed_exp\n \n else\n \n exp_to_gain = actor_exp.tick_exp\n \n end\n \n else\n \n exp_to_gain = actor_exp.remaining_exp\n \n end\n \n actor.gain_exp(exp_to_gain, false)\n actor_exp.remaining_exp -= exp_to_gain\n else\n actor.gain_exp(actor_exp.remaining_exp, false)\n actor_exp.remaining_exp = 0\n end\n \n @victory_char_info_windows[i].window_update(actor)\n \n if actor.level > last_level\n actor_exp.tick_exp = determine_tick(actor.next_exp, actor_exp.remaining_exp)\n \n @victory_level_up_windows[i].visible = true\n Sound.play_level_up_se\n wait(30)\n @victory_level_up_windows[i].visible = false\n end\n new_skills = actor.skills - last_skills\n for skill in new_skills\n @victory_new_skill_windows[i].window_update(skill)\n @victory_new_skill_windows[i].visible = true\n Sound.play_new_skill_se\n wait(30)\n @victory_new_skill_windows[i].visible = false\n end\n end\n end\n \n if total_remaining == 0\n @complete = true\n end\n end\n end", "def display_coins\n end", "def lose_with_insurance\n self.chips += 2 * self.bet_chips\n self.is_complete = true\n \"Dealer hit Blackjack. A lose for #{name}\n #{name} bought an insurance. Pay 2 times of insurance.\"\n end", "def get_credits\r\n self.credits\r\n end", "def get_credits\r\n self.credits\r\n end", "def proficiency_bonus\n\t\t(level()+3)/4 + 1\n\tend", "def getCombatLevel()\n sum_bonus=0\n \n while i< @visibleTreasures.size\n i=i+1\n sum_bonus = @visibleTreasures.fetch(i).bonus + sum_bonus\n end\n \n @level = @level + sum_bonus\n end", "def show_lives\n puts \"Lives remaining: #{@players[0].name}: #{@players[0].life}/3 - #{@players[1].name}: #{@players[1].life}/3\"\n end", "def bet_attribution(state_of_game)\n if state_of_game === \"lose\"\n @money_current = @money_current - @money_bet\n elsif state_of_game === \"win\"\n @money_current = @money_current + (@money_bet * 0.5)\n @money_current = @money_current.to_i\n end\n @money_bet = 0\nend", "def party_worth\n get_worth_of( shared_inventory + actors_inventory )\n end", "def add_trivia(amount)\n if amount < 10\n @credits = @credits + amount * 2\n else\n @credits = @credits + 20\n end\n end", "def income_list\n end", "def pledge_rewards\n pledge_rewards = []\n @project=Project.find(project_id)\n @project.rewards.each do |reward|\n if dollar_amount >= reward.dollar_amount\n pledge_rewards << reward\n end\n end\n return pledge_rewards\nend", "def credits\n cast + crew\n end", "def huella_nutricional\n ((get_impacto_energia + get_impacto_gei)/2).ceil(2)\n end", "def draw_reward(achievement)\r\r\n reward = achievement.reward\r\r\n currency = $game_party.get_csca_cs_currency(reward.id) if $imported[\"CSCA-CurrencySystem\"] && reward.type == :gold\r\r\n case reward.type\r\r\n when :gold; reward_s = $imported[\"CSCA-CurrencySystem\"] ? currency[:currency_unit] : reward_s = Vocab::currency_unit\r\r\n when :item; reward_s = \" \" + $data_items[reward.id].name\r\r\n when :weapon; reward_s = \" \" + $data_weapons[reward.id].name\r\r\n when :armor; reward_s = \" \" + $data_armors[reward.id].name\r\r\n end\r\r\n draw_text(0,line_height*2,contents.width,line_height,CSCA::ACHIEVEMENTS::REWARD+reward.amount.to_s+reward_s,1)\r\r\n end", "def index\n @liabilities = Liability.where(:user_id => current_user.id)\n end", "def loan(lender, lendee, amount)\n lender[:monies] -= amount\n lendee[:monies] += amount\n return [lender[:monies], lendee[:monies]]\nend", "def lend_money(lender, lendee, amount)\n lender[:monies] -= amount\n lendee[:monies] += amount\nend", "def blind_score\n p_score = player_hand.collect{|x| x.value}.inject(:+)\n c_score = computer_hand.collect{|x| x.value}.inject(:+)\n puts \"You have #{player_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{p_score}\"\n puts \"The computer has #{computer_hand[1].face}#{computer_hand[1].suit} & [#]\"\n puts \" \"\n end", "def show\n @chance = @user.chance\n @loans = @user.loans.order(purchase_date: :desc)\n end", "def show_coins_list\n coins_list(coins)\n end", "def guild_achievements\r\n BnetApi::make_request('/wow/data/guild/achievements')\r\n end", "def pledge_math\n @pledges = Pledge.where(\"gift_id\" => self.id)\n return pledge_total.to_f, cost_remainder.to_f\n end", "def show\n @credits = (@split.availability.end_time.to_i - @split.availability.start_time.to_i)/3600\n end", "def credit_description(amount)\n \"Credited Transaction where platform credit covers $#{(amount/100)} of the original $#{total} for transaction ID: #{id} -- #{user.email} just bought a #{item_bought.title} for $#{total}, from #{merchant.title}\"\n end", "def suitable_halfs\n required_amount\n end", "def pnl(fake_yahoo_api)\n \"#{((portfolio_value(fake_yahoo_api) - @starting_balance) / @starting_balance * 100).round(2)}%\"\n end", "def money_made\n total_crowd * self.ticket_price\n end", "def Laboratory(action_hash = {})\n puts 'Laboratory called!'\n card = Card.find(played_card_id)\n if card and phase == 'Action'\n # +1 actions -1 from playing laboratory = +0 actions\n player = game.players.find(player_turn)\n player.draw_card(2)\n player.add_to_played(card)\n update_attributes(prompt: '<b>Played Village!</b><br />Draw 1 card / +2 Actions<br />')\n end\n reset_action_variables\n end", "def credit_amount\n sum( credits )\n end", "def expense_list\n\n end", "def add_year_growth(coins)\r\n \r\n coins.each do |x|\r\n \r\n puts 'x.name: ' + x.name if @debug\r\n \r\n if @growth.has_key?(x.name) then\r\n x.percent_change_year = @growth[x.name].to_s\r\n else\r\n x.percent_change_year = '-'\r\n end\r\n end \r\n \r\n coins\r\n \r\n end", "def loan_amt\n (self.buying_price*1000) * (1 - (self.deposit/100))\n end", "def loan_money(person_lending, person_receiving, loan)\n person_lending[:monies] -= loan\n person_receiving[:monies] += loan\nend", "def attack_roll(item)\r\r\n \r\r\n bonus = (item.magical? || item.speed > 60) ? 4 : 0\r\r\n \r\r\n if item.physical?\r\r\n if item.is_missile\r\r\n return self.difficulty_class('dex',-10,false) + bonus\r\r\n else\r\r\n return self.difficulty_class('str',-10,false) + bonus\r\r\n end\r\r\n elsif item.magical?\r\r\n return self.difficulty_class('int',-8,false) + bonus\r\r\n end\r\r\n \r\r\n return 20\r\r\n end", "def you_are_owed\n detailed_expenses = self.expenses.includes(:expense_details)\n amount = 0\n more_details = Hash.new {|h,k| h[k] = k }\n detailed_expenses.each do |ex|\n id = Friend.includes(:profile).find(ex.payable_id)\n friend_id = self.id != id.profile_id ? id.profile_id : id.friend_id\n ex.expense_details.each do |ed|\n if ed.paid_by == self.id\n amount += (ed.amount_paid / 2.0)\n more_details[friend_id] ||= {}\n more_details[friend_id] += ed.amount_paid / 2.0\n end\n end\n end\n [amount, more_details]\n end", "def mark_up_amt\n rounder5(self.vehicle.price * 0.082)\n end", "def investment\n if buy_price\n num_of_shares * buy_price\n end\n end", "def money_for_us(auction)\n total_sale = auction.current_bid * auction.quantity\n if auction.premium_service\n total_sale * 0.1 # ten percent commission\n else\n total_sale * 0.05 # five percent commission\n end\n end", "def money; end", "def effective_level\n level + level_bonus\n end", "def skill_mod(player=nil)\n player ||= belongs_to_player\n t = total\n t -= 10\n t > 0 ? (t/2) : t\n end", "def deposit\n if admin_use\n 0\n elsif estimated_numbers < 20\n 150\n elsif estimated_numbers < 40\n 300\n else\n 600\n end\n end", "def show\n # monthly_payment, total_payment = TwLaborIncome.load_payment(buy_house_params[\"house_price\"].to_i,buy_house_params[\"loan_duration\"].to_i) \n @predicted_income = TwLaborIncome.new.get_prediction(@buy_house)\n end", "def creditCoins(amount)\r\n @betESSCoins += amount\r\n end", "def calculate_money\n return_data = {lose: 0.0, win: 0.0}\n \n self.bet_scores.each do |e|\n if e.match.result && e.match.result == e.score\n return_data[:win] += e.money\n else\n return_data[:lose] += e.money\n end\n end\n\n self.update_attributes({lose: return_data[:lose], win: return_data[:win]})\n end", "def amount_spent\n \"You have used <strong>#{number_to_currency(money_used)}</strong> out of <strong>#{number_to_currency(incomes)}</strong>\".html_safe\n end", "def sell_bonus\n bonus = 0.0\n battle_members.each { |member| bonus += member.sell_bonus }\n bonus\n end", "def calc_achievements\n\n #TODO: Use a list of achievements in db with conditions stored in db, iterate and award as necessary. \n if (self.games_won_as_pacman == 10)\n self.user.achievements << Achievement.create(:name => \"The Elusive Pacman\", :desc => \"Win 10 games as Pacman\");\n elsif (self.games_won_as_pacman == 100)\n self.user.achievements << Achievement.create(:name => \"Pacman Supreme\", :desc => \"Win 100 games as Pacman\");\n elsif (self.games_won_as_ghost == 10)\n self.user.achievements << Achievement.create(:name => \"Pacman Killer\", :desc => \"Win 10 games as a Ghost\");\n elsif (self.games_won_as_ghost == 100)\n self.user.achievements << Achievement.create(:name => \"Guardian of all the dots in the world\", :desc => \"Win 100 games as a Ghost\");\n elsif (self.total_ghosts_eaten == 50)\n self.user.achievements << Achievement.create(:name => \"Om nom nom!\", :desc => \"Eat 50 ghosts.\");\n elsif (self.total_pacman_eaten == 50)\n self.user.achievements << Achievement.create(:name => \"He never saw it coming.\", :desc => \"Eat 50 Pacman\");\n end \n end", "def ability_used(attack_type, mod_type)\n puts \"You used a #{attack_type} attack with a plus #{mod_type} increase!\"\nend", "def increment_of_health(user)\n (user.max_health / 15) + 5 * (difficulty - 1).round\n end", "def disbursed_amount\n amount = 0\n loans.each do |project|\n amount += project.disbursed_amount.to_i\n end\n amount\n end", "def afford_horse(money)\n horse_cost = 20000\n if money < horse_cost\n return 'Keep saving!'\n end\n\n remaining = money - horse_cost\n return \"You bought a horse and have $#{remaining} left.\"\nend", "def getCUsability()\n return @combat_usability\n end", "def health_benefit; end", "def index\n @habilities = Hability.all\n end", "def credit_in_cents\n (user.credit * 100).to_i\n end", "def haul\n @totalhaul = @silvercounter * SILVERVAL + @goldcounter * GOLDVAL\n @totalhaul\n end", "def skill_lmt_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.skill_acts_mod ||= 0)\n sum += mod\n end\n end", "def claim(args)\n \"#{calc(@total_dice_in_game, args[:dice]) + calc(@total_dice_in_game, @total_dice_in_game)}%\"\n end", "def benefits\n self.ticket_price * self.spectators\n end", "def weapon_reward(available_weapons)\n\n #reward is 1 random choice from this array\n reward = available_weapons.sample\n\n #create to CharacterWeapon object to show that player obtains weaopn\n CharacterWeapon.new_character_weapon(self.id, reward.id)\n\n #print weapon details to player\n puts \"#{reward.name}\".bold.blue\n puts \"Weapon Power: #{reward.attack_power}\"\n puts\"#####################################\".blink\n\n #actually equip the weapon, if it will increase this player's attack power\n if reward.attack_power > self.power - 1 || self.power == 1\n #increase the player's attack power\n self.update(power: 1+reward.attack_power)\n end\n end", "def availableCoins (email)\r\n puts \"The amount of coins in your account is: #{@BetESS.fGetBetESSCoinsFrom(email)}\"\r\n end", "def calories_per_liter\n 672\n end", "def earnings\n @title = \"Your Earnings\"\n @earnings = @affiliate.get_earnings()\n end", "def show\n @auction = Auction.find(params[:id])\n @items = Item.where(auction_id: @auction.id)\n pledges = @auction.items.map { |item| item.high_bid.try(:amount) }\n @pledge_total = pledges.compact.sum\n @payments_received = @auction.winning_bids.where(paid: true).map { |wbid| wbid.bid.amount }.sum\n \n @donor_count = @auction.donors.uniq.length\n @bidder_count = @auction.bidders.uniq.length\n \n @donation_count = @auction.items.count\n @declined_items_count = @auction.items.where(declined: true).count\n\n items_sold = @auction.items.to_a.delete_if { |item| item.bids.empty? }\n @items_sold_count = items_sold.compact.length\n @items_unsold_count = @auction.items.count - @items_sold_count\n \n @bids_count = @auction.bids.count\n end", "def interest\n return (@capital / 100) * @rate\n end", "def predicted_deaths\n death_toll = (population * death_multiplier).floor\n print \"#{state} will lose #{death_toll} people in this outbreak\"\n end", "def buy_choc money, price, num_wr\n\n total = 0\n\n total += money /price\n\n total_wr = total\n\n while total_wr >= num_wr\n bonus = total_wr / num_wr\n remainder = total_wr % num_wr\n\n total += bonus\n\n total_wr = bonus + remainder\n end", "def get_earnings\n get_historic_eps(1)\n end", "def index\n @loyalty_cards = current_user.loyalty_cards\n end", "def getCombatLevel\n combatLevel = @level\n @visibleTreasures.each { |treasure| combatLevel += treasure.getBonus}\n combatLevel\n end", "def acc_balance\n @page.css(\"span[data-semantic = 'header-available-balance-amount']\").text.to_money.to_f\n end", "def offense_report(label = 'Attackers:')\n status_report(\n name: label,\n items: @attackers,\n item_text: lambda { |item| item.list_name num_id_cols: @attackers.size.to_s.size }\n )\nend", "def get_shelley_balances(wid)\n w = SHELLEY.wallets.get(wid)\n total = w['balance']['total']['quantity']\n available = w['balance']['available']['quantity']\n reward = w['balance']['reward']['quantity']\n assets_total = w['assets']['total']\n assets_available = w['assets']['available']\n { 'total' => total,\n 'available' => available,\n 'rewards' => reward,\n 'assets_available' => assets_available,\n 'assets_total' => assets_total\n }\nend", "def draw_anger_cost\n return if item.anger_cost == 0\n draw_detail(Vocab.attribute(:anger_cost), item.anger_cost)\n end", "def attack(user)\n # Variable to see how many damage instances will be\n damage_instances_count = 0\n\n # Search within weapons for damage bonus\n user.weapons.each do |weapon|\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'damage'\n damage_instances_count = bonus.multiplier\n end\n end\n end\n\n # For each damage bonus we will calculate the attack again\n damage_instances = (1..damage_instances_count).map do\n # Values from weapons\n weapon_attack_points = 0\n weapon_attack_modifiers = 0\n weapon_attack_recoil_modifier = 0\n\n weapon_defense_points = 0\n weapon_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.weapons.each do |weapon|\n weapon_attack_points += weapon.attack_points\n weapon_defense_points += weapon.defense_points\n\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n weapon_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'recoil'\n weapon_attack_recoil_modifier += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n weapon_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from rings\n rings_attack_points = 0\n rings_attack_modifiers = 0\n\n rings_defense_points = 0\n rings_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.rings.each do |ring|\n rings_attack_points += ring.attack_points\n rings_defense_points += ring.defense_points\n\n ring.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n rings_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n rings_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from helmets\n helmet_attack_points = user.helmet.attack_points\n helmet_attack_modifiers = 0\n\n helmet_defense_points = user.helmet.defense_points\n helmet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.helmet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n helmet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n helmet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from body armor\n body_armor_attack_points = user.body_armor.attack_points\n body_armor_attack_modifiers = 0\n\n body_armor_defense_points = user.body_armor.defense_points\n body_armor_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.body_armor.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n body_armor_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n body_armor_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from boots\n boots_attack_points = user.boots.attack_points\n boots_attack_modifiers = 0\n\n boots_defense_points = user.boots.defense_points\n boots_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.boots.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n boots_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n boots_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from gloves\n gloves_attack_points = user.gloves.attack_points\n gloves_attack_modifiers = 0\n\n gloves_defense_points = user.gloves.defense_points\n gloves_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.gloves.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n gloves_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n gloves_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from amulet\n amulet_attack_points = user.amulet.attack_points\n amulet_attack_modifiers = 0\n\n amulet_defense_points = user.amulet.defense_points\n amulet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.amulet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n amulet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n amulet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Making a sum of all the points from the itens\n attack_points_sum = weapon_attack_points + rings_attack_points + helmet_attack_points + body_armor_attack_points + boots_attack_points + gloves_attack_points + amulet_attack_points\n defense_points_sum = weapon_defense_points + rings_defense_points + helmet_defense_points + body_armor_defense_points + boots_defense_points + gloves_defense_points + amulet_defense_points\n\n # Making a sum of all the bonuses from the items\n attack_modifiers_sum = weapon_attack_modifiers + rings_attack_modifiers + helmet_attack_modifiers + body_armor_attack_modifiers + boots_attack_modifiers + gloves_attack_modifiers + amulet_attack_modifiers\n defense_modifiers_sum = weapon_defense_modifiers + rings_defense_modifiers + helmet_defense_modifiers + body_armor_defense_modifiers + boots_defense_modifiers + gloves_defense_modifiers + amulet_defense_modifiers\n\n # Calculating damage, defense and recoil\n attack_total = attack_points_sum * attack_modifiers_sum\n defense_total = defense_points_sum * defense_modifiers_sum\n recoil_total = (attack_total * weapon_attack_recoil_modifier * ((attack_total / (defense_total + (E ** -attack_total))) / 100)).floor\n\n # Creating a new DamageInstance\n DamageInstance.new(attack_total, recoil_total)\n end\n\n # Returning damage instances\n damage_instances\n end", "def money\n end", "def amount_owed\n total_price - amount_paid\n end", "def display_money\n\tputs \"You have $#{$player_money}\"\t\nend" ]
[ "0.65483916", "0.6204804", "0.6156031", "0.6096375", "0.60831046", "0.6013273", "0.5999547", "0.5915415", "0.58615434", "0.5818462", "0.5772451", "0.5766779", "0.574856", "0.57436496", "0.57299966", "0.57145005", "0.57054454", "0.564986", "0.56490535", "0.5627159", "0.562418", "0.56237197", "0.56218165", "0.56218165", "0.5619158", "0.56021005", "0.5598357", "0.5594712", "0.5587137", "0.5585287", "0.55736935", "0.55689186", "0.55519146", "0.5540005", "0.55290854", "0.55050373", "0.5479741", "0.5478009", "0.5450056", "0.54479575", "0.5446792", "0.5440182", "0.5437311", "0.542899", "0.5423407", "0.54231054", "0.54187757", "0.5407862", "0.54040945", "0.539901", "0.5392062", "0.5386618", "0.53852093", "0.53785586", "0.53751266", "0.5372332", "0.5370694", "0.536937", "0.53691614", "0.536895", "0.536393", "0.53618985", "0.5355191", "0.53459126", "0.5343391", "0.5342894", "0.5339926", "0.53343046", "0.53305924", "0.5325106", "0.53238404", "0.5319921", "0.5315635", "0.5309051", "0.53085", "0.53022885", "0.52996033", "0.5292507", "0.52877474", "0.52847797", "0.5284365", "0.5280612", "0.52795637", "0.5278907", "0.5278472", "0.5267881", "0.52591246", "0.52565557", "0.5255899", "0.5251811", "0.52506524", "0.52497333", "0.5247465", "0.5244766", "0.5242258", "0.5242065", "0.52414644", "0.52384466", "0.5235245", "0.52342045" ]
0.5344736
64
def setup end def teardown end
def test_sequence dotest( ''' <process-definition name="n" revision="0"> <sequence> <print>a</print> <print>b</print> </sequence> </process-definition> '''.strip, "a\nb") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recycle; teardown; setup; end", "def teardown; end", "def teardown; end", "def teardown\r\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def before_teardown; end", "def setup; end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown!\n\n end", "def teardown\n puts \"tear down\"\n end", "def teardown\n end", "def teardown\n end", "def teardown\n # if necessary\n end", "def teardown\n # empty\n end", "def teardown\n\tend", "def teardown\n\tend", "def teardown\n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\r\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n\n end", "def setup\n\n end", "def setup\n\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end" ]
[ "0.89268225", "0.88954216", "0.88954216", "0.87634265", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.86602306", "0.8634565", "0.8589314", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.8570958", "0.85353476", "0.8525226", "0.8524149", "0.8524149", "0.8489033", "0.8483084", "0.8477717", "0.8477717", "0.8427477", "0.8401328", "0.8401328", "0.8401328", "0.8401328", "0.8401328", "0.8401328", "0.8401328", "0.8387995", "0.8352665", "0.8352665", "0.8352665", "0.8352665", "0.8352665", "0.8352665", "0.8338891", "0.8338891", "0.8338891", "0.8302322", "0.8302322", "0.8302322", "0.8302322", "0.8302322", "0.8302322", "0.8302322", "0.8302322", "0.8302322", "0.8302322", "0.8302322", "0.8302322" ]
0.0
-1
Log the given message +msg+ is the message to log Returns nothing
def log(msg) $logger << msg + "\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_log( msg )\n log( msg )\n end", "def log(msg)\n puts msg\n end", "def log(msg)\n STDERR.print \"** \", msg, \"\\n\"\n end", "def on_msg(msg)\n\n puts(fancy_print(msg, @noisy)) if @noisy\n\n return if msg['action'] == 'noop'\n\n @mutex.synchronize do\n\n @seen << msg\n @log << msg\n\n while @log.size > @log_max; @log.shift; end\n while @seen.size > @log_max; @seen.shift; end\n end\n end", "def log(msg)\n Serv::Log.info(Time.now.to_s+': '+msg+\"\\n\")\n end", "def log(msg)\n @logger.write(msg) if @logger\n end", "def log(msg)\n Syslog.log(Syslog::LOG_NOTICE, \"#{Time.now.to_f} #{msg}\")\n if @config.key?('logger') and @config['logger'].is_a?(Proc)\n @config['logger'].call(msg)\n end\n end", "def log(msg)\n STDERR.puts msg\n end", "def log(msg)\n (@logger ||= OMF::Common::LObject.new(self.class)).info(msg)\n end", "def log(msg)\n (@logger ||= OMF::Base::LObject.new(self.class)).info(msg)\n end", "def log(msg)\n return if logger.nil?\n logger.debug(msg)\n end", "def log(msg)\n SystemLog.fact(title: self.class.name.underscore, payload: msg)\n end", "def puts_and_logs(msg)\n @@logger.puts_and_logs msg\n end", "def log(msg)\n lines = msg.split(/\\n/)\n\n STDERR.puts \"** #{lines.first}\"\n lines[1..-1].each do |line|\n STDERR.puts\" #{line}\"\n end\n end", "def log(msg)\n logger.info(\"#{tag} #{msg}\")\n end", "def log(msg)\r\n STDERR.puts msg\r\n end", "def my_msg(msg = nil, put_msg = false)\n Rails.logger.info { \"#{self.class}: #{msg}\" }\n @msg << msg if put_msg\n true\n end", "def log(msg)\n puts(msg) if @info_values['enable_debug_logging'] == \"Yes\"\n end", "def log(msg)\n puts msg\n $stdout.flush\n end", "def logging(msg, severity = 1)\n return if ClientConfig::LOGGING.zero?\n LibLog.log(msg, severity)\n end", "def log!(msg)\n log_info(msg)\n puts(msg)\nend", "def log(msg)\n\t\tSyslog.info(msg) if @verbose\n\tend", "def log(msg,level = Logger::DEBUG)\n @logger.log(level, msg) unless @logger.nil?\n end", "def log(msg, type = :info, multipart: false)\n if dut_version > '0.15.0'\n put(\"k^#{LOG_CODES[type]}^#{msg}\")\n else\n Origen.log.send(type, msg)\n end\n end", "def log(msg)\n print \" \" if $trace && $verbose\n $stderr.puts msg if $verbose\n end", "def log_write(msg)\n puts msg\n end", "def trace(msg=nil)\n return unless msg \n (@logger ||= OMF::Base::LObject.new(self.class)).debug(msg)\n end", "def <<(msg)\n unless @logdev.nil?\n @logdev.write(msg)\n end\n end", "def log(msg)\n print \" \" if $trace && $verbose\n puts msg if $verbose\n end", "def log(msg)\n\n Puppet::Util::Log.create(\n\n :level => @parameters[:loglevel].value,\n :message => msg,\n\n :source => self\n )\n end", "def log(msg)\n puts msg\n $stdout.flush\n end", "def log(msg)\n puts\n puts msg\nend", "def log(msg)\n puts msg if @verbose\n end", "def log(msg)\n puts msg if @verbose\n end", "def log(msg)\n # puts msg\n $stdout.write(\"#{msg}\\n\")\n end", "def info(msg) log(6, msg); end", "def log (msg, **kwargs) Log.write(msg, :info, kwargs) end", "def info(msg); @logger.info(msg); end", "def log(message); logger.info(message); end", "def log(msg, params = { }, &block)\n CondLog.call(msg, params, &block)\n end", "def log msg\n puts \"U:Service: #{msg}\"\n end", "def log_message(message)\r\n @log.log_message(message)\r\n end", "def notice(msg) log(5, msg); end", "def write(msg)\n case msg\n when String then @logger.info(msg.chomp)\n when Array then @logger.info(msg.join(\"\\n\"))\n else\n @logger.error(msg.inspect)\n end\n end", "def trace(msg)\n @self_logs.file.info(msg)\n @self_logs.stdout.info(msg) if @self_logs.stdout\n end", "def log(message)\n puts message\n end", "def info_msg(msg)\n @log.puts(msg)\n puts msg\nend", "def log(msg)\n Rails::logger.debug msg\n end", "def log(msg)\n Puppet::Util::Log.create(\n :level => resource[:loglevel],\n :message => msg,\n :source => self\n )\n end", "def log_action msg\n\t\t\t\tputs '=> ' + msg\n\t\t\tend", "def log(msg)\n if ENV['LAUNCHY_DEBUG'] == 'true' then\n $stderr.puts \"LAUNCHY_DEBUG: #{msg}\"\n end\n end", "def log_message(message)\n\t\tputs(message)\n\tend", "def log(msg)\n SystemLog.fact(title: 'live-dynamo-controller', payload: msg)\n end", "def log(msg, level = :devel)\n Log4r::NDC.push(\"jack_tube\")\n Log.__send__(level, msg)\n Log4r::NDC.pop\n end", "def log( *msg )\n\t\t\toutput = colorize( msg.flatten.join(' '), 'cyan' )\n\t\t\t$stderr.puts( output )\n\t\tend", "def log(msg)\n File.open(File.join(runtime_dir, 'content-repo.log'), 'w+') { |f| \n f.puts msg }\n end", "def debug(msg)\r\n prelog\r\n logger.debug(msg)\r\n end", "def log_message( level, message )\n\n end", "def <<(msg)\n @logdev.write(msg) if @logdev\n end", "def puts(msg)\n msg = msg.to_s\n @logger.unknown(msg)\n msg\n end", "def info(msg)\r\n prelog\r\n logger.info(msg)\r\n end", "def debug(msg)\n log.debug msg\n end", "def log(msg)\n puts(\"#{Time.now}> #{msg}\")\n end", "def log(msg=nil, level=3, &block)\n return @controller_log unless msg or block # hack -- allow clients to set log level, call log.debug, etc.\n @controller_log.add(Logger::INFO, msg, msg, &block)\n end", "def write(msg)\n @logger.info msg\n end", "def log_topic(msg)\n return if @stopped\n\n @filemutex.synchronize do\n log_html_topic(msg)\n end\n end", "def info(msg)\n log.info msg\n end", "def error(msg)\r\n prelog\r\n logger.error(msg)\r\n end", "def log(msg)\n if $settings[:log]\n $settings[:log].write(Time.now.inspect + \" \" + msg + \"\\n\")\n $settings[:log].flush\n end\nend", "def log_public_message(msg)\n return if @stopped\n\n @filemutex.synchronize do\n if msg.action?\n log_html_action(msg)\n else\n log_html_message(msg)\n end\n end\n end", "def log(msg, level = :info)\n puts(\"ZapUpdater: \" + msg)\n RAILS_DEFAULT_LOGGER.info(\"ZapUpdater: \" + msg)\n @mail_log << msg + \"<br/>\\r\\n\" if level == :info\n end", "def warn(msg)\n log.warn msg\n end", "def debug_msg(msg)\n if(@options[:debug])\n @log.puts(msg)\n puts msg\n end\nend", "def log(msg, cls=nil)\n time_stamp = Time.now.strftime(\"%H:%M:%S\")\n if cls.nil?\n print \" [#{time_stamp}] #{msg}\\n\"\n else\n print \" [#{time_stamp}] #{cls.class.name}: #{msg}\\n\"\n end\nend", "def warn(msg)\r\n logger.warn(msg)\r\n end", "def grid_rest_log_message(msg)\n GridRest.log_file ||= File.open(File.join(Rails.root, 'log', \"#{Rails.env}_grid_rest.log\"), 'a+')\n GridRest.log_file.puts msg\n GridRest.log_file.flush unless Rails.env == 'production'\n end", "def debug(msg=nil)\n return unless msg\n (@logger ||= OMF::Common::LObject.new(self.class)).debug(msg)\n end", "def log_info(msg)\n # puts \"-I- #{msg}\"\n @msg_text.insert('end', \"-I- #{msg}\\n\")\n @msg_text.see('end')\n end", "def print(msg)\n message = msg['message']\n @logger.debug(\"Printing msg #{message}\")\n print_raw(message)\n end", "def debug(msg) log(7, msg); end", "def log(msg)\n ConfigureTask.log(msg)\n end", "def debug(msg=nil)\n return unless msg\n (@logger ||= OMF::Base::LObject.new(self.class)).debug(msg)\n end", "def write(msg)\n\t\tinfo(msg)\n\tend", "def debug_msg( *msg )\n\t\treturn unless $DEBUG\n\t\t$stderr.puts( *msg )\n\tend", "def debug_msg( *msg )\n\t\treturn unless $DEBUG\n\t\t$stderr.puts( *msg )\n\tend", "def log(msg, level = :info)\n msg = safe(msg)\n warn \"#{Time.now} #{msg}\" if ENV.key?('debug')\n Syslog.open($PROGRAM_NAME, Syslog::LOG_PID | Syslog::LOG_CONS) do |s|\n s.send(level, '%s', msg)\n end\n end", "def debug(msg)\n @logger.debug(msg)\n end", "def debug(msg)\n @logger.debug(msg)\n end", "def log_info(msg)\n logger ? logger.info(msg) : puts(msg)\n end", "def msg(msg)\n if @name\n \"[#{name}] #{msg}\"\n else\n msg\n end\n end", "def error(msg)\n log.error msg\n end", "def log(message)\n puts \">> #{message}\"\n end", "def debug(msg); @logger.debug(msg); end", "def log(msg)\n puts msg unless ENV['TEST']\n end", "def dmsg(msg)\n if $DEBUG\n case msg\n when String\n puts msg\n else\n puts msg.inspect\n end\n end\n end", "def dmsg(msg)\n if $DEBUG\n case msg\n when String\n puts msg\n else\n puts msg.inspect\n end\n end\n end", "def dmsg(msg)\n if $DEBUG\n case msg\n when String\n puts msg\n else\n puts msg.inspect\n end\n end\n end", "def clog(msg, ltype = :debug, key = :global, logEng = [])\n log(msg, { type: @lType != ltype ? ltype : @lType, \n key: (key != @lKey ? key : @lKey),\n logEng: @llEng })\n end", "def message(message)\n log.info(message.to_s)\n end", "def log(message)\n @__result.add_log(message)\n true\n end" ]
[ "0.79773825", "0.7550129", "0.75215745", "0.74550974", "0.7428155", "0.7391896", "0.72911304", "0.72785366", "0.7248565", "0.72187406", "0.7210956", "0.7193646", "0.7190936", "0.7189346", "0.7142849", "0.7124976", "0.71004134", "0.70522743", "0.698523", "0.6977893", "0.6959235", "0.69315076", "0.69140077", "0.6880261", "0.68759066", "0.68718886", "0.6868319", "0.6862596", "0.68540084", "0.68528444", "0.6849151", "0.6836311", "0.683271", "0.683271", "0.67947155", "0.67884105", "0.67460227", "0.6737721", "0.673232", "0.6717852", "0.67130023", "0.6706702", "0.6612793", "0.6611868", "0.66059923", "0.6603378", "0.65895146", "0.65583146", "0.653411", "0.65183127", "0.6518023", "0.6514369", "0.65093607", "0.6506841", "0.6502134", "0.6501189", "0.64985627", "0.6497125", "0.6485197", "0.64788336", "0.6472427", "0.6459533", "0.6456629", "0.6455827", "0.644391", "0.643829", "0.6430414", "0.64292246", "0.6409893", "0.6405025", "0.6396091", "0.6395334", "0.6380089", "0.637937", "0.63737845", "0.636624", "0.6366115", "0.6362652", "0.6351406", "0.63482946", "0.6341526", "0.63394785", "0.6336449", "0.63330936", "0.63330936", "0.63324946", "0.632111", "0.632111", "0.63146764", "0.63133717", "0.63110477", "0.6296135", "0.62905914", "0.6289474", "0.6289336", "0.6289336", "0.6289336", "0.62825674", "0.6281741", "0.6279788" ]
0.6314112
89
Funciones y codigo personalizado
def url agencia_paquete_path(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def zuruecksetzen()\n end", "def mi_carrera\n\n\tend", "def functions\n\n end", "def probers; end", "def custom; end", "def custom; end", "def operations; end", "def operations; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def private; end", "def methods() end", "def schubert; end", "def who_we_are\r\n end", "def method\n\t\t# code code\n\tend", "def code_of_conduct; end", "def implementation; end", "def implementation; end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def relatorios\n end", "def operation; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def villian; end", "def verdi; end", "def letzte_komponente\n \n end", "def how_it_works\r\n end", "def formation; end", "def fungsiPertama()\n puts \"Ini adalah fungsi pertama\"\nend", "def rossini; end", "def notificaciones\n end", "def extrato\n\n end", "def monica\n end", "def guct\n end", "def solicitudes_atrasadas\n end", "def callbacks; end", "def callbacks; end", "def intensifier; end", "def status_da_divulgacao(topico)\n end", "def terpene; end", "def refutal()\n end", "def process_custom_method\n # da implementare per eventuali estensioni\n end", "def donizetti; end", "def bellini; end", "def testMethod nombre,apellido\n \nend", "def transact; end", "def sichtbar_machen()\n end", "def processor; end", "def schumann; end", "def get_data()\t\n\tend", "def invention; end", "def funktionsname\n\tanweisung\nend", "def heroine; end", "def call\n\n\tend", "def call\n\n\tend", "def apply\n\t\t\t\t\n\t\t\tend", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def param; end", "def param; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def public; end", "def public; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def common\n \n end", "def returns; end", "def informacoes_da_conta(local)\n\t\t\t\t\traise NotImplementedError.new('Sobreescreva este método na classe referente ao banco que você esta criando')\n\t\t\t\tend", "def do()\r\n\tend", "def publico\n puts \"e aqui el metodo publico\"\n end" ]
[ "0.7378923", "0.7030819", "0.69482577", "0.6727263", "0.65133315", "0.6508423", "0.6508423", "0.65034413", "0.65034413", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64255404", "0.6416642", "0.6373922", "0.63500303", "0.6214733", "0.61398584", "0.61248624", "0.61248624", "0.6124775", "0.6124775", "0.6124775", "0.6124775", "0.61035997", "0.6091856", "0.60769147", "0.60769147", "0.60769147", "0.60769147", "0.60587645", "0.60519046", "0.60490716", "0.6047116", "0.59589505", "0.5957332", "0.5946869", "0.59433496", "0.59343725", "0.5921032", "0.5919593", "0.5903863", "0.58986133", "0.58986133", "0.58906585", "0.58704776", "0.58618456", "0.5853196", "0.58487344", "0.5844671", "0.58350104", "0.5822735", "0.5820545", "0.5814541", "0.58128965", "0.58070177", "0.5805332", "0.5805238", "0.5798868", "0.5793589", "0.57871187", "0.57871187", "0.57852405", "0.5779216", "0.5779216", "0.5779216", "0.5779216", "0.5779216", "0.5779216", "0.5779216", "0.5779216", "0.5779216", "0.5779216", "0.5779216", "0.57791877", "0.57791877", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.57727474", "0.5768774", "0.5768774", "0.5761721", "0.5761721", "0.5734503", "0.5715275", "0.57151544", "0.5711228", "0.5705437" ]
0.0
-1
run a shell command and stream the output
def pipe(command) output = "" IO.popen(command) do |io| until io.eof? buffer = io.gets output << buffer puts buffer end end output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stream_output(command)\n puts command\n exit_status = nil\n Open3.popen3(command) do |stdin, stdout, stderr, wait_thread|\n stdout.each { |line| puts line }\n stderr.each { |line| puts line }\n exit_status = wait_thread.value.to_i\n end\n raise %Q(The command \"#{command}\" failed.) unless exit_status == 0\nend", "def sh( cmd )\n logger.info( cmd )\n\n io = IO.popen( \"#{cmd} 2>&1\" )\n io.each_line do |l|\n logger.debug( l.strip )\n end\n end", "def sh(command)\n output = \"\"\n IO.popen(command) do |io|\n until io.eof?\n buffer = io.gets\n output << buffer\n puts buffer\n end\n end\n error \"Command #{command} failed #{$?}\" unless $? == 0\n output\nend", "def shell_command(cmd)\n # Send the command to the session's stdin.\n shell_write(cmd + \"\\n\")\n\n timeo = 5\n etime = ::Time.now.to_f + timeo\n buff = \"\"\n\n # Keep reading data until no more data is available or the timeout is\n # reached.\n while (::Time.now.to_f < etime and (self.respond_to?(:ring) or ::IO.select([rstream], nil, nil, timeo)))\n res = shell_read(-1, 0.01)\n buff << res if res\n timeo = etime - ::Time.now.to_f\n end\n\n buff\n end", "def stream_locally(cmd,opts={})\n shell = opts[:shell] || 'bash'\n tee = opts[:tee]\n redact = opts[:redact]\n redact_replacement = opts[:redact_replacment] || '-REDACTED-'\n cmd = [shell,'-c \"',cmd.gsub(/\"/,'\\\"'),'\" 2>&1'].join(' ')\n cmd_text = redact ? redact.inject(cmd.inspect){|ct,r| ct.gsub(r,redact_replacement)} : cmd.inspect\n logger.trace %Q{executing locally: #{cmd_text}} if logger\n $stdout.sync = true\n elapsed = Benchmark.realtime do\n Open3.popen3(cmd) do |stdin, out, err, external|\n # Create a thread to read from each stream\n { :out => out, :err => err }.each do |key, stream|\n Thread.new do\n until (line = stream.gets).nil? do\n redact.each {|r| line.gsub!(r,redact_replacement)} if redact\n $stdout << line\n File.open(tee,'a') {|f| f.write(line) } if tee\n end\n end\n end\n # Don't exit until the external process is done\n external.join\n end\n if $?.to_i > 0 # $? is command exit code (posix style)\n raise Capistrano::LocalArgumentError, \"Command #{cmd_text} returned status code #{$?}\"\n end\n end\n $stdout.sync = false\n logger.trace \"\\ncommand finished in #{(elapsed * 1000).round}ms\" if logger\n end", "def run_command(command)\n command = \"true\" if command.to_s.strip.empty?\n with_shell_instance do\n stdin.puts wrapped_command(command)\n stdin.close\n out, err = stdout.read, stderr.read\n out, status, _ = raw_stdout_to_parts(out)\n return status, out, err\n end\n end", "def capture_stdout(*command, dir: repo_cache_dir)\n success, output = Samson::CommandExecutor.execute(\n *command,\n whitelist_env: ['HOME', 'PATH'],\n timeout: 30.minutes,\n err: '/dev/null',\n dir: dir\n )\n output.strip if success\n end", "def run_for_output(cmd)\n LOG.debug \"RUNNING (for output): #{cmd}\"\n out, _status = Open3.capture2e(cmd)\n out.strip\n end", "def run_and_output(cmd)\n run(cmd).output\n end", "def run_shell( command, opts = {} )\n opts = opts.merge( dryrun: true, coalesce: false, accept: [0] )\n args = sh_args( command, opts )\n capture_stream( args, host, :sh, opts )\n @commands << args\n nil\n end", "def sh_out(cmd, fail = true, stdin = '')\n r_in, w_in = IO.pipe\n r_out, w_out = IO.pipe\n r_err, w_err = IO.pipe\n w_in.write(stdin)\n w_in.close\n pid = Process.spawn(cmd, in: r_in, out: w_out, err: w_err)\n Process.wait(pid)\n\n r_in.close\n w_out.close\n w_err.close\n stdout = r_out.read\n r_out.close\n stderr = r_err.read\n r_err.close\n\n if fail && $CHILD_STATUS.exitstatus != 0\n raise CommandError, \"`#{cmd}` exited #{$CHILD_STATUS.exitstatus}\\n\" \\\n \"stdout:\\n\" \\\n \"#{stdout}\\n\" \\\n \"stderr:\\n\" \\\n \"#{stderr}\\n\"\n end\n stdout\n end", "def system_run(cmd, o={})\n opts = {:quiet => false, :sysread => 1024}.merge(o)\n buf = \"\"\n ddputs(\"Running command: #{cmd}\")\n Open3.popen3(cmd) do |stdout, stdin, stderr|\n begin\n while (chunk = stdin.readpartial(opts[:sysread]))\n buf << chunk\n unless chunk.nil? || chunk.empty?\n $stdout.write(chunk) #if debugging? || verbose?\n end\n end\n err = stderr.readlines\n $stderr.write_nonblock(err)\n rescue SystemCallError => error\n err = stderr.readlines\n $stderr.write_nonblock(err)\n rescue EOFError => error\n err = stderr.readlines\n $stderr.write_nonblock(err)\n # used to do nothing\n end\n end\n buf\n end", "def shell_execute(command)\n require 'open3'\n stdout, stderr, status = Open3.capture3(command.chomp)\n if status.success? && status.exitstatus.zero?\n stdout\n else\n msg = \"Shell command failed: [#{command}] caused by <STDERR = #{stderr}>\"\n msg << \" STDOUT = #{stdout}\" if stdout && stdout.length.positive?\n raise(StandardError, msg)\n end\n rescue SystemCallError => e\n msg = \"Shell command failed: [#{command}] caused by #{e.inspect}\"\n raise(StandardError, msg)\n end", "def run_cmd(cmd)\n Chef::Log.info \"executing: #{cmd}\"\n result = Mixlib::ShellOut.new(cmd).run_command.stdout.strip\n return result\nend", "def run(*command)\n IO.popen(command) { |io| io.read.strip }\n end", "def run_shell(command, env: {}, stdin_data: '')\n # If we're passed a string, convert it to an array beofre passing to capture3\n command = command.split unless command.is_a?(Array)\n Salus::ShellResult.new(*Open3.capture3(env, *command, stdin_data: stdin_data))\n end", "def shell_out(command)\n process_status, out, err = jruby? ? jruby_out(command) : mri_out(command)\n Response.new(process_status, out, err)\n end", "def run(command)\n display command.join(\" \")\n\n IO.popen(command + [err: %i[child out]]) do |io|\n __display(io.read(128), partial: true, verbose: true) until io.eof?\n end\n\n fail StandardError, \"Error running '#{command.join(\" \")}'\" unless $?.success?\n end", "def run\n out = \"\"\n\n begin\n PTY.spawn(command) do |stdout, stdin, pid|\n begin\n stdout.each do |line|\n out << line.strip+\"\\n\"\n print line if @tee\n end\n rescue Errno::EIO\n #Errno:EIO error probably just means that the process has finished giving output\n end\n Process.wait(pid)\n end\n rescue PTY::ChildExited\n # The child process has exited.\n end\n\n if $?.exitstatus == 0\n return Parser.parse(out) if @parse\n return out\n else\n raise \"httperf exited with status #{$?.exitstatus}\\n\\nhttperf output:\\n--------------\\n#{out}\"\n end\n end", "def shell(*cmd, &block)\n options = (Hash === cmd.last) ? cmd.pop : {}\n options[:verbose] = false\n command = cmd.first\n puts \"Running #{command} via Rake sh\"\n sh command, options, &block\n end", "def exec(command)\n cmd = Open3.popen3(command) do |i, o, e|\n i.close\n t0 = Thread.new do\n o.each_line do |line|\n $stdout.puts \" \" << line\n end\n end\n t1 = Thread.new do\n e.each_line do |line|\n $stderr.puts \" \" << line\n end\n end\n t0.join\n t1.join\n end\n end", "def command_output(stream=nil)\n case stream\n when 'stdout'\n command_stdout\n when 'stderr'\n command_stderr\n else\n \"#{command_stdout}\\n#{command_stderr}\"\n end\n end", "def execute(command)\n #2>&1 Redirect standard error to standard output\n system(\"#{command} > #{OUTPUT} 2>&1\")\n puts File.read(OUTPUT) if SHOW_OUTPUT\nend", "def run_command(cmd, *args)\n r,w = IO.pipe\n\n pid = fork do\n r.close\n STDIN.close\n STDOUT.reopen(w)\n STDERR.reopen(w)\n\n exec(cmd, *args)\n end\n\n w.close\n output = r.read.force_encoding('binary')\n pid, status = Process::wait2(pid)\n\n [output, status]\n end", "def command(command)\n IO.pipe do |read_io, write_io|\n pid = Process.spawn(command, :in => \"/dev/tty\", :out => write_io)\n Process.wait(pid)\n raise \"Command failed: #{command.inspect}\" unless $?.success?\n write_io.close\n read_io.read\n end\n end", "def out(command)\n assert(system(command))\n end", "def sh(cmd, opts = {})\n opts = DEFAULT_SH_OPTS.merge(opts)\n cmd = [cmd] if cmd.is_a?(String)\n puts cmd.join(' ') if opts[:echo]\n exit_status = nil\n if opts[:tty]\n exit_status = system(*cmd) ? 0 : -1\n else\n out, status = Open3.capture2(*cmd)\n puts out if opts[:output]\n exit_status = status.exitstatus\n end\n raise \"Failed to execute '#{cmd.join(' ')}' (#{exit_status})\" unless exit_status == 0\n end", "def run_command(shell, whether_show_log=true, whether_reject_empty=true)\n result = IO.popen(shell) do |stdout| \n stdout.readlines#.reject(&method) \n end.map { |l| l.is_a?(String) ? string_format(l) : l }\n status = $?.exitstatus.zero?\n if !status or whether_show_log\n shell = string_format(shell).split(/\\n/).map { |line| \"\\t`\" + line + \"`\" }.join(\"\\n\")\n result = [\"bash: no output\"] if result.empty?\n if result.length > 100\n resstr = \"\\t\\tbash: output line number more than 100 rows.\"\n else\n resstr = result.map { |line| \"\\t\\t\" + line }.join\n end\n puts \"%s\\n\\t\\t==> %s\\n%s\\n\" % [shell, status, resstr]\n end\n return result.unshift(status)\n end", "def shell(command, output: false)\n command += ' > /dev/null 2>&1' if !output\n system(command)\nrescue => e\n lex(e, \"Failed to execute shell command: #{command}\")\nend", "def execute_command(command)\n @stdin.puts command\n end", "def run(command)\n wait_until_done if running?\n setup_environment\n begin\n @command = command.dup\n @status = nil\n words = Shellwords.shellwords(command)\n @pid, @stdin, stdout, stderr = Open4.popen4(*words)\n @standard_output = Stream.new(self, 'standard output', stdout)\n @standard_error = Stream.new(self, 'standard error' , stderr)\n self\n ensure\n teardown_environment\n end\n end", "def run_command(shell, whether_show_log=true, whether_reject_empty=true)\n result = IO.popen(shell) do |stdout| \n stdout.readlines#.reject(&method) \n end.map { |l| l.is_a?(String) ? string_format(l) : l }\n status = $?.exitstatus.zero?\n if !status or whether_show_log\n shell = string_format(shell).split(/\\n/).map { |line| \"\\t`\" + line + \"`\" }.join(\"\\n\")\n resstr = (result || [\"bash: no output\"]).map { |line| \"\\t\\t\" + line }.join\n puts \"%s\\n\\t\\t==> %s\\n%s\\n\" % [shell, status, resstr]\n end\n return result.unshift(status)\n end", "def execute_shell(command, input = nil)\n Open3.popen3(command) do |stdin, stdout, stderr, thrd|\n stdin.puts input unless input.nil?\n stdin.close\n SystemCallError.new(\"Error invoking #{command}, #{stderr.read}\", thrd.value.exitstatus)\n out = stdout.read\n end\n rescue Errno::EPIPE\n \"\"\n end", "def |(cmd)\n IO.popen(cmd.to_s, 'r+') do |pipe|\n pipe.write(self)\n pipe.close_write\n pipe.read.strip\n end\n end", "def remote_shell args\n remote(args) do |ssh|\n command = true\n while command\n print \"> \"\n command = gets\n if command\n result = ssh.exec! command\n puts result.split(\"\\n\").awesome_inspect if not result.nil?\n end\n end\n ssh.exec! \"exit\"\n end\n end", "def run(command)\n if !command.kind_of?(Array)\n cmd = [command]\n else\n cmd = command\n end\n\n cmd.each { |line|\n puts line\n IO.popen(line) { |io|\n io.each_char do |c|\n print c\n end\n }\n }\n\nend", "def streamed_api_command(command, stdin = nil, *args, &block)\n command, args = prepare_command_args(command, args)\n i, o, t = Open3.popen2(command, *args)\n i.puts(stdin) unless stdin.blank? # If we have any input, send it to the child\n i.close # Afterwards we can close child's stdin\n if block_given?\n o.each_line do |line|\n yield line\n end\n o.close\n raise \"#{command} failed\" unless t.value.success?\n else\n return o, t # The caller has to close o and wait for t\n end\n end", "def exec_command(command)\n log = ''\n puts \"\\n=> Executing \\\"#{command}\\\"\"\n log += \"\\n\\n=> Executing \\\"#{command}\\\"\\n\"\n Open3.popen2e(command) { |stdin, stdout_and_stderr, wait_thr|\n stdout_and_stderr.each {|line|\n puts line\n log += line\n }\n }\n return log\nend", "def run_command(*command)\n\t\t\t#stdout, stderr, status\n\t\t\treturn Open3.capture3(*command)\n\t\tend", "def shell(cmd)\n `#{cmd}`\n end", "def shell(cmd)\n `#{cmd}`\n end", "def run(command, chdir: nil)\n chdir_label = \" (#{chdir})\" if chdir\n puts \"Running command: #{command}#{chdir_label}\"\n read, write = IO.pipe\n options = { [:out, :err] => write }\n options[:chdir] = chdir if chdir\n pid = spawn command, options\n output_lines = []\n thread =\n Thread.new do\n while line = read.readline # rubocop:disable Lint/AssignmentInCondition\n # Output lines as the program runs\n puts \"| #{line}\"\n # Store the output for later\n output_lines << line\n end\n rescue EOFError\n # Do nothing, nothing to read anymore\n end\n _pid, status = Process.wait2 pid\n write.close\n thread.join\n output = output_lines.join\n raise CommandFailed.new(command, output) unless status.success?\n\n puts\n output\nend", "def run_program(cmd, input = \"\")\n stdout, = Open3.capture2e(shell_out_env, *cmd, stdin_data: input)\n\n stdout\n end", "def run\n begin\n IO.popen(@cmd_line).read\n rescue\n @logger.error(\"Failed to execute command on #{@host}\")\n \"\"\n end\n end", "def shell_out_command(cmd, msg)\n cmd_local = \"#{cmd}\" + \" -c #{knife_config}\" + \"#{grep_cmd}\"\n shell_out = Mixlib::ShellOut.new(\"#{cmd_local}\", :timeout => timeout)\n puts \"#{msg}\"\n puts \"#{cmd_local}\"\n @op = shell_out.tap(&:run_command).stdout\n puts \"#{cmd_stdout}\"\n return shell_out\n end", "def run(command,use_shell=true,working_dir=\"C:\\\\\",forward_to_standard_out=true)\n\tif command.strip.empty?\n\t\traise \"No command provided to run()\"\n\tend\n\n\t# Necessary if command take advantage of any shell features such as\n\t# IO piping\n\tif use_shell\n\t\tcommand = \"cmd /S /C \\\"#{command}\\\"\"\n\tend\n\n\toutput = []\n\tp = nil\n\n\tbegin\n\t\tputs \"Executing: #{command}\"\n\t\tp = Runtime.getRuntime.exec(command,[].to_java(:string),java.io.File.new(working_dir))\n\n\t\t# Read error stream\n\t\tstd_err_reader = BufferedReader.new(InputStreamReader.new(p.getErrorStream))\n\t\twhile ((line = std_err_reader.readLine()).nil? == false)\n\t\t\tputs line if forward_to_standard_out\n\t\tend\n\n\t\tp.waitFor\n\t\tputs \"Execution completed\"\n\t\treader = BufferedReader.new(InputStreamReader.new(p.getInputStream))\n\t\twhile ((line = reader.readLine()).nil? == false)\n\t\t\tputs line if forward_to_standard_out\n\t\t\toutput << \"#{line}\"\n\t\tend\n\trescue Exception => e\n\t\tputs e.message\n\t\tputs e.backtrace.inspect\n\tensure\n\t\tp.destroy if !p.nil?\n\tend\n\treturn output.join(\"\\n\")\nend", "def get_command_output(shell_id, command_id, &block)\r\n body = { \"#{NS_WIN_SHELL}:DesiredStream\" => 'stdout stderr',\r\n :attributes! => {\"#{NS_WIN_SHELL}:DesiredStream\" => {'CommandId' => command_id}}}\r\n\r\n builder = Builder::XmlMarkup.new\r\n builder.instruct!(:xml, :encoding => 'UTF-8')\r\n builder.tag! :env, :Envelope, namespaces do |env|\r\n env.tag!(:env, :Header) { |h| h << Gyoku.xml(merge_headers(header,resource_uri_cmd,action_receive,selector_shell_id(shell_id))) }\r\n env.tag!(:env, :Body) do |env_body|\r\n env_body.tag!(\"#{NS_WIN_SHELL}:Receive\") { |cl| cl << Gyoku.xml(body) }\r\n end\r\n end\r\n\r\n resp_doc = nil\r\n request_msg = builder.target!\r\n done_elems = []\r\n output = Output.new\r\n\r\n while done_elems.empty?\r\n resp_doc = send_get_output_message(request_msg)\r\n\r\n REXML::XPath.match(resp_doc, \"//#{NS_WIN_SHELL}:Stream\").each do |n|\r\n next if n.text.nil? || n.text.empty?\r\n\r\n # decode and strip off BOM which win 2008R2 applies\r\n stream = { n.attributes['Name'].to_sym => Base64.decode64(n.text).force_encoding('utf-8').sub(\"\\xEF\\xBB\\xBF\", \"\") }\r\n output[:data] << stream\r\n yield stream[:stdout], stream[:stderr] if block_given?\r\n end\r\n\r\n # We may need to get additional output if the stream has not finished.\r\n # The CommandState will change from Running to Done like so:\r\n # @example\r\n # from...\r\n # <rsp:CommandState CommandId=\"...\" State=\"http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running\"/>\r\n # to...\r\n # <rsp:CommandState CommandId=\"...\" State=\"http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done\">\r\n # <rsp:ExitCode>0</rsp:ExitCode>\r\n # </rsp:CommandState>\r\n done_elems = REXML::XPath.match(resp_doc, \"//*[@State='http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done']\")\r\n end\r\n\r\n output[:exitcode] = REXML::XPath.first(resp_doc, \"//#{NS_WIN_SHELL}:ExitCode\").text.to_i\r\n output\r\n end", "def system_command(*command_args)\n cmd = Mixlib::ShellOut.new(*command_args)\n cmd.run_command\n cmd\n end", "def execute\n begin\n rout, wout = IO.pipe\n rerr, werr = IO.pipe\n stdout, stderr = nil\n\n pid = Process.spawn(command_line, :pgroup => true, :out => wout, :err => werr)\n Timeout.timeout(timeout) do\n Process.wait(pid)\n\n wout.close\n werr.close\n\n stdout = rout.readlines.join\n stderr = rerr.readlines.join\n end\n rescue Timeout::Error\n Process.kill(-9, pid)\n Process.detach(pid)\n ensure\n wout.close unless wout.closed?\n werr.close unless werr.closed?\n\n rout.close\n rerr.close\n end\n stdout\n end", "def system_command(*command_args)\n cmd = Mixlib::ShellOut.new(*command_args)\n cmd.run_command\n cmd\n end", "def run_shell(command, env: {}, stdin_data: '')\n # If we're passed a string, convert it to an array beofre passing to capture3\n command = command.split unless command.is_a?(Array)\n\n stdout, stderr, exit_status = Open3.capture3(env, *command, stdin_data: stdin_data)\n { stdout: stdout, stderr: stderr, exit_status: exit_status }\n end", "def run_cmd(cmd)\n process = session.sys.process.execute(cmd, nil, {'Hidden' => true, 'Channelized' => true})\n res = \"\"\n while (d = process.channel.read)\n break if d == \"\"\n res << d\n end\n process.channel.close\n process.close\n return res\n end", "def run command, *args\n formatted = Report.format_command_line command, *args\n write \">>> #{formatted}\\n\"\n Report.run_capturing_output(command, *args) do |data|\n write data\n end\n end", "def run_cmd(cmd)\n ret = \"\"\n start = Time.now.to_i\n log_and_stream \"<div class='command'><h4>Running #{cmd}</h4><p class='output'>\"\n time = Benchmark.measure do\n Open3.popen3(cmd) do |inn, out, err|\n output = \"\"\n until out.eof?\n # raise \"Timeout\" if output.empty? && Time.now.to_i - start > 300\n chr = out.read(1)\n output << chr\n ret << chr\n if chr == \"\\n\" || chr == \"\\r\"\n log_and_stream output + \"<br>\"\n output = \"\"\n end\n end\n log_and_stream(output) unless output.empty?\n log_and_stream(\"<span class='stderr'>STDERR: #{err.read}</span><br>\") unless err.eof?\n end\n end\n log_and_stream \"</p>\"\n log_and_stream \"<h5>Time: #{time}</h5></div>\"\n return ret\n end", "def pipe(*cmd, stdin: nil)\n IO.popen(cmd, \"r+\", err: %i[child out]) do |io|\n io.write stdin if stdin\n io.close_write\n io.read\n end\nend", "def stdout(command, data)\n # called when the process writes to STDOUT\n end", "def run(shell, cmd, &blk)\n run_on_servers(shell, 'sh -l -c', cmd, &blk)\n end", "def capture_shell( command, opts = {} )\n accept = opts[ :accept ] || [ 0 ]\n opts = opts.merge( dryrun: true, coalesce: false, accept: [0] )\n args = sh_args( command, opts )\n capture_stream( args, host, :sh, opts )\n @commands << args\n [ accept[ rand( accept.length ) ], \"\" ]\n end", "def run_cmd(command, prompt=@prompt)\n msg \"run command #{command}\"\n @pipe.write(\"#{command}\\r\")\n response = @pipe.readline(prompt)\n @pipe.close\n return response\n end", "def spawn(cmd)\n log \">> #{cmd}\"\n\n cmd += ' 2>&1'\n output = \"\"\n PTY.spawn cmd do |r, _w, pid|\n begin\n r.sync\n r.each_char do |chr|\n STDOUT.write(chr) unless @options[:quiet]\n output << chr\n end\n rescue Errno::EIO\n # simply ignoring this\n ensure\n ::Process.wait pid\n end\n end\n abort \"#{cmd} failed, exit code #{$? && $?.exitstatus}\" unless $? && $?.exitstatus == 0\n\n output.strip\n end", "def capture_command_output(*command, **kwargs, &block)\n # Default block returns what's passed in\n block ||= -> line { line }\n IO.popen(command.flatten, **kwargs) { |io| io.each_line { |line| print block.call(line) } }\n end", "def run_shell(command, env: {}, stdin_data: '',\n chdir: File.expand_path(@repository&.path_to_repo))\n # If we're passed a string, convert it to an array before passing to capture3\n command = command.split unless command.is_a?(Array)\n Salus::PluginManager.send_event(:run_shell, command, chdir: chdir)\n # chdir: '/some/directory'\n opts = { stdin_data: stdin_data }\n opts[:chdir] = chdir unless chdir.nil? || chdir == \".\"\n Salus::ShellResult.new(*Open3.capture3(env, *command, opts))\n end", "def shell_command(cmd, timeout = 1800)\n # insert random marker\n strm = Rex::Text.rand_text_alpha(15)\n endm = Rex::Text.rand_text_alpha(15)\n\n # Send the shell channel's stdin.\n shell_write(\";'#{strm}'\\n\" + cmd + \"\\n'#{endm}';\\n\")\n\n etime = ::Time.now.to_f + timeout\n\n buff = \"\"\n # Keep reading data until the marker has been received or the 30 minture timeout has occured\n while (::Time.now.to_f < etime)\n res = shell_read(-1, timeout)\n break unless res\n timeout = etime - ::Time.now.to_f\n\n buff << res\n if buff.include?(endm)\n # if you see the end marker, read the buffer from the start marker to the end and then display back to screen\n buff = buff.split(/#{strm}\\r\\n/)[-1]\n buff = buff.split(endm)[0]\n buff.gsub!(/(?<=\\r\\n)PS [^>]*>/, '')\n return buff\n end\n end\n buff\n end", "def system cmd, *args\n ohai \"#{cmd} #{args*' '}\".strip\n\n if ARGV.verbose?\n safe_system cmd, *args\n else\n rd, wr = IO.pipe\n pid = fork do\n rd.close\n $stdout.reopen wr\n $stderr.reopen wr\n exec(cmd, *args) rescue nil\n exit! 1 # never gets here unless exec threw or failed\n end\n wr.close\n out = ''\n out << rd.read until rd.eof?\n Process.wait\n unless $?.success?\n puts out\n raise\n end\n end\n rescue SystemCallError\n # usually because exec could not be find the command that was requested\n raise\n rescue \n raise BuildError.new(cmd, args, $?)\n end", "def exec(cmd)\n container.exec(cmd) { |_, chunk| puts \"#{fqdn.purple}: #{chunk}\" }\n end", "def run_command_script(command)\n Open3.popen2e(\"ruby #{command}\") do |stdin, stdout_err|\n while line = stdout_err.gets\n puts line\n end\n end\n end", "def `(cmd)\n $shell_result\n end", "def exec_hadoop_streaming\n $stderr.puts \"Streaming on self\"\n input_path, output_path = input_output_paths\n command = runner_command(input_path, output_path)\n $stderr.puts command\n unless options[:dry_run]\n maybe_overwrite_output_paths! output_path\n $stdout.puts `#{command}`\n end\n end", "def run(cmd)\n Open3.popen3(*cmd) do |i, o, e, t|\n i.close\n t.value\n end\n end", "def command(command, *args)\n @shell.command(command, *args)\n end", "def shell(*) end", "def run_cmd(command, arguments = [], &block)\n shell_id = open_shell\n command_id = run_command(shell_id, command, arguments)\n command_output = get_command_output(shell_id, command_id, &block)\n cleanup_command(shell_id, command_id)\n close_shell(shell_id)\n command_output\n end", "def shell_out!(*command_args)\n cmd = shell_out(*command_args)\n cmd.error!\n cmd\n end", "def with_filter(command)\n io = IO.popen(command, 'r+')\n yield io.method(:puts)\n\n io.close_write\n io.readlines.map(&:chomp)\nend", "def do_shell(line)\n shell = ENV['SHELL']\n line ? write(%x(#{line}).strip) : system(shell)\n end", "def scm_run(command)\n run(command) do |ch,stream,text|\n ch[:state] ||= { :channel => ch }\n output = source.handle_data(ch[:state], stream, text)\n ch.send_data(output) if output\n end\n end", "def sh(cmd)\n\t# Print the command to stdout.\n\tif(cmd.is_a?(Array))\n\t\tp cmd\n\telse\n\t\tputs cmd\n\tend\n\t# Run it.\n\tsuccess = system(cmd)\n\traise \"Command failed\" unless(success)\nend", "def exec(command, &on_output)\n status = nil\n shell.execute(command) do |process|\n process.on_output(&on_output)\n process.on_error_output(&on_output)\n process.on_finish { |p| status = p.exit_status }\n end\n shell.session.loop(1) { status.nil? }\n status\n end", "def get_from_shell_cmd(cmd, proc_id)\n stdout, stderr, status = Open3.capture3(cmd)\n if not status.success?\n cancel_job(\"error executing command '#{cmd}' - #{stderr}\", proc_id)\n end\n return stdout.strip!\nend", "def run_cmd(command, arguments = [], &block)\r\n command_output = nil\r\n open_shell do |shell_id|\r\n run_command(shell_id, command, arguments) do |command_id|\r\n command_output = get_command_output(shell_id, command_id, &block)\r\n end\r\n end\r\n command_output\r\n end", "def run_command_via_connection(command)\n command = command.shelljoin if command.is_a? Array\n command = ['sh', '-c', command]\n res = lxd.execute(command)\n CommandResult.new res.stdout, res.stderr, res.exitstatus\n end", "def shell_commands(cmd, args); end", "def run_command(cmd)\n IO.popen(cmd) do |f|\n while ! f.eof\n puts f.gets\n end\n end\n $?\n end", "def run(stdout = :dev_null, stderr = :dev_null)\n stdout = %w(/dev/null w) if stdout == :dev_null\n stderr = %w(/dev/null w) if stderr == :dev_null\n\n File.write(stdout[0], \"#{cmd}\\n\\n\") if stdout.is_a?(Array) && stdout[1] == 'a'\n\n @subexec = Subexec.run cmd, subexec_options.merge(stdout: stdout, stderr: stderr)\n end", "def run(cmd)\n runner.run(cmd, shell, nil)\n end", "def run(cmd)\n puts(cmd)\n system(cmd)\nend", "def do_shell(cmd)\n puts \"[METASIM]:#{Dir.pwd}$ #{cmd}\"\n raise \"Shell command failure\" unless system(cmd)\nend", "def run_in_pty(cmd, dir)\n result = ''\n PTY.spawn(\"cd #{dir.realpath}; #{cmd}\") do |stdout, stdin, pid|\n begin\n stdout.each { |line| result += line }\n rescue Errno::EIO #Done getting output\n result\n end\n end\n result\n end", "def cmd(str)\n\t\t@pipe.puts str\n\tend", "def run(command)\n result = connection.exec!(command)\n puts \"[BEGIN #{@host}: #{command}]\"\n puts \" #{result}\"\n puts \"[END #{@host}: #{command}]\"\n end", "def run command\n # unless command\n # command = \" \\\"#{@args.join(\"\\\" \\\"\")}\\\"\" if args.any?\n # @switches.each{ |opt| command += \" --#{opt.to_s}\" }\n # @options.each { |opt, val| command += \" --#{opt.to_s} \\\"#{val}\\\"\" }\n # end\n return if command.nil? || command.strip.empty?\n command += \" 2>&1\"\n command += \" >/dev/null\" unless @capture || @output\n\n output = `#{self.path} #{command}`.strip\n puts output.gsub(/^/, \" -- \") if @output\n\n self.reset_for_next_command\n output\n end", "def execute(command_array, with_stderr = false)\n command_array << \"2>/dev/null\" unless with_stderr\n command_array << \"2>&1\" if with_stderr\n command = command_array.join(\" \")\n\n output = []\n IO::popen command do |f|\n line = \"\"\n f.each_char do |c|\n if \"\\n\" == c || \"\\r\" == c\n output << line\n yield line if block_given?\n line = \"\"\n else\n line << c\n end\n end\n output << line\n end\n output\nend", "def sh( cmd )\n out, cmd = Open3.capture2e cmd\n yield out if !cmd.success?\n end", "def shell(commands = [])\n begin\n command = commands.join(' ')\n stdin, _stderr, _status = Open3.capture3(command)\n rescue => e\n raise \"Problem processing #{command}, #{e.message}\"\n end\n stdin\n end", "def call_command_local_popen(cmd, query = nil)\n str = make_command_line(cmd)\n IO.popen(str, \"w+\") do |io|\n if block_given? then\n io.sync = true\n yield io, io\n else\n io.sync = true\n io.print query if query\n io.close_write\n io.read\n end\n end\n end", "def system_exec(cmd)\n Open3.popen3(RSpec::Support::Env.env, cmd) do |stdin, stdout, stderr, wait_thr|\n yield stdin, stdout, wait_thr if block_given?\n stdin.close\n\n @exitstatus = wait_thr && wait_thr.value.exitstatus\n @out = Thread.new { stdout.read }.value.strip\n @err = Thread.new { stderr.read }.value.strip\n end\n\n (@all_output ||= \"\") << [\n \"$ #{cmd.to_s.strip}\",\n out,\n err,\n @exitstatus ? \"# $? => #{@exitstatus}\" : \"\",\n \"\\n\"\n ].reject(&:empty?).join(\"\\n\")\n\n @out\n end", "def get_command_output(shell_id, command_id, &block)\r\n done_elems = []\r\n output = Output.new\r\n\r\n while done_elems.empty?\r\n resp_doc = nil\r\n builder = get_builder_obj(shell_id, command_id, &block)\r\n request_msg = builder.target!\r\n resp_doc = send_get_output_message(request_msg)\r\n\r\n REXML::XPath.match(resp_doc, \"//#{NS_WIN_SHELL}:Stream\").each do |n|\r\n next if n.text.nil? || n.text.empty?\r\n stream = { n.attributes['Name'].to_sym => Base64.decode64(n.text).force_encoding('utf-8').sub(\"\\xEF\\xBB\\xBF\", \"\") }\r\n output[:data] << stream\r\n yield stream[:stdout], stream[:stderr] if block_given?\r\n end\r\n\r\n # We may need to get additional output if the stream has not finished.\r\n # The CommandState will change from Running to Done like so:\r\n # @example\r\n # from...\r\n # <rsp:CommandState CommandId=\"...\" State=\"http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running\"/>\r\n # to...\r\n # <rsp:CommandState CommandId=\"...\" State=\"http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done\">\r\n # <rsp:ExitCode>0</rsp:ExitCode>\r\n # </rsp:CommandState>\r\n done_elems = REXML::XPath.match(resp_doc, \"//*[@State='http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done']\")\r\n end\r\n output[:exitcode] = REXML::XPath.first(resp_doc, \"//#{NS_WIN_SHELL}:ExitCode\").text.to_i\r\n output\r\n end", "def exec(command)\n #logger.debug { \"Github: Executing command: '#{command}'\" }\n #p \"Github: Executing command: '#{command}'\"\n \n # Get a path to a temp file\n #logfile = Tempfile.new('github__exec')\n #logfile.close\n \n #success = system(\"#{command} > #{logfile.path} 2>&1\")\n #output_from_command = File.readlines(logfile.path)\n #output_from_command = %x[command]\n shell = Shell.new(command)\n shell.run\n success = (shell.exitstatus == 0)\n output_from_command = shell.output\n if success\n #logger.debug { \"Github: Command output: #{output_from_command.inspect}\"}\n #p \"Github: Command output: #{output_from_command.inspect}\"\n return output_from_command\n else\n #logger.error { \"Github: Command '#{command}' didn't exit properly. Full output: #{output_from_command.inspect}\"}\n p \"Github: Command failed '#{command}' didn't exit properly. Full output: #{output_from_command.inspect}\"\n end\n \n #ensure\n #logfile.unlink\n end", "def run(command, options = {:desc => '', :get_output_string => false})\n puts options[:desc]\n puts \"Executing: #{command}\"\n\n if options[:get_output_string]\n result = `#{command}`\n else\n command << \" > /dev/null\" if command # Not show output details to stdout\n result = system(command)\n end\n\n report(result)\n end", "def exec_cmd cmd\n t = Time.now\n results = \"\"\n @ssh.open_channel do |channel|\n channel.exec(cmd) do |ch,success|\n unless success\n Logger.<<(__FILE__,\"INFO\",\"Could Not execute command #{cmd}\")\n abort\n end\n # stdout\n channel.on_data do |ch,data|\n results += data\n end\n # stderr\n channel.on_extended_data do |ch,type,data|\n Logger.<<(__FILE__,\"ERROR\",\"Error from the cmd #{cmd} : #{data}\")\n abort\n end\n channel.on_close do |ch|\n end\n end\n end\n # wait for the command to finish\n @ssh.loop\n Logger.<<(__FILE__,\"DEBUG\",\"SFTP Command executed in #{Time.now - t} sec\") if @opts[:v]\n results.split\n end" ]
[ "0.73853344", "0.70910066", "0.6960645", "0.6930949", "0.6858384", "0.67822677", "0.67751426", "0.6771282", "0.67387", "0.6719041", "0.67178994", "0.6708008", "0.66929185", "0.6685716", "0.66768575", "0.66759187", "0.6675779", "0.6663482", "0.6657783", "0.6644214", "0.6625352", "0.6615171", "0.66112804", "0.66096884", "0.6575943", "0.65503746", "0.6549867", "0.6540093", "0.65315986", "0.65178937", "0.65147", "0.65082234", "0.64896977", "0.647849", "0.6474712", "0.64663947", "0.64396244", "0.6426242", "0.64245296", "0.6417314", "0.6417314", "0.64057106", "0.6404403", "0.63981503", "0.63967675", "0.6380261", "0.63697743", "0.6365879", "0.6355892", "0.63536817", "0.6348587", "0.63293135", "0.6317644", "0.6306062", "0.63015985", "0.62879395", "0.6272843", "0.6268475", "0.62610525", "0.6256165", "0.62468183", "0.62443054", "0.6241885", "0.6234803", "0.62324834", "0.6215594", "0.62093735", "0.6200431", "0.61607796", "0.61578727", "0.6155028", "0.61390275", "0.6135007", "0.61337686", "0.6124419", "0.61224747", "0.6119553", "0.6114494", "0.61080414", "0.6094553", "0.6090295", "0.60888237", "0.6085582", "0.60836875", "0.6081317", "0.60667294", "0.6062488", "0.60615754", "0.60500556", "0.6048374", "0.60474557", "0.604732", "0.6043427", "0.6036628", "0.6034668", "0.6031308", "0.6029144", "0.60237163", "0.6021099", "0.6015377" ]
0.6895726
4
Comparison operator for sorting, if the distance and num_dims_used accessor is set on both entities before calling this then it is sorted by rating else it is sorted alphabetically.
def <=>(ent) return self.name <=> ent.name unless num_dims_used and ent.num_dims_used return 1 if num_dims_used == 0 and ent.num_dims_used > 0 return -1 if num_dims_used > 0 and ent.num_dims_used == 0 return 0 if num_dims_used == 0 and ent.num_dims_used == 0 ent.percent <=> self.percent end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def <=>( other)\n @rating <=> other.rating\n end", "def sort_by_size(x,y)\n sizes = [\"Small\",\"Medium\",\"Large\",\"X-Large\",\"2X-Large\",\"3X-Large\"]\n cmp = sizes.index(x.tshirt) <=> sizes.index(y.tshirt)\n if cmp == 0\n x.name <=> y.name\n else\n cmp\n end\n end", "def spaceship_alphabetisch(other)\r\n return nil unless self.class == other.class\r\n if (@name <=> other.name) == 0\r\n if (@strasse <=> other.strasse) == 0\r\n if (@plz <=> other.plz) == 0\r\n return @ort <=> other.ort\r\n end\r\n return @plz <=> other.plz\r\n end\r\n return @strasse <=> other.strasse\r\n end\r\n return @name <=> other.name\r\n end", "def <=> (other) #we will feed the \"type\" instance variable to the method MEDAL_VALUES\n if MEDAL_VALUES[self.type] < MEDAL_VALUES[other.type]\n -1\n elsif MEDAL_VALUES[self.type] == MEDAL_VALUES[other.type]\n 0\n else\n 1\n end\n end", "def render_order(entity, other)\n entity.id <=> other.id\n end", "def sort_by_rating(nearby_places)\n nearby_places.sort_by! {|place| place.values[0][:rating]}\n\n nearby_places.reverse\nend", "def sort_teams_and_adjs\n @teams.sort! { |a,b| b.calc_rank <=> a.calc_rank }\n @adjs.sort! { |a,b| b.score <=> a.score }\n\n #@teams.sort! { |a,b| b.score <=> a.score } #allows sorting by score only\n #expression is flipped in terms of a and b\n #therefore we have decending in teams by score\n end", "def <=>(other)\n (0..(self.dimension_count-1)).each do |d|\n cmp = self.value(d) <=> other.value(d)\n return cmp unless cmp == 0\n end\n self.object_id <=> other.object_id\n end", "def <=>(other)\n return -(hits <=> other.hits) if hits != other.hits\n\n # We want years to sort inverse, while we want others normal.\n return -(value <=> other.value) if field == :year\n (value <=> other.value)\n end", "def <=>(other)\n # If both elements are either nil or have content, compare by quality\n # value. Otherwise, rank the element with non-nil content higher than\n # +other+.\n if [ self, other ].select{ |x| x.content.nil? }.size % 2 == 0\n self.quality_val <=> other.quality_val\n else\n self.content.nil? ? -1 : 1\n end\n end", "def sort\n @hits = all.sort {|x,y| y.score <=> x.score }\n end", "def <=> (other)\n return nil unless other.is_a? Reference\n\n if self.authors?\n self_term = authors\n elsif self.source?\n self_term = source\n elsif self.title?\n self_term = title\n else\n return nil\n end\n\n if other.authors?\n other_term = other.authors\n elsif other.source?\n other_term = other.source\n elsif other.title?\n other_term = other.title\n else\n return nil\n end\n\n if self_term.is_a? PersonGroup and\n other_term.is_a? PersonGroup\n author_compare = self_term <=> other_term\n return author_compare unless author_compare.zero?\n\n year_compare = self.year <=> other.year\n return year_compare unless year_compare.zero?\n\n return self.source <=> other.source\n end\n\n if self_term.is_a? String and \n other_term.is_a? PersonGroup\n return compare_string_with_authors(self_term, other_term)\n end\n\n if self_term.is_a? PersonGroup and \n other_term.is_a? String\n return compare_string_with_authors(other_term, self_term)\n end\n end", "def compare(attr, statable)\r\n a = self.send(attr)\r\n\tb = statable.send(attr)\r\n#\treturn 0 if a.nil? || b.nil?\r\n\t\r\n\torder = StatSummary::STATS[attr][:order]\r\n\tif order == 1\r\n\t return (a || 10000) <=> (b || 10000)\r\n# return a <=> b\r\n\telse\r\n\t return (b || -1) <=> (a || -1)\r\n# return b <=> a\r\n\tend\r\n end", "def sort_drivers\n @drivers.sort! {|x, y| y.miles_driven <=> x.miles_driven}\n end", "def <=>(other)\n # if SUBJECT_POINTS[self.name] > SUBJECT_POINTS[other.name]\n # return 1\n # elsif SUBJECT_POINTS[self.name] < SUBJECT_POINTS[other.name]\n # return -1\n # else\n # return 0\n # end\n # shorter way to do this :O WOW! just tell which\n # things(quantities) to compare, and rubys comparable does it for you\n # so as long as the quantities you want to compare are builtin ones,\n # just call <=> straight instead of doing the if..elsif..else\n SUBJECT_POINTS[self.name] <=> SUBJECT_POINTS[other.name]\n end", "def sort_by_metric_title rel\n rel.joins(sort_join(\"right_id = sort.id\"))\n .order(\"sort.key #{@sort_args[:sort_order]}\")\n end", "def sort_by_decending_rating\n self.find_recipe_card_by_user.sort_by {|recipe| recipe.rating}.reverse\n end", "def comparer_methods\n super + [\n :min_rank\n ]\n end", "def sort_images_by_name\n add_join(:observation_images, :observations)\n add_join(:observations, :names)\n self.group = \"images.id\"\n \"MIN(names.sort_name) ASC, images.when DESC\"\n end", "def <=>(other)\n m = self.class.default_sort_method\n my_val = send(m)\n\n # other can be a string or a model of the same type as this model.\n other_val =\n if other.is_a?(::String)\n other\n elsif other.class == self.class\n other.send(m)\n else\n nil\n end\n\n my_val <=> other_val\n end", "def <=>(other)\n (attributes.keys - [:id]).map(&:to_s).sort.map(&:to_sym).inject(attributes[:id] <=> other.attributes[:id]) do |rc, key|\n if rc == 0\n attributes[key] <=> other.attributes[key] rescue 0\n else\n rc\n end\n end\n end", "def cmp?(other, operator)\n # check the attributes that are most likely to differ first\n unless repository.send(operator, other.repository)\n return false\n end\n\n unless model.send(operator, other.model)\n return false\n end\n\n unless conditions.send(operator, other.conditions)\n return false\n end\n\n unless offset.send(operator, other.offset)\n return false\n end\n\n unless limit.send(operator, other.limit)\n return false\n end\n\n unless order.send(operator, other.order)\n return false\n end\n\n unless fields.sort_by { |property| property.hash }.send(operator, other.fields.sort_by { |property| property.hash })\n return false\n end\n\n unless links.send(operator, other.links)\n return false\n end\n\n unless reload?.send(operator, other.reload?)\n return false\n end\n\n unless unique?.send(operator, other.unique?)\n return false\n end\n\n unless add_reversed?.send(operator, other.add_reversed?)\n return false\n end\n\n true\n end", "def order(*attrs)\n new(dataset.sort(*schema.project(*attrs).map(&:to_sort_expr)))\n end", "def <=> other\n #This is a stub, used for indexing\n end", "def <=> other\n if other.class == HD::Ratio\n return self[0].to_f / self[1] <=> other[0].to_f / other[1]\n elsif other.is_a? Numeric\n return self.to_f <=> other\n end\n end", "def sort_using_rank\n score[1]\n end", "def <=> other_allocation\n other_allocation.score <=> self.score\n end", "def <=>(other)\n compare = other.score <=> score\n return compare unless compare.zero?\n\n classification.number <=> other.classification.number\n end", "def compare(x,y)\n a = CachedProduct.find_by_product_id(x['product_id'].to_s)\n b = CachedProduct.find_by_product_id(y['product_id'].to_s)\n return a.max_small <=> b.max_small\n end", "def sort\n @items.sort { |x,y| x.rank <=> y.rank }\n end", "def <=>(other)\n # Bump one to the surface if it is conflicted and the other isn't\n #return -1 if (conflicted? and !other.conflicted?)\n #return 1 if (!conflicted? and other.conflicted?)\n comparison = (sort_level <=> other.sort_level)\n return comparison unless comparison == 0\n # Next sort by initialism, then meaning\n comparison = (initialism.downcase <=> other.initialism.downcase)\n return comparison unless comparison == 0\n meaning.downcase <=> other.meaning.downcase\n end", "def cmp (left_element, right_element)\n #puts left_element\n #puts right_element\n if @order == \"ASC\"\n if left_element[@order_column] < right_element[@order_column]\n return true\n else\n return false\n end\n else\n if left_element[@order_column] > right_element[@order_column]\n return true\n else\n return false \n end \n end\n end", "def <=>(other)\n # Descending order\n other.rank <=> @rank\n end", "def <=>(other)\n # Descending order\n other.rank <=> @rank\n end", "def <=>(other)\n # Descending order\n other.rank <=> @rank\n end", "def condition_sort(input)\n poke_name = input.poke_name\n product_db = SearchRecord::For.klass(Entity::Product)\n case input.sort\n when 'id'\n product_db.find_full_name(poke_name)\n when 'likes_DESC'\n product_db.order_by_desc_likes(poke_name)\n when 'likes_ASC'\n product_db.order_by_asc_likes(poke_name)\n when 'rating_DESC'\n product_db.order_by_desc_rating(poke_name)\n when 'rating_ASC'\n product_db.order_by_asc_rating(poke_name)\n when 'price_DESC'\n product_db.order_by_desc_price(poke_name)\n else\n # priceASC\n product_db.order_by_asc_price(poke_name)\n end\n end", "def ordering\n if params[:order]\n Hash[params[:order].values.map{ |ordering|\n [COLUMNS_TO_ORDER_FIELD[ordering[\"column\"].to_i], ordering[\"dir\"].to_sym]\n }]\n elsif params[:sort]\n params[:sort]\n else\n {_score: :desc}\n end\n end", "def <=>(other)\n return -1 if other.nil?\n return super unless other.is_a?(Category)\n return 0 if self[:id] && self[:id] == other[:id]\n diff = (position <=> other.position)\n if diff == 0\n name <=> other.name\n else\n diff\n end\n end", "def ordered_by_qualifications(candidates)\n if [:years_of_experience] == [:years_of_experience]\n @candidates.sort_by { |experience| experience[:years_of_experience] }.reverse\n else\n @candidates.sort_by { |github| github[:github_points]}.reverse\n end\nend", "def spaceship(left, right, **options)\n case\n # @see https://www.w3.org/TR/sparql11-query/#OperatorMapping\n # @see https://www.w3.org/TR/sparql11-query/#modOrderBy\n when left.is_a?(RDF::Literal) && right.is_a?(RDF::Literal)\n # @see https://www.w3.org/TR/xpath-functions/#string-compare\n # @see https://www.w3.org/TR/xpath-functions/#comp.numeric\n # @see https://www.w3.org/TR/xpath-functions/#op.boolean\n # @see https://www.w3.org/TR/xpath-functions/#comp.duration.datetime\n left <=> right\n when left.is_a?(RDF::URI) && right.is_a?(RDF::URI)\n raise TypeError, \"Comparing IRIs not supported\" unless options[:order_by] || left == right\n # Pairs of IRIs are ordered by comparing them as simple literals.\n left.to_s <=> right.to_s\n when left.is_a?(RDF::Node) && right.is_a?(RDF::Node)\n raise TypeError, \"Comparing Blank nodes not supported\" unless options[:order_by] || left == right\n # BNode comparison is undefined.\n left == right ? 0 : 1\n when left.nil? && right.nil?\n 0\n\n when left.is_a?(RDF::Statement) && right.is_a?(RDF::Statement)\n v = spaceship(left.subject, right.subject, **options)\n v = spaceship(left.predicate, right.predicate, **options) if v == 0\n v = spaceship(left.object, right.object, **options) if v == 0\n v\n when left.is_a?(RDF::Statement) && right.is_a?(RDF::Term)\n raise TypeError, \"Comparing statement with #{right.inspect}\" unless options[:order_by]\n 1\n when right.is_a?(RDF::Statement) && left.is_a?(RDF::Term)\n raise TypeError, \"Comparing statement with #{left.inspect}\" unless options[:order_by]\n -1\n\n # SPARQL also fixes an order between some kinds of RDF terms that would not otherwise be ordered:\n\n when left.nil? && !right.nil?\n -1\n when right.nil?\n 1\n\n when left.is_a?(RDF::Node) && right.is_a?(RDF::Term)\n raise TypeError, \"Comparing Blank nodes not supported\" unless options[:order_by]\n # Nodes lower than other terms\n -1\n when right.is_a?(RDF::Node) && left.is_a?(RDF::Term)\n raise TypeError, \"Comparing Blank nodes not supported\" unless options[:order_by]\n 1\n\n when left.is_a?(RDF::URI) && right.is_a?(RDF::Term)\n raise TypeError, \"Comparing IRIs not supported\" unless options[:order_by]\n # IRIs lower than terms other than nodes\n -1\n when right.is_a?(RDF::URI) && left.is_a?(RDF::Term)\n raise TypeError, \"Comparing IRIs not supported\" unless options[:order_by]\n 1\n else raise TypeError, \"expected two RDF::Term operands, but got #{left.inspect} and #{right.inspect}\"\n end\n end", "def compare_by_revelance(query, product1, product2)\n return 0 if query.blank?\n \n words = query.split(/[ \\t\\n\\r]/)\n \n name1 = product1.name.split(/[ \\t\\n\\r]/)\n hits1 = words.select {|word| name1.include?(word)}\n \n name2 = product2.name.split(/[ \\t\\n\\r]/)\n hits2 = words.select {|word| name2.include?(word)}\n \n hits1.size <=> hits2.size\n end", "def sort_using(xs, sidebar)\n # caching is possible but doesn't improve significantly the build times\n\n rank_lookup = rank_lookup_from_sidebar(sidebar)\n\n xs.sort {|x, y|\n # The default rank is very high so that pages that don't appear in the sidebar are put at the end\n rx = rank_lookup[x.url] || 10000\n ry = rank_lookup[y.url] || 10000\n\n rx <=> ry\n }\n\n end", "def sort_criteria\n @sort_criteria ||=\n sort_params.reduce('') do |sum, (key, value)|\n comparables = [\"a[:#{key}]\", \"b[:#{key}]\"]\n comparables.reverse! if value == :desc\n sum + \"comp = comp == 0 ? #{comparables.join(' <=> ')} : comp; \"\n end\n end", "def <=>(other)\n self.comparison_criteria <=> other.comparison_criteria\n end", "def <=>(other)\n # Assign 'points' to each type of tag. More 'important' tags have\n # higher point values.\n type_points = {\n general: 0,\n meta: 2,\n character: 4\n }\n # The different in point value between the tag types represents the\n # difference in sorting order.\n # - If this tag's type is more important, type_diff <= -2\n # - If the other's type is more important, type_diff >= 2\n # - If the types are the same, the points cancel out: type_diff == 0\n type_diff = type_points[other.type] -\n type_points[type]\n\n # If the types are different, type_diff will overshadow the name\n # comparison (which is -1, 0, or 1).\n comparison = (name <=> other.name) + type_diff\n # Clamp the result to -1, 0, 1\n comparison <=> 0\n end", "def ordered_by_qualifications(candidates)\n candidates.sort {|candidate1, candidate2| candidate1[:years_of_experience] == candidate2[:years_of_experience]? candidate2[:github_points] <=> candidate1[:github_points] : candidate2[:years_of_experience] <=> candidate1[:years_of_experience]}\nend", "def <=>(other)\n other.fitness <=> self.fitness\n end", "def <=>(other)\n cmp = self.x <=> other.x\n cmp = self.y <=> other.y if cmp == 0\n cmp = self.object_id <=> other.object_id if cmp == 0\n return cmp\n end", "def <=>(other)\n self.rank <=> other.rank\n end", "def <=>(other)\n size <=> other.size.zero? || rank <=> other.rank\n end", "def <=> (other)\n self.word <=> other.word\n end", "def ordered_by_qualifications (collection)\n collection.sort_by {|x| [x[:years_of_experience], x[:github_points]]}.reverse!\nend", "def <=>(other)\n @logger = Logger.new(\"#{Rails.root}/log/cache_read.log\")\n @logger.debug \"--sort: comparing: #{other.match_rate} vs #{@match_rate}\"\n return (other.match_rate <=> @match_rate)\n end", "def <(other)\n return false if self.cat != other.cat\n return self.feat < other.feat\n end", "def <=>(other)\n p 'comparing'\n legs <=> other.legs\n end", "def __sort_option__\n { name => operator }\n end", "def sort_by_fitness\n sort_by { |individual| individual.fitness }\n end", "def sort_weight\n if !ec? && (excellent_schools_grade == 'N/A' || excellent_schools_grade == 'New') && recommended?\n # Put Recommended schools that don't have a grade, between C+ and C schools\n 49.5\n else\n school_type_weight\n end\n end", "def <=>(other)\n score <=> other.score\n end", "def <=>(other)\n score <=> other.score\n end", "def sort_matched_arrays\n matched_arrays = [@matched_names, @matched_queries, @matched_tags,\n @matched_creator, @matched_modifier]\n matched_arrays.each do |array|\n array.joins(\"left join asq_statuses on asq_statuses.status_enum = \\\n asqs.status\")\n .order(\"disabled ASC, query_type ASC, \\\n asq_statuses.sort_priority ASC\")\n end\n end", "def <=>(other)\n if comparable_attrs.all? { |attr| send(attr) == other.send(attr) }\n if premium_tuples.to_a == other.premium_tuples.to_a\n 0\n else\n premium_tuples.to_a <=> other.premium_tuples.to_a\n end\n else\n other.updated_at.blank? || (updated_at < other.updated_at) ? -1 : 1\n end\n end", "def type_comparison(a, b)\n # Set the precendence for features\n type_order = [:exon,\n :intron,\n :CDS,\n :five_prime_UTR,\n :three_prime_UTR,\n :transcription_start_site,\n :transcription_end_site,\n :start_codon,\n :stop_codon ]\n (type_order.index(a.type) || type_order.length) <=> (type_order.index(b.type) || type_order.length)\n end", "def sort_operations\n operations.sort! { |a, b| sort_list(b, a) <=> sort_list(a, b) }\n end", "def ordered_by_qualifications(candidates)\n\n candidates.sort_by{ |candidate| [-candidate[:years_of_experience], -candidate[:github_points]] }\n\nend", "def comparer_methods\n super + [\n :highest_pair_rank,\n :lowest_pair_rank,\n :side_card_rank\n ]\n end", "def index\n\t @somewhere = [52.477995,13.566360]\n\t @sites = Site.joins(:sizes).includes([:sizes, :reviews])\n\t @sites.sort_by{|s| s.distance_to(@somewhere)}\n\t \n\t #@sites = Site.by_distance(:origin => @somewhere).order('distance ASC')\n\t \n end", "def sort_norm_data\n store.sort_norm_data!\n end", "def <=> (other)\n\t\tener_kj <=> other.ener_kj\n\tend", "def comparer_methods\n super + [\n :three_of_a_kind_rank,\n :pair_rank\n ]\n end", "def sort_name\n sort_constituent\n end", "def <=>(other)\n return 0 if self[:id] && self[:id] == other[:id]\n diff = (position <=> other.position)\n if diff == 0\n name <=> other.name\n else\n diff\n end\n end", "def sort_attributes(attributes_hash)\n attributes_order = %w{ID Name * Target Gap}\n\n attributes_hash.sort do |(a_key, a_value), (b_key, b_value)|\n a_key = a_key.to_s\n b_key = b_key.to_s\n \n # Reduce each of the attribute pairs to their correct index in the order\n a_key_val = attributes_order.include?(a_key) ? a_key : '*'\n b_key_val = attributes_order.include?(b_key) ? b_key : '*'\n\n index_sort = attributes_order.index(a_key_val) <=> attributes_order.index(b_key_val)\n\n index_sort == 0 ? a_key_val <=> b_key_val : index_sort\n end\n end", "def <=> other\n self.f <=> other.f\n end", "def <=>(other)\n score <=> other.score\n end", "def <=>(doc2)\n doc2.score_value <=> self.score_value\n end", "def <=>(other)\n other.score <=> score\n end", "def apply_sorting(relation)\n relation.order(@q.sorting.to_sql)\n end", "def ai_sorting_extension(a, b, action)\n return 0\n end", "def comparer_methods\n super + [\n :four_of_a_kind_rank,\n :kicker_rank\n ]\n end", "def complex_sort( task_a, task_b, options )\n\n # Implement grouping by billable and/or active flags by using these as\n # sort paramneters. The order of the checks means that if grouping by both\n # flags we'll get a sort order of billable/active, billable/inactive,\n # non-billable/active, non-billable/inactive.\n\n if ( options[ :group_by_billable ] )\n return -1 if ( task_a.billable && ! task_b.billable )\n return 1 if ( task_b.billable && ! task_a.billable )\n end\n\n if ( options[ :group_by_active ] )\n return -1 if ( task_a.active && ! task_b.active )\n return 1 if ( task_b.active && ! task_a.active )\n end\n\n # More conventional sorting - we group by customer, then by project, then\n # finally sort by the task itself. The field used for the sorting of each\n # of the three object types is configurable and usually one of :title,\n # :code or :created_at.\n #\n # Liberal use of 'try' to deal with unassigned items - tasks with no\n # project, projects with no customer. Any \"<=>\" comparison with 'nil' will\n # result in 'nil' and a failed sort, so return '0' for such cases to treat\n # any nil comparison as 'same' (the \"|| 0\" at the end of comparison lines).\n\n if ( task_a.project.try( :customer_id ) != task_b.project.try( :customer_id ) )\n method = options[ :customer_sort_field ] || :title\n return ( task_a.project.try( :customer ).try( method ) <=> task_b.project.try( :customer ).try( method ) ) || 0\n elsif ( task_a.project_id != task_b.project_id )\n method = options[ :project_sort_field ] || :title\n return ( task_a.project.try( method ) <=> task_b.project.try( method ) ) || 0\n else\n method = options[ :task_sort_field ] || :title\n return ( task_a.send( method ) <=> task_b.send( method ) ) || 0\n end\n end", "def ordered_by_qualifications(candiates)\n # Candidates with the most experience are at the top\n return candiates.sort_by { | obj | [obj[:years_of_experience], obj[:github_points]] }\n # return candiates.sort! { |a, b| b[:years_of_experience] <=> a[:years_of_experience] }\n\n # return candiates.sort_by {|:years_of_experience, :github_points|[ :github_points, :years_of_experience]}\n\n # return candiates.sort { | a, b | }\n # array.sort { |a,b| [ a[1], a[0] ] <=> [ b[1], b[0] ] }\n\n\n # For Candidates that have the same years of experience, \n #they are further sorted by their number of Github points (highest first)\nend", "def advancedSort\n @sortField = params[:sortField]#field to search on \n @searchField =params[:searchField]# value to search for\n @sortField2 = params[:sortField2]\n @searchField2 =params[:searchField2]\n @graphField = params[:graphField] #datapoint to build graph around\n \n if @sortField2 == \" \"#check if default second value was changed\n @records = Record.where(@sortField => @searchField) #if not only use the first search field\n else#otherwise use both seach fields\n @records = Record.where(@sortField => @searchField, @sortField2 => @searchField2 )\n end\n @sortedSet = @records.order(@graphField)\n end", "def sortByDistanceFrom(otherLocation)\n ParkingSpots.new(@_parkingSpots.sort { |a, b|\n a.metersFromLocation(otherLocation) <=> b.metersFromLocation(otherLocation)\n })\n end", "def recommended_to(main, opts={})\n opts.merge!(default_options)\n\n @similarities = @totals = Hash.new(0)\n\n create_similarities_totals(main)\n\n results = generate_rankings\n\n sort_results(results,opts[:size])\n end", "def <=>(other)\n if @weight < other.weight\n -1\n elsif @weight > other.weight\n 1\n else\n if @order < other.order\n return -1\n elsif @order > other.order\n return 1\n end\n 0\n end\n end", "def <=> other\n (@comparator ||=\n KeyValue.const_defined?(:COMPARATOR) ?\n KeyValue::COMPARATOR : KeyValue.COMPARATOR).compare(@java, other.java)\n end", "def <=>(other)\n\t\tself.order <=> other.order\n\tend", "def <=>(other)\n self.rank <=> other.rank\n end", "def <=>(other)\n self.question <=> other.question\n end", "def sort_params; end", "def sort_params; end", "def ordered_entities\n ids = self.entity_ids\n self.entities.sort { |a, b| ids.index(a.id) <=> ids.index(b.id) }\n end", "def <=>(other)\n fitness <=> other.fitness\n end", "def <=>(other)\n by_appearance = appearances <=> other.appearances\n by_position = other.position <=> position # reverse comparison, smaller is better\n\n by_appearance.zero? ? by_position : by_appearance\n end", "def ordered_by_qualifications(candidates)\n myArray = candidates\n #first sort by github points\n myArray.sort! { |a, b| a[:github_points] <=> b[:github_points] }\n #sort by experience\n myArray.sort! { |a, b| a[:years_of_experience] <=> b[:years_of_experience] }\n\n return myArray\nend", "def <=>(other)\n other.score <=> score\n end", "def <=>(other)\n product.name <=> other.product.name\n end", "def priority_sorting_metric\n [-1 * (measurement.priority.presence || (Measurement::MIN_PRIORITY - 1)), open_from]\n end", "def <=>(other)\n\t\tother.score <=> score\n\tend" ]
[ "0.61207867", "0.5983499", "0.579375", "0.5778915", "0.5769216", "0.5762753", "0.5692422", "0.5635052", "0.5560633", "0.5536304", "0.5535014", "0.5526959", "0.5509945", "0.55003774", "0.54993075", "0.5493392", "0.5473351", "0.5443815", "0.5368507", "0.53674096", "0.53658485", "0.5363979", "0.53524154", "0.5349321", "0.53466797", "0.53301597", "0.5327957", "0.5323924", "0.5309187", "0.53083473", "0.53044605", "0.5282267", "0.52764666", "0.52764666", "0.52764666", "0.5273864", "0.5265152", "0.5246187", "0.522565", "0.52251196", "0.522143", "0.52145785", "0.521025", "0.5205776", "0.5200799", "0.51823115", "0.5176102", "0.5172908", "0.5169507", "0.51642513", "0.51608264", "0.5159879", "0.5155644", "0.5155015", "0.51538527", "0.5151075", "0.51442516", "0.5142719", "0.5141423", "0.5141423", "0.5141245", "0.51276505", "0.512388", "0.51190794", "0.51185936", "0.51177996", "0.51107794", "0.51058966", "0.5103967", "0.5102504", "0.5101917", "0.5100727", "0.51", "0.5085495", "0.5079576", "0.50742996", "0.50735855", "0.5073514", "0.50704634", "0.50702953", "0.50587386", "0.5057997", "0.5054915", "0.50538516", "0.50515014", "0.5050483", "0.50503653", "0.5049005", "0.50482655", "0.5046808", "0.5046047", "0.5046047", "0.50453144", "0.5039622", "0.5030488", "0.50203377", "0.50191885", "0.50162095", "0.5013843", "0.50081456" ]
0.570391
6
returns in range [1,5]
def rating_for(dim) # If it's a boolean then this entity either has it or doesn't # Retirn 0|1 in the range of 1|5 if dim.bool? fv = FactValue.get_value(Fact.find_by_name(dim.name), self) return fv.value * 4 + 1 if fv else cr = CurrentRating.find_by_entity_id_and_opinion_id(self, dim.valuable) return cr.rating if cr end nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range(arr)\n\nend", "def range; end", "def range; end", "def range; end", "def range(input); end", "def range1(min, max)\n # Base Case / Inductive Step\n return [] if max <= min\n\n range1(min, max - 1) << max - 1\nend", "def create_range(num)\n (1..num).to_a\nend", "def range(min, max)\n\ti = min\n \tarry = []\n while i <= max\n arry << i\n i += 1\n end\n return arry\n\nend", "def range(min, max)\n\trange = []\n\n\ti = min\n\twhile i <= max\n\t\trange << i\n\t\ti += 1\n end\n \n\treturn range\nend", "def range(min, max)\n \tarr = []\n\tfor i in min..max\n arr << i\n end\n return arr\nend", "def range(min, max)\n nums = []\n \n i = min\n while i <= max\n nums << i\n \n i += 1\n end\n \n return nums\nend", "def range(min, max)\n return [] if max < min\n range(min, max - 1) << max\nend", "def range(start_val, end_val)\n return [] if start_val + 1 == end_val\n nums = [start_val + 1]\n nums + range(start_val + 1, end_val)\nend", "def range(min, max)\n nums = []\n \n i = min\n while i <= max\n nums << i\n \n i += 1\n end\n \n return nums\n end", "def straight_values_from(from)\n (from.to_i...from.to_i + 5).to_a\n end", "def range(start, ending_value)\n return [] if start > ending_value\n result = [start] + range(start + 1, ending_value)\nend", "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 range(min, max)\n return max if max < min\n range(min, max) << max\nend", "def divisible_by_5_and_3\n numbers = (1..100).to_a # this will create an array from 1 to 100. Check the Range class from Ruby - https://ruby-doc.org/core-2.5.1/Range.html\nend", "def range(min, max)\n all_numbers = []\n \n i = min\n while i <= max\n all_numbers << i\n \n i += 1\n end\n \n return all_numbers\nend", "def bound(n,options={})\n min=(options[:min]||1).to_i\n max=(options[:max]||5).to_i\n default=(options[:default]||min).to_i\n [[(n||default).to_i,min].max,max].min\n end", "def range(min, max)\n newArray = []\n i = min\n while i <= max\n newArray << i\n \ti += 1 \n end\n return newArray\n\nend", "def xRange(max)\n (@x > 0 ? @x - 1 : @x)..(@x < max - 1 ? @x + 1 : @x) \n end", "def rec_range(min, max)\n return [] if max == min\n [min] + rec_range(min+1, max)\nend", "def range(min, max)\n range_array = []\n\n i = min\n while i <= max\n range_array << i\n i += 1\n end\n return range_array\nend", "def range(min, max)\n\tprint (min..max).to_a\nend", "def range(start, finish)\n return [] if start >= finish\n [start + 1] + range(start + 1, finish)\nend", "def next5\n x = @exact[0,5]\n x + @list[0,5 - x.size]\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 range(min, max)\n arr = []\n\n while min <= max\n arr << min\n min += 1\n end\n return arr\nend", "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 range\n @from..@to\n end", "def rand5\n rand(1..5)\nend", "def range(min, max)\n nums = []\n\n i = min\n while i <= max\n nums << i\n\n i += 1\n end\n\n return nums\nend", "def range(start, last)\n return [] if last < start\n range(start, last - 1) << last - 1\nend", "def range(start, ending)\n return [] if start >= ending\n\n return [start] + range(start + 1, ending)\nend", "def an_array_with_5_elements\n [1, 2, 3, 4, 5]\nend", "def get_elements_until_greater_than_five(array)\n array[0..5]\nend", "def range(min, max)\n newArr = []\n i = min\n while i <= max\n newArr << i\n i +=1\n end\n return newArr\n end", "def price_setter(min, max)\n price_range = []\n (min..max).step(5) { |x| price_range.push(x) }\n return price_range.sample\nend", "def range(limits)\r\n\tnumbers = []\r\n\tfor number in (0..limits)\r\n\t\tputs \"At the top numbers are : #{number}\"\r\n\t\tnumbers.push(number)\r\n\tend\r\n\r\n\tputs \"The numbers: \"\r\n\tfor number in numbers\r\n\t\tputs number\r\n\tend\r\nend", "def get_sequence(low, high)\n (low..high).to_a\nend", "def range_numerals\n [ range(:numerals) ]\n end", "def range(start, stop)\n return [] if stop < start\n return [stop] if start == stop\n\n [start] + range(start+1, stop)\nend", "def range(min, max)\n new_arr = []\n i = min\n while i <= max\n new_arr << i\n i += 1\n end\n return new_arr\n end", "def rand_in_range(from, to); end", "def range(start, finish)\n #base case\n return nil if finish <= start\n return [start] if finish == start + 1 #return [0] for [0,1]\n #inductive step\n range(start, finish - 1) + [finish - 1]\nend", "def range(start_num, end_num)\n range_array = []\n range_array << start_num\n\n if(start_num < end_num)\n range_array += range(start_num + 1, end_num)\n end\n\n range_array\nend", "def r(range)\n range.to_a\nend", "def rand5\n rand(0...5)\nend", "def to_range\n min .. max\n end", "def rand5()\n rand(1..5)\nend", "def range(min, max)\n return [] if max <= min\n range(min, max - 1) << max - 1\n\n end", "def range(start, finish)\n return [] if finish < start\n return [start] if finish - 1 == start\n range(start, finish - 1) + [finish - 1]\nend", "def range(start,final)\n return [] if start >= final\n return [final - 1] if start == final - 1\n\n arr = []\n result = range(start,final-1)\n arr.concat(result)\n arr.push ( final - start )\n arr\nend", "def secret_numbers\n\t\t(1..5).to_a \n\tend", "def range(num, jobs)\n anp = ActiveNumberingPlan.last\n f = NumberingPlan.first.id\n l = NumberingPlan.last.id\n chank = ((l - f) + 1)/jobs\n r1 = f + ((num - 1) * chank) + (num - 1)\n r2 = r1 + chank\n (r1..r2)\nend", "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 range(num1, num2)\n return [] if num2 <= num1\n range(num1, num2-1) + [num2 - 1] \nend", "def range(min, max)\n minMax = []\n i = min\n while i <= max\n minMax << i\n i += 1\n end\n return minMax\n end", "def range(min, max)\n new_arr = []\n\n i = min\n while i <= max\n new_arr << i\n i = i + 1 \n end\n\n return new_arr\nend", "def range(arr)\narr.max - arr.min\nend", "def range(arr)\n arr.max - arr.min\nend", "def range(arr)\n arr.max - arr.min\nend", "def rnd_select_range(list, n, m)\n rnd_select(range(1, m), n)\nend", "def range(min, max) # takes some smaller num and then a larger num\n range_arr = [] # initialize new array\n i = min # indice counter @ whatever the first number passed in is\n\n firstnum = min # store val of first num\n lastnum = max # store val of last num\n \n while i <= max\n range_arr << i\n i += 1\n end\n return range_arr\nend", "def get_elements_until_greater_than_five(array)\n result = Array.new\n array.each {|x| x <= 5 ? result.push(x) : break}\n result\nend", "def range\n min, max = span\n min..max\n end", "def range(s, e)\n (s...e).to_a\nend", "def generate_range(min, max, step)\n array = []\n\n while min <= max\n\n array << min\n min += step\n end\n puts array\nend", "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_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 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 range(min, max)\n \n i = min\n new_array = [] # The reason this is here and not in while loop is because we would be setting it to an empty array at the beginning of every instance and it would return the last iteration value of i.\n \n while i <= max\n \n new_array << i # Shovels each iteration of i in to array\n i += 1 # Goes up by one\n end\n return new_array # Self explanatory\n\nend", "def select(numbers)\r\nreturn numbers.select { |x| x < 5 }\r\nend", "def loopy_range(max, step)\n numbers =[]\n for nums in (0..max)\n numbers.push(nums)\n end\n puts \"The end array is #{numbers}\"\nend", "def range(start,finish)\n if start == finish\n return [start]\n end\n\n prev_arr = range(start+1, finish)\n prev_arr << start\n return prev_arr\nend", "def sequence(integer)\n (1..integer).to_a\nend", "def sequence(integer)\n (1..integer).to_a\nend", "def get_upper_limit_of(range)\n\tn = 1..20\n\tn.last\nend", "def sequence(number)\n (1..number).to_a\nend", "def sequence(number)\n (1..number).to_a\nend", "def range(start,last) # recursive Version\n return [] if start >= last\n [start] + range(start+1,last)\nend", "def getMultpiles(range)\n\tmultiples = []\n\tfor i in 3...range\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tmultiples << i\n\t\tend\n\tend\n\treturn multiples\nend", "def range\n @range ||= 0.upto(@limit)\n end", "def select_div5(numbers)\n numbers.select { |e| (e % 5).zero? }\nend", "def group\n students = (1...59).to_a\n students.each_slice(5).to_a\n\nend", "def range(arr)\n max = arr.max\n min = arr.min\n\n max - min\nend", "def range(arr)\n # your code goes here\n arr.max - arr.min\nend", "def range(arr)\n # your code goes here\n arr.max - arr.min\nend", "def range_number(n,t)\n\t\t(n).step(t){|n|n+2}\n\tend", "def range(data)\n return (minimum(data)..maximum(data))\n end", "def range(arr)\r\n # your code goes here\r\n\r\n arr.max - arr.min\r\nend", "def m_range\r\n end", "def sequence4(num)\n (num > 0 ? 1..num : num..1).to_a\nend", "def range\n (@from..@to)\n end", "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 sequence(num)\n (1..num).to_a\nend", "def sequence(num)\n (1..num).to_a\nend", "def sequence(num)\n (1..num).to_a\nend", "def given\n [6,5,3,1,8,7,2,3]\nend" ]
[ "0.72225076", "0.7116516", "0.7116516", "0.7116516", "0.703115", "0.69801944", "0.6970153", "0.68838", "0.6873761", "0.6869183", "0.6841101", "0.6811183", "0.68026847", "0.6796398", "0.6790431", "0.6786825", "0.6774616", "0.6771307", "0.6760523", "0.6760008", "0.674558", "0.6729533", "0.67136925", "0.66978973", "0.6688239", "0.6681869", "0.6656935", "0.664526", "0.6632693", "0.6617141", "0.6593207", "0.65915734", "0.658618", "0.65843356", "0.6582872", "0.65811276", "0.6571102", "0.6569445", "0.6569137", "0.6555629", "0.6543303", "0.65420294", "0.6538748", "0.6531444", "0.6525422", "0.65152687", "0.65107363", "0.65005124", "0.6500131", "0.64957577", "0.64906377", "0.6488294", "0.64809644", "0.6480808", "0.64806664", "0.6479534", "0.6475384", "0.6471323", "0.6469483", "0.64674103", "0.646604", "0.6440246", "0.6421497", "0.6421497", "0.64037544", "0.6378088", "0.6377104", "0.63710654", "0.63681406", "0.6358848", "0.63408107", "0.6339979", "0.6338769", "0.63365", "0.63158727", "0.63153", "0.6302826", "0.6301021", "0.6301021", "0.62950337", "0.62906295", "0.62906295", "0.6280637", "0.62726647", "0.6271926", "0.6267011", "0.62604207", "0.6246815", "0.6240984", "0.6240984", "0.6231639", "0.62285733", "0.62264806", "0.6212737", "0.6212507", "0.6193961", "0.61806023", "0.6164591", "0.6164591", "0.6164591", "0.61628795" ]
0.0
-1
def followed_by?(other_user) reverse_followships.find_by_follower_id(other_user.id) end def unfollowed!(other_user) reverse_followships.find_by_follower_id(other_user.id).destroy end
def has_role?(role) case role when :admin then admin? when :member then true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unfollowed(other_user)\n passive_relationships.find_by(follower_id: other_user.id).try(:destroy) \n end", "def unfollow(user)\n following = out_followings.find_by(to_id: user.id)\n if following\n following.destroy\n true\n else\n false\n end\n end", "def unfollow(other_user)\n \tactive_relationships.find_by(followed_id: other_user.id).destroy\n \tend", "def unfollow(other_user)\n active_follows.find_by(followed_id: other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by(followed_id: other_user.id).destroy!\n end", "def unfollow!(other_user)\n\t\tself.relationships.find_by_followed_id(other_user.id).destroy\n\tend", "def following?(other_user)\n !follower_followships.find_by(followed_id: other_user.id).nil?\n end", "def unfollow(other_user)\n\t\tactive_relationships.find_by(followed_id: other_user.id).destroy\n\tend", "def unfollow(other_user_id)\n \tuser_to_unfollow = User.find_by(id: other_user_id)\n active_relationships.find_by(followed_id: user_to_unfollow.id).destroy\n end", "def unfollow!(user)\n relationships.find_by_followed_id(user).destroy\n end", "def unfollow(other_user)\n following_relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow_user(follow_user)\n #before we can destroy the link we must check if the user is already not following the other user\n #or if the user is trying to unfollow themself.\n #if the user can follow the other user then that means no relationship exists\n if can_follow?(follow_user)\n raise \"Can't unfollow yourself or a user that you are not already following!\"\n else\n followRel = Follow.find(:first, :conditions => {:user_id => self.id, :follow_user_id => follow_user.id})\n followRel.destroy\n end\n end", "def unfollow(other_user)\n following.delete(other_user)\n end", "def unfollow(other_user)\n following.delete(other_user)\n end", "def unfollow(other_user)\n following.delete(other_user)\n end", "def unfollow(other_user)\n following.delete(other_user)\n end", "def unfollow!(user)\n followings.find_by(following_id: user.id)&.destroy!\n end", "def unfollow!(followed)\n relationships.find_by_followed_id(followed).destroy\n end", "def unfollow!(followed)\n relationships.find_by_followed_id(followed).destroy\n end", "def unfollow(other_person)\n active_relationships.find_by(followed_id: other_person.id).destroy\n end", "def delete_follower\n if (@user = find(User, params[:user_id])).is_a?(User)\n current_user.unfollow(@user)\n redirect_to @user, notice: \"You are not following #{@user.username} anymore!\"\n end\n end", "def unfollow_user\n\t\t# determine who is following who\n\t @follower = current_user\n @following = User.find_by_login(params[:username])\n @user = @following\n\n\t\t# if follower was self, unknown\n if @follower.id == @following.id\n gflash :error => \"Unknown request!\"\n redirect_back_or_default('/')\n end\n\n\t\t# see if user is being followed \t\n exist = Follow.find(:first, :conditions => {:follower_id => @follower.id, :following_id => @following.id})\n if exist\n\t\t\t# if he is, erase from database\n exist.destroy\n\t\t\t# show pop up regarding unfollow success\n gflash :success => \"You are no longer following #{@following.login}!\"\n else\n gflash :error => \"You are already not following #{@following.login}!\"\n end\n redirect_to :action => 'profile', :username => @following.login\n end", "def unfollow\n unfollow = User.where(:username => params[:id]).first\n relationship = @current_user.followers.where( :friend_id => unfollow.id ).first\n relationship.destroy\n redirect_to user_path( unfollow.username )\n end", "def destroy\n user = Relationship.find(params[:id]).followed\n @current_user.unfollow(user)\n redirect_to user\n end", "def unfollow(user)\n self.following.delete(user)\n end", "def unfollow\n fs = Friendship.where(user_id: current_user, friend_id: params[:id]).first\n if fs\n fs.destroy\n redirect_to user_url(params[:id]), notice: \"This user was removed from your list of friends.\"\n else\n flash.alert = \"Something went wrong. You weren't following that user.\"\n redirect_to users_url\n end\n end", "def unfollow_user\n\t\tauthenticate_current_user\n\t\t# destroy the current user from that user's followers\n\t\tUser.find(params.user_id).followers.destroy(User.find(current_user.id))\n\t\t# run the following action to return the updated group of followers\n\t\tfollowing\n\tend", "def unfollow! followee\n return if !following? followee\n following_ids.delete(followee.id)\n save\n followee.followers_ids.delete(id)\n followee.save\n end", "def unfollow(user)\n user.followers.delete(self)\n end", "def destroy_following\n user = User.find(params[:id])\n current_user.followings.where(following_id: user.id).destroy_all\n end", "def end_friendship!(other_user) \n relother=Relationship.where(user: other_user, friend: self).first\n relself=Relationship.where(user: self, friend: other_user).first\n if (relother==nil or relself==nil)\n return false\n else\n #if both relations exist: destroy them\n relother.destroy\n relself.destroy\n return true\n end\n end", "def remove_follower\n @user = User.friendly.find(params[:user_id])\n\n @follow = Follow.find_by followable_id: current_user.id, follower_id: @user.id\n @follow.status = 2\n\n if @follow.save\n render :json => {:success => true}\n else\n render :json => {:success => false}\n end\n end", "def unfollow_user(user)\n following.delete(user)\n end", "def following?(user)\n !can_follow?(user)\n end", "def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end", "def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end", "def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end", "def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end", "def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end", "def unfollow\n user_id = params[:id]\n following_user_id = (params[:following_user_id] || params[:connected_user_id])\n\n if (user_id.present? and following_user_id.present?)\n user = User.find_by_id(user_id)\n following_user = User.find_by_id(following_user_id)\n\n if (!user.nil? and !following_user.nil?)\n if !user.follows.exists?(following_user)\n message = t('user.unfollow.messages.already_not_following', {following_user_name: following_user.name})\n else\n followed_following_obj = user.unfollow(following_user_id)\n if followed_following_obj.nil?\n message = t('user.unfollow.messages.failure', { following_user_name: following_user.name })\n else\n message = t('user.unfollow.messages.success', { following_user_name: following_user.name })\n end\n end\n else\n message = t('user.unfollow.errors.no_user_found', { user_id: user_id, following_user_id: following_user_id })\n end\n else\n message = t('user.unfollow.errors.could_not_process_unfollow')\n end\n\n redirect_to :back, flash: { notice: message }\n end", "def following?(other_user)\n\t\trelationships.find_by_followed_id(other_user.id)\n\tend", "def following?(other_user)\n\t\trelationships.find_by_followed_id(other_user.id)\n\tend", "def delete_follower(user)\n followers.delete(user)\n end", "def follow(other_user)\n following << other_user unless self == other_user\n end", "def unfollow(user_a, user_b)\n\t\t#This method deletes the follow relationship in the database\n\t\tuser_a.unfollow(user_b)\n\n\t\tif REDIS.exists(user_a.handle+\"_relations\")\n\t\t\tREDIS.srem(user_a.handle+\"_relations\", params[:userid])\n\t\tend\n\t\tif REDIS.exists(user_a.handle+\"_num_following\")\n\t\t\tREDIS.decr(user_a.handle+\"_num_following\")\n\t\tend\n\t\tif REDIS.exists(user_b.handle+\"_num_followers\")\n\t\t\tREDIS.decr(user_b.handle+\"_num_followers\")\n\t\tend\n\tend", "def unfollow\n \n # Get the specified user, making sure that it exists\n @user = User.find_by_login(params[:user_login])\n \n # Find the follow relationship between the current user and the specified\n # user\n @follow = Follow.find(:first, :conditions => \"follower_id = #{current_user.id} and followee_id = #{@user.id}\")\n \n # Destroy the follow relationship\n @follow.destroy\n current_user.save!\n \n # Redirect back to the profile of the user that was being followed\n flash[:notice] = \"You are no longer following #{@user.login}.\"\n redirect_to user_profile_url(:user_login => @user.login)\n end", "def revert_to_follower(user, target)\n return false if user.blank? || target.blank?\n transaction do\n friend = self.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id})\n friend.destroy if friend\n friend = self.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id})\n if friend\n return friend.update_attribute(:status, MuckFriends::FOLLOWING)\n else\n return false\n end\n end\n end", "def following?(other_user)\n following.include?(other_user)\n # relationships.find_by(followed_id: other_user.id) \n end", "def unfollow\n @user = User.find(params[:follow_id])\n\n current_user.following.delete(params[:follow_id].to_i)\n @user.followers.delete(current_user.id)\n\n current_user.save\n @user.save\n \n if current_user.save\n flash[:success] = \"You are no longer following #{@user.username}!\"\n redirect_to root_path\n else\n flash[:error] = \"Something went wrong.\"\n end\n #show_followers\n end", "def unfollow\n @user = User.find_by_id(params[:id])\n if @user and current_user.unfollow(@user)\n flash[:notice] = \"You are no longer following #{@user.login} :(\"\n redirect_to home_path()\n elsif @user\n flash[:notice] = \"You aren't following #{@user.login}\"\n redirect_to user_path(@user.login)\n else\n redirect_to home_path()\n end\n end", "def following?(other_user)\n relationships.find_by(followed_id: other_user.id)\n end", "def following?(other_user)\n active_relationships.find_by(followed_id: other_user.id)\nend", "def followed_by?(other_user)\n followers.include?(other_user)\n end", "def following?(other_user)\n relationships.find_by(followed_id: other_user.id)\n end", "def unfollow! followee\n following_ids.delete(followee.id)\n save\n followee.followers_ids.delete(id)\n followee.save\n end", "def user_unfollows\n if user_signed_in?\n Rails.logger.debug { \"The user to be unfollowed is #{params[:id]}\" }\n user = User.find(id: params[:id])\n user.follows.delete(current_user)\n end\n \n end", "def unfollow\n @user = User.friendly.find(params[:user_id])\n\n @follow = Follow.find_by followable_id: @user.id, follower_id: current_user.id\n @follow.status = 2\n \n if @follow.save\n render :json => {:success => true}\n else \n render :json => {:success => false}\n end\n end", "def followable_by?(user)\n return false if self.id == user.id #can't follow self\n return false if user.following?(self) #can't follow someone already following\n true #otherwise \n end", "def followed_by?(user)\n followers.exists?(user.id)\n end", "def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end", "def following?(other_user)\n relationships.find_by(followed_id: other_user.id)\n end", "def can_follow?(followee)\n !Follow.exists?([\"user_id = ? AND follow_user_id = ?\", self.id, followee.id]) && self != followee\n end", "def following?(other_user)\n active_relationships.find_by(followed_id: other_user.id)\n end", "def can_follow?(amigo_id)\n not amigo_id == self.id or friendships.where(friend_id: amigo_id).size > 0\n\n \n end", "def unfollow\r\n @relationship = Relationship.where(follower_id: current_user.id, followed_id: params[:followed_id]).first\r\n @relationship.create_activity key: 'relationship.unfollow', owner: current_user, recipient: User.find(params[:followed_id]) \r\n @relationship.destroy\r\n render json: { message: \"Relationship destroyed successfully\" }\r\n end", "def stop_following(user, target)\n return false if user.blank? || target.blank?\n friend = self.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id})\n if friend\n friend.destroy\n else\n false\n end\n end", "def unfollow_user(follower, following)\n User.where(handle: follower).first.pull(:following, following)\n end", "def following?(other_user)\n #!active_relationships.find_by(followed_id: other_user.id).nil? or\n following.include?(other_user)\n end", "def following?(other_user)\n followeds.include?(other_user)\n end", "def following?(other_user)\n self.relationships.find_by_followed_id(other_user.id)\n end", "def unfollow\n if @user_auth.nil?\n raise ActionController::MethodNotAllowed, 'Vous n\\'êtes pas connecté'\n elsif @user_auth.id != @user_followed.id\n follow = Follow.find_by(follower_user_id: @user_auth.id, followed_user_id:@user_followed.id)\n if follow.destroy\n redirect_back fallback_location: '/', notice: \"Vous ne suivez plus #{@user_followed.name}\"\n else\n redirect_back fallback_location: '/', error: \"Impossible de follow l'utilisateur\"\n end\n else\n redirect_back fallback_location: '/', error: 'Vous ne pouvez pas vous auto unfollow'\n end\n end", "def following?(other_user)\n following.exists?(other_user.id)\n end", "def following?(user)\n\tself.followed_users.exists?(user.id)\nend", "def unfollow\n requested_profile.unfollow!(requested_follow_profile)\n redirect_to :action => 'following', :profile_id => current_user.profile\n end", "def following?(other_user)\n \tfollowing.include?(other_user)\n \tend", "def following?(other_user)\n \tfollowing.include?(other_user)\n \tend", "def follow_user_link followed_user\n return if followed_user == current_user\n\n if current_user.followed_user_ids.include?(followed_user.id)\n internal_unfollow_user_link(followed_user)\n else\n internal_follow_user_link(followed_user)\n end\n end", "def unfollow\n follower_db = resolve_db(:required => 'pg:unfollow')\n\n if follower_db[:name].include? \"SHARED_DATABASE\"\n display \" ! SHARED_DATABASE is not following another database\"\n return\n end\n\n follower_name = follower_db[:pretty_name]\n follower_db_info = heroku_postgresql_client(follower_db[:url]).get_database\n origin_db_url = follower_db_info[:following]\n\n unless origin_db_url\n display \" ! #{follower_name} is not following another database\"\n return\n end\n\n origin_name = name_from_url(origin_db_url)\n\n display \" ! #{follower_name} will become writable and no longer\"\n display \" ! follow #{origin_name}. This cannot be undone.\"\n return unless confirm_command\n\n working_display \"Unfollowing\" do\n heroku_postgresql_client(follower_db[:url]).unfollow\n end\n end", "def unfollow_fan_base!(followed)\r\n fan_relationships.find_by_followed_id(followed).destroy\r\n end", "def toggle\n @follows = Follow.where(:user_id => current_user.id, :question_id => params[:question]).all\n if !@follows.empty?\n @follows.each do |follow|\n follow.destroy\n end\n render :text => 'Successfully destroyed Follow association'\n else\n @follow = Follow.create(:user_id => current_user.id, :question_id => params[:question])\n render :text => 'Successfully created Follow association'\n end\n end", "def following?(followed)\n \trelationships.find_by_followed_id(followed)\n end", "def following?( other_user )\n followings.include?( other_user )\n end", "def unfollow\n \t\n \t\t@fol = Follow.find_by_follower_and_followee(session[:id], params[:aid])\n \t\tif @fol == nil\n \t\t\tflash[:error] = \"wtf????\"\n \t\telse\n \t\t\t@sql = \"DELETE FROM follows WHERE follower = \"+@fol.follower.to_s+\" AND followee = \"+@fol.followee.to_s\n \t\tActiveRecord::Base.connection.execute(@sql)\n \t\t\n \t\t#if request.xhr?\n \t\t\trender 'accounts/unfollow'\n \t\t\t#else\n \t\t\t\t#redirect_to :controller => :main, :action => :searching\n \t\t\t#end\n \t\tend\n \t\t\n \t \t\n end", "def followed_by?(user)\n followers.include?(user)\n end", "def following?(user)\n relationships.find_by_followed_id(user)\n end", "def following?(user)\n relationships.find_by_followed_id(user)\n end", "def unfollow_user\n user = User.find(params[:user_id])\n current_user.unfollow(user)\n render_success_message(\"You are not anymore following #{user.full_name(false)}\")\n end", "def destroy\n @user = User.find(params[:user_id])\n @follower = @user.follower.find(params[:id])\n @follower.destroy\n head :no_content\n end", "def toggle_follow(user)\n if self.followers.include?(user)\n self.followers.delete(user)\n else\n self.followers << user\n end\n end", "def following?(other)\n\t\tself.relationships.find_by_followed_id(other.id) #followed_id = name of the attribute as it appears in relationships\n\tend", "def unfollow\n follower_db = resolve_db(:required => 'pg:unfollow')\n\n if follower_db[:name].include? \"SHARED_DATABASE\"\n output_with_bang \"SHARED_DATABASE is not following another database\"\n return\n end\n\n follower_name = follower_db[:pretty_name]\n follower_db_info = heroku_postgresql_client(follower_db[:url]).get_database\n origin_db_url = follower_db_info[:following]\n\n unless origin_db_url\n output_with_bang \"#{follower_name} is not following another database\"\n return\n end\n\n origin_name = name_from_url(origin_db_url)\n\n output_with_bang \"#{follower_name} will become writable and no longer\"\n output_with_bang \"follow #{origin_name}. This cannot be undone.\"\n return unless confirm_command\n\n working_display \"Unfollowing\" do\n heroku_postgresql_client(follower_db[:url]).unfollow\n end\n end", "def delete_follows\n \t@follower = User.find(params[:id])\n \t@followed = User.find(params[:follows_id])\n \t\n \tif @follower.follows.delete(@followed)\n \t\t\n \telse\n \t\trender json @follower.errors\n \tend\n end" ]
[ "0.84277236", "0.8358495", "0.82541686", "0.8202163", "0.8177405", "0.8177405", "0.8177405", "0.8177405", "0.8177405", "0.8143758", "0.80772305", "0.80772305", "0.80772305", "0.80667704", "0.80224836", "0.8001884", "0.7991048", "0.79881614", "0.7982519", "0.7974786", "0.79663956", "0.7863153", "0.7862916", "0.7862916", "0.7862916", "0.783201", "0.7719047", "0.7719047", "0.7638512", "0.76365304", "0.762744", "0.76229215", "0.7568788", "0.7547031", "0.7537799", "0.7527062", "0.74814075", "0.74717146", "0.7433703", "0.74302363", "0.7420987", "0.7410125", "0.739336", "0.73803604", "0.73803604", "0.73803604", "0.73803604", "0.73803604", "0.73791087", "0.7373557", "0.7373557", "0.7368925", "0.73576766", "0.73523015", "0.73500484", "0.7342442", "0.73328364", "0.7326606", "0.7320816", "0.731888", "0.73144025", "0.7314093", "0.7300602", "0.7299988", "0.72990084", "0.7279641", "0.7275841", "0.7268504", "0.72666466", "0.72592956", "0.7257459", "0.7255346", "0.723205", "0.72299993", "0.72288346", "0.7191605", "0.7181194", "0.71706456", "0.7161568", "0.7125881", "0.7125402", "0.71246946", "0.71187687", "0.71067774", "0.71067774", "0.70961475", "0.70849663", "0.7083297", "0.7079529", "0.70756006", "0.7072465", "0.7061295", "0.705713", "0.70450413", "0.70450413", "0.7025747", "0.70208675", "0.7020638", "0.70180887", "0.70136493", "0.7012429" ]
0.0
-1
This method is to ascertain whether the value given is an integer and if not, continue down the array
def find_int(obj) if obj.respond_to?(:each) # This is an array, not the object type sought. obj.each do |x| find_int(x) end else # This is an integer or other object, return it. @holding_array << obj end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_a_number?(arr_value)\n\tarr_value.is_an_integer?\nend", "def is_int_array(arr)\n if arr == nil || arr == ''\n return false\n elsif arr.empty?\n return true\n end\n\narr.each do |i|\n if i.class == Integer || i.class == Float && i%1==0\n else\n return false\n end\n end\ntrue\nend", "def int_array_check(arr)\n arr.each do |element|\n Integer(element) != nil rescue return false\n end\n return true\n end", "def sum(arr)\r\n #if array includes the value of non-integer,change it to 1\r\n iIntegerFlag=0\r\n #initialize the value of the sum of array's elements\r\n iSum=0\r\n #identify array\r\n if arr.instance_of?(Array) then\r\n #get the length of arr\r\n iArrLength=arr.size\r\n #justify whether the each element of array is a integer\r\n for value in arr do\r\n if !value.is_a?(Integer) then\r\n iIntegerFlag=1\r\n break\r\n end\r\n end\r\n if iIntegerFlag==1 then\r\n puts \"The array must be consisted of integers!\"\r\n return false\r\n else\r\n if iArrLength!=0 then\r\n for n in 1..iArrLength\r\n iSum=iSum+arr[n-1]\r\n end\r\n end\r\n return iSum\r\n end\r\n else\r\n puts \"Please input an array!\"\r\n return false\r\n end\r\nend", "def sum(int_array)\r\n sum = 0\r\n\r\n #puts int_array.class.to_s == 'Array'\r\n # Check that int_array behaves like array \r\n if int_array.respond_to?(:each)\r\n int_array.each do |num|\r\n if num.class.to_s =='Fixnum' \r\n sum += num\r\n else\r\n puts \"Non-integer entry #{num} of the array are not added to the sum\"\r\n end\r\n end\r\n else\r\n raise \"Input parameter is not an array\"\r\n end\r\n sum\r\nend", "def is_integer_array? array\n\t\treturn array.all? {|a| a.is_a? Integer}\n\tend", "def integer?(value)\n value.is_a?(Integer)\n end", "def is_int(value)\n true if Integer(value) rescue false\n end", "def return_only_integer(arr)\n arr.select { |element| element.is_a? Integer }\nend", "def sum_up_numbers(arr)\n sum = 0\n arr.each do |num|\n if num.is_a? Integer\n sum += num\n end\n end\n return sum\nend", "def do_if_integer(element)\n if element.is_a?(Integer)\n yield element\n else\n element\n end\nend", "def check_integer\n if @position == 0 \n return false\n else return true\n end\n end", "def expect_array_of_integers(value, field, subfield)\n return false unless expect_array(value, field, subfield)\n error_count = 0\n value.each_with_index do |v, i|\n error_count += 1 unless expect_integer(v, field, \"#{subfield}[#{i}]\")\n end\n error_count == 0\n end", "def integers (arr, int)\r\n current_index = 0\r\n index_item = nil\r\n arr.each do |item| \r\n if item == int\r\n index_item = current_index\r\n end\r\n current_index += 1\r\n end\r\n index_item\r\nend", "def require_integer(value)\n if value.is_a?(Integer) != true\n log_error_and_raise(\"expected integer value, got #{value.class}, #{value.inspect}\")\n end\n end", "def integer?() end", "def sum_of_array(array)\n sum = 0\n array.each do |item|\n if item.is_a?(Integer) == true\n sum = sum + item\n else\n sum = sum + num_value(item)\n end\n end\n sum\nend", "def integer?(input)\n Integer(input) rescue false\nend", "def new_numbers (array)\n emptyArr = []\n array.each do |i|\n if i.class == Integer\n emptyArr << i\n end\n end\n return emptyArr\nend", "def sum_array(arry)\n sum = 0\n arry.each do |num|\n # if num = num.to_i\n sum += num\n\n\n end\n sum\nend", "def all_ints?(collection)\n collection.each do |n|\n begin\n Integer(n)\n rescue\n return false\n end \n end\n true\n end", "def validate_integer_type(field)\n if field.is_a?(Integer)\n return true\n else\n return false\n end\n end", "def is_integer?\n self.to_i.to_s == self\n end", "def integer?(obj)\n obj = obj.to_s unless obj.is_a? String\n /^\\d+$/.match obj\nend", "def is_numeric(val)\n\t\treturn Integer(val).is_a? Integer rescue false\n\tend", "def integer?(num)\n num.to_i > 0 && num.to_i.to_s == num\nend", "def is_int\r\n\t\tself.to_i.to_s != self.to_s\r\n\tend", "def is_integer?\n self =~ /\\A-?(?:0|[1-9][0-9]*)\\z/\n end", "def array_of_fixnums?(array)\n array.all? { |x| x.is_a? Integer } \nend", "def up_array(arr)\n return nil if arr.length < 1\n condition = true\n arr.each { |i| condition = false if ( (i < 0) || (i > 9) || (i.class == Float) ) }\n return (arr.join.to_i + 1).to_s.chars.map {|i| i.to_i} if condition == true\nend", "def filter_list(arr)\n\treturn arr.select {|x| x.is_a?(Integer) }\nend", "def test_int_check_pass\n assert_equal int_check([]), true # EDGE CASE\n assert_equal int_check(['1']), true # pass\n assert_equal int_check(['1', '1']), true # pass\n assert_equal int_check(['1', '1', '1']), true # pass\n end", "def numeric?(value)\n !value.nil? && value.is_a?(Integer)\n end", "def isint\n int? ? Q::ONE : Q::ZERO\n end", "def is_value?(value)\n\t\tvalue.to_i < 10\n\tend", "def numeric?(object)\n \t\ttrue if Integer(object) rescue false\n \tend", "def is_integer?(input)\n input.to_i.to_s == input\nend", "def integer?(num)\n num.to_i.to_s == num\nend", "def valid_val?(val) #=> checking to see if the value is valid\n val.is_a?(Integer) && #=> checking the value is an array\n val.between?(0, 9) #=> is the value between 0-9\n end", "def sum_only_numbers(an_array)\n # TODO write your code here\n total = 0\n\n an_array.each do |x|\n if(x.is_a? Numeric)\n total = total + x\n end\n end\n\n total\nend", "def verify(x)\n\ty = 1\n\twhile y == 1\n\t\tif x.is_a?(Integer) && x > 0 && x < 10 #need to fix this. Still able to take non integers like 1.5\n\t\t\treturn x\n\t\t\ty-=1\n\t\telse\n\t\t\tputs \"Try again - number must be 1 through 10 and an integer\"\n\t\t\tx = gets.chomp.to_i\n\t\tend\n\tend\nend", "def match_integer( val )\n\t\treturn Integer( val ) rescue nil\n\tend", "def oddnum arr\n # arr.select { |x| x.is_a?(Integer) }\n array = arr.select { |x| x.instance_of?(Integer) }\n final_array = array.select { |x| x.odd?}\n final_array.sort\nend", "def is_integer?(obj)\n\t\tif obj\n\t\t\treturn obj.to_s == obj.to_i.to_s\n\t\tend\n\t\treturn false\n\tend", "def is_integer?(num)\n # first two arguments can be replaced with num.is_a?(Integer)\n num.class == Fixnum || num.class == Bignum || ( num.class == Float && !num.nan? && num == num.floor )\nend", "def integer?(num)\n num.to_i().to_s()==num\nend", "def is_numeric(o)\n true if Integer(o) rescue false \n end", "def is_number?(i)\n true if Float(i) rescue false\nend", "def is_number?(i)\n true if Float(i) rescue false\nend", "def is_numeric(o)\n true if Integer(o) rescue false \n end", "def is_integer?(num)\n num.class == Fixnum || num.class == Bignum ||\n ( num.is_a?(Float) && !num.nan? && num.to_i == num )\nend", "def number?( item )\n [Float, Fixnum, Integer].any? {|type| item.is_a?( type )}\n end", "def isNum(c)\r\n\tInteger(c) rescue return false\r\n\treturn true\r\nend", "def integer?\n type == \"INTEGER\" || type == \"INT64\"\n end", "def is_int? str\n Integer(str) rescue return false\n return true\nend", "def should_be_integer?(field_info, field)\n field_info[\"type\"] == \"INTEGER\"\n end", "def my_array_splitting_method(source)\n source.partition{|element| element.is_a?(Integer)}\nend", "def contains_int?\r\n \treturn false if self.empty?\r\n \treturn self.match(/^[0-9]+$/)\r\n end", "def is_integer?(num)\n\tif num.is_a? Integer\n\t\ttrue\n\telsif num.is_a? Float\n\t\tif num.nan?\n\t\t\tfalse\n\t\telsif num == num.floor\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\telse\n\t\tfalse\n\tend\nend", "def integer?(object)\n (object.to_s.to_i == object) || (object.to_i.to_s == object)\nend", "def integer?(input)\n input.to_i.to_s == input\nend", "def integer?(input)\n input.to_i.to_s == input\nend", "def integer?(input)\n input.to_i.to_s == input\nend", "def my_array_splitting_method(source)\n source.partition { |x| x.is_a? Integer }\nend", "def sum_only_numbers(an_array)\n # TODO write your code here\n arraySum = 0\n an_array.each do |arrayElement|\n if arrayElement.is_a?(Numeric) == true\n arraySum += arrayElement\n end\n end\n puts arraySum\nend", "def value_is_integer?(string)\n return string.strip.numeric?\n end", "def number?(value)\n value.is_a?(Numeric)\n end", "def missing_integer(a)\n result = []\n a.each do |i|\n result[i] = i if i > 0\n end\n\n i = 1\n while result[i] != nil\n i += 1\n end\n i\nend", "def integer?\n self.to_i.to_s == self\n end", "def sum_only_numbers(an_array)\n sum = 0\n an_array.each do |item|\n item.is_a?(Integer) || item.is_a?(Float) ? sum += item : sum\n end\n return sum\nend", "def is_integer?(num)\n num.class == Fixnum || num.class == Bignum ||\n ( num.is_a?(Float) && !num.nan? && num.to_i == num )\n end", "def is_integer?(num)\n num.class == Fixnum || num.class == Bignum ||\n ( num.is_a?(Float) && !num.nan? && num.to_i == num )\n end", "def sum(array)\n\n raise 'array includes non integers' unless \n (array.empty? || array.all? { |x| x.integer?})\n \n array.reduce(0,:+)\n \nend", "def integer?(input)\n # could also do input.to_i.to_s == input but something with a\n # leading 0 (\"00\", \"01\", etc) will return false\n Integer(input)\nrescue ArgumentError\n false\nend", "def array_of_fixnums?(array)\n for element in array\n unless element.is_a? Fixnum\n return false\n end\n end\n return true\nend", "def search_array(arr, int)\r\n i = 0\r\n while i < arr.length\r\n if arr[i] == int\r\n return i\r\n else\r\n puts NIL\r\n end\r\n i += 1\r\nend\r\nend", "def is_i?\n self.to_f == self.to_f.floor\n end", "def filter_out_integers(arr)\n reformed_array = []\n\n index = 0\n arr.each do |value|\n if value.is_a? String\n reformed_array.insert(index, value)\n\n index += 1\n end\n end\n\n return reformed_array\nend", "def find_ints\n\todds_n_ends = [:Alabama, \"Arkansas\", 2, true, \"I do love my ma and pa\"]\n\t# Integer can be changed to String or Symbol\n\tints = odds_n_ends.select { |nums| nums.is_a? Integer}\n\tputs \"Integers: \"\n\tputs ints\nend", "def not_int?(dig)\n if dig.to_i == 0 && dig != \"0\"\n puts \"Invalid Number, enter again\" \n true\n else\n false \n end #end of if \n end", "def IS_NUMBER(value)\n value.first.is_a?(Numeric)\n end", "def is_integer?(input)\n return input.to_s.ord >= 48 and input.to_s.ord <= 57\nend", "def sum_mix2(x)\n b = 0\n for i in x\n if i == Integer\n b += i\n else\n b += i.to_i\n end\n \nend\nputs b\nend", "def search_array(arr, int)\n\ti = 0\n\twhile i < arr.length\n\t\tif arr[i] == int\n\t\t\treturn i \n\t\tend\n\ti += 1\n\tend\nend", "def search_array(array, int)\n \n return_value = nil\n x = 0\n while x < array.length\n \n if array[x] == int\n return return_value = x\n else \n x += 1\n end\n end\n return return_value\nend", "def sum_only_numbers(an_array)\n sum=0\n an_array.each do |item|\n if item.is_a? Integer or item.is_a? Float\n\tsum+=item\n end\n end\n return sum\nend", "def sum_up_numbers(arr)\n arr.select {|n| n.is_a? Integer}.reduce(0, :+)\nend", "def filter_out_strings(arr)\n arr.select { |num| num.is_a? (Integer) }\nend", "def is_number(value) #method\n if is_bool(value)\n false\n elsif value[0] == \"\\\"\"\n false\n else\n true\n end\n end", "def check_numbers(data)\n hash = {}\n\n data.each do |number|\n integer = number.to_i\n\n if integer > 0 && integer < 10\n if hash[integer]\n return false\n else\n hash[integer] = 1\n end\n end\n end\n\n return true\nend", "def sum_only_numbers(an_array)\n\tsummation = 0\n\tfor item in an_array\n\t\tif item.is_a? Integer\n\t\t\tsummation += item\n\t\tend\n\t\tif item.is_a? Float\n\t\t\tsummation += item\n\t\tend\n\tend\n\treturn summation\nend", "def double?(int)\n array = int.to_s.chars\n first = []\n last = []\n if array.size.odd?\n false\n else\n loop do\n break if array.empty?\n first << array.shift\n last << array.pop\n end\n first == last.reverse ? true : false\n end\n \nend", "def check_nums(num, surname)\n if (num.class == Integer && surname[0] == 'P')\n puts \"it's class is integer, so it\\'s number\"\n else puts \"argument num [val:#{num}]is not a num!! it\\'s class object is#{num.class}\"\n end\nend", "def convert_array_elements_to_i(array)\n for i in 0..array.length-1\n array[i] = array[i].to_i\n end\nend", "def search_array(array, integer)\nindex = 0\n\twhile index < array.length \n\t\tif array[index] == integer \n\t\t\treturn index\n\t\tend \n\t\tindex += 1\n\tend\n\tputs \"This integer is not included.\" \nend", "def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |value, index|\n if value.is_a? Integer\n source[index] += thing_to_modify\n end\n end\nend", "def is_integer? string\n true if Integer(string) rescue false\n end", "def search_array(array, int)\n\ti = 0\n\twhile i < array.length\n\t\tif array[i] == int\n\t\t\treturn i\n\t\tend\n\t\ti += 1\n\tend\n\n\treturn nil\nend", "def is_number?(obj)\n obj.to_s == obj.to_i.to_s\n end", "def _match_class_convert_Integer(value)\n value = super\n value if value <= _match_class_max_Integer\n end" ]
[ "0.74689525", "0.72572684", "0.6982113", "0.68708277", "0.66392297", "0.6637574", "0.6629268", "0.6601657", "0.6360849", "0.633293", "0.6281026", "0.62784475", "0.62735057", "0.6192196", "0.61749107", "0.6137958", "0.6136474", "0.6109165", "0.60758746", "0.60547787", "0.60470784", "0.59443915", "0.5930424", "0.59133065", "0.5892779", "0.58561456", "0.5843682", "0.58385813", "0.58356196", "0.58321774", "0.58061934", "0.5792795", "0.5789719", "0.57760155", "0.5744504", "0.5736587", "0.5727131", "0.5721008", "0.57135165", "0.57108545", "0.57077926", "0.5700162", "0.56950825", "0.56870687", "0.567902", "0.5654878", "0.56495327", "0.5648513", "0.5648513", "0.5647314", "0.56445074", "0.5632343", "0.56302875", "0.56225526", "0.561323", "0.5600664", "0.55961174", "0.55857265", "0.5574569", "0.5571892", "0.55598545", "0.55598545", "0.5558977", "0.554976", "0.55415416", "0.55219907", "0.5519641", "0.5514889", "0.5495364", "0.5481663", "0.54626215", "0.54626215", "0.5460765", "0.5459281", "0.54443836", "0.5425186", "0.54158586", "0.5414573", "0.54133576", "0.5411288", "0.54047024", "0.5390827", "0.5390409", "0.53894293", "0.5384616", "0.5381973", "0.5377738", "0.53688884", "0.536067", "0.5358353", "0.53560174", "0.5353143", "0.535197", "0.5345521", "0.5344471", "0.5342451", "0.53397363", "0.5334996", "0.53329545", "0.5328756" ]
0.6332216
10
, :except => [:index, :show ]
def contact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n prevent_non_admin\n end", "def index # Only view\n end", "def index\n @unwanteds = Unwanted.all\n end", "def index\n super\n end", "def show\n skip_authorization\n end", "def index\n\t\trender :nothing => true\n\tend", "def index\n index_filter\n end", "def index\n \n respond_to do |format|\n format.html #\n format.xml {disable_action}\n end\n end", "def skip_actions; end", "def exclude; end", "def show\n @except = Except.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @except }\n end\n end", "def index(model, instance = nil)\n # do nothing\n true\n end", "def index?\n false\n end", "def index\n @show_form = false\n\n end", "def index\n show\n end", "def show\n render :nothing => true\n end", "def index\n render layout: false\n end", "def index\n render layout: false\n end", "def index\n render layout: false\n end", "def index\n head :no_content\n end", "def show\n admin_only\n end", "def show\n admin_only\n end", "def show\n admin_only\n end", "def excluded; end", "def index\n redirect_to not_found_path\n end", "def index\n\n \n end", "def show\n index\n render :index\n end", "def show\n index\n end", "def show\n index\n end", "def show\n index\n end", "def index \n \n end", "def index \n \n end", "def index \n render :layout => false\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n\n end", "def index\n @item_not_includeds = ItemNotIncluded.all\n end", "def index\n raise \"not supported\"\n end", "def skip_tab_filter?\n !['index', 'new', 'create'].include?(params[:action])\n end", "def skip_tab_filter?\n !['index', 'new', 'create'].include?(params[:action])\n end", "def skip_tab_filter?\n !['index', 'new', 'create'].include?(params[:action])\n end", "def index?; end", "def index \n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end" ]
[ "0.7006304", "0.69962823", "0.6766851", "0.67623687", "0.6743255", "0.66927266", "0.66541106", "0.6613451", "0.6604464", "0.6580434", "0.6551282", "0.6543847", "0.6513401", "0.65105754", "0.6507022", "0.6447714", "0.6430164", "0.6430164", "0.6430164", "0.64212704", "0.6414382", "0.6414382", "0.6414382", "0.64092463", "0.6374063", "0.63738424", "0.6371625", "0.6369164", "0.6369164", "0.6369164", "0.6367571", "0.6367571", "0.6349791", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6326337", "0.6325676", "0.6322847", "0.6322611", "0.6322611", "0.6322611", "0.6306236", "0.6287051", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625", "0.62798625" ]
0.0
-1
return the location to read the stubContentMetadata.xml file from (could be in either the new or old location)
def stub_cm_file_name @stub_cm_file_name ||= path_finder.path_to_metadata_file(Settings.assembly.stub_cm_file_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metadata_full_path\n @metadata_full_path ||= \"#{File.dirname(@full_path)}/#{name}\"\n end", "def file() = pathname.relative_path_from(Cnfs.config.paths.definitions)", "def definition_root\n Rails.root.join('data', 'HCA_metadata', self.version)\n end", "def metadata_full_path\n @metadata_full_path ||= File.join(File.dirname(@full_path), name)\n end", "def to_s\n return contentHost.locationDescriptor(baseDir)\n end", "def find\n \"#{content_path}#{clean_path}\"\n end", "def metadata_file\n @metadata_file ||= site.in_source_dir(\".jekyll-metadata\")\n end", "def path_for(package)\n \"#{package.path}.metadata.json\"\n end", "def source_location()\n #This is a stub, used for indexing\n end", "def path\n http_url @store.rdoc.generator.file_dir\n end", "def meta_info_file_pathname\n return @meta_info_file_pathname if @meta_info_file_pathname\n\n @meta_info_file_pathname = RubyFileReader::Reader.meta_info_file_pathname_for(@pathname)\n end", "def doclocationcreate\n File.expand_path(\"../../test_result_report/\", __FILE__)\nend", "def path_for(package)\n \"#{package.path}.metadata.json\"\n end", "def metadata_file\n [site.regenerator.metadata_file]\n end", "def location_path\n @grpc.location\n end", "def location\n\t\tif @location\n\t\t\t@location\n\t\telsif File.exists?(default_location)\n\t\t\tdefault_location\n\t\telsif File.exists?(appstore_location)\n\t\t\tappstore_location\n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def relative_file_path_for(md_path)\n rel_md_path = relativize(md_path)\n\n if rel_md_path.end_with?(MetadataSerializer::metadata_suffix)\n rel_md_path[0..-MetadataSerializer::metadata_suffix.length - 1]\n else\n rel_md_path\n end\n end", "def module_root\n metadata_path = find_upwards('metadata.json')\n if metadata_path\n File.dirname(metadata_path)\n else\n nil\n end\n end", "def getOtherLocation\n return \"#{Dir.tmpdir}/RDITest\"\n end", "def get_content_path\r\n if ENV[\"RACK_ENV\"] != \"test\"\r\n File.expand_path(\"..\", __FILE__) + \"/content_files\"\r\n else\r\n File.expand_path(\"..\", __FILE__) + \"/test/content_files\"\r\n end\r\nend", "def infos_path\n\t@infos_path ||= File.join(main_folder, 'infos.yaml')\nend", "def content_path\n raise \"An Entry must define a `content_path` in its Spec.\"\n end", "def esri_opendata_metadata\n File.read(File.join(File.dirname(__FILE__), './docs/esri_open_data.json'))\n end", "def esri_opendata_metadata\n File.read(File.join(File.dirname(__FILE__), './docs/esri_open_data.json'))\n end", "def contents_root\n config[:root]\n end", "def metadata_path\n File.join(Rake.original_dir, 'metadata.rb')\nend", "def metadata_xml\n Nokogiri::XML(original_file.content)\n end", "def path\n @reader.path\n end", "def metadata_file; end", "def metadata_file; end", "def local_path\n src = if %i(direct repo).include?(new_resource.source)\n package_metadata[:url]\n else\n new_resource.source.to_s\n end\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(src))\n end", "def abs_filepath\n @epub.manifest.abs_path_from_id(@id)\n end", "def path\n http_url RDoc::RDoc.current.generator.file_dir\n end", "def get_existing_spec_location\n [ \n \"#{Dir.pwd}/#{Default.default_specfile_name}\",\n Dir[\"#{Dir.pwd}/*/#{Default.default_specfile_name}\"],\n \"#{Default.remote_storage_path}/#{Default.default_specfile_name}\", \n \"#{Default.default_specfile_name}\", \n \"#{Default.base_config_directory}/#{Default.default_specfile_name}\",\n \"#{Default.poolparty_home_path}/#{Default.default_specfile_name}\", \n ENV[\"POOL_SPEC\"]\n ].flatten.reject {|a| a.nil?}.reject do |f|\n f unless ::File.readable?(f)\n end.first\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 path\n @absolute_path.sub(%r{^#{Slimdown.config.location}/(.*)\\.md}, '\\1')\n end", "def filepath\n @epub.manifest.path_from_id(@id)\n end", "def relative_path\n @relative_path ||= File.join(doc.relative_path, \"#excerpt\")\n end", "def library_xml_path\n @ole.LibraryXMLPath\n end", "def doclocation\n File.expand_path(\"../../uploaddoc/\", __FILE__)\nend", "def source_path\n File.expand_path \"sitemap.xml\", File.dirname(__FILE__)\n end", "def locate\r\n File.dirname(__FILE__)\r\n end", "def locate\r\n File.dirname(__FILE__)\r\n end", "def content\n return @content if @content\n raise Puppet::DevError, \"No source for content was stored with the metadata\" unless metadata.source\n\n unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source)\n fail \"Could not find any content at %s\" % metadata.source\n end\n @content = tmp.content\n end", "def cached_location\n dlt = (download_type) ? download_type : 'default'\n Drupid.cache_path + self.class.to_s.split(/::/).last + extended_name + dlt + name\n end", "def path\n if @site.config[\"feed\"] && @site.config[\"feed\"][\"path\"]\n @site.config[\"feed\"][\"path\"]\n else\n \"feed.xml\"\n end\n end", "def source_path\n File.expand_path \"feed.xml\", File.dirname(__FILE__)\n end", "def location\n return unless exists?\n folder_pathname.relative_path_from(root_path)\n end", "def file= location\n @file = case location\n when RDoc::TopLevel then\n location.relative_name\n else\n location\n end\n end", "def source_location; end", "def path\n File.join(doc.path, \"#excerpt\")\n end", "def module_root\n metadata_path = find_upwards('metadata.json')\n if metadata_path\n File.dirname(metadata_path)\n elsif in_module_root?\n Dir.pwd\n end\n end", "def base\n\t\t@base ||= begin\n\t\t\tzip_file = Dir[File.join(self.location,\"*.zip\")].sort.first\n\t\t\tif zip_file\n\t\t\t\tZip::File.open(zip_file){ |z| z.get_entry(\"contents.xml\").get_input_stream.read }\n\t\t\telse\n\t\t\t\traise RuntimeError, \"Rubyfocus::LocalFetcher looking for zip files at #{self.location}: none found.\"\n\t\t\tend\n\t\tend\n\tend", "def content_paths\n if @content_paths.nil?\n paths = if filesystem_path.end_with?(\".content.xml\")\n Pathname(filesystem_path).parent.to_s\n elsif sling_initial_content? and filesystem_path.end_with?(\".json\")\n [filesystem_path, filesystem_path.gsub(/.json$/, \"\")].delete_if { |path| !File.exist?(path) }\n else\n filesystem_path\n end\n\n @content_paths = Array(paths)\n end\n\n @content_paths\n end", "def patched_location\n cached_location.dirname + '__patches' + name\n end", "def path\n http_url @store.rdoc.generator.class_dir\n end", "def manifest_path\n path = @config[\"manifest\"][\"path\"] if @config[\"manifest\"]\n return Licensed::Git.repository_root.join(path) if path\n\n @config.cache_path.join(\"manifest.json\")\n end", "def path\n return self.saved? ? @realfile.path : nil\n end", "def pkg_metadata_file\n @pkg_metadata_file ||= File.join(staging_dir, \"gen.manifestfile\")\n end", "def rightlink_metadata_dir\n var_dir = File.join( RUBY_PLATFORM =~ /mswin|mingw|windows/ ? [ENV['ProgramData'],'RightScale'] : ['/', 'var'] )\n metadata_dir = File.join(var_dir, 'spool','cloud','meta-data')\n metadata_dir\n end", "def getNewLocation\n @Called = true\n return @Directory\n end", "def pathSourceDoc\n\t\"./documentation/\"\nend", "def staging_root\n Pathname.new(CookbookOmnifetch.cache_path).join(\".cache_tmp\", \"metadata-installer\")\n end", "def location\n @grpc.location.split(\"/\")[3]\n end", "def media_path_location\n return @media_path_location\n end", "def realpath\n @site.tags[@tag].sort_by do |v|\n v.data[\"date\"]\n end.first.relative_path\n end", "def get(from_location, local_filepath, revision = nil)\n contents, metadata = @client.get_file_and_metadata(from_location, revision)\n File.open(local_filepath, 'wb'){ |f| f.write contents }\n metadata\n rescue\n puts $! if @@verbose\n nil\n end", "def file_location(options={})\n self.class.file_location(options)\n end", "def feed_source_path\n @feed_source_path ||= File.expand_path \"feed.xml\", __dir__\n end", "def local_file_list_path\n File.join config.config_dir, 'files.xml.bz2'\n end", "def get_content_search_paths()\n r = @file_content_search_paths.clone\n p = find_project_dir_of_cur_buffer()\n if p.nil?\n p = vma.buffers.last_dir\n end\n\n if p and !@file_content_search_paths.include?(p)\n r.insert(0, p)\n end\n\n return r\n end", "def location\r\n infoxml = get_info\r\n return infoxml.at('location').inner_text\r\n end", "def root_file_path; end", "def get_pkg_location(cookbook)\n\n version = node.etcd.version\n base_url = get_mirror_svc('etcd')\n Chef::Log.info(\"Etcd base_url: #{base_url}\")\n\n # Replace any $version/$arch/$extn placeholder variables present in the URL\n # e.x: https://github.com/coreos/etcd/releases/download/v$version/etcd-v$version-$arch.$extn\n base_url = base_url.gsub('$version', version)\n .gsub('$arch', node.etcd.arch)\n .gsub('$extn', node.etcd.extn)\n exit_with_err(\"Invalid package base URL: #{base_url}\") unless url_valid?(base_url)\n\n file_name = File.basename(URI.parse(base_url).path)\n Chef::Log.info(\"Package url: #{base_url}, filename: #{file_name}\")\n return File.dirname(base_url), file_name\n\n end", "def get_pkg_location(cookbook)\n\n version = node.etcd.version\n base_url = get_mirror_svc('etcd')\n Chef::Log.info(\"Etcd base_url: #{base_url}\")\n\n # Replace any $version/$arch/$extn placeholder variables present in the URL\n # e.x: https://github.com/coreos/etcd/releases/download/v$version/etcd-v$version-$arch.$extn\n base_url = base_url.gsub('$version', version)\n .gsub('$arch', node.etcd.arch)\n .gsub('$extn', node.etcd.extn)\n exit_with_err(\"Invalid package base URL: #{base_url}\") unless url_valid?(base_url)\n\n file_name = File.basename(URI.parse(base_url).path)\n Chef::Log.info(\"Package url: #{base_url}, filename: #{file_name}\")\n return File.dirname(base_url), file_name\n\n end", "def absolute_location\n peer.get_absolute_location.clone\n end", "def doc_file_path\n \"#{@structure[:working_path]}/docs/#{@structure[:full_relation_name]}.md\"\n end", "def source_file\n @source_location[0]\n end", "def content\n return @content if @content\n raise Puppet::DevError, \"No source for content was stored with the metadata\" unless metadata.source\n\n unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source, :environment => resource.catalog.environment)\n fail \"Could not find any content at %s\" % metadata.source\n end\n #debug 'fragment get content from source'\n @content = tmp.content\n end", "def configuration_file_path; end", "def external_path_for_source\n @external_path_for_source ||= File.join('source', 'external_document', external_name)\n end", "def getExistingCachedContentTreeFile\n #N Without this check, it would try to find the cached content file when none was specified\n if cachedContentFile == nil\n #N Without this, there will be no feedback to the user that no cached content file is specified\n puts \"No cached content file specified for location\"\n return nil\n #N Without this check, it will try to open the cached content file when it doesn't exist (i.e. because it hasn't been created, or, it has been deleted)\n elsif File.exists?(cachedContentFile)\n #N Without this, it won't return the cached content file when it does exist\n return cachedContentFile\n else\n #N Without this, there won't be feedback to the user that the specified cached content file doesn't exist.\n puts \"Cached content file #{cachedContentFile} does not yet exist.\"\n return nil\n end\n end", "def location\n wrap.location\n end", "def original_fullpath; end", "def gemfile_path\n @gemfile_path ||= begin\n path = ::File.expand_path(new_resource.path)\n if ::File.file?(path)\n # We got a path to a real file, use that.\n path\n else\n # Walk back until path==dirname(path) meaning we are at the root\n while path != (next_path = ::File.dirname(path))\n possible_path = ::File.join(path, 'Gemfile')\n return possible_path if ::File.file?(possible_path)\n path = next_path\n end\n end\n end\n end", "def virtual_path\n\t\tself.class.local_file_path_from_hash( Pathname.new('/managed_file_resource_images/'), self.file_hash ).to_s\n end", "def read_path\n @read_path ||= self.class.image_read_path.dup\n end", "def original_path\n \"content/feed.rss.haml\"\n end", "def getRefPath()\n return @refPath\n end", "def filepath\n @filepath\n end", "def filepath\n @filepath\n end", "def filepath\n @filepath\n end", "def node_files_path()\n return File.join(@base_path, 'pages')\n end", "def provider_root(lookup_invocation)\n configuration_path(lookup_invocation).parent\n end", "def getReferencePath()\n inputParams = BWAParams.new()\n inputParams.loadFromFile()\n @referencePath = inputParams.getReferencePath()\n\n if isEmptyOrNull(@referencePath)\n @referencePath = \"none\"\n end\n end", "def get_remote_dir\n return @resource[:remote_dir]\n end", "def location\n @client.get(\"#{path}/location\")\n end", "def snapshot_metadata_url\n \"#{artifact_directory_url}/maven-metadata.xml\"\n end", "def source_location\n source_component.source_location\n end", "def local_path\n fetch_path(DevTools.gem_root)\n end" ]
[ "0.60456425", "0.6014891", "0.5996093", "0.59916687", "0.5981252", "0.587458", "0.5837271", "0.58074325", "0.5786748", "0.57599765", "0.5732341", "0.57246023", "0.57190514", "0.57072794", "0.57066685", "0.57032806", "0.56712615", "0.56645745", "0.5661508", "0.56613666", "0.5640307", "0.5631751", "0.5615823", "0.5615823", "0.5614201", "0.5613962", "0.55843884", "0.55614007", "0.55501175", "0.55501175", "0.554817", "0.5546737", "0.5539019", "0.5513972", "0.55102545", "0.5495907", "0.54903674", "0.54723597", "0.54638803", "0.54607636", "0.545375", "0.5452021", "0.5452021", "0.54471225", "0.5426335", "0.5418365", "0.54148245", "0.5404519", "0.5397258", "0.53848565", "0.53785145", "0.5363248", "0.5334412", "0.53045756", "0.5287585", "0.52796626", "0.52748114", "0.527203", "0.52705836", "0.5251681", "0.5248304", "0.52434164", "0.52427113", "0.5232614", "0.52228105", "0.52223736", "0.52170557", "0.52164423", "0.5211456", "0.521028", "0.5201601", "0.5200873", "0.5198855", "0.5193219", "0.5193219", "0.51904136", "0.5188855", "0.5181918", "0.51767415", "0.51611006", "0.514572", "0.5145515", "0.51373404", "0.5136303", "0.51310384", "0.51299185", "0.5129818", "0.5120505", "0.51163495", "0.5105567", "0.5105567", "0.5105567", "0.5091366", "0.50805116", "0.50785637", "0.5075454", "0.5073149", "0.5068936", "0.5067748", "0.50658214" ]
0.56455034
20
this determines the reading order from the stub_object_type (default ltr unless the object type contains one of the possible "rtl" designations)
def book_reading_order return 'right-to-left' if stub_object_type.include?('rtl') || stub_object_type.include?('r-l') 'left-to-right' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line_order = locale_info(:layout, :orientation, :line_order)", "def text_direction\n I18n.translate(:'bidi.direction') == 'right-to-left' ? 'rtl' : 'ltr'\n # in ../locale/he.yml add\n # he:\n #bidi:\n #direction: right-to-left\n # then in ../locale/root.yml add\n # root:\n #bidi:\n # direction: left-to-right\n end", "def text_direction\n I18n.translate(:'bidi.direction') == 'right-to-left' ? 'rtl' : 'ltr'\n # in ../locale/he.yml add\n # he:\n #bidi:\n #direction: right-to-left\n # then in ../locale/root.yml add\n # root:\n #bidi:\n # direction: left-to-right\n end", "def language_direction\n \"ltr\"\n end", "def direction\n # For future reference\n # Hebrew - U+05D0 to U+05EA, U+05F0 to U+05F2, U+05BE, U+05C0, U+05C3, U+05F3, U+05F4, U+05B0 to U+05C4, U+0591 to U+05AF.\n # Arabic - U+0600 to U+06FF, U+0750 to U+077F, U+FB50 to U+FDFF, U+FE70 to U+FEFF, U+10E60 to U+10E7F.\n # ltrChars = 'A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02B8\\u0300-\\u0590\\u0800-\\u1FFF'+'\\u2C00-\\uFB1C\\uFDFE-\\uFE6F\\uFEFD-\\uFFFF',\n # rtlChars = '\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC',\n\n dir = options[:font][:direction]\n if dir == :auto\n if /[\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC]/.match(text_content)\n 'right-to-left'\n else\n 'left-to-right'\n end\n else\n dir\n end\n end", "def polarity\n ORDERING[@direction] || ORDERING[:asc]\n end", "def rtl?\n t(\"site.direction\", :default => \"ltr\") == \"rtl\"\n end", "def guess_byte_order\n # Assume native, since we don't know what type of file we have.\n :native\n end", "def character_order = locale_info(:layout, :orientation, :character_order)", "def text_direction_css\n rtl_languages = [:he]\n if rtl_languages.include?(I18n.locale.to_sym)\n 'direction-rtl'\n else\n 'direction-ltr'\n end\n end", "def directionality\n return @directionality\n end", "def fallback_sort_order(direction)\n \"#{resource_handler.model.table_name}.id #{direction}\"\n end", "def bit_order\n @bit_order ||= parent.respond_to?(:bit_order) ? parent.bit_order : :lsb0\n end", "def text_direction\n I18n.t(\"languages.#{locale}.direction\", default: 'ltr')\n end", "def default_ordering(field_name)\n case field_name\n when \"status\"; return(\"ascending\")\n when \"from\"; return(\"ascending\")\n when \"subject\"; return(\"ascending\")\n when \"date\"; return(\"descending\")\n end \n end", "def page_progression_direction(val)\n raise assert unless ['rtl', 'ltr', 'default'].member? val\n @book.page_progression_direction = val\n end", "def detect_standard_refmode_readings fact_type, entity_role, value_role\n forward_reading = reverse_reading = nil\n fact_type.all_reading.each do |reading|\n if reading.text =~ /^\\{(\\d)\\} has \\{\\d\\}$/\n if reading.role_sequence.all_role_ref.detect{|rr| rr.ordinal == $1.to_i}.role == entity_role\n forward_reading = reading\n else\n reverse_reading = reading\n end\n elsif reading.text =~ /^\\{(\\d)\\} is of \\{\\d\\}$/\n if reading.role_sequence.all_role_ref.detect{|rr| rr.ordinal == $1.to_i}.role == value_role\n reverse_reading = reading\n else\n forward_reading = reading\n end\n end\n end\n trace :mode, \"Didn't find standard forward reading\" unless forward_reading\n trace :mode, \"Didn't find standard reverse reading\" unless reverse_reading\n [forward_reading, reverse_reading]\n end", "def ol_depth(node)\n depth = node.ancestors(\"ul, ol\").size + 1\n type = :alphabet\n type = :arabic if [2, 7].include? depth\n type = :roman if [3, 8].include? depth\n type = :alphabet_upper if [4, 9].include? depth\n type = :roman_upper if [5, 10].include? depth\n ol_style(type)\n end", "def modo_ord!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 50 )\n\n\n\n type = ModoOrd\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 453:3: ( 'asc' | 'desc' )\n # at line 453:3: ( 'asc' | 'desc' )\n alt_15 = 2\n look_15_0 = @input.peek( 1 )\n\n if ( look_15_0 == 0x61 )\n alt_15 = 1\n elsif ( look_15_0 == 0x64 )\n alt_15 = 2\n else\n raise NoViableAlternative( \"\", 15, 0 )\n\n end\n case alt_15\n when 1\n # at line 453:4: 'asc'\n match( \"asc\" )\n\n\n when 2\n # at line 453:10: 'desc'\n match( \"desc\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 50 )\n\n\n end", "def bit_order\n @bit_order ||= if parent\n parent.bit_order\n else\n :lsb0\n end\n end", "def direction_for_solr\n DIRECTIONS[@direction] || \n raise(\n ArgumentError,\n \"Unknown sort direction #{@direction}. Acceptable input is: #{DIRECTIONS.keys.map { |input| input.inspect } * ', '}\"\n )\n end", "def directionality=(value)\n @directionality = value\n end", "def is_rtl_locale\n I18n.locale.to_s.eql?(\"he\")\n end", "def sort_direction\n params[\"order\"][\"0\"][\"dir\"] == \"desc\" ? \"desc\" : \"asc\"\n end", "def sort_types\n @sort_types ||= begin\n sql = <<-SQLT\n SELECT\n CASE\n WHEN min(sortkey) < 0 THEN 'interleaved'\n ELSE 'compound'\n END AS sort_type, tablename\n FROM pg_table_def\n WHERE tablename in (#{tables_for_sql})\n GROUP BY tablename\n SQLT\n RailsRedshiftReplicator.connection.exec(sql.squish).entries\n end\n end", "def list_type\n case @node.name\n when 'ol' then :ordered\n when 'ul' then :unordered\n end\n end", "def original_order\n end", "def normalize_order!\n @order = @order.map do |order_by|\n case order_by\n when Direction\n order_by\n when Property\n # TODO: if the property's resource doesn't match\n # self.resource, append the property's resource to @links\n # eg:\n #if property.resource != self.resource\n # @links << discover_path_for_property(property)\n #end\n\n Direction.new(order_by)\n when Symbol, String\n Direction.new(@properties[order_by])\n else\n raise ArgumentError, \"Order #{order_by.inspect} not supported\"\n end\n end\n end", "def line_order\n [:controller_files, :model_files, :view_files, :lib_files, :controller_specs, :model_specs, :view_specs]\n end", "def <=>(object)\n return -1 if object.language.nil?\n # Put Chinese when sorting\n return -1 if object.language.code == 'chi'\n return 1 if object.language.code == 'eng'\n return self.name <=> object.name\n end", "def arel_order\n text_columns = if params[:order]\n params[:order].split(' ')\n elsif self.default_sort\n [self.default_sort].flatten\n else\n [model_class.primary_key].flatten\n end\n sort_columns = text_columns.map do |column|\n if column.to_s.include?('.')\n name,direction = column.to_s.split('.',2)\n raise \"Illegal sort direction: #{direction} in #{column}\" unless %w{asc desc}.include?(direction)\n table[name].send(direction)\n else\n table[column]\n end\n end\n sort_columns\n end", "def order\n if terminal?\n 0\n elsif self_referential?\n 1\n else\n r = 0\n @rules.each do |rule|\n # Only interested in rule with recursion\n if rule.size > 1\n rule.each do |elem|\n # Only interested in references\n if elem.is_a? String\n b = @klass.defs.find_all {|i| i.name == elem}[0].order + 1\n r = b if b > r # swap if higher\n end\n end\n end\n end\n r\n end\n end", "def direction\n return @direction\n end", "def getRecoveryOrderObjName\r\n\t\t\treturn \"mfiforce__Recovery_Order__c\"\r\n\t\tend", "def read_object\n if @read_object\n @read_object\n else\n warn \"No read_object info has been defined for this reader.\"\n end\n end", "def get_line_types\n @lines.line_types\n end", "def text_direction(direction = nil)\n if direction.nil?\n defined?(@text_direction) && @text_direction || :ltr\n else\n @text_direction = direction\n end\n end", "def bit_order\n parent.bit_order\n end", "def document_types\n {\n ORIGINAL: %w(TY ID T1 TI CT A1 A2 AU Y1 PY N1 KW RP SP EP JF JO JA J1 J2 VL IS T2 CY PB U1 U5 T3 N2 SN AV M1 M3 AD UR L1 L2 L3 L4 ER),\n GEN: %w(TY A2 A3 A4 AB AD AN AU C1 C2 C3 C4 C5 C6 C7 C8 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RI RN RP SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n JOUR: %w(TY AB AD AN AU C1 C2 C6 C7 CA CN DA DB DO DP ET J2 KW L1 L4 LA LB IS M2 M3 N1 OP PY RI RN RP SN SP ST T2 TA TI TT UR VL Y2 ER),\n BLOG: %w(TY A2 A3 AB AD AN AU C1 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M3 N1 OP PB PY RN SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n BOOK: %w(TY A3 A2 A4 AB AD AN AU C3 C4 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RN RP SE SN SP ST T2 TA TI TT UR VL Y2 ER),\n CASE: %w(TY A2 A3 A4 AB AD AN CA CN DA DB DO DP ET KW L1 L4 LA LB M3 N1 NV OP PB PY RN SE SP ST T3 TA TI TT UR VL Y2 ER),\n EBSCO: %w(JN VO)\n }\n end", "def hook_order\n self.class.options[:hook_order]\n end", "def direction; end", "def direction; end", "def get_type\n \"line\"\n end", "def get_ordering_fields\n return self.class.ordering_fields&.map(&:to_s) || self.get_fields\n end", "def flexmock_current_order\n @flexmock_current_order ||= 0\n end", "def line_breakdown_types\n TrendReport.line_breakdown_types\n end", "def sort_order\n sortable_column_order do |column, direction|\n if resource_handler.model_associations.present? && column.match(/\\./)\n table, column = column.split('.')\n if resource_handler.model_associations.detect { |a| a.table_name == table }\n \"#{table}.#{column} #{direction}\"\n else\n fallback_sort_order(direction)\n end\n elsif resource_handler.model.column_names.include?(column.to_s)\n \"#{resource_handler.model.table_name}.#{column} #{direction}\"\n else\n fallback_sort_order(direction)\n end\n end\n end", "def txn_read_preference\n rp = txn_options[:read] ||\n @client.read_preference\n Mongo::Lint.validate_underscore_read_preference(rp)\n rp\n end", "def wrap_html_for_rtl(content)\n plain_text = Nokogiri::HTML(content).text\n\n case RtlThatString::DETECTOR.direction(plain_text)\n when StringDirection::RTL\n rtl_html_borders(content)\n when StringDirection::BIDI\n Rails.logger.info \"*** #{bidi_processor.inspect}\"\n Rails.logger.info \"*** #{RtlThatString.configuration.inspect}\"\n bidi_processor.run(plain_text) ? bidi_html_borders(content) : content\n else\n content\n end\n end", "def is_ordered?\n # TODO Stubbed - Requires definition and implementation\n end", "def ascending?\n direction == :asc\n end", "def sorted_properties\n properties.sort {|a,b| \n case\n when a == master\n -1\n when b == master\n 1\n else\n a.locale <=> b.locale\n end\n }\n \n end", "def nonstandard_lro_name\n \"NonstandardLro\"\n end", "def read_locale\n raise \"Override me\"\n end", "def reverse_operation_type(operation_type)\n @reverse_order_operations ||= {\n 'is' => 'is',\n 'is_equal_to' => 'is_equal_to',\n 'is_above' => 'is_below',\n 'is_below' => 'is_above'\n }\n @reverse_order_operations[operation_type]\n end", "def diff_types\n\t\t\tavailable = []\n\n\t\t\tif @parent.file_1.contains_found? and @parent.file_2.contains_found? then\n\t\t\t\tavailable.push :direct\n\t\t\tend\n\n\n\t\t\tif available.empty? then\n\t\t\t\tavailable.push :notAvailable\n\t\t\tend\n\t\t\treturn available\n\t\tend", "def local_order\n owner.field_prototypes.keys\n end", "def o_type\n 8 \n end", "def define_order(s_order)\n s_order=='Crescente' ? :asc : :desc\n end", "def lob_order_by_expression(klass, order)\n return order if order.nil?\n changed = false\n new_order = order.to_s.strip.split(/, */).map do |order_by_col|\n column_name, asc_desc = order_by_col.split(/ +/)\n if column = klass.columns.detect { |col| col.name == column_name && col.sql_type =~ /LOB$/i}\n changed = true\n \"DBMS_LOB.SUBSTR(#{column_name},100,1) #{asc_desc}\"\n else\n order_by_col\n end\n end.join(', ')\n changed ? new_order : order\n end", "def current_order_direction\n direction = nil\n if @mg_params.key?(:order_direction) && %w(asc desc).include?(@mg_params[:order_direction].downcase)\n direction = @mg_params[:order_direction].downcase\n end\n direction\n end", "def s_typesort; det.link(:text, 'Type'); end", "def load_order\n @cache_load_order = read_load_order unless defined?(@cache_load_order)\n @cache_load_order\n end", "def direction\n @direction ||= (@head - @root)\n end", "def get_file_display_order(file)\n if !file.nil? && file.data.display_order\n return file.data.display_order\n else\n return \"0\"\n end\n end", "def lines\n old_order_lines\n end", "def default_direction\n dd = self['DefaultDirection']\n\n if (dd and dd.to_s.match(/(-1|backward)/i))\n return -1\n end\n\n return 1\n end", "def type index\n @order[index][1]\n end", "def safeSort type\r\n\t\traise \"CrossValidatorSet::InvalidSortType\" if ! @@acceptableSortMethods.include? type.to_sym\r\n\t\t@set.sort{|a, b| a.getError.rmse <=> b.getError}\r\n\tend", "def parse_direction(direction)\n direction.to_s.match(/^desc/i) ? 'desc' : 'asc'\n end", "def object_direction(object)\r\n for i in 0..3\r\n if @warrior.feel(DIRECTIONS[i]).send(object)\r\n return DIRECTIONS[i]\r\n end\r\n end\r\n end", "def sort_edition\n \"-#{barcode.edition}\"\n end", "def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n\n end", "def change_AL_to_R par, run\n sor=run['sor']\n eor_m1=run['eor'] - 1\n chars=par['characters']\n sor.upto eor_m1 do |ind|\n chars[ind]['bidiType']='R' if chars[ind]['bidiType']=='AL'\n end\n end", "def to_read\n if self.object_id.nil?\n [self.object_id.to_s, self.start, (self.end - self.start) - 1, '1', '1', self.sequence]\n else\n [self.object_id, self.start, (self.end - self.start) - 1, '1', '1', self.sequence]\n end\n end", "def set_language_dependent_sorting\n for model in APPCTRL_TRANSLATABLE_MODELS\n model.set_sorting() if model.respond_to?( :set_sorting )\n end\n end", "def libraries_order\n order = [:Ruby_]\n order.unshift(:Statistics2_) if has_statistics2?\n order.unshift(:GSL_) if has_gsl?\n order.unshift(:Java_) if has_java?\n order\n end", "def assign_types_to_lines(margin = 0, level = 0)\n while line = @lines.next\n if line.blank? then\n line.stamp :BLANK, level\n next\n end\n\n # if a line contains non-blanks before the margin, then it must belong\n # to an outer level\n\n text = line.text\n\n for i in 0...margin\n if text[i] != SPACE\n @lines.unget\n return\n end\n end\n\n active_line = text[margin..-1]\n\n # Rules (horizontal lines) look like\n #\n # --- (three or more hyphens)\n #\n # The more hyphens, the thicker the rule\n #\n\n if /^(---+)\\s*$/ =~ active_line\n line.stamp :RULE, level, $1.length-2\n next\n end\n\n # Then look for list entries. First the ones that have to have\n # text following them (* xxx, - xxx, and dd. xxx)\n\n if SIMPLE_LIST_RE =~ active_line\n offset = margin + $1.length\n prefix = $2\n prefix_length = prefix.length\n\n flag = case prefix\n when \"*\",\"-\" then :BULLET\n when /^\\d/ then :NUMBER\n when /^[A-Z]/ then :UPPERALPHA\n when /^[a-z]/ then :LOWERALPHA\n else raise \"Invalid List Type: #{self.inspect}\"\n end\n\n line.stamp :LIST, level+1, prefix, flag\n text[margin, prefix_length] = \" \" * prefix_length\n assign_types_to_lines(offset, level + 1)\n next\n end\n\n if LABEL_LIST_RE =~ active_line\n offset = margin + $1.length\n prefix = $2\n prefix_length = prefix.length\n\n next if handled_labeled_list(line, level, margin, offset, prefix)\n end\n\n # Headings look like\n # = Main heading\n # == Second level\n # === Third\n #\n # Headings reset the level to 0\n\n if active_line[0] == ?= and active_line =~ /^(=+)\\s*(.*)/\n prefix_length = $1.length\n prefix_length = 6 if prefix_length > 6\n line.stamp :HEADING, 0, prefix_length\n line.strip_leading(margin + prefix_length)\n next\n end\n\n # If the character's a space, then we have verbatim text,\n # otherwise\n\n if active_line[0] == SPACE\n line.strip_leading(margin) if margin > 0\n line.stamp :VERBATIM, level\n else\n line.stamp :PARAGRAPH, level\n end\n end\n end", "def get_list_order(sort, dir)\n\t\t\tif sort\n\t\t\t\tcolumn_order_mapping = get_sext_constant('SEXT_COLUMN_ORDER_MAPPING')\n\n\t\t\t\t# Lookup and use the designated ordering if defined in the model.\n\t\t \t\tif column_order_mapping && column_order_mapping.has_key?(sort.to_sym)\n\t\t \t\t\tsort = column_order_mapping[sort.to_sym]\n\n\t\t \t\t# Use the passed in value if it looks complete with table name.\n \t\t\t\telsif !sort.include?('.')\n\t\t\t\t\tsort = [self.table_name, sort].join('.')\n\t\t \t\tend\n\n\t\t\t\tdir ||= \"ASC\"\n\t\t \t\torder = sort + \" \" + dir\n\t\t \telse\n\t\t \t\torder = get_sext_constant('SEXT_DEFAULT_SORT')\n\t\t \tend\n\t\t \t\n\t\t\treturn order\t\n\t\tend", "def another_order_direction\n @mg_params.key?(:order_direction) ? (%w(asc desc) - [@mg_params[:order_direction].to_s]).first : MightyGrid.order_direction\n end", "def top_down\n\t\t@roof_status = \"open\" if @convertible\n\tend", "def lf_type(type)\n type = type.downcase.gsub(' ', '_').intern if type.class == String\n\n case type\n when :normal\n retval = self.lf\n when :rot\n retval = self.lf\n when :best_in_slot\n retval = self.bislf\n when :bis\n retval = self.bislf\n when :situational\n retval = self.sitlf\n when :sit\n retval = self.sitlf\n end\n end", "def mark_as_read(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_read if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_read(self)\n when Mailboxer::Conversation\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n end", "def sort_direction\n params[:dir] == \"asc\" ? \"asc\" : \"desc\"\n end", "def rtl_locales\n %i[ar]\n end", "def ascending?(objects)\n column_values_array = []\n objects.each do |row|\n column_values_array << row.text.downcase\n end\n column_values_array == column_values_array.sort\n end", "def direction\n @params[:direction] || :desc\n end", "def order_type\n xml_field('orderType', 1, false)\n end", "def get_direction\n return (@dir || @character.direction)\n end", "def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self, details)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj, details) }\n end\n\n end", "def descending?(objects)\n column_values_array = []\n objects.each do |row|\n column_values_array << row.text.downcase\n end\n column_values_array == column_values_array.sort.reverse\n end", "def determine_paragraph_type\n @paragraph_type = \\\n case\n when blank?\n :blank\n when definition_list? # order is important! A definition_list is also an unordered_list!\n :definition_term\n when (ordered_list? or unordered_list?)\n :list_item\n when property_drawer_begin_block?\n :property_drawer_begin_block\n when property_drawer_end_block?\n :property_drawer_end_block\n when property_drawer_item?\n :property_drawer_item\n when metadata?\n :metadata\n when block_type\n if block_should_be_exported?\n case block_type.downcase.to_sym\n when :center, :comment, :example, :html, :quote, :src\n block_type.downcase.to_sym\n else\n :comment\n end\n else\n :comment\n end\n when title?\n :title\n when raw_text? # order is important! Raw text can be also a comment\n :raw_text\n when comment?\n :comment\n when table_separator?\n :table_separator\n when table_row?\n :table_row\n when table_header?\n :table_header\n when inline_example?\n :inline_example\n when horizontal_rule?\n :horizontal_rule\n else :paragraph\n end\n end", "def ascending?\n @direction == 1\n end", "def translation_order( name )\n TRANSLATION_ORDER.index( name.to_s ) || TRANSLATION_ORDER.count\n end", "def get_draw_ordering\n # raise \"Need to override via subclass\"\n nil\n end", "def FieldTypes\n @_FieldTypes ||= OLEProperty.new(@ole, 9, [VT_BSTR], [VT_BSTR, VT_BSTR])\n end", "def encode_sort_controls(sort_definitions)\n return sort_definitions unless sort_definitions\n\n sort_control_values = sort_definitions.map do |control|\n control = Array(control) # if there is only an attribute name as a string then infer the orderinrule and reverseorder\n control[0] = String(control[0]).to_ber,\n control[1] = String(control[1]).to_ber,\n control[2] = (control[2] == true).to_ber\n control.to_ber_sequence\n end\n sort_control = [\n Net::LDAP::LDAPControls::SORT_REQUEST.to_ber,\n false.to_ber,\n sort_control_values.to_ber_sequence.to_s.to_ber\n ].to_ber_sequence\n end", "def default_sort_order\n ::Mincer.config.sorting.order_attribute\n end", "def order_from_source\n order = []\n control.sources.first.definition.each do |item|\n case item\n when Hash\n order << item[:name]\n else\n order << item\n end\n end\n order\n end", "def get_field_deserializers()\n return super.merge({\n \"check32BitOn64System\" => lambda {|n| @check32_bit_on64_system = n.get_boolean_value() },\n \"comparisonValue\" => lambda {|n| @comparison_value = n.get_string_value() },\n \"fileOrFolderName\" => lambda {|n| @file_or_folder_name = n.get_string_value() },\n \"operationType\" => lambda {|n| @operation_type = n.get_enum_value(MicrosoftGraph::Models::Win32LobAppFileSystemOperationType) },\n \"operator\" => lambda {|n| @operator = n.get_enum_value(MicrosoftGraph::Models::Win32LobAppRuleOperator) },\n \"path\" => lambda {|n| @path = n.get_string_value() },\n })\n end" ]
[ "0.526763", "0.52128154", "0.52128154", "0.51135576", "0.50958973", "0.5048924", "0.49184984", "0.4907119", "0.48280075", "0.47610536", "0.47595844", "0.4753641", "0.47307527", "0.4727238", "0.4699162", "0.46970668", "0.46337548", "0.4633393", "0.46326482", "0.46310407", "0.46213794", "0.46093085", "0.4604951", "0.45762008", "0.45712945", "0.4554964", "0.4553219", "0.45480022", "0.4524421", "0.45019838", "0.4497835", "0.44760594", "0.44671762", "0.44438073", "0.4437352", "0.44197798", "0.44134218", "0.43965998", "0.43800494", "0.43762225", "0.43718508", "0.43718508", "0.43676156", "0.43531254", "0.43402413", "0.43369213", "0.4325251", "0.4309698", "0.43000406", "0.42909956", "0.42878935", "0.4284468", "0.42673954", "0.42666817", "0.42612743", "0.4252115", "0.42496893", "0.4248064", "0.42466155", "0.42398223", "0.42365974", "0.4227042", "0.42216223", "0.42156443", "0.42078692", "0.4207722", "0.42043823", "0.4195638", "0.41951063", "0.41949087", "0.4191664", "0.41895592", "0.418909", "0.41869083", "0.4186255", "0.41826865", "0.41825327", "0.41770688", "0.41764772", "0.41753975", "0.4172466", "0.41697153", "0.41677105", "0.41591343", "0.41582027", "0.41560367", "0.41555703", "0.41548184", "0.41442803", "0.4140666", "0.41387182", "0.41386577", "0.41371822", "0.41310158", "0.41308406", "0.41300672", "0.41287667", "0.4128066", "0.41276392", "0.41275263" ]
0.7757093
0
return a hash for any known file attributes defined in the stub content metadata file, these will override or add to the defaults
def stub_file_attributes(file) result = {} %w[preserve publish shelve role].each { |attribute| result[attribute.to_sym] = file.at_xpath("@#{attribute}").value unless file.at_xpath("@#{attribute}").blank? } result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_attributes\n {}\n end", "def file_attributes\n {}\n end", "def internal_file_attributes; end", "def file_attributes\n get_attributes_set(:FILE_ATT_LOOKUPS)\n end", "def file_attributes\n get_attributes_set(:FILE_ATT_LOOKUPS)\n end", "def external_file_attributes; end", "def metadata\n @metadata.tap do |h|\n # This represents the minimal set of attribute methods that should be available in every subclass.\n h[:mime_type] = mime_type if mime_type\n h[:filename] = filename if filename\n h[:digest] = digest if digest\n h[:size] = size if size\n h[:last_modified] = last_modified if last_modified\n end\n end", "def external_file_attributes=(_arg0); end", "def add_file_metadata\n file_data = {}\n file_data[:filename] = File.basename(options[:original_filename])\n file_data[:file_size] = File.size(options[:original_filename])\n file_data[:record_delimiter] = options[:delimiter]\n file_data[:rows] = options[:rows]\n file_data[:columns] = options[:csv_column_datatypes].keys.size\n file_data[:processed_filename] = File.basename(options[:filename])\n file_data[:processed_file_path] = options[:filename]\n file_data[:processed_file_size] = File.size(options[:filename])\n file_data[:error_report] = options[:temp_file]\n return file_data\n end", "def metadata\n metadata = {}\n @file.data.each { |key, value| metadata[key.to_sym] = value }\n\n metadata[:type] = @file.class.name.split('::')[1].downcase\n metadata[:url] = @file.url\n\n metadata[:slug] = slug\n\n metadata[:posted_at] = @file.date.to_time.to_i if @file.respond_to? :date\n metadata[:tags] = tags\n\n metadata\n end", "def general_metadata_hash\r\n metadata = Hash.new\r\n metadata[:filename] = @datafile.file_file_name\r\n metadata[:downloads] = 0\r\n\r\n metadata[:title] = clean_string(general_metadata_sheet[*WBF[:meta_title_pos]])\r\n metadata[:abstract] = clean_string(general_metadata_sheet[*WBF[:meta_abstract_pos]])\r\n metadata[:comment] = clean_string(general_metadata_sheet[*WBF[:meta_comment_pos]])\r\n metadata[:usagerights] = clean_string(general_metadata_sheet[*WBF[:meta_usagerights_pos]])\r\n metadata[:published] = clean_string(general_metadata_sheet[*WBF[:meta_published_pos]])\r\n metadata[:spatialextent] = clean_string(general_metadata_sheet[*WBF[:meta_spatial_extent_pos]])\r\n metadata[:temporalextent] = clean_string(general_metadata_sheet[*WBF[:meta_temporalextent_pos]])\r\n metadata[:taxonomicextent] = clean_string(general_metadata_sheet[*WBF[:meta_taxonomicextent_pos]])\r\n metadata[:design] = clean_string(general_metadata_sheet[*WBF[:meta_design_pos]])\r\n metadata[:dataanalysis] = clean_string(general_metadata_sheet[*WBF[:meta_dataanalysis_pos]])\r\n metadata[:circumstances] = clean_string(general_metadata_sheet[*WBF[:meta_circumstances_pos]])\r\n return metadata\r\n end", "def hash\n [file_info, output_path, encoding, recognize_lists, leading_spaces, trailing_spaces, enable_pagination].hash\n end", "def internal_file_attributes=(_arg0); end", "def file_hashes\n @file_hashes ||= file_field_sets.map do |file_field_set|\n instantiation_fields, file_fields = file_field_set.partition do |field|\n instantiation_header?(field.header)\n end\n\n file_hash = fields_to_hash(file_fields)\n file_hash['files'] = [fields_to_hash(instantiation_fields)]\n\n file_hash\n end\n end", "def file_hash\n return @file_hash\n end", "def file_characterization_attributes\n {\n bounds: info_service.bounds,\n mime_type: mime_type\n }\n end", "def to_hash\n r = ATTR_NAMES.inject({}) { |m,e|\n m[e] = self.send(e)\n m\n }\n r[:files] = mappings_for_files.map { |e| e.to_hash }\n r\n end", "def metadata\n @manifest_options[:metadata] || {}\n end", "def metadata_file; end", "def metadata_file; end", "def fetch_metadata\n {\n \"public_fqdn\" => fetch_metadata_item(\"getFullyQualifiedDomainName.txt\"),\n \"local_ipv4\" => fetch_metadata_item(\"getPrimaryBackendIpAddress.txt\"),\n \"public_ipv4\" => fetch_metadata_item(\"getPrimaryIpAddress.txt\"),\n \"region\" => fetch_metadata_item(\"getDatacenter.txt\"),\n \"instance_id\" => fetch_metadata_item(\"getId.txt\"),\n }\n end", "def hash \n @hash ||= CobraVsMongoose.xml_to_hash(file_content)\n end", "def metadata\n attributes['metadata'] ||= {}\n attributes['metadata']\n end", "def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end", "def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end", "def files_hash\n @files_hash\n end", "def iiif_metadata\n iiif_manifest_attributes.select { |k, v| !iiif_suppressed_metadata.include?(k) && v.present? }.map do |u, v|\n MetadataObject.new(u, v).to_h\n end\n end", "def getxattrs\n # # file: Scissor_Sisters_-_Invisible_Light.flv\n # user.m.options=\"-c\"\n\n cmd = %w[getfattr -d -m - -e base64] + [realpath.to_s]\n\n attrs = {}\n\n IO.popen(cmd, \"rb\", :err=>[:child, :out]) do |io|\n io.each_line do |line|\n if line =~ /^([^=]+)=0s(.+)/\n key = $1\n value = $2.from_base64 # unpack base64 string\n # value = value.encode(\"UTF-8\", \"UTF-8\") # set string's encoding to UTF-8\n value = value.force_encoding(\"UTF-8\").scrub # set string's encoding to UTF-8\n # value = value.encode(\"UTF-8\", \"UTF-8\") # set string's encoding to UTF-8\n\n attrs[key] = value\n end\n end\n end\n\n attrs\n end", "def attributes\r\n hash = super\r\n hash.delete('author')\r\n hash.delete('images')\r\n hash[\"document_type\"] = document_type\r\n hash[\"section_name\"] = section_name\r\n hash\r\n end", "def file_characterization_attributes\n {\n mime_type: mime_type\n }\n end", "def file_characterization_attributes\n {\n geometry: info_service.geom,\n mime_type: mime_type\n }\n end", "def file_characterization_attributes\n {\n geometry: info_service.geom,\n mime_type: mime_type\n }\n end", "def hash\n [color, cards, address_placement, custom_envelope, double_sided, extra_service, mail_type, return_envelope, bleed, file_original_url].hash\n end", "def diphot_metadata_to_h\n File.open(@qualified_filename, 'r') do |fd|\n diff = fd.readline.chomp\n reference = fd.readline.chomp\n @obj_metadata = { 'diff' => diff, 'reference' => reference }\n end\n end", "def default_attributes\n @attributes = {\n :project => @name,\n :prefix => @prefix,\n :repositories => @repositories,\n :source => @source_project,\n :target => @target_project,\n :creation_date => \"#{Time.now}\",\n :last_mirror => \"0\",\n :date => \"#{Time.now}\",\n }\n end", "def hash\n [clean_result, contains_executable, contains_invalid_file, contains_script, contains_password_protected_file, contains_restricted_file_format, contains_macros, contains_xml_external_entities, contains_insecure_deserialization, contains_html, contains_unsafe_archive, verified_file_format, found_viruses, content_information].hash\n end", "def hash\n [format, text_compression, embed_full_fonts, compliance, sufficient_resolution, jpeg_quality, draw_slides_frame, show_hidden_slides, save_metafiles_as_png, password, embed_true_type_fonts_for_ascii, additional_common_font_families, notes_position, comments_position, comments_area_width, comments_area_color, show_comments_by_no_author, image_transparent_color, apply_image_transparent].hash\n end", "def iiif_manifest_attributes\n super.merge iiif_manifest_exhibit\n end", "def iiif_manifest_attributes\n super.merge iiif_manifest_exhibit\n end", "def default_metadata_for(job)\n {:width => job.width, :height => job.height, :uid => uid}#, :content_type => job.mime_type}\n end", "def metadata_info\n @metadata = Chef::Cookbook::Metadata.new\n @metadata.from_file(File.join(@opts[:path], 'metadata.rb'))\n end", "def attrs\r\n @attrs ||= Utils.deep_merge(@attributes, _package_.env)\r\n end", "def metadata(filepath)\n metadata = {}\n metadata.merge!(author(filepath))\n metadata.merge!(title(filepath))\n metadata.merge!(serie(filepath))\n metadata\n end", "def add_doc_specific_attributes(filepath, is_src, attributes); end", "def default_attributes\n cfg_get(:default_attributes)\n end", "def load_attributes\n @attributes = YAML.load_file(file).inject({}){|h,(k,v)| h[k.to_sym] = v;h}\n end", "def file_hash=(value)\n @file_hash = value\n end", "def default_attributes\n cfg_get(:default_attributes)\n end", "def metadata_file\n [site.regenerator.metadata_file]\n end", "def resource_attributes\n %w(\n auth_users\n comment\n dont_compress\n exclude\n exclude_from\n fake_super\n gid\n hosts_allow\n hosts_deny\n include\n include_from\n list\n lock_file\n log_file\n log_format\n max_connections\n munge_symlinks\n numeric_ids\n path\n read_only\n refuse_options\n secrets_file\n strict_modes\n timeout\n transfer_logging\n uid\n use_chroot\n write_only\n )\n end", "def attr_hash\n\t\t\thash = {:sourcetype => @type}\n\t\t\tcase @type\n\t\t\twhen 'random_string'\n\t\t\t\thash[:length] = @length\n\t\t\twhen 'random_number'\n\t\t\t\thash[:start] = @start\n\t\t\t\thash[:end] = @end\n\t\t\twhen 'eval'\n\t\t\t\thash[:code] = @code.chomp.to_sym\t\t\t# symbolize it in order to prevent it from being escaped\n\t\t\twhen 'file'\n\t\t\t\thash[:fileid] = @fileid\n\t\t\t\thash[:delimiter] = @delimiter\n\t\t\t\thash[:order] = @order\n\t\t\tend\n\t\t\thash\n\t\tend", "def to_hash\n {\n :id => id.to_s,\n :name => file.original_filename,\n :mime => file.content_type,\n :size => file.size,\n :versions => {\n :original => file.url,\n :icon => file.url(:icon),\n :thumb => file.url(:thumb)\n }\n }\n end", "def attributes_hash\n attributes_hash = section.attributes.to_hash\n attributes_hash.each { |k, attr| attributes_hash[k] = attr.value }\n end", "def ingest_attributes attr_file\n attr_files_array = attr_file.force_array\n attrs = {}\n attr_files_array.each do |f|\n if f.include? \":\"\n file = f.split(\":\")\n filename = file[0]\n block_name = file[1]\n else\n filename = f\n block_name = false\n end\n validate_file_input(filename, \"attributes\")\n begin\n new_attrs = YAML.load_file(filename)\n if block_name\n begin\n new_attrs = new_attrs[block_name]\n rescue\n raise \"InvalidAttributesBlock (#{filename}:#{block_name})\"\n end\n end\n rescue Exception => ex\n @logger.error \"Attributes block invalid. #{ex.class}: #{ex.message}\"\n raise \"AttributeBlockError\"\n end\n begin\n if new_attrs.is_a? Hash\n attrs.merge!new_attrs\n else\n @logger.warn \"The AsciiDoc attributes file #{filename} is not formatted as a hash, so its data was not ingested.\"\n end\n rescue Exception => ex\n raise \"AttributesMergeError #{ex.message}\"\n end\n end\n return attrs\nend", "def create_image_metadata\n {}\n end", "def attributes\n @attributes ||= {\n 'id' => nil,\n 'dzi_url' => nil,\n 'thumbnail_url' => nil,\n 'isc_row' => nil\n }\n end", "def hash\n [file_id, output_version, image_quality, recompress_images, enable_color_detection, pack_document, pack_fonts, downscale_images, downscale_resolution, fast_web_view, remove_form_fields, remove_annotations, remove_bookmarks, remove_hyperlinks, remove_embedded_files, remove_blank_pages, remove_java_script, enable_jpeg2000, enable_jbig2, enable_char_repair, enable_mrc, preserve_smoothing, downscale_resolution_mrc, remove_metadata, remove_page_thumbnails, remove_page_piece_info, jbig2_pms_threshold].hash\n end", "def hash\n [id, default_ldap, default_from_address, portal_url_override, site_url, logo_path, contact_sync, server_time_zone, default_calendar, default_address_format, use_ssl_flag, sync_leads_flag, include_portal_link_flag, use_expanded_format_time_flag, use_expanded_format_activity_flag, update_member_time_zones_flag, _info].hash\n end", "def read_meta_info\n if meta_info_file_pathname.exist?\n inode, bytes_read = meta_info_file_pathname.read.strip.split(':').map(&:to_i)\n {\n inode: inode,\n bytes_read: bytes_read\n }\n else\n {\n inode: nil,\n bytes_read: 0\n }\n end\n end", "def files\n @files ||= {}\n end", "def attributes\n data = super\n photo_path = File.join(api_user_dir(data[:username]), USER_PHOTO_FILENAME)\n username = (File.exists? photo_path)? data[:username]: 'default'\n photo_url = \"#{user_url(options[:host], username)}/#{USER_PHOTO_FILENAME}\"\n data.to_a.insert(6, [:photo_url, photo_url]).to_h\n end", "def metadata\n @metadata ||= {}\n end", "def hash\n [avatar, banner, created_at, description, handle, hidden_modules, link_count, modified_at, name, summary, user_count, visible_modules].hash\n end", "def metadata\n result = store.metadata_for_path(path).dup\n\n file_meta = store.metadata_for_file(source_file).dup\n result.deep_merge!(file_meta)\n\n local_meta = @local_metadata.dup\n result.deep_merge!(local_meta)\n\n result\n end", "def metadata\n @metadata ||= (\n if md = /\\<\\!\\-\\-\\-(.*?)\\-{2,3}\\>\\s*\\Z/m.match(content)\n YAML.load(md[1])\n else\n {}\n end\n )\n end", "def iiif_manifest_attributes\n super.merge imported_attributes\n end", "def iiif_manifest_attributes\n super.merge imported_attributes\n end", "def default_bit_metadata\n Origen::Registers.bit_metadata[:global] ||= {}\n if block_given?\n collector = Origen::Utility::Collector.new\n yield collector\n Origen::Registers.bit_metadata[:global].merge!(collector.to_h)\n end\n Origen::Registers.bit_metadata[:global]\n end", "def extract_metadata!(data = {})\n data.tap do |d|\n file = File.open(@file)\n d[:filesize] = file.size\n file.close\n\n d[:content_type] = MIME::Types.type_for(@file).first.to_s\n end\n end", "def hash\n [self_uri, alternate_links, name, width, height, alternative_text, alternative_text_title, hidden, x, y, z_order_position, fill_format, effect_format, three_d_format, line_format, hyperlink_click, hyperlink_mouse_over, type, is_object_icon, substitute_picture_title, substitute_picture_format, object_name, embedded_file_base64_data, embedded_file_extension, object_prog_id, link_path, update_automatic].hash\n end", "def hash\n [active, additional_properties, author, authored, banned, category, comments, contributors, created_date, embed, extension, height, id, length, location, long_description, mime_type, name, priority, privacy, published, short_description, size, tags, template, thumbnail, updated_date, uploader, views, width].hash\n end", "def attributes_mapping\n common = {\n :hourly_billing_flag => :hourlyBillingFlag,\n :os_code => :operatingSystemReferenceCode,\n :vlan => :primaryNetworkComponent,\n :private_vlan => :primaryBackendNetworkComponent,\n :key_pairs => :sshKeys,\n :private_network_only => :privateNetworkOnlyFlag,\n :user_data => :userData,\n :provision_script => :postInstallScriptUri,\n :network_components => :networkComponents,\n }\n\n conditional = if bare_metal?\n {\n :cpu => :processorCoreAmount,\n :ram => :memoryCapacity,\n :disk => :hardDrives,\n :bare_metal => :bareMetalInstanceFlag\n }\n else\n {\n :cpu => :startCpus,\n :ram => :maxMemory,\n :disk => :blockDevices,\n :image_id => :blockDeviceTemplateGroup,\n :ephemeral_storage => :localDiskFlag,\n }\n end\n common.merge(conditional)\n end", "def hash\n [save_format, lookup_paths, file_name, file_format, show_grid, show_rulers, show_ui, orientation_box, up_vector, far_plane, near_plane, look_at, camera_position, field_of_view].hash\n end", "def attributes_hash\n fail 'sub class to implement'\n end", "def metadata\n { :attributes => @attributes, \n :qualified_attributes => @qualified_attributes, \n :collections => @collections, \n :flatten => @flatten, \n :namespaces => @namespaces, \n :types => @types }\n end", "def base_attributes\n\t\t\t\t\t# Base Attributes to be sent for foreman host creation API\n\t\t\t\t\t\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\"name\" \t\t\t\t\t=> self.name,\n \n\t\t\t\t\t\t\"compute_resource_id\" \t=> self.compute_resource_id,\n\n\t\t\t\t\t\t\"compute_profile_id\" \t=> self.compute_profile_id,\n\t\t\t\t\t\t\n\t\t\t\t\t\t\"managed\"\t\t\t\t=> \"true\",\n\n\t\t\t\t\t\t\"type\"\t\t\t\t\t=> \"Host::Managed\",\t\t\t\t\t\t\n\n\t\t\t\t\t\t\"provision_method\"\t\t=> \"build\",\n\n\t\t\t\t\t\t\"build\"\t\t\t\t\t=> \"1\",\t\t\t\t\t\t\n\n\t\t\t\t\t\t\"disk\"\t\t\t\t\t=> \"\",\t\t\t\t\t\t\n\n\t\t\t\t\t\t\"enabled\"\t\t\t\t=> \"1\",\n\n\t\t\t\t\t\t\"model_id\"\t\t\t\t=> \"\",\n\n\t\t\t\t\t\t\"comment\"\t\t\t\t=> \"\",\n\n\t\t\t\t\t\t\"overwrite\" \t\t\t=> \"false\",\t\t\t\t\t\n\n\t\t\t\t\t\t\"mac\"\t\t\t\t\t=> \"\",\n\t\t\t\t\t\t\"organization_id\"\t\t=> self.organization_id,\n\t\t\t\t\t\t\"location_id\"\t\t\t=> self.location_id,\n\t\t\t\t\t\t\"owner_id\"\t\t\t\t=> self.user_id,\n\t\t\t\t\t\t\"owner_type\"\t\t\t=> \"User\",\n\t\t\t\t\t\t\n\t\t\t\t\t}.merge(self.host_parameters)\n\t\t\t\tend", "def masterfile_defaults\n {'date_end' => Date.new(2090,1,1), 'inv_code' => 'UL'}\n end", "def metadata\n @metadata ||= {}\n end", "def to_jaxb_json_hash\n _h = super\n _h['mimeType'] = mimeType.to_jaxb_json_hash unless mimeType.nil?\n if !bytes.nil?\n _ha = Array.new\n bytes.each { | _item | _ha.push _item.to_jaxb_json_hash }\n _h['bytes'] = _ha\n end\n _h['fileName'] = fileName.to_jaxb_json_hash unless fileName.nil?\n return _h\n end", "def hash\n [attachments, billing, body, body_html, body_rtf, body_type, categories, companies, item_id, message_class, mileage, recipients, sensitivity, subject, subject_prefix, properties, discriminator, electronic_addresses, events, name_info, other_fields, personal_info, photo, physical_addresses, professional_info, telephones].hash\n end", "def hash\n [contact, extensions, external_resources, info, integrations, org, schema_version, tags].hash\n end", "def files\n @config.keys - [:defaults]\n end", "def set_asset_metadata\n headers = fog_connection.head_object(CarrierWave::Uploader::Base.fog_directory, upload_data[:path]).headers\n\n self.name = upload_data[:filename]\n self.size = headers['Content-Length']\n self.etag = headers['Etag']\n self.content_type = headers['Content-Type']\n end", "def attributes\n (@original_attributes||{}).merge(@attributes).keys.inject({}) do |hash, key|\n hash[key] = read_attribute(key)\n hash\n end\n end", "def hash\n [allow_embedding_post_script_fonts, custom_time_zone_info_data, dml3_d_effects_rendering_mode, dml_effects_rendering_mode, dml_rendering_mode, file_name, iml_rendering_mode, update_created_time_property, update_fields, update_last_printed_property, update_last_saved_time_property, zip_output, color_mode, jpeg_quality, metafile_rendering_options, numeral_format, optimize_output, page_count, page_index, horizontal_resolution, image_brightness, image_color_mode, image_contrast, paper_color, pixel_format, resolution, scale, use_anti_aliasing, use_high_quality_rendering, vertical_resolution, use_gdi_emf_renderer, save_format].hash\n end", "def hash\n @attrs\n end", "def resource_attributes\n %w(\n auth_users\n comment\n dont_compress\n exclude\n exclude_from\n fake_super\n gid\n hosts_allow\n hosts_deny\n include\n include_from\n incoming_chmod\n list\n lock_file\n log_file\n log_format\n max_connections\n munge_symlinks\n numeric_ids\n outgoing_chmod\n path\n postxfer_exec\n prexfer_exec\n read_only\n refuse_options\n secrets_file\n strict_modes\n timeout\n transfer_logging\n uid\n use_chroot\n write_only\n )\nend", "def attributes\n @attributes ||= @internal_struct[:attributes] || {}\n end", "def hash\n [fully_qualified_rel, raw_href, templated?].hash\n end", "def default_meta\n {\n submission: '',\n solution: '',\n submit_as_file: false,\n submission_files: [],\n solution_files: [],\n prepend: '',\n append: '',\n data_files: [],\n test_cases: {\n public: [],\n private: [],\n evaluation: []\n }\n }\n end", "def calculate_attributes\n if local?\n file = Magick::Image.read(local_path_to_file).first\n @attributes[:width] = file.columns\n @attributes[:height] = file.rows\n @attributes[:created_at] ||= file.properties['create-date']\n end\n end", "def hash\n [key, name, description, kind, creation_date, include_in_snippet, temporary, maintainer_id, tags, variations, goal_ids, _version, custom_properties, _links, _maintainer, environments, archived_date, archived, client_side_availability, defaults].hash\n end", "def dockerfile_metadata(file = nil)\n meta_data = @properties.merge(:repo_name => nil,\n :image_name => nil,\n :file_name => nil,\n :VERSION => nil,\n :maintainer_name => nil,\n :maintainer_email => nil)\n return meta_data unless File.exist?(file)\n meta_data[:file_name] = File.expand_path(file)\n File.open(file, 'r').each do |line|\n [{ :property => :VERSION, :token => '.*#\\sDOCKER-VERSION' },\n { :property => :maintainer_name, :token => '^MAINTAINER',\n :exp => '(.*),\\s(.*)', :field => 1 },\n { :property => :maintainer_email, :token => '^MAINTAINER',\n :exp => '(.*),\\s(.*)', :field => 2 },\n { :property => :image_name, :token => '.*#\\sDOCKER-NAME',\n :exp => '(.*)/(.*)', :field => 2 },\n { :property => :repo_name, :token => '.*#\\sDOCKER-NAME' }].each do |p|\n match_val = match_token(p[:token], line, p)\n meta_data[p[:property]] = match_val unless match_val.nil?\n end\n end\n meta_data\n end", "def asciidoc_attributes\n { 'author' => author_name,\n 'email' => author_email,\n 'project-name' => project_name,\n 'package-name' => package_name,\n 'package-version' => version,\n 'package-description' => description,\n 'package-summary' => summary,\n 'project-url' => project_url \n }.reject{|k,v| v.nil? }\n end", "def default_attributes(custom = {})\n {}\n end", "def extract_attributes(file_name)\n extract_publish_date(file_name)\n extract_tags(file_name)\n extract_filter(file_name)\n extract_title_and_content(file_name)\n @path = Pathname.new(file_name)\n @file = @path.to_s\n @title = @file.gsub('_', ' ').capitalize if @title.to_s.empty?\n @summary = @content.match(%r{<p>.*</p>}).to_s\n self\n end", "def attributes\n return {\n :level => level,\n :message => message,\n :line => line,\n :column => column,\n :file => file,\n :filename => filename,\n :node => node\n }\n end", "def metadata\n self[:metadata] || {}\n end", "def default_reg_metadata\n Origen::Registers.default_reg_metadata.merge(\n Origen::Registers.reg_metadata[owner.class] || {}\n )\n end", "def attributes\n hash = {\n \"author\" => @author,\n \"title\" => @title,\n \"summary\" => @summary,\n \"images\" => @images,\n \"source\" => @source,\n \"date\" => @date\n }\n end" ]
[ "0.7176146", "0.7176146", "0.71211416", "0.7079605", "0.7079605", "0.70232767", "0.6845598", "0.6459782", "0.64118034", "0.63867086", "0.63658184", "0.6360381", "0.6348694", "0.6313983", "0.6241228", "0.61640114", "0.6104902", "0.6094918", "0.60694766", "0.60694766", "0.6004189", "0.6002981", "0.6000871", "0.60006166", "0.60006166", "0.59689647", "0.5955269", "0.5950418", "0.59499156", "0.5948997", "0.59279627", "0.59279627", "0.5926973", "0.5894061", "0.5893613", "0.5893338", "0.5868159", "0.5856333", "0.5856333", "0.58525795", "0.5846283", "0.58412313", "0.5840629", "0.58320737", "0.58262515", "0.581522", "0.57985777", "0.5797166", "0.5791165", "0.57899827", "0.57837206", "0.57823324", "0.57779807", "0.57734394", "0.5767172", "0.5742473", "0.5741578", "0.57353354", "0.57348764", "0.5729666", "0.572941", "0.57231057", "0.572052", "0.5716212", "0.5706952", "0.57041967", "0.57041967", "0.5698276", "0.5698158", "0.56930697", "0.56789285", "0.5678428", "0.5676951", "0.5666973", "0.56557846", "0.5647912", "0.5645143", "0.5613525", "0.5611222", "0.5600262", "0.56000525", "0.5596546", "0.5590887", "0.55753213", "0.5570743", "0.55676425", "0.5566587", "0.5556609", "0.55557936", "0.5550202", "0.5542626", "0.55405855", "0.55401295", "0.5539507", "0.55319387", "0.55291194", "0.55274796", "0.5524574", "0.55230004", "0.5521707" ]
0.7125154
2
Add 1 white space after def
def method1 # some proccesses end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def space1\n puts \"\"\nend", "def spaces; end", "def spaces; end", "def space; txt ' ','' end", "def indent1\n ' ' * 2\n end", "def space_out\n gsub(/(.)/, ' \\1')\n end", "def space_before()\n #This is a stub, used for indexing\n end", "def special_action_code\n \"\".ljust_trim 2\n end", "def increase_spaces()\n @spaces += 1\n end", "def my_name_is\n # and my code is here\n # two spaces for tabs in Ruby\nend", "def code_with_trailing_space\n code.chomp+\" \"\n end", "def space\n\tputs \" \" * 100\nend", "def spacer\n name.length > 15 ? '' : ' '*(15-name.length+1)\n end", "def skip_space=(_arg0); end", "def a3()\n puts('123454')\nend", "def spacing\n puts \"\"\n puts \"\"\n puts \"\"\n end", "def hellow3\n\t'Hello'\nend", "def space(number = 1)\n ' ' * number\n end", "def introduce_myself \n # Best practice 2 spaces within method body \n puts \"I am handsome\"\n end", "def add_commas(number)\n # write code here \nend", "def hello1(name)\n 'halo ' + name\nend", "def spaces_suround\n string = self\n unless [-1] == \" \"\n string = string + \" \"\n end\n unless [0] == \" \"\n string = \" \" + string\n end\n string\n end", "def output_spaces (intnumber, string=\"\")\n intnumber.times { print \" \" }\n puts string\nend", "def repeat(word, x=2)\n return ((+ word + ' ') *x).rstrip\n \nend", "def indent=(_arg0); end", "def space\n 3.times { puts \"\\n\"}\n end", "def spacer\n puts \"\\n----------------------------\\n\"\nend", "def ruspace (short = false)\n rusprice ' ', short\n end", "def indent_atom; \" \"; end", "def underscorize\n self.gsub(\" \",\"_\")\n end", "def prefix\n \" => \"\n end", "def hello2 name2 \r\n 'Hello ' + name2 \r\nend", "def empty_line\n puts\" \" * 70\nend", "def standard_gap\n \" \"\n end", "def repeat(word, times = 2)\r\n ((word + ' ') * times).strip\r\nend", "def ending num\n \"#{num+1} end\"\nend", "def make_blanks\r\n\t#make an array with \"_ \" pushed in the length times. Every time its printed use join method\r\n\t\t@wordlength.times do |x|\r\n\t\t\t@blanks << \"_ \"\r\n\t\tend\r\n\tend", "def hello1 (name)\n 'Hello ' + name\nend", "def escape\n puts \"\"\n puts \" \" + \"_\" * 40\n puts \"\"\n end", "def white_middle(var)\n return \"║ #{var} ║\"\n\tend", "def no_space(x)\n # code go here\n x.gsub(' ', '')\nend", "def leading=(_); end", "def decoration(number, line_length)\n (\"=\" * number * (line_length+1)) << \"\\n\"\nend", "def change_indent plus\n # nothing here\n end", "def %(arg0)\n end", "def %(arg0)\n end", "def diga_ola (nome)\n\nputs 'ola ,' + nome\n\nend", "def space\n 20.times do\n puts \"\"\n end\n end", "def formatFunction(theLines)\n\n\treplaceVoids(\t\ttheLines);\n\tspaceFirstComment(\ttheLines);\n\nend", "def hello1(name)\n 'Hello ' + name\nend", "def hello1(name)\n 'Hello ' + name\nend", "def undent\n gsub /^.{#{slice(/^ +/).length}}/, ''\n end", "def hello1(name)\n 'Hello ' + name \nend", "def to_s\n \"#{indent(1)}def #{name}\\n\" <<\n \"#{indent(2)}# Code here later\\n\" <<\n \"#{indent(1)}end\"\n end", "def newParagraphSpacer(n) \n n.times {puts \" \" }\nend", "def divider(char=\"-\")\n char * 80\nend", "def horizontalSpacer(n , text)\n n.times {print \" \"}\n puts text\nend", "def plusOne(x)\n\tputs x+1\nend", "def repeat(word, num=2)\n word = word + \" \"\n word *= num\n\n # Removes trailing whitespace\n word.rstrip\nend", "def prettify\n @code.gsub(/(.{4})/, '\\1 ').strip\n end", "def %(p0) end", "def %(p0) end", "def indent!(num)\n replace( ' ' * num + self.gsub(\"\\n\", \"\\n\"+' '*num))\n self\n end", "def h(heading)\n puts \"\"\n puts \"-\"*10\n puts heading\n puts \"-\"*10\nend", "def str1; end", "def str1; end", "def say_baa number_of_baas\n puts 'baaaaaaa...'*number_of_baas\n 'yellow submarine'\nend", "def postfix()\n \"\"\n end", "def indentize!(count, char = ' ')\n tap do |s|\n s.gsub!(/([^\\n]*)(\\n|$)/) do\n s1 = Regexp.last_match(1)\n s2 = Regexp.last_match(2)\n not_empty = s1 != '' || s2 != ''\n \"#{char * count}#{s1}#{s2}\" if not_empty\n end\n end\n end", "def unindent\n gsub(/^#{self[/\\A\\s*/]}/, \"\")\n end", "def printSpaces(name,space)\n if name\n name.size.upto (space) do\n print \"\\s\"\n end\n else\n 0.size.upto (space) do\n print \"\\s\"\n end\n end\nend", "def unindent\n self.gsub(/^#{self[/\\A\\s*/]}/, \"\")\n end", "def hello2 name2\n 'good day ' + name2\nend", "def seperator\n puts \"*\"*49\n end", "def aaa\n\t\tdefine_method(\"aa\") {puts \"aa\"}\n\tend", "def trim_whitespace=(_arg0); end", "def word; end", "def word; end", "def word; end", "def word; end", "def word; end", "def five_spaces\n 5.times do\n nbsp\n end\n end", "def separator(num_of_astrsk = 24)\n $report_file.puts(\"*\" * num_of_astrsk)\nend", "def wrap_text(hello, blank )\n return \"#{blank}#{hello}#{blank}\"\nend", "def printSpaces(name,space)\n if name\n print name\n name.size.upto (space) do\n print \"\\s\"\n end\n else\n 0.size.upto (space) do\n print \"\\s\"\n end\n end\nend", "def repeat(word, times=2)\n\t((word+\" \")*times).rstrip\nend", "def add_stuff\n 4 + \"foo\"\nend", "def second_method\n puts \"This is my second method\"\n \"Hello\"\nend", "def leading; end", "def sep\n puts\n puts '=' * 70\n puts\nend", "def possessify\n return \"#{self}'\" if self =~ /s$/\n return \"#{self}'s\"\n end", "def woo; puts \"woooooo\"; end", "def split_function_name(line)\n /(\\s*def\\s*)(\\S[^\\(]*)(\\(.*)/.match(line)\nend", "def hello2 name2\n 'Hello ' + name2\nend", "def hello2 name2\n 'Hello ' + name2\nend", "def start_of_word; end", "def skip_space; end", "def z(a)\n # a + a # =>\nend", "def edit\n puts \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n end", "def prefix(argument_1, argument_2)\n print argument_1\n print argument_2\nend", "def macro; end" ]
[ "0.6701916", "0.6420368", "0.6420368", "0.63849", "0.62949806", "0.6265731", "0.62510705", "0.62003106", "0.61522585", "0.6085364", "0.6058045", "0.6048515", "0.6022566", "0.59448016", "0.5941362", "0.5941183", "0.5928407", "0.5895583", "0.58608586", "0.5844196", "0.5841073", "0.58156693", "0.5809779", "0.580296", "0.578823", "0.57617843", "0.5747708", "0.57396424", "0.5725102", "0.572015", "0.56971645", "0.56957334", "0.5692057", "0.56836104", "0.5681698", "0.5663746", "0.56538224", "0.56388116", "0.5626322", "0.56103486", "0.55953044", "0.5590033", "0.55887747", "0.55877036", "0.55859894", "0.55859894", "0.5583842", "0.55766815", "0.55755055", "0.556897", "0.556897", "0.5568428", "0.5563259", "0.5553469", "0.55530596", "0.5548414", "0.5544094", "0.5542624", "0.5540158", "0.5537081", "0.5534542", "0.5534542", "0.5518145", "0.5506204", "0.5505935", "0.5505935", "0.55043525", "0.54994714", "0.5499387", "0.5492888", "0.5482638", "0.5482633", "0.5453089", "0.5447213", "0.54439914", "0.5442465", "0.54398566", "0.54398566", "0.54398566", "0.54398566", "0.54398566", "0.5438019", "0.54331607", "0.5431575", "0.54208916", "0.54182285", "0.54167706", "0.5406579", "0.53995764", "0.53989077", "0.5397123", "0.5389049", "0.5388311", "0.53875875", "0.5387203", "0.5387017", "0.5386193", "0.53861254", "0.53784275", "0.536528", "0.5362755" ]
0.0
-1
Use () in method definition
def method1 # some proccesses end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call(*) end", "def call(*) end", "def method_one; end", "def method\r\nend", "def call() end", "def method(arg0)\n end", "def method(arg0)\n end", "def custom; end", "def custom; end", "def method=(_arg0); end", "def method=(_arg0); end", "def method=(_arg0); end", "def method_one\n end", "def method_one\n end", "def methods=(_arg0); end", "def method_name=(_arg0); end", "def method_name=(_arg0); end", "def method\n\t\t# code code\n\tend", "def method(p0) end", "def method=(_); end", "def methods() end", "def invoke; end", "def mah_method!(method_param)\nend", "def method_builder; end", "def meth(\n **\n ); end", "def body=(_arg0); end", "def body=(_arg0); end", "def method\r\n\t1\r\nend", "def call(*)\n raise NotImplementedError\n end", "def returns=(_arg0); end", "def call\n end", "def operation; end", "def call\n end", "def implementation; end", "def implementation; end", "def op; end", "def public_method; end", "def whatever\n end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def bar=(_arg0); end", "def bar=(_arg0); end", "def method c\r\nend", "def method2() end", "def use_as_method\n @method = true\n end", "def something\n end", "def arg; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def called_from=(_arg0); end", "def called_from=(_arg0); end", "def call\n\n\tend", "def call\n\n\tend", "def my_method\n end", "def foo(arg); end", "def ...\nend", "def method1; end", "def standalone=(_arg0); end", "def method a=3,\r\n\tb\r\nend", "def suivre; end", "def meth(arg1)\nend", "def method(a=\r\n\t3)\r\nend", "def method_name\n end", "def method a=3, b=4\r\nend", "def something\n\nend", "def signature=(_); end", "def signature=(_); end", "def apply()\n end", "def invoking\n end" ]
[ "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7247189", "0.7247189", "0.71513313", "0.7068083", "0.7048256", "0.7032196", "0.7032196", "0.70276576", "0.70276576", "0.7001792", "0.7001792", "0.7001792", "0.6977599", "0.6977599", "0.69736737", "0.6954557", "0.6954557", "0.688967", "0.6801065", "0.6769852", "0.67509186", "0.6749021", "0.67212296", "0.66807216", "0.66736776", "0.6580962", "0.6580962", "0.656676", "0.65585834", "0.655289", "0.6526868", "0.650523", "0.6501257", "0.6493621", "0.6493621", "0.6483514", "0.64831513", "0.64812326", "0.6468903", "0.6468903", "0.6468903", "0.6468903", "0.6468249", "0.6468249", "0.6461686", "0.64562833", "0.64411247", "0.6438813", "0.6438266", "0.642817", "0.642817", "0.642817", "0.642817", "0.642817", "0.642817", "0.642817", "0.642817", "0.642817", "0.642817", "0.642817", "0.642817", "0.6427676", "0.6427676", "0.64217925", "0.64217925", "0.641733", "0.6398163", "0.6397258", "0.63967043", "0.638324", "0.6382816", "0.637648", "0.6369265", "0.6358686", "0.635812", "0.63566726", "0.63529766", "0.63519615", "0.63519615", "0.6348673", "0.63444555" ]
0.0
-1
Remove return if possible
def some_method(some_arr) some_arr.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discard; end", "def discard; end", "def discard_results; end", "def return!(&block); end", "def capture_return\n @returns = @code.split(/\\(/).first !~ /void/ \n end", "def returns; end", "def ignores; end", "def soft_return\n <<-CODE\n t1 = stack_pop();\n cpu_simple_return(state, c, t1);\n CODE\n end", "def if_to_return(node = @prog)\n node.traverse(nil) {|st, parent|\n if st.kind_of? ECMA262::StIf\n if st.to_return?\n t = st.to_return\n remove_paren(t)\n if t.to_js.length <= st.to_js.length\n parent.replace(st, t)\n end\n end\n end\n }\n self\n end", "def keep_retval?\n @keep_retval\n end", "def clear_result; end", "def keep_if(&block); end", "def no_return?\n !note[TSBS::NoReturnTAG].nil?\n end", "def no_return?\n !note[TSBS::NoReturnTAG].nil?\n end", "def method_with_explicit_return\n :a_non_return_value\n return :return_value\n :another_non_return_value\n end", "def trim_requested; end", "def returnsomething\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 18 )\n\n begin\n # at line 613:5: expression\n @state.following.push( TOKENS_FOLLOWING_expression_IN_returnsomething_848 )\n expression\n @state.following.pop\n # --> action\n\n \trt = @stack_operands.pop\n rt_t = @stack_types.pop\n if(rt_t != @current_method.return_type)\n raise \"Invalid return type #{rt_t} in the #{@current_method.return_type} type method #{@current_class.name}::#{@current_method.name}\"\n end\n generate('ret', nil, nil ,rt )\n @is_returning = true\n free_avail(rt)\n free_avail_const(rt)\n \n \n # <-- action\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 18 )\n\n end\n \n return \n end", "def discard=(_arg0); end", "def discard\n fmap { Unit }\n end", "def ignore; end", "def keep_if\n block_given? or return enum_for(__method__)\n reject { |o| yield o }.each { |o| delete(o) }\n self\n end", "def celebration; end", "def optimize_if_return2(node = @prog)\n node.traverse(nil) {|st, parent|\n if st.kind_of? ECMA262::StIf and st.else_st and parent.kind_of? ECMA262::StatementList\n st.remove_empty_statement\n if (st.then_st.kind_of? ECMA262::StBlock and st.then_st[-1].kind_of? ECMA262::StReturn) or\n st.then_st.kind_of? ECMA262::StReturn\n idx = parent.index(st)\n parent[idx+1..0] = st.else_st\n st.replace(st.else_st, nil)\n end\n end\n }\n self\n end", "def strip!() end", "def remove!; end", "def ~() end", "def ~() end", "def skips; end", "def return(&block); end", "def remove; end", "def remove; end", "def remove; end", "def remove; end", "def return!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n\n type = RETURN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 327:10: 'return'\n match( \"return\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n\n end", "def original_result; end", "def demonstrate_early_return\n return\n puts \"You will never see this, because we never get here.\"\nend", "def discard\n @args = nil\n @block = nil\n end", "def return!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n\n type = RETURN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 141:10: 'return'\n match( \"return\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 20 )\n\n end", "def nothing; end", "def returns_nil; end", "def delete_if(&block); end", "def process_return(exp)\n return \"return #{process exp.shift}\"\n end", "def discard_result token\n interpret_result token\n end", "def supports_returning?\n false\n end", "def method_removed(a_symbol)\n nil\n end", "def unroll\r\n nil\r\n end", "def scrubbed\n end", "def exclude_end?() end", "def may_return?\n @returnsites = instructions.list.select { |i| i.returns? } unless @returnsites\n ! @returnsites.empty? || must_return?\n end", "def check_misplaced_return(stmts)\n stmts.each do |stmt|\n case stmt\n when If\n check_misplaced_return(stmt.then_stmts)\n check_misplaced_return(stmt.else_stmts)\n when For\n check_misplaced_return(stmt.body_stmts)\n when Return\n raise \"cannot return from main\"\n end\n end\n end", "def ret!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 1)\n\n type = RET\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 7:7: 'returns'\n match(\"returns\")\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 1)\n\n end", "def abandon_results!()\n #This is a stub, used for indexing\n end", "def false a\n # catch cuts\n catch :rubylog_cut do\n a.prove { return }\n end\n yield\n end", "def no_change( x )\n return x\nend", "def void()\n nil\n end", "def exit!(res=0) end", "def forget_me!; end", "def exclude; end", "def delelte\n\n end", "def stop!\n throw :return, 1\n end", "def return!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 45 )\n\n\n\n type = RETURN\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 223:9: 'return'\n match( \"return\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 45 )\n\n\n end", "def backtrace_remove; end", "def preClean(leave_ours = false)\n end", "def return_statement(num)\n puts \"this is before the explicit return...\"\n if num != 1\n return \"yeah you entered something other than 1 !\"\n end\n puts \"this is after explicit return so you must have entered 1!\"\nend", "def returns_original\n @returns_original = true\n self\n end", "def after_clean_source\n return :success\n end", "def none a,b=:true\n a.prove {\n b.prove { return } \n }\n yield\n end", "def skipped; end", "def exit(res=0) end", "def check_ending(_result)\n end", "def final?; end", "def discard!\n # This should be overridden by concrete adapters.\n end", "def test_method\n return \"The method will return this string here!\"\n puts \"This line of code will not run.\"\nend", "def negative?; end", "def remove_entrance(exit)\n if !@entrances\n return\n end\n @entrances.delete(exit)\n if @entrances.empty?\n @entrances = nil\n end\n resolve_personal_objective_pronoun\n end", "def method_removed(*) end", "def exit() end", "def a_method_interrupted(a,b)\n puts \"I got #{a}\"\n puts \"I got #{b}\"\n return a+b\n puts \"I got #{a+b}\"\nend", "def apply; nil; end", "def absent?; end", "def unmark!\n STDERR.puts \"unmark!\" if @trace > 0\n return if @paths.empty?\n n = @paths.rindex {|x| x.instance_of? Proc}\n n and @paths.delete_at(n)\n end", "def none?; end", "def none?; end", "def none?; end", "def skipped!; end", "def returns val = nil\n @returns = val\n self\n end", "def strip() end", "def keep_if\n delete_if { |item| not yield(item) }\n end", "def proc_in_return\n proc_func = proc {\n return\n }\n proc_func.call\n\n \"mew\"\n end", "def ignore_me\nend", "def remove_returns_and_spaces(file_contents)\n clean_file =\n file_contents\n .gsub!(/\\n+/, '')\n .gsub!(/(\\s+)(?![^<])/, '')\n\n clean_file\n end", "def deny\n throw(:return)\n end", "def say_hello\n return\n puts \"Hello!\" #this code will never be reached\nend", "def nooriginal\n return @nooriginal\n end", "def keep_going; end", "def returns_something?; @return_type || !@returned_arguments.empty? end", "def before_clean_source\n return :success\n end", "def never?; end", "def leaving_wrap_method\n @@inside_methods -= 1\n end", "def irrelevant_line(source_line); end", "def exit!() end" ]
[ "0.67757374", "0.67757374", "0.64712447", "0.6356915", "0.6305391", "0.6261828", "0.62025833", "0.6158363", "0.61473", "0.6126667", "0.6102062", "0.6048262", "0.60336524", "0.60336524", "0.59802616", "0.5922496", "0.5864825", "0.58587396", "0.5824187", "0.5822716", "0.5768857", "0.5747562", "0.5732924", "0.57182956", "0.5712619", "0.5700318", "0.5700318", "0.5695563", "0.56848437", "0.56666994", "0.56666994", "0.56666994", "0.56666994", "0.5663092", "0.56603265", "0.5658367", "0.5649716", "0.5645159", "0.5642481", "0.5621369", "0.562", "0.5596872", "0.5591536", "0.5590506", "0.5584322", "0.55829716", "0.55710995", "0.55658966", "0.5559105", "0.5556339", "0.5553018", "0.5535347", "0.5533931", "0.55281246", "0.5501913", "0.5500155", "0.5498868", "0.5494708", "0.5492103", "0.5490131", "0.5482944", "0.54788125", "0.547457", "0.5467861", "0.54579604", "0.544683", "0.54421175", "0.5440262", "0.542563", "0.54245824", "0.54234934", "0.54178876", "0.5416234", "0.5415678", "0.5411165", "0.5409418", "0.54038316", "0.5402772", "0.5400812", "0.5397419", "0.53918517", "0.5390302", "0.5390302", "0.5390302", "0.538722", "0.5383816", "0.536056", "0.5354704", "0.5353005", "0.53511536", "0.5350701", "0.53456944", "0.5343156", "0.53423035", "0.534191", "0.5333972", "0.53271145", "0.5324704", "0.53240395", "0.5322547", "0.5321798" ]
0.0
-1
From the page 482 The full list of operating system errors on your particular platform is available as the constants of Errno. Any userdefined exception in this module (including subclasses of existing exceptions) must also define an Errno constant.
def test_Errno_Introduction2 assert_equal([:NOERROR, :EPERM, :ENOENT, :ESRCH, :EINTR], Errno.constants[0..4]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def errno\n SystemCallError.new(get_errno)\n end", "def errno; end", "def errno\n self.class::Errno\n end", "def shell_error_string ( e )\n if e > 32\n return nil\n else\n return case e\n when 0 then \"Out of memory or resources\"\n #define ERROR_FILE_NOT_FOUND 2L\n #define SE_ERR_FNF 2\n when 2 then \"File not found\"\n #define ERROR_PATH_NOT_FOUND 3L\n #define SE_ERR_PNF 3\n when 3 then \"Path not found\"\n #define SE_ERR_ACCESSDENIED 5\n when 5 then \"Access denied\"\n #define SE_ERR_OOM 8\n when 8 then \"Not enough memory\"\n #define ERROR_BAD_FORMAT 11L\n when 11 then \"Invalid exe\"\n #define SE_ERR_SHARE 26\n when 26 then \"Sharing violation\"\n #define SE_ERR_ASSOCINCOMPLETE 27\n when 27 then \"Invalid file association\"\n #define SE_ERR_DDETIMEOUT 28\n when 28 then \"DDE timeout\"\n #define SE_ERR_DDEFAIL 29\n when 29 then \"DDE fail\"\n #define SE_ERR_DDEBUSY 30\n when 30 then \"DDE busy\"\n #define SE_ERR_NOASSOC 31\n when 31 then \"No file association\"\n #define SE_ERR_DLLNOTFOUND 32\n when 32 then \"DLL not found\"\n else \"Unspecified error\"\n end # case\n end # else\nend", "def einval?() EINVAL == @error_code; end", "def errno\n @last_error ? @last_error.errno : 0\n end", "def errors_handling(err_code)\n\n\t\terr_code = err_code.to_i + 32000\n\n\t\t# PJL File System Errors (32xxx)\n\t\tfs_errors = {\n\t\t\t'32000' => 'General error',\n\t\t\t'32001' => 'Volume not available',\n\t\t\t'32002' => 'Disk full',\n\t\t\t'32003' => 'File not found',\n\t\t\t'32004' => 'No free file descriptors',\n\t\t\t'32005' => 'Invalid number of bytes',\n\t\t\t'32006' => 'File already exists',\n\t\t\t'32007' => 'Illegal name',\n\t\t\t'32008' => 'Can\\'t delete root',\n\t\t\t'32009' => 'File operation attempted on a directory',\n\t\t\t'32010' => 'Directory operation attempted on a file',\n\t\t\t'32011' => 'Not same volume',\n\t\t\t'32012' => 'Read only',\n\t\t\t'32013' => 'Directory full',\n\t\t\t'32014' => 'Directory not empty',\n\t\t\t'32015' => 'Bad disk',\n\t\t\t'32016' => 'No label',\n\t\t\t'32017' => 'Invalid parameter',\n\t\t\t'32018' => 'No contiguous space',\n\t\t\t'32019' => 'Can\\'t change root',\n\t\t\t'32020' => 'File Descriptor obsolete',\n\t\t\t'32021' => 'Deleted',\n\t\t\t'32022' => 'No block device',\n\t\t\t'32023' => 'Bad seek',\n\t\t\t'32024' => 'Internal error',\n\t\t\t'32025' => 'Write only',\n\t\t\t'32026' => 'Write protected',\n\t\t\t'32027' => 'No filename',\n\t\t\t'32051' => 'End of directory',\n\t\t\t'32052' => 'No file system',\n\t\t\t'32053' => 'No memory',\n\t\t\t'32054' => 'Vol name out of range',\n\t\t\t'32055' => 'Bad FS',\n\t\t\t'32056' => 'Hardware failure'\n\t\t}\n\n\t\tif (fs_errors.has_key?(err_code.to_s))\n\t\t\treturn fs_errors[err_code.to_s]\n\t\telse\n\t\t\treturn 'Bad command or error'\n\t\tend\n\tend", "def errors_handling(err_code)\n\n\t\terr_code = err_code.to_i + 32000\n\n\t\t# PJL File System Errors (32xxx)\n\t\tfs_errors = {\n\t\t\t'32000' => 'General error',\n\t\t\t'32001' => 'Volume not available',\n\t\t\t'32002' => 'Disk full',\n\t\t\t'32003' => 'File not found',\n\t\t\t'32004' => 'No free file descriptors',\n\t\t\t'32005' => 'Invalid number of bytes',\n\t\t\t'32006' => 'File already exists',\n\t\t\t'32007' => 'Illegal name',\n\t\t\t'32008' => 'Can\\'t delete root',\n\t\t\t'32009' => 'File operation attempted on a directory',\n\t\t\t'32010' => 'Directory operation attempted on a file',\n\t\t\t'32011' => 'Not same volume',\n\t\t\t'32012' => 'Read only',\n\t\t\t'32013' => 'Directory full',\n\t\t\t'32014' => 'Directory not empty',\n\t\t\t'32015' => 'Bad disk',\n\t\t\t'32016' => 'No label',\n\t\t\t'32017' => 'Invalid parameter',\n\t\t\t'32018' => 'No contiguous space',\n\t\t\t'32019' => 'Can\\'t change root',\n\t\t\t'32020' => 'File Descriptor obsolete',\n\t\t\t'32021' => 'Deleted',\n\t\t\t'32022' => 'No block device',\n\t\t\t'32023' => 'Bad seek',\n\t\t\t'32024' => 'Internal error',\n\t\t\t'32025' => 'Write only',\n\t\t\t'32026' => 'Write protected',\n\t\t\t'32027' => 'No filename',\n\t\t\t'32051' => 'End of directory',\n\t\t\t'32052' => 'No file system',\n\t\t\t'32053' => 'No memory',\n\t\t\t'32054' => 'Vol name out of range',\n\t\t\t'32055' => 'Bad FS',\n\t\t\t'32056' => 'Hardware failure'\n\t\t}\n\n\t\tif (fs_errors.has_key?(err_code.to_s))\n\t\t\treturn fs_errors[err_code.to_s]\n\t\telse\n\t\t\treturn 'Bad command or error'\n\t\tend\n\tend", "def check_retval(rc, e_klass = nil)\n return true unless ::OpenNebula.is_error?(rc)\n fail (e_klass ? e_klass : RuntimeError ), rc.message\n end", "def errnum\r\n self.class.errnum\r\n end", "def thread_run_refused(unix: false)\n if unix\n DARWIN ? [IOError, Errno::ENOENT, Errno::EPIPE] :\n [IOError, Errno::ENOENT]\n else\n # Errno::ECONNABORTED is thrown intermittently on TCPSocket.new\n DARWIN ? [IOError, Errno::ECONNREFUSED, Errno::EPIPE, Errno::EBADF, EOFError, Errno::ECONNABORTED] :\n [IOError, Errno::ECONNREFUSED, Errno::EPIPE]\n end\n end", "def error_number(exception) # :nodoc:\n raise NotImplementedError\n end", "def exit_status_from_exception; end", "def check_retval(rc, e_klass)\n return true unless OpenNebula.is_error?(rc)\n case rc.errno\n when OpenNebula::Error::EAUTHENTICATION\n fail Errors::AuthenticationError, rc.message\n when OpenNebula::Error::EAUTHORIZATION\n fail Errors::UserNotAuthorizedError, rc.message\n when OpenNebula::Error::ENO_EXISTS\n fail Errors::ResourceNotFoundError, rc.message\n when OpenNebula::Error::EACTION\n fail Errors::ResourceStateError, rc.message\n else\n fail e_klass, rc.message\n end\n end", "def ioerr; end", "def eterm?() ETERM == @error_code; end", "def raise(cls, str, junk=nil)\n Rubinius::VM.write_error \"Fatal error loading runtime kernel:\\n \"\n Rubinius::VM.write_error str\n Rubinius::VM.write_error \"\\n\"\n Rubinius::VM.show_backtrace\n Process.exit! 1\n end", "def eprotonosupport?() EPROTONOSUPPORT == @error_code; end", "def results_errno()\n r = attr_get(\"status\")\n if(r.eql?(\"passed\"))\n 0\n end\n r = attr_get(\"errno\")\n unless r\n r = -1\n end\n r\n end", "def error(nvae)\n end", "def lookup_error(failed_operation = nil)\n error_no = FFI::LastError.error\n case error_no\n when 1223\n raise SystemCallError.new(\"The operation was canceled by the user\", error_no)\n when -2146885628\n raise SystemCallError.new(\"Cannot find object or property\", error_no)\n when -2146885629\n raise SystemCallError.new(\"An error occurred while reading or writing to a file.\", error_no)\n when -2146881269\n raise SystemCallError.new(\"ASN1 bad tag value met. -- Is the certificate in DER format?\", error_no)\n when -2146881278\n raise SystemCallError.new(\"ASN1 unexpected end of data.\", error_no)\n when -2147024891\n raise SystemCallError.new(\"System.UnauthorizedAccessException, Access denied..\", error_no)\n else\n raise SystemCallError.new(\"Unable to #{failed_operation} certificate.\", error_no)\n end\n end", "def friendly_error(e)\n case e\n when Ncio::Support::RetryAction::RetryException::Timeout\n 'Timeout expired connecting to the console service. Verify it is up and running.'\n when OpenSSL::SSL::SSLError\n friendly_ssl_error(e)\n when Ncio::Api::V1::ApiAuthenticationError\n 'Make sure the --cert option value is listed in the certificate whitelist, '\\\n 'and you are able to run puppet agent --test on the master. '\\\n 'The certificate whitelist on the master is located at '\\\n '/etc/puppetlabs/console-services/rbac-certificate-whitelist'\n else\n e.message\n end\n end", "def error_code\n raise BASICRuntimeError.new(:te_err_no_err) if @error_stack.empty?\n\n code = @error_stack[-1]\n NumericConstant.new(code)\n end", "def usage_error\n $stderr.printf(\"%s\\n\", usage)\n exit(-1)\n end", "def error!(text, **message)\n\t\t\t\t\tmessage[:errno] ||= -1\n\t\t\t\t\t\n\t\t\t\t\tsend(status: text, **message)\n\t\t\t\tend", "def puppet_detailed_exit_code_indicates_error?(ec)\n return (ec == 4 or ec == 6 or ec == 1)\n end", "def error(progname = T.unsafe(nil), &block); end", "def refute_error(error_code)\n refute_nil error_code if error_code.nil?\n return if error_code >= 0\n name = UV.err_name(error_code) || error_code\n msg = UV.strerror(error_code)\n raise RuntimeError, \"#{msg} - #{name}\", caller\nend", "def error(msg, exc: nil)\n must \"message\", msg, be: String\n\n tell(colorize(\"☠ \", :magenta) + colorize(msg, :red))\n\n if exc\n raise exc.new(msg)\n else\n exit(-1)\n end\n end", "def err_name\n if (defined? @port_num)\n return \"error_#{@port_num}.log\"\n else\n return \"error_#{Process.pid}.log\"\n end\n end", "def systemOrDie(*cmd)\n puts 'executes: ' + cmd.join(' ')\n ret = system(*cmd)\n raise \"Failed to execute command: \" + cmd.join(' ') if !ret\n end", "def XOerror(msg)\n\t\tres= setResCritical (msg)\n\t\treturnRes( res)\n\tend", "def geterrorcode()\r\n return getvalue(@@ERROR_CODE)\r\n end", "def error!\n throw :return, -1\n end", "def error_number; end", "def unknown_error(error, req = T.unsafe(nil), text = T.unsafe(nil)); end", "def err(msg)\n puts msg.red\n exit(1)\n end", "def error(message, code = 1)\n puts \"custodian: #{message}\"\n exit code\n end", "def error(msg, code)\n STDERR.puts msg\n exit code\nend", "def error(msg, code)\n STDERR.puts msg\n exit code\nend", "def show_oom_error\n $E_OOM += 1\n puts \"ERROR - OOM, Bucket RAM Quota Too Small, Ejection from RAM too slow for write velocity #{$E_OOM}\"\nend", "def exitstatus; end", "def exception_codes\n return Egregious.exception_codes\n end", "def error(msg, exc: -1, silent: false)\n tell \"#{✘} {r{#{msg}}}\" unless silent\n\n if exc.is_a? Integer\n exit exc\n elsif !exc.nil?\n raise exc if msg.nil?\n raise exc, msg\n end\n end", "def raise_last_win_32_error\n errorCode = Win32API.new(\"kernel32\", \"GetLastError\", [], 'L').call\n if errorCode != ERROR_SUCCESS\n params = [\n 'L', # IN DWORD dwFlags,\n 'P', # IN LPCVOID lpSource,\n 'L', # IN DWORD dwMessageId,\n 'L', # IN DWORD dwLanguageId,\n 'P', # OUT LPSTR lpBuffer,\n 'L', # IN DWORD nSize,\n 'P', # IN va_list *Arguments\n ]\n\n formatMessage = Win32API.new(\"kernel32\", \"FormatMessage\", params, 'L')\n msg = ' ' * 255\n msgLength = formatMessage.call(FORMAT_MESSAGE_FROM_SYSTEM +\n FORMAT_MESSAGE_ARGUMENT_ARRAY, '', errorCode, 0, msg, 255, '')\n\n msg.gsub!(/\\000/, '')\n msg.strip!\n raise msg\n end\n end", "def error!\n # Unhandled exception\n if @exception\n exception_message\n exit 2\n # Some checksums did not match?\n elsif !(invalid_packages.empty? && invalid_metadata_files.empty?)\n error_message\n exit 2\n # We don't have checksums for some packages?\n elsif unverifiable_package_count != 0\n unverifiable_packages_message\n exit 2\n else\n success_message\n exit 0\n end\n end", "def error(msg)\n raise CmdFailedError.new(msg)\n end", "def error_thread_crash error, error_location; end", "def error(msg)\n STDERR.puts \"#{@progname}: FAIL: #{msg}\"\n end", "def eaddrinuse?() EADDRINUSE == @error_code; end", "def error(msg)\n raise RuntimeError.new(msg)\n end", "def error(msg)\n raise RuntimeError.new(msg)\n end", "def error(msg)\n raise RuntimeError.new(msg)\n end", "def failure(err)\n raise ArgumentError.new(\"Unexpected failure type: #{err}\") unless err.is_a?(StandardError)\n\n err\n end", "def underlying_exception=(_arg0); end", "def set_exit_exception; end", "def err_missing (message, usage)\n raise \"Missing argument --#{message}\\n#{usage}\"\n end", "def error(exception) nil ; end", "def check_error_no\n @error_no = 0\n if @err_bit\n if @data != nil && @data.size > 0\n @error_no = (0x0 - 0xFFFFFFFF + (BioPacket.swap_dword(@data.first) - 1)).to_i\n @error_desc = BioPacket.format_err_desc(@error_no)\n $test_logger.log(\"Error#{(\" in ACK\" if @ack_bit)}: #{@error_no} #{@error_desc}\")\n else \n $test_logger.log(\"Error bit is set but error code not found!!\")\n end\n end\n end", "def handle_perform_error(_e); end", "def error_string\n LibZMQ.zmq_strerror(errno).read_string\n end", "def Error(msg)\n\t\t#Fatal error\n\t\traise (\"TCPDF error: #{msg}\")\n\tend", "def err_code\n puts \"Your date is not valid............!\"\n Kernel.exit\n end", "def check_and_raise( err_ptr )\n return if err_ptr.null?\n raise specific_error_class( err_ptr ).new( err_ptr.message )\n end", "def er(msg)\n puts \"Error: #{msg}\"\n exit 1\nend", "def error!(status, msg)\n error msg\n exit status\n end", "def error(rc)\n return rc[0].strip if rc[2].success?\n\n puts \"ERROR: #{rc[1]}\"\n\n exit(-1)\nend", "def fork_err\n @fork_err\n end", "def err\n @err\n end", "def error(str)\n\tloc = @io.tell() - 1\n\traise \"#{self.class.name} error at byte #{loc} (0x#{'%02x' % loc}): #{str}\"\n end", "def error\n raise Exception, \"An example of what an error looks like if you make a mistake using Commandable.\"\n end", "def err(cod)\n @st = :err\n @ie = cod\n end", "def error(msg)\n puts \"#{msg}\\n\\n\"\n exit -1\nend", "def print_invalid_platform\n puts \"\\nOops... Invalid Platform\"\n puts \"\\nSupported platform are \\\"android\\\" and \\\"iOS\\\".\"\n puts \"\\nTo run on Desktop no need to mention platform.\"\n Process.exit(0) \nend", "def assert_error_occurred\n assert_not_exit_status 0\n end", "def errmsg(message); end", "def NaCl_error(e)\n e1 = e.is_a?(RbNaCl::BadAuthenticatorError) ? 'The authenticator was forged or otherwise corrupt' : ''\n e2 = e.is_a?(RbNaCl::BadSignatureError) ? 'The signature was forged or otherwise corrupt' : ''\n error \"#{ERROR} Decryption error for packet:\\n\"\\\n \"#{e1}#{e2} \"\\\n \"#{@controller.body}\"\n _log_exception ERROR, \"Stack trace\", e\n\n @controller.head @response_code,\n x_error_details: 'Your request can not be completed.'\n end", "def handle_error(cmd, stderr)\n summary = \"\\rError running \\`#{cmd}\\`\"\n details = readable_curr_time << \"\\n\\n\"\n details << \"**************************************************************\\n\"\n details << \"#{summary}\\n\"\n details << \"**************************************************************\\n\"\n details << stderr << \"\\n\\n\"\n File.open(@err_path, 'a') { |file| file.write(details) }\n summary\nend", "def error(msg)\n stderr(\"error: #{msg}\")\n end", "def error_poslook_crash error, error_location; end", "def error(msg)\n raise ::RDoc::Error, msg\n end", "def error(msg)\n raise ::RDoc::Error, msg\n end", "def raise_exception_on_sigterm(answer = T.unsafe(nil)); end", "def exit_exception; end", "def error(*args); end", "def perror(message)\n rc = Native.sd_journal_perror(message)\n raise JournalError, rc if rc < 0\n end", "def err(message)\n STDERR.puts(message)\n exit 1\n end", "def error_message(ex) #:nodoc:\n msg = \"error: #{ex.message}\"\n case ex\n when UnknownCommand\n msg += \". Use '#{program_name} help' for a list of commands\"\n when UnknownCommandArgument\n msg += \". Use '#{program_name} help #{ex.command.name}' for a list of command options\"\n when UnknownGlobalArgument\n msg += \". Use '#{program_name} help' for a list of global options\"\n end\n msg\n end", "def report_error(err)\n case err.message\n when Creator::REPOSITORY_CREATION_FAILED\n GitHubClassroom.statsd.increment(\"v2_exercise_repo.create.repo.fail\")\n when Creator::REPOSITORY_COLLABORATOR_ADDITION_FAILED\n GitHubClassroom.statsd.increment(\"v2_exercise_repo.create.adding_collaborator.fail\")\n when Creator::REPOSITORY_STARTER_CODE_IMPORT_FAILED\n GitHubClassroom.statsd.increment(\"v2_exercise_repo.create.importing_starter_code.fail\")\n else\n GitHubClassroom.statsd.increment(\"v2_exercise_repo.create.fail\")\n end\n end", "def exitstatus(*) end", "def error_code\n extract_raw_value __callee__\n end", "def test_exception\n with_fixture 'exception' do\n system(\"ruby \\\"#{ocra}\\\" exception.rb #{DefaultArgs.join(' ')} 2>NUL\")\n assert $?.exitstatus != 0\n assert !File.exist?(\"exception.exe\")\n end\n end", "def soma(n1, n2)\r\n n1 + n2\r\nrescue Exception => e\r\n puts 'Erro ao excecutar o programa'\r\nend", "def chef_error(e)\n if e.is_a?(::RightScale::Exceptions::Exec)\n msg = \"External command error: \"\n if match = /RightScale::Exceptions::Exec: (.*)/.match(e.message)\n cmd_output = match[1]\n else\n cmd_output = e.message\n end\n msg += cmd_output\n msg += \"\\nThe command was run from \\\"#{e.path}\\\"\" if e.path\n elsif e.is_a?(::Chef::Exceptions::ValidationFailed) && (e.message =~ /Option action must be equal to one of:/)\n msg = \"[chef] recipe references an action that does not exist. #{e.message}\"\n elsif e.is_a?(::NoMethodError) && (missing_action_match = /undefined method .action_(\\S*)' for #<\\S*:\\S*>/.match(e.message)) && missing_action_match[1]\n msg = \"[chef] recipe references the action <#{missing_action_match[1]}> which is missing an implementation\"\n else\n msg = \"Execution error:\\n\"\n msg += e.message\n file, line, meth = e.backtrace[0].scan(BACKTRACE_LINE_REGEXP).flatten\n line_number = line.to_i\n if file && line && (line_number.to_s == line)\n dir = AgentConfig.cookbook_download_dir\n if file[0..dir.size - 1] == dir\n path = \"[COOKBOOKS]/\" + file[dir.size..file.size]\n else\n path = file\n end\n msg += \"\\n\\nThe error occurred line #{line} of #{path}\"\n msg += \" in method '#{meth}'\" if meth\n context = \"\"\n if File.readable?(file)\n File.open(file, 'r') do |f|\n lines = f.readlines\n lines_count = lines.size\n if lines_count >= line_number\n upper = [lines_count, line_number + 2].max\n padding = upper.to_s.size\n context += context_line(lines, line_number - 2, padding)\n context += context_line(lines, line_number - 1, padding)\n context += context_line(lines, line_number, padding, '*')\n context += context_line(lines, line_number + 1, padding)\n context += context_line(lines, line_number + 2, padding)\n end\n end\n end\n msg += \" while executing:\\n\\n#{context}\" unless context.empty?\n end\n end\n msg\n end", "def assert_rc(rc)\n fail \"XS operation failed! Descr [#{::XS::Util.error_string}] Errno [#{::XS::Util.errno}]\" unless ::XS::Util.resultcode_ok? rc\n end", "def internal_err_code\n SendgridClient.internal_err_code\n end", "def eaddrnotavail?() EADDRNOTAVAIL == @error_code; end", "def do_open_failed(reason_code, description); end", "def code\n @errorcode\n end", "def error(msg)\n raise RDoc::Error, msg\n end" ]
[ "0.6997116", "0.6874913", "0.6696123", "0.66079605", "0.63397455", "0.58944684", "0.58938855", "0.58938855", "0.5835156", "0.5780108", "0.5765723", "0.5751015", "0.569087", "0.56798285", "0.56031066", "0.55592716", "0.54955876", "0.54669195", "0.54658747", "0.5461876", "0.54455733", "0.5437305", "0.54365927", "0.54181224", "0.5414629", "0.53898746", "0.52957", "0.528866", "0.5282202", "0.523953", "0.5211864", "0.5198367", "0.51874334", "0.5175393", "0.51560646", "0.5155663", "0.51554126", "0.51423466", "0.51410484", "0.51410484", "0.51286113", "0.5119355", "0.5114833", "0.5107825", "0.5086233", "0.50818473", "0.5081634", "0.50805724", "0.5079101", "0.5077503", "0.5061733", "0.5061733", "0.5061733", "0.50546724", "0.5048085", "0.50343335", "0.5030029", "0.5029048", "0.5017199", "0.5011716", "0.49989608", "0.49797654", "0.4978604", "0.497231", "0.49671036", "0.49609277", "0.49584293", "0.4957527", "0.49550012", "0.49483666", "0.494484", "0.49434218", "0.49398896", "0.49244666", "0.49160025", "0.49138138", "0.49137253", "0.49115813", "0.48995924", "0.4891129", "0.4883921", "0.4883921", "0.48700958", "0.48690915", "0.48672584", "0.48630813", "0.48539105", "0.48534188", "0.4850833", "0.48406675", "0.48304868", "0.482484", "0.48146185", "0.47974983", "0.47907534", "0.4784421", "0.47759098", "0.47751766", "0.4775169", "0.4774565" ]
0.68636173
2
scenarios if item is present: best: O(1), avg: O(N/2), worst: O(N) if item is NOT present best: O(1), avg: O(N/2), worst: O(N)
def sorted_sequential_search(array, value) i = 0 while i < array.length return i if array[i] == value return false if array[i] > value i += 1 end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def which_elements_missing? desired_elements\n database_elements = as_set\n desired_elements = Set.new(desired_elements)\n not_in_database = desired_elements - database_elements\n return not_in_database\n end", "def exists? item, list, lo, hi\n until lo >= hi\n mid = ((lo + hi) / 2).to_i\n if list[mid] < item\n lo = mid + 1\n elsif list[mid] > item\n hi = mid - 1\n else\n return true\n end\n end\n list[lo] == item\nend", "def missing(ordered)\n first_index = 0\n missings = []\n while first_index < ordered.size - 1\n second_index = first_index + 1\n\n first_missing = ordered[first_index] + 1\n\n until first_missing == ordered[second_index]\n missings << first_missing\n\n first_missing += 1\n end\n\n first_index += 1\n end\n missings\nend", "def sufficient_quantity_present?(item_quantities)\n all_items_present = true\n not_sufficient_item = nil\n item_quantities.each do |ingredient_name, quantity|\n if !@ingredients[ingredient_name] || @ingredients[ingredient_name] < quantity\n all_items_present = false\n not_sufficient_item = ingredient_name\n break\n end\n end\n return all_items_present, not_sufficient_item\n end", "def check_empty_order(items)\r\n flag = items.item.length\r\n items.item.each do |h|\r\n (flag -= 1) if h[:num] == 0\r\n end\r\n return true if flag == 0\r\n return false\r\nend", "def test_growthItemNullValue\n f = ItemFilter.new(\"growth\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def is_allergic?(score, item)\n test_by_score(score).include?(item)\nend", "def get_basket(variety)\n basket_with_space = find_basket_with_space()\n basket_with_same_variety = basket_with_space.find { |b| b.apples.first.variety == variety && b.apples.size > 0 }\n if basket_with_same_variety.nil?\n # return some other completely empty basket\n basket_with_space.find { |b| b.apples.size == 0 }\n else\n # return basket with same variety of apples\n basket_with_same_variety\n end\nend", "def usable_item_conditions_met?(item)\r\n movable? && occasion_ok?(item)\r\n end", "def test_healingItemNullValue\n f = ItemFilter.new(\"healing\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def bench_similar_elements\n skip 'TODO'\n q = qualifier(:DockItem, title: 'Finder')\n assert_performance_linear do |n|\n (items * n).each { |item| q.qualifies? item }\n end\n end", "def best_two_sum?(arr, target)\n fastest = {}\n arr.each_with_index {|ele, i| fastest[ele] = i }\n arr.each_with_index do |ele, i|\n return true if fastest.has_key?(target - ele) && fastest[target - ele] != i\n end\n false\nend", "def contains?(item)\n\n\n\n\n end", "def check_for_equal_item(name, price, description, item_not_to_compare = nil)\r\n index = items.index {|x| x.name.eql?(name) and x.price.eql?(price) and x.description.eql?(description) and x != item_not_to_compare}\r\n return items[index] unless index == nil\r\n end", "def test_attackItemNullValue\n f = ItemFilter.new(\"attack\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def test_growthItem\n f = ItemFilter.new(\"growth\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 6\n end", "def test_emptyUsableItem\n f = UsableItemFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def first_come_first_served?(take_out, dine_in, served)\n next_take_out, next_dine_in = 0, 0\n return false if take_out.size + dine_in.size != served.size\n\n served.each do |order|\n if take_out[next_take_out] != nil && take_out[next_take_out] == order\n next_take_out += 1\n elsif dine_in[next_dine_in] != nil && dine_in[next_dine_in] == order\n next_dine_in += 1\n else\n return false\n end\n end\n\n true\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def find_the_cheese(potentially_cheesy_items)\n cheeses = %w(gouda cheddar camembert)\n\n potentially_cheesy_items.find do |maybe_cheese|\n cheeses.include?(maybe_cheese)\n end\nend", "def return_diff_betw_indexes(hash, key_1, value_1, key_2, value_2)\n array_1 = hash[:bay_1].to_a\n array_2 = hash[:bay_2].to_a\n\n full_array = array_1 + array_2\n object_1 = key_1 , value_1\n object_2 = key_2, value_2\n for item_selection in full_array\n if (item_selection == object_1) || (item_selection == object_2)#trying to make sure the code doesnt get run if there is a mistake in the input but can only check item_selection one at a time and it returns nil for the mistake and error occurs because nil cant be into a Fixnum\n #break if object_1 == nil Trying to implement a test to filter results if they contain a nil\n index_1 = full_array.index(object_1)\n index_2 = full_array.index(object_2)\n difference = index_2 - index_1\n return difference\n end\n end\n return false\nend", "def not_included(arr) \n hash = Hash.new(0)\n arr.each { |el| hash[el] = 0 }\n i = 1\n # hash[5] == 0\n while true\n return i unless hash.has_key?(i)\n i += 1\n end\nend", "def low_missing(input)\n i = 0\n while i < input.length\n item = input[i]\n next i += 1 if input[item] == input[i]\n next i += 1 if item < 0 || item > input.length - 1\n input[i], input[item] = input[item], input[i]\n end\n out = 1\n out += 1 while out == input[out]\n out\nend", "def should_collect_broken_bikes?(container)\n !self.full? && container.broken_bikes.count >= 1 \n end", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def test_emptyItem\n f = ItemFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def heuristic_solving_possible\n prev_item = nil\n items.each do |item|\n if prev_item.present?\n if item[:c] < prev_item[:c]\n # \"The absolute cost of a heavier item (cost #{item[:c]} with weight #{item[:w]}) is lower than the cost of another item (cost #{prev_item[:c]} with weight #{prev_item[:w]})\"\n return false\n elsif (item[:c].to_f / item[:w].to_f) > (prev_item[:c].to_f / prev_item[:w].to_f)\n # \"The relative cost of a heavier item (cost #{item[:c]} with weight #{item[:w]} having a relative cost of #{item[:c].to_f/item[:w].to_f}) is higher than the cost of another item (cost #{prev_item[:c]} with weight #{prev_item[:w]} having a relative cost of #{prev_item[:c].to_f/prev_item[:w].to_f})\"\n return false\n end\n end\n prev_item = item\n end\n true\n end", "def find_ge(list, item, &block)\r\n\t\ti = bisect_left(list, item, &block)\r\n\t\treturn list[i] unless list.size == i\r\n\tend", "def data_bag_item_exist?(bag, item)\n list_data_bag_items(bag).include?(item)\nend", "def test_physicalAttackUsableItemNullValue\n f = UsableItemFilter.new(\"physical_attack\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def good_two_sum?(arr, target_sum)\r\n elements = {}\r\n\r\n arr.each do |ele|\r\n return true if elements[target_sum - ele]\r\n elements[ele] = true\r\n end\r\n false\r\nend", "def keep_if\n keep_values=(@d.select {|item| yield item}).values\n keep_prob=(keep_values==[]) ? 0 : keep_values.inject(:+)\n if (keep_prob>0)\n @d.keep_if {|item| yield item}\n @d=(self.mult(Rational(1,keep_prob))).d\n else\n # TODO\n end\n end", "def insert(item)\n return false unless has_space?\n\n fingerprint = fingerprint(item)\n first_index = hash(item)\n second_index = alt_index(first_index, fingerprint)\n\n if @buckets[first_index].insert(fingerprint) || @buckets[second_index].insert(fingerprint)\n increment_filled_count\n return true\n end\n\n index = [first_index, second_index].sample\n\n @max_kicks.times do\n fingerprint = @buckets[index].random_swap(fingerprint)\n index = alt_index(index, fingerprint)\n\n if @buckets[index].insert(fingerprint)\n increment_filled_count\n return true\n end\n end\n\n return false\n end", "def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend", "def test_supportItemNullValue\n f = ItemFilter.new(\"support\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def ukp5(ukpi, return_used_items = false)\n n = ukpi[:n]\n c = ukpi[:c]\n items = ukpi[:items].clone\n\n max_w = items.max_by { | i | i[:w] }[:w]\n g = Array.new(c+max_w+1, 0)\n d = Array.new(c+max_w+1, n-1)\n sort_items_by_profitability!(items)\n\n last_y_where_nonbest_item_was_used = 0\n items.each_with_index do | it, ix |\n wi = it[:w]\n pi = it[:p]\n if g[wi] < pi then\n g[wi] = pi\n d[wi] = ix\n last_y_where_nonbest_item_was_used = wi if wi > last_y_where_nonbest_item_was_used && ix != 0\n end\n end\n\n opt = 0\n (1..(c-1)).each do | y |\n next if g[y] <= opt\n break if last_y_where_nonbest_item_was_used < y\n\n opt = gy = g[y]\n dy = d[y]\n\n # this block is a copy-past of the loop bellow only for the best item\n bi = items[0]\n pb = bi[:p]\n wb = bi[:w]\n next_y = y + wb\n old_gny = g[next_y]\n new_gny = gy + pb\n if old_gny < new_gny then\n g[next_y] = new_gny\n d[next_y] = 0\n end\n\n (1..dy).each do | ix |\n it = items[ix]\n pi = it[:p]\n wi = it[:w]\n ny = y + wi\n ogny = g[ny]\n ngny = gy + pi\n if ogny < ngny then\n g[ny] = ngny\n d[ny] = ix\n last_y_where_nonbest_item_was_used = ny if ny > last_y_where_nonbest_item_was_used\n end\n end\n end\n\n if last_y_where_nonbest_item_was_used < c-1 then\n y_ = last_y_where_nonbest_item_was_used\n while d[y_] != 0 do\n y_ += 1\n end\n# puts \"Periodicity used - c: #{c}; last_y: #{y_}\"\n\n extra_capacity = c - y_\n c1, a1 = items[0][:p], items[0][:w]\n qt_best_item_used = Rational(extra_capacity, a1).ceil\n space_used_by_best_item = qt_best_item_used*a1\n profit_generated_by_best_item = qt_best_item_used*c1\n\n opt_y = get_opt_y(c-space_used_by_best_item, items, g, d)\n g[c] = g[opt_y] + profit_generated_by_best_item\n end\n\n opt = g[c] if opt < g[c]\n\n if return_used_items then\n g.slice!(c+1, max_w)\n d.slice!(c+1, max_w)\n opt_y = get_opt_y(c, items, g, d)\n get_used_items_for_y(opt_y, items, g, d)\n else\n opt\n end\nend", "def test_healingItem\n f = ItemFilter.new(\"healing\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 6\n end", "def secretary\n\t\trejects, considered = distr.partition.with_index{|t,i| i < count/EXP}\n\t\tlow = rejects.min\n\t\tconsidered.detect{|good| good <= low} or low\n\tend", "def does_list_include?(array, obj)\n array.count(obj) > 0\nend", "def lookup(item)\n fingerprint = fingerprint(item)\n first_index = hash(item)\n second_index = alt_index(first_index, fingerprint)\n\n @buckets[first_index].contains?(fingerprint) || @buckets[second_index].contains?(fingerprint)\n end", "def used_by?(element)\n end", "def used_by?(element)\n end", "def probable_matching(ingredient_long_name,item)\n return (item.downcase.split(\" \") & ingredient_long_name.split(\" \")).size >= 2\nend", "def test_physicalAttackItemNullValue\n f = ItemFilter.new(\"physical_attack\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def include? item\n return index_of(item) != nil\n end", "def remove_simple_dominance(items, already_sorted = false)\n # the vector HAS TO BE sorted by non-increasing profitability first AND\n # non-decreasing weight after to this code work\n items = sort_items_by_profitability!(items.clone) unless already_sorted\n \n # If an item i dominate an item j, then pi/wi >= pj/wj. Note that NOT every\n # case we have an item i and item j and pi/wi >= pj/wj i dominates j\n # (if this was the case every UKP problem could be reduced to the best item).\n # This only means that, if i is the index of the item when the items are\n # ordered by pi/wi, then it can't be simple or multiple dominated by any\n # item of index j where j > i.\n undominated = [items[0]]\n # if this was C++ would be interesting to already reserve the n capacity\n # on the vector above\n items.each do | i |\n dominated = false\n wi = i[:w]\n pi = i[:p]\n undominated.each do | u |\n wu = u[:w]\n pu = u[:p]\n if Rational(wi,wu).floor * pu >= pi then\n dominated = true\n break\n end\n end\n undominated << i unless dominated\n end\n\n undominated\nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend", "def item_check(tree)\n if tree[0] == nil\n tree[1]\n else\n tree[1] + item_check(tree[0]) - item_check(tree[2])\n end\nend", "def include?(item)\n return item != nil\n end", "def assert_not_includes(expected_items, collection)\n expected_items = [ expected_items ] unless expected_items.respond_to? \"size\"\n expected_items.each { |item| assert_false collection.include?(item), \"#{item.inspect} should not be contained in the collection\" }\n end", "def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end", "def filter_available_for *items\n items.any? do |item|\n item = [item] unless item.is_a? Array\n item.reduce(filter_params) do |memo,it|\n if memo.is_a?(Hash)\n if memo[it].nil?\n false\n else\n memo[it]\n end\n else\n false\n end\n end\n end\n end", "def better_two_sum?(arr, target_sum)\n hash = {}\n arr.each_with_index do |ele,i|\n hash[ele] = i\n end\n arr.each_with_index do |ele,i|\n target = target_sum - ele\n return true if !hash[target].nil? && i != hash[target]\n end\n \n false\nend", "def should_i_buy?(item)\n !!list[item.to_sym]\n end", "def true_for_ravenclaw(array, item)\n for i in array\n status= i.include?(item)\n end\n return status\nend", "def search_by_item_with_feedback(item, type, o={})\n o[:feedback_weights] ||= [0.2]*5\n initial_result = search_by_item(item, type, o)\n final_result = initial_result.map_hash{|e|[e[:id], e[:score]]}\n initial_result.each_with_index do |row,i|\n break if !o[:feedback_weights][i]\n result = search_by_item(row[:id], type, o).map_hash{|e|[e[:id], e[:score]]}\n final_result = final_result.sum_prob(result.times(o[:feedback_weights][i] / DISCOUNT_FACTOR))\n end\n final_result.map{|k,v|{:id=>k, :score=>v}}.sort_by{|e|e[:score]}.reverse\n end", "def has_ordered?(item_to_check)\n if item_to_check.class == Item\n @order.any? {|item| item.name == item_to_check.name}\n else \n false\n end \nend", "def test_exists_with_order_and_distinct\n assert_equal true, Topic.order(:id).distinct.exists?\n end", "def numSmaller(list,item)\r\n\tif(list.count > 0) then\r\n\t\treturn list.count{|val| val.to_i<item.to_i}\r\n\telse\r\n\t\treturn 0\r\n\tend\r\nend", "def test_attackItem\n f = ItemFilter.new(\"attack\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 9\n end", "def keep_item?(item)\n keep_all? or interesting_item?(item)\n end", "def is_straight?\n order_by_value.each_cons(2).all? { |x,y| y.point == x.point + 1 }\n end", "def test_xyz_not_in_arr\n refute_includes(list, 'ttt')\n end", "def has_places?\n capacity > 0\n end", "def test_healingSkillNullValue\n f = SkillFilter.new(\"healing\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def collect_eligible(items)\n items.select{|item| eligible?(item) }\n end", "def find_item(houses, house_im_looking_for)\nfor house in houses\n if house == house_im_looking_for\n return true\n end\nend\nreturn false\nend", "def check_items_balances\n details.select(&:marked_for_destruction?)\n .all?(&:valid_for_destruction?)\n end", "def item_check(left, item, right)\n return item if left.nil?\n item + item_check(*left) - item_check(*right)\nend", "def compute_matching_product(among_products) among_products.select { |product| concern?(product, among_products) } end", "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 two_sum?(arr, target)\r\n hash = {}\r\n arr.each_with_index do |ele, i| #n\r\n hash[i] = ele\r\n end\r\n arr.each_with_index do |ele, i| #n \r\n value = target - ele\r\n if hash.has_value?(value) && hash.key(value) != i\r\n return true\r\n end\r\n # all the keys in has except i\r\n # if any of the value = value\r\n end\r\n false\r\nend", "def include?(list, search)\n !!list.find_index(search)\nend", "def two_sum?(arr, target)\n hash = Hash.new(0)\n arr.each do |ele|\n hash[ele] += 1\n end\n arr.each do |ele|\n dif = target - ele\n if hash[dif] && (dif != ele || hash[dif] >= 2 )\n # if hash.include?(dif) && (dif != ele || hash[dif] >= 2 ) \n return true \n end\n end\n false\nend", "def contains_nearby_duplicate(nums, k)\n counter = {}\n \n nums.each_with_index do |num, i|\n return true if i - counter[num] <= k if counter[num]\n \n counter[num] = i \n end\n \n false\nend", "def item_check(left, item, right)\n return item if left.nil?\n item + item_check(left[0],left[1],left[2]) - item_check(right[0],right[1],right[2])\nend", "def two_sum?(arr, target_sum) # O(N)\n hash = Hash.new(0)\n count = Hash.new(0)\n\n arr.each do |num|\n hash[num] = target_sum - num\n count[num] += 1\n end\n\n hash.each do |key, value|\n if hash.has_key?(value) \n if key == value \n if count[value] > 1\n return true\n end\n else\n return true\n end\n end\n end\n\n false\nend", "def include?(item)\n ! get(item).nil?\n end", "def most_likely_duplicate\n possible_matching_people.first\n end", "def at_least?(arr, n, &blck)\n count = 0\n arr.each do |el|\n count += 1 if blck.call(el)\n end\n count >= n\nend", "def include?(array, search_value)\n array.count(search_value) > 0\nend", "def has_items?\n return !items.empty?\n end", "def include?(item)\n item_hash = item.hash\n\n index = item_hash & @mask\n return true if match? @table, index, item_hash, item\n\n index = item_hash.hash & @mask\n return true if match? @table, index, item_hash, item\n\n return false if @spill.empty?\n\n i = @spill.to_iter 3\n while i.next\n return true if match? @spill, i.index, item_hash, item\n end\n\n false\n end", "def include?(item)\n end", "def is_complex(an_item)\n occurrence_counter = 0\n #verify if item has two or more affilition elements\n if get_institution(an_item) != nil then occurrence_counter += 1 end\n if get_country_any(an_item) != nil then occurrence_counter += 1 end\n if get_department(an_item) != nil then occurrence_counter += 1 end\n if get_faculty(an_item) != nil then occurrence_counter += 1 end\n if get_workgroup(an_item) != nil then occurrence_counter += 1 end\n # if more than one affilition element, treat as complex\n if occurrence_counter > 1\n return true\n else\n return(false)\n end\nend", "def find_index array, item\n\tl,r = 0, array.length-1\n\n\twhile l <= r\n\t\tm = (r+l) / 2\n\t\tcomp = yield item, array[m]\n\t\tif comp == false\n\t\t\t# Items compare the same\n\t\t\treturn false\n\t\telsif comp == -1 \n\t\t\tr = m - 1\n\t\telse\n\t\t\tl = m + 1\n\t\tend\n\tend\n\n\tl\nend", "def test_physicalAttackItem\n f = ItemFilter.new(\"physical_attack\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 2\n end", "def should_collect_functioning_bikes?(container)\n !self.full? && container.functioning_bikes.count >= 1\n end", "def test_nameUsableItemNullValue\n f = UsableItemFilter.new(\"name\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def guess_gifts(wishlist, presents)\n\n wishlist.map do |w|\n w[:name] if presents.include? w.reject { |key| key == :name }\n end.compact.uniq\n\nend", "def item_conditions_met?(item)\r\n usable_item_conditions_met?(item) && $game_party.has_item?(item)\r\n end", "def test_attackSkillNullValue\n f = SkillFilter.new(\"attack\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def test_supportSkillNullValue\n f = SkillFilter.new(\"support\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def include?(item)\n return false if item.nil?\n return true\n end", "def test_emptyBaseItem\n f = BaseItemFilter.new()\n new_list = [].find_all{|x| f.apply(x)}\n return new_list.size == 0\n end", "def include?(ary, target)\n !ary.select { |value| value == target }.empty?\nend", "def item_before_in_list(check, list)\n list.each do |item|\n list.each do |inner_item|\n if item == inner_item\n puts \"do something\"\n end\n end\n end\nend", "def test_physicalAttackUsableItem\n f = UsableItemFilter.new(\"physical_attack\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 12\n end", "def check_the_bucket(bucket)\n bucket.include? 'gold'\nend" ]
[ "0.56466204", "0.5602917", "0.55562454", "0.5533335", "0.5503255", "0.53874195", "0.53644425", "0.53553236", "0.5306399", "0.52539283", "0.5243651", "0.5224115", "0.52207965", "0.521725", "0.52033013", "0.51916766", "0.5186297", "0.5158719", "0.5156644", "0.5154102", "0.51536125", "0.5141256", "0.5139081", "0.51245725", "0.5104948", "0.51008576", "0.509568", "0.5094144", "0.50900114", "0.50772864", "0.5073726", "0.5072868", "0.50709", "0.50612724", "0.50600296", "0.5052681", "0.5048947", "0.50431275", "0.5027337", "0.50240445", "0.501355", "0.501355", "0.50057924", "0.4993042", "0.49875084", "0.4983059", "0.4979472", "0.49670768", "0.4966637", "0.49619293", "0.49529693", "0.49435055", "0.49407354", "0.49396655", "0.49377835", "0.4934712", "0.49317768", "0.4924993", "0.49234927", "0.49226263", "0.4922152", "0.49178836", "0.49119276", "0.4908644", "0.49025437", "0.49005234", "0.48999882", "0.48986062", "0.48967224", "0.48959747", "0.48844293", "0.48788893", "0.4878377", "0.48783022", "0.4878096", "0.48738402", "0.48667714", "0.4864565", "0.48637342", "0.4863592", "0.48623744", "0.48614508", "0.48572367", "0.48552492", "0.4855063", "0.48531768", "0.48517415", "0.4849399", "0.48478684", "0.484668", "0.48443532", "0.4842007", "0.483591", "0.4834191", "0.48318136", "0.4830699", "0.4830685", "0.4828616", "0.4825913", "0.48248035", "0.48155263" ]
0.0
-1
binary search without recursion
def binary_search_with_while(array, value) from = 0 to = array.size - 1 while from <= to mid = (from + to) / 2 if array[mid] > value to = mid - 1 elsif array[mid] < value from = mid + 1 else return mid end end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_search(ary, value); end", "def bin_search(x, a, b)\r\n mid = (a + b) / 2\r\n sq = mid ** 2\r\n \r\n if a == b || sq == x\r\n mid\r\n elsif sq > x\r\n bin_search(x, a, mid - 1)\r\n else\r\n (mid + 1) ** 2 > x ? mid : bin_search(x, mid + 1, b)\r\n end\r\nend", "def binary_search(arr, target)\n return nil if arr.empty?\n probe_index = arr.size / 2\n probe_ele = arr[probe_index]\n\n case probe_ele <=> target\n when 1\n left_arr = arr.take(probe_index) \n return binary_search(left_arr,target)\n when 0 \n return probe_index\n when -1\n compensated_index = (probe_index + 1)\n right_arr = arr.drop(compensated_index)\n return nil if binary_search(right_arr,target).nil?\n return binary_search(right_arr,target) + compensated_index\n end\nend", "def binary_search(arr, val, strategy='rec')\n if strategy != 'rec'\n search(arr, val)\n else\n rec_search(arr, val, 0, arr.size - 1)\n end\nend", "def binary_search(a, key)\n low = 0\n high = a.length - 1\n\n while low <= high\n mid = low + ((high - low) / 2)\n\n return mid if a[mid] == key\n\n if key < a[mid]\n high = mid - 1\n else\n low = mid + 1\n end\n end\n\n return -1\nend", "def rec_bin_search(array, target)\n return nil if array.length == 0\n\n midpoint = array.length / 2\n\n return midpoint if array[midpoint] == target\n\n if target < array[midpoint]\n rec_bin_search(array.take(midpoint), target)\n else\n top = rec_bin_search(array.drop(midpoint + 1), target)\n top == nil ? nil : top + (midpoint + 1)\n end\nend", "def recursive_bin_search(d, arr, first = 0, last=arr.size-1)\n middle = (first + last) / 2\n case arr[middle] <=> d\n when 0 # arr[middle] == d\n return true\n when -1 # arr[middle] < d\n first = first + 1\n return recursive_binary_search(arr, target, first, last)\n when 1 # arr[middle] > d\n last = last - 1\n return recursive_binary_search(arr, target, first, last)\n end\n end", "def binary_search_recursive(array, target, low = 0, high = array.length - 1)\n return \"#{target} value could not be found\" if low > high\n mid = (low + high) / 2\n return mid if array[mid] == target\n p \"#{low} #{mid} #{high}\"\n if array[mid] > target\n high = mid - 1\n else\n low = mid + 1\n end\n binary_search_recursive(array, target, low, high)\nend", "def binary_search(arr, target)\n binary_search_helper(arr, target, 0, arr.length - 1)\nend", "def binary_search(array, target)\n lower_bound = 0\n upper_bound array.length - 1\n while lower_bound <= upper_boud do\n midpoint = (upper_bound + lower_bound) / 2\n value_at_midpoint = array[midpoint]\n if target == value_at_midpoint\n return midpoint\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n end\n end\n return nil\nend", "def binary_search(arr, key)\n low = 0\n high = arr.length - 1\n\n while low <= high\n mid = low + (high - low) / 2\n\n return mid if arr[mid] == key\n\n arr[mid] > key ? high = mid - 1 : low = mid + 1\n end\n\n return -1\nend", "def binary_search_rec(a, key, low, high)\n# At every step, consider the array between low and high indices\n# When low is greater than high, the key doesn’t exist and -1 is returned.\n if low > high\n return -1\n end\n\n\n# Calculate the mid index.\n mid = low + ((high - low) / 2)\n\n# If the element at the mid index is the key, return mid.\n if a[mid] == key\n return mid\n\n# If the element at mid is greater than the key, then change the index high to mid - 1.\n# The index at low remains the same.\n elsif key < a[mid]\n return binary_search_rec(a, key, low, mid - 1)\n else\n# If the element at mid is less than the key, then change low to mid + 1. The index at high remains the same.\n return binary_search_rec(a, key, mid + 1, high)\n end\nend", "def binary_search(array, target)\n return nil if array.length == 1 && array[0] != target\n mid = array.length / 2\n\n if target == array[mid]\n return mid\n elsif target < array[mid]\n return binary_search(array[0...mid], target)\n else\n found = binary_search(array[mid+1..-1], target)\n return found.nil? ? nil : mid + 1 + found\n end\nend", "def binary_search_internal(value)\n return [false, 0] if @inner.size == 0\n left = 0\n right = @inner.size - 1\n return [false, 0] if value < @inner[left]\n return [false, right + 1] if value > @inner[right]\n while left <= right\n middle = (left + right) / 2\n if @inner[middle] == value\n return [true, middle]\n elsif value < @inner[middle]\n right = middle - 1\n else\n left = middle + 1\n end\n end\n return [false, left]\n end", "def binary_search(arr, target, idx_puls = 0)\n mid = arr.length / 2\n return mid + idx_puls if arr[mid] == target\n return nil if arr.length == 1\n\n if arr[mid] < target\n binary_search(arr[(mid + 1)..-1], target, mid + 1)\n else\n binary_search(arr[0...mid], target, idx_puls)\n end\n\nend", "def binary_search(array, key, low=0, high=array.size-1) \n return -1 if low > high \n mid = (low + high) / 2 \n return mid if array[mid]==key \n if array[mid] > key \n high = mid - 1 \n else \n low = mid + 1 \n end \n binary_search(array, key, low, high) \nend", "def binary_search(arr, target)\n return nil if !arr.include?(target)\n middle_ele = arr[arr.length / 2]\n middle_idx = arr.length / 2\n if target == middle_ele\n return middle_idx\n elsif target > middle_ele\n binary_search(arr[middle_idx+1..-1], target) + arr[0..middle_idx].length\n else\n binary_search(arr[0...middle_idx], target)\n end\nend", "def binary_search(target, array)\r\n\t#Your code here\r\n\tindex = array.length / 2\r\n\tlo = 0\r\n\thi = array.length - 1\r\n\twhile array[index] != target && array.include?(target)\r\n\t\tif array[index] > target\r\n\t\t\thi = index - 1\r\n\t\t index = (lo + hi) / 2\r\n\t\telsif array[index] < target\r\n\t\t\tlo = index + 1\r\n\t\t\tindex = (lo + hi) / 2\r\n\t\tend\r\n\tend\r\n\tif array[index] == target\r\n\t\treturn index\r\n\telse\r\n\t\treturn -1\r\n\tend \r\nend", "def binary_search(array, value, from=0, to=nil)\n to = array.count - 1 unless to\n mid = (from + to) / 2\n \n if value < array[mid]\n return binary_search(array, value, from, mid - 1)\n elsif value > array[mid]\n return binary_search(array, value, mid + 1, to)\n else\n return mid\n end\nend", "def binary_search(array, target) \n return nil if array.length == 0\n mid = array.length / 2\n return mid if array[mid] == target\n left = array[0...mid]\n right = array[mid + 1..-1]\n if array[mid] > target #[]\n binary_search(left, target)\n else\n result = binary_search(right, target)\n return result.nil? ? nil : result + mid + 1\n end\n \nend", "def binary_search(array, target)\n return nil if array.empty?\n midpoint = array.length / 2\n case target <=> array[midpoint]\n when 0\n midpoint\n when 1\n right_idx = binary_search(array[(midpoint + 1)..-1], target)\n if right_idx\n right_idx + 1 + midpoint\n else\n nil\n end\n when -1\n binary_search(array[0...midpoint], target)\n end\nend", "def binary_search(arr, target)\n if arr.length == 1\n return nil if arr[0] != target\n end\n mid = arr.length / 2\n if target == arr[mid]\n return mid\n elsif target > arr[mid]\n if binary_search(arr[mid..arr.length], target) == nil\n return nil\n else\n return binary_search(arr[mid..arr.length], target) + arr.length / 2\n end\n else\n binary_search(arr[0..mid-1], target)\n end\nend", "def binary_search(arr, l, r, x)\n if r >= l\n mid = l + (r - l)\n\n # If the element is present\n # at the middle itself\n if arr[mid] == x\n return mid\n end\n\n # If element is smaller than\n # mid, then it can only be\n # present in left subarray\n\n if arr[mid] > x\n return binary_search(arr, l, mid - 1, x)\n\n # Else the element can only\n # be present in right subarray\n return binary_search(arr, mid + 1, r, x)\n end\n end\n # We reach here when element\n # is not present in array\n - 1\nend", "def binary_search_iterative(array, target)\n# declare variables for low and high positions\nlow_index = 0\nhigh_index = array.length - 1\nmid_index = (high_index + low_index) / 2\n\n# while the low is less than the high\nwhile low_index <= high_index do\n\n return mid_index if target == array[mid_index]\n\n puts \"#{low_index} #{mid_index} #{high_index}\"\n\n if low_index == mid_index\n return high_index\n elsif target > array[mid_index]\n # move lower bound up to mid, recalculate new mid\n low_index = mid_index\n # set the high halfway between\n mid_index = (low_index + high_index) / 2\n elsif target < array[mid_index]\n # move upper bound to mid, recalculate new mid\n high_index = mid_index\n mid_index = (low_index + high_index) / 2\n end\n end\nend", "def binary_search(array, value)\n return nil if array.length == 1 && array[0] != value\n midpoint = array.length/2\n return midpoint if array[midpoint] == value\n if array[midpoint] < value\n midpoint + binary_search(array[midpoint..array.length], value) if binary_search(array[midpoint..array.length], value)\n else\n binary_search(array[0...midpoint], value)\n end\nend", "def binary_search(arr,tar)\n return nil if arr.length < 1\n mid_idx = arr.length / 2\n if arr[mid_idx] == tar\n return mid_idx\n elsif arr[mid_idx] > tar\n binary_search(arr[0...mid_idx],tar)\n elsif arr[mid_idx] < tar\n subanswer = binary_search(arr[mid_idx+1..-1],tar)\n subanswer.nil? ? nil : (mid_idx+1) + subanswer\n end\nend", "def bsearch(arr, target)\n if arr.length == 1 \n if arr[0] == target\n return 0\n else\n return nil\n end\n end\n arr.sort!\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle + 1..-1]\n if arr[middle] == target\n return middle\n elsif arr[middle] < target\n if bsearch(right, target).nil?\n return nil\n # else\n return left.length + 1 + bsearch(right, target)\n end\n else \n bsearch(left, target)\n end\nend", "def binary_search(arr, target)\n new_arr = arr\n return nil if arr.empty? \n middle = (arr.length - 1) / 2\n if arr[middle] > target\n binary_search(arr[0...middle], target)\n elsif arr[middle] < target \n if binary_search(arr[middle+1..-1], target).nil?\n return nil\n else\n binary_search(arr[middle+1..-1], target) + middle + 1\n end \n elsif target == arr[middle]\n return new_arr.index(arr[middle])\n else\n return nil\n end\nend", "def bin_search(arr, key)\n low = 0\n high = arr.length - 1\n while high >= low do\n mid = low + (high - low) / 2\n if arr[mid] > key\n high = mid - 1\n elsif arr[mid] < key\n low = mid + 1\n else\n return mid\n end\n end\n return 0\nend", "def bsearch(arr, target)\n return nil if arr.length == 1 && arr[0] != target\n mid_i = arr.length / 2\n return mid_i if arr[mid_i] == target\n\n low_arr = arr[0...mid_i]\n high_arr = arr[mid_i+1..-1]\n\n if arr[mid_i] > target\n bsearch(low_arr, target) \n elsif bsearch(high_arr, target) != nil\n low_arr.length + 1 + bsearch(high_arr, target)\n end\n\nend", "def binsearch(ary, x)\n left = 0\n right = ary.length - 1\n while left < right\n middle = (left + right) / 2\n Tanj.array :ary, index: [:left..:right, :middle]\n if ary[middle] == x\n Tanj.message \"found it!\"\n return middle\n elsif ary[middle] < x\n Tanj.message \"too small\"\n left = middle + 1\n elsif ary[middle] > x\n Tanj.message \"too large\"\n right = middle - 1\n else\n Tanj.message \"this should be unreachable!\"\n end\n end\n Tanj.message \"didn't find it\"\n return nil\nend", "def binary_search(array, target)\n lower_bound = 0\n upper_bound = array.length - 1\n while lower_bound <= upper_bound\n midpoint = (lower_bound + upper_bound) / 2\n value_at_midpoint = array[midpoint]\n if target = value_at_midpoint\n return midpoint\n elsif target > value_at_midpoint\n lower_bound = midpoint + 1\n elsif target < value_at_midpoint\n upper_bound = midpoint - 1\n end\n end\n return nil\nend", "def binary_search(array, key, start_position)\n left = start_position\n right = array.size - 1\n\n while left < right\n mid = (left + right) / 2\n\n if array[mid] < key\n left = mid + 1\n else\n right = mid\n end\n end\n\n (left == right && array[left] == key) ? left : -1\nend", "def recursive_binary_search_two(arr, value)\n low, hi = get_limits(arr)\n return false if low >= hi\n\n mid = (low + hi) / 2\n if arr[mid] == value\n true\n elsif arr[mid] < value\n recursive_binary_search_two(arr[mid + 1..hi], value)\n else\n recursive_binary_search_two(arr[low..mid], value)\n end\nend", "def binary_search(a, key)\n return binary_search_rec(a, key, 0, a.length - 1)\nend", "def binary_search(arr, target)\n mid = arr.length / 2\n left = arr.slice(0, mid)\n right = arr.slice(mid, arr.length)\n if arr.length < 2\n return arr.first == target\n elsif left.last >= target\n return binary_search(left, target)\n elsif right.last >= target\n return binary_search(right, target)\n else\n false\n end\nend", "def binary_search(a, key)\n# At every step, consider the array between low and high indices\n# Define initial low and high indices \n low = 0\n high = a.length - 1\n\n\n# If low value is less or equal to high value, calculate the mid index.\n while low <= high\n mid = low + ((high - low) / 2)\n\n# If the element at the mid index is the key, return mid.\n if a[mid] == key\n return mid\n end\n\n# If the element at mid is greater than the key, then change the index high to mid - 1.\n# The index at low remains the same.\n if key < a[mid]\n high = mid - 1\n\n# If the element at mid is less than the key, then change low to mid + 1. The index at high remains the same.\n else\n low = mid + 1\n end\n end\n\n# Through interations, the low indice will be larger than the high indice if the key doesn’t exist, so -1 is returned.\n return -1\nend", "def bsearch(arr, target)\n return nil if arr.empty?\n mid = arr.length / 2\n return mid if arr[mid] == target\n\n if target < arr[mid]\n bsearch(arr[0...mid], target)\n else\n result = bsearch(arr[mid + 1..-1], target)\n result.nil? ? nil : mid + 1 + result\n end\nend", "def b_search(arr, target)\n return false if arr.empty?\n mid = arr / 2\n if arr[mid] == target\n true\n elsif arr[mid] < target\n b_search(arr[mid..-1], target)\n else\n b_search(arr[0...mid], target)\n end\nend", "def binary_search(array, value, from=0, to=nil)\n if to == nil\n to = array.count - 1\n end\n\n mid = (from + to) / 2\n\n if value < array[mid]\n return binary_search array, value, from, mid - 1\n elsif value > array[mid]\n return binary_search array, value, mid + 1, to\n else\n return mid\n end\nend", "def binary_search(array, value, from=0, to=nil)\n if to == nil\n to = array.count - 1\n end\n\n mid = (from + to) / 2\n\n if value < array[mid]\n return binary_search array, value, from, mid - 1\n elsif value > array[mid]\n return binary_search array, value, mid + 1, to\n else\n return mid\n end\nend", "def do_search(target_value, array)\n min = 0\n max = array.length - 1\n\n binary_search(target_value, array, min, max)\nend", "def binary_search(length, prime)\r\n\r\nend", "def binary_search(arr, l, r, target)\n return [-1, l, r] if l > r\n mid = l + (r - l) / 2\n return [mid, l, r] if (arr[mid] == target) # Found match!\n (arr[mid] > target) ? binary_search(arr, l, mid - 1, target) : binary_search(arr, mid + 1, r, target)\nend", "def binary_search(array, length, value_to_find)\n raise NotImplementedError\nend", "def binary_search(collection, value)\n low = 0\n high = collection.length\n if low >= high\n return \"not found\"\n end\n\n mid = (high / 2).ceil\n\n if collection[mid] == value\n return collection[mid]\n elsif collection[mid] < value\n binary_search(collection[(mid+1)...high], value)\n else\n binary_search(collection[low...mid], value)\n end\nend", "def binary_search(binaryMatrix,start,last,n,row)\n\tif start > last\n\t\treturn -1\n\tend\n\tmid = start + (last-start)/2\n\tif binaryMatrix.get(row,mid) == 1\n\t\tif binaryMatrix.get(row,mid-1) == 0 || mid == 0\n\t\t\treturn mid\n\t\telse\n\t\t\tbinary_search(binaryMatrix,start,mid-1,n,row)\n\t\tend\t\n\telsif binaryMatrix.get(row,mid) == 0\n\t\tbinary_search(binaryMatrix,mid+1,last,n,row)\n\tend\nend", "def binary_search(array, target)\n mid = array.length / 2\n\n if target < array[mid]\n binary_search(array[0...mid], target)\n elsif value > array[mid]\n function = binary_search(array[mid + 1..-1], target)\n function.nil? ? nil : function + mid + 1\n else\n return mid\n end\nend", "def bin_search(target,array)\n lo = 0\n hi = array.length - 1\n mid = (lo+hi)/2\n while lo <= hi\n if array[mid] > target\n hi = mid-1\n mid = (lo+hi)/2\n elsif array[mid] < target\n lo = mid+1\n mid = (lo+hi)/2\n else\n return mid\n end\n end\n return -1\nend", "def binarySearch(arr, l, r, x)\n if r >= l\n mid = l + (r - l) / 2\n # // If the element is present at the middle itself\n return mid if (arr[mid] == x)\n # // If element is smaller than mid, then it can only be present in left subarray\n # // Else the element can only be present in right subarray\n (arr[mid] > x) ? binarySearch(arr, l, mid - 1, x) : binarySearch(arr, mid + 1, r, x)\n end\n # // We reach here when element is not present in array\n -1\nend", "def bin_search_array(num, array)\n return \"not found!\" if array.nil? || array.empty?\n mid = (array.length / 2).ceil\n puts mid\n if array[mid] == num\n puts \"found!\"\n return mid\n elsif array[mid] > num\n puts \"searching left in #{array[0..mid]}\"\n bin_search_array(num, array[0..mid])\n else\n puts \"searching right in #{array[mid...array.length]}\"\n bin_search_array(num, array[mid...array.length])\n end\nend", "def binary_search(array, target)\n return nil if array.empty?\n\n middle_idx = array.length/2\n\n case target <=> array[middle_idx]\n\n when -1\n binary_search(array.take(middle_idx), target)\n when 0\n return middle_idx\n when 1\n binary_search(array[middle_idx..-1], target)\n end\n\nend", "def binary_search(binary, size, search_key, low, middle, high)\n while (low <= high)\n middle=(low+high)/2;\n print_row(binary, size, low, middle, high);\n if (search_key == binary[middle])\n return middle;\n elsif (search_key <= binary[middle])\n high=middle-1\n else \n low=middle+1\n end\n end\nend", "def search(a, x) # search for x in a[]\n puts \"Called search(#{a.inspect}, #{x})\"\n return false if a.length == 0\n\n mid = a.length / 2\n left, right = 0, -1\n if a[mid] == x\n true\n elsif a[mid] <= a[right] # sorted, between mid -> right\n if x > a[mid] && x <= a[right]\n search(a.right, x)\n else\n search(a.left, x)\n end\n else # resets after middle\n if x > a[mid] || x <= a[right]\n search(a.right, x)\n else\n search(a.left, x)\n end\n end\nend", "def binary_search(array, key)\n low, high = 0, array.length - 1\n while low <= high\n mid = (low + high) >> 1\n case key <=> array[mid] # if key < array[mid] then return -1 if key = array[mid] then 0 else return 1\n\t when 1\n low = mid + 1\n when -1\n high = mid - 1\n else\n return mid\n end\n end\nend", "def binary_search(array, target)\n temp = array.sort\n middle = temp.length / 2\n first = 0\n last = temp.length - 1\n while first < last\n if temp[middle] == target\n return middle\n elsif temp[middle] < target\n first = middle + 1\n middle = (first + last) / 2\n else\n last = middle - 1\n middle = (first + last) / 2\n end\n end\n return -1\nend", "def binary_search(array, length, value_to_find)\n # take the length and divide in half,\n # start_index = 0\n # end_index = length - 1\n # midpoint = length / 2\n # until start_index > end_index\n #\n # end\n\nend", "def binary_search(array, find)\n\tlow = 0\n\thi = array.length-1 \n\n\twhile (low <= hi)\n\t\tmid = low + (hi-low)/2\n\n\t\tif array[mid] == find\n\t\t\treturn mid\n\t\telsif array[mid] < find\n\t\t\tlow = mid + 1\n\t\telse \n\t\t\thi = mid - 1\n\t\tend\t\n\tend\n\n\treturn \"Value not found in array\"\n\nend", "def binary_search_recursive_destructive(array, target)\n\n low = 0\n high = array.length - 1\n mid = (low + high) / 2\n\n binding.pry\n\n return true if target == array[mid] # the target is found\n return false if array[mid] == nil # the target doesn't exist\n\n # reduce the search area && call recursively\n if target > array[mid]\n new_array = array[(mid + 1)..high]\n binary_search_recursive_destructive(new_array, target)\n elsif target < array[mid]\n new_array = array[low..(mid - 1)]\n binary_search_recursive_destructive(new_array, target)\n end\n\nend", "def bsearch(array, target)\n return nil if !array.include?(target)\n arr = array.sort\n\n mid = arr.length / 2\n\n\n if arr[mid] == target\n return mid\n elsif arr[mid] < target\n mid + bsearch(arr[mid..-1], target)\n else\n bsearch(arr[0..mid-1], target)\n end\nend", "def binary_search(array, length, value_to_find)\n puts \"NOT IMPLEMENTED\"\nend", "def bsearch(arr, target)\n return -1 if arr.empty?\n left = 0\n right = arr.length - 1\n bsearch_helper(arr, target, left, right)\nend", "def binary_search(array, target)\n return nil if array.count == 0\n\n median = array.length / 2\n left = array[0...median]\n right = array[median + 1..-1]\n\n return median if array[median] == target\n if target < array[median]\n return binary_search(left, target)\n else\n sub_answer = binary_search(right, target)\n (sub_answer.nil?) ? nil : (sub_anser + median + 1)\n end\n\nend", "def bsearch(arr, target)\r\n return false if arr.length == 0\r\n\r\n mid = arr.length/2\r\n\r\n return mid if arr[mid] == target\r\n if arr[mid] > target\r\n found = bsearch(arr[mid+1..-1], target)\r\n found + mid + 1 unless found == false\r\n else\r\n bsearch(arr[0...mid], target)\r\n end\r\n false\r\nend", "def bsearch(arr, num)\n return nil if !arr.include?(num)\n\n mid_idx = arr.length / 2\n if arr[mid_idx] == num\n return mid_idx\n elsif arr[mid_idx] > num\n lower_half = arr[0...mid_idx]\n bsearch(lower_half, num)\n else\n upper_half = arr[(mid_idx + 1)..-1]\n bsearch(upper_half, num)\n end\n\nend", "def binary_search(array, length, value_to_find)\n high = length\n low = 0\n length.times do\n guess = (low + high) / 2\n return true if array[guess] == value_to_find\n return false if high - low <= 1\n array[guess] < value_to_find ? low = guess : high = guess\n end\nend", "def binary_search(array,target)\n \n min = 0\n max = array.length - 1\n \n while min <= max\n mid = (min + max) / 2\n if array[mid] > target\n max = mid -1\n elsif array[mid] < target\n low = mid + 1 \n else\n return mid\n end\n end\n\nend", "def bsearch arr, target \n return nil if arr.length == 1 && !arr.include?(target)\n\n mid_idx = arr.length / 2\n\n return mid_idx if arr[mid_idx] == target \n \n left = arr.take(mid_idx)\n right = arr.drop(mid_idx)\n\n if arr[mid_idx] > target \n bsearch(left, target)\n else \n result = bsearch(right,target)\n if result.nil? \n return nil \n else \n result + mid_idx\n end\n end\nend", "def bsearch(arr,target)\r\n return nil if arr.length == 0 \r\n midIdx = arr.length/2\r\n mid = arr[midIdx] \r\n if mid > target #left half\r\n bsearch(arr[0...midIdx],target)\r\n elsif mid < target #right half\r\n\r\n idx = bsearch(arr[midIdx+1..-1],target)\r\n if idx \r\n idx + arr[0..midIdx].length\r\n else\r\n return nil\r\n end\r\n \r\n else\r\n return midIdx\r\n end\r\n\r\nend", "def binary_search(array,item,min,max) #We want this to return the array index of item\n midpoint = min + ( (max - min) / 2 )\n return midpoint if array[midpoint] == item\n\n if max - min == 1 || max - min == 0\n if array[midpoint] == item\n return midpoint\n elsif array[midpoint +1] == item\n return midpoint + 1\n else\n return nil\n end\n end\n\n if array[midpoint] > item\n binary_search(array,item,min,midpoint)\n else array[midpoint] < item\n binary_search(array,item,midpoint,max)\n end\n\nend", "def binary_search(array, length, value_to_find)\n mid_point = length/2\n mid = array[mid_point]\n counter = 0\n\n until mid == value_to_find || counter > length\n if mid > value_to_find\n mid_point = mid_point/2\n else \n mid_point = (length - mid_point)/2 + mid_point\n end\n\n mid = array[mid_point]\n counter += 1\n end\n\n mid == value_to_find\nend", "def binary_search(array, element, low=0, high=array.length-1)\n return nil if high < low\n\n mid = ( low + high ) / 2\n\n if array[mid] > element\n return binary_search(array, element, low, mid - 1)\n elsif array[mid] < element\n return binary_search(array, element, mid + 1, high)\n else\n return mid\n end\nend", "def binary_search(arr, element)\n low = 0\n high = arr.length - 1\n\n while low <= high\n mid = (low + high) / 2\n guess = arr[mid]\n\n if guess > element\n high = mid - 1\n elsif guess < element\n low = mid + 1\n else\n return mid\n end\n end\n\n nil\nend", "def binary_search(key,array)\n\tlow = 0\n\thigh = array.sort.length - 1\n\treturn -1 if low>high\n\tmid = (low+high)/2\n\treturn mid if array[mid]==key\n\t\tif array[mid]>key\n\t\t\thigh=mid-1\n\t\t\tmid=(low+high)/2\n\t\telse\n\t\t\tlow=mid+1\n\t\t\tmid=(low+high)/2\n\t\tend\nend", "def bsearch(array, target)\n return nil if array.empty?\n\n mid_idx = array.length / 2\n mid_ele = array[mid_idx]\n\n return mid_idx if target == mid_ele\n\n if target < mid_ele\n sub_arr = array[0...mid_idx]\n return bsearch(sub_arr, target)\n else\n sub_arr = array[mid_idx + 1..-1]\n next_search = bsearch(sub_arr, target)\n return nil if next_search == nil\n return mid_idx + 1 + next_search\n end\nend", "def binary_search(array, value, lower = 0, upper = nil)\n upper = array.count - 1 unless upper\n\n return \"Not in array\" if lower > upper\n\n mid = (lower + upper) / 2\n\n if value < array[mid]\n return binary_search(array, value, lower, mid - 1)\n elsif value > array[mid]\n return binary_search(array, value, mid + 1, upper)\n else\n return mid\n end\nend", "def bin_search(d, arr)\n middle = arr.length / 2\n i = 0\n j = arr.length - 1\n \n while i < j\n if arr[middle] == d\n return true\n elsif arr[middle] < d\n i = middle + 1\n middle = i + j / 2\n else\n j = middle - 1\n middle = i + j / 2\n end\n end\n return false\nend", "def binary_search(arr, ele)\n min = 0;\n max = arr.size - 1;\n\n while min <= max \n \n middle = ( (min + max) / 2).floor\n \n if ele == arr[middle]\n return middle\n elsif ele < arr[middle]\n max = middle - 1\n elsif ele > arr[middle]\n min = middle + 1\n end\n\n end\n\n return -1 \nend", "def bsearch(array, target)\n mid_idx = array.length / 2\n if array[mid_idx] == target\n mid_idx\n elsif array.length == 1\n nil\n elsif array[mid_idx] > target\n bsearch(array[0...mid_idx], target)\n elsif array[mid_idx] < target\n after_mid_idx = mid_idx + 1\n recursion = bsearch(array[after_mid_idx..-1], target)\n recursion.nil? ? nil : after_mid_idx + recursion\n end\nend", "def search(nums, target)\n return -1 if nums.length == 0\n\n left = 0\n right = nums.length\n\n while left < right\n mid = (left + right) / 2\n if nums[mid] == target\n return mid\n elsif nums[mid] < target\n left = mid + 1\n else\n right = mid\n end\n end\n\n # Post-processing:\n # End Condition: left == right\n if (left != nums.length) && (nums[left] == target)\n left\n else\n -1\n end\nend", "def binary_search(arr, item)\n #assign parts of the array by beginning and end\n\n #Envoy of the beginning\n left = 0\n #Envoy of the End\n right = arr.length - 1\n\n # while the item is not found\n # (since you are converging from the changing range, high to low)\n while left <= right\n #set a mid point to be used in the middle of any range created by high & low\n mid = (left + right) / 2\n\n if arr[mid] == item\n return mid\n end\n\n if arr[mid] > item\n right = mid - 1\n else\n left = mid + 1\n end\n end\n\n return nil\n\nend", "def binary_search(numbers, element)\n min = 0\n max = numbers.size - 1\n\n index = nil\n\n while index.nil? do\n middle_element_index = (min + max) / 2 # Every iteration (N / 2) = O(log n)\n middle_element = numbers[middle_element_index] \n \n if element < middle_element\n max = middle_element_index\n elsif element > middle_element\n min = middle_element_index\n elsif element == middle_element\n index = middle_element_index\n end\n end\n\n index\nend", "def binary_search(array, value)\n low = 0\n high = array.length - 1\n\n while ( low <= high )\n mid = low + ( (high-low)/2 )\n\n if array[mid] == value\n return mid\n elsif array[mid] < value\n low = mid + 1\n else\n high = mid - 1\n end\n end\n\n return \"Value not found\"\nend", "def bsearch(arr, target)\n return nil if arr.empty?\n mid_idx = arr.length / 2\n pivot = arr[mid_idx]\n return mid_idx if pivot == target\n if pivot > target\n bsearch(arr[0...mid_idx], target)\n else\n result = bsearch(arr[mid_idx + 1..-1], target)\n if result == nil\n nil\n else\n mid_idx + 1 + result\n end\n end\nend", "def binary_search(input)\n midpoint = input.length/2\n mid_minus_one = midpoint - 1\n\n if input[0] < input[-1] || input.length <= 1\n return input[0]\n\n elsif input[midpoint] < input[mid_minus_one]\n return input[midpoint]\n\n # if value at midpoint is less than value at end of array, then the\n # rotation point is on left side\n elsif input[midpoint] < input[-1]\n # call binary_search with left 1/2 of array\n binary_search(input[0..midpoint])\n\n # rotation point is on right side\n elsif input[midpoint] > input[-1]\n # call binary_search with right 1/2 of array\n binary_search(input[midpoint..-1])\n end\n\nend", "def search(arr, target)\n left = 0\n right = arr.length - 1\n\n while left <= right\n mid = (left + right ) / 2\n\n return mid if arr[mid] == target\n\n if arr[mid] < target\n left = mid + 1\n else\n right = mid - 1\n end\n end\n\n return -1\nend", "def binary_search(elem, field=nil, low=0, high=self.length-1)\n mid = low+((high-low)/2).to_i\n if low > high \n return -(low + 1)\n end\n mid_elt = (field.nil?) ? self[mid] : self[mid].send(field)\n if elem < mid_elt\n return binary_search(elem, field, low, mid-1)\n elsif elem > mid_elt\n return binary_search(elem, field, mid+1, high)\n else\n return mid\n end\n end", "def bsearch(array, target)\n # compare target value to middle element\n #if target value is == to middle elements value\n #return the position and end\n # if target value is less than middle value seach lower half of array\n # same goes for greater than (search upper half)\n # when it searches lower or upper half it keeps the same logic as the beginning\n # nil if not found; can't find anything in an empty array\n return nil if array.empty?\n\n index = array.length / 2\n # spaceship operator magic!\n case target <=> array[index]\n when -1 #search left side\n bsearch(array.take(index), target)\n when 0\n index\n when 1 #search right side\n answer = bsearch(array.drop(index + 1), target)\n answer.nil? ? nil : index + 1 + answer\n end\nend", "def bsearch(array, value)\n return nil if array.empty?\n # return nil if !array.include?(value)\n\n # debugger\n indeces = array.dup.freeze #[1, 2, 3]\n \n middle = (array.length) / 2\n left = array[(0...middle)]\n right = array[(middle..-1)]\n\n # debugger\n if array[middle] == value\n return indeces.index(value) \n elsif value < array[middle]\n bsearch(left, value)\n else\n middle + bsearch(right, value)\n end\n #somewhere bsearch(array[(0..-2)]\nend", "def ubiquitous_binary_search(a,key) # a is the array and key is the value we want to search\n lo= 0\n hi = a.length-1\n \n while(hi-lo>1)\n mid = lo + (hi-lo)/2\n \n if a[mid]<=key\n lo=mid\n else\n hi=mid\n end\n end\n \n if (a[lo]== key)\n return lo\n elsif (a[hi]== key)\n return hi\n else\n return \"value not found\"\n end\nend", "def binsearch_index(low = nil, high = nil) \n return nil if length == 0\n low = 0 if !low\n high = length if !high\n\n if low == high\n if yield at(low)\n return low\n else\n return nil\n end\n end\n\n mid = (high-low)/2 + low\n if yield at(mid)\n # this value >= target.\n result = binsearch_index(low, mid == low ? mid : mid-1){ |x| yield x if !x.nil?}\n if result\n return result\n else\n return mid\n end\n else\n # this value < target\n binsearch_index(mid == high ? mid : mid+1, high){ |x| yield x if !x.nil?}\n end\n end", "def binarysearch(v, key)\n\tlow = 0\n\thigh = v.length - 1\n\twhile low <= high\n\t\tmid = (low + high) / 2\n\t\t#was having trouble with if/else so went with case statement\n\t\tcase\n\t\t\twhen (v[mid] < key) \n low = mid + 1\n\t\t\twhen (v[mid] > key) \n\t\t\t\thigh = mid - 1\n\t\t\telse \n\t\t\t\treturn mid\n\t\tend\n\tend\n\t-1\t#if key not found\nend", "def binary_search(key)\n return binsearch(0, self.length - 1, key)\n end", "def bsearch(array, target)\n mid_point = array.length / 2\n\n return mid_point if target == array[mid_point]\n return nil if array.length == 1\n\n left_hand = array[0...mid_point]\n right_hand = array[mid_point..-1]\n\n if target < array[mid_point]\n bsearch(left_hand, target)\n else\n result = bsearch(right_hand, target)\n return nil if result.nil?\n mid_point + result\n end\n\nend", "def use_binary_search(list, item)\r\n low = 0\r\n high = list.length - 1\r\n while low <= high\r\n mid = (low + high)\r\n guess = list[mid]\r\n if guess == item\r\n return mid\r\n end\r\n if guess > item\r\n high = mid - 1\r\n else\r\n low = mid + 1\r\n end\r\n end\r\n return nil\r\nend", "def binary_search(value)\n search_result = binary_search_internal(value)\n return search_result[0] ? search_result[1] : -1\n end", "def binary_search(haystack, needle)\n size = haystack.size\n midpoint = (size / 2.0).round\n # case\n # when value > needle then binary_search(haystack[0...(midpoint-1)], needle)\n # when value < needle then binary_search(haystack[(midpoint+1)..size], needle)\n # else midpoint\n # end\n return nil if haystack[midpoint].nil?\n if haystack[midpoint] > needle\n binary_search(haystack[0...(midpoint-1)], needle)\n elsif haystack[midpoint] < needle\n binary_search(haystack[(midpoint+1)..size], needle)\n else\n return midpoint\n end\nend", "def bsearch(array, target)\n return nil if array.length == 1 && target != array[0]\n idx = array.length / 2\n mid_ele = array[idx]\n\n if target == mid_ele\n return idx\n elsif target < mid_ele\n return bsearch(array[0...idx], target)\n else\n if bsearch(array[idx+1..-1], target).nil?\n return nil\n else\n return idx + 1 + bsearch(array[idx+1..-1], target)\n end\n end\nend", "def binary_search(arr, target)\n\n floor = -1\n ceiling = arr.length\n\n while floor + 1 < ceiling # Has to be plus one or else it will keep looping. NB: Guess index always rounds down.\n\n guess_index = (floor + ceiling)/2\n # puts \"Guess_index\", guess_index\n guess_value = arr[guess_index]\n\n if guess_value == target\n return true\n elsif guess_value < target\n floor = guess_index\n else\n ceiling = guess_index\n end\n\n end\n\n return false\n\nend", "def bsearch(array, target)\n return nil if array.empty?\n\n n = array.size / 2\n bottom = array[0...n]\n mid = array[n]\n top = array[n + 1..-1]\n\n if target < mid\n bsearch(bottom, target)\n elsif target > mid\n top_search = bsearch(top, target)\n top_search.nil? ? nil : top_search + bottom.size + 1\n else\n mid == target ? n : nil\n end\nend", "def bsearch(arr,target)\n# p arr\nreturn nil if arr.length==1 && target != arr[0]\nmid =arr.length/2 # 3,1,1,0\n# if arr.length==1 && arr[0] != target\n# return nil\n# end\n\n\nif target==arr[mid]\n\nreturn mid\nelsif target<arr[mid]\n left_index = 0\n right_index = mid-1\n return bsearch(arr[left_index..right_index],target)\n# return bsearch(arr.take(mid),target)\nelse\n left_index = mid+1\n right_index = arr.length-1\n sub_position=bsearch(arr[left_index..right_index],target)\n # sub_position=bsearch(arr.drop(mid+1),target)\n return sub_position.nil? ? nil : (mid+1)+sub_position \n\nend\nend" ]
[ "0.8074286", "0.79244035", "0.7866262", "0.7840983", "0.78335905", "0.78310955", "0.78063136", "0.7773762", "0.77485484", "0.77258575", "0.7720127", "0.7709612", "0.77026045", "0.77022976", "0.769793", "0.7696042", "0.76854426", "0.76706547", "0.7667535", "0.76500267", "0.76350236", "0.7625425", "0.76234365", "0.76212907", "0.76191735", "0.76187325", "0.7615205", "0.76145285", "0.7612039", "0.76094455", "0.76075375", "0.75996286", "0.7597183", "0.75947446", "0.7593363", "0.75815755", "0.7579254", "0.7579185", "0.7575627", "0.7569317", "0.7569317", "0.7563822", "0.75558233", "0.7555315", "0.7554823", "0.7551339", "0.7551194", "0.7545292", "0.75396866", "0.7532053", "0.7520948", "0.75147915", "0.75061196", "0.75047433", "0.7493233", "0.7491729", "0.74765974", "0.7476017", "0.7474349", "0.7474064", "0.7473998", "0.7465565", "0.7459765", "0.74494386", "0.7446112", "0.7440617", "0.74355024", "0.742283", "0.7415762", "0.7413832", "0.74133575", "0.74105597", "0.74104726", "0.74018824", "0.7400438", "0.73910207", "0.7381763", "0.73765135", "0.73713833", "0.7369035", "0.73644257", "0.7353122", "0.73506725", "0.73494065", "0.7346212", "0.734309", "0.73425776", "0.73397654", "0.733776", "0.7335473", "0.7334373", "0.7333754", "0.73200214", "0.7317277", "0.7316561", "0.7313012", "0.7311845", "0.7306918", "0.73066497", "0.7302485", "0.7288169" ]
0.0
-1
USER METHODS Follow a user by id
def follow(other_user_id) user_to_follow = User.find_by(id: other_user_id) followee_followerships.create(followee_id: user_to_follow.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follow\n who = User.find(params[:id])\n @current_user.follow(who)\n render :text => \"you are now following #{who.username}\"\n end", "def follow\n current_user.follow_user(@user)\n render json: {ok: 1}\n end", "def follow \n @user = User.find_by_id(params[:id])\n if @user and current_user.follow(@user)\n flash[:notice] = \"You are now following #{@user.login}\"\n redirect_to home_path()\n elsif @user\n flash[:notice] = \"Already following\"\n redirect_to user_path(@user.login)\n else\n redirect_to home_path()\n end\n end", "def follow_user\n user = User.find(params[:user_id])\n authorize! :follow, user\n current_user.follow(user)\n render_success_message(\"You are following #{user.full_name(false)}\")\n end", "def user_follows \n if user_signed_in?\n Rails.logger.debug { \"The user to be followed is #{params[:id]}\" }\n user = User.find(id: params[:id])\n user.follows << current_user\n end\n end", "def follow\n userToFollow = User.find_by_id(params[:id])\n begin\n if userToFollow\n @currentUser.follow_user(userToFollow)\n flash[:notice] = \"#{userToFollow} followed successfully\"\n end\n rescue Exception => e\n flash[:notice] = e.message\n end\n redirect_to(session[:last_page])\n end", "def follow(user_id)\n follower.create(followed_id: user_id)\n end", "def follow(user_id)\n if self.id != user_id && active_follow.find_by(following_id: user_id) == nil\n active_follow.create!(following_id: user_id)\n end\n end", "def add_follower\n if (@user = find(User, params[:user_id])).is_a?(User)\n current_user.follow(@user)\n redirect_to @user, notice: \"Now you are following #{@user.username}!, and you can read his personal articles and comments!\"\n end\n end", "def follow_user(user)\n return @mouth.follow(user)\n end", "def follow(user)\n user.add_follower(self)\n self\n end", "def follow(user)\n user.followers << self\n self\n end", "def follow(user)\n user.followers << self\n end", "def follow\n follow = User.where(:username => params[:id]).first\n @current_user.friends << follow\n redirect_to user_path( follow.username )\n end", "def follow(user)\n self.following << user\n ActionLog.log_other(self.id, \"follow\", user) \n end", "def follow_user\n\t\tauthenticate_current_user\n\t\t# add the current user to the user they followed list of followers\n\t\tUser.find(params.user_id).followers.push(User.find(current_user.id))\n\t\t# run the following action to return the updated group of followers\n\t\tfollowing\n\tend", "def follow(user)\n user.add_follower(self)\n self\n end", "def follow(user_id)\n followee_relationships.create(followee_id: user_id)\n end", "def follow(user)\n\t self[:following].push(user.id)\n\t\tself.save\n end", "def follow\n if (!current_user.friends.exists?(params[:id]))\n fs = Friendship.new(user_id: current_user.id, friend_id: params[:id])\n if fs.save\n redirect_to user_url(params[:id]), notice: \"Now you can read this user's posts in your friends feed.\"\n else\n flash.alert = \"Something went wrong. You cannot follow this user.\"\n redirect_to user_url(params[:id])\n end\n end\n end", "def follow(user_a,user_b)\n\t\t#This method deletes the follow relationship in the database\n\t\tuser_a.follow(user_b)\n\n\t\tif REDIS.exists(user_a.handle+\"_relations\")\n\t\t\tREDIS.sadd(user_a.handle+\"_relations\", params[:userid])\n\t\tend\n\t\tif REDIS.exists(user_a.handle+\"_num_following\")\n\t\t\tREDIS.incr(user_a.handle+\"_num_following\")\n\t\tend\n\t\tif REDIS.exists(user_b.handle+\"_num_followers\")\n\t\t\tREDIS.incr(user_b.handle+\"_num_followers\")\n\t\tend\n\tend", "def set_follow\n @user_auth = auth_user\n @user_followed = User.find(params[:follow_user_id])\n end", "def follow\n if current_user\n update_and_decorate # Generate a FeedEntryDecorator as @feed_entry and prepares it for editing\n if current_user.follows? @user\n current_user_or_guest.followees.delete @user\n msg = \"You've just been unplugged from'#{@user.handle}'.\"\n else\n current_user_or_guest.followees << @user\n msg = \"You're now connected with '#{@user.handle}'.\"\n end\n current_user.save\n @user.save\n if post_resource_errors(current_user)\n render :errors\n else\n flash[:popup] = msg\n render :follow\n end\n else\n flash[:alert] = \"Sorry, you need to be logged in to follow someone.\"\n render :errors\n end\n end", "def followUser(userToFollow)\n @followers << userToFollow\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow_steve\n return if username == \"steve\"\n steve = User.first(:username => 'steve')\n return if steve.nil?\n\n follow! steve\n steve.follow! self\n end", "def follow\n Following.find_or_create_by_follower_id_and_followed_id(current_user.id, params[:user_id])\n @user_id = params[:user_id]\n @followed = true\n render \"shared/follow\"\n end", "def follow(other_user)\n following << other_user\n end", "def following\n if current_user \n params[ :type ] = \"following\" if params[ :type ] .nil?\n @result = User.set_relation( params[ :id ] , current_user , params[ :type ] )\n render :layout => false\n else\n render \"misc/need_authentication\"\n end\n end", "def follow(other_user)\n active_follows.create(followed_id: other_user.id)\n end", "def follow(user)\n Friend.add_follower(self, user)\n end", "def user_follows user_id, pages: 1\n url = API + \"users/#{user_id}/follows?access_token=\" + @access_token\n pages.times do\n get(url)['data'].map do |user|\n @user_ids << user['id']\n end\n url = get(url)['pagination']['next_url']\n end\n export(@user_id_list, @user_ids)\n end", "def follow\r\n \r\n @followu = FollowUser.where(user_id: @u_id)\r\n @followt = FollowThread.where(user_id: @u_id)\r\n end", "def follow\n user = User.find(params[:user_id])\n @follow = current_user.follow(user)\n render json: @follow\n end", "def follow(user_id, followee_id)\n @follows[user_id] = { user_id => 1 } unless @follows.key?(user_id)\n @follows[user_id][followee_id] = 1\n end", "def follow!(user)\n relationships.create!(:followed_id => user.id)\n end", "def follow\n\n end", "def follow(user)\n active_relationships.create(followed_id: user.id)\n end", "def follow(user)\n active_follows.create(followed_id: user.id)\n \n end", "def set_user_follow\n @user_follow = UserFollow.find(params[:id])\n end", "def follow!(user)\n\t\tfollowed << user \n\tend", "def follow!(user)\n\t\tfollowed << user\n\tend", "def follow!(other_user)\n relationships.create!(followed_id: other_user.id)\n end", "def follow!(other_user)\n relationships.create!(followed_id: other_user.id)\n end", "def follow!(other_user)\n relationships.create!(followed_id: other_user.id)\n end", "def follow!(other_user)\n relationships.create!(followed_id: other_user.id)\n end", "def follow!(other_user)\n relationships.create!(followed_id: other_user.id)\n end", "def follow(user)\n\tout_followings.create(to_id: user.id)\nend", "def create\n\n user = User.find(params[:followed_id])\n @current_user.follow(user)\n redirect_to user\n\n\n # PATCH/PUT /relationships/1\n # PATCH/PUT /relationships/1.json\n def update\n\n end\n\n # DELETE /relationships/1\n # DELETE /relationships/1.json\n def destroy\n user = Relationship.find(params[:id]).followed\n @current_user.unfollow(user)\n redirect_to user\n end\n end", "def seguir\n\n @profile = User.find(params[:id])\n if current_user.following?(@profile)\n current_user.stop_following(@profile)\n else\n current_user.follow(@profile)\n end\n redirect_to @profile\n end", "def follow!(other_user)\n relationships.create(followed_id: other_user.id)\n end", "def follow_user\n output = ''\n if params[:user_id].present?\n x = Notification.add_follow_user(current_user.id, params[:user_id])\n if x\n output = 'success!'\n else\n output = \"error: #{x.errors.full_message}\"\n end\n else\n output = 'please provide a user to follow'\n end\n\n respond_to do |format|\n format.json { render json: output.to_json }\n end\n end", "def follow!(other_user)\n relationships.create!(followed_id: other_user.id)\n end", "def following(user_id = nil)\n twitter_request do\n logger.info \"Get following of #{user_id || 'me'}\"\n client.friend_ids(user_id).take(5000)\n end\n end", "def follow!(other_user)\n\t\trelationships.create!(followed_id: other_user.id)\n\tend", "def follow!(other_user)\n\t\t# same as user.relationships.create or self.relationships.create\n\t\trelationships.create!(followed_id: other_user.id)\n\tend", "def follow(other_user)\n active_relationships.create(following_id: other_user.id)\n end", "def follow(other_user)\n\t\tactive_relationships.create(followed_id: other_user.id)\n\tend", "def both_follow(id)\n $redis.sinter(\"#{key}:friends\", \"User:#{id}:friends\")\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end", "def follow (other_user)\n active_relationships.create(followed_id: other_user.id)\nend", "def follows_given(user_id)\n follows = Follow.where(user_id: user_id)\n end", "def following\n @following||= get(\"/user/show/#{login}/following\")['users'].map { |u| User.new(connection, :login => u) }\n end", "def following(id)\n perform_request_with_collection(:get,\n \"/api/v1/accounts/#{id}/following\",\n {}, Mastodon::Account)\n end", "def follow\n \n # Get the specified user, making sure that it exists\n @user = User.find_by_login(params[:user_login])\n \n # Create and save a new follow, with the current user as the follower\n follow = Follow.new\n follow.follower_id = current_user.id\n follow.followee_id = @user.id\n follow.save!\n \n # Send an email to the user being followed\n UserMailer.deliver_follow(current_user, @user)\n \n # Redirect back to the profile of the user being followed\n flash[:notice] = \"You are now following #{@user.login}.\"\n redirect_to user_profile_url(:user_login => @user.login)\n end", "def follow(user_id, follow_status)\n following_relationships.create(following_id: user_id, follow_status: follow_status)\n end", "def follow(user_id, follow_status)\n following_relationships.create(following_id: user_id, follow_status: follow_status)\n end", "def user_followers(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:get, \"users/#{id}/followers\", params)\n end", "def follow!(other_user)\n self.relationships.create!(followed_id: other_user.id)\n self.update_attribute(:followings_num, self.followings_num + 1)\n other_user.update_attribute(:followers_num, other_user.followers_num + 1)\n end", "def follow(other_user)\n follow_down.create(following_id: other_user.id)\n end", "def followed\n\t\t@user = User.find(params[:id])\n\t\tcurrent_user.create_rel(\"FOLLOWING\", @user) \n\t\tif request.xhr?\n\t\t\trender json: { count: @user.following.count, id: @user.id }\n\t\telse\n\t\t\tredirect_to @user\n\t\tend\n\n\tend", "def follow_user_link followed_user\n return if followed_user == current_user\n\n if current_user.followed_user_ids.include?(followed_user.id)\n internal_unfollow_user_link(followed_user)\n else\n internal_follow_user_link(followed_user)\n end\n end", "def follow_user(user)\n # Ternary to prevent duplicates\n following?(user) ? following : following << user\n end", "def follow!(user)\n followings.find_or_create_by!(following_id: user.id)\n end", "def follow\n check_user_id_is_present\n\n user = User.find_by_id(params[:user_id])\n\n if params[:movie].present?\n movie = Movie.find_by_title(params[:movie])\n\n if user.movies.include? movie\n render json: { response: 'Already followed' }, status: :ok\n end\n\n user.movies << movie\n elsif params[:genre].present?\n genre = Genre.find_by_name(params[:genre])\n\n if genre.nil?\n render json: { response: 'Genre not found' }, status: :not_found\n end\n\n user.genres << genre\n elsif params[:star].present?\n star = Star.find_by_name(params[:star])\n\n if star.nil?\n render json: { response: 'Movie not found' }, status: :bad_request\n end\n\n star.users << user\n end\n\n render json: { response: 'Done' }, status: :ok\n end", "def run_callbacks\n user = @user_repository.find_or_create(@to_user_id)\n user.add_follower(@from_user_id)\n end", "def follow(other_user)\n following_relationships.create(followed_id: other_user.id)\n end", "def follow(followee_handle)\n HTTParty.post(\"#{@api_path}/users/follow/#{@handle}/#{@password}/#{followee_handle}\")\n end", "def follow!(other_user)\n\t\tself.relationships.create! followed_id: other_user.id, follower_id: self.id\n\tend", "def next_user\n redirect_to_next_object(:next, User, params[:id].to_s)\n end", "def follow(foo_user)\n active_relationships.create(followed_id: foo_user.id)\n end", "def next_user # :norobots:\n redirect_to_next_object(:next, User, params[:id].to_s)\n end", "def set_user_following\n @user_following = UserFollowing.find(params[:id])\n end", "def set_follower\n @follower = Follower.where('user_id=?', params[:rooster_id]).where('follower_id=?', params[:id])[0]\n @user = User.find(params[:rooster_id])\n end", "def add_follower_to_deal(id:, **args)\n params = parameters(args) do\n required_params :user_id\n optional_params :user_id\n end\n request(:post, \"deals/#{id}/followers\", params)\n end", "def follow(other_user)\n following << other_user unless self == other_user\n end", "def follow(*user_ids)\n query_params = user_ids.pop if user_ids.last.is_a?(::Hash)\n query_params ||= {}\n filter(query_params.merge(:follow => user_ids))\n end" ]
[ "0.7668381", "0.75081784", "0.7464432", "0.74639857", "0.7438839", "0.7399948", "0.7358199", "0.7355392", "0.73367906", "0.730492", "0.7291635", "0.7261809", "0.72572756", "0.72493", "0.7204702", "0.71847063", "0.71781725", "0.71346617", "0.7091446", "0.70668876", "0.7054419", "0.70192444", "0.7018447", "0.7004496", "0.69853246", "0.69853246", "0.69853246", "0.69853246", "0.69853246", "0.69853246", "0.69706345", "0.69467163", "0.6932666", "0.69277585", "0.6907849", "0.6905717", "0.6902714", "0.69009835", "0.6900607", "0.6868569", "0.6867115", "0.68625736", "0.68549925", "0.6849253", "0.6845261", "0.6840883", "0.68386364", "0.6829415", "0.6829415", "0.6829415", "0.6829415", "0.6829415", "0.6827098", "0.68191886", "0.68149567", "0.681266", "0.6811186", "0.68099034", "0.68087554", "0.6793459", "0.67925847", "0.6788326", "0.6760536", "0.67496556", "0.6735713", "0.6735713", "0.6735713", "0.6735713", "0.6735713", "0.6735713", "0.6735713", "0.6735713", "0.6735713", "0.67238986", "0.67235214", "0.6709603", "0.67085576", "0.6705751", "0.6701025", "0.66994166", "0.6683938", "0.6682557", "0.6671957", "0.66454893", "0.6643172", "0.66402346", "0.66329277", "0.66285425", "0.66266537", "0.66245383", "0.66231203", "0.66009593", "0.6599393", "0.6589781", "0.65707546", "0.65653294", "0.65496755", "0.6547603", "0.6531687", "0.6528522" ]
0.727207
11
Unfollow a user by id
def unfollow(other_user_id) user_to_unfollow = User.find_by(id: other_user_id) active_relationships.find_by(followed_id: user_to_unfollow.id).destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unfollow\n current_user.unfollow_user(@user)\n render json: {ok: 1}\n end", "def unfollow(user)\n user.followers.delete(self)\n end", "def unfollow_user\n user = User.find(params[:user_id])\n current_user.unfollow(user)\n render_success_message(\"You are not anymore following #{user.full_name(false)}\")\n end", "def unfollow_user(user)\n following.delete(user)\n end", "def unfollow\n unfollow = User.where(:username => params[:id]).first\n relationship = @current_user.followers.where( :friend_id => unfollow.id ).first\n relationship.destroy\n redirect_to user_path( unfollow.username )\n end", "def unfollow\n @user = User.find_by_id(params[:id])\n if @user and current_user.unfollow(@user)\n flash[:notice] = \"You are no longer following #{@user.login} :(\"\n redirect_to home_path()\n elsif @user\n flash[:notice] = \"You aren't following #{@user.login}\"\n redirect_to user_path(@user.login)\n else\n redirect_to home_path()\n end\n end", "def unfollow(user)\n self.following.delete(user)\n end", "def user_unfollows\n if user_signed_in?\n Rails.logger.debug { \"The user to be unfollowed is #{params[:id]}\" }\n user = User.find(id: params[:id])\n user.follows.delete(current_user)\n end\n \n end", "def unfollow!(user)\n relationships.find_by_followed_id(user).destroy\n end", "def unfollow_user\n\t\tauthenticate_current_user\n\t\t# destroy the current user from that user's followers\n\t\tUser.find(params.user_id).followers.destroy(User.find(current_user.id))\n\t\t# run the following action to return the updated group of followers\n\t\tfollowing\n\tend", "def unfollow\n fs = Friendship.where(user_id: current_user, friend_id: params[:id]).first\n if fs\n fs.destroy\n redirect_to user_url(params[:id]), notice: \"This user was removed from your list of friends.\"\n else\n flash.alert = \"Something went wrong. You weren't following that user.\"\n redirect_to users_url\n end\n end", "def unfollow!(user)\n followings.find_by(following_id: user.id)&.destroy!\n end", "def unfollow(other_user)\n active_follows.find_by(followed_id: other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end", "def unfollow(other_user)\n following.delete(other_user)\n end", "def unfollow(other_user)\n following.delete(other_user)\n end", "def unfollow(other_user)\n following.delete(other_user)\n end", "def unfollow(other_user)\n following.delete(other_user)\n end", "def unfollow!(other_user)\n relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow!(other_user)\n relationships.find_by(followed_id: other_user.id).destroy!\n end", "def unfollow! followee\n following_ids.delete(followee.id)\n save\n followee.followers_ids.delete(id)\n followee.save\n end", "def unfollow(other_user)\n \tactive_relationships.find_by(followed_id: other_user.id).destroy\n \tend", "def unfollow(user_id, followee_id)\n @follows[user_id] = { user_id => 1 } unless @follows.key?(user_id)\n @follows[user_id][followee_id] = nil\n end", "def unfollow_user\n\t\t# determine who is following who\n\t @follower = current_user\n @following = User.find_by_login(params[:username])\n @user = @following\n\n\t\t# if follower was self, unknown\n if @follower.id == @following.id\n gflash :error => \"Unknown request!\"\n redirect_back_or_default('/')\n end\n\n\t\t# see if user is being followed \t\n exist = Follow.find(:first, :conditions => {:follower_id => @follower.id, :following_id => @following.id})\n if exist\n\t\t\t# if he is, erase from database\n exist.destroy\n\t\t\t# show pop up regarding unfollow success\n gflash :success => \"You are no longer following #{@following.login}!\"\n else\n gflash :error => \"You are already not following #{@following.login}!\"\n end\n redirect_to :action => 'profile', :username => @following.login\n end", "def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow!(other_user)\n\t\tself.relationships.find_by_followed_id(other_user.id).destroy\n\tend", "def unfollow\n \n # Get the specified user, making sure that it exists\n @user = User.find_by_login(params[:user_login])\n \n # Find the follow relationship between the current user and the specified\n # user\n @follow = Follow.find(:first, :conditions => \"follower_id = #{current_user.id} and followee_id = #{@user.id}\")\n \n # Destroy the follow relationship\n @follow.destroy\n current_user.save!\n \n # Redirect back to the profile of the user that was being followed\n flash[:notice] = \"You are no longer following #{@user.login}.\"\n redirect_to user_profile_url(:user_login => @user.login)\n end", "def unfollow! followee\n return if !following? followee\n following_ids.delete(followee.id)\n save\n followee.followers_ids.delete(id)\n followee.save\n end", "def unfollow\n @user = User.find(params[:follow_id])\n\n current_user.following.delete(params[:follow_id].to_i)\n @user.followers.delete(current_user.id)\n\n current_user.save\n @user.save\n \n if current_user.save\n flash[:success] = \"You are no longer following #{@user.username}!\"\n redirect_to root_path\n else\n flash[:error] = \"Something went wrong.\"\n end\n #show_followers\n end", "def destroy\n @user = User.find(params[:id])\n if @user\n current_user.unfollow(@user)\n flash[:notice] = \"Unfollow #{@user.username}\"\n else\n flash[:notice] = 'Something happens please try again'\n end\n redirect_to request.referer\n end", "def unfollow(other_user)\n following_relationships.find_by(followed_id: other_user.id).destroy\n end", "def unfollow(other_user)\n\t\tactive_relationships.find_by(followed_id: other_user.id).destroy\n\tend", "def unfollow\n user_id = params[:id]\n following_user_id = (params[:following_user_id] || params[:connected_user_id])\n\n if (user_id.present? and following_user_id.present?)\n user = User.find_by_id(user_id)\n following_user = User.find_by_id(following_user_id)\n\n if (!user.nil? and !following_user.nil?)\n if !user.follows.exists?(following_user)\n message = t('user.unfollow.messages.already_not_following', {following_user_name: following_user.name})\n else\n followed_following_obj = user.unfollow(following_user_id)\n if followed_following_obj.nil?\n message = t('user.unfollow.messages.failure', { following_user_name: following_user.name })\n else\n message = t('user.unfollow.messages.success', { following_user_name: following_user.name })\n end\n end\n else\n message = t('user.unfollow.errors.no_user_found', { user_id: user_id, following_user_id: following_user_id })\n end\n else\n message = t('user.unfollow.errors.could_not_process_unfollow')\n end\n\n redirect_to :back, flash: { notice: message }\n end", "def unfollow\n if @user_auth.nil?\n raise ActionController::MethodNotAllowed, 'Vous n\\'êtes pas connecté'\n elsif @user_auth.id != @user_followed.id\n follow = Follow.find_by(follower_user_id: @user_auth.id, followed_user_id:@user_followed.id)\n if follow.destroy\n redirect_back fallback_location: '/', notice: \"Vous ne suivez plus #{@user_followed.name}\"\n else\n redirect_back fallback_location: '/', error: \"Impossible de follow l'utilisateur\"\n end\n else\n redirect_back fallback_location: '/', error: 'Vous ne pouvez pas vous auto unfollow'\n end\n end", "def unfollow\n @user = User.friendly.find(params[:user_id])\n\n @follow = Follow.find_by followable_id: @user.id, follower_id: current_user.id\n @follow.status = 2\n \n if @follow.save\n render :json => {:success => true}\n else \n render :json => {:success => false}\n end\n end", "def unfollow_user(follower, following)\n User.where(handle: follower).first.pull(:following, following)\n end", "def unfollow(user)\n following = out_followings.find_by(to_id: user.id)\n if following\n following.destroy\n true\n else\n false\n end\n end", "def unfollow\n userToUnFollow = User.find_by_id(params[:id])\n begin\n if userToUnFollow\n @currentUser.unfollow_user(userToUnFollow)\n flash[:notice] = \"#{userToUnFollow} unfollowed successfully\"\n end\n rescue Exception => e\n flash[:notice] = e.message\n end\n #Do not want to display a blank search page to the user - head to the user index\n if session[:last_page] == search_path\n redirect_to(:action => \"index\")\n else\n redirect_to(session[:last_page])\n end\n end", "def unfollow!(followed)\n relationships.find_by_followed_id(followed).destroy\n end", "def unfollow!(followed)\n relationships.find_by_followed_id(followed).destroy\n end", "def delete_follower\n if (@user = find(User, params[:user_id])).is_a?(User)\n current_user.unfollow(@user)\n redirect_to @user, notice: \"You are not following #{@user.username} anymore!\"\n end\n end", "def unfollow\n requested_profile.unfollow!(requested_follow_profile)\n redirect_to :action => 'following', :profile_id => current_user.profile\n end", "def unfollow\n user = User.find(params[:user_id])\n @unfollow = current_user.stop_following(user)\n render json: @unfollow\n end", "def destroy\n user = Relationship.find(params[:id]).followed\n @current_user.unfollow(user)\n redirect_to user\n end", "def unfollow_user(follow_user)\n #before we can destroy the link we must check if the user is already not following the other user\n #or if the user is trying to unfollow themself.\n #if the user can follow the other user then that means no relationship exists\n if can_follow?(follow_user)\n raise \"Can't unfollow yourself or a user that you are not already following!\"\n else\n followRel = Follow.find(:first, :conditions => {:user_id => self.id, :follow_user_id => follow_user.id})\n followRel.destroy\n end\n end", "def unfollow(unfollowed)\n if unfollowed.is_a? Array\n ids = unfollowed.map(&:id).join(',')\n type = unfollowed.first.type\n else\n ids = unfollowed.id\n type = unfollowed.type\n end\n\n url = if type == 'playlist'\n \"users/#{unfollowed.owner.id}/playlists/#{unfollowed.id}/followers\"\n else\n \"me/following?type=#{type}&ids=#{ids}\"\n end\n\n User.oauth_delete(@id, url)\n unfollowed\n end", "def unfollowed(other_user)\n passive_relationships.find_by(follower_id: other_user.id).try(:destroy) \n end", "def unfollow\n followable_uid = unsafe_params[\"followable_uid\"]\n fail \"Followable uid needs to be a non-empty string\" unless followable_uid.is_a?(String) && followable_uid != \"\"\n\n followable = item_from_uid(followable_uid)\n follower = @context.user\n if followable.accessible_by?(@context) && [\"discussion\"].include?(followable.klass)\n follower.stop_following(followable)\n render json: {\n followable_uid: followable_uid,\n follower_uid: follower.uid,\n follow_count: followable.followers_by_type_count(follower.class.name),\n }\n else\n fail \"You do not have permission to unfollow this object\"\n end\n end", "def unfollow(user_a, user_b)\n\t\t#This method deletes the follow relationship in the database\n\t\tuser_a.unfollow(user_b)\n\n\t\tif REDIS.exists(user_a.handle+\"_relations\")\n\t\t\tREDIS.srem(user_a.handle+\"_relations\", params[:userid])\n\t\tend\n\t\tif REDIS.exists(user_a.handle+\"_num_following\")\n\t\t\tREDIS.decr(user_a.handle+\"_num_following\")\n\t\tend\n\t\tif REDIS.exists(user_b.handle+\"_num_followers\")\n\t\t\tREDIS.decr(user_b.handle+\"_num_followers\")\n\t\tend\n\tend", "def unfollow\n\t\t@twitter = Twitter::Client.new(\n\t\t\t:oauth_token => @bot.tw_token,\n\t\t\t:oauth_token_secret => @bot.tw_secret\n\t\t)\n\n\t\t@tweet = Tweet.find(params[:tweet])\n\n\t\t@twitter.unfollow(@tweet.tw_usuario)\n\t\t@tweet.estado = 4\n\t\t@tweet.save\n\n\t\tmensaje = \"Dejo de seguir a \" + @tweet.tw_usuario\n\t\tredirect_to(bot_tweets_path(@bot), notice: mensaje)\n\tend", "def unfollow\n \t\n \t\t@fol = Follow.find_by_follower_and_followee(session[:id], params[:aid])\n \t\tif @fol == nil\n \t\t\tflash[:error] = \"wtf????\"\n \t\telse\n \t\t\t@sql = \"DELETE FROM follows WHERE follower = \"+@fol.follower.to_s+\" AND followee = \"+@fol.followee.to_s\n \t\tActiveRecord::Base.connection.execute(@sql)\n \t\t\n \t\t#if request.xhr?\n \t\t\trender 'accounts/unfollow'\n \t\t\t#else\n \t\t\t\t#redirect_to :controller => :main, :action => :searching\n \t\t\t#end\n \t\tend\n \t\t\n \t \t\n end", "def unfollow\n @twitter = Twitter::Client.new(\n :oauth_token => @bot.tw_token,\n :oauth_token_secret => @bot.tw_secret\n )\n\n @tweet = Tweet.find(params[:tweet])\n\n @twitter.unfollow(@tweet.tw_usuario)\n @tweet.estado = 4\n @tweet.save\n\n mensaje = \"Dejo de seguir a \" + @tweet.tw_usuario\n redirect_to(bot_tweets_path(@bot), notice: mensaje)\n end", "def unfollow(response)\n user_name = response.user.andand.name\n routing_key = response.match_data[1]\n unsubscribe(nil, user_name, routing_key)\n response.reply \"#{response.user.name}, no longer following '#{routing_key}'\"\n rescue Error => e\n log.error e.inspect\n log.error response.inspect\n response.reply \"#{response.user.name}, #{e} (routing_key: '#{routing_key}')\"\n end", "def unfollow\n user_to_unfollow = User.find(params[:id])\n followId = Follow\n .select(:id)\n .where(follower_id: current_user.id, followed_id: user_to_unfollow.id)\n current_user.unfollow(user_to_unfollow)\n render partial: 'api/follows/follow_data',\n locals: {\n follower: current_user,\n followed: user_to_unfollow,\n other: user_to_unfollow.follower_ids,\n followId: followId,\n current: current_user.following_ids\n }\n end", "def unfollow\n current_user.unfollow_topic(@topic)\n render json: {ok: 1}\n end", "def unfriend(id)\n post(\"users/#{id}/unfriend\").user\n end", "def unfollow\r\n @relationship = Relationship.where(follower_id: current_user.id, followed_id: params[:followed_id]).first\r\n @relationship.create_activity key: 'relationship.unfollow', owner: current_user, recipient: User.find(params[:followed_id]) \r\n @relationship.destroy\r\n render json: { message: \"Relationship destroyed successfully\" }\r\n end", "def unfollow\n @data = {:user_id => params[:follow_user_id] , :follow_user_id => current_user.id}\n status = UserFollower.unfollow(@data)\n render json: {:status => status} \n # render layout: \"homepage\"\n\n end", "def destroy\n response = current_user.unfollow_item(params[:id])\n redirect_to items_path\n end", "def unfriendship\n if params[:id]\n current_user.follow_ids.delete(params[:id])\n @user = User.find(params[:id]).del_follower(current_user)\n @user.save\n current_user.save\n end\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.js\n end\n end", "def remove\n begin\n followee = User.find(params[:id])\n rescue Exception => e\n flash[:error] = \"Couldn't find followee \"+params[:id].to_s\n end\n if current_user && followee\n current_user.followees.delete followee\n current_user.save\n flash[:notice] = \"There you go! No longer following \"+followee.handle\n else\n flash[:error] ||= \": No current user\"\n end\n redirect_to root_path\n end", "def unfollow\n return render_404 if params[:type].blank? or params[:id].blank? or params[:key].blank?\n email = Encoder.decode(params[:key])\n return render_404 if email.blank?\n\n Unfollower.create(:email => email, \n :unfollowerable_type => params[:type].capitalize, \n :unfollowerable_id => params[:id].to_i)\n \n render :text => \"你已经成功退定.\"\n end", "def unfollow_location(user_id, location_id)\n Following.find_by_sql(\"SELECT * FROM following f WHERE f.follower_id = ? AND f.location_id = ?\", user_id, location_id).destroy\n end", "def destroy\n @follow = Follow.where(follower_id: current_user.id, followed_id: params[:id]).first\n @follow.destroy\n redirect_to users_path, notice: 'You successfully unfollowed'\n end", "def ufu\r\n \r\n @follow = FollowUser.where(user_id: @u_id, second_user_id: params[:id])\r\n if @follow[0].destroy\r\n redirect_to follow_path\r\n end\r\n end", "def unfollow(other_person)\n active_relationships.find_by(followed_id: other_person.id).destroy\n end", "def remove_follower\n @user = User.friendly.find(params[:user_id])\n\n @follow = Follow.find_by followable_id: current_user.id, follower_id: @user.id\n @follow.status = 2\n\n if @follow.save\n render :json => {:success => true}\n else\n render :json => {:success => false}\n end\n end", "def unfollow\n current_profile.unfollow_profile(@profile)\n respond_to do |format|\n format.html { redirect_to profile_home_path(@profile.site_identifier) }\n format.json { head :no_content }\n end\n end", "def unfollow\n if request.post?\n @unf_ids = params[:unfollow]\n \n #unf_str = \"\"\n #unf_cnt = unf_ids.length - 1\n #for i in 0..unf_cnt\n # unf_str +=unf_ids[i].to_s\n # unf_str += \",\" unless unf_cnt == i\n #end\n if @unf_ids.nil? || @unf_ids.length < 1\n else\n @unf_ids.each do |unfo| \n hydra = Typhoeus::Hydra.new\n uri = \"http://api.twitter.com/1/friendships/destroy.json\"\n req = Typhoeus::Request.new(uri,\n :method =>\"post\",\n :params =>{:user_id=>unfo, :include_entities=>\"true\"})\n \n sign_request(req,uri)\n hydra.queue(req)\n hydra.run\n #puts req.response.inspect\n end\n end\n end\n respond_to do |format|\n format.js\n end\n end", "def unfollow(*followees)\n perform_followable_action(:unfollow, followees)\n end", "def delete_follower(user)\n followers.delete(user)\n end", "def unfollow_location(user_id, location_id)\n # need to cover case where we try to unfollow same location twice. Should be an if check for a nil return value, only\n # delete if user_id AND location_id are in the table\n @unfollow = Following.where(\"user_id = ? AND location_id = ?\", user_id, location_id)\n Following.destroy(@unfollow)\n end", "def destroy\n @user = User.find(params[:user_id])\n @follower = @user.follower.find(params[:id])\n @follower.destroy\n head :no_content\n end", "def unfriend user_id\n response = post(\"/users/#{user_id}/unfriend\")[\"response\"]\n @user = Foursquared::Response::User.new(self,response[\"user\"])\n end", "def Unfollow\n \n @kite = Kite.find(params[:id])\n \n if current_user\n @following = current_user.follwing.where(:Type => params[:type], :kite_id =>params[:id]).first\n end\n\n respond_to do |format|\n if @following && @following.destroy\n format.html { redirect_to(@kite, :notice => 'Kite has been unfollowed.')}\n format.xml { render :xml => @kite, :status => :created, :location => @kite }\n format.js {}\n format.json { render :json => @following, :status => :success }\n else\n format.html { render :action => \"owner_show\" }\n format.xml { render :status => :failure }\n format.js {}\n format.json { render :status => :unprocessable_entity }\n end\n end\n\n end", "def del_follow\n current_user.del_follow(@user)\n\n respond_to do |format|\n format.html { redirect_to wall_user_path(@user) }\n format.json { render :json => { user: @user.as_json(:json => 'wall') }}\n end\n end", "def unfollow(from_id, to_id, scope = Amico.default_scope_key)\n return if from_id == to_id\n\n Amico.redis.multi do\n Amico.redis.zrem(\"#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{from_id}\", to_id)\n Amico.redis.zrem(\"#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{to_id}\", from_id)\n Amico.redis.zrem(\"#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{from_id}\", to_id)\n Amico.redis.zrem(\"#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{to_id}\", from_id)\n Amico.redis.zrem(\"#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{to_id}\", from_id)\n Amico.redis.zrem(\"#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{from_id}\", to_id)\n end\n end", "def unfollow\n cookbook_follower = @cookbook\n .cookbook_followers\n .where(user: current_user)\n .first!\n cookbook_follower.destroy\n Supermarket::Metrics.increment \"cookbook.unfollowed\"\n\n render_follow_button\n end", "def unfollow(model)\n if self.id != model.id && self.followed?(model)\n\n model.reload\n self.reload\n\n model.before_unfollowed_by(self) if model.respond_to?('before_unfollowed_by')\n\n follows.where(:followable_type => model.class.name, :followable_id => model.id).destroy\n model.followers.delete(self)\n\n model.inc(:followers_count, -1)\n model.after_unfollowed_by(self) if model.respond_to?('after_unfollowed_by')\n self.before_unfollow(model) if self.respond_to?('before_unfollow')\n\n self.inc(:follows_count, -1)\n self.after_unfollow(model) if self.respond_to?('after_unfollow')\n\n return true\n else\n return false\n end\n end", "def unfollow_fan_base!(followed)\r\n fan_relationships.find_by_followed_id(followed).destroy\r\n end", "def unfollow_all\n Follow.where(follower_class: self.class.to_s, follower_id: id).destroy_all\n end", "def destroy\n @user = Relationship.find(params[:id]).followed\n current_user.unfollow(@user)\n respond_to do |format|\n format.html { redirect_to @user }\n format.js\n end\n end", "def destroy\n @user = Relationship.find(params[:id]).followed\n current_user.unfollow!(@user)\n respond_to do |format|\n format.html { redirect_to @user }\n format.js\n end\n end", "def destroy\n @user = Relationship.find(params[:id]).followed\n current_user.unfollow!(@user)\n respond_to do |format|\n format.html { redirect_to @user }\n format.js\n end\n end", "def unfriend(actor)\n unfollow(actor)\n actor.unfollow(self) if ActsAsActivityStream.sns_type == :custom\n end", "def unfollow\n return render_404 if params[:type].blank? or params[:id].blank? or params[:key].blank?\n email = Encoder.decode(params[:key])\n return render_404 if email.blank?\n\n Unfollower.create(:email => email, \n :unfollowerable_type => params[:type].capitalize, \n :unfollowerable_id => params[:id].to_i)\n \n render :text => \"You have successfully set back.\"\n end", "def destroy_following\n user = User.find(params[:id])\n current_user.followings.where(following_id: user.id).destroy_all\n end", "def unfriend\n request_response = post(\"/users/#{id}/unfriend\")[\"response\"]\n @user = Foursquared::Response::User.new(client, request_response[\"user\"])\n end", "def unfollow_company(company_id)\n path = \"/people/~/following/companies/id=#{company_id}\"\n delete(path)\n end", "def destroy\n rel = current_user.active_relationships.find_by(followed_id: params[:id])\n @user = Relationship.find(rel).followed\n current_user.unfollow(@user)\n\n respond_with @user\n # respond_to do |format|\n # format.html {redirects_to @user}\n # format.js\n # end\n end", "def unfollow_test\n unf_ids = params[:unfollow]\n \n unf_str = \"\"\n unf_cnt = unf_ids.length - 1\n for i in 0..unf_cnt\n unf_str +=unf_ids[i].to_s\n unf_str += \",\" unless unf_cnt == i\n end\n \n params_before_encode = [\n [\"user_id\",unf_str],\n [\"include_entities\",\"true\"]\n ]\n request_before_encode = [\n [\"http_method\",\"POST\"],\n [\"base_url\",\"http://api.twitter.com/1/friendships/destroy.json\"]\n ]\n header_string = buildheader(params_before_encode,request_before_encode)\n #puts header_string\n request = Typhoeus::Request.new(\"http://api.twitter.com/1/friendships/destroy.json\",\n :method =>\"post\",\n :headers =>{\"Authorization\" => header_string},\n :params =>{:user_id=>unf_str, :include_entities=>\"true\"})\n hydra = Typhoeus::Hydra.new\n hydra.queue(request)\n hydra.run \n end", "def unfollow_location(user_id, location_id)\n if User.find(user_id).locations.exists?(location_id)\n User.find(user_id).locations.delete(Location.find(location_id))\n end\n end", "def unfollow(user, contact)\n destroy(conn(user, contact))\n other_connection = conn(contact, user)\n if !other_connection.nil?\n if other_connection.status == ACCEPTED\n other_connection.status = PENDING\n other_connection.save\n elsif other_connection.status == REQUESTED\n destroy(other_connection)\n end\n end\n end", "def unfollow!(unfriend)\n\t\tresponse = access_token.post(\"/friendships/destroy/#{unfriend}.json\")\n\t\tcase response\n\t\twhen Net::HTTPSuccess\n\t\t\tfriend=JSON.parse(response.body)\n\t\t\traise TwitterOauth::UnexpectedResponse unless friend.is_a? Hash\n\t\t\tfriend\n\t\telse\n\t\t\traise TwitterOauth::APIError\n\t\tend\n\trescue => err\n\t\tputs \"Exception in unfollow!: #{err}\"\n\t\traise err\n\tend" ]
[ "0.8556826", "0.84737766", "0.84720457", "0.8419654", "0.83508956", "0.8334739", "0.83328897", "0.8319284", "0.8296302", "0.8239457", "0.81995213", "0.8193418", "0.81641597", "0.8146922", "0.8146922", "0.8146922", "0.8146922", "0.8146922", "0.8095", "0.80946875", "0.80946875", "0.80946875", "0.80568445", "0.80341846", "0.79728097", "0.79696125", "0.7964728", "0.79562646", "0.79534423", "0.79534423", "0.79534423", "0.7932592", "0.7928105", "0.7927514", "0.7925649", "0.7918473", "0.7889515", "0.7856499", "0.7854781", "0.7849099", "0.7830648", "0.77934784", "0.77813613", "0.77767277", "0.77452743", "0.77452743", "0.77386355", "0.7734762", "0.77108145", "0.77087927", "0.76900214", "0.76526594", "0.759747", "0.7587244", "0.7572861", "0.75674117", "0.7499101", "0.7469217", "0.74405783", "0.7355071", "0.7334192", "0.7323831", "0.7284133", "0.7279953", "0.7259253", "0.7214105", "0.7144595", "0.71381015", "0.71361196", "0.71249217", "0.71110445", "0.71058446", "0.71017516", "0.70983773", "0.708366", "0.70771295", "0.70415324", "0.7028637", "0.70157135", "0.70153886", "0.698565", "0.694398", "0.69369304", "0.69131064", "0.6908455", "0.6894851", "0.68580085", "0.6855416", "0.6854934", "0.6854934", "0.68285114", "0.6827304", "0.6805922", "0.68054265", "0.6801844", "0.6801758", "0.6789878", "0.6745353", "0.6717189", "0.66993773" ]
0.82586986
9
change password and encrypt
def password=(new_password) @password = Password.create(new_password) self.digest_password = @password end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt_password\n self.salt = make_salt if new_record?\n self.encrypted_password = encrypt(password)\n end", "def password=(new_password); end", "def password= password\n @password = password\n encrypt_password!\n end", "def encrypt_password\n self.salt = make_salt if new_record?\n\t self.encrypted_password = encrypt(password)\n end", "def encrypt_password\n # the argument on the right hand side is implicitly self.password\n self.encrypted_password = encrypt( password )\n end", "def encrypt_password\r\n \r\n # If the user is new, create a salt\r\n self.make_salt if new_record?\r\n \r\n # Hash the salt and password to create the encrypted pass\r\n self.encrypted_password = sha_hash(\"#{self.password}--#{self.salt}\")\r\n \r\n end", "def encrypt_password\n \tself.password = Digest::MD5.hexdigest(self.password)\n end", "def encrypt_password\n\t\t\tself.salt = make_salt if new_record? #new_record? retourne \"true\" si l'objet n'est pas dans la base de données\n\t\t\tself.encrypted_password = encrypt(password)\n\t\tend", "def encrypt_password\n self.salt = make_salt if new_record?\n self.encrypted_password = encrypt(password)\n end", "def encrypt_password\n self.salt = make_salt if new_record?\n self.encrypted_password = encrypt(self.password)\n end", "def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end", "def change_password(new_pass)\n self.salt = User.gen_salt\n salted_pass = User.salt_password(new_pass, self.salt)\n self.password = salted_pass\n end", "def encrypt_new_password\n return if password.blank?\n self.hashed_password = encrypt(password)\n end", "def encrypt_new_password\n return if password.blank?\n self.hashed_password = encrypt(password)\n end", "def encrypt_password\n return if password.blank?\n self.salt = Digest::SHA1.hexdigest(\"--#{Time.now.to_s}--#{login}--\") if new_record?\n self.crypted_password = encrypt(password)\n end", "def change_password\r\n \r\n end", "def encrypt_password\n return if password.blank?\n self.salt = User.make_token if new_record?\n self.crypted_password = encrypt(password)\n end", "def update_password(newpwd)\n self.password = Utils.sha1(newpwd + 'ad2012spot' + email)\n end", "def password=(new_password)\n @password = new_password\n self.encrypted_password = encrypt(@password) if @password.present?\n end", "def encrypt_password\n self.password = Digest::MD5.hexdigest(self.password).encode('UTF-8')\n end", "def encrypt_password\n if self.id.nil? || self.password_changed?\n self.password = BCrypt::Password.create(self.password)\n end\n end", "def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end", "def encrypt_password(encrypt_pass)\n if self.unencrypted? && self.unencrypted_password == self.password_confirmation\n self.create_salt\n self.password = Base64.encode64(EzCrypto::Key.encrypt_with_password(encrypt_pass, self.salt, self.unencrypted_password))\n @unencrypted = false\n end\n end", "def encrypt_password\n return if password.blank?\n self.salt = Digest::SHA1.hexdigest(\"--#{Time.now.to_s}--#{login}--\") if new_record?\n self.crypted_password = User.encrypt(password,self.salt)\n end", "def change_password\n #check if user is new or being updated\n if self.encrypted_password.present?\n #verifies password\n if self.password_check\n self.encrypt_password\n else\n raise \"error\"\n end\n else\n raise \"error\"\n end\n end", "def encrypt_password!\n if( !password.blank? )\n self['encrypted_password_store'] = BCrypt::Password.create( password, :cost => 11 )\n password, password_confirmation = nil, nil\n end\n end", "def encrypt_password\n if self.new_record? || !self.password.blank?\n self.encrypted_password = Digest::SHA256.hexdigest(\"#{self.encryption_salt}::#{@password}\")\n end\n end", "def encrypt_password\n\t\t\tif new_record?\n\t\t\t\tself.salt = make_salt\n\t\t\tend\n\t\t\tself.encrypted_password = encrypt(password)\n\t\tend", "def crypt_password\r\n write_attribute \"password\", self.class.sha1(password)\r\n end", "def encrypt_password!(user)\n return unless user.changed?(:password) # only run when the contract's password field changed (from nil to XXX).\n user.password_encrypted = Digest::SHA1.hexdigest(user.password)\n end", "def crypt_password\n\t\twrite_attribute \"password\", self.class.sha1(password)\n\tend", "def password=(pass)\n @good_password = false if system(\"look \\\"#{pass.downcase}\\\" > /dev/null 2>&1\")\n super Encrypt::Password.createHash pass\n end", "def encrypt_password\n\t unless @password.blank?\n self.password_salt = salt\n self.encrypted_password = encrypt(@password, salt)\n\t end\n\tend", "def encrypt_password\n if self.password.present?\n self.salt = secure_token\n self.crypted_password = password.to_s.encrypt( self.salt )\n end\n end", "def encrypt_password\n if(password.blank?)\n return\n else\n self.salt = make_salt(password) unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end\n end", "def encrypt_password\n if new_record?\n self.salt = make_salt\n self.password_digest = encrypt(password_digest)\n end\n end", "def crypt_password\n \t\twrite_attribute \"password\", self.class.sha1(password) unless self.password.empty?\n end", "def encrypt_password\n\t\treturn if password.blank?\n\t\tif new_record?\n\t\t\tself.salt = Digest::SHA1.hexdigest(\"--#{Time.now}--#{name}--\")\n\t\tend\n\t\tself.encrypted_password = User.encrypt(password, salt)\n\tend", "def change_password!(password)\n json = JSON.generate(:changePassword => { :adminPass => password })\n @compute.connection.req('POST', \"/servers/#{@id}/action\", :data => json)\n @adminPass = password\n end", "def password=(pwd)\n @password = pwd\n self.encrypted_password = self.class.encrypt(pwd,SALT) unless pwd.blank?\n end", "def encrypt_password\n unless self.password.nil?\n self.salt = make_salt\n self.encrypted_password = encrypt(password)\n end\n end", "def encrypt_password\n return if self.password.blank?\n \n self.salt = Digest::SHA1.hexdigest(\"--#{Time.now.to_s}--#{self.username}--\") if self.new_record?\n self.crypted_password = self.encrypt(self.password)\n end", "def encrypt_password\n if self.password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.password = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end", "def encrypt_password\n self.salt = make_salt unless has_password?(password)\n #the encrpyted_password attribute of the current user is the encryption of the password virtual attribute?\n self.encrypted_password = encrypt(password)\n end", "def password=(pass)\n return if pass.blank?\n before_password_set\n @password = pass\n send(\"#{password_salt_field}=\", Authlogic::Random.friendly_token) if password_salt_field\n send(\"#{crypted_password_field}=\", crypto_provider.encrypt(*encrypt_arguments(@password, act_like_restful_authentication? ? :restful_authentication : nil)))\n after_password_set\n end", "def digest_encrypt_password\n if password_changed? || username_changed?\n self.password = encrypt_password(username, DIGEST_REALM, password)\n end\n end", "def encrypt_password\n if password.present?\n #create salt password\n self.salt_password = BCrypt::Engine.generate_salt\n #create hash password\n self.password = BCrypt::Engine.hash_secret(password,salt_password)\n end\n end", "def crypt_password\n write_attribute \"password\", self.class.sha1(password)\n end", "def crypt_password\n write_attribute \"password\", self.class.sha1(password)\n end", "def crypt_password\n # EmailNotify.send_user_create_notification self\n self[:password] =\n password_hash(password(true))\n @password = nil\n end", "def change_password!(opts = {})\n password!(opts.merge(:verb => :put))\n end", "def encrypt_password(password)\n self.class.secure_digest([password, password_salt])\n end", "def change_temp_password\n\tend", "def encrypt(password)\n self.class.encrypt(password, Time.now.to_s)\n end", "def encrypt_password\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end", "def update_with_password(params, *options); end", "def cryptpass\n !self.password.nil? && self.password = self.password.crypt((rand*100).to_s)\n self.active = true\n end", "def change_password(opts = {})\n password(opts.merge(:verb => :put))\n end", "def change_customer_password\n enc_password = Authentication::Encryptor.digest([password, ::GlobalConstant::CUSTOMER_PEPPER].join)\n account = Authentication::Account.find_by(email: username)\n account.customer_password = enc_password\n account.save!\n {'success' => true}\n end", "def encrypt_password\n \t\tunless password.blank?\n \t\t# Encrypt password using BCrypt\n \t\tself.salt = BCrypt::Engine.generate_salt\n \t\tself.encrypted_password = BCrypt::Engine.hash_secret(password, salt)\n \tend\n end", "def encrypt_password(key = @key)\n # TODO: add different sql statements for different DBs.\n sql = \"UPDATE login_details\n SET encrypted_password = \n AES_ENCRYPT(#{quote_value(self.decrypted_password)}, #{quote_value(key)})\n WHERE id = #{self.id}\"\n # Run this update manually.\n self.connection.execute sql\n end", "def edit_password; end", "def encrypt_password\n # If password blank no need to go any further\n return if password.blank?\n # If the password is set we have some work to do\n self.hashed_password =encrypt(password)\n end", "def change_password(new_password)\n put(\"\", {:password => new_password})\n @password = new_password\n end", "def set_password(password) \n\t\t#Generate salt\n\t\tbase = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten\n\t\tsalt = (0...50).map{ base[rand(base.length)] }.join\n\t\t\n\t\tenc_password = Digest::SHA1.hexdigest(salt+password)\n\t\t\n\t\tself.salt = salt\n\t\tself.password = enc_password\n\t\tself.temp_password = nil\n\t\tself.save\n\tend", "def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def scramble_password\n if self.password_changed?\n self.password = Digest::MD5.hexdigest(self.password)\n end\n end", "def encrypt_password\n\n if password.present?\n\n self.password_salt = BCrypt::Engine.generate_salt\n\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n\n end \n\n end", "def set_password pass\n self.pass_salt = SHA256Salt.generate_random\n self.pass_hash = WodaHash.digest(self.pass_salt + pass).to_hex\n end", "def set_password(pass)\n self.user_password = User.crypt(pass)\n end", "def encrypt_password()\n if password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end", "def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend", "def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend", "def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend", "def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend", "def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend", "def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def crypt_password\n write_attribute \"password\", self.class.sha1(self.class.generate_salt, password)\n @password = nil\n end", "def encrypt_password\n if password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password= BCrypt::Engine.hash_secret(password, salt)\n end\n end", "def password=(password)\n@password = password\nif password.present?\ngenerate_salt\nself.hashed_password = self.class.encrypt_password(password, salt)\nend\nend", "def password=(password)\n@password = password\nif password.present?\ngenerate_salt\nself.hashed_password = self.class.encrypt_password(password, salt)\nend\nend", "def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def encrypt_password\n unless password.blank?\n self.salt = BCrypt::Engine.generate_salt\n self.fish = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end", "def encrypt_password\n if self.password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(self.password, salt)\n end\n end", "def password_encrypt\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def encrypt_password(pass)\n BCrypt::Engine.hash_secret(pass, password_salt)\n end", "def encrypt_password\n unless password.empty?\n self.password_hash = Digest::SHA1.hexdigest(password)\n end\n end", "def encrypt_password\n\t\tif password.present?\n\t\t\tself.password_salt = BCrypt::Engine.generate_salt\n\t\t\tself.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n\t\tend\n\tend", "def set_password(user, password)\n\t\t\t\t`echo \"#{shellescape(password)}\" | /usr/sbin/pw usermod #{shellescape(user)} -h 0`\n\t\t\tend", "def password_field=(plaintext)\n if plaintext != self.password\n self.password = Digest::SHA1.hexdigest(plaintext)[0..39] \n end\n end", "def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end", "def change_password(old_pass, new_pass, confirm_pass)\n if self.encrypted_password == encrypt(old_pass)\n p \"password_verified\"\n if new_pass = confirm_pass\n self.password = new_pass\n self.password_confirmation = confirm_pass\n if self.save\n p \"Sucess\"\n end\n else\n p \"Hey, your password doesn't match it's confirmation!\"\n end\n else\n p \"Hey, your Old password doesn't match!\"\n end\n end", "def change_password(old_password, new_password)\n old_password_tb.type_text(old_password)\n new_password_tb.type_text(new_password)\n password_confirm_tb.type_text(new_password)\n change_pw_btn.click\n end", "def encrypted\n \tself.encrypted_password = BCrypt::Password.create(self.password)\n end", "def newPassword(newPass)\n\t\tDATABASE.edit(\"users\", \"password\", newPass, \"username\", @username)\n\tend", "def old_password=(string)\n end", "def password=(pass)\n return if ignore_blank_passwords? && pass.blank?\n run_callbacks :password_set do\n @password = pass\n if password_salt_field\n send(\"#{password_salt_field}=\", Authlogic::Random.friendly_token)\n end\n send(\n \"#{crypted_password_field}=\",\n crypto_provider.encrypt(*encrypt_arguments(@password, false))\n )\n @password_changed = true\n end\n end" ]
[ "0.7974026", "0.7953494", "0.7913802", "0.7885503", "0.7868835", "0.78353184", "0.7827973", "0.781044", "0.7763111", "0.77279276", "0.7727391", "0.76988864", "0.7679751", "0.76769423", "0.76711094", "0.76619637", "0.76426196", "0.76342595", "0.7612288", "0.7606431", "0.75997", "0.7590487", "0.7558657", "0.75525844", "0.75415415", "0.75404686", "0.7531147", "0.7513924", "0.74913687", "0.74781185", "0.7474413", "0.7471295", "0.7468548", "0.7449166", "0.74435794", "0.74382263", "0.7426166", "0.7418317", "0.74155205", "0.7398692", "0.7391874", "0.73881394", "0.7377817", "0.73756844", "0.73737425", "0.73703825", "0.73622143", "0.73598105", "0.73598105", "0.73555166", "0.73482794", "0.73366266", "0.73252255", "0.73073065", "0.7300835", "0.7290595", "0.72888273", "0.72854805", "0.7277578", "0.7273499", "0.727258", "0.72709197", "0.72627956", "0.7254399", "0.72444886", "0.72420526", "0.7241539", "0.7233226", "0.7230047", "0.72297984", "0.72246015", "0.7222732", "0.7222732", "0.7222732", "0.7222732", "0.7222732", "0.7221515", "0.72113204", "0.7198635", "0.7194532", "0.7194532", "0.71905684", "0.71905684", "0.71905684", "0.71905684", "0.71905684", "0.718969", "0.7183781", "0.7177045", "0.71737397", "0.7165486", "0.7161453", "0.7156937", "0.7155843", "0.7155231", "0.71491444", "0.7145413", "0.7143386", "0.7142732", "0.7134794", "0.7100137" ]
0.0
-1
POST /signup return authenticated token upon signup
def create extuser = User.find_by(username: user_params[:username]) if(extuser.nil?) @user = User.new(user_params) @user.high_score = 0 @user.save! auth_token = AuthenticateUser.new(user_params[:username], user_params[:password]).call response = { message: Message.account_created, auth_token: auth_token, high_score: 0 } json_response(response, :created) else response = { message: Message.dublicate_user } json_response(response, :bad_request) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end", "def sign_up\n user = User.new(signup_params)\n if user.save\n response = {success: true, result: user.id}\n render json: response, status: :created\n else\n response = {success: false}\n render json: response, status: :internal_server_error\n end\n end", "def signup\n puts 'signup is happening here'\n permitted = params.require('signup').permit(['email', 'password', 'password_confirmation'])\n @newUser = User.new(permitted)\n if @newUser.save\n head :ok\n else\n render json:{\"reason\": \"could not create user\"}, status: 422\n end\n end", "def sign_up\n @user = User.new(user_params)\n if @user.save\n sign_in(@user)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def sign_up\n NexaasID::Resources::SignUp.new(api_token, config)\n end", "def sign_up\n service_response = UserManagement::SignUp.new(\n params.merge({\n is_client_manager: 1,\n client_creation_needed: 1,\n browser_user_agent: http_user_agent\n })\n ).perform\n\n if service_response.success?\n # NOTE: delete cookie value from data\n cookie_value = service_response.data.delete(:cookie_value)\n set_cookie(\n GlobalConstant::Cookie.user_cookie_name,\n cookie_value,\n GlobalConstant::Cookie.user_expiry.from_now\n )\n end\n\n render_api_response(service_response)\n end", "def create\n @user = User.new(signup_params)\n if @user.save\n sign_in @user\n respond_to do |format|\n \tformat.json { render json: @user }\n end\n else\n # render :new\n end\n end", "def signup\n case request.method\n when :post\n @user = User.new(params['user'])\n \n if @user.save \n session['user'] = User.authenticate(@user.login, params['user']['password'])\n flash['notice'] = _(\"Signup successful\")\n redirect_back_or_default :action => \"welcome\" \n end\n end \n end", "def create\n user = User.create!(user_params)\n render json: { token: user.auth_token }\n end", "def signup\n end", "def signup\n end", "def create\n cookies.delete :auth_token\n @user = User.new(params[:user])\n @user.save\n if @user.errors.empty?\n self.current_user = @user\n flash[:notice] = \"Thanks for signing up!\"\n redirect_back_or_default root_path\n else\n flash[:error] = \"There was an error during signup\"\n render :action => 'new', :layout => 'login'\n end\n end", "def create\n user = warden.authenticate!(auth_options)\n Tiddle.expire_token(user, request) if request.headers['X-USER-EMAIL'] && request.headers['X-USER-TOKEN']\n Tiddle.purge_old_tokens(user)\n token = Tiddle.create_and_return_token(user, request, expires_in: 3.days)\n render json: { user: user.as_json, authentication_token: token, message: t('devise.sessions.signed_in') }\n end", "def create\n @user = User.new(user_params)\n if @user.valid? && @user.save\n render json: { token: @user.auth_token }\n #render json: @user, status: 200\n else\n render json: {errors: \"Could not create user\"}\n end\n end", "def create\n user = User.new(sign_up_params)\n user.save!\n\n # Check if active for authentication.\n # If it needs mail confirmation, etc.., return false.\n if resource.active_for_authentication?\n # Validate params for authorize.\n if pre_auth.authorizable?\n # TODO: Fase 2, activate below flow.\n # if skip_authorization? || matching_token?\n # auth = authorization.authorize\n # redirect_to auth.redirect_uri\n # else\n # render :new\n # end\n\n # TODO: Fase 2, remove below process.\n result = authorization.authorize\n render json: result.auth, status: 201\n else\n # TODO: Fase 2, return error view.\n render json: pre_auth.error_response.body, status: 400\n end\n else\n render json: \"mail okuttayo\", status: 201\n end\n end", "def signup_user(options = {})\n options[:email] = options[:email] || $settings.customer_service_email\n options[:password] = options[:password] || 'foobar'\n\n # signup\n json = post_api '/api/session/signup', {\n 'email' => options[:email],\n 'password' => options[:password],\n 'name' => options[:email].split('@')[0]\n }\n assert_equal 200, json['status'], json['message']\n\n login_user(options) unless options[:skip_login]\n end", "def signup\n return if generate_blank\n params[:user].delete('form')\n params[:user].delete('verified') # you CANNOT pass this as part of the request\n @user = User.new(params[:user])\n begin\n User.transaction(@user) do\n @user.new_password = true\n unless LoginEngine.config(:use_email_notification) and LoginEngine.config(:confirm_account)\n @user.verified = 1\n end\n if @user.save\n key = @user.generate_security_token\n url = url_for(:action => 'home', :user_id => @user.id, :key => key)\n flash[:notice] = 'Signup successful!'\n if LoginEngine.config(:use_email_notification) and LoginEngine.config(:confirm_account)\n UserNotify.deliver_signup(@user, params[:user][:password], url)\n flash[:notice] << ' Please check your registered email account to verify your account registration and continue with the login.'\n else\n flash[:notice] << ' Please log in.'\n end\n redirect_to :action => 'login'\n end\n end\n rescue Exception => e\n flash.now[:notice] = nil\n flash.now[:warning] = 'Error creating account: confirmation email not sent'\n logger.error \"Unable to send confirmation E-Mail:\"\n logger.error e\n end\n end", "def create\n user = User.where(email: params[:user][:email]).first\n if user && user.authenticate(params[:user][:password])\n user.regenerate_token\n render json: { status: :success, data: user.to_json }\n else\n render json: { status: :error, data: 'Invalid login details' }\n end\n end", "def create\n logger.debug request.content_type\n if request.content_type != 'application/json'\n logger.info \"SignIn method: form\"\n super\n else\n logger.info \"SignIn method: json\"\n token = warden.authenticate!(:token_gen_strategy)\n render json: {\"token\" => token.to_s}\n end\n end", "def register\n email = request.headers['email'].to_s\n username = request.headers['username'].to_s\n password = request.headers['password'].to_s\n password_confirmation = request.headers['passconf'].to_s\n\n @user = User.new(email: email, username: username, password: password, password_confirmation: password_confirmation)\n if @user.save\n remember_token = RememberToken.create(token: User.encrypt(User.new_remember_token), user_id: @user.id, accessed_at: Time.now)\n respond_to do |format|\n format.json { render :json => remember_token }\n end\n else\n respond_to do |format|\n format.all{head :bad_request, :content_type => 'text/html'}\n end\n end\n end", "def create\n cookies.delete :auth_token\n # protects against session fixation attacks, wreaks havoc with \n # request forgery protection.\n # uncomment at your own risk\n # reset_session\n @user = User.new(params[:user])\n @user.save\n if @user.errors.empty?\n self.current_user = @user\n redirect_back_or_default('/')\n flash[:notice] = \"Thanks for signing up!\"\n else\n render :action => 'new'\n end\n end", "def sign_up\n if params[:email].present? and params[:password].present? and params[:confirm_password].present? and \\\n params[:password] == params[:confirm_password]\n begin\n user = User.new(email: params[:email],password: params[:password], encrypted_password: BCrypt::Password.create(params[:password]))\n if user.save\n token = user.access_tokens.create\n @msg = { status: STATUS_SUCCESS, token: token.access_token, user: token.user.email, message: SUCCESS_MESSAGE }\n else\n #error = get_error_message(user.errors.messages)\n temp_message = {}\n user.errors.messages.each { |h,v| temp_message[h] = v[0] }\n @msg = { status: STATUS_ERROR, error_message: temp_message }\n end\n rescue Exception => e\n user.really_destroy! if user and (message = user.errors.full_messages if user.errors.full_messages.present?)\n token.destroy if token and (message = token.errors.full_messages if token.errors.full_messages.present?)\n message = message.present? ? message.join(\",\") : CREDENTIAL_ERROR_MSG\n @msg = { status: STATUS_ERROR, message: message }\n end\n else\n @msg = { status: STATUS_ERROR, message: CREDENTIAL_ERROR_MSG }\n end\n render json: @msg\n end", "def create\n user = User.create(user_params)\n if user.valid?\n token = generate_token(user)\n render json: { success: true, token: token }.to_json, status: 200\n else\n render json: { success: false, message: \"Username Taken\" }\n end\n end", "def oauth_signup\n @user = User.new(\n nickname: params[:nickname],\n sex: params[:sex],\n phone: params[:phone],\n birthday: params[:birthday],\n province: params[:province],\n city: params[:city],\n area: params[:area] )\n @user.created_by_oauth = 'mobile'\n @user.authentications.build(\n uid: params[:oauth_uid],\n provider: params[:provider],\n access_token: params[:access_token])\n if @user.save\n @user.confirm!\n render :login\n else\n render json: {\n success: false,\n message: @user.errors.messages\n }\n end\n end", "def signup\n sign_out\n puts '----signup called.----'\n redirect_to '/users/sign_up'\n end", "def sign_in(user)\n user.create_new_auth_token\n end", "def attemp_signup\n\n end", "def register\n begin\n params.permit!\n user = User.new(name: params[:name], email: params[:email], password: params[:password])\n user.save!\n token = AuthenticateUser.call(params[:email], params[:password])\n render json: {status: 200, data: {auth_token: token.result, user_details: user}, msg: \"You are registered successfully.\"}\n rescue => e\n render json: {status: 401, data: {auth_token: nil, user_details: nil}, msg: e.message}, status: :unauthorized\n end \n end", "def create\n p 'hello world'\n @user = User.create(sign_up_params)\n if @user\n create_jwt_with({ user_id: @user.id })\n render json: { user: { username: @user.email } }, status: :created\n else\n render json: { errors: user.errors }, status: :unprocessable_entity\n end\n end", "def signup(params={})\n begin\n JSON.parse(RestClient.put construct_url(\"user\"), params)\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 create\n user = new_user\n\n authorize! :create, user\n\n user.unflattened_attributes = flat_params\n user.signup_type = :api\n\n user.save\n\n respond_with(user)\n end", "def signup\n return set_session_user_id!(nil, 'Введите данные.') { render :signup_new } if params_valid?(:signup)\n LdapService.mutex.synchronize do\n ldap_result = LdapService.new.add(\n email: params[:email],\n password: params[:password],\n name: params[:name],\n surname: params[:surname],\n role: 'painter'\n )\n return set_session_user_id!(nil, 'Невозможно зарегистрироваться.') { render :signup_new } if ldap_result.blank?\n user = User.find_by(ldap_id: ldap_result[:ldap_id])\n return set_session_user_id!(user.id, 'Вы вошли!') { redirect_to root_url } if user.present?\n user = User.new(ldap_result)\n return set_session_user_id!(user.id, 'Вы вошли!') { redirect_to root_url } if user.save\n set_session_user_id!(nil, 'Возникли проблемы. Попробуйте еще раз.') { render :signup_new }\n end\n end", "def create\n user = User.find_by(email: auth_params[:email])\n if user&.valid_password?(auth_params[:password])\n @token = user.api_tokens.find_or_create_by(name: (auth_params[:name] || \"default\")) do |token|\n token.make_token.save!\n end\n render json: {\n token: @token.token\n }\n else\n head :unauthorized\n end\n end", "def create_user\n fake_password = Faker::Internet.password\n params = {\n user: {\n username: Faker::Internet.user_name,\n email: Faker::Internet.email,\n password: fake_password,\n password_confirmation: fake_password\n }\n }\n post signup_post_url, { params: params }\n params[:user]\n end", "def create\n user = User.find_for_authentication(email: user_params[:email])\n\n if user && user.valid_password?(user_params[:password])\n user.generate_authentication_token\n\n expose({\n user_id: user.id,\n token: user.authentication_token\n })\n else\n error! :unauthenticated\n end\n end", "def sign_in(user)\n @user.create_new_auth_token\n end", "def create_set_and_add_token\n token = SecureRandom.urlsafe_base64\n @user.token = token\n response.headers['X-AUTH-TOKEN'] = token\n end", "def create\n self.current_user = User.from_omniauth(request.env['omniauth.auth'])\n\n if current_user\n # Send the email notifying the user!\n NotificationsMailer.signup(@user).deliver_later\n # byebug\n redirect_to request.referer\n else\n redirect_to auth_path(provider: 'github')\n end\n end", "def create\n @user = User.new(signup_params)\n if @user.save\n session[:user_email]=@user.email\n render 'homepage'\n else\n render 'index'\n end\n\n end", "def create\n user = User.find_for_database_authentication(email: params[:email])\n\n if user && user.valid_password?(params[:password])\n token = user.ensure_authentication_token\n render json: { user: user }\n else\n render nothing: true, status: :unauthorized\n end\n end", "def create\n @user = User.create_or_find_by(user_params)\n my_token = issue_token(@user)\n\n render json: {user: @user, token: my_token}\n # render json: @user\n \n end", "def create\n p \"-------user signup------\"\n user = User.new(user_params)\n user.skip_confirmation!\n if user.save\n data = { success: true, message: \"Your account registered.\" }\n else\n key, val = user.errors.messages.first\n data = { success: false, message: user.errors.full_messages.first }\n end\n render json: data\n end", "def signup\n @user = User.new\n end", "def signup\n @user = User.new\n end", "def create\n user = User.new(user_params)\n if user.save\n payload = { user_id: user.id }\n\n hmac_secret = 'my$ecretK3ys'\n\n auth_token = JWT.encode(payload, hmac_secret)\n\n render json: { message: 'Account created successfully', auth_token: auth_token }\n else\n render json: { message: 'Something went wrong', errors: user.errors }, status: :unprocessable_entity\n end\n end", "def generate_auth_token\n token = AuthToken.new(user: self)\n token if token.save\n end", "def post_signup(req)\n # Create account\n identity = Lynr::Model::Identity.new(@posted['email'], @posted['email'])\n # Create and Save dealership\n dealer = create_dealership(identity, nil)\n notify('dealership.created.demo', req, dealer)\n # Send to admin pages?\n send_to_next(req) || send_to_admin(req, dealer)\n rescue Lynr::Persist::MongoUniqueError\n attempt_signin(req)\n end", "def create\n @user = ::Accounts::User.new data_params\n @user.ensure_authentication_token\n\n render_create @user, :with_token\n end", "def create\n @user = User.where(:email => params[:user][:email]).first\n\n if !@user.nil?\n \trender :json => {:success => false, :message => \"User already registered\"}, :status => 401\n else\n \tbegin\n\t\t @user = User.new(params[:user])\n @user.password = Devise.friendly_token[0,20]\n\t\t if @user.save\n\t\t @api_key = ApiKey.find_or_create_token_for(@user)\n\t\t render :json => {:success => true, :message => \"Registration successful\",:access_key => @api_key.access_token, :user => @user}, :status => 200\n\t\t else\n\t\t \trender :json => {:success => false, :message => \"Error while creating user\"}, :status => :not_acceptable\n\t\t end\n\t\t rescue Exception => e\n p e\n\t \tp e.backtrace\n\t render :json => {:success => false, :message => e.backtrace}, :status => :not_acceptable\n\t end\n\t end\n end", "def create\n user = User.find_by_email(params[:email])\n if user.valid_password?(params[:password])\n render :json => { name: user.first_name, token: user.auth_token }\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token }, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n \thashPassword= Digest::MD5.hexdigest(params[:signup][:password])\n\t\tnewParams={\"name\" => params[:signup][:name], \"email\" => params[:signup][:email], \"password\" => hashPassword, \"phone\" => params[:signup][:phone] }\n\t\t@signup = Signup.new(newParams)\n respond_to do |format|\n if @signup.save\n\t\t\t\t@first = \"first\"\n\t\t\t\tformat.html { render action: \"login\" }\n #format.html { redirect_to @signup, notice: hashPassword }\n format.json { render json: @signup, status: :created, location: @signup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end", "def signup!(params)\n self.login = params[:user][:login]\n self.email = params[:user][:email]\n generate_temporary_password!\n save_without_session_maintenance\n end", "def signin_get\n @mode = :signin\n \n if params[:req].present? && !ApplicationController::RequiredIdentity.payload(session)\n @mode = :signup\n kind = params[:req].to_sym\n back = request.env[\"HTTP_REFERER\"]\n \n ApplicationController::RequiredIdentity.set_payload(session, \n :on_success => back,\n :on_cancel => back,\n :kind => kind)\n end\n \n render! :action => \"new\", :layout => \"dialog\"\n end", "def before_POST(req)\n super\n @errors = validate_signup(@posted)\n get_signup(req) if has_errors?\n end", "def create\n @user = User.new(user_params)\n if @user.save\n @token = encode_token({user_id: @user.id})\n render json: {user: @user, token: @token}\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def sign_up\n user = User.new(user_params); user.id = SecureRandom.uuid # genrating secure uuid token\n if user.save\n image_url = \"\"\n image_url = url_for(user.profile_photo) if user.profile_photo.attached?\n render json: { email: user.email, first_name: user.first_name, last_name: user.last_name, profile_photo: image_url, \"UUID\" => user.id, \"Authentication\" => user.authentication_token }, status: 200\n else\n render json: user.errors.messages, status: 400\n end\n rescue StandardError => e # rescue if any exception occurr\n render json: { message: \"Error: Something went wrong... #{e}\" }, status: 400\n end", "def sign_up\n request_params = {\n host_url_with_protocol: host_url_with_protocol,\n host_url: host_url,\n entity_type: GlobalConstant::TemplateType.registration_template_type\n }\n service_response = GlobalConstant::StTokenSale.get_client_details(request_params)\n\n # Check if error present or not?\n unless service_response.success?\n render_error_response(service_response)\n return\n end\n\n @presenter_obj = ::Web::Client::Setup.new(service_response, params)\n\n redirect_to '/token-sale-blocked-region', status: GlobalConstant::ErrorCode.temporary_redirect and return if @presenter_obj.is_blacklisted_ip?(get_ip_to_aml_countries)\n redirect_to \"/login\", status: GlobalConstant::ErrorCode.temporary_redirect and return if @presenter_obj.has_registration_ended?\n set_page_meta_info(@presenter_obj.custom_meta_tags)\n end", "def create\n user = User.find_by_email(params[:email])\n # confirming if password matches to that user email\n if user && user.authenticate(params[:password])\n render json: user.as_json(only: [:email, :id])\n .merge(\"token\": user.generate_jwt)\n else \n render json: { errors: {'email or password': [\"is invalid\"]}}, \n status: :unprocessable_entity\n end \n end", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def create_signup(attrs = {})\n Signup.create!(attrs.reverse_merge({\n access_token: 'access-token',\n instagram_username: 'jillsmith',\n instagram_id: '123456'\n }))\n end", "def api_sign_in\n user = users(:one)\n post '/auth/sign_in', params: { email: user.uid, password: \"secret123\" }\n\n return { \n \"uid\" => response.headers[\"uid\"],\n \"access-token\" => response.headers[\"access-token\"],\n \"client\" => response.headers[\"client\"] }\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n session[:user] = {id: @user.id, auth_token: @user.generate_auth_token!}\n format.html { redirect_to main_welcome_url, notice: 'User was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n @user = User.create(user_params)\n if @user.valid?\n token = encode_token({user_id: @user.id})\n render json: {user: @user, token: token}\n else\n render json: {error: \"Invalid username or password\"}\n end\n end", "def create\n @user = User.create(user_params)\n if @user.valid?\n token = encode_token({user_id: @user.id})\n render json: {user: @user, token: token}\n else\n render json: {error: \"Invalid username or password\"}\n end\n end", "def create\n payload = {\n user: {\n name: Faker::Name.name,\n email: Faker::Internet.email\n }\n }\n\n jwt = Auth.issue(payload)\n\n render json: { jwt: jwt }\n end", "def create\n respond_to do |format|\n # Check if user ticked T&C\n if (signup_params[:tos].to_i == 0)\n format.html{ redirect_to request.referrer, notice: \"You must accept the Terms & Conditions to register.\" }\n format.json { head :no_content }\n else\n # Check if username taken\n if username_exist(signup_params[:name])\n format.html{ redirect_to request.referrer, notice: \"Username already taken.\" }\n format.json { head :no_content }\n # check if email taken\n elsif email_exist(signup_params[:email])\n format.html{ redirect_to request.referrer, notice: \"Email already taken.\" }\n format.json { head :no_content }\n # check if password valid\n elsif !password_valid(signup_params[:password])\n format.html{ redirect_to request.referrer, notice: \"Password must be between 8-20 characters!.\" }\n format.json { head :no_content }\n else\n # check if email valid\n if email_valid(signup_params[:email])\n @user = User.create(signup_params) \n session[:user_id] = @user.id\n \n # User successfully creates account if save is called\n if @user.save\n UserMailer.newsletter_confirmation(@user).deliver_now\n format.html{ redirect_to root_path, notice: \"Account created!\" }\n format.json { head :no_content }\n # if save failed means the password and confirm password params are not the same\n else\n format.html{ redirect_to request.referrer, notice: \"Password not the same!\" }\n format.json { head :no_content }\n end\n else \n format.html{ redirect_to request.referrer, notice: \"Please enter a valid email!\" }\n format.json { head :no_content }\n end\n end\n end\n end\n end", "def new\n @user = User.new\n @is_signup = true\n end", "def create\n cookies.delete :auth_token\n # protects against session fixation attacks, wreaks havoc with\n # request forgery protection.\n # uncomment at your own risk\n # reset_session\n @klant = Klant.new(params[:klant])\n @klant.register! if @klant.valid?\n if @klant.errors.empty?\n UserMailer.deliver_signup_notification(@klant)\n #self.current_user = @klant\n #redirect_back_or_default('/')\n flash[:notice] = \"Thanks for signing up!\"\n else\n render :action => 'new'\n end\n end", "def create\n @user = User.new user_params\n\n respond_to do |format|\n if @user.save\n if ConfigVar['signup.email_check'] == 'enabled'\n token = Tokens::EmailVerification.random_for @user.email_credential\n SessionMailer.email_verification_email(token, root_url).deliver_now\n\n format.html do\n redirect_to new_session_url,\n notice: 'Please check your e-mail to verify your account.'\n end\n else\n email_credential = @user.email_credential\n email_credential.verified = true\n email_credential.save!\n set_session_current_user @user\n format.html { redirect_to root_url }\n end\n\n format.json do\n render json: @user, status: :created, location: @user\n end\n else\n format.json do\n render json: @user.errors, status: :unprocessable_entity\n end\n format.html { render action: :new }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n recaptcha_token = params[:'g-recaptcha-response']\n\n\n if recaptcha_token.blank?\n logger.error('encountered user signup without recaptcha token -- failing request')\n return render file: 'public/400.html', layout: false, status: :bad_request\n end\n\n if !RecaptchaVerifier.new(recaptcha_token).success?\n logger.error('got a failed recaptcha response')\n return render file: 'public/400.html', layout: false, status: :bad_request\n end\n\n respond_to do |format|\n if @user.save\n SignupConfirmationMailer.confirmation_email(@user).deliver_now\n format.html { render :confirmation_pending }\n format.json do\n render :json => {\n :success => true,\n :msg => t(\"welcome.index.accounts.signup_success_msg\")\n }\n end\n else\n format.html { render :new }\n\n format.json do\n render :json => {\n :success => false,\n :msg => t(\"welcome.index.accounts.signup_failure_msg\"),\n :errors => @user.errors\n }\n end\n end\n end\n end", "def create\n @user = User.new(params[:user])\n\n session[:token] = @user.generateToken\n respond_to do |format|\n if @user.save\n unless session[:original_url].nil?\n redirect_to session[:original_url]\n return\n end\n format.html { redirect_to root_path, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if user&.valid_password?(params[:password])\n if turbo_native_app?\n sign_in_user\n render json: {location: after_sign_in_path_for(user), token: token_by_name(ApiToken::APP_NAME)}\n else\n render json: {token: token_by_name(ApiToken::DEFAULT_NAME)}\n end\n else\n render json: {error: error_message}, status: :unauthorized\n end\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if user_exists?(@user)\n @current_user = User.find_by_email(@user.email)\n cookies.permanent[:auth_token] = @current_user.auth_token\n user_may_be_different = (@current_user.last_ip != request.remote_ip)\n @current_user.last_ip = request.remote_ip\n @current_user.save!\n login_message = \"You've already signed up, so we signed you in!\"\n login_message << \" We also notice you've logged in from a different location. We don't care, but you might ;-]\" if user_may_be_different\n format.html { redirect_to user_path(@current_user), notice: \"#{login_message}\" }\n elsif @user.save\n format.html { redirect_to user_tasks_path(@user), notice: 'Signed up!' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n self.resource = warden.authenticate!(scope: :user)\n token = Tiddle.create_and_return_token(resource, request)\n render json: { authentication_token: token }\n end", "def create\n if params[:via_linkedin] == false\n # create the new user instance with params from sign up form\n user = User.create(user_params)\n else\n params[:user][:password] = SecureRandom.hex\n\n # find or create the new user instance via linkedin\n user = User.where(provider: user_params[:provider], uid: user_params[:uid])\n .first_or_create(user_params)\n end\n # check the user save ok\n if user.persisted?\n # use the Knock AuthToken model to create a token for us\n render json: { jwt: auth_token(user).token, user: UserSerializer.new(user) }, status: 200\n else\n # bad request\n render json: user, status: 400\n end\n end", "def create\n @user = User.new(user_params)\n # return msg: render json: @user, status: :created\n if @user.save\n reset_session\n log_in @user\n flash[:success] = \"Signup Success, Welcome to Fyber Connect!\"\n redirect_to @user\n else\n render 'new'\n end\n end", "def sign_up(resource_name, resource)\n # sign_in(resource_name, resource)\n end", "def signup\n \n # Look up for User in database\n @user = User.find_by(name: param_username) \n\n if @user\n\n @user = nil\n render json: {status: status_code(:conflict), message: \"Username already exists. Please sign in using your mobile.\" }\n \n else\n \n @user = User.create(name: param_username, email: param_user_email, password: param_password)\n\n if !@user.save\n render json: {status: status_code(:unprocessable_entity), message: 'Validation errors', data: {errors: @user.errors}}\n return\n end\n\n @user.signin!(request)\n \n render json: {\n status: status_code(:ok),\n message: 'Signed in successfully!',\n data: @user.as_signin_json\n }\n\n end\n\n end", "def signup!(params)\n self.email = params[:user][:email]\n self.name = params[:user][:name]\n self.password = params[:user][:password]\n #save_without_session_maintenance\n end", "def create\n # Insert new user in database\n user = User.new(user_params)\n\n if user.save\n # On success, send token information to authenticate user\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n # render json: @user, status: :created, location: @user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end", "def register\n\n # New User\n user = User.new(register_params)\n user.save()\n\n # If no errors...\n if user.errors.messages.empty?\n # Returns user authentication payload\n render json: payload(user)\n else\n # Returns error messages\n render json: { errors: user.errors.messages }, status: :bad_request\n end\n\n end", "def create\n # login\n user = User.authenticate(params[:user][:email], params[:user][:password])\n\n respond_to do |format|\n if user\n # Create an api token for this user.\n user.enable_api!\n format.json { render :json => user }\n else\n format.json { head :unauthorized }\n end\n end\n end", "def signup\n @user = User.new(params[:user])\n return unless request.post?\n if @user.save\n flash[:notice] = \"New user added!\"\n redirect_to :action=>'show', :id=>@user\n end\n end", "def register\n user = User.new(login_params.merge(password_confirmation: nil))\n\n if user.save!\n render json: user\n else\n head :bad_request\n end\n end", "def create\n user = User.new(user_params)\n userDB = User.find_by(email: user_params[\"email\"])\n \n if ( userDB == nil )\n if user.save\n token = AuthenticationHelper::Auth.instance.generateJWT( user_params[\"email\"] )\n render json: token, status: :created\n else\n render json: user.errors, status: :unprocessable_entity\n end\n else\n render json: :nothing, status: :unprocessable_entity \n end\n end", "def create\n super do |user|\n if request.format.json?\n data = {\n token: user.authentication_token,\n email: user.email,\n userId: user.id\n }\n render json: data, status: 200 and return\n end\n end\n end", "def create\n user = User.new(user_params)\n \n if user.save\n token = JsonWebToken.encode(user_id: user.id)\n render json: { auth_token: token, user: AuthUserSerializer.new(user).serializable_hash }, status: 201\n else \n render json: { errors: user.errors.full_messages }, status: 400\n end\n end", "def create\n @user = User.new(user_params)\n # If the User instance was successfully saved then redirect to home page and display notice\n if @user.save\n # Set authentication token cookie so that the User is automatically signed in after signing up\n cookies[:authentication_token] = @user.:authentication_token\n redirect_to root_url, notice: \"Thank you for signing up.\"\n # If the User instance was not saved in the database then redisplay the sign up form\n else\n render :new\n end\n end", "def signup\n @user= User.new\n end", "def signup!(params)\n self.login = params[:user][:login]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def sign_up\n\t\tif params[:uuid].present?\n\t\t\t@existing_member = Com::Nbos::User.where(uuid: params[:uuid])\n\t\t\tif @existing_member.present?\n\t\t\t\trender :json => @existing_member.first\n\t\t\telse\n\t\t\t\t@member = build_user(params)\n\t\t\t\tif @member && @member.save\n\t\t\t\t\trender :json => @member\n\t\t\t\telse\n\t\t\t\t\trender :json => {status: 500, message: @member.errors.messages}, status: 500\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\trender :json => {status: 400, message: \"Bad Request\"}, status: 400\n\t\tend\t\n\tend", "def create\n user = User.find_by email: params[:email]\n if user && user.authenticate(params[:password])\n reactivate(user)\n render json: user.session_api_key, status: 201\n else\n render json: {\n \"error\" => \"Unauthorized\"\n }, status: 401\n end\n end", "def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n # send welcome email\n YamrsMailer.welcome_email(@user).deliver\n # authenticates them\n cookies[:auth_token] = @user.auth_token\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if user_signed_in?\n render json: { redirect_url: after_sign_in_path_for(@current_user) }\n else\n render json: { errors: \"Invalid email or password\"} and return \n end\n end", "def new\n @user_signup = User.new\n @is_signup = true\n end", "def signup_with_email\n @status, @msg, @data = UserValidator.signup_with_email(params)\n @status, @msg, @data = UserManager.signup_with_email(params) if @status\n end", "def client_sign_up\n\n end", "def sign_up\n @user = User.new\n end", "def register_with_password\n pu = params[:user]\n if user = User.find_by_email(pu[:email]) \n # Go ahead and sign the user in if he mistakenly used the signup form to login. But dont bother updating any attributes\n # that area different from the last time he used the sign up screen. \n if pu[:password] == user.password\n set_and_cookie_current_user user\n render :json => {:success => {:user => user}}\n else\n render :json => {:fail => {:email => user.email}}\n end\n else user = User.create!( pu.merge(:status => :active,:app_version => params[:v]) )\n set_and_cookie_current_user user\n render :json => {:success => {:user => user}}\n end \n end" ]
[ "0.7063818", "0.68050104", "0.6739276", "0.6681925", "0.66760415", "0.66422856", "0.6563522", "0.655776", "0.65307575", "0.64594257", "0.64594257", "0.6419524", "0.6391598", "0.63508296", "0.6337406", "0.6335316", "0.62596434", "0.62461716", "0.62396497", "0.62369937", "0.6233925", "0.62288785", "0.6224758", "0.6222375", "0.61849475", "0.61844194", "0.61829114", "0.61755985", "0.6173643", "0.6169033", "0.61582935", "0.61547333", "0.615437", "0.61451644", "0.6143171", "0.61325836", "0.61323303", "0.6114254", "0.6101445", "0.60919386", "0.6086415", "0.6073939", "0.6059539", "0.6059539", "0.6058625", "0.60527885", "0.6048178", "0.60329455", "0.6028081", "0.60249305", "0.6017966", "0.60087293", "0.5992529", "0.5986881", "0.5985317", "0.5977966", "0.5974901", "0.5973412", "0.596742", "0.596224", "0.596224", "0.5957649", "0.5957446", "0.5957126", "0.59542006", "0.59542006", "0.5947106", "0.59439445", "0.5943541", "0.5942085", "0.5941017", "0.59404063", "0.5924996", "0.59200895", "0.591598", "0.5911885", "0.59081703", "0.5905757", "0.5901913", "0.590178", "0.5897241", "0.5896845", "0.58931124", "0.58926094", "0.58883625", "0.5882785", "0.5878841", "0.5874807", "0.58744967", "0.5868267", "0.5865986", "0.5856362", "0.58542454", "0.5844996", "0.5838862", "0.5830169", "0.58297783", "0.5824161", "0.5823144", "0.58172065", "0.5811478" ]
0.0
-1
POST /reviews POST /reviews.json
def create _params = review_init_params _params[:id] = SecurityManager.md5("#{@user.id}_#{@task.id}") _params[:score] = _params[:score].to_i _params[:author_id] = @user.id begin @review = @task.reviews.create(_params) rescue Mongo::Error::OperationFailure return bad_request("duplicated") end respond_to do |format| if @review.save format.html { redirect_to '/task' } else return unprocessable_entity end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @review = current_author.reviews.create(review_params)\n render json: @review, status: 201\n end", "def create\n review = course.reviews.new(review_params)\n \n if review.save\n render json: ReviewSerializer.new(review).serialized_json\n else\n render json: { error: review.errors.messages }, status: 422\n end\n end", "def create\n @user = current_user\n @review = @user.reviews.build(review_params)\n if @user.save\n render json: @review\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.save\n render json: @review, status: :created, location: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @review = Review.new(review_params)\n current_user.reviews << @review\n respond_to do |format|\n if @review.save\n format.json { render :show, status: :created, location: @review }\n else\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = reviewable.reviews.build(params[:review])\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to reviewable_review_url(reviewable, @review), notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(params[:review])\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@review = Review.new(review_params)\n\t\t@review.user_id = current_user.id\n\t\trespond_to do |format|\n\t\t\tif @review.save\n\t\t\t\t@reviews = Review.order(:heading).paginate(page: params[:page], per_page: 18)\n\t\t\t\tformat.html { redirect_to @review; flash[:success]= 'review was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @review }\n\t\t\t\tformat.js\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @review.errors, status: :unprocessable_entity }\n\t\t\t\tformat.js\n\t\t\tend\n\t\tend\n\tend", "def create\n @review = @post.reviews.where(user_id: current_user.id).create(params[:review])\n respond_with @post, @review, location: post_path(@post, anchor: \"review_#{@review.id}\")\n end", "def create\n #binding.pry\n review = Review.new(review_params) \n if review.save\n render json: ReviewSerializer.new(review)\n else\n render json: {errors: review.errors.full_messages}\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render action: 'show', status: :created, location: @review }\n else\n format.html { render action: 'new' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_review(booking, options = {})\n post(\"bookings/#{booking}/reviews\", reviews: [options]).pop\n end", "def create\n\t\treview = Review.create(:user_id=>params[:review][:user_id], :note_id=>params[:review][:note_id], :status=>params[:review][:status])\n\t\treview.save!\n\n render json: []\n\tend", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to dashboard_path, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n @review.user = current_user\n\n if @review.save\n render :show, status: :created, location: @review\n else\n render json: { Error: @review.errors }, status: :unprocessable_entity\n end\n end", "def new\n @review = reviewable.reviews.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def create\n @review = current_user.reviews.build(review_params)\n \n if @review.save\n flash[:success] = 'レビューを投稿しました。'\n redirect_to root_url\n else\n @reviews = current_user.reviews.order(id: :desc).page(params[:page])\n flash.now[:danger] = 'レビューの投稿に失敗しました。'\n render '/reviews'\n end\n end", "def create\n @review = Review.new(review_params)\n if @review.save\n redirect_to reviews_path\n else\n render 'new'\n end\n end", "def index\n @reviews = reviewable.reviews\n\n respond_to do |format|\n format.html\n format.json { render json: @reviews }\n end\n end", "def create\n @review = @publication.reviews.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review.publication, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reviews_and_rating = ReviewsAndRating.new(reviews_and_rating_params)\n\n respond_to do |format|\n if @reviews_and_rating.save\n format.html { redirect_to @reviews_and_rating, notice: 'Reviews and rating was successfully created.' }\n format.json { render :show, status: :created, location: @reviews_and_rating }\n else\n format.html { render :new }\n format.json { render json: @reviews_and_rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if !!@review && current_user\n current_user.reviews << @review\n @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n # TODO redirect to page that shows what their review will look like. \n format.html { redirect_to thanks_path, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: \"レビューが作成されました\" }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if current_user\n @review = current_user.reviews.build(params[:review])\n\n respond_to do |format|\n if @review.save\n flash[:success] = 'Запись успешно добавлена!'\n format.html { redirect_to reviews_path }\n format.json { render json: @review, status: :created, location: reviews_path }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:error] = 'Вы должны войти в систему!'\n redirect_to root_path\n end\n end", "def create\n @review = Review.new(review_params)\n respond_to do |format|\n if Review.validate(@review) and @review.save\n format.html { redirect_to bookings_path, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n flash[:notice] = \"You are submitting your review multiple times. Aborting\"\n format.html { redirect_to bookings_path }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\t@review.user_id = current_user.id\n\t\n\t# used for partials rendering in SPA\n\t@site = Site.find(@review.site_id)\n\t@sites = Site.all\n\t@reviews = Review.where(site_id: @site.id).order(\"created_at DESC\")\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to @review, notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n\t\tformat.js\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n\t\tformat.js { render 'shared/errors' }\n end\n end\n end", "def save_review\r\n return unless self.review\r\n begin\r\n r = JSON.parse self.review\r\n c = Comment.new\r\n c.id = r['id']\r\n c.content = r['content']\r\n c.user_id = r['user']['id']\r\n c.app_id = r['app']['id']\r\n c.created_at = Time.at r['created_at']\r\n c.model = r['model']\r\n c.sdk = r['sdk']\r\n c.image = r['image']\r\n c.image_size = r['image_size']\r\n c.sns_status_id = r['sns_status_id']\r\n c.sns_id = r['sns_id'] \r\n c.in_reply_to_id = r['in_reply_to_id']\r\n c.save\r\n rescue\r\n end\r\n end", "def create\n @user_review = UserReview.new(user_review_params)\n\n respond_to do |format|\n if @user_review.save!\n format.html { redirect_to user_reviews_path, notice: 'User review was successfully created.' }\n format.json { render :show, status: :created, location: @user_review }\n else\n format.html { render :new }\n format.json { render json: @user_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = @story.reviews.new(review_params)\n if @review.save\n redirect_to @review.story, notice: 'Review was successfully created.'\n else\n render :new\n end\n end", "def new\n @review = current_user.reviews.new\n 1.times { @review.review_photos.build }\n @place = Place.first\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def create\n @item_review = ItemReview.new(item_review_params)\n\n respond_to do |format|\n if @item_review.save\n format.html { redirect_to @item_review, notice: 'Item review was successfully created.' }\n format.json { render :show, status: :created, location: @item_review }\n else\n format.html { render :new }\n format.json { render json: @item_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:user_id] && params[:recruiter_id] && params[:review]\n user = User.find(params[:user_id])\n # puts user\n recruiter = Recruiter.find(params[:recruiter_id])\n # puts recruiter\n ################################\n params[\"got_interview\"] ? got_interview = params[\"got_interview\"] : got_interview = false\n params[\"got_job\"] ? got_job = params[\"got_job\"] : got_job = false\n got_job ? got_interview = true : \"null\" #if got job then must have had interview\n params[\"rating\"] ? rating = params[\"rating\"] : rating = 0 #0 means not rated\n params[\"recommended\"] ? recommended = params[\"recommended\"] : recommended = false\n params[\"ghoster\"] ? ghoster = params[\"ghoster\"] : ghoster = false\n # puts \"*********$\"\n # puts params\n # puts recommended\n # puts params[:recommended]\n # puts \"***************$\"\n review = Review.new(\n user_id: user.id,\n recruiter_id: recruiter.id,\n review: params[\"review\"],\n got_interview: got_interview,\n got_job: got_job,\n rating: rating,\n recommended: recommended,\n ghoster: ghoster\n ) #Review.new\n\n if review.save\n render json: {\"POSTED REVIEW\": \"ok\"} #works\n else\n render json: {\"error\": \"ERROR SAVE POSTED REVIEW\"}\n end\n ################################\n # render json: {\"POSTED REVIEW\": \"ok\"} #works\n else\n render json: {\"error\": \"no user_id or recruiter_id or review\"}\n end # if params[:user_id]\n end", "def new\n @review = @place.reviews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def create\n @recipe = Recipe.find params[:recipe_id]\n review = Review.new review_params\n review.recipe = @recipe\n review.user = current_user\n if review.save\n render json:{id: review.id}\n else \n render(json: {status: 422},\n status: 422 )\n end\n end", "def create\n @item_review = ItemReview.new(item_review_params)\n\n respond_to do |format|\n if @item_review.save\n format.html { redirect_to @item_review, notice: 'Item review was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item_review }\n else\n format.html { render action: 'new' }\n format.json { render json: @item_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = current_user.reviews.new(review_params)\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to place_path(@review.place), notice: 'Review was successfully created.' }\n else\n format.html { redirect_to root_path }\n end\n end\n end", "def create\n\t\t@book_review = BookReview.new(params[:book_review])\n\t\t@book_review.user_id = current_user.id\n\t\t@book_review.book_id = params[:book_id]\n\n\t\trespond_to do |format|\n\t\t\tif @book_review.save\n\t\t\t\tformat.html { redirect_to @book_review, :notice => 'Book review was successfully created.' }\n\t\t\t\tformat.json { render :json => @book_review, :status => :created, :location => @book_review }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render :json => @book_review.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def review\n\t@applicants = Applicant.all\n\t\n\trespond_to do |format|\n\tformat.html # review.html.erb\n\tformat.json { render json: @applicants }\n\tend\n\tend", "def create\n item = Item.find(params[:review][:rateable_id])\n @review = item.reviews.new\n @review.user_id = current_user.id\n @review.rating = params[:review][:rating]\n @review.comment = params[:review][:comment]\n if @review.save\n redirect_to item_path(item)\n else\n flash[:alet] = \"There was a problem creating the review\"\n render :new\n end\n end", "def reviews(params = {})\n data = request(\"/review/list\", params.merge(v: \"2\"))\n reviews = data[\"reviews\"][\"review\"]\n if reviews.present?\n reviews.map { |review| Hashie::Mash.new(review) }\n else\n []\n end\n end", "def create\n @review = @place.reviews.new(params[:review])\n @review.user = current_user\n respond_to do |format|\n if @review.save\n format.html { redirect_to place_path(@place), notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { redirect_to place_path(@place, :anchor => \"review\"), notice: 'Please enter your review!!.' }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @reviews = Review.all\n @review = Review.new(review: params[:review][:review], my_book_id: params[:my_book_id])\n end", "def create\n @review = Review.new(review_params)\n @review.exceptional ||= 0\n if @review.save\n @apn.update_attribute(:reviewed, true)\n link = reviews_path\n name = @apn.profile.first_name.capitalize + \" \".to_s + @apn.profile.last_name.capitalize\n redirect_to new_review_path, notice: (\"#{name} successfully reviewed.\" +\n \" New application loaded. If you're feeling lazy, <a href='#{link}'>\" +\n \"go to the Dashboard</a>\").html_safe\n else\n render action: \"new\", alert: \"something went wrong with submitting the review\"\n end\n end", "def create\n\t\t@review = Review.new(params[:review])\n\t\t@review.establishment = Establishment.find(params[:establishment])\n\t\t@review.category = Category.find(params[:category])\n\t\t@review.clientele = Clientele.find(params[:clientele])\n\t\t@review.sound_level = SoundLevel.find(params[:sound_level])\n\t\t@review.hygiene = Hygiene.find(params[:hygiene])\n\t\t@review.rating = Rating.find(params[:rating])\n\n\t\trespond_to do |format|\n\t\t\tif @review.save\n\t\t\t\tformat.html { redirect_to(@review, :notice => 'Review was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @review, :status => :created, :location => @review }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @critic_review = CriticReview.new(critic_review_params)\n\n respond_to do |format|\n if @critic_review.save\n format.html { redirect_to @critic_review, notice: 'Critic review was successfully created.' }\n format.json { render :show, status: :created, location: @critic_review }\n else\n format.html { render :new }\n format.json { render json: @critic_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Creates a new review & sends them back to their updated page\n review = current_user.reviews.create(review_params)\n if review.save\n redirect_to :back\n else\n redirect_to product_path(id: params[:product_id])\n end\n end", "def welcome\n @reviews = Review.all\n render json: @reviews\n end", "def create\n @comic = Comic.find(params[:comic_id])\n @review = current_user.reviews.new(review_params)\n @review.tag_list = params[:tag_list]\n @review.comic_id = @comic.id\n p @review\n p review_params\n respond_to do |format|\n if @review.save\n format.html { redirect_to comic_path(@comic), notice: 'Review was successfully created.' }\n format.json { render :show, status: :created, location: @review }\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review = Review.new(review_params)\n\n if @review.valid?\n @review.save \n @boardgame = Boardgame.find(params[:boardgame_id])\n render json: @boardgame, status: :created \n else\n render json: @review.errors, status: :unprocessable_entity\n end\n end", "def create\n @product = Product.find params[:product_id] \n @review = @product.reviews.create(review_params)\n if @review.save\n redirect_to :back\n end\n end", "def index\n @reviews = Review.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def index\n @reviews = Review.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def create\n @visitor_review = VisitorReview.new(visitor_review_params)\n\n respond_to do |format|\n if @visitor_review.save\n format.html { redirect_to @visitor_review, notice: 'Visitor review was successfully created.' }\n format.json { render :show, status: :created, location: @visitor_review }\n else\n format.html { render :new }\n format.json { render json: @visitor_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book_review = BookReview.new(params[:book_review])\n\n respond_to do |format|\n if @book_review.save\n format.html { redirect_to @book_review, notice: 'Book review was successfully created.' }\n format.json { render json: @book_review, status: :created, location: @book_review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def reviews_params\n params.require(:review).permit(:name, :email, :content, :score)\n end", "def index\n @reviews = @post.reviews.all\n respond_with @post, @reviews\n end", "def create\n @review = Review.new(review_params)\n @review.user_id = current_user.id\n @review.movie_id = @movie.id\n\n respond_to do |format|\n #If the review is saved, it redirects to the movie page and shows the notice.\n if @review.save\n format.html { redirect_to @movie, notice: t('review.create') }\n format.json { render :show, status: :created, location: @review }\n #If the review is not saved, it refreshes the create review page.\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @review = Review.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def new\n @review = Review.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def new\n @review = Review.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def new\n @review = Review.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def new\n @review = Review.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def new\n @review = Review.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end", "def post_review\n @review = Review.new\n @review.title = params[:title]\n @review.description = params[:description]\n @review.name = params[:name]\n @review.user_id = User.find(session[:user_id]).id\n @review.rating = params[:rating]\n @review.listing = params[:listing]\n @review.save()\n # flash[:notice] = \"Review added successfully.\"\n redirect_to :action => :listing, :id => params[:listing]\n end", "def review_params\n params.require(:review).permit(:customer_id, :car_id, :reservation_id, :content, :rating)\n end", "def create\n if @restaurant.present?\n review = Review.new(review_params)\n if review.save\n render_json content: review\n else\n render_json content: review.errors\n end\n else\n render json: {error: \"restaurant id #{review_params[:restaurant_id]} does not exist\"}, status: :forbidden\n end\n end", "def create\n @book = Book.find(params[:book_id])\n @review = @book.reviews.build(review_params)\n @review.user = current_user\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to book_path(@book), notice: 'Su crítica se envió correctamente.' }\n format.json { render :show, status: :created, location: @review }\n format.js\n else\n format.html { render :new }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @shop = Shop.find(params[:shop_id])\n @review = @shop.reviews.create(reviewer: params[:review][:reviewer], rate: params[:review][:rate], body: params[:review][:body])\n\n if @review.save\n puts \"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n flash[:notice] = \"レビューの投稿が完了しました\"\n redirect_to shop_path(@shop)\n\n else\n redirect_to shop_path(@shop)\n flash[:notice] = \"レビューの投稿に失敗しました\"\n end\n\n\n end", "def create_review(book_id, params = {})\n params = params.merge(book_id: book_id, v: \"2\")\n\n params[:read_at] = params[:read_at].strftime('%Y-%m-%d') if params[:read_at].is_a?(Time)\n\n params[:'review[review]'] = params.delete(:review) if params[:review]\n params[:'review[rating]'] = params.delete(:rating) if params[:rating]\n params[:'review[read_at]'] = params.delete(:read_at) if params[:read_at]\n\n data = oauth_request_method(:post, '/review.xml', params)\n\n Hashie::Mash.new(data[\"review\"])\n end", "def create\n @review = Review.new(params[:review])\n @review.review_date = Time.now\n @review.user_id = current_user.id\n\n respond_to do |format|\n if @review.save\n format.html { redirect_to place_url(@review.place), notice: 'Review was successfully created.' }\n format.json { render json: @review, status: :created, location: @review }\n else\n format.html { render action: \"new\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def review_params\n params.require(:review).permit(:user_id, :comic_id, :review_text, :review_title, :netabare, :tag_list, :star)\n end", "def review\n fetch('restaurant.review')\n end", "def create\n @food_review = FoodReview.new(food_review_params)\n\n respond_to do |format|\n if @food_review.save\n format.html { redirect_to @food_review, notice: 'Food review was successfully created.' }\n format.json { render :show, status: :created, location: @food_review }\n else\n format.html { render :new }\n format.json { render json: @food_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n author = Author.find(params[:author_id])\n @reviews = author.reviews\n render json: @reviews\n end", "def new\n @new_review = NewReview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_review }\n end\n end", "def create\n @restaurant_review = RestaurantReview.new(restaurant_review_params)\n\n respond_to do |format|\n if @restaurant_review.save\n format.html { redirect_to @restaurant_review, notice: 'Restaurant review was successfully created.' }\n format.json { render :show, status: :created, location: @restaurant_review }\n else\n format.html { render :new }\n format.json { render json: @restaurant_review.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def index\n @reviews = @place.reviews\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n end\n end", "def review_params\n params.require(:review).permit(:description, :rating, :restaurant_id)\n end", "def create\n @review = Review.new(review_params)\n respond_to do |format|\n if @review.save\n format.json { render action: 'show', status: :created, location: @review }\n format.html { redirect_to postings_path, notice: 'Review was successfully created.' }\n if current_user.type == \"Student\"\n format.html { redirect_to postings_path, notice: 'Review was successfully created.' }\n else\n format.html { redirect_to supervisor_application_index_path, notice: 'Review was successfully created.' }\n end\n else\n format.html { redirect_to postings_path, notice: \"Review could not be saved. Make sure you fill out fields with an *.\" }\n format.json { render json: @review.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@reviews = @share.reviews.order(priority: :asc)\n\t\t@reviewToAlter = @share.reviews.new(review_params)\n\t\t\n\t\tif @reviewToAlter.save\n\t\t\tredirect_to share_reviews_path(@share), notice: \"Review saved!\"\n\t\telse\n\t\t\tflash[:alert] = \"Error : #{@reviewToAlter.errors.full_messages.to_sentence}\"\n\t\t\trender :index\n\t\tend\n\tend", "def reviews( params={} )\n reviews = get_connections(\"reviews\", params)\n return map_connections reviews, :to => Facebook::Graph::Review\n end", "def create\n @review = Review.new(params[:review])\n if @review.save\n flash[:notice] = \"Review Created\"\n redirect_to \"/products\"\n else\n render \"create\"\n end\n end", "def review_params\n params.require(:review).permit(:content, :rating)\n end", "def create \n @refrigerator = Refrigerator.find(params[:refrigerator_id])\n @review = Review.create(create_update_params)\n @refrigerator.reviews << @review\n\n if @review.save!\n\n flash[:notice] = 'Review successfully created.'\n redirect_to refrigerator_path(params[:refrigerator_id])\n else\n flash[:notice] = 'Could not create new review.'\n redirect_to (new_refrigerator_review_path(@refrigerator))\n end\n end", "def review\n @users = User.all\n @review = Review.new\n end", "def create\n @review = Review.new(params[:review])\n @review.user = current_user\n\n respond_to do |format|\n if @review.save\n flash[:notice] = 'Review was successfully created.'\n format.html { redirect_to(@review) }\n format.xml { render :xml => @review, :status => :created, :location => @review }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @review.errors, :status => :unprocessable_entity }\n end\n end\n end", "def review_params\n params.require(:review).permit(:rating, :comment)\n end", "def review_params\n params.require(:review).permit(:rating, :comment)\n end", "def review_params\n params.require(:review).permit( :description, :rating)\n end", "def create\n @review = Review.new(params[:review])\n\n if @review.save\n redirect_to contact_path, :notice => \"Uw waardering is geplaatst, hartelijk dank!\"\n else\n\t\t\tredirect_to contact_path, :notice => \"Uw waardering kan op dit moment niet geplaatst worden, probeer het later nog eens.\"\n end\n end", "def index\n @reviews = Review.all\n \n end", "def review_params\n params.require(:review).permit(:score, :confidence, :comments, :paper_id)\n end", "def review_params\n params.require(:review).permit(:lecture_id, :user_id, :content, :rating)\n end" ]
[ "0.7576602", "0.75637454", "0.7493771", "0.747111", "0.747111", "0.747111", "0.7300367", "0.72989565", "0.7201945", "0.7201945", "0.71795744", "0.717838", "0.71406734", "0.7120858", "0.7118763", "0.7002209", "0.6988962", "0.6979939", "0.69722533", "0.69606304", "0.6958055", "0.6953352", "0.6946341", "0.6917387", "0.6896529", "0.689131", "0.684411", "0.68377984", "0.6826352", "0.68095565", "0.6805745", "0.68000114", "0.6756741", "0.6750588", "0.6718385", "0.6698959", "0.6666458", "0.6655321", "0.66511434", "0.6650238", "0.66481405", "0.6643257", "0.66334975", "0.6632171", "0.6625182", "0.6617069", "0.6616355", "0.6614021", "0.65939176", "0.6578096", "0.6566304", "0.655079", "0.6537635", "0.65306634", "0.6529929", "0.6526942", "0.6526942", "0.6521888", "0.6516327", "0.65065676", "0.6494446", "0.64794886", "0.6476289", "0.6476289", "0.6476289", "0.6476289", "0.6476289", "0.6476289", "0.6471607", "0.6462259", "0.6460475", "0.64579177", "0.6457529", "0.6450494", "0.64474744", "0.6443972", "0.6440192", "0.642906", "0.64266014", "0.6419717", "0.64197063", "0.641245", "0.641245", "0.641063", "0.6410248", "0.640811", "0.640109", "0.64005774", "0.6394809", "0.6391521", "0.6385833", "0.6378832", "0.6370554", "0.6365557", "0.6365557", "0.6360124", "0.63526964", "0.63338596", "0.6333214", "0.63185745" ]
0.64110076
83
overridden Devise method that checks the soft delete timestamp on authentication
def active_for_authentication? super && !deactivated_at end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def active_for_authentication? \n super && !deleted_at \n end", "def active_for_authentication? \n super && !deleted_at \n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication? \n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n\t\tsuper && !deleted_at\n\tend", "def active_for_authentication? \n super && !is_deleted \n end", "def active_for_authentication?\n super and not self.deleted?\n end", "def active_for_authentication?\n super && !delete_flag\n end", "def active_for_authentication?\n super && !deleted?\n end", "def active_for_authentication?\n super && !deleted?\n end", "def active_for_authentication?\n super && !deleted?\n end", "def active_for_authentication?\n super && !delete_flag?\n end", "def active_for_authentication?\n \tsuper && !delete_flag\n end", "def soft_delete\n\t\tupdate_attribute(:deleted_at, Time.current)\n\tend", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def active_for_authentication?\n super && !deleted_at && self.enabled?\n end", "def soft_delete \n update_attribute(:deleted_at, Time.current) \n end", "def soft_delete \n update_attribute(:deleted_at, Time.current) \n end", "def active_for_authentication? \n raise ErrorHandling::Errors::User::DeletedUser.new(deleted_at: deleted_at) if deleted_at? \n return true\n end", "def soft_delete\n update_attribute(:delete_flag, Time.current)\n end", "def soft_delete\n update_attribute(:deactivated_at, Time.current)\n update_attribute(:encrypted_api_secret_key, '')\n end", "def is_safe_deleted?\n return !self.deleted_at.nil?\n end", "def soft_delete\n ActiveRecord::Base.record_timestamps = false\n self.deleted_at = Time.now\n self.save\n ActiveRecord::Base.record_timestamps = true\n end", "def user_can_delete?\n false\n end", "def before_soft_delete\n return self.soft_deletable?\n end", "def soft_delete\n transaction do\n before_soft_delete if respond_to?(:before_soft_delete)\n result = if is_a?(Claim::BaseClaim)\n update_attribute(:deleted_at, Time.zone.now)\n else\n update(deleted_at: Time.zone.now)\n end\n after_soft_delete if respond_to?(:after_soft_delete)\n result\n end\n end", "def authorized_for_delete?\n return !self.is_default?\n end", "def active_for_authentication?\n super && !deleted? && approved?\n end", "def active_for_authentication?\n super && !deleted? && approved?\n end", "def soft_deleted?\n mark_as_deleted\n end", "def soft_delete!\n update_attribute(:mark_as_deleted, true)\n end", "def soft_delete(at = Time.zone.now)\n update_attribute(:deleted_at, at)\n end", "def before_destory\n if User.count(:all, :conditions => [\"is_superuser = 1 and active = 1\"]) <= 1\n errors.add_to_base \"Cannot delete #{self.username.upcase} because it is the last admin user\"\n return false\n else\n return true\n end\n end", "def active_for_authentication?\n super && !disabled_at\n end", "def not_active_on_create!\n self.deleted_at ||= Time.zone.now\n end", "def after_soft_delete; end", "def verify_signed_out_user; end", "def verify_signed_out_user; end", "def verify_signed_out_user; end", "def destroy\n log_record('users/delete', current_user.id)\n super\n end", "def before_destroy\n # can_destroyed?\n end", "def before_destroy\n # can_destroyed?\n end", "def before_destroy\n # can_destroyed?\n end", "def before_destroy\r\n errors.add(:base, I18n.t(\"activerecord.errors.models.user.self_delete\")) if current_user_id == self.id\r\n errors.add(:base, I18n.t(\"activerecord.errors.models.user.delete\")) if User.count == 1\r\n errors.blank?\r\n end", "def delete\n Authentication.where(user_id: id).each { |auth| auth.delete }\n super\n end", "def create\n super\n # delete_expired_tokens\n end", "def ensure_active\n run_callbacks(:destroy) do\n update_attribute(:deleted_at, nil)\n end\n end", "def delete\n user = getUserByAuthToken(request)\n user.soft_delete\n head :no_content\n end", "def destroy\n signed_out_user = current_user\n sign_out :user\n session.try(:delete, :_csrf_token)\n # Prevent Token Fixation attacks by generating a new token upon user logout.\n signed_out_user.authentication_token = Devise.friendly_token\n signed_out_user.save\n super\n end", "def enforce_delete_permissions\n enforce_edit_permissions\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def mark_as_deleted(current_user)\n self.is_deleted = true\n self.deleted_at = Time.now\n self.deleted_by_id = current_user.id\n self.save\n end", "def destroy\n update_attribute(:deleted_at, Time.now)\n end", "def before_destroy\n if public?\n errors.add_to_base _('Public user cannot be deleted.')\n end\n if last_admin?\n errors.add_to_base _(\"Cannot delete. User '{{username}}' is the last available admin.\", :username => username)\n end\n if current?\n errors.add_to_base _('You cannot delete your own account.')\n end\n errors.empty?\n end", "def authorized_for_destroy?\n current_user.es_admin?\n end", "def super_active_users_retention\n \n end", "def soft_delete\n self.active = false\n save\n end", "def destroy\n before_action :authenticate_user\n @user.destroy\n end", "def active_for_authentication?\n super && !expired?\n end", "def delete_user\n end", "def session_check\n return if (t_last = last_operation_time).zero?\n return if (t_boot = BOOT_TIME.to_i) < t_last\n __debug { \"last_operation_time #{t_last} < BOOT_TIME #{t_boot}\" }\n Log.info { \"Signed out #{current_user&.to_s || 'user'} after reboot.\" }\n local_sign_out\n end", "def authorized_for_destroy?\n return false unless current_user && current_user.is_admin_type?\n end", "def verify_signed_out_user\n end", "def inactive_message \n !deleted_at ? super : :deleted_account \n end", "def owner_deleted?\n !!User.with_deleted.find_by_id(user_id).try(:deleted?)\n end", "def verify_signed_out_user\n end", "def verify_signed_out_user\n end" ]
[ "0.7789174", "0.7789174", "0.76794314", "0.7674369", "0.7647149", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.7403961", "0.7360637", "0.7151867", "0.71252936", "0.7078617", "0.7078617", "0.7078617", "0.70562184", "0.7047073", "0.68803304", "0.6880122", "0.68476474", "0.68379575", "0.6824666", "0.6824666", "0.6824666", "0.6824666", "0.6824666", "0.6824666", "0.6824666", "0.6824666", "0.68094784", "0.6780404", "0.6780404", "0.6778841", "0.67516726", "0.6636623", "0.6533752", "0.6500858", "0.64836967", "0.6413171", "0.6338886", "0.63098335", "0.62534773", "0.62534773", "0.61765397", "0.6143122", "0.61066216", "0.6065545", "0.6020543", "0.60143006", "0.601047", "0.59526837", "0.59526837", "0.59526837", "0.5922973", "0.59047633", "0.59047633", "0.59047633", "0.58956647", "0.58900493", "0.588173", "0.58616996", "0.58599705", "0.5859148", "0.580422", "0.5780556", "0.5780556", "0.5780556", "0.5774439", "0.5758359", "0.57457423", "0.57394785", "0.5717532", "0.5701477", "0.5689564", "0.5684841", "0.5675193", "0.56706756", "0.56669974", "0.5664119", "0.5663969", "0.5662569", "0.5638583", "0.5638583" ]
0.6381492
55
The AI serve multiple purpose, it can assume the role of both player (one at the time)
def initialize @possible = ["red", "red", "red", "red", "blue", "blue", "blue", "blue", "yellow", "yellow", "yellow", "yellow", "green", "green", "green", "green", "magenta", "magenta", "magenta", "magenta", "cyan", "cyan", "cyan", "cyan"] @possible_solution = Array.new @possible_score = {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def played_by?(username)\n @first_player.name == username || @second_player.name == username\n end", "def switch_players\n \n if @current_asker == @player1\n @current_asker = @player2\n @current_responder = @player1\n else\n @current_asker = @player1\n @current_responder = @player2\n end\n\n end", "def affichage_player\n\n\n end", "def played_by_users?(username1, username2)\n played_by?(username1) && played_by?(username2)\n end", "def swap_role\n if role == \"player\"\n update! role: \"observer\"\n elsif role == \"observer\"\n update! role: \"player\"\n end\n end", "def assign_role(role)\n if role == 'cm'\n @player = 'codemaker'\n @computer = 'codebreaker'\n announce_role\n elsif role == 'cb'\n @player = 'codebreaker'\n @computer = 'codemaker'\n announce_role\n else\n puts \"Invalid Selection. Either choose 'cb' or 'cm'.\"\n choose_role\n end\n end", "def confirmed_by(username)\n self.confirm1 if @first_player.name == username\n self.confirm2 if @second_player.name == username\n end", "def switch_players \n @active_player, @inactive_player = @inactive_player, @active_player\n end", "def execute actor, target=[nil]\n def himher thing\n multiple = thing.count > 1 \n\n if multiple \n return \"them\"\n end\n\n case thing[0]\n when Player then \"him\"\n when ItemFacade then \"it\"\n else \"\"\n end\n end\n room_msg, self_msg, vict_msg = @ofound.dup, @found.dup, @tfound.dup\n\n\n if target.include?(actor) # if they're the same person then it's an auto\n target = [actor]\n room_msg = @oauto.dup\n self_msg = @auto.dup\n vict_msg = nil\n elsif target[0] == nil\n room_msg = @onoarg.dup\n self_msg = @noarg.dup\n vict_msg = nil\n end\n room_msg.gsub!(\"$n\", \"<%=other.peek(actor)%>\")\n room_msg.gsub!(\"$N\", \"<%=other.peek(if arg[0].include?(other) then arg[0]-[other]+['You'] else arg[0] end)%>\")\n room_msg.gsub!(\"$m\", himher([actor]))\n room_msg.gsub!(\"$M\", himher(target))\n\n self_msg.gsub!(\"$M\", himher(target))\n self_msg.gsub!(\"$m\", himher([actor]))\n if target\n self_msg.gsub!(\"$N\", actor.peek(target))\n end\n actor.view(\"#G\"+self_msg+\"#n\" + ENDL)\n \n room_msg.untaint\n if target[0]\n if target.count > 1 \n actor.in_room.display([:visual, \"other.can_see?(actor) || other.can_see?(arg[0])\"], actor, [actor], \"#G\"+room_msg+\"#n\", target)\n else\n actor.in_room.display([:visual, \"other.can_see?(actor) || other.can_see?(arg[0])\"], actor, [actor, *target], \"#G\"+room_msg+\"#n\", target)\n target.each do |one_targ|\n vm = vict_msg.dup\n vm.gsub!(\"$n\", one_targ.peek(actor))\n one_targ.view(\"#G\"+vm+ \"#n\" + ENDL)\n end\n end\n else\n puts room_msg\n actor.in_room.display([:visual, \"other.can_see?(actor)\"], actor, [actor], \"#G\"+room_msg+\"#n\", \"\")\n end\n end", "def one_round\n player1_weapon = get_player_one_weapon\n player2_weapon = get_player_two_weapon\n return winner?(player1_weapon,player2_weapon)\nend", "def switch_players(player_one, player_two)\n self.current_player = current_player == player_one ? player_two : player_one\n\n end", "def opponent_of(the_player)\n the_player == player_1 ? player_2 : player_1\n end", "def switch_players\n @current_player, @other_player = @other_player, @current_player\n end", "def switch_players\n @current_player, @other_player = @other_player, @current_player\n end", "def opponent(player)\n (player == player_one) ? player_two : player_one\n end", "def leader?\n if self.role and self.role < 2 \n true\n end\n end", "def game_engine\n\t\tif @ai_on == true\n\t\t\tgame_with_ai\n\t\telse\n\t\t\t@player_two = 'black'\n\t\t\tgame_with_two_players\n\t\tend\n\t\tannounce_winner\n\t\tend_of_game\n\tend", "def switch_players\n if @current_player.name == @player1.name\n @current_player = @player2\n @other_player = @player1\n else \n @current_player = @player1\n @other_player = @player2\n end\n return\n end", "def switch_players\n @player1_turn = !@player1_turn\n end", "def switch_players!\n if current_player==player1\n @current_player=player2\n else\n @current_player=player1\n end\n end", "def victor\n return @attack_initiator if @attack_initiator.soldiers_alive.count > 0\n return @other_army if @other_army.soldiers_alive.count > 0\n end", "def ai_action()\n # sleep 3\n player = get_player(self.current_player)\n action_info = ai_one_logic(player)\n if player.ai == \"2\"\n action_info = ai_two_logic(player)\n end\n action(action_info[0], action_info[1], player.id) # this progresses current player and may progress round\n self.save\n end", "def two_players\n\n if go_first? == true\n game = Game.new(Players::Human.new(\"X\"), Players::Human.new(\"O\"))\n game.play\n\n else\n game = Game.new(Players::Human.new(\"O\"), Players::Human.new(\"X\"))\n game.play\n end # inner if\n end", "def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end", "def second_player\n singles_player_of_team second_team\n end", "def winner\n return self.player_a_pyre_end_health <= 0 ? :player_b : :player_a\n end", "def give_point\n if@current_player == @player1\n @p1_score += 1\n else\n @p2_score += 1\n end\nend", "def players_allowed_to_play\n return if self.manager.nil? || self.players.nil?\n\n self.players.each do |p|\n unless p.tournaments.include? self.manager\n errors.add(:match, \"players must be in same tournament as match\")\n end\n end\n end", "def exclusive_play\n if(player2_move == player1_move)\n self.errors.add(:player1_move, \" only one player can play a move\")\n end\n end", "def switch_players\n temp = @current_player\n @current_player = @opposing_player\n @opposing_player = temp\n end", "def player_1_actual\n unless self.player_1_id == nil || User.all.include?(self.player_1)\n errors.add(:no_player_1, \"Sorry, Player 1 is not a user we recognise.\") \n end\n end", "def solo?\n self.participant_role == 'soloist'\n end", "def change_player\n\t\tif @current_player == @player1\n\t\t\t@current_player = @player2\n\t\t\t@opponent_player = @player1\n\t\telse\n\t\t\t@current_player = @player1\n\t\t\t@opponent_player = @player2\n\t\tend\n\tend", "def game_with_two_players\n\t\t@current_turn = @player_one if @current_turn == false\n\t\tuntil check_or_checkmate(@current_turn) == \"CHECKMATE\"\n\t\t\tmove\n\t\t\tif @current_turn == @player_one\n\t\t\t\t@current_turn = @player_two\n\t\t\telsif @current_turn == @player_two\n\t\t\t\t@current_turn = @player_one\n\t\t\tend\n\t\t\tclear_screen\n\t\tend\n\tend", "def change_turns\n (@current_player == @p1) ? @current_player = @p2 : @current_player = @p1\n end", "def switch_player\n @act_p = @act_p.id == 0 ? self[1] : self[0]\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 player_rdy(color, player2_color: :black, player_name: \"Player 1\", player2_name: \"Player 2\", ai_level: nil, role: 0)\n MenuControllerContracts.invariant(self)\n if ai_level == nil\n if role == 0\n @game_state_model::players.push(Models::RealPlayer.new(1, color, @game_state_model::name))\n @game_state_model::players.push(Models::RealPlayer.new(2, 'black', player2_name))\n elsif role == 1\n @game_state_model::players.push(Models::RealPlayer.new(1, 'green', player2_name))\n @game_state_model::players.push(Models::RealPlayer.new(2, color, @game_state_model::name))\n end\n else\n @game_state_model::players.push(Models::RealPlayer.new(1, color, player_name))\n if @game_state_model::game_type == :classic\n @game_state_model::players.push(Models::AIPlayer.new(2, 'black', GameLogic::ClassicAI.new(@game_state_model, ai_level), \"Roboto\"))\n else\n @game_state_model::players.push(Models::AIPlayer.new(2, 'black', GameLogic::OttoAI.new(@game_state_model, ai_level), \"Roboto\"))\n end\n end\n @window.start_game\n MenuControllerContracts.invariant(self)\n end", "def winner\n player_alive?(Player1) ? Player1 : Player2\n end", "def role_for_object(object)\n # Order is important here as captains may change some but NOT all things via mass update\n if object.is_a?(Match) && (self.captained_teams.include?(object.home_participant) || self.captained_teams.include?(object.away_participant))\n :captain\n elsif Permissions.can_edit? object\n :admin\n else\n :default\n end\n end", "def switch_player()\n\t\tif $current_player == @player1\n\t\t\t$current_player = @player2\n\t\telse \n\t\t\t$current_player = @player1\n\t\tend \n\tend", "def announce_role\n if @player == 'codebreaker'\n puts\n puts 'You are the CODEBREAKER!'\n elsif @player == 'codemaker'\n puts\n puts 'you are the CODEMAKER!'\n end\n Pattern.new(@computer, @player)\n end", "def switch_player\n if @active_player == @player1\n @active_player = @player2\n else\n @active_player = @player1\n end\n end", "def outcome\n if (pl_high? || session[:dealer].bust?) && !session[:player].bust?\n outcome = :player\n elsif session[:player].blackjack? && !session[:dealer].blackjack?\n outcome = :blackjack\n session[:player].qualities << \"lucky\"\n elsif push?\n outcome = :push\n else\n outcome = :dealer\n end\n outcome\n end", "def opponent\n @player == :human ? :computer : :human\n end", "def set_players(player1, player2)\n @p1, @p2 = player1, player2\n (@p1.starts) ? @current_player = @p1 : @current_player = @p2\n end", "def determine_winner(p1, p2)\n p1.acquire_move(@rules)\n p2.acquire_move(@rules)\n @rules.winner_of_game(p1, p2)\n end", "def playerTurn\n if @current_player == @player1\n @current_player = @player2\n else \n @current_player = @player1\n end\n return @current_player\n end", "def winner player1, player2\n player1.health > player2.health ? player1 : player2\n end", "def current_player\n if turn_count.even?\n player_1\n else\n player_2\n end\n end", "def random_role\n ['admin', 'player'].sample\n end", "def current_player\n self.board.turn_count.even?? self.player_1 : self.player_2\n end", "def handle_winner(p1,p2)\n winner = winner?(p1,p2)\n if winner == p1\n give_cards_to_winner(p1, p2)\n p1.take_own_hand\n elsif winner == p2\n give_cards_to_winner(p2, p1)\n p2.take_own_hand\n end\n end", "def switch_player\nif @player == PIECE[:x]\n@player = PIECE[:o]\nelse\n@player = PIECE[:x]\nend\nend", "def next_of current_player\n \t\tif current_player == self.player \n self.robot\n else\n self.player\t\n end\n \tend", "def winner\n if type == :basic\n if get_rank(@player1, 0) > get_rank(@player2, 0)\n @player1\n else\n @player2\n end\n elsif type == :war\n if get_rank(@player1, 2) > get_rank(@player2, 2)\n @player1\n else\n @player2\n end\n elsif type == :mutually_assured_destruction\n 'No Winner'\n end\n end", "def choice_acquisition\n if @player_role_selection == 'breaker'\n @proposed_code = player_choice_acquisition\n elsif @player_role_selection == 'maker'\n @proposed_code = computer_choice_acquisition\n end\n puts \"Playing #{@proposed_code}\"\n end", "def player_lives(player)\n player == 1 ? @player_1_lives : @player_2_lives\nend", "def initialize\n @player1 = Player.new(\"Player 1\")\n @player2 = Player.new(\"Player 2\")\n @player1_turn = true; # true -> player1's turn, false -> player2's turn\n end", "def deuce?\n @player1.points == 3 && @player2.points == 3\n end", "def Winner?(player)\r\n end", "def initialize\n @player1 = Player.new\n @player2 = Player.new\n\n @player1.opponent = @player2\n @player2.opponent = @player1\n end", "def play_for_trick \n if @player1.deal == true && @player2.deal == false && !@player1.hand.empty?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player1.lead_card\n @player1.remove_card_from_hand(leading_card)\n puts @player1.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player2.respond(leading_card)\n @player2.remove_card_from_hand(response_card)\n puts @player1.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player2.name + \" plays the \" + response_card.card_to_string\n \n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n if winning_card == leading_card \n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n else\n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n\n if @player1.deal == false && @player2.deal == true && !@player2.hand.empty?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player2.lead_card\n @player2.remove_card_from_hand(leading_card)\n puts @player2.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player1.respond(leading_card)\n @player1.remove_card_from_hand(response_card)\n puts @player2.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player1.name + \" plays the \" + response_card.card_to_string\n\n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n\n if winning_card == leading_card \n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n else\n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n end", "def invited_or_captain\n self.captain || invited?\n end", "def random_player \n\t\tsalida_aleatoria = rand(1..3)\n\t\tsalida_aleatoria\n\tend", "def result\n if victory? == @player1 || victory? == @player2\n puts \"Congratulations #{victory?.name}, you won!\"\n puts \" \"\n puts '╭━━━┳━╮╱╭┳━━━╮╭━━━┳━━━╮╭━━━┳━━━┳━╮╭━┳━━━╮\n ┃╭━━┫┃╰╮┃┣╮╭╮┃┃╭━╮┃╭━━╯┃╭━╮┃╭━╮┃┃╰╯┃┃╭━━╯\n ┃╰━━┫╭╮╰╯┃┃┃┃┃┃┃╱┃┃╰━━╮┃┃╱╰┫┃╱┃┃╭╮╭╮┃╰━━╮\n ┃╭━━┫┃╰╮┃┃┃┃┃┃┃┃╱┃┃╭━━╯┃┃╭━┫╰━╯┃┃┃┃┃┃╭━━╯\n ┃╰━━┫┃╱┃┃┣╯╰╯┃┃╰━╯┃┃╱╱╱┃╰┻━┃╭━╮┃┃┃┃┃┃╰━━╮\n ╰━━━┻╯╱╰━┻━━━╯╰━━━┻╯╱╱╱╰━━━┻╯╱╰┻╯╰╯╰┻━━━╯\n ╭━━━┳╮╱╱╭━━━┳╮╱╱╭╮╭━━━┳━━━┳━━━┳━━┳━╮╱╭┳━━━╮\n ┃╭━╮┃┃╱╱┃╭━╮┃╰╮╭╯┃┃╭━╮┃╭━╮┃╭━╮┣┫┣┫┃╰╮┃┃╭━╮┃\n ┃╰━╯┃┃╱╱┃┃╱┃┣╮╰╯╭╯┃┃╱┃┃┃╱╰┫┃╱┃┃┃┃┃╭╮╰╯┣╯╭╯┃\n ┃╭━━┫┃╱╭┫╰━╯┃╰╮╭╯╱┃╰━╯┃┃╭━┫╰━╯┃┃┃┃┃╰╮┃┃╱┃╭╯\n ┃┃╱╱┃╰━╯┃╭━╮┃╱┃┃╱╱┃╭━╮┃╰┻━┃╭━╮┣┫┣┫┃╱┃┃┃╱╭╮\n ╰╯╱╱╰━━━┻╯╱╰╯╱╰╯╱╱╰╯╱╰┻━━━┻╯╱╰┻━━┻╯╱╰━╯╱╰╯'\n else\n puts \"Too bad! Tied game...\"\n puts \" \"\n puts '╭━━━┳━╮╱╭┳━━━╮╭━━━┳━━━╮╭━━━┳━━━┳━╮╭━┳━━━╮\n ┃╭━━┫┃╰╮┃┣╮╭╮┃┃╭━╮┃╭━━╯┃╭━╮┃╭━╮┃┃╰╯┃┃╭━━╯\n ┃╰━━┫╭╮╰╯┃┃┃┃┃┃┃╱┃┃╰━━╮┃┃╱╰┫┃╱┃┃╭╮╭╮┃╰━━╮\n ┃╭━━┫┃╰╮┃┃┃┃┃┃┃┃╱┃┃╭━━╯┃┃╭━┫╰━╯┃┃┃┃┃┃╭━━╯\n ┃╰━━┫┃╱┃┃┣╯╰╯┃┃╰━╯┃┃╱╱╱┃╰┻━┃╭━╮┃┃┃┃┃┃╰━━╮\n ╰━━━┻╯╱╰━┻━━━╯╰━━━┻╯╱╱╱╰━━━┻╯╱╰┻╯╰╯╰┻━━━╯\n ╭━━━┳╮╱╱╭━━━┳╮╱╱╭╮╭━━━┳━━━┳━━━┳━━┳━╮╱╭┳━━━╮\n ┃╭━╮┃┃╱╱┃╭━╮┃╰╮╭╯┃┃╭━╮┃╭━╮┃╭━╮┣┫┣┫┃╰╮┃┃╭━╮┃\n ┃╰━╯┃┃╱╱┃┃╱┃┣╮╰╯╭╯┃┃╱┃┃┃╱╰┫┃╱┃┃┃┃┃╭╮╰╯┣╯╭╯┃\n ┃╭━━┫┃╱╭┫╰━╯┃╰╮╭╯╱┃╰━╯┃┃╭━┫╰━╯┃┃┃┃┃╰╮┃┃╱┃╭╯\n ┃┃╱╱┃╰━╯┃╭━╮┃╱┃┃╱╱┃╭━╮┃╰┻━┃╭━╮┣┫┣┫┃╱┃┃┃╱╭╮\n ╰╯╱╱╰━━━┻╯╱╰╯╱╰╯╱╱╰╯╱╰┻━━━┻╯╱╰┻━━┻╯╱╰━╯╱╰╯'\n end\n end", "def play(p1_choice,p2_choice)\n if p1_choice == \"rock\"\n if p2_choice == \"paper\"\n self.winner_id = p2_choice.id\n elsif p2_choice == \"scissor\"\n self.winner_id = p1_choice.id\n end\n\n return winner_id\n end\n\n if p1_choice == \"paper\"\n if p2_choice == \"rock\"\n return @winner_id = p1_choice.id\n elsif p2_choice == \"scissor\"\n return @winner_id = p2_choice.id\n else\n return @winner_id\n end\n end\n\n if p1_choice == \"scissor\"\n if p2_choice == \"rock\"\n return @winner_id = p2_choice.id\n elsif p2_choice == \"paper\"\n return @winner_id = p1_choice.id\n else\n return @winner_id\n end\n end\n\n\n # plays game\n # return either p1_choice or p2_choice winner\n end", "def winner\n\t\tvictor = false\n\t\tvictor = \"Player1\" unless @board.on_board? player2.tokens[-1][0].position\n\t\tvictor = \"Player2\" unless @board.on_board? player1.tokens[-1][0].position\n\t\tvictor\n\tend", "def player_wins(player1_action, player2_action)\n if ((player1_action == \"R\" and player2_action == \"S\") or\n (player1_action == \"S\" and player2_action == \"P\") or\n (player1_action == \"P\" and player2_action == \"R\"))\n return true\n end\nend", "def current_player\n\tif $turn == 0\n\t\tplayerone\n\telse\n\t\tplayertwo\n\tend\nend", "def two_player_mode\nend", "def players_choose\n @p1_game_move = @player1.p1_moves\n @p2_game_move = @player2.p2_moves\n puts \"#{@player1.name} chooses: #{@p1_game_move}\\n\" + \"#{@player2.name} chooses: #{@p2_game_move}\"\n end", "def orchestre1\n player1 = Player.new(\"Josiane\")\n player2 = Player.new(\"José\")\n while player1.life_points > 0 && player2.life_points > 0\n puts \"\" \n puts \"Voici l'état de chaque joueur :\"\n puts \"#{player1.show_state} #{player2.show_state}\"\n puts \"\"\n puts \"Fight ! Passons à la phase d'attaque\"\n player1.attacks(player2)\n if player2.life_points <= 0\n break\n else\n player2.attacks(player1)\n end\n end\n if player2.life_points<= 0\n player2.show_state\n else \n player1.show_state\n end\n puts \"Fin du fight\"\nend", "def advantage?\n @player1.points >= 4 && @player1.points == (@player2.points + 1) ||\n @player2.points >= 4 && @player2.points == (@player1.points + 1)\n end", "def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end", "def find_winner\n if @player_1.life == 0\n return 2\n end\n return 1\n end", "def assign_roles_to_players(players={})\n roles.keys.each do |rolekey|\n assign_role_to_player(rolekey, players[rolekey])\n end\n end", "def admin_assistant?\n if self.role and self.role < 3 \n true\n end\n end", "def change_player \n if @current_player == 0\n @current_player = 1\n elsif @current_player == 1\n @current_player = 0\n end\n end", "def is?(rololo)\n role == rololo\n end", "def assign_enemy\n\t\t@has_enemy = rand(1..2)==1 ? true : false\n\t\t#need an enemy value for the room.\n\tend", "def opponent(match, user_id)\n match.winner_id == user_id ? match.loser : match.winner\n end", "def play_game\nget_winner(comp_choose_rps,user_choose_rps)\t\nend", "def current_player #player 1 goes first because 0 is even. so first turn is player 1, second is player 2, 3rd is player 1\n @board.turn_count.even? ? @player_1 : @player_2\n end", "def alternate_player(crt_player)\n if crt_player == 'PLR'\n return 'CPU'\n elsif crt_player == 'CPU'\n return 'PLR'\n end\n end", "def change_current_player\n current_player == player_1 ? @current_player = @player_2 : @current_player = @player_1\n end", "def player_action\n @players.each{ |p|\n linebreak('-')\n p.hands.each_with_index{ |hand, index|\n hit = true\n double = p.wallet >= hand.bet\n while hit\n splittable = hand.pair? && p.wallet >= hand.bet\n status(p)\n hit, split = player_decision(p, hand, index, double, splittable)\n double = false unless split\n linebreak\n end\n }\n }\n end", "def earn_point(player)\n player ==1 ? @player_2_wins += 1 : @player_1_wins +=1\nend", "def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end", "def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end", "def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end", "def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end", "def initialize(user_id1, user_id2)\n super() # NOTE: This *must* be called, otherwise states won't get initialized\n @first_player, @second_player = Player.new(user_id1), Player.new(user_id2)\n end", "def opponent\n\t\thomeaway=='H' ? self.contest.awaycontestant : self.contest.homecontestant\n\tend", "def game_over?\n (@player1.lives == 0) || (@player2.lives == 0)\n end", "def current_player\n @board.turn_count.even? ? @player_1 : @player_2\n\n end", "def authenticate_agent(rank, name, credentials)\n if (rank == \"007\" && name == \"James Bond\") || credentials == \"Secret Agent\"\n puts \"Access granted #{rank}, please proceed to the Intelligence Department\"\n else\n puts \"Access Denied\"\n end \nend", "def player; end", "def player; end", "def player; end", "def player; end" ]
[ "0.6530433", "0.6422845", "0.62878066", "0.62067527", "0.6203622", "0.6189053", "0.61464787", "0.6145142", "0.61423403", "0.61257845", "0.6099792", "0.6090982", "0.60865784", "0.60865784", "0.6071835", "0.60284823", "0.60090196", "0.6002437", "0.59999555", "0.59967315", "0.5992671", "0.5985957", "0.5985471", "0.5984501", "0.59714055", "0.59260434", "0.59227306", "0.5920436", "0.5915023", "0.59055793", "0.5893464", "0.5886728", "0.58849937", "0.5884367", "0.5877653", "0.5872896", "0.5872543", "0.584962", "0.584343", "0.58314866", "0.58219886", "0.5818684", "0.58110714", "0.57980055", "0.57964194", "0.5793545", "0.57858175", "0.5782123", "0.57818055", "0.57488596", "0.57471603", "0.5744199", "0.5742358", "0.57419133", "0.5740298", "0.5739286", "0.5738822", "0.5730069", "0.5721775", "0.5716161", "0.5714594", "0.5710105", "0.5708931", "0.5694126", "0.5686054", "0.56828725", "0.56820047", "0.5681641", "0.5677934", "0.5666038", "0.56622076", "0.5643427", "0.56347895", "0.5629442", "0.56213164", "0.56140393", "0.56127495", "0.56079817", "0.56052846", "0.56018656", "0.55967665", "0.55894494", "0.55861014", "0.5584879", "0.55825996", "0.55764484", "0.55747706", "0.5566306", "0.55649185", "0.55649185", "0.55649185", "0.55649185", "0.5563878", "0.5561609", "0.5560731", "0.55577815", "0.5553334", "0.55509734", "0.55509734", "0.55509734", "0.55509734" ]
0.0
-1
Serve the Ai playing the CodeMaker to choose a code.
def choose_code @code = [] 4.times do @code.push($possible_color[(rand(0..5))]) end @code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_code \n puts \"\\nYou have chosen to be the new CodeBreaker!\\nNow wait for me to create a code for you to crack \"\n @code = @role.random_code\n end", "def play_again\n begin\n _call = direction\n if _call.present?\n applet = \"{\\\"select\\\":\\\"#{_call.play_again(params)}\\\"}\" if defined?(_call.play_again)\n end\n rescue => e\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n end\n render :plain => applet, content_type: \"text/html\", :status => 200\n end", "def new_serve(server)\n\t\t\tputs \" \"\n\t\t\tputs \">>>>>>>>>>>>> #{$hitter} serves the ball >>>>>>>>>>>>>>>\"\n\t\t\tputs \"hit any letter to continue 'q' to quit.\"\n\t\t\tputs \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n\t\t\tresult = gets.chomp.downcase\n\t\t\t\n\t\t\tif result == 'q'\n\t\t \tputs \"exiting game\"\n\n\t\t\telse\n\t\t\t\tself.rally\n\t\t\tend\n\t\tend", "def input_code\n if @human\n print 'Bitte gib deinen Tipp ab:'\n code = []\n gets.chomp.split(/ ?/).each { |e| code << e.to_i }\n @code = code\n else\n puts 'Ich denke...'\n sleep(0.5)\n @code = generate\n end\n end", "def fetch_from_code(code)\n client.code = code\n fetch_and_write\n end", "def choice_acquisition\n if @player_role_selection == 'breaker'\n @proposed_code = player_choice_acquisition\n elsif @player_role_selection == 'maker'\n @proposed_code = computer_choice_acquisition\n end\n puts \"Playing #{@proposed_code}\"\n end", "def choose_role\n puts \"Press 1 to be the Codebreaker or 2 to be the Codemaker\"\n input = gets.chomp\n if input == \"1\"\n @maker.random_code\n elsif input == \"2\"\n @maker.set_code\n @breaker.ai = true\n else\n choose_role\n end\n end", "def send_key(code)\n ping player_url+\"/application/sendKey?code=#{CGI::escape(code.to_s)}&#{plex_token}\"\n end", "def code_browse path\n dr = ruby_renderer\n view(path, :close_key => 'q', :title => $0) do |t|\n t.renderer dr\n t.bind_key([?\\\\,?\\\\,?o],'choose file') { \n str = choose_file \"**/*\"\n if str and str != \"\"\n t.add_content str\n t.buffer_last\n else\n alert \"nothing chosen\"\n end\n }\n end\n end", "def Action(code) # Sends a raw Action ID (see key.h)\n success?(parse(cmd(with_args(code))))\n end", "def interactive_generator\n webGui = WebGui.new(\"\")\n webGui.start\nend", "def start_app\n response = show_menu\n response = show_menu while response < 1 || response > 7\n\n case response\n when 1\n list_books\n when 2\n list_people\n when 3\n create_person\n when 4\n create_book\n when 5\n create_rental\n when 6\n list_rentals_for_person_id\n when 7\n puts 'Thank you for using this app!'\n end\n\n puts \"\\n\"\n end", "def show\n\n \t\t\trespond_with @play\n\n \t\tend", "def create_secrete_code\n if @player_role_selection == 'breaker'\n output = computer_code_acquisition\n elsif @player_role_selection == 'maker'\n output = player_choice_acquisition\n end\n output\n end", "def scdisplay(id)\n\thttp = Net::HTTP.new(\"shell-storm.org\", 80)\n\treq = Net::HTTP::Get.new(\"/shellcode/files/shellcode-#{id}.php\", {'User-Agent' => 'Shell-Storm Ruby API - Display'})\n\tres = http.request(req)\n\tcase res\n\twhen Net::HTTPSuccess then\n\t\tputs \"#{HC}#{FGRN}[#{FWHT}*#{FGRN}] Displaying#{FWHT}: http://shell-storm.org/shellcode/files/shellcode-#{id}.php#{FCYN}\"\n\t\tputs res.body.split(\"\\n\")[7..-13].join(\"\\n\").gsub('&quot;', '\"').gsub('&gt;', '>').gsub('&lt;', '<').gsub('&amp;', '&')\n\t\tputs \"#{RS}\"\n\telse\n\t\tputs \"#{HC}#{FRED}Seems we made a bad request somehow#{FWHT}....#{RS}\"\n\t\tputs res.value\n\tend\nend", "def fetch_code_from_url(url)\n code = nil\n server = WEBrick::HTTPServer.new(\n AccessLog: [],\n Logger: WEBrick::BasicLog.new(\n log_file=nil, level=WEBrick::BasicLog::FATAL),\n Port: REDIRECT_PORT,\n )\n # We'll use a condition variable to signal that we've received the code.\n mutex = Mutex.new\n code_notification = ConditionVariable.new\n server.mount_proc(CALLBACK_URI) do\n |req, res|\n code = req.query[\"code\"]\n res.status = 200\n res[\"Content-Type\"] = \"text/plain\"\n res.body = \"Authorization completed, you may close this window now.\"\n mutex.synchronize { code_notification.signal }\n end\n Launchy.open(url)\n # Launch the HTTP server on another thread so it doesn't block\n # the samples and then wait until we have the code to shut down\n # the server and continue.\n server_thread = Thread.new { server.start }\n mutex.synchronize {\n code_notification.wait(mutex)\n server.shutdown\n server_thread.join\n }\n return code\nend", "def play\n\temulate do |emulator|\n\t\temulator.play(self)\n\tend\nend", "def show_snippet\n @clam = Clam.find(params[:id])\n @clam.content_type =~ /^Resource::(.*)$/\n @template = $1 ? $1.downcase : \"octet_stream\"\n\n render :action => \"clam_snippet\", :layout => false\n end", "def run_game\n\t\t# Startup\n\t\tputs \"Welcome to Mastermind: Console Edition!\"\n\n\t\t# Select player or computer\n\t\t@choice = choose_codemaker\n\n\t\tif @choice == 'codemaker'\n\t\t\t@code = record_player_code\n\t\t\tputs \"Thanks! Your code has been stored.\"\n\t\t\tuntil self.game_over?\n\t\t\t\tcomputer_take_turn\n\t\t\tend\n\t\telse \n\t\t\t@code = create_code\n\t\t\tputs \"The computer has chosen a 4-color code.\"\n\t\t\tputs \"While debugging, here is the code: #{@code}\"\n\t\t\tuntil self.game_over?\n\t\t\t\tplayer_take_turn\n\t\t\tend\n\t\tend\n\n\t\tif won_game?\n\t\t\tputs \"Congratulations! You won the game.\"\n\t\telse\n\t\t\tputs \"Sorry, all out of turns. Game over.\"\n\t\tend\n\tend", "def make_code\n\t\tget_colors_from_player MAKE_CODE_PROMPT\n\tend", "def code(url)\n filename = SecureRandom.hex.to_s\n tmp_code_path = \"#{Rails.root}/tmp/#{filename}.gif\"\n output_path = \"#{Rails.root}/tmp/#{filename}\"\n random = V8::Context.new.eval(\"Math.random();\")\n\n response = RestClient.get \"#{url}?#{random}\"\n\n File.open(tmp_code_path, \"wb\") { |file| file.write(response.body) }\n\n code = `python #{Rails.root}/bin/recognize_code.py #{tmp_code_path} #{output_path}`\n\n File.unlink(tmp_code_path)\n\n {\n value: code,\n cookies: response.cookies\n }\n end", "def maker\n show \n end", "def show\n render \"sigCode\"\n end", "def serve\n puts WELCOME\n menu.order_or_not\n # asks the user for input\n # sends that input to choose_to_order case method\n choose_to_order(gets.chomp.to_i)\n end", "def show\n @code = Code.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @code }\n end\n end", "def play socket\n end", "def request_code\n auth_response = auth_request\n action_url = parse_form_action(auth_response)\n cookies = auth_response.cookies\n redirect = send_form_with_code(action_url, cookies)\n parse_code(redirect)\n end", "def browse(number)\n request = get_request_by_number(number)\n Launchy.open(request.html_url)\n end", "def play_game_with_user_as_codemaker\n @display.welcome_message_for_user_as_codemaker\n solve_the_secret_combination\n end", "def play\n end", "def play\n \n end", "def play_codemaker\n @mastermind_code = get_player_code\n # Set up the player to win if the loop terminates wihtout a\n # correct guess.\n @win = true\n # Start out with a recommended guess\n @computer_ai = SimpleAI.new('RROO')\n NUM_TURNS_HARD.times do\n @player_score += 1\n sleep(0.5) # Add time to make it more suspenseful\n if computer_play_turn\n @win = false\n break\n end\n end\n end_game_codemaker\n end", "def play_random_song_from_band(term)\n response = search_itunes(term)\n results = response[\"results\"]\n pick = results.sample\n system(\"open\", pick[\"previewUrl\"]) \nend", "def call(params)\n @item = ItemRepository.find_by_code(params[:code])\n redirect_to @item.content, status: 301\n end", "def play\n\tend", "def start_application\n sleep(1)\n loop do\n puts \"\\nWhat price are you looking for?\"\n input = gets.chomp\n next if input.empty?\n\n @analyzer.process_request(input)\n end\n end", "def set_code\n @code = Code.find(params[:id])\n end", "def set_code\n @code = Code.find(params[:id])\n end", "def set_code\n @code = Code.find(params[:id])\n end", "def set_code\n @code = Code.find(params[:id])\n end", "def set_code\n @code = Code.find(params[:id])\n end", "def set_code\n @code = Code.find(params[:id])\n end", "def set_code\n @code = Code.find(params[:id])\n end", "def code\r\n render :template => 'mxes/code/code' \r\n end", "def cfs_kit_launch_app(screen, app)\n\n\n if (app == \"UPDATE_TUTORIAL\")\n # An exception will report any errors \n if cfs_kit_create_tutorial_screen\n prompt (\"Successfuly created tutorial screen file #{tutorial_scr_file}\\nusing #{tutorial_def_file}\")\n end\n elsif (app == \"PROTO_APPP\")\n #TODO - Investigate generic text table editor or tutorial screen\n\t Cosmos.run_process(\"ruby lib/OskCfeFileViewer -f '/mnt/hgfs/OpenSatKit/cosmos/cfs_kit/file_server/cfe_es_syslog.dat'\")\n\t #Cosmos.run_process(\"ruby lib/OskTxtFileViewer -f '/mnt/hgfs/OpenSatKit/cosmos/test.json'\")\n #require 'osk_tbl_editor'\n #Cosmos.run_process(\"ruby lib/OskTblEditor\")\n\t #require 'cfs_fcx_cmdgen'\n #Cosmos.run_process(\"ruby lib/CfsFcxCmdGen\")\n #Cosmos.run_process(\"ruby tools/ConfigEditor\")\n #Cosmos::OskTblEditor.run\n #Cosmos.run_cosmos_tool('ConfigEditor')\n\n elsif (app == \"TUTORIAL\")\n cfs_kit_launch_tutorial_screen\n end\n\nend", "def display_and_run\n\n # prints the menu name and waits briefly\n @dp.d_print(@menu_name + \":^^\")\n i = 1\n\n # displays the options\n @options.each do |option|\n print(i.to_s + ' ')\n puts(option.get_name)\n i += 1\n end\n\n # prompt and get valid input from the player\n print(@prompt_string)\n action = get_action\n\n # runs the selected action\n action.call :menu_select\n\n # some test code\n print(\"here\")\n end", "def ask_for_action\n @response.gather(numDigits: 1) do |g|\n g.say('To call Julien directly, press 1. To leave a message, press 2.')\n end\n end", "def choseScheme()\n \tscheme = UI.select(\"Select scheme:\", [\"CIASMovie\", \"ZhongDuMovie\", \"BaoShan\", \"HuaChenMovie\", \"HengDian\"])\n\n\tENV[\"SCHEME\"] = scheme\n\tENV[\"APP_ID\"] = ENV[\"APP_ID_#{scheme}\"]\n\n end", "def play\n @selected_slide_key = @interface.current_slide.short_name\n respond_to do |format|\n format.html { render :play, layout: 'etm' }\n format.js\n end\n end", "def show\n head(:ok)\n end", "def welcome_message_for_user_as_codemaker\n puts \"OK, great! You're the codemaker.\"\n puts \"In order to play, you need to think up a secret code with 4 spots.\"\n puts \"The colors you can choose from are: red, blue, green, yellow, purple, and orange.\"\n puts \"Hit enter when you're ready for my first guess!\"\n get_input\n end", "def play()\n @ole.Play()\n end", "def play()\n @ole.Play()\n end", "def select_botgarden_action_code(data_set)\n action = data_set[BOTGARDENCurrentLocationData::ACTION_CODE.name]\n if action\n logger.debug \"Entering action code '#{action}'\"\n action_code_options_locator = input_options_locator([], BOTGARDENCurrentLocationData::ACTION_CODE.name)\n hit_escape\n wait_for_options_and_select(botgarden_action_code_input_locator, action_code_options_locator, action)\n end\n end", "def main_menu\n puts \"------------------------------------------------------------------------------------------------------\".colorize(:yellow)\n Artii::Base#asciify\n a = Artii::Base.new\n a.asciify(\"Toy Robot Challenge\")\n system(\"clear\")\n puts a.asciify(\"Toy Robot Challenge\").colorize(:red,)\n\n prompt = TTY::Prompt.new\n choices = [\n {name: 'New Game.', value: 1},\n {name: 'Exit.', value: 2},\n ]\n players_input = prompt.select(\"Select An Option:\", choices) \n case players_input\n when 1\n new_game\n when 2\n exit\n end \nend", "def play\n end", "def play\n end", "def play\n end", "def play\n end", "def play\n\t\twelcome\n\t\task_name\n\t\task_name2 \n\t\task_input\n\t\tturns\n\tend", "def upload_code\n @type = Atg.load_code_type\n @message = ''\n end", "def choose\n \n end", "def run(code)\n\t\t\t@interpreter.run(code)\n\t\tend", "def pbPlayTrainerIntroME(trainerType)\n data = pbGetTrainerTypeData(trainerType)\n if data && data[6] && data[6]!=\"\"\n bgm = pbStringToAudioFile(data[6])\n pbMEPlay(bgm)\n end\nend", "def show\n @inkpmscode = Inkpmscode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inkpmscode }\n end\n end", "def run_code(code)\n codemirror_send_keys(find('#scratchpad-editor-wrapper'), code)\n find_button('__papyros-run-code-btn', disabled: false).click\n end", "def classic(generator: ClassicApp.new(cli: self))\n app = generator.generate\n say <<~SAY\n\n Success! Created #{app.camelized_name} at #{app.absolute_app_path}\n To get started, type\n\n #{cmd :classic_server, path: (app.underscored_name + \".rb\")}\n\n and visit localhost:4567 in your browser.\n\n SAY\n end", "def kgio_accept()\n #This is a stub, used for indexing\n end", "def serve(options)\n @logger = Logger.new STDERR\n @logger.level = options[:logging] ? Logger::DEBUG : Logger::FATAL\n\n serving_transport = Smartcard::Iso.auto_transport\n unless serving_transport\n @logger.error \"ISO7816 smart-card transport auto-configuration failed\"\n return\n end\n @logger.info \"Proxying to #{serving_transport.inspect}\\n\"\n @logger.info \"Serving with #{options.inspect}\\n\"\n serving_logic = ServingLogic.new serving_transport, options[:logging]\n Smartcard::Iso::JcopRemoteServer.new(options, serving_logic).run\nend", "def main\n # Check that there was an argument supplied to the application\n if ARGV.length > 0\n # Convert the argument to an integer to be used as a port number\n port = ARGV[0].to_i\n if port < 1024 || port > 49151\n puts \"illegal port #{ARGV[0].to_i}: Choose one in range 1024-49151\"\n exit\n end\n else\n # If no port was specified, create a random port number\n port = Random.new.rand(48128) + 1024\n end\n serve port\nend", "def play_random_song_from_band(term)\n response = search_itunes(term)\n results = response[\"results\"]\n pick = results.sample #chose a randome song in the array and put it in variable pick\n system(\"open\", pick[\"previewUrl\"])\nend", "def play\n if (RUBY_PLATFORM == \"java\")\n java_play\n else\n ruby_play\n end\n end", "def show\n @code = Code.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @code }\n end\n end", "def new_access_code\n client.redirect_uri = 'http://giffare.com/callback'\n uri = client.authorization_uri(:scope => [:create_note, :manage_pages])\n puts \"Visit: #{uri}\"\n `open \"#{uri}\"`\n puts \"Get code param and call #from_code with it\"\n end", "def start\n @driver.navigate.to \"http://play.threesgame.com\"\n sleep(0.5)\n end", "def respond code, &block\n application \"respond\", code.to_s, &block\n end", "def pbPlayDecisionSE()\n if $data_system && $data_system.respond_to?(\"decision_se\") &&\n $data_system.decision_se && $data_system.decision_se.name!=\"\"\n pbSEPlay($data_system.decision_se)\n elsif $data_system && $data_system.respond_to?(\"sounds\") &&\n $data_system.sounds && $data_system.sounds[1] && $data_system.sounds[1].name!=\"\"\n pbSEPlay($data_system.sounds[1])\n elsif FileTest.audio_exist?(\"Audio/SE/GUI sel decision\")\n pbSEPlay(\"GUI sel decision\",80)\n end\nend", "def show\n @ota_code_list_code = Ota::CodeList::Code.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ota_code_list_code }\n end\n end", "def setCode(code)\n @code = code\n end", "def show\n @codesnippet = Codesnippet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @codesnippet }\n end\n end", "def show() end", "def show() end", "def show() end", "def show\n @m_code = MCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @m_code }\n end\n end", "def action\n puts \"use command!\\n\\n\"\n end", "def choose_to_order(serve_number)\n if serve_number == 1\n puts GET_MENU\n start_order\n elsif serve_number == 2\n puts BYE\n else\n puts ERROR\n end\n end", "def step\n send_cmd 'vCont;s'\n read_response(decode: true)\n end", "def set_webcode\n @webcode = Webcode.find(params[:id])\n end", "def set_coding\n @coding = Coding.find(params[:id])\n end", "def set_Code(value)\n set_input(\"Code\", value)\n end", "def initialize\n puts \"Would you like to be the codemaker? (y/n)\"\n puts\n response = gets.chomp.downcase\n puts\n if response == \"y\"\n @user = \"human\"\n @code = input\n else\n if response != \"n\"\n puts \"I'm not quite sure what you mean but I will just\" \\\n \" allow the computer to be the codemaker and choose.\"\n puts\n end\n @user = \"computer\"\n @code = generate_code\n end\n end", "def open()\n \n #note we would want to check for the browser bing open already\n #so we don't annoy people\n \n event(\"Pre\")\n require 'launchy'\n Launchy.open(\"http://local.general.dev/info.php\") #note this should be from setting file\n event(\"Post\")\n end", "def exchange_code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def play_random_song_from_band(term)\n response = search_itunes(term)\n results = response[\"results\"]\n pick = results.sample # Fill in this blank with the code that will grab a random member of the results array. Look at the Ruby Docs to find it.\n system(\"open\", pick[\"previewUrl\"]) \nend" ]
[ "0.5867024", "0.5853624", "0.57858384", "0.5697716", "0.56517893", "0.56193143", "0.5558522", "0.55563265", "0.5545944", "0.5511267", "0.5459809", "0.54586744", "0.5450313", "0.54152787", "0.541295", "0.54060256", "0.5395365", "0.53819996", "0.53635365", "0.5346344", "0.5328403", "0.5328106", "0.5323259", "0.5321138", "0.5312615", "0.529908", "0.52962273", "0.5273425", "0.5272712", "0.5259699", "0.5251824", "0.52499086", "0.5240779", "0.5221955", "0.5211866", "0.5208852", "0.52080375", "0.52080375", "0.52080375", "0.52080375", "0.52080375", "0.52080375", "0.52080375", "0.5187375", "0.51690644", "0.51578945", "0.5155445", "0.51552653", "0.5143217", "0.5142451", "0.5131211", "0.513029", "0.513029", "0.5123753", "0.5121738", "0.51200664", "0.51200664", "0.51200664", "0.51200664", "0.5112711", "0.51032674", "0.51010394", "0.5099215", "0.5091628", "0.50882447", "0.5081655", "0.5081012", "0.5073414", "0.5070088", "0.506927", "0.50674033", "0.5065655", "0.50617445", "0.50612015", "0.5056111", "0.5053136", "0.50518775", "0.50487864", "0.5047511", "0.5044896", "0.5043511", "0.5043511", "0.5043511", "0.5035846", "0.50297034", "0.5027378", "0.5022838", "0.5022774", "0.5018051", "0.50157845", "0.50132954", "0.5007441", "0.50048697", "0.5003778", "0.5003778", "0.5003778", "0.5003778", "0.5003778", "0.5003778", "0.5003778", "0.5002753" ]
0.0
-1
Will serve the Ai to take a guess. Will look at the feedback and take guess
def choose_guess(turn) @guess = [] if turn == 0 @best_available_guess = [] @guess = ["red", "red", "blue", "blue"] else @guess = @next_guess end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guess(guess)\n \t@guess = guess\n\n \tguess_response\n end", "def game_guess\n if path == \"/game\" && verb == \"POST\"\n number = client.read\n game.guess(number)\n redirect(client)\n end\n end", "def make_guess\n guess = input_guess\n check_guess(guess)\n render_code(guess)\n render_pegs(@black_pegs, @white_pegs)\n end", "def getguess guess\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t if guess.length == 1\r\n\t\t\t\t if check_repeated_choice guess\r\n\t\t\t\t @message = \"Already guessed this letter!\"\r\n\t\t\t\t if @console\r\n\t\t\t\t\t\t\t\t@output.puts \"#{@message}\"\r\n\t\t\t\t\t\t\t\tword_input = take_user_word_input\r\n\t\t\t\t\t\t\t\tvalid = false\r\n\t\t\t\t\t\t\t while !valid do\r\n\t\t if validate_input word_input\r\n\t\t valid = true\r\n\t\t else\r\n\t\t @output.puts \"Invalid input\"\r\n\t\t word_input = take_user_word_input\r\n\t\t end\r\n\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif check_enter word_input\r\n\t\t\t\t\t\t\t\t\t\t@break_flag = true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t getguess word_input\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t end\r\n\t\t\t\t else\r\n\t\t\t\t \t@message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @guess_counter+=1\r\n\t\t\t\t check_guess guess\r\n\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t end\r\n\t\t\t\t success = check_phrase @resulta.join(',').gsub(\",\",\"\")\r\n\t\t\t\t return success ? true : false\r\n\t\t\t\telse\r\n\t\t\t\t\t if check_phrase guess\r\n\t\t\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t\t\t i = 0\r\n\t\t\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\t\t\t@resulta[i] = phrase[i]\r\n\t\t\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t return true\r\n\t\t\t\t\t else\r\n\t\t\t\t\t\t @num_guessed = 0\r\n\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t @guess_counter+=1\r\n\t\t\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t\t\t return false\r\n\t\t\t\t\t end\r\n\t\t\t\tend\r\n\t\t\t\tend", "def play_game_with_user_as_codebreaker\n @display.welcome_message_for_user_as_codebreaker\n generate_secret_code\n collect_first_guess_and_provide_feedback\n let_the_user_provide_successive_guesses_and_provide_feedback\n end", "def guessed\n\n end", "def guessing_for_the_win(letter)\n\t\tif repeat_guess(letter)\n\t\telsif guess_correct(letter)\n\t\telse wrong_guess(letter)\n\t\tend \n\n\t\tif @secret_word == @display\n\t\t\tcongrats\n\t\telsif @number_of_guesses > 0 \n\n\t\t\tp \"Keep guessing\"\n\t\telse\n\t\t\tfailure\n\t\tend\n\tend", "def guess(name)\n choose(name)\n click_button(\"Guess\")\n end", "def guess(guess,event)\n case @status\n when :new, :finished\n 'You need to start a game first: `!rfk start`'\n when :running\n if guess == @kitten\n # We currently get a warning trying to send a message and add a reaction\n # [WARN : ct-3 @ 2018-02-26 17:49:52.182] Locking RL mutex (key: [:channels_cid_messages_mid_reactions_emoji_me, 417679731291324417]) for 1.0 seconds preemptively\n #event.message.react('😸') # Smiley Cat\n @status=:finished\n \"#{event.message.author.mention} Woo you found kitten\"\n elsif @guesses.include?(guess)\n \"#{event.message.author.mention} someone already guessed `#{guess}`, the kitten doesn't move during a game\"\n else\n @guesses << guess\n \"#{event.message.author.mention} You found `#{@nki[guess]}` but that's not a kitten!\"\n end\n else\n puts \"We got a guess of #{guess} but not in a known state of #{@state}\"\n \"Wibble not sure what's happening here\"\n end\n end", "def ask_for_guess\n @guess_count += 1\n @guess = get_code(\"Please enter your guess in the format 'color color color color'(to list available color options enter 'options'):\")\n end", "def play_game\r\n\r\n #Call on the generate_number method in order to get a random number\r\n number = generate_number\r\n $noOfGuesses = 0 \r\n\r\n #Loop until the player inputs a valid answer\r\n loop do\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n \r\n\r\n if $noOfGuesses > $maxGameGuesses then\r\n print \"You exceeded the allowed number of guesses of \" + $maxGameGuesses.to_s + \".\"\r\n print \"\\nYou lose! Please try again.\"\r\n print \"\\n\\nPress enter to continue.\"\r\n Console_Screen.pause \r\n break\r\n end\r\n\r\n if $cheatMode == true then\r\n print \"\\nShh.... the answer is \" + number.to_s \r\n end\r\n\r\n #Prompt the player to make a guess\r\n print \"\\n\\nEnter your guess and press the Enter key: \"\r\n \r\n \r\n reply = STDIN.gets #Collect the player's answer\r\n reply.chop! #Remove the end of line character\r\n\r\n reply = reply.to_i\r\n\r\n if reply < 1 || reply > $maxChallengeRange then\r\n Console_Screen.cls\r\n print \"\\nInvalid entry. Please enter a number between 1 and \" + $maxChallengeRange.to_s\r\n print \"\\n\\nPlease press enter to continue.\"\r\n Console_Screen.pause\r\n redo #Redo the current iteration of the loop\r\n end\r\n \r\n $noOfGuesses = $noOfGuesses + 1\r\n \r\n #Analyze the player's guess to determine if it is correct\r\n if reply == number then #The player's guess was correct\r\n Console_Screen.cls #Clear the display area\r\n print \"You have guessed the number! Press enter to continue.\"\r\n Console_Screen.pause #Pause the game\r\n break #Exit loop\r\n elsif reply < number then #The player's guess was too low\r\n Console_Screen.cls #Clear the display area\r\n print \"Your guess is too low! Press Enter to continue.\\n\\n\"\r\n Console_Screen.pause #Pause the game\r\n elsif reply > number then #The player's guess was too high\r\n Console_Screen.cls #Clear the display area\r\n print \"Your guess is too high! Press Enter to continue.\\n\\n\"\r\n Console_Screen.pause #Pause the game\r\n end\r\n\r\n \r\n \r\n end\r\n\r\n end", "def guess\n puts \"Write down a guess.\"\n @guess_code.make_seq\n @code_seq = guess_code.sequence\n end", "def respond_to_guess(letter)\n letter = letter.clone.downcase\n\n if @incorrect_letters.include?(letter) || @progress.include?(letter) || @progress.include?(letter.upcase)\n puts \"You already guessed that letter!\"\n puts \"\"\n elsif @word.include?(letter) || @word.include?(letter.upcase)\n update_progress(letter)\n unless @progress.include?(\"_\")\n @round_finished = true\n @guessed = true\n end\n else\n @incorrect_letters << letter\n @round_finished = true if @incorrect_letters.size == 6\n end\n print_hangman\n end", "def congrats\n\t\tp \"Congrats on Guessing the Word\"\n\tend", "def solicit_guess\n\t\tputs \"\\nPlease input a letter!\"\n\t\tguess = gets.chomp.downcase\n\t\tif guess.downcase == \"save\"\n\t\t\t$save = true\n\t\telse\t\n\t\t\tuntil !(@guess_tracker.include?(guess)) && (guess.length == 1) && (guess <= 'z' && guess >= 'a')\n\t\t\t\tputs \"Unacceptable input (maybe you already guessed that?), please try again!\"\n\t\t\t\tguess = gets.chomp.downcase\n\t\t\tend\n\t\tend\n\t\tguess\n\tend", "def guess_code\n puts \"\\nI have 12 turns to guess the color code that you have set.\\nLet's see whether I can do it or not\"\n catch(:guessed) do\n (1..12).each do |turn|\n sleep(rand(1..8))\n print \"\\nMy guess #{turn}: \"\n guess = @role.random_code\n puts guess\n response = validate_guess(guess.split(''), get_code.split(''))\n puts \"Response: #{response}\"\n validate_response(response, turn)\n end\n end \n end", "def guess!(letter)\n end", "def computer_guess_turn\n feedback_engine\n sleep 2.5\n puts \"The computer is thinking...\"\n computer_change_guess\n puts \"Guess Board: #{@guess_board.state}\"\n end", "def give_feedback\n print 'Matches: '\n puts 'Black ' * @secret.exact_matches(last_guess) + \\\n 'White ' * @secret.near_matches(last_guess)\n end", "def play_game(value)\r\n\r\n #Call on the generate_number method in order to get a random number\r\n number = generate_number \r\n\r\n\tif value == \"c\"\r\n\t\tConsole_Screen.cls\r\n\t\tputs \"\\n\\nCHEAT MODE: secret number is \" + number.to_s \r\n\t\tConsole_Screen.cls\r\n\tend\r\n\t\r\n #Loop until the player inputs a valid answer\r\n loop do\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Prompt the player to make a guess\r\n print \"\\nEnter your guess and press the Enter key: \"\r\n \r\n reply = STDIN.gets #Collect the player's answer\r\n reply.chop! #Remove the end of line character\r\n reply = reply.to_i #Convert the player's guess to an integer\r\n \r\n\t #Increment Guesses Variable\r\n\t $noOfGuesses += 1\r\n\t\r\n #Validate the player's input only allowing guesses between 1 and 100\r\n if reply < 1 or reply > 1000 then\r\n\t \r\n\t\tConsole_Screen.cls #clear screen\r\n\t\t\r\n\t\tputs \"\\nInvalid input was entered!\"\r\n\t\tprint \"\\n\\Only use numbers from 1 to 1000 for guesses. Press enter to continue.\" \r\n\t\t\r\n\t\tConsole_Screen.pause\r\n\t \r\n redo #Redo the current iteration of the loop\r\n end\r\n \r\n #Analyze the player's guess to determine if it is correct\r\n if reply == number then #The player's guess was correct\r\n Console_Screen.cls #Clear the display area\r\n print \"You have guessed the number! Press enter to continue.\"\r\n Console_Screen.pause #Pause the game\r\n break #Exit loop\r\n elsif reply < number then #The player's guess was too low\r\n Console_Screen.cls #Clear the display area\r\n print \"Your guess is too low! Press Enter to continue.\"\r\n Console_Screen.pause #Pause the game\r\n elsif reply > number then #The player's guess was too high\r\n Console_Screen.cls #Clear the display area\r\n print \"Your guess is too high! Press Enter to continue.\"\r\n Console_Screen.pause #Pause the game\r\n end\r\n \r\n\t\tif $noOfGuesses >= 10\t\t#Max guess attemps (10)\r\n\t\tConsole_Screen.cls \t#clear screen\r\n\t\t\tprint \"Your \" + $noOfGuesses.to_s + \" guesses are at max allowable attempts. Press enter to continue.\"\r\n\t\t\tConsole_Screen.pause\t#pause the game\r\n\t\t\tbreak\t#break loop\r\n\t\tend\r\n end\r\n\r\n end", "def guess\n # takes human input and stores guess\n puts 'Pick a letter'\n self.human_guess = gets.chomp\n end", "def guess(guess)\n \t@guess = guess\n \treturn :correct if solved?\n \t@guess > @answer ? :high : :low\n end", "def make_guess\n\tputs \"#{ @name } is thinking...\"\n\tif @first_guess==[]\n\t return make_first_guess\n\telse\n\t # update the last guess, get a random sample from the set of available codes\n\t sleep 1\n\t @last_guess = @set_of_codes.sample \n\t return @last_guess\n\tend\n end", "def play_as_codebreaker\n # answer = colors.sample(4)\n loop do\n display.tables(hint.table,decode.table)\n puts \"Please enter your guess #{colors.join(' | ')}:\"\n player.input = gets.split.map(&:capitalize)\n if player.valid_input?\n if player.win?(answer)\n puts \"You won! #{display_answer}\"\n exit\n elsif player.lose?\n puts \"You lost! #{display_answer}\"\n exit\n else\n complete_turn\n end\n else\n puts \"Not a valid input!\"\n end\n end\n end", "def turn()\n\tguess = \"\"\n\tif @human_is_guessing == true\n\t\tputs \"Enter your guess for the secret code\"\n\t\tguess = gets.chomp\n\t\twhile guess.length != 4 || (guess =~ /[^0-5]/)\n\t\t\tputs \" Please enter guess again. Remember it must be 4 numbers and only consist of values 0-5.\"\n\t\t\tguess = gets.chomp\n\t\tend\n\telse #computer is guessing\n\t\t#random guess from array of viable solutions.\n\t\tguess = @solutions.delete_at(rand(@solutions.length)).join.to_s\n\t\t\tputs \" I guess \" + guess\n\t\tend\n\t\tset_guess(guess)\n\t\t@score = compare_guess(guess)\n\t\tputs \"You have correctly guessed \" + @colors_correct.to_s + \" out of 4 digits in the code\" + \" and have \" + @placed_correct.to_s + \" in the right place.\"\n\t\t@solutions.delete_if {|x| compare_guess(x.join.to_s, @guess) != @score }\n\t\t@turns += 1\n\tend", "def guess_progress(user_guess)\n @letter_found = false\n check_letter(user_guess)\n\n @secret_array.each_index do |i|\n if !@letter\n puts \"Invalid input. Please input a letter\"\n @letter_found = true\n break\n elsif @secret_array[i] == user_guess \n @display_array[i] = \" #{user_guess} \"\n @letter_found = true\n end\n end\n\n puts \"Sorry. '#{user_guess}' is not in the secret word\" if !@letter_found\n\n if !check_finish\n increment_guess(user_guess)\n end \n\n @display_array\n @is_over\n end", "def ask_guess\n guess = gets.chomp.downcase\n check_guess_is_valid?(guess) ? guess : ask_guess\n end", "def check_guess guess\r\n\t\t\t\t @resultb.push(guess)\r\n\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t i = 0\r\n\t\t\t\t @num_guessed = 0\r\n\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\tif phrase[i] == guess\r\n\t\t\t\t\t\t\t\t @resulta[i] = guess\r\n\t\t\t\t\t\t\t\t @num_guessed += 1\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif @num_guessed > 0\r\n\t\t\t\t\t\t\t\t@score += (@reward.to_i * @num_guessed)\r\n\t\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t\t\tend\r\n\t\t end", "def turn\n\t\t\t@turns += 1\n\t\t\t@guess_letter = gets[0].downcase\n\t\t\tshow_matches\n\t\t\tcheck_win\n\t\tend", "def incorrect_guess(guess)\n end", "def correct_guess(guess)\n end", "def give_feedback(guess)\n guess.split('').each_with_index do |val, index|\n if val == @code[index]\n print 'M'\n elsif @code.split('').include?(val)\n print 'O'\n else\n print 'X'\n end\n end\n puts\n end", "def show_guess\n @guess\n end", "def guess_hidden_word\n puts (\"Enter your guess: \")\n end", "def start\n \"You're playing with #{deck.count} cards.\"\n puts (\"-\"*60).cyan\n deck.cards.each do |card|\n puts \"This is card number #{current + 1} out of #{deck.count}.\"\n puts \"Question: #{current_card.question}\"\n response = gets.chomp\n record_guess(response)\n puts \"#{guesses.last.feedback}\"\n next_card\n end\n puts \"****** Game over! ******\"\n puts \"You had #{number_correct} correct answers out of #{deck.count} for a score of #{percent_correct}%\"\n end", "def running(turn, time_to_guess, last_guess, last_word, last_feedback)\n system('cls')\n puts '***************************************************************'\n puts '* Word Mastermind *'\n puts '***************************************************************'\n puts '* Turn Number: ' + turn.to_s + ' Turns To Guess: '+time_to_guess.to_s+' *'\n puts '***************************************************************'\n puts ''\n puts ' REMEMBER: Your Word can only have 5 letters, and can only'\n puts ' contain one of each character!'\n puts ''\n puts '|X| = Not in word |O| = In the word and the correct place'\n puts '|-| = In the word but in the incorrect place '\n puts ''\n puts ' Your Last Guess Was: ' + last_word\n puts ''\n puts ' ' + \"#{last_guess}\"\n puts ' ' + \"#{last_feedback}\"\n puts ''\n puts ''\n puts 'What will you guess this turn?'\n puts ''\n print 'Guess: '\n end", "def guess_without_choosing_anyone\n click_button(\"Guess\")\n end", "def guess_code\n puts \"\\nYou'll have 12 turns to guess the color code set by me.\\nNot So Good Luck jk\\nOptions: r,b,y,g,o,w,v\"\n catch(:guessed) do\n guess = ''\n (1..12).each do |turn|\n print \"\\nGuess #{turn}: \"\n #print \"#{get_code} \"\n guess = gets.chomp!.downcase\n response = ''\n gc = get_code.split('')\n g = guess.split('')\n for i in 0..3 do \n if g[i]==gc[i]\n response += 'X'\n elsif gc.include?(g[i]) \n response += 'O'\n end\n end\n puts \"Response: #{response.split('').shuffle.join('')}\"\n if response=='XXXX'\n puts \"\\nCongratulations! I Lost\\nThe code was #{get_code}\"\n throw :guessed\n elsif response!='XXXX' and turn==12\n puts \"\\nBoohoo! I won\\nTHe code was #{get_code}\"\n throw :guessed\n end\n end\n end\n end", "def play\n puts \"I have generated a beginner sequence with four elements made up of: (r)ed,\n (g)reen, (b)lue, and (y)ellow. Use (q)uit at any time to end the game.\n What's your guess?\"\n mastermind = Game.new\n mastermind.game_solution\n amount_of_guesses = 0\n guess = gets.chomp\n user_guess = []\n user_guess << guess.chars\n amount_of_guesses += 1\n mastermind.check_for_correct_letters(user_guess)\n mastermind.check_for_correct_indexes(user_guess, mastermind.solution)\n until guess == \"q\"\n if guess == \"c\"\n puts \"The solution is #{mastermind.solution}\"\n break\n elsif guess.length > 4\n puts \"Your guess was too long.\"\n elsif guess.length < 4\n puts \"Your guess was too short.\"\n elsif guess != mastermind.solution\n puts \"You had #{mastermind.correct_letters} correct colors with #{mastermind.correct_indexes}\n in the correct position.\"\n break\n elsif guess == mastermind.solution.to_s\n \"You won! You guessed #{guess}. You had #{mastermind.correct_letters} correct\n colors in #{mastermind.correct_indexes} correct positions.\n You guessed #{amount_of_guesses.to_s} times.\"\n break\n else\n puts \"Goodbye, quitter.\"\n end\n end\nend", "def gets_user_guess\n @guess = gets.strip.downcase\n generate_new_card\n end", "def guess(guess)\r\n\t\t# Make sure the guess is either a letter or the whole word\r\n\t\tif guess.length != 1 && guess.length != @win_word.length\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp \"Guess a letter, or the complete word!\"\r\n\t\t# check for repeated guesses\r\n\t\telsif @past_guesses.include? guess\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"You guessed that already!\"\r\n\t\t# check if they guessed the entire word correctly\r\n\t\telsif guess == @win_word\r\n\t\t\twin\r\n\t\t# if the letter is not in the word\r\n\t\telsif !@win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tif @remaining_guesses == 1\r\n\t\t\t\tlose\r\n\t\t\telse\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"Sorry, try again!\"\r\n\t\t\tend\r\n\t\t# if the letter is in the word\r\n\t\telsif @win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tupdate_hint(guess)\r\n\t\t\tif @hint_str == @win_word\r\n\t\t\t\twin\r\n\t\t\telse\r\n\t\t\t\tp \"Nice guess!\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tp \"Error\"\r\n\t\tend\r\n\r\n\tend", "def prompt_for_guess\n puts (\"1. Enter a vowel.\")\n\tputs (\"2. Enter a consonant.\")\n\tputs (\"3. Guess the entire word.\")\n\tputs (\"(Enter your letter choice now. If you enter more than a letter than its your own fault.)\")\n end", "def read_guess\n print \"Pretty please enter your guess: \"\n gets.to_i\nend", "def ask_question\n @game_id = params[:game_id]\n @current_game = Game.find(@game_id)\n @bonus = params[:bonus]\n unless @current_game.players_turn?(current_user.id)\n back_to_index and return\n end\n\n if @current_game.normal_round?\n subject_title = params[:subject]\n @subject = subject_title\n @questions = Question.questions_by_user_experience(current_user.experience_level, @subject)\n @question = @questions.sample\n elsif @current_game.challenge_round?\n @challenge = Challenge::get_ongoing_challenge_by_game(@current_game.id)\n if @challenge\n @question = Question.find(@challenge.get_question_id_by_counter)\n @subject = @question.subject_title\n elsif @challenge.nil?\n wager = params[:wager]\n prize = params[:prize]\n if wager && prize\n @challenge = Challenge.create_challenge(@current_game.id, current_user.id, @current_game.opponent_id(current_user.id), wager, prize)\n else\n redirect_to game_challenge_path(:game_id => @current_game.id)\n end\n end\n end\n if @question\n respond_to do |format|\n format.html\n format.xml { render :xml => @question }\n end\n end\n end", "def guess(board)\n print \"Make a guess: \"\n gets.chomp\n end", "def one_round_human_codebreaker\n show_round(@round)\n obtain_human_input\n codebreaker_guess\n print_colorized_array(@guess)\n update_feedback\n codemaker_feedback\n print_colorized_array(@feedback)\n end", "def handle_response(guess, indices)\n\t\tindices.each do |index|\n \t\t\t@board[index] = guess\n \t\tend\n \t\tcandidate_words(guess, indices)\n\tend", "def make_guess\n puts \"Make a guess:\"\n @current_guess = gets.chomp\n unless good_guess?\n puts \"That is an invalid guess, please try again!\"\n @current_guess = gets.chomp\n end\n puts\n guesses << current_guess unless current_guess == \"save\" || current_guess == secret_word\n end", "def test\n\t\t#load a QA pair into current\n\t\t@qa_pairs = @qa_pairs.shuffle\n\t\ttemp = @qa_pairs.pop\n\t\t@current_question = temp[0]\n\t\t@current_answer = temp[1]\n\t\t#ask question\n\t\tputs \"Question: #{@current_question[0]}\"\n\t\t#prompt and assess guess\n\t\tis_correct = false\n\t\twhile is_correct == false do\n\t\t\tguess = []\n\t\t\tputs \"Please type your answer:\"\n\t\t\tguess << gets.chomp\n\t\t\tif guess[0] == \"EXIT\"\n\t\t\t\t@shutdown = true\n\t\t\t\tputs @shutdown_msg\n\t\t\t\tis_correct = true\n\t\t\telsif guess[0] == \"SKIP\"\n\t\t\t\t@qa_pairs << temp\n\t\t\t\tputs @skip_msg\n\t\t\t\tis_correct = true\n\t\t\telsif self.assess(guess)\n\t\t\t\tputs @correct_msg\n\t\t\t\tis_correct = true\n\t\t\telse\n\t\t\t\tputs @incorrect_msg\n\t\t\t\tputs \"...\"\n\t\t\tend\n\t\tend\n\t\tputs \"--------------------\"\n\t\treturn nil\n\tend", "def store_and_redirect(guess)\n @guesses << guess\n game_response(guess)\n #redirect\n end", "def enter_guess\n\t\t@guess = nil\n\t\tuntil valid_guess?(@guess)\n\t\t\tputs \"Please enter your guess (A-Z) now, or type 'save' to save (and quit):\"\n\t\t\t@guess = gets.chomp.upcase\t\t\n\t\tend\n\tend", "def run\n\t\t# initialize board with length\n\t\tlength = checker.pick_secret_word # picks a word, returns length\n\t\t@board = Board.new(length)\n\t\tguesser.receive_secret_length(@board)\n\t\t\n\t\tuntil @misses > MAX_MISSES\n\t\t\t\n\t\t\t# return letter \n\t\t\tguess = guesser.make_guess\n\t\t\t\n\t\t\t# rescue human putting in wrong indices\n\t\t\tbegin\n\t\t\t\t# return array of hits given guess\n\t\t\t\thits_arr = checker.check_guess(guess) \n\t\t\t\t# update @board if there was a hit; else, increment misses\n\t\t\t\thits_arr.empty? ? @misses +=1 : update_board(hits_arr, guess) \n\t\t\trescue Exception => e\n\t\t\t\tputs e.message\n\t\t\t\tretry\n\t\t\tend\n\t\t\t\n\t\t\t# break if the board is over\n\t\t\twon if @board.filled?\n\t\n\t\t\t# if not over, pass updated board to guesser \n\t\t\tguesser.handle_guess_response(@board)\n\t\t\t\n\t\t\t# render new board\n\t\t\t@board.render\n\t\tend\n\t\t\n\t\t# Guesser lost\n\t\tputs \"The guesser lost!\"\n\t\tchecker.reveal_secret\n\t\t\n\tend", "def introduce_the_game\n @irc_server.puts \"Welcome to hangman!\"\n @irc_server.puts \"To get started, enter a word to be guessed\"\n end", "def get_feedback\n @title_page = 'Feedback'\n\n params.each { |question, answer| $game.quiz.user_answer << answer.to_i }\n\n $game.player.score = ($game.quiz.number_corrects * 100) / $game.quiz.question_answer.length\n @feedback = $game.player.score\n\n @questions = $game.quiz.questions\n @user_answer = $game.quiz.user_answer\n\n erb :feedback, layout: :template\nend", "def update\n respond_to do |format|\n if @round.make_guess(params[\"round\"][\"guessed_letter\"])\n update_current_player\n format.html { redirect_to game_round_path(@game, @round) }\n format.json { render :show, status: :created, location: @round }\n else\n format.html { redirect_to game_round_path(@game, @round), notice: 'Invalid guess' }\n format.json { render :show, status: :created, location: @round }\n end\n end\n end", "def guess_params\n params.require(:guess).permit(:response, :card_id, :round_id)\n end", "def create\n @guess = Guess.new(params[:guess])\n\n respond_to do |format|\n if @guess.save\n format.html { redirect_to(@guess, :notice => 'Guess was successfully created.') }\n format.xml { render :xml => @guess, :status => :created, :location => @guess }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @guess.errors, :status => :unprocessable_entity }\n end\n end\n end", "def getGuess\n puts \"It is your turn.\"\n puts \"Which person do you want to suggest?\"\n guessSuspect = getUserInputFromArray(@suspects)\n puts \"Which location do you want to suggest?\"\n guessLocation = getUserInputFromArray(@locations)\n puts \"Which weapon do you want to suggest?\"\n guessWeapon = getUserInputFromArray(@weapons)\n\n puts \"Is this an accusation (Y/[N])?\"\n accuse = nil\n while accuse == nil\n input = gets.chomp.to_s\n if input == \"Y\" or input == \"y\"\n accuse = true\n elsif input == \"N\" or input == \"n\"\n accuse = false\n else\n accuse = nil\n puts \"Invalid input, please try again.\"\n end\n end\n return Guess.new(guessSuspect, guessLocation, guessWeapon, accuse)\n end", "def generate_random_guesses\n position1 = validate_ai_input\n guess1 = @board.reveal(position1)\n @board.render\n position2 = validate_ai_input\n guess2 = @board.reveal(position2)\n @board.render\n result = is_match?(guess1, guess2)\n if !result\n write_to_ai_memory(guess1.value, position1, guess2.value, position2)\n end\n end", "def player_guess\n puts \"Turn #{@turn} - Put your guess in below:\"\n begin\n guess = gets.chomp\n guess_code = Code.new(guess.upcase)\n rescue StandardError => e\n puts e\n retry\n end\n guess_code\n end", "def run_guessing_game\n\n player_guess = ''\n\n until player_guess == 'exit'\n welcome\n player_guess = get_player_guess\n check_guess(player_guess)\n end\nend", "def set_guess\n @guess = Guess.find(params[:id])\n end", "def guess_params\n params.require(:guess).permit(:member_id, :game_id, :faction_id, :result)\n end", "def create\n # create the guess object based on the params passed form the form, i.e the text of the guess, the user_id and the card_id\n # we are able to find the @card and the @round becuase we passed their id's as hidden fields in the form that was submitted\n @guess = Guess.create(guess_params)\n # find the card the guess is associated with\n @card = Card.find(guess_params[:card_id]);\n # find the round the guess is associated with\n @round = Round.find(guess_params[:round_id])\n\n respond_to do |format|\n # calling the card instance method 'check_guess' and passing it the @guess object\n # this method will compare the guess to the card's answer and return true if correct, false if incorrect\n # you can find this check_guess method in models/card.rb\n result = @card.check_guess(@guess)\n \n # if the result of the guess was true, that means it was correct\n if result == true\n # the guess was correct, so update the \"correct\" attribute on the guess to true (it was false by default)\n @guess.update_attributes(correct: true)\n # delete the card_id that was answered correctly from our array of cards_not_answered, which is stored in the session\n # if we delete the card_id of the card that was answered, it will no longer be showin in the game\n session[:cards_not_answered].delete(@card.id)\n\n # this is checking if there aren't any cards left in the cards_not_answered\n # if its greater than 0, then there are still cars left to anser\n if session[:cards_not_answered].length > 0\n # randomly select a card_id from the cards_not_answered array\n next_card_id = session[:cards_not_answered].sample\n # redirect to play that card, using the variable next_card_id that we just made\n # this is redirecting to the /cards/:id/play/:round_id route, which will trigger the play_card method. the play_card method will render the view with the new card's question and a submit form to anser it\n format.html {redirect_to \"/cards/#{next_card_id}/play/#{@round.id}\"}\n else\n # if there aren't any cards left in the cards_not_answered array then the game must be over - we have answered all the cards\n # in this case, we should redirect to the results route which will show our results\n format.html {redirect_to \"/rounds/#{@round.id}/results\"}\n end\n else\n # down here is the block for if the guess was not correct\n # if the guess was incorrect, we simply pick a new card_id from the cards_not_answered array that is stored in the session\n next_card_id = session[:cards_not_answered].sample\n # with that next_card_id we can redirect to /cards/:id/play/:round_id route, which will trigger the play_card method which will render the view with the next card's question and a submit form to answer\n format.html {redirect_to \"/cards/#{next_card_id}/play/#{@round.id}\"} \n end\n end\n end", "def process_guess(guess)\n\t\t\tunless @secret.include? guess\n\t\t\t\tputs \"Bad guess...\"\n\t\t\t\t@bad_guesses << guess\n\t\t\t\t@guesses -= 1\n\t\t\t\t@drawing[@bad_guess_count+1] = @drawing_animation[@bad_guess_count]\n\t\t\t\t@bad_guess_count += 1\n\t\t\tend\n\n\t\t\twhile @secret.include? guess\n\t\t\t\t@fill_in_word[@secret.index(guess) * 2] = guess\n\t\t\t\t@secret[@secret.index guess] = \" \"\n\t\t\tend\n\t\tend", "def guessing_game\n answer = rand(1..10)\n print \"What is your guess?\"\n guess = gets.chomp\n if\n guess.to_i > answer\n puts \"Your guess is too high.\"\n elsif\n guess.to_i < answer\n puts \"Your guess is too low.\"\n else\n puts \"Your guess is correct.\"\n end\n \n print \"What is your guess?\"\n guess = gets.chomp\n if\n guess.to_i > answer\n puts \"Your guess is too high.\"\n elsif\n guess.to_i < answer\n puts \"Your guess is too low.\"\n else\n puts \"Your guess is correct.\"\n end\n \n print \"What is your guess?\"\n guess = gets.chomp\n if\n guess.to_i > answer\n puts \"Your guess is too high.\"\n elsif\n guess.to_i < answer\n puts \"Your guess is too low.\"\n else\n puts \"Your guess is correct.\"\n end\n \n puts \"The answer was\"\n puts answer\nend", "def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end", "def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end", "def get_guess\n\t\t# There are turns left...\n\t\tif @turn < 9\n\t\t\tshow_board\n\t\t\tputs \"Enter your letter guess...\"\n\t\t\tletter = gets.chomp.downcase\n\t\t\tvalidate_letter(letter)\n\t\t# No turns left, show losing message and delete game if it was previously saved\n\t\telse\n\t\t\tputs\n\t\t\tshow_board\n\t\t\tputs \"Dangit, you ran out of turns!\"\n\t\t\tputs \"The word was #{@word.join}...\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\tend\n\tend", "def hit\n @printer = []\n @printer << \"You Hit.\"\n deal_player\n pl_total\n if session[:player].bust? || session[:player].hand_total == 21\n @action = :end\n run_dealer\n else\n @action = :choice\n end\n chat\n end", "def results(guess)\n if guess == @number\n puts 'Congratulations you guessed the right number!'\n else\n puts \"Correct answer was #{@number}. You ran out of guesses.\"\n end\n end", "def play_game\r\n\r\n word = select_word #Call on the method that retrieves a random word\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n consonants = get_consonants #Call on the method that prompts the player\r\n #to enter a list of consonants\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Call on the method that prompts the player to enter a vowel\r\n vowel = get_vowel\r\n\r\n #Remove blank spaces from the word to create a short version of the word\r\n shortWord = word.gsub(\" \", \"\")\r\n\r\n #Call the method that processes player guesses\r\n prompt_for_guess(shortWord, word, consonants, vowel)\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n end", "def give_hint()\n \n sleep(2)\n puts \"hint...\"\n sleep(1)\n\n correct_colors = []\n correct_place = 0\n\n #count matching colors\n $computer[\"code\"].map { |value| if $player[\"code\"].include?(value)\n if !correct_colors.include?(value)\n correct_colors.push(value) \n end\n end }\n\n #update object\n $computer[\"correct_colors\"] = correct_colors\n\n #report matching colors \n if correct_colors.length() > 0\n puts \"#{correct_colors.length()} of the colors that the computer chose are accurate...\"\n end \n \n #count matching placement of matching colors\n correct_colors.map { |value| $computer[\"code\"].index(value) == $player[\"code\"].index(value) }.map { |value| if value == true\n correct_place += 1\n end}\n\n #update object\n $computer[\"correct_place\"] = correct_place\n\n puts \"... and #{correct_place} in the correct place\" \n \n sleep(3)\n\n end", "def set_guess\n @guess = Guess.find(params[:id])\n end", "def set_guess\n @guess = Guess.find(params[:id])\n end", "def set_guess\n @guess = Guess.find(params[:id])\n end", "def getGuess\n\t\tputs \"It's Player #{@myIndex}'s turn.\"\n\n\t\t#if this players last guess was not correct\n\t\tif (!@isCorrect)\n\t\t\t#just grab some unseen values\n\t\t\tguessPerson = @suspectsNotSeen[0]\n\t\t\tguessPlace = @locationsNotSeen[0]\n\t\t\tguessWeapon = @weaponsNotSeen[0]\n\n\t\t\t#check if you only have 3 options\n\t\t\tif(@suspectsNotSeen.length == 1 && @locationsNotSeen.length == 1 && @weaponsNotSeen.length == 1)\n\t\t\t\t@theGuess = Guess.new(guessPerson, guessPlace, guessWeapon, true)\n\t\t\telse \n\t\t\t\t@theGuess = Guess.new(guessPerson, guessPlace, guessWeapon, false)\n\t\t\tend\n\n\t\t\t@theGuess\n\t\t#if it was \n\t\telse\n\t\t\tputs \"Player #{@playerIndex} makes an Accusation: #{@theGuess.toString}!\"\n\t\t\t#take the last guess, change it to an accusation, and return it\n\t\t\t@theGuess.changeToAccusation\n\t\t\t@theGuess\n\t\tend\n\tend", "def feedback\n end", "def play_game \n\n @number_guesses = 0\n @start_time = Time.now\n puts \"I have generated a secret code, a sequence of four colors: (R)ed, (G)reen, (B)lue, and (Y)ellow\"\n\n game_over = false \n\n until game_over \n \n guess = get_guess\n\n exit_game if guess.upcase == \"Q\" \n guess = @secret_code if guess.upcase == \"C\" # provide option to cheat\n\n if validate_guess(guess)\n @number_guesses += 1\n # add_guess_to_history(guess_report(guess))\n display_history(guess)\n\n if guess.upcase == @secret_code\n game_over = true \n end_game\n else\n puts \"Please guess again.\" \n end\n end\n end\n end", "def guess_params\n params.require(:guess).permit(:text, :card_id, :round_id)\n end", "def start_guess\r\n\t\tuntil @is_over == true\r\n\t#player enters 1 letter string\r\n\r\n\t\t\tputs \"guess a letter you've already guessed #{@used}. #{@tries-@guess_count} attempts remain\"\r\n\t\t\tputs @blanks.join\r\n\t\t\tletter = gets.chomp\r\n\t#if letter is not in guessed box take a turn away\r\n\t\t\tif @used.include?(letter) == false\r\n\t\t\t\t@guess_count += 1\r\n\t\t\t\tif @tries == @guess_count \r\n\t\t\t\t\t@is_over = true\r\n\t\t\t\tend\r\n\t\t#if letter is in the world replace the blank\r\n\t\t\t\tif @word.include?(letter)\r\n\t\t\t\t\twordindex = @word.index(letter)\r\n\t\t\t\t\t@blanks[wordindex] = letter\r\n\t\t\t\t\tif @blanks.include?(\"_ \") == false\r\n\t\t\t\t\t\t@is_over = true\r\n\t\t\t\t\tend\r\n\t\t#if letter is not in the world add to guessed box\r\n\t\t\t\telse\r\n\t\t\t\t\t@used << letter\r\n\t\t\t\tend\r\n\t#if letter is in guessed box don't consume a turn\r\n\t\t\telse\r\n\t\t\t\tputs \"you already tried that letter\"\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t#end:\r\n\t#if word is guessed correctly print congrants\r\n\t\tif @blanks.include?(\"_ \")\r\n\t\t\tputs \"haha try harder next time\"\r\n\t#if word is guessed wrong print taunt\r\n\t\telse\r\n\t\t\tputs \"well done! you guessed the word\"\r\n\t\tend\r\n\tend", "def attempt\n # # if @guesses.defined\n # if (defined?(@guesses)).nil?\n # @guesses = Array.new\n # end\n #\n @first_number = params[\"first_number\"]\n @second_number = params[\"second_number\"]\n @third_number = params[\"third_number\"]\n\n\n if @first_number.to_i < @second_number.to_i && @second_number.to_i < @third_number.to_i\n @guesses=(@first_number + \", \" + @second_number + \", \" + @third_number + \" Yes!\")\n else\n @guesses=(@first_number + \", \" + @second_number + \", \" + @third_number + \" No.\")\n end\n\n render(\"sequence/all_guesses.html.erb\")\n end", "def handle_betting\n puts \"Player #{@number}, See, fold, or raise?\"\n\n case (resp = gets.chomp)\n when /see/i\n :see\n when /fold/i\n :fold\n when /raise/i\n Integer(resp.split(' ')[1])\n else\n raise \"Unknown player response: #{resp}\"\n end\n end", "def guess\n question_response = QuestionResponse.build_response_guess(current_user, params)\n if question_response.try :save\n # load item\n question = Question.find(params[:id_question])\n item = question.xmlnode.xpath(\"//question/item[@text='\" + params[:item].gsub(\"'\", \"\\\\'\") + \"']\").first\n\n json = GuessQuestion.response(question, item, params[:answer])\n render json: json\n else\n render json: { message: \"error\" }, status: :unprocessable_entity\n end\n end", "def play\n 10.times do |i|\n \n# i is the chance number\n puts \"This is chance #{i+1} of 10\"\n \n# current guess is what player typed in\n current_guess = @player.guess_code\n \n# standing is based on method evaluate guess with paramater current guess from above\n standing = evaluate_guess(current_guess)\n \n# if correct for all 4\n if standing[:exact].length == 4\n# display to user\n puts \"You won!\"\n return\n else\n puts \"#{standing[:exact].length} Exact Matches\"\n puts \"#{standing[:near].length} Near Matches\"\n end\n end\n \n# if reached end of loop, that means guesses out & not all perfectly matched\n\n # If we make it this far, we have used up \n # all of our turns and lost.\n puts \"You lost!\"\n return\n end", "def evaluate_players_letter()\n letter= @player1.give_letter()\n if @hiddenword1.determine_if_correct_letter_given(letter)\n p @hiddenword1.obscured_word\n @guessed_letters.push(letter)\n else\n @player1.lives-=1\n p \"Please try again\"\n p @guessed_letters\n p @hiddenword1.obscured_word\n end\n end", "def play_game_with_user_as_codemaker\n @display.welcome_message_for_user_as_codemaker\n solve_the_secret_combination\n end", "def display\n puts \" \"*35 + \"===MasterMind!=== right: guess position\"\n for col in 0..9\n print \" \"*40\n for row in 0..3\n print guess_history[col][row] + ' '\n end\n puts \" \"*15 + guess_result_history[col][0] + \" \" + guess_result_history[col][1]\n puts \"\\n\"\n end\n puts \" \"*20 + \"input 4 color initials for making your choice, 'h' for help, 'q' for quit this round\"\n end", "def feedback()\n return $prompt # $prompt is conditionally populated by good_letter(), word_test() and wrong_letter()\nend", "def one_round_human_codemaker\n show_round(@round)\n puts 'The machine is thinking...'\n sleep 1\n @guess = define_secret_code\n print_colorized_array(@guess)\n end", "def play\n\t\twelcome\n\t\task_name\n\t\task_name2 \n\t\task_input\n\t\tturns\n\tend", "def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end", "def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end", "def guess\n\t\tcollect_words_of_length\n\t\tputs \"Already guessed letters by computer: #{@guessed_letters}\"\n\t\t@guessing_letter = nil\n\t\twhile @guessing_letter == nil || invalid?(@guessing_letter)\n\t\t\t@guessing_letter = guessing_letter\n\t\tend\n\t\t@guessed_letters << @guessing_letter\n\t\t@guessing_letter\n\tend", "def round\n show_guess\n show_lives\n show_bank\n puts ''\n set_letter(ask_letter)\n add_to_bank\n add_to_guess\n take_life unless check_choice\n end", "def letter_guess\n letter = get_letter_player()\n check_letter_in_random_word(@guess_letter)\n if @correct_guess == false\n @failed_attempts += 1\n if @failed_attempts == 10\n @lose = true\n end\n end\n guess_word_status_string = @guess_word_status.join()\n if guess_word_status_string == @random_word\n @win = true\n end\n end", "def get_guess\n puts \"#{@name}'s turn!\"\n print \"Enter 1 to guess a letter, or 2 to guess a word: \"\n choice = gets.chomp.downcase\n if choice == \"1\"\n print \"Guess a letter: \"\n guess = gets.chomp.downcase\n if valid_letter_guess?(guess)\n return guess\n else\n self.get_guess\n end\n elsif choice == \"2\"\n print \"Guess a word: \"\n guess = gets.chomp.downcase\n if valid_word_guess?(guess)\n return guess\n else\n self.get_guess\n end\n end\n end", "def update_feedback(guess)\n\t\tguess.split('').each do |guess_letter|\n\t\t\t@feedback.each do |target|\n\t\t\t\tif target[0] == guess_letter\n\t\t\t\t\ttarget[1] = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tall_true_check = true\n\t\t@feedback.each do |x|\n\t\t\tif !x[1]\n\t\t\t\tall_true_check = false\n\t\t\tend\n\t\tend\n\t\tif all_true_check\n\t\t\t@win = true\n\t\t\t@is_over = true\n\t\tend\n\tend", "def return_guess\n 5\n end", "def respond_to_guess(guess)\n\t\t@guessed_letters << guess\n\t\t@secret_word.split(\"\").include?(guess)\t\n\tend", "def game(name,max,tries)\n secret_number = rand(1..max)\n puts \"Make your first guess. Type in a number when you are ready and click enter.\"\n guess_previous = 999999\n guess = gets.to_i\n bad_counter = 0\n for i in 1..tries\n \tif guess == 0\n \t\tbad_guess(i,guess,secret_number,name,bad_counter,tries)\n \t\tbad_counter = bad_counter + 1\n \telsif guess == secret_number\n \t\thardergame = correct_guess(i,guess,secret_number,name)\n \t\treturn hardergame\n \telsif guess == guess_previous\n \t\tputs \"What are you thinking? You picked #{guess} before!\"\n \t\twrong_guess(i,guess,secret_number,name,tries)\t\n \telse \n \t\twrong_guess(i,guess,secret_number,name,tries)\t \t\t\n \tend\n \tguess_previous = guess\n \tguess = gets.to_i\n end\nend" ]
[ "0.753297", "0.71783257", "0.6946222", "0.681105", "0.6727323", "0.66807675", "0.66701126", "0.6514951", "0.6493853", "0.6463969", "0.6446141", "0.6434985", "0.6387544", "0.63712543", "0.6364618", "0.63473374", "0.63429815", "0.6339126", "0.63371587", "0.63173115", "0.63159657", "0.6314363", "0.6302191", "0.6296742", "0.62778175", "0.6269764", "0.6252079", "0.6251729", "0.6244802", "0.62363935", "0.6231235", "0.6221184", "0.6198366", "0.61936337", "0.6188464", "0.6180049", "0.61704195", "0.6167208", "0.6143037", "0.6125873", "0.61201185", "0.6115247", "0.61091834", "0.6107503", "0.609654", "0.6092276", "0.60910845", "0.6086776", "0.60697645", "0.6060672", "0.60592335", "0.605118", "0.6050871", "0.60491055", "0.60482574", "0.604646", "0.60400546", "0.6034164", "0.60321665", "0.60259044", "0.60130745", "0.6012445", "0.6005986", "0.6005277", "0.6003331", "0.6001969", "0.6001932", "0.6001932", "0.5998106", "0.5996217", "0.59883267", "0.5981907", "0.5981754", "0.5980198", "0.5980198", "0.5980198", "0.5970915", "0.5970614", "0.59705687", "0.5969", "0.59632474", "0.5959483", "0.5958411", "0.5955308", "0.595157", "0.5944673", "0.5940554", "0.59355104", "0.5931933", "0.5929665", "0.5926366", "0.59249735", "0.59249735", "0.5924084", "0.5922081", "0.5915848", "0.5915211", "0.5912895", "0.58973044", "0.5894796", "0.58875245" ]
0.0
-1
GET /investments GET /investments.json
def index @investments = Investment.all respond_to do |format| format.html format.json end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @investments = Investment.all\n\n render json: {investments: @investments}, root: false\n end", "def show\n render json: @investment, root: false\n end", "def index\n @investables = Investable.all\n end", "def index\n @investigations = Investigation.where(:visible => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @investigations }\n end\n end", "def index\n @investments = Investment.all.paginate(:page => params[:page], :per_page => 30)\n end", "def index\n @investigations = Investigation.all\n end", "def index\n @investment_funds = InvestmentFund.all\n end", "def show\n @investment = Investment.find(params[:id])\n end", "def show\n @investigation = Investigation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @investigation }\n end\n end", "def show\n @investment_type = InvestmentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @investment_type }\n end\n end", "def index\n @investors = params[:q].present? ? Investor.search(params[:q]) : Investor.all\n @investors = @investors.includes(:investment_group, :consultant).ordered.\n page(params[:page]).references(:investment_group, :consultant)\n end", "def index\n @investigadores = Investigador.all\n end", "def index\n @individual_company_investments = IndividualCompanyInvestment.all\n end", "def index\r\n @fixed_deposit_investments = FixedDepositInvestment.all\r\n end", "def index\n @wallet_id = params[:wallet_id]\n @investment_funds = InvestmentFund.where(\"wallet_id = ?\", @wallet_id)\n end", "def create\n @investment = Investment.new(investment_params)\n\n if @investment.save\n render json: @investment, status: :created\n else\n render json: @investment.errors, status: :unprocessable_entity\n end\n end", "def index\n @fund_company_investments = FundCompanyInvestment.all\n end", "def show\n @player_investment = PlayerInvestment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_investment }\n end\n end", "def show\n @invest = Invest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @invest }\n end\n end", "def index\n @investigaciones = Investigacion.search.page params[:page]\n end", "def index \n\n\n @investigateds = Investigated.all\n total_count = @investigateds.count\n respond_to do |format|\n format.html { }\n format.json { render json: { total: total_count, investigateds: @investigateds.map { |s| {id: s.id, name: s.name, lastname1: s.lastname1 } } } }\n end\n end", "def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end", "def new\n @investigation = Investigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @investigation }\n end\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def index\n @investments = Investment.all\n @user=User.find(session[:user_id])\n puts \"the user id is #{@user.id}\"\n @investment=@user.investments.first\n #puts \"the investment id is #{@investment.id}\"\n #puts \"this is id #{@user.id}\"\n end", "def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def index\n @api_v1_mentorship_interests = Api::V1::MentorshipInterest.all\n end", "def update\n if @investment.update(investment_params)\n render json: @investment, status: :ok\n else\n render json: @investment.errors, status: :unprocessable_entity\n end\n end", "def set_investment\n #@investment = Investment.find(params[:id])\n end", "def index\n @expenses = find_expenses.all\n render json: @expenses\n end", "def index\n @investment_declaration = InvestmentDeclaration.new\n @investment_declarations = InvestmentDeclaration.all\n @policy_details = PolicyDetail.all\n @investment_declaration = InvestmentDeclaration.find(params[:investment_declaration_id])\n end", "def index\n @investments = Investment.order((sort_column + \" \" + sort_direction))\n @investments = @investments.search(params[:search])\n end", "def index\n @employments = Employment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employments }\n end\n end", "def index\n @endorsements = Endorsement.all\n\n render json: @endorsements\n end", "def index\n @expenses = Expense.all\n respond_with @expenses\n end", "def investment_params\n params.require(:investment).permit(:feature_id, :team_id, :investment)\n end", "def create\n puts \"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\"\n @investment = Investment.new(amount:params[:amount])\n\n respond_to do |format|\n if @investment.save\n format.html { redirect_to @investment, notice: 'Investment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @investment }\n else\n format.html { render action: 'new' }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @investigationcauses = Investigationcause.all\n end", "def new\n @investment_type = InvestmentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @investment_type }\n end\n end", "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to investments_url }\n format.json { head :no_content }\n end\n end", "def show\n @investigation = Investigation.find(params[:id])\n @names = @investigation.names\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @investigation }\n end\n end", "def index\n @entertainments = Entertainment.all\n end", "def index\n @departments = Department.all\n respond_to do |format|\n format.json{ render json: @departments}\n end\n end", "def index\n @incomes = Income.all\n\n respond_to do |format|\n format.json { render json: @incomes }\n end\n end", "def index\n @establishments = Establishment.all\n end", "def index\n @establishments = Establishment.all\n end", "def create\n @investment = Investment.new(investment_params)\n\n respond_to do |format|\n if @investment.save\n format.html { redirect_to @investment, notice: 'Investment was successfully created.' }\n format.json { render :show, status: :created, location: @investment }\n else\n format.html { render :new }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @projeto = Projeto.find(params[:id])\n @enrollments = Enroll.find_all_by_projeto_id params[:id]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projeto }\n end\n end", "def details(investor_payment_id)\n API::request(:get, \"investor_payments/#{investor_payment_id}\")\n end", "def index\n @peds = Ped.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peds }\n end\n end", "def investor_payments(entity_id)\n API::request(:get, \"entities/#{entity_id}/investor_payments\")\n end", "def index\n @company_investors = CompanyInvestor.all\n end", "def show\n @userin = UserInvestor.find(params[:id])\n if @userin.present?\n data = @userin.as_json(include: %i[product_invest])\n render json: { status: 'OK', results: data, errors: nil }, status: :ok\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'user does not exist' },\n status: :not_found\n end\n end", "def index\n @petty_cash_expenses = PettyCashExpense.all\n render json: @petty_cash_expenses\n end", "def index\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @leases }\n end\n end", "def index\n @ef_mentals = EfMental.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ef_mentals }\n end\n end", "def index\n @arrangements = Arrangement.query_list(params[:auction_id], params[:accept_status])\n render json: @arrangements, status: 200\n end", "def view\n\t\t\t@investor = Investor.find params[:id]\n\t\tend", "def index\n @funds = Fund.all\n\n render json: @funds\n end", "def set_investable\n @investable = Investable.find(params[:id])\n end", "def index\n @investigation_groups = InvestigationGroup.all\n end", "def index\n @incomes = current_company.incomes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @incomes }\n end\n end", "def index\n @api_v1_expenses = Api::V1::Expense.all\n end", "def index\n @deseases = Desease.order(:id)\n\n render json: @deseases\n end", "def index\n @involvements = Involvement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @involvements }\n end\n end", "def destroy\n @investable.destroy\n respond_to do |format|\n format.html { redirect_to investables_url }\n format.json { head :no_content }\n end\n end", "def set_investigated\n @investigated = Investigated.find(params[:id])\n end", "def new\n @player_investment = PlayerInvestment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @player_investment }\n end\n end", "def index_approvable\n @asset_info_adjustments = AssetInfoAdjustment.accessible_by(current_ability, :approve).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html { render \"index\" }\n format.json { render json: @asset_info_adjustments }\n format.xml { render xml: @asset_info_adjustments }\n end\n end", "def index\n puts session[:_csrf_token]\n @departments = Department.all\n render json: @departments, status: :ok\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @extended_warranties = ExtendedWarranty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @extended_warranties }\n end\n end", "def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end", "def index\n @involvements = Involvement.all\n end", "def index\n if (params[:client_id])\n @engagements = Engagement.find_all_by_client_id(params[:client_id])\n else\n @engagements = Engagement.all\n end\n\n respond_with(@engagements)\n end", "def set_investigacion\n @investigacion = Investigacion.find(params[:id])\n end", "def investor_sector\n @investor = Investor.find(params[:id])\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end", "def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end", "def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end", "def index\n @inciting_incidents = IncitingIncident.all\n render json: @inciting_incidents\n end", "def show\n @expense = current_user.organization.expenses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @person_expense_records = PersonExpenseRecord.all\n\n render json: @person_expense_records\n end", "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to investments_url, notice: 'Investment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to investments_url, notice: 'Investment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @investigated = Investigated.new(investigated_params)\n\n respond_to do |format|\n if @investigated.save\n format.html { redirect_to @investigated, notice: 'Investigated was successfully created.' }\n format.json { render :show, status: :created, location: @investigated }\n else\n format.html { render :new }\n format.json { render json: @investigated.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interests }\n end\n end", "def index\n @investigators = (@organization ? @organization.investigators : Investigator).search(params[:q], :page => params[:page], :total_entries => @total_entries)\n\n respond_to do |format|\n format.html {\n if @investigators.size == 0\n @organizations = Organization.search(params[:q], :page => params[:page])\n if @organizations.size > 0\n redirect_to organizations_path(params)\n end\n elsif params.key?(:q) and @investigators.size == 1\n redirect_to investigator_path(@investigators[0])\n end\n } # index.html.erb\n format.xml { render :xml => @investigators }\n end\n end", "def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @interests }\n end\n end", "def index\n @points_spents = PointsSpent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @points_spents }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @financials }\n end\n end" ]
[ "0.7938945", "0.7190257", "0.71611875", "0.6985033", "0.69051164", "0.6877576", "0.68006974", "0.67372435", "0.66845745", "0.6632461", "0.6598962", "0.6554188", "0.6550055", "0.6512522", "0.6326754", "0.6315476", "0.6315378", "0.6278007", "0.62501585", "0.62358487", "0.6231864", "0.6149841", "0.6149087", "0.6141594", "0.6141594", "0.6141594", "0.6141594", "0.6141594", "0.6125379", "0.6101372", "0.6087168", "0.6074531", "0.6050619", "0.6009269", "0.600801", "0.6001934", "0.59924155", "0.5990676", "0.5980521", "0.59664094", "0.5961244", "0.5959482", "0.5958487", "0.5954106", "0.5933589", "0.5923212", "0.5917518", "0.5860751", "0.5858075", "0.5858075", "0.5852915", "0.58512527", "0.58443826", "0.5829393", "0.5828385", "0.5814051", "0.58127195", "0.5809496", "0.580777", "0.58050865", "0.5802753", "0.58012676", "0.57976645", "0.5795367", "0.57943404", "0.57796216", "0.57755286", "0.5760852", "0.5749879", "0.57460314", "0.5732887", "0.57297736", "0.5724746", "0.5721237", "0.57165223", "0.5716226", "0.5708514", "0.57007354", "0.5693719", "0.5688764", "0.5686304", "0.5685949", "0.5685949", "0.5685949", "0.5685949", "0.5685949", "0.56799245", "0.56799245", "0.56799245", "0.56775004", "0.5676622", "0.56708395", "0.56658274", "0.56658274", "0.5654713", "0.5654712", "0.5654502", "0.56544834", "0.5654161", "0.5645516" ]
0.8015847
0
GET /investments/1 GET /investments/1.json
def show @investment = Investment.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @investments = Investment.all\n\n respond_to do |format|\n format.html\n format.json\n end\n end", "def index\n @investments = Investment.all\n\n render json: {investments: @investments}, root: false\n end", "def show\n render json: @investment, root: false\n end", "def show\n @investigation = Investigation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @investigation }\n end\n end", "def show\n @investment_type = InvestmentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @investment_type }\n end\n end", "def index\n @investables = Investable.all\n end", "def index\n @investigations = Investigation.where(:visible => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @investigations }\n end\n end", "def show\n @invest = Invest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @invest }\n end\n end", "def index\n @investigations = Investigation.all\n end", "def index\n @investment_funds = InvestmentFund.all\n end", "def index\n @investments = Investment.all.paginate(:page => params[:page], :per_page => 30)\n end", "def index\n @investments = Investment.all\n @user=User.find(session[:user_id])\n puts \"the user id is #{@user.id}\"\n @investment=@user.investments.first\n #puts \"the investment id is #{@investment.id}\"\n #puts \"this is id #{@user.id}\"\n end", "def index\n @wallet_id = params[:wallet_id]\n @investment_funds = InvestmentFund.where(\"wallet_id = ?\", @wallet_id)\n end", "def new\n @investigation = Investigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @investigation }\n end\n end", "def show\n @player_investment = PlayerInvestment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_investment }\n end\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n #@investment = Investment.find(params[:id])\n end", "def index\n @individual_company_investments = IndividualCompanyInvestment.all\n end", "def index\r\n @fixed_deposit_investments = FixedDepositInvestment.all\r\n end", "def index\n @investigadores = Investigador.all\n end", "def view\n\t\t\t@investor = Investor.find params[:id]\n\t\tend", "def create\n @investment = Investment.new(investment_params)\n\n if @investment.save\n render json: @investment, status: :created\n else\n render json: @investment.errors, status: :unprocessable_entity\n end\n end", "def index\n @investors = params[:q].present? ? Investor.search(params[:q]) : Investor.all\n @investors = @investors.includes(:investment_group, :consultant).ordered.\n page(params[:page]).references(:investment_group, :consultant)\n end", "def new\n @investment_type = InvestmentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @investment_type }\n end\n end", "def update\n if @investment.update(investment_params)\n render json: @investment, status: :ok\n else\n render json: @investment.errors, status: :unprocessable_entity\n end\n end", "def details(investor_payment_id)\n API::request(:get, \"investor_payments/#{investor_payment_id}\")\n end", "def index\n @investment_declaration = InvestmentDeclaration.new\n @investment_declarations = InvestmentDeclaration.all\n @policy_details = PolicyDetail.all\n @investment_declaration = InvestmentDeclaration.find(params[:investment_declaration_id])\n end", "def index\n @fund_company_investments = FundCompanyInvestment.all\n end", "def create\n puts \"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\"\n @investment = Investment.new(amount:params[:amount])\n\n respond_to do |format|\n if @investment.save\n format.html { redirect_to @investment, notice: 'Investment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @investment }\n else\n format.html { render action: 'new' }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @investigation = Investigation.find(params[:id])\n @names = @investigation.names\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @investigation }\n end\n end", "def index\n @investigaciones = Investigacion.search.page params[:page]\n end", "def index \n\n\n @investigateds = Investigated.all\n total_count = @investigateds.count\n respond_to do |format|\n format.html { }\n format.json { render json: { total: total_count, investigateds: @investigateds.map { |s| {id: s.id, name: s.name, lastname1: s.lastname1 } } } }\n end\n end", "def show\n @stock_market_invest_log = StockMarketInvestLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_market_invest_log }\n end\n end", "def show\n @expense = current_user.organization.expenses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def investor_sector\n @investor = Investor.find(params[:id])\n end", "def set_investable\n @investable = Investable.find(params[:id])\n end", "def set_investigacion\n @investigacion = Investigacion.find(params[:id])\n end", "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to investments_url }\n format.json { head :no_content }\n end\n end", "def show\n @userin = UserInvestor.find(params[:id])\n if @userin.present?\n data = @userin.as_json(include: %i[product_invest])\n render json: { status: 'OK', results: data, errors: nil }, status: :ok\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'user does not exist' },\n status: :not_found\n end\n end", "def create\n @investment = Investment.new(investment_params)\n\n respond_to do |format|\n if @investment.save\n format.html { redirect_to @investment, notice: 'Investment was successfully created.' }\n format.json { render :show, status: :created, location: @investment }\n else\n format.html { render :new }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @draft_investment = DraftInvestment.find(params[:id])\n\n respond_to do |format|\n\n format.xml { render :xml => @draft_investment }\n end\n end", "def show\n @investigator = Investigator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @investigator }\n end\n end", "def index\n @api_v1_mentorship_interests = Api::V1::MentorshipInterest.all\n end", "def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def show\n @estimate = Estimate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estimate }\n end\n end", "def set_investigated\n @investigated = Investigated.find(params[:id])\n end", "def show\n @revenue = Revenue.find(params[:id])\n\n render json: @revenue\n end", "def set_investment_fund\n @investment_fund = InvestmentFund.find(params[:id])\n end", "def set_investment_fund\n @investment_fund = InvestmentFund.find(params[:id])\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def show\n @income_entry = IncomeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @income_entry }\n end\n end", "def show\n @projeto = Projeto.find(params[:id])\n @enrollments = Enroll.find_all_by_projeto_id params[:id]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projeto }\n end\n end", "def create\n @invest = Invest.new(params[:invest])\n\n respond_to do |format|\n if @invest.save\n format.html { redirect_to(@invest, :notice => 'Invest was successfully created.') }\n format.xml { render :xml => @invest, :status => :created, :location => @invest }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @invest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @invest = Invest.find(params[:id])\n @invest.destroy\n\n respond_to do |format|\n format.html { redirect_to(invests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @investable.destroy\n respond_to do |format|\n format.html { redirect_to investables_url }\n format.json { head :no_content }\n end\n end", "def new\n @player_investment = PlayerInvestment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @player_investment }\n end\n end", "def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end", "def show\n @income = Income.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @income }\n end\n end", "def show\n @medium_mission_inv = MediumMissionInv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_mission_inv }\n end\n end", "def index\n @incomes = Income.all\n\n respond_to do |format|\n format.json { render json: @incomes }\n end\n end", "def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end", "def set_investigador\n @investigador = Investigador.find(params[:id])\n end", "def index\n @investigationcauses = Investigationcause.all\n end", "def index\n @api_v1_expenses = Api::V1::Expense.all\n end", "def show\n @commitment = Commitment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @commitment }\n end\n end", "def show\n @unsolved = Unsolved.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unsolved }\n end\n end", "def create\n @investigated = Investigated.new(investigated_params)\n\n respond_to do |format|\n if @investigated.save\n format.html { redirect_to @investigated, notice: 'Investigated was successfully created.' }\n format.json { render :show, status: :created, location: @investigated }\n else\n format.html { render :new }\n format.json { render json: @investigated.errors, status: :unprocessable_entity }\n end\n end\n end", "def investor(id:)\n Investor.find(id)\n end", "def new\n @invest = Invest.new\n @invest.seq = get_next_seq(Invest)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @invest }\n end\n end", "def investment_params\n params.require(:investment).permit(:feature_id, :team_id, :investment)\n end", "def set_investor\n @investor = ::Cap::Table::Investor.find(params[:id])\n end", "def show\n @ledger_entries = @invoice.ledger_entries.page(params[:page])\n respond_with @organization, @invoice\n end", "def show\n @expense = TblReceipt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense }\n end\n end", "def index\n @funds = Fund.all\n\n render json: @funds\n end", "def index\n @incomes = current_company.incomes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @incomes }\n end\n end", "def show\n @expense_state = ExpenseState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense_state }\n end\n end", "def index\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @leases }\n end\n end", "def show\n @anniversary = Anniversary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @anniversary }\n end\n end", "def index\n @employments = Employment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employments }\n end\n end", "def show\n @annual_stat = AnnualStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @annual_stat }\n end\n end", "def index\n @company_investors = CompanyInvestor.all\n end", "def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @interest }\n end\n end", "def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end", "def show\n @fundamentals_history = @company.fundamentals_histories.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fundamentals_history }\n end\n end", "def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interest }\n end\n end", "def create\n @investable = Investable.new(investable_params)\n\n respond_to do |format|\n if @investable.save\n format.html { redirect_to @investable, notice: 'Investable was successfully created.' }\n format.json { render action: 'show', status: :created, location: @investable }\n else\n format.html { render action: 'new' }\n format.json { render json: @investable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investment.update(investment_params)\n format.html { redirect_to @investment, notice: 'Investment was successfully updated.' }\n format.json { render :show, status: :ok, location: @investment }\n else\n format.html { render :edit }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investment.update(investment_params)\n format.html { redirect_to @investment, notice: 'Investment was successfully updated.' }\n format.json { render :show, status: :ok, location: @investment }\n else\n format.html { render :edit }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @investment_type = InvestmentType.find(params[:id])\n @investment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to investment_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to investments_url, notice: 'Investment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to investments_url, notice: 'Investment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.78003675", "0.7705234", "0.7289373", "0.71217364", "0.70874935", "0.6921958", "0.6823459", "0.6760489", "0.67382467", "0.6684904", "0.66459566", "0.65948385", "0.65658617", "0.65514493", "0.6546267", "0.64925194", "0.64925194", "0.64925194", "0.64925194", "0.64925194", "0.64856803", "0.6480741", "0.64064187", "0.64056385", "0.6396857", "0.6384628", "0.6379843", "0.63275266", "0.6321407", "0.6286022", "0.6276702", "0.6262291", "0.621294", "0.62045085", "0.62045085", "0.62045085", "0.62045085", "0.62045085", "0.6160961", "0.6148813", "0.6130999", "0.6130554", "0.61222965", "0.61152023", "0.61082023", "0.60993016", "0.6097807", "0.60543334", "0.6045964", "0.60361814", "0.6033885", "0.60302263", "0.60265946", "0.6011693", "0.60111016", "0.6008286", "0.60049385", "0.60049385", "0.6003312", "0.6003184", "0.6000427", "0.5979651", "0.5976817", "0.596088", "0.5955338", "0.59487283", "0.5947331", "0.5942661", "0.5941285", "0.5925011", "0.59161884", "0.59118015", "0.58912915", "0.58755034", "0.5873583", "0.5870128", "0.5867368", "0.5862924", "0.5862219", "0.58513725", "0.58513474", "0.58486384", "0.5844728", "0.58383876", "0.58284223", "0.58246285", "0.5820901", "0.5819404", "0.5814839", "0.5812519", "0.5807419", "0.5806067", "0.580601", "0.5803435", "0.5797839", "0.57964754", "0.57964754", "0.5794601", "0.57911307", "0.57911307" ]
0.7187704
3
PATCH/PUT /investments/1 PATCH/PUT /investments/1.json
def update respond_to do |format| if @investment.update(investment_params) format.html { redirect_to @investment, notice: 'Investment was successfully updated.' } format.json { render :show, status: :ok, location: @investment } else format.html { render :edit } format.json { render json: @investment.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @investment.update(investment_params)\n render json: @investment, status: :ok\n else\n render json: @investment.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @investment.update(investment_params)\n format.html { redirect_to @investment, notice: 'Investment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investable.update(investable_params)\n format.html { redirect_to @investable, notice: 'Investable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @investable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @individual_company_investment.update(individual_company_investment_params)\n format.html { redirect_to @individual_company_investment, notice: 'Individual company investment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @individual_company_investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @invest = Invest.find(params[:id])\n\n respond_to do |format|\n if @invest.update_attributes(params[:invest])\n format.html { redirect_to(@invest, :notice => 'Invest was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investigated.update(investigated_params)\n format.html { redirect_to @investigated, notice: 'Investigated was successfully updated.' }\n format.json { render :show, status: :ok, location: @investigated }\n else\n format.html { render :edit }\n format.json { render json: @investigated.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @investigation = Investigation.find(params[:id])\n\n respond_to do |format|\n if @investigation.update_attributes(params[:investigation])\n format.html { redirect_to @investigation, notice: 'Investigation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @investigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @feature = Feature.find(@investment.feature_id) #feature is needed for the redirect\n if @investment.update(investment_params)\n format.html { redirect_to @feature, notice: 'Investment was successfully updated.' }\n format.json { render @investment, status: :ok, location: @investment }\n else\n errors = add_errors\n format.html { redirect_to edit_investment_path(@investment, :errors => errors) }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fund_company_investment.update(fund_company_investment_params)\n format.html { redirect_to @fund_company_investment, notice: 'Fund company investment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fund_company_investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @investment_type = InvestmentType.find(params[:id])\n\n respond_to do |format|\n if @investment_type.update_attributes(params[:investment_type])\n format.html { redirect_to investment_types_path, notice: 'Investment type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @investment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investigation.update(investigation_params)\n format.html { redirect_to @investigation, notice: 'Investigation was successfully updated.' }\n format.json { render :show, status: :ok, location: @investigation }\n else\n format.html { render :edit }\n format.json { render json: @investigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @draft_investment = DraftInvestment.find(params[:id])\n\n respond_to do |format|\n if @draft_investment.update_attributes(params[:investment])\n\n format.xml \n else\n\n format.xml { render :xml => @draft_investment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_investments investment_type\n if self.investment_type.nil?\n self.create_investments investment_type\n else\n self.investment_type.update!(:fix_income => investment_type[:fix_income], :equity=> investment_type[:equity], :gold=> investment_type[:gold], :land_and_estate=> investment_type[:land_and_estate])\n end\n end", "def update\n respond_to do |format|\n if @investment_fund.update(investment_fund_params)\n format.html { redirect_to @investment_fund, notice: 'Investment fund was successfully updated.' }\n format.json { render :show, status: :ok, location: @investment_fund }\n else\n format.html { render :edit }\n format.json { render json: @investment_fund.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investment_fund.update(investment_fund_params)\n format.html { redirect_to @investment_fund, notice: 'Investment fund was successfully updated.' }\n format.json { render :show, status: :ok, location: @investment_fund }\n else\n format.html { render :edit }\n format.json { render json: @investment_fund.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investigador.update(investigador_params)\n format.html { redirect_to investigadore_path(@investigador), notice: \"Investigador was successfully updated.\" }\n format.json { render :show, status: :ok, location: @investigador }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @investigador.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ico_etz_investment.update(ico_etz_investment_params)\n format.html { redirect_to ico_etz_investment_path(@ico_etz_investment), notice: 'Etz investment was successfully updated.' }\n format.json { render :show, status: :ok, location: @ico_etz_investment }\n else\n format.html { render :edit }\n format.json { render json: @ico_etz_investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @fixed_deposit_investment.update(fixed_deposit_investment_params)\r\n format.html { redirect_to @fixed_deposit_investment, notice: 'Fixed deposit investment was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @fixed_deposit_investment }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @fixed_deposit_investment.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @company_investor.update(company_investor_params)\n format.html { redirect_to @company_investor, notice: 'Company investor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @company_investor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_expense.update(api_v1_expense_params)\n format.html { redirect_to @api_v1_expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_expense }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end", "def update\n @investigation = Investigation.find(params[:id])\n\n respond_to do |format|\n if @investigation.update_attributes(params[:investigation])\n format.html { redirect_to(@investigation, :notice => 'Investigation was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @investigation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n resource.update(deposit_contract_params)\n respond_with client, resource\n end", "def update\n respond_to do |format|\n if @employment_contract.update(employment_contract_params)\n format.html { redirect_to request_steps_path, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @employment_contract }\n else\n format.html { render :edit }\n format.json { render json: @employment_contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n ActiveRecord::Base.transaction do\n respond_to do |format|\n if @investigacion.update(investigacion_params)\n format.html { redirect_to @investigacion, notice: 'La Investigacion se actualizo correctamente.' }\n format.json { render :show, status: :ok, location: @investigacion }\n else\n format.html { render :edit }\n format.json { render json: @investigacion.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n @player_investment = PlayerInvestment.find(params[:id])\n\n respond_to do |format|\n if @player_investment.update_attributes(params[:player_investment])\n format.html { redirect_to @player_investment, notice: 'Player investment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player_investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @investor.update investor_params\n redirect_to @investor\n else\n render 'edit'\n end\n end", "def update\n @expense = Expense.find params.fetch(:id)\n\n if @expense.update(expense_params)\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @individual_portfolio_invesetment.update(individual_portfolio_invesetment_params)\n format.html { redirect_to @individual_portfolio_invesetment, notice: 'Individual portfolio invesetment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @individual_portfolio_invesetment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interested = Interested.find(params[:id])\n\n respond_to do |format|\n if @interested.update_attributes(params[:interested])\n format.html { redirect_to @interested, notice: 'Interested was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interested.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to :json\n\n if @expense_claim.update(expense_claim_params)\n head :ok\n else\n render partial: 'expense_claim_key_data', layout: false, status: :ok, locals: { expense_claim: @expense_claim }\n end\n end", "def update\n respond_to do |format|\n if @api_v1_mentorship_interest.update(api_v1_mentorship_interest_params)\n format.html { redirect_to @api_v1_mentorship_interest, notice: 'Mentorship interest was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_mentorship_interest }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_mentorship_interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investigationcause.update(investigationcause_params)\n format.html { redirect_to @investigationcause.investigation, notice: 'Investigationcause was successfully updated.' }\n format.json { render :show, status: :ok, location: @investigationcause }\n else\n format.html { render :edit }\n format.json { render json: @investigationcause.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \t\t@interested = Interested.find(params[:id])\n\n \t\trespond_to do |format|\n \t\t\tif @interested.update_attributes(params[:interested])\n \t\t\tformat.html { redirect_to @interested, notice: 'Interested was sucessfully updated.' }\n \t\t\tformat.json {head :no_content }\n \t\t\telse\n \t\t\t\tformat.html { render action: \"edit\" }\n \t\t\t\tformat.json { render json: @interested.error, status: :unprocessable_entity }\n \t\t\tend\n \t\tend\n \tend", "def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @carrera_investigacion.update(carrera_investigacion_params)\n format.html { redirect_to @carrera_investigacion, notice: 'Carrera investigacion was successfully updated.' }\n format.json { render :show, status: :ok, location: @carrera_investigacion }\n else\n format.html { render :edit }\n format.json { render json: @carrera_investigacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n standard_update(Interest, params[:id], interest_params)\n end", "def update\n contract = Contract.find_by_id(params[:id])\n (head :unauthorized unless contract) and return\n \n # try to update the attributes\n if contract.update_attributes(edit_contract_params)\n render json: contract\n else\n render json: { errors: contract.error.full_messages}\n end\n end", "def update\n respond_to do |format|\n if @investment.update(investment_params)\n update_staffs\n if investment_params[:background_image].present?\n redirect_to investment_crop_url(@investment) and return\n else\n format.html { redirect_to @investment, notice: 'Investment was successfully updated.' }\n format.json { render :show, status: :ok, location: @investment }\n end\n else\n flash[:danger] = @investment.errors.full_messages.join(', ')\n format.html { render :edit }\n format.json { render json: @investment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enviroment.update(enviroment_params)\n format.html { redirect_to @enviroment, notice: 'Enviroment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enviroment }\n else\n format.html { render :edit }\n format.json { render json: @enviroment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @enviroment.update(enviroment_params)\n format.html { redirect_to @enviroment, notice: 'Enviroment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enviroment }\n else\n format.html { render :edit }\n format.json { render json: @enviroment.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_investment\n #@investment = Investment.find(params[:id])\n end", "def update\n budgets = update_budgets(params[:budgets])\n\n render json: budgets, status: :ok\n end", "def update\n respond_to do |format|\n if @personal_finance.update(personal_finance_params)\n format.html { redirect_to @personal_finance, notice: 'Personal finance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @personal_finance.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n #format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { head :ok }\n else\n #format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def set_investment\n @investment = Investment.find(params[:id])\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @income = current_company.incomes.find(params[:id])\n\n respond_to do |format|\n if @income.update_attributes(params[:income])\n format.html { redirect_to incomes_path, notice: 'Income was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @petty_cash_expense.update(petty_cash_expense_params)\n format.json { render :show, status: :ok, location: @petty_cash_expense }\n else\n format.json { render json: @petty_cash_expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.html { redirect_to expenses_url, notice: 'Expense was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contract = Contract.find(params[:id])\n\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n format.html { redirect_to @contract.lead, notice: 'Contract was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def investment_params\n params.require(:investment).permit(:feature_id, :team_id, :investment)\n end", "def update\n respond_to do |format|\n if @individual.update(individual_params)\n format.html { redirect_to @individual, notice: 'Individual was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @individual.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_investment_fund\n @investment_fund = InvestmentFund.find(params[:id])\n end", "def set_investment_fund\n @investment_fund = InvestmentFund.find(params[:id])\n end", "def update\n respond_to do |format|\n if @budget_approver.update(budget_approver_params)\n format.html { redirect_to @budget_approver, notice: 'Budget approver page was successfully updated.' }\n format.json { render :show, status: :ok, location: @budget_approver }\n else\n format.html { render :edit }\n format.json { render json: @budget_approver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # Si no existen éstos campos no se guarda y crea un mensaje.\n if (!@investigation.nombre.present? or !@investigation.descripcion.present?)\n redirect_to request.referrer, notice: 'Complete todos los campos.!'\n else\n respond_to do |format|\n if @investigation.update(investigation_params)\n format.html { redirect_to @investigation, notice: 'Trabajo de investigación´actualizado.' }\n format.json { render :show, status: :ok, location: @investigation }\n else\n format.html { render :edit }\n format.json { render json: @investigation.errors, status: :unprocessable_entity }\n end\n end\n end \n end", "def update\n @income = Income.find(params[:id])\n\n respond_to do |format|\n if @income.update_attributes(income_params)\n format.html { redirect_to @income, notice: 'Income was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to edit_expense_path(@expense), notice: 'Expense was successfully updated.' }\n format.json { render :edit, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, :notice => 'Interest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @enhancement = Enhancement.find(params[:id])\n\n respond_to do |format|\n if @enhancement.update_attributes(params[:enhancement])\n format.html { redirect_to @enhancement, notice: 'Enhancement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enhancement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @spent.update(spent_params)\n format.html { redirect_to @spent, notice: 'Spent was successfully updated.' }\n format.json { render :show, status: :ok, location: @spent }\n else\n format.html { render :edit }\n format.json { render json: @spent.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @investigation_group.update(investigation_group_params)\n format.html { redirect_to @investigation_group, notice: 'Investigation group was successfully updated.' }\n format.json { render :show, status: :ok, location: @investigation_group }\n else\n format.html { render :edit }\n format.json { render json: @investigation_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person_expense_record = PersonExpenseRecord.find(params[:id])\n\n if @person_expense_record.update(person_expense_record_params)\n head :no_content\n else\n render json: @person_expense_record.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to expenses_path, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to :back, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { redirect :back}\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense = Expense.find(params[:id])\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n format.json { head :ok }\n format.js\n else\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n @employment = Employment.find(params[:id])\n\n respond_to do |format|\n if @employment.update_attributes(params[:employment])\n format.html { redirect_to @employment, notice: 'Employment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @employment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to '/expenses', notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, notice: 'Interest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t @service = servicio\n\t @experience = @service.experiences.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tif @experience.update(experience_params)\n\t\t\t\tformat.html { redirect_to experience_path(@experience), notice: 'La experiencia se ha modificado exitosamente.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @experience }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @experience.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @expense.update(expense_params)\n format.html { redirect_to @expense, notice: 'Expense was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @commitment = Commitment.find(params[:id])\n\n respond_to do |format|\n if @commitment.update_attributes(params[:commitment])\n format.html { redirect_to @commitment, notice: 'Commitment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @commitment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @capartment.update(capartment_params)\n format.html { redirect_to calc_apartments_path, notice: 'Capartment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @capartment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @fund.update(fund_params)\n head :no_content\n else\n render json: @fund.errors, status: :unprocessable_entity\n end\n end", "def update\n @budget = Budget.find(params[:id])\n\n respond_to do |format|\n if @budget.update_attributes(params[:budget])\n format.html { redirect_to @budget, notice: 'Budget was successfully updated.' }\n # format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n # format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @budget = Budget.find(params[:id])\n\n respond_to do |format|\n if @budget.update_attributes(params[:budget])\n format.html { redirect_to @budget, notice: 'Budget was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @budget = Budget.find(params[:id])\n\n respond_to do |format|\n if @budget.update_attributes(params[:budget])\n format.html { redirect_to @budget, notice: 'Budget was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @establishment.update(establishment_params)\n format.html { redirect_to @establishment, notice: 'Establishment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @establishment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(update_params)\n format.html { redirect_to_leaf_notice(UPDATE_SUCCESS) }\n format.json { render :show, status: :ok, location: @contract }\n else\n unprocessable_response(format)\n end\n end\n end", "def update\n @income_entry = IncomeEntry.find(params[:id])\n\n respond_to do |format|\n if @income_entry.update_attributes(params[:income_entry])\n format.html { redirect_to @income_entry, notice: 'Income entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @income_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inventory_own.update(inventory_own_params)\n format.html { redirect_to @inventory_own }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @inventory_own.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @employment\n respond_to do |format|\n\n if @employment.update(employment_params)\n format.html { redirect_to openings_path, notice: 'Employment was successfully updated.' }\n format.json { render :show, status: :ok, location: @employment }\n else\n format.html { redirect_to openings_path }\n format.json { render json: @employment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interesting = Interesting.find(params[:id])\n\n respond_to do |format|\n if @interesting.update_attributes(params[:interesting])\n format.html { redirect_to @interesting, notice: 'Interesting was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interesting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium_mission_inv = MediumMissionInv.find(params[:id])\n\n respond_to do |format|\n if @medium_mission_inv.update_attributes(params[:medium_mission_inv])\n format.html { redirect_to @medium_mission_inv, notice: 'Medium mission inv was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_mission_inv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @planets_exoplanet = Planets::Exoplanet.find(params[:id])\n\n respond_to do |format|\n if @planets_exoplanet.update_attributes(params[:planets_exoplanet])\n format.html { redirect_to @planets_exoplanet, :notice => 'Exoplanet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @planets_exoplanet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize @trip\n\n\n @trip.estimated_expenses.each do |exp|\n exp.requests.each do |req|\n req.amount_from_total = req.percentrequested * exp.total\n req.destination = @trip.destination\n req.expense_type = 'estimated'\n end\n end\n\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7436032", "0.7222304", "0.70660806", "0.69927675", "0.6985275", "0.6845567", "0.6717098", "0.66828084", "0.66499", "0.6646283", "0.65785193", "0.6573181", "0.65629935", "0.6558879", "0.6558879", "0.6555064", "0.65539455", "0.6488449", "0.64707756", "0.6405279", "0.63817567", "0.6365009", "0.6335286", "0.6331165", "0.6326913", "0.6315003", "0.62795126", "0.62765557", "0.6267568", "0.6248383", "0.6207626", "0.6178839", "0.61691606", "0.6166364", "0.6150667", "0.61402565", "0.61124295", "0.60939956", "0.60566986", "0.60376835", "0.60376835", "0.598876", "0.598876", "0.59864354", "0.5984548", "0.59837395", "0.5979532", "0.59691054", "0.59691054", "0.59691054", "0.59691054", "0.59691054", "0.5966584", "0.5957342", "0.5953578", "0.5947789", "0.59347045", "0.5932607", "0.59305376", "0.5924278", "0.5916349", "0.5916349", "0.59156203", "0.5909513", "0.5892521", "0.5887541", "0.58856857", "0.587852", "0.5872763", "0.5866513", "0.5860984", "0.5858426", "0.58576846", "0.58551615", "0.5850315", "0.5838409", "0.5838409", "0.5838409", "0.5837422", "0.5835965", "0.5834831", "0.58319694", "0.5831445", "0.5830339", "0.58289117", "0.5825078", "0.58205813", "0.58205813", "0.5817644", "0.58167845", "0.58033186", "0.58020616", "0.5801734", "0.58004034", "0.57977736", "0.57973", "0.5792124", "0.57857746", "0.57849145" ]
0.70902956
3
DELETE /investments/1 DELETE /investments/1.json
def destroy @investment.destroy respond_to do |format| format.html { redirect_to investments_url, notice: 'Investment was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to investments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @investable.destroy\n respond_to do |format|\n format.html { redirect_to investables_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @investigated.destroy\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @invest = Invest.find(params[:id])\n @invest.destroy\n\n respond_to do |format|\n format.html { redirect_to(invests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @individual_company_investment.destroy\n respond_to do |format|\n format.html { redirect_to individual_company_investments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @investigation.destroy\n respond_to do |format|\n # Redirige al index de investigations.\n format.html { redirect_to investigations_url, notice: 'Investigation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @investment_type = InvestmentType.find(params[:id])\n @investment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to investment_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ico_etz_investment.destroy\n respond_to do |format|\n format.html { redirect_to ico_etz_investments_url, notice: 'Etz investment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fund_company_investment.destroy\n respond_to do |format|\n format.html { redirect_to fund_company_investments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to feature_path(@investment.feature_id), notice: 'Investment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @investigador.destroy\n respond_to do |format|\n format.html { redirect_to investigadores_url, notice: \"Investigador was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @investment.destroy\n end", "def destroy\n @draft_investment = DraftInvestment.find(params[:id])\n @draft_investment.destroy\n\n respond_to do |format|\n\n format.xml { head :ok }\n end\n end", "def destroy\n @investigation.destroy\n respond_to do |format|\n format.html { redirect_to investigations_url, notice: 'Investigation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @investigation = Investigation.find(params[:id])\n @investigation.destroy\n\n respond_to do |format|\n format.html { redirect_to(investigations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @fixed_deposit_investment.destroy\r\n respond_to do |format|\r\n format.html { redirect_to fixed_deposit_investments_url, notice: 'Fixed deposit investment was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @investment_fund.destroy\n respond_to do |format|\n format.html { redirect_to wallets_path, notice: 'Investment fund was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @player_investment = PlayerInvestment.find(params[:id])\n @player_investment.destroy\n\n respond_to do |format|\n format.html { redirect_to player_investments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @api_v1_expense.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @investor.destroy\n redirect_to investors_url\n end", "def destroy\n ActiveRecord::Base.transaction do\n @investigacion.status = Status.find(Status::VALUES[:deleted])\n @investigacion.save validate: false\n respond_to do |format|\n format.html { redirect_to investigaciones_url, notice: 'La Investigacion se marco como borrada.' }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @company_investor.destroy\n respond_to do |format|\n format.html { redirect_to company_investors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @investment_fund.destroy\n respond_to do |format|\n format.html { redirect_to products_path, notice: 'Investment fund was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n respond_to do |format|\n if current_user && (@investment.investor_id.eql?(current_user.id) || current_user.admin?)\n @investment.destroy \n format.html { redirect_to investments_url, notice: 'Investment was successfully destroyed.' }\n format.json { head :no_content }\n else\n flash[:danger] = 'Unauthorized user!'\n format.html { redirect_to root_path }\n end\n end\n end", "def destroy\n @expense = Expense.find params.fetch(:id)\n @expense.destroy\n head :no_content\n end", "def destroy\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @carrera_investigacion.destroy\n respond_to do |format|\n format.html { redirect_to carrera_investigacions_url, notice: 'Carrera investigacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @estimate = Estimate.find(params[:id])\n @estimate.destroy\n\n respond_to do |format|\n format.html { redirect_to estimates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium_mission_inv = MediumMissionInv.find(params[:id])\n @medium_mission_inv.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_mission_invs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_mentorship_interest.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_mentorship_interests_url, notice: 'Mentorship interest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @investigation = Investigation.find(params[:id])\n @investigation.visible = false\n @investigation.save\n\n respond_to do |format|\n format.html { redirect_to investigations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @income = Income.find(params[:id])\n @income.destroy\n\n respond_to do |format|\n format.html { redirect_to incomes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end \n end", "def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end", "def destroy\n @spent.destroy\n respond_to do |format|\n format.html { redirect_to incomes_url, notice: 'Spent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @investigationcause.destroy\n respond_to do |format|\n format.html { redirect_to investigationcauses_url, notice: 'Investigationcause was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @individual_portfolio_invesetment.destroy\n respond_to do |format|\n format.html { redirect_to individual_portfolio_invesetments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to account_statement_url(params[:account_id],params[:statement_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = current_user.organization.expenses.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def delete\n\t\trender json: Investor.delete_by_id(params[:id])\n\tend", "def destroy\n respond_with @expense.destroy, status: 204\n end", "def destroy\n @income_entry = IncomeEntry.find(params[:id])\n @income_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to income_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @investment_declaration.destroy\n @investment_declaration = InvestmentDeclaration.new\n @investment_declarations = InvestmentDeclaration.all\n #redirect_to investment_declaration_self_services_path\n end", "def destroy\n @income = current_company.incomes.find(params[:id])\n @income.destroy\n\n respond_to do |format|\n format.html { redirect_to incomes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @expense.destroy\n \n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expensesbasis.destroy\n respond_to do |format|\n format.html { redirect_to [@post, @expensesbasis], notice: 'Expensesbase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_plan = ExercisePlan.find(params[:id])\n @exercise_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @deposit.destroy\n respond_to do |format|\n format.html { redirect_to deposits_url, notice: \"Deposit was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @deposit.destroy\n respond_to do |format|\n format.html { redirect_to deposits_url, notice: 'Deposit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @estimate.destroy\n respond_to do |format|\n format.html { redirect_to estimates_url, notice: 'Estimate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @estimate.destroy\n respond_to do |format|\n format.html { redirect_to estimates_url, notice: 'Estimate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person_expense_record.destroy\n\n head :no_content\n end", "def destroy\n @name_expense.destroy\n respond_to do |format|\n format.html { redirect_to name_expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @status_ativ = StatusAtiv.find(params[:id])\n @status_ativ.destroy\n\n respond_to do |format|\n format.html { redirect_to status_ativs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @income.destroy\n respond_to do |format|\n format.html { redirect_to incomes_url, notice: 'Income was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to budget_path(@line.budget) }\n format.json { head :no_content }\n end\n end", "def destroy\n @withdrawal = Withdrawal.find(params[:id])\n @withdrawal.destroy\n\n respond_to do |format|\n format.html { redirect_to withdrawals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html\n format.json { render head :ok }\n format.js { render :nothing => true }\n end\n end", "def destroy\n record = InvoiceLineItem.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @budget = Budget.find(params[:id])\n @budget.destroy\n\n respond_to do |format|\n format.html { redirect_to budgets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @income_payment.destroy\n respond_to do |format|\n format.html { redirect_to income_income_payments_url(@income), notice: 'Income payment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @personal_finance.destroy\n respond_to do |format|\n format.html { redirect_to personal_finances_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @deposit.destroy\r\n respond_to do |format|\r\n format.html { redirect_to deposits_url, notice: 'Deposit was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @budget = Budget.find(params[:id])\n @budget.destroy\n respond_to do |format|\n format.html { redirect_to budgets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @invent_journal_line = InventJournalLine.find(params[:id])\n @invent_journal_line.destroy\n\n respond_to do |format|\n format.html { redirect_to invent_journal_lines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @monthly_income.destroy\n respond_to do |format|\n format.html { redirect_to monthly_incomes_url, notice: \"Monthly income was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense_state = ExpenseState.find(params[:id])\n @expense_state.destroy\n\n respond_to do |format|\n format.html { redirect_to expense_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @establishment.destroy\n respond_to do |format|\n format.html { redirect_to establishments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @operating_expense = OperatingExpense.find(params[:id])\n @operating_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(operating_expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expense.destroy\n respond_to do |format|\n format.html {redirect_to expenses_url, notice: 'Expense was successfully destroyed.'}\n format.json {head :no_content}\n end\n end", "def destroy\n @lease = Lease.find(params[:id])\n @lease.destroy\n\n respond_to do |format|\n format.html { redirect_to leases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @annex = Annex.find(params[:id])\n @annex.destroy\n\n respond_to do |format|\n format.html { redirect_to annexes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @petty_cash_expense.destroy\n head :no_content \n end", "def destroy\n @planets_exoplanet = Planets::Exoplanet.find(params[:id])\n @planets_exoplanet.destroy\n\n respond_to do |format|\n format.html { redirect_to planets_exoplanets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @unpaid_debt = UnpaidDebt.find(params[:id])\n @unpaid_debt.destroy\n\n respond_to do |format|\n format.html { redirect_to unpaid_debts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expenditure = Expenditure.find(params[:id])\n @expenditure.destroy\n\n respond_to do |format|\n format.html { redirect_to expenditures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inven.destroy\n respond_to do |format|\n format.html { redirect_to invens_url, notice: 'Inven was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @round_expense = RoundExpense.find(params[:id])\n @round_expense.destroy\n\n respond_to do |format|\n format.html { redirect_to(round_expenses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @etat_depense.destroy\n respond_to do |format|\n format.html { redirect_to etat_depenses_url, notice: 'Etat depense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @invoice_status = InvoiceStatus.find(params[:id])\n @invoice_status.destroy\n\n respond_to do |format|\n format.html { redirect_to invoice_statuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rec_expense.destroy\n respond_to do |format|\n format.html { redirect_to rec_expenses_url, notice: 'Rec expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @finance_inflow = FinanceInflow.find(params[:id])\n @finance_inflow.destroy\n\n respond_to do |format|\n format.html { redirect_to finance_inflows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @withdrawal_request = WithdrawalRequest.find(params[:id])\n @withdrawal_request.destroy\n\n respond_to do |format|\n format.html { redirect_to withdrawal_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.79008186", "0.78626424", "0.7798032", "0.7760932", "0.75271136", "0.746929", "0.7452431", "0.74502695", "0.735179", "0.73415893", "0.7315725", "0.7307491", "0.73034465", "0.7295861", "0.7270416", "0.7250957", "0.7205344", "0.7169677", "0.71198225", "0.70978886", "0.70914876", "0.7073335", "0.70406556", "0.7018014", "0.69867367", "0.69616556", "0.6936895", "0.6936895", "0.6929678", "0.6929678", "0.6928929", "0.69152224", "0.6893442", "0.6882693", "0.6858721", "0.6847976", "0.68270624", "0.6815366", "0.68051136", "0.6795178", "0.67882997", "0.67871493", "0.6777619", "0.6768359", "0.6767384", "0.6759954", "0.67497367", "0.6740784", "0.67382395", "0.67327386", "0.6725267", "0.6716175", "0.67017275", "0.6699217", "0.66921926", "0.66921926", "0.66921926", "0.66921926", "0.66921926", "0.66921926", "0.66888785", "0.66888785", "0.66881984", "0.66768503", "0.6674572", "0.6672319", "0.66586494", "0.66586494", "0.6657089", "0.6651324", "0.66472876", "0.6646399", "0.66455036", "0.6643184", "0.66398513", "0.66348785", "0.66292626", "0.6628989", "0.6626684", "0.66257566", "0.6618804", "0.66171885", "0.66094166", "0.66025275", "0.659976", "0.659715", "0.6596216", "0.659386", "0.6593234", "0.6592571", "0.6586606", "0.65827245", "0.65802884", "0.65794986", "0.6573363", "0.6572988", "0.6565172", "0.6560574", "0.6558096" ]
0.7656909
5
Use callbacks to share common setup or constraints between actions.
def set_investment @investment = Investment.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def after_set_callback; end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def setup(&blk)\n @setup_block = blk\n end", "def default_action; end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def call\n setup_context\n super\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end" ]
[ "0.6165094", "0.60450804", "0.5944413", "0.5915806", "0.58885634", "0.5835225", "0.5775847", "0.5700531", "0.5700531", "0.56543404", "0.56209993", "0.54238355", "0.5410386", "0.5410386", "0.5410386", "0.5394892", "0.5377769", "0.53559244", "0.5339896", "0.53388095", "0.5330087", "0.5311993", "0.5297402", "0.5296789", "0.52957207", "0.52596015", "0.5245442", "0.5237084", "0.5237084", "0.5237084", "0.5237084", "0.5237084", "0.5235431", "0.5231888", "0.5226663", "0.52220625", "0.5217086", "0.52137345", "0.5208314", "0.5205469", "0.5175606", "0.5174914", "0.5173361", "0.51662856", "0.5161792", "0.51572216", "0.5153063", "0.5152982", "0.5152632", "0.51435786", "0.5139829", "0.51346594", "0.511372", "0.511372", "0.51136476", "0.51083213", "0.5108011", "0.5091935", "0.5089297", "0.5081576", "0.50807106", "0.50656676", "0.50548106", "0.50537366", "0.505074", "0.505074", "0.5033361", "0.5025158", "0.5020441", "0.5015611", "0.50142473", "0.5000281", "0.50001067", "0.49989453", "0.4989465", "0.4989465", "0.4985425", "0.49805096", "0.49795893", "0.49783278", "0.49676263", "0.49656346", "0.49579078", "0.4955427", "0.49554235", "0.49536413", "0.49523768", "0.49457142", "0.49433607", "0.4933641", "0.49320185", "0.49265638", "0.49262375", "0.49259067", "0.4922456", "0.49201223", "0.49165115", "0.49158815", "0.49151883", "0.49149552", "0.4914386" ]
0.0
-1
Fetch the two first characters (interpreted as AI) from the remaining data and try to find record class. If no record class was found, fetch a third character and try again, and then finally a forth, as no AI currently have more then 4 characters.
def record @record ||= process_ai_variants(2) || process_ai_variants(1) || process_ai_variants(1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preferred_264(fields)\n fields.select { |field| field.indicator1 == '3' && field.indicator2 == '1' }.last ||\n fields.select { |field| field.indicator2 == '1' }.last ||\n fields.select { |field| field.indicator1 == '3' && field.indicator2 =~ /[023]/ }.last ||\n fields.select { |field| field.indicator2 != '4' }.last\n end", "def next_match char\n data = get_content\n row = focussed_index + 1\n row.upto(data.length-1) do |ix|\n val = data[ix].chomp rescue return # 2010-01-05 15:28 crashed on trueclass\n #if val[0,1] == char #and val != currval\n if val[0,1].casecmp(char) == 0 #AND VAL != CURRval\n return ix\n end\n end\n row = focussed_index - 1\n 0.upto(row) do |ix|\n val = data[ix].chomp\n #if val[0,1] == char #and val != currval\n if val[0,1].casecmp(char) == 0 #and val != currval\n return ix\n end\n end\n return -1\n end", "def get_class(dns_query, parsed_dns)\n RECORD_CLASS[get_rdata_value(dns_query, parsed_dns, SHORT_LENGTH).to_i]\n end", "def first_char_idx\n dewey? ? 3 : 0\n end", "def handle_fifty_fifty(review)\n title = review.ars_title\n gb_titles = self.find_games_by_title(title)\n \n puts \"GB_TITLES: #{gb_titles.collect(&:name)}\"\n if gb_titles.nil?\n return nil\n end\n \n if gb_titles.size > 2\n raise ArgumentError\n end\n \n if gb_titles\n # Do we have at least one hit from Giant Bomb?\n if gb_titles.map{|g| g[\"name\"].downcase}.include?(title.downcase)\n # find a title using downcase. if we have multiple hits, it's probably multiple platforms\n # so just pick the first one\n match = gb_titles.select {|hash| hash[\"name\"].downcase == title.downcase}.first\n end\n end\n end", "def classify(record_name)\n record_name = invalid_names[record_name] || record_name\n return record_name.gsub(/(^|_)(.)/) { $2.upcase }\n end", "def get_class()\n result = nil\n @cont.each { |line|\n if line =~ /\\s*\\w+\\s*=/\n result = /\\w+/.match(line)[0]\n break\n end\n }\n return result\n end", "def bad_decode(letter1, letter2, letter3)\n new1 = \"abcdefghijklmnopqrstuvwxyz\".index(letter1) - 1\n puts \"abcdefghijklmnopqrstuvwxyz\"[new1.to_i]\n new2 = \"abcdefghijklmnopqrstuvwxyz\".index(letter2) - 1\n puts \"abcdefghijklmnopqrstuvwxyz\"[new2.to_i]\n new3 = \"abcdefghijklmnopqrstuvwxyz\".index(letter3) - 1\n puts \"abcdefghijklmnopqrstuvwxyz\"[new3.to_i]\nend", "def first_char_with_odd_ascii_gr8ter_80(input)\n input.find do |c|\n c.ord.odd? && c.ord > 80\n end\n end", "def find_key(cipher)\n (0..2).map do |offset|\n # Create a sublist starting at the given offset, taking every 3rd element\n elems = cipher.values_at(*(offset..cipher.length).step(3))\n # Find the most common item\n item = elems.group_by { |x| x }.values.max_by { |vs| vs.size }.first\n # We assume it's an int representing the ord of the space character\n item ^ \" \".ord\n end\nend", "def classify(word)\n return word unless rare? word\n case word\n when /^\\d+$/ then CARD\n when /^\\d+[.,;:]+$/ then CARDPUNCT\n when /^\\d+\\D+$/ then CARDSUFFIX\n when /^\\d+[.,;:\\-]+(\\d+[.,;:\\-]+)*\\d+$/ then CARDSEPS\n else UNKNOWN\n end\n end", "def guess_type(sequence_string)\n cleaned_sequence = sequence_string.gsub(/[^A-Z]/i, '') # removing non-letter characters\n cleaned_sequence.gsub!(/[NX]/i, '') # removing ambiguous characters\n\n return nil if cleaned_sequence.length < 10 # conservative\n\n composition = composition(cleaned_sequence)\n composition_NAs = composition.select {|character, count| character.match(/[ACGTU]/i)} # only putative NAs\n putative_NA_counts = composition_NAs.collect {|key_value_array| key_value_array[1]} # only count, not char\n putative_NA_sum = putative_NA_counts.inject {|sum, n| sum + n} # count of all putative NA\n putative_NA_sum = 0 if putative_NA_sum.nil?\n\n if putative_NA_sum > (0.9 * cleaned_sequence.length)\n return :nucleotide\n else\n return :protein\n end\n end", "def resume_builder(file_2data, regex)\n\t\t\tper = \"Not Found\"\n\n\t\t\tfor j in 0..file_2data.length-1\n\t\t\t\tif file_2data[j].match(regex)\n\t\t\t\t\tper = file_2data[j]\n\t\t\t\t\tper = per.split(\" \")[0]\n\t\t\t\t\treturn per\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn per\n\t\tend", "def penultimate3(string)\n string.split[string.split.size - 2]\nend", "def firstCommonClass(user_id)\n # get all of the self's courses and get all of the user_id's courses and see if there is any commonality and get the first commonality\n coursesForSelf = Course.where(\"user_id = '#{self.id}'\")\n coursesForUserId = Course.where(\"user_id = '#{user_id.to_s}'\")\n coursesForSelf.each do |courseForSelf|\n coursesForUserId.each do |courseForUserId|\n if courseForSelf.name == courseForUserId.name\n return courseForUserId.name\n end\n end\n end\n return nil\n end", "def top_char_downcase(field)\n check_str = field.split(\"_\").map {|word| word.capitalize }.join(\"\")\n head_str = check_str[0].downcase \n check_str.slice!(0)\n result = head_str + check_str\n end", "def top_char_downcase(field)\n check_str = field.split(\"_\").map {|word| word.capitalize }.join(\"\")\n head_str = check_str[0].downcase \n check_str.slice!(0)\n result = head_str + check_str\n end", "def best(str, ndigits=1)\n _best(str, ndigits) rescue str\n end", "def find_end_of_match(string, chars, score, first_index)\n last_index = first_index\n\n # Remember the type of the last character match for special scoring.\n last_type = nil\n\n chars.each do |this_char|\n # Where's the next occurrence of this character? The optimal algorithm\n # would consider all instances of query character, but that's slower\n # than this eager method.\n index = string.index(this_char, last_index + 1)\n\n # This character doesn't occur in the string, so this can't be a match.\n return [nil, nil] unless index\n\n if index == last_index + 1\n # This matching character immediately follows the last matching\n # character. The first two sequential characters score; subsequent\n # ones don't.\n if last_type != :sequential\n last_type = :sequential\n score += 1\n end\n # This character follows a boundary character.\n elsif BOUNDARY_CHARS.include?(string[index - 1])\n if last_type != :boundary\n last_type = :boundary\n score += 1\n end\n # This character isn't special.\n else\n last_type = :normal\n score += index - last_index\n end\n\n last_index = index\n end\n\n [score, last_index]\n end", "def look_ahead(kclass, index, char, buffer, classified_sentence, nivel_parentese)\n if @raw[index + 1] && kclass::REGEX.match( \"#{buffer}#{char}#{@raw[index + 1]}\" )\n buffer.concat char\n else\n classified_sentence.push kclass.new(buffer+char)\n buffer.clear\n end\n end", "def best_character_is(my_character)\n return my_character =~ /\\ABismarck|IA\\Z/i\n end", "def get_record_type (dns_name, dns_values)\n record_type = \"cname\"\n ips = dns_values.grep(/\\d+\\.\\d+\\.\\d+\\.\\d+/)\n dns_values.each do |dns_value|\n if dns_value =~ Resolv::IPv6::Regex\n record_type = \"aaaa\"\n end\n end\n\n\n if ips.size > 0\n record_type = \"a\"\n end\n if dns_name =~ /^\\d+\\.\\d+\\.\\d+\\.\\d+$/ || dns_name =~ Resolv::IPv6::Regex\n record_type = \"ptr\"\n end\n if dns_name =~ /^txt-/\n record_type = \"txt\"\n end\n return record_type\n end", "def next_match char\n data = get_content\n row = focussed_index\n currval = data[row].chomp\n row.upto(data.length-1) do |ix|\n val = data[ix].chomp\n if val[0,1] == char and val != currval\n return ix\n end\n end\n 0.upto(row) do |ix|\n val = data[ix].chomp\n if val[0,1] == char and val != currval\n return ix\n end\n end\n return -1\n end", "def num_decodings(s)\n\n decode = ('A'..'Z').to_a\n number_of_prev_ended_singly = 1\n\n ways_count = 1\n number_of_prev_ended_singly = 1\n\n s.chars[1..-1].each_with_index do |ch, idx|\n if s[idx - 1].to_i == 1 ||\n s[idx - 1] == 2.to_i && ch.to_i.between?(1,6)\n\n numbers_added_this_time = ways_count - number_of_prev_ended_singly\n ways_count += numbers_added_this_time\n number_of_prev_ended_singly = numbers_added_this_time\n else\n number_of_prev_ended_singly = 0\n end\n end\n\n ways_count\n\nend", "def higher_chars(char)\n ROMAN_CHARS.split(char)[1]\n end", "def card_type\r\n length = @num.length\r\n if length == 15 && @num =~ /^(34|37)/\r\n \treturn 'AMEX'\r\n elsif length == 16 && @num =~ /^6011/\r\n \treturn 'Discover'\r\n elsif length == 16 && @num =~ /^5[1-5]/\r\n \treturn 'MasterCard'\r\n elsif (length == 13 || length == 16) && @num =~ /^4/\r\n \treturn 'Visa'\r\n else\r\n return 'Unknown'\r\n end\r\n end", "def find_type\n if row[0..0] == \"5\"\n @type = \"CK\"\n elsif row[0..0] == \"6\"\n @type = \"IN\"\n else\n @type = nil\n end\n end", "def consolidate_classes(original_line, list_of_classes)\n record = {\n :original_ocr => original_line,\n :attributes_parsed => {\n :subject =>\n [\n #{:value => \"Curran Sarah\", :type => \"primary\", :occupation => \"widowed\"},\n #{:value => \"Richard\", :type => \"widower of primary\"}\n ],\n :location =>\n [\n #{:value => \"7 Sixth\", :position => \"rear\", :type => \"home\"}\n ]\n }\n }\n\n list_of_classes.each_with_index do |classed_token, index|\n parsed_class = classed_token[1][0]\n value = classed_token[0]\n if index == 0 && parsed_class == :name_component\n record[:attributes_parsed][:subject] << {:value => value, :type => 'primary'}\n end\n if index > 0\n case parsed_class\n when :job_component\n unless record[:attributes_parsed][:subject].count < 1\n record[:attributes_parsed][:subject][0][:occupation] = value\n end\n when :predicate\n case value\n when \"wid\"\n unless record[:attributes_parsed][:subject].count < 1\n record[:attributes_parsed][:subject][0][:occupation] = 'widow'\n end\n deceased_name = look_for_name_of_deceased(list_of_classes,index)\n unless deceased_name.nil?\n record[:attributes_parsed][:subject] << {:value => deceased_name, :type => 'deceased spouse of primary'}\n end\n #attach_to_next(list_of_classes, index, :name_component, [{:type => 'deceased spouse of primary'}])\n when \"h\"\n attach_to_next(list_of_classes, index, :address_component, [{:type => 'home'}])\n when \"r\"\n attach_to_next(list_of_classes, index, :address_component, [{:position => 'rear'}])\n else\n end\n ## inner case\n when :address_component\n loc = {:value => value}\n classed_token[2..-1].each do |xtra_attr| ## add in any additional attributes from predicates\n xtra_attr.each do |k, v|\n loc[k] = v\n end\n end\n unless merge_if_directly_subsequent_is_alike(list_of_classes, index, classed_token)\n record[:attributes_parsed][:location] << loc\n end\n else\n end\n end ## indices after 0\n end ## loop of classes\n\n return record\nend", "def consensus_naming\n matches = find_matches\n return nil if matches.empty?\n return matches.first if matches.length == 1\n\n best_naming = matches.first\n best_value = matches.first.vote_cache\n matches.each do |naming|\n next unless naming.vote_cache > best_value\n\n best_naming = naming\n best_value = naming.vote_cache\n end\n best_naming\n end", "def autoselect_primary_character!(blacklist=[])\n c = self.validated_characters - blacklist\n if !c or c.length == 0\n self.character = nil\n self.save!\n return true\n else\n sp = 0\n highest_sp_char = nil\n c.each do |char|\n if char.skill_points > sp\n sp = char.skill_points\n highest_sp_char = char\n end\n end\n self.character = char\n self.save!\n return true\n end\n end", "def test_upper_lower\n assert_equal(\"A\", @target.find_first_non_repeating(\"aaaAaaa\"))\n end", "def parse_klass_info(line)\n #(dept_abbr, klass_section, instructor, title) = line[0].gsub(/^\"(.*)\"$/,'\\1').split\n (dept_abbr, klass_section, instructor, title) = line[0].scan(\n /^\"*(\\w*)\\s+([^\\s]*)\\s+(.*[^\\s])\\s*\\((\\w*)\\)\"*$/ ).first\n (full_course_number, section) = klass_section.split(\"-\")\n if instructor.index(\",\").nil?\n puts \"Could not parse instructor name #{instructor} correctly. Please check source file.\"\n exit\n end\n (last_name, first_name) = instructor.split(\",\")\n\n # Handles cases where an instructor has multiple parts to their name\n # i.e. El Ghaoui, Laurent\n # i.e. Chang-Hasnain, C.\n first_name = first_name.scan(/(\\W+|\\w+)/).map{|x| x.first.capitalize}.join\n last_name = last_name.scan(/(\\W+|\\w+)/).map{|x| x.first.capitalize}.join\n\n respondents = line[1]\n semester = line[11]\n full_course_number.upcase!\n\n # Check and find department\n department = Department.find_by_nice_abbr(dept_abbr)\n if department.nil?\n puts \"Could not find department #{dept_abbr}. Please check the formatting of the input file.\"\n exit\n end\n\n # Check whether course exists\n (course_number, suffix) = full_course_number.match(/^([0-9]*)([A-Z]*)$/)[1..-1]\n course = Course.find(:first, :conditions => {:department_id => department.id, :course_number => course_number, :suffix => suffix})\n if course.nil?\n puts \"Could not find course #{dept_abbr} #{full_course_number}. Please enter it into the database before rerunning this script\" \n exit\n end\n\n # Check whether instructor exists\n # I have no idea what we should do about duplicates. I'll probably want to see what the old script did\n # So many bad things can happen here if the survey does not format the instructor name properly\n instructor = Instructor.find(:first, :conditions => { :first_name => first_name, :last_name => last_name })\n \n if instructor.nil?\n puts \"No instructor named #{first_name} #{last_name} found. Creating now.\"\n puts \"If this is in error, please merge the instructor entries in the database.\"\n if title == \"prof\"\n privacy = false\n else\n privacy = true\n end\n instructor = Instructor.create( :first_name => first_name, :last_name => last_name, :private => privacy )\n end\n\n # Check whether klass exists, note that the EE survey results for TAs may not not follow the same section number convention as the other results\n formatted_semester = semester[-4..-1] + case semester[0..-6] when \"SPRING\" then \"1\" when \"SUMMER\" then \"2\" when \"FALL\" then \"3\" else \"UNKNOWN\" end\n klass = Klass.find( :first, :conditions => { :course_id => course.id, :semester => formatted_semester, :section => section } )\n if klass.nil?\n if title == 'ta'\n raise \"Error: TA #{first_name} #{last_name} belongs to unknown section of #{course_number}\"\n elsif title == 'prof'\n puts \"No klass for #{semester} #{course.course_abbr} found. Creating new one.\"\n klass = Klass.create( :course_id => course.id, :semester => formatted_semester, :section => section )\n else\n raise \"Error\"\n end\n end\n\n # Check whether instructor is an instructor or a TA for the klass\n case title\n when \"prof\"\n klass.instructors << instructor unless klass.instructors.include? instructor\n klass.save\n when \"ta\"\n klass.tas << instructor unless klass.tas.include? instructor\n klass.save\n else\n raise \"Error: Title #{title} not recognized. Should be either 'prof' or 'ta'\"\n end\n\n return [1, instructor, klass]\nend", "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_char\n if @match == true\n find_array\n remove_miss_match_words\n @match == false\n else\n remove_miss_match_words\n end\n\n @chars = analysis\n\n #for short words do\n if @remain > 1\n find_main_char\n else\n @chars\n end\n end", "def strclass_record() @records.get(GRT_STRCLASS); end", "def longest_prefix(strings)\n\n # Assign relevant variables\n winning_ticket = \"\"\n i = 0 \n fastest_furthest = strings[0][i]\n\n # Account for non-nil values and return method result \n while fastest_furthest != nil\n strings.each do |string|\n unless string[i] == fastest_furthest\n return winning_ticket\n end \n end \n winning_ticket += fastest_furthest\n i += 1\n fastest_furthest = strings[0][i]\n end\n return winning_ticket\nend", "def countABC(str)\n if(str.length == 3)\n return 1 if (str == \"abc\") || (str == \"aba\")\n return 0\n end\n first_three = str[0..2]\n if first_three = \"abc\" || first_three = \"aba\"\n return 1 + countABC(str[3..-1])\n else\n return 0 + countABC(str[1..-1])\n end\nend", "def get_faculty(affi_string)\n $affi_faculties.each do |faculty|\n if affi_string.include?(faculty)\n return faculty\n end\n end\n return nil\nend", "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 fieldparse(string,whatcase)\n \n string = string.downcase\n array = string.split(/ /)\n @lowest = 10000\n array.each {|x|\n if x == \"lowest\"\n location = array.index x\n nextword = location + 1\n \n if array[nextword] == \"atk\" or \"def\"\n para = \"#{array[nextword]}\"\n elsif array[nextword] == \"attack\"\n para = \"atk\"\n elsif array[nextword] == \"def\" or \"defense\" or \"defence\"\n para = \"def\"\n end\n #puts para\n @lowest = { \"atk\" => 10000,\n \"def\" => 10000,\n }\n cards = @@monsterfield.search(1,0/1,false)\n #puts \"cards:\"\n #puts cards\n #puts \"Finished cards\"\n cards.each {|card|\n #puts card.type\n #puts card[para]\n #puts @lowest\n @lowest = card if card[para] < @lowest[para] \n }\n \n end\n }\n #puts \"returning card from parser...\"\n return @lowest\nend", "def next_char(char)\n #if the char is capitalized we have to ask for uppercased vowels\n vowels = is_upcase?(char) ? \"AEIOU\" : \"aeiou\"\n if char == \" \"\n char\n elsif vowels.include?(char)\n get_next_vowel(char,vowels)\n else\n get_next_consonant(char,vowels)\n end\nend", "def parse_record(data)\n unpacked = data.unpack(\"a1a*\")\n return unpacked[0] == \"A\" ? Dir_A : Dir_B, unpacked[1].to_i\n end", "def guess(text, meta)\n @re =~ text ? @dbclass : nil\n end", "def three_of_a_kind(hand)\n\t\thand_num = check_num(hand)\n\t\ti = 0\n\t\twhile i < hand_num.size\n\t\t\tif hand_num.count(hand_num[i]) == 3\n\t\t\t\treturn 3\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\treturn 0\n\tend", "def test_long_string\n assert_equal(\"g\", @target.find_first_non_repeating(\"learning javascript is pretty lame\"))\n end", "def select_dominant_course_name(primary_course, courses)\n # Currently this dominant course resolution is needed for 3HP vs INH only\n # thus we are simply returning 3HP (Rifapentine) or nothing.\n case primary_course.name.downcase\n when 'isoniazid/rifapentine' then '3HP'\n when 'rifapentine' then '3HP'\n when 'inh' then courses.find { |course| course.name.casecmp?('rifapentine') } && '3HP'\n end\n end", "def handleTwoCardSameValue(str)\n max = 0\n list = []\n str.each_char do |i|\n if str.count(i) == 2\n max = replaceCharToNumber(i)\n else\n list.push(replaceCharToNumber(i))\n end\n end\n return [max] + list.sort.reverse\nend", "def test_3_text_before_first_corinthians\n sample_text = \"This is some text about 1 Corinthians 1:1.\"\n pericopes = Pericope.parse(sample_text)\n assert pericopes.any?, \"No pericope found.\"\n end", "def fake_name_c2(real_name)\n\treal_full_name = real_name.split(\" \")\n\treal_first_name = real_full_name[0] \n\treal_last_name = real_full_name[1]\n\ti = 0\n\tfake_first_name = \"\"\n\tfake_last_name = \"\"\n\tvowel_index = \"\"\n\tlength_first = real_first_name.length\n\tlength_last = real_last_name.length \n\t\twhile i < length_last\n\t\tif real_last_name[i] == \"z\"\n\t\t\tfake_last_name += \"a\"\n\t\telsif real_last_name[i] == \"a\" || real_last_name[i] ==\"e\" || \n\t\t\t real_last_name[i] == \"i\" || real_last_name[i] == \"o\" || \n\t\t\t real_last_name[i] == \"u\"\n\t\t\tfake_last_name += real_last_name[i] \n\t\telse \n\t\t\tfake_last_name += real_last_name[i].next \n\t\tend \n\t\ti+=1\n\tend\n\tfake_last_name\nend", "def _rl_find_prev_mbchar(string, seed, flags)\r\n if @encoding == 'N'\r\n return ((seed == 0) ? seed : seed - 1)\r\n end\r\n\r\n length = string.length\r\n if seed < 0\r\n return 0\r\n elsif length < seed\r\n return length\r\n end\r\n\r\n case @encoding\r\n when 'E'\r\n string[0,seed].scan(/./me)[0..-2].to_s.length\r\n when 'S'\r\n string[0,seed].scan(/./ms)[0..-2].to_s.length\r\n when 'U'\r\n string[0,seed].scan(/./mu)[0..-2].to_s.length\r\n when 'X'\r\n string[0,seed].force_encoding(@encoding_name)[0..-2].bytesize\r\n end\r\n end", "def strclass() @records.get_data(GRT_STRCLASS); end", "def convertToBoard(text)\n response=text\n\n responseArray=response.split(\" \")\n # responseArray = Capture.find(:all)\n responseArray.delete('and')\n # responseArray.reject! { |item| item.text =~ 'and' }\n puts response.size\n puts responseArray.size\n if responseArray.size==1\n if response.size<=4\n response=response.upcase\n else \n puts \"shortening response\"\n response=response[0..3].upcase\n end\n elsif responseArray.size==2\n if not is_num(responseArray[1])\n if responseArray[0].size<=3\n response=responseArray[0][0..responseArray[0].size].upcase + responseArray[1][0].upcase\n else\n response=responseArray[0][0..2].upcase + responseArray[1][0].upcase\n end\n else\n if responseArray[1].size>=2\n response=responseArray[0][0..1].upcase + responseArray[1][responseArray[1].size-3..responseArray[1].size-1]\n else\n response=responseArray[0][0..1].upcase + responseArray[1][0..responseArray[1].size-1]\n end\n end\n else\n puts\"size invalid\"\n response=responseArray[0][0].upcase+responseArray[1][0].upcase+responseArray[2][0].upcase\n end\n return response\nend", "def preferred_260(fields)\n fields.select { |field| field.indicator1 == '3' }.last || fields.last\n end", "def first_char_with_ascii_gr8ter_120(input)\n input.find do |c|\n c.ord > 120\n end\nend", "def get_institution(affi_string)\n found_inst = nil\n $affi_institutions.each do |institution|\n if affi_string.include?(institution) then\n if found_inst == nil then\n found_inst = institution\n elsif found_inst.length < institution.length then\n found_inst = institution\n end\n end\n end\n return found_inst\nend", "def test_fetch_with_default\n letters = ['a', 'b', 'c']\n assert_equal 'b', letters.fetch(1, 'z')\n assert_equal 'z', letters.fetch(3, 'z')\n end", "def find_eow\n\t\t\ti = buffer.index\n\t\t\ti += 1 while ((buffer[i] != nil) && buffer[i].match(/\\w/))\n\t\t\treturn i-1\n\t\tend", "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 guess_sequence_type(sequence_string)\n cleaned_sequence = sequence_string.gsub(/[^A-Z]/i, '') # removing non-letter characters\n cleaned_sequence.gsub!(/[NX]/i, '') # removing ambiguous characters\n\n return nil if cleaned_sequence.length < 10 # conservative\n\n composition = composition(cleaned_sequence) \n composition_NAs = composition.select { |character, count|character.match(/[ACGTU]/i) } # only putative NAs\n putative_NA_counts = composition_NAs.collect { |key_value_array| key_value_array[1] } # only count, not char\n putative_NA_sum = putative_NA_counts.inject { |sum, n| sum + n } # count of all putative NA\n putative_NA_sum = 0 if putative_NA_sum.nil?\n\n if putative_NA_sum > (0.9 * cleaned_sequence.length)\n return :nucleotide\n else\n return :protein\n end\n end", "def get_previous_class cursor\n # The class (or module) is followed by a '('\n ret = @info.rsearch_with_length(/\\s\\S+\\(/, cursor)\n return ret[0].empty? ? nil : ret[2][1..-2] # skip the first char (a space) and the last (a parentheses)\n end", "def _rl_find_next_mbchar(string, seed, count, flags)\r\n if @encoding == 'N'\r\n return (seed + count)\r\n end\r\n seed = 0 if seed < 0\r\n return seed if count <= 0\r\n\r\n point = seed + _rl_adjust_point(string,seed)\r\n if (seed < point)\r\n count -= 1\r\n end\r\n\r\n str = (flags == MB_FIND_NONZERO) ? string.sub(/\\x00+$/,'') : string\r\n\r\n case @encoding\r\n when 'E'\r\n point += str[point..-1].scan(/./me)[0,count].to_s.length\r\n when 'S'\r\n point += str[point..-1].scan(/./ms)[0,count].to_s.length\r\n when 'U'\r\n point += str[point..-1].scan(/./mu)[0,count].to_s.length\r\n when 'X'\r\n point += str[point..-1].force_encoding(@encoding_name)[0,count].bytesize\r\n else\r\n point += count\r\n point = str.length if point >= str.length\r\n end\r\n point\r\n end", "def get_next_char extracted_password, options\n num_chars_to_go = options[:length] - extracted_password.length\n remainder = \".{#{num_chars_to_go-1}}\"\n possible_charset = options[:charset]\n while possible_charset.length > 1\n charset_slices = possible_charset.chars.each_slice((possible_charset.size/2.0).round).to_a.map(&:join)\n char_test = \"[#{charset_slices[1]}]\"\n regex = ['^', extracted_password, char_test, remainder, '$'].join\n matched = password_matches?(regex)\n puts ' ' * 18 + \"> Matched: #{matched ? 'yes' : 'no'}\"\n matching_slice = matched ? 1 : 0\n possible_charset = charset_slices[matching_slice]\n puts ' ' * 6 + \"> #{possible_charset}\"\n end\n possible_charset\n end", "def letterCountI(str)\n\t# count = 0\n\t# mostRepeatedLetters = ''\n\t# str = str.split('').each{|letter| \n\t# \tif(str.count(letter) > count)\n\t# \t\tcount = str.count(letter)\n\t# \t\tmostRepeatedLetters = str\n\t# \tend\n\t# }\n\t# return mostRepeatedLetters\n\n\tletterCount = 0\n\tletterMaxWord = ''\n\tstr = str.split(' ').each{|word| word.split('').each{|letter| \n\t\tif(word.downcase.count(letter) > letterCount)\n\t\t\tletterCount = word.downcase.count(letter)\n\t\t\tletterMaxWord = word\n\t\tend\n\t\t}}\n\tletterCount > 1 ? (return letterMaxWord) : (return -1)\n\t\nend", "def most_frequent_letter(string)\nend", "def top_3_words(text)\n text.gsub(\"\\n\", \" \")\n .split(\" \")\n .map(&:downcase)\n .map(&sanitize)\n .reject(&empty)\n .reject(&no_letters)\n .reduce({}, &top_word)\n .sort_by(&word_count)\n .reverse\n .take(3)\n .map(&:first)\nend", "def plausible_common_name\n parse('creature.bird.plausible_common_names').capitalize\n end", "def try_exact_match(review)\n possible_titles = review.ars_titles.collect(&:title)\n exact_match = false\n possible_titles.each do |possible_title|\n puts \"TRYING #{possible_title} for exact match\"\n \n # TODO: self here instead of class?\n if GiantLookup.new.is_title? possible_title\n return GiantLookup.new.find_games_by_title(possible_title).first\n end\n end\n \n # nothing found, oh well\n return nil\n end", "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 dbLookup(type = 'DA')\n i = 1;\n sql = \"select * from data where `council_reference` like '#{type}%/#{ENV['MORPH_PERIOD']}'\"\n results = ScraperWiki.sqliteexecute(sql) rescue false\n if ( results )\n results.each do |result|\n maxApplication = result['council_reference'].gsub!(type + '/', '').gsub!(\"/#{ENV['MORPH_PERIOD']}\", '')\n if maxApplication.to_i > i\n i = maxApplication.to_i\n end\n end\n end\n maxApplication = i\nend", "def next_consonant(char)\n char = char.downcase\n compare = \"bcdfghjklmnpqrstvwxyz\"\n\n # not a consonant, i.e., no instance of the variable\n if compare.count(char) == 0\n # puts \"Not a consonant\"\n return nil\n end\n\n consonant_index = compare.index(char)\n\n if consonant_index == compare.length - 1 # end edge case\n return 'b'\n else\n return compare[consonant_index + 1]\n end\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 type\n length = @number.size\n if length == 15 && @number =~ /^(34|37)/\n \"AMEX\"\n elsif length == 16 && @number =~ /^6011/\n \"Discover\"\n elsif length == 16 && @number =~ /^5[1-5]/\n \"MasterCard\"\n elsif (length == 13 || length == 16) && @number =~ /^4/\n \"Visa\"\n else\n \"Unknown\"\n end\n end", "def acceptable_serial( str )\n # no more than two repeating characters\n return true\n end", "def get_university_rank(text)\n rank = nil\n nu_count = text.downcase.scan(/northwestern university/).count\n @universities.reverse.each_with_index do |u, i|\n if text.downcase.include?(u.downcase)\n rank = 500 - i\n end\n if rank != nil\n if rank > 30 && nu_count > 1\n rank = 30\n end\n elsif nu_count > 1\n rank = 30\n end\n end\n return rank\nend", "def most_common_letter(string)\r\nidx = 0\r\ncommon_letter = nil\r\nletter_counter = nil\r\n\r\n while idx < string.length\r\n letter = string[idx]\r\n count = 0\r\n idx2 = 0\r\n while idx2 < string.length\r\n if string[idx2] == letter\r\n count = count+1\r\n end\r\n idx2 = idx2 + 1\r\n end\r\n if(letter_counter == nil)||(count > letter_counter)\r\n common_letter = letter\r\n letter_counter = count\r\n end\r\n idx = idx + 1\r\n end\r\n return [common_letter,letter_counter].to_s\r\nend", "def extract_class(string)\n uncapitalize(string.split('::').last)\n end", "def get_element type, line\n case type\n when :kanji\n return line.split(\" \")[0]\n when :nanori, :onyomi, :kunyomi\n nanori_match = regexp(:nanori_divider).match line\n #if there is a nanori section then create the\n # nanoris and get section for other readings (yomi)\n unless nanori_match.nil?\n nanori_section = nanori_match.post_match\n nanoris = nanori_section.scan regexp(:kana)\n yomi = nanori_match.pre_match\n else #no nanoris everything is a yomi (normal reading)\n nanoris= []\n yomi = line\n end\n return nanoris if type == :nanori\n #puts \"processing #{type}\"\n return yomi.scan(regexp(type)).flatten\n\n when :yomi, :meaning, :kana, :korean, :pinyin, :skip\n return line.scan(regexp(type)).flatten\n\n when :bushu, :radical, :historical_radical, :classical_radical, :halpern, :nelson,\n :new_nelson, :japanese_for_busy_people, :kanji_way , \n :japanese_flashcards , :kodansha , :hensall , :kanji_in_context ,\n :kanji_learners_dictionary , :french_heisig , :o_neill , :de_roo ,\n :sakade , :tuttle_flash_card , :tuttle_dictionary ,\n :tuttle_kanji_and_kana , :unicode, :four_corner ,\n :heisig, :morohashi_index , :morohashi_volume_page ,\n :henshall , :gakken , :japanese_names , :cross_reference ,\n :misclassification\n return (line.scan regexp(type)).flatten[0]\n\n end\n end", "def candidate_name_scrub (line, matches)\n candidates = Array.new\n case line\n when /CLINTON/ # List full names\n @candidates[1] = \"Hillary Rodham Clinton / Timothy Michael Kaine\"\n @candidates[2] = \"Gary Johnson / Bill Weld\"\n when /TRUMP/ # Single Space, List full names\n @candidates[1] = \"Jill Stein / Ajamu Baraka\"\n @candidates[2] = \"Donald J Trump / Michael R Pence\"\n when /CONLEY/ # Single Space\n @candidates[1] = \"Jason Conley\"\n @candidates[2] = \"Pat Pettey\"\n when /MOLLY/ # Spill over to next line\n @candidates[1] = \"Molly Baumgardner\"\n @candidates[2] = matches[:rx_candidate_2].sub(/\\(.\\)/, '').rstrip.split.map(&:capitalize).join(' ')\n when /AMANDA/ # Spill over to next line\n @candidates[1] = \"Amanda Grosserode\"\n @candidates[2] = matches[:rx_candidate_2].sub(/\\(.\\)/, '').rstrip.split.map(&:capitalize).join(' ')\n when /STEPHANIE/ # Spill over to next line\n @candidates[1] = \"Stepanie Clayton\"\n @candidates[2] = matches[:rx_candidate_2].sub(/\\(.\\)/, '').rstrip.split.map(&:capitalize).join(' ')\n when /CHRISTOPHER/ # Spill over to next line\n @candidates[1] = \"Christopher McQueeny\"\n @candidates[2] = matches[:rx_candidate_2].sub(/\\(.\\)/, '').rstrip.split.map(&:capitalize).join(' ') \n else\n @candidates[1] = matches[:rx_candidate_1].sub(/\\(.\\)/, '').rstrip.split.map(&:capitalize).join(' ')\n if matches[:rx_candidate_2] && !matches[:rx_candidate_2].empty?\n @candidates[2] = matches[:rx_candidate_2].sub(/\\(.\\)/, '').rstrip.split.map(&:capitalize).join(' ')\n end\n end\n\n if !@party_affiliation[@candidates[1]]\n $stderr.puts @candidates[1]\n raise(@candidates[1])\n end\n if @candidates[2] && !@candidates[2].empty?\n if !@party_affiliation[@candidates[2]]\n $stderr.puts @candidates[2]\n @party_affiliation[@candidates[2]]\n end\n end\n end", "def last_four\n card_number.slice(-4,4)\n end", "def get_lookup_selection(record, provider)\n\n w = record[:word].strip\n puts \"Resolving \\\"#{w}\\\" ...\"\n\n candidates = w.split(\",\").map{ |t| t.strip }\n\n # Print the candidates and the number of sentences returned on\n # lookup. User chooses the candidate, sentences are stored. Note\n # that if only one of the words has sample sentences, no\n # intervention is required.\n sentences = {}\n autoselection = nil\n candidates.each_with_index do |c, index|\n print \"#{index + 1}. #{c} ... \"\n s = provider.get_sentences(c)\n autoselection = index + 1 if (s.size > 0)\n puts \"#{s.size} sentences\"\n sentences[c] = s\n end\n\n can_autoselect = (sentences.values.count { |s| s.size > 0 } == 1)\n selected = can_autoselect ? autoselection :\n get_selection_number(\"Enter selection: \", 1, candidates.size)\n\n selection = candidates[selected - 1]\n puts \"Selected: #{selection}\"\n record[:word] = selection\n record[:sentences] = sentences[selection]\n\n record\nend", "def character_data(spec_id, number_to_retrieve)\n top_characters(spec_id, number_to_retrieve).map do |character|\n begin\n CharacterData.new(\n character['realmSlug'],\n character['name'],\n character['specId'])\n rescue\n puts \"error.. skipped character\"\n nil\n end\n end.compact\n end", "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 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 highestRemainLetterOf word\n word.gsub!('*','.').downcase!\n @incorrectWord = @missingWord - word.chars\n getHighestAbilityLetterFrom(Regexp.compile('^'+word+'$')).pop[0]\nend", "def first_loop(letters)\n 0.upto(letters.length-1) do |idx1|\n (idx1+4).step(letters.length-1,2) do |idx2|\n return [idx1,idx2] if letters[idx1].casecmp(letters[idx2])==0\n end\n end\n nil\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 classification\n @line1[07]\n end", "def find_start_good_section(iupac_concensus_string, min_length)\n good_char_count = 0\n char_index = 0\n iupac_concensus_string.each_char do |char|\n if char =~ /[^\\?\\-Nn]/\n good_char_count += 1\n if good_char_count >= min_length\n break\n end\n else\n good_char_count = 0\n end\n char_index += 1\n end\n char_index - (good_char_count - 1)\n end", "def first_english_name\n self[3].split(';').first\n end", "def balance_class?(string)\n unmatch = 0\n tester = [['[',']'],['{','}'],['(',')']]\n quotes = []\n string.each_char.with_index do |char, index|\n if char == \"'\" || char == \"\\\"\"\n unmatch += test_quote(char, quotes)\n elsif tester.each do |x,y|\n char == x ? unmatch += 1 : char == y ? unmatch -= 1 : nil\n end\n end\n break if unmatch < 0\n end\n unmatch\nend", "def select_main_imprint(fields)\n if fields.length == 1\n fields.first\n elsif all_260s?(fields)\n preferred_260(fields)\n elsif all_264s?(fields)\n preferred_264(fields)\n else\n fields.last\n end\n end", "def string_to_class string\n chain = string.split \"::\"\n i=0\n res = chain.inject(Module) do |ans,obj|\n break if ans.nil?\n i+=1\n klass = ans.const_get(obj)\n # Make sure the current obj is a valid class\n # Or it's a module but not the last element,\n # as the last element should be a class\n klass.is_a?(Class) || (klass.is_a?(Module) and i != chain.length) ? klass : nil\n end\nrescue NameError\n nil\nend", "def get_race(page)\n # Get the line that contains the player's race\n race = page.grep(/chara_profile_title/)\n # Make the Race the beginning of the line\n race1 = race[0][36..-1]\n # Get just the race (the first word)\n race2 = race1.split[0]\n # If race is Au Ra, it has a space in it, re-add Ra back\n if race2 == 'Au'\n race2 = 'Au Ra'\n end\n # Un-escape the ' in Miqo'te\n race2.sub('&#39;',\"'\")\n end", "def get_race(page)\n # Get the line that contains the player's race\n race = page.grep(/chara_profile_title/)\n # Make the Race the beginning of the line\n race1 = race[0][36..-1]\n # Get just the race (the first word)\n race2 = race1.split[0]\n # If race is Au Ra, it has a space in it, re-add Ra back\n if race2 == 'Au'\n race2 = 'Au Ra'\n end\n # Un-escape the ' in Miqo'te\n race2.sub('&#39;',\"'\")\n end", "def three_in_a_row?\n\t\tthree_in_a_row = false\n\t\toccurrences = 0\n\t\tboard = @board.board\n\t\tboard.each do |row|\n\t\t\tif (current_letter = row[0]) != \"_\"\n\t\t\t\trow.each do |element|\n\t\t\t\t\tif element == current_letter\n\t\t\t\t\t\toccurrences += 1\n\t\t\t\t\telse\n\t\t\t\t\t\toccurrences = 0\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tnext\n\t\t\tend\n\t\t\tif occurrences == 3\n\t\t\t\treturn [true, current_letter]\n\t\t\tend\n\t\tend\n\t\t[three_in_a_row]\n\tend", "def next_letter(full_name)\r\n\tidx = 0\r\n\twhile idx < full_name.length\r\n\t\tname = full_name.split('')\r\n\t\tname.map! { |letter| letter.next }\r\n\t\tidx += 1\r\n\tend\r\n\tname\r\nend", "def _reduce_11(val, _values, result)\n result = CharacterClass.new(val[1]) \n result\nend", "def test_5_text_before_first_john\n sample_text = \"This is some text about 1 Jn. 1:1.\"\n pericopes = Pericope.parse(sample_text)\n assert pericopes.any?, \"No pericope found.\"\n end", "def get_next_state(char)\n @@scan_table[@state - 1].find(lambda {[0, 1]}) { |rule| char =~ rule[0] }[1]\n end", "def find_type_apria\n csv[0][0].to_s.strip.downcase =~ /^denials*$/ ? 'CORRESP' : 'PAYMENT'\n end", "def nextmatch(char)\n n = self.nextchar\n raise \"Expected '#{char}' and instead saw '#{n}'.\" if (n != char)\n return(n)\n end" ]
[ "0.50342816", "0.5013062", "0.4884477", "0.47540987", "0.47352165", "0.47298652", "0.4716367", "0.47113243", "0.47038415", "0.4700437", "0.4647205", "0.4613086", "0.46043113", "0.45938137", "0.45789075", "0.45625678", "0.45625678", "0.45603186", "0.4560045", "0.45441553", "0.45435438", "0.4542901", "0.45248505", "0.45165527", "0.45129806", "0.4510768", "0.45088226", "0.4500405", "0.44991857", "0.44938737", "0.44828126", "0.4480365", "0.4474792", "0.4474545", "0.44721878", "0.44690558", "0.4464743", "0.44603223", "0.44575843", "0.44542933", "0.44431987", "0.44376057", "0.44279867", "0.442781", "0.44125694", "0.44106045", "0.44074923", "0.44070143", "0.44051313", "0.44038096", "0.43996388", "0.4398619", "0.4396352", "0.43746784", "0.43725023", "0.43724245", "0.43715236", "0.43705538", "0.43656483", "0.43630907", "0.43609342", "0.43566835", "0.4356573", "0.435106", "0.43492085", "0.43468803", "0.43372408", "0.43357617", "0.43336433", "0.43223515", "0.4322029", "0.43216652", "0.43211907", "0.4313554", "0.43126312", "0.4306289", "0.4305383", "0.43034643", "0.4295805", "0.42955646", "0.42927364", "0.42799276", "0.42717028", "0.42671046", "0.4264996", "0.42625892", "0.42612645", "0.42576578", "0.4246598", "0.42434993", "0.42406538", "0.42400515", "0.4237945", "0.4237945", "0.4236976", "0.42347643", "0.4232518", "0.42282593", "0.42254043", "0.4224219", "0.42230213" ]
0.0
-1
Record has a fixed barcode length
def shift_barcode_length return unless record.barcode_length shift_fixed_length(record.barcode_length) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def length\n barcode.two_dimensional? ? encoding.first.length : encoding.length\n end", "def length\n barcode.two_dimensional? ? encoding.first.length : encoding.length\n end", "def barcode\n str_order = order.id.to_s.rjust(5, '0')\n str_cardinality = 1.to_s.rjust(3, '0')\n str_order + str_cardinality\n end", "def barcode(length: 8, bits: 10)\n rand(bits**length).to_s(bits).rjust(length, '0')\n end", "def is_corrected_barcode?(barcode_id, is)\n is != barcode_id && is.length != 4 && is.length != 8\n end", "def trailer_arquivo_posicao_394_a_400(sequencial)\n\t\t\t\t\t\t\"#{sequencial}\".adjust_size_to(6, '0', :right)\n\t\t\t\t\tend", "def width\n barcode.encoding.length * xdim\n end", "def data520\n max_length = 1879\n @thesis.abstract&.each_line do |line|\n # skip any blank lines. Mostly if multiple linebreaks were added to the text.\n next if line.strip.empty?\n\n # if the line length is valid for 520, add it\n if line.length < max_length\n @record.append(MARC::DataField.new(\n '520', '3', ' ',\n ['a', line.encode(options: :xml).strip]\n ))\n # split lines that remain too long into valid size strings\n else\n part = line.chars.to_a.each_slice(max_length).map(&:join)\n part.each do |part_line|\n @record.append(MARC::DataField.new(\n '520', '3', ' ',\n ['a', part_line.encode(options: :xml).strip]\n ))\n end\n end\n end\n end", "def barcode\n return if not_registered\n barcode_string.to_i(2)\n end", "def pad_length\n offset = (lp_value_name.abs_offset + lp_value_name.to_binary_s.length) % 4\n (4 - offset) % 4\n end", "def paper_white_area() barcode_bit_area -1 end", "def pad_record(text_line)\n flow_type = Inflector.underscore(self.class.to_s).split(\"_\")[0].upcase()\n record_type = text_line.slice(0..1).upcase()\n\n\n #remove x-tra spaces to right, i.e where the passed in text-line > schema required length\n if text_line.length() > RecordPadder.required_record_length(flow_type, record_type, text_line.length)\n text_line.slice!(RecordPadder.required_record_length(flow_type, record_type, text_line.length)..text_line.length())\n return text_line\n else\n text_line.ljust(RecordPadder.required_record_length(flow_type, record_type, text_line.length))\n\n end\n\n\n\n end", "def byte_size(); @data.byte_size + 4; end", "def barcode\n \"*#{identifier}*\"\n end", "def illumina_barcode\n self.barcode_type == :illumina ? self.barcode : \"\"\n end", "def data_length\n super\n end", "def current_length; end", "def length_override; end", "def pad_length\n offset = (lp_data.abs_offset + lp_data.to_binary_s.length) % 4\n (4 - offset) % 4\n end", "def genbank\n chars = 60\n lines = (length / chars.to_f).ceil\n width = length.to_s.length\n\n s = ''\n (1..lines).each do |i|\n s << \"%#{width}d\" % (chars * (i - 1) + 1)\n s << ' '\n s << to_s[chars * (i - 1), chars].scan(/\\w{1,10}/).join(' ')\n s << \"\\n\"\n end\n s\n end", "def valid_length?\n specification && specification['length'] - 4 == @code.length\n end", "def name_record_long(type, ext_ref) #:nodoc:\n record = 0x0018 # Record identifier\n length = 0x002a # Number of bytes to follow\n\n grbit = 0x0020 # Option flags\n chkey = 0x00 # Keyboard shortcut\n cch = 0x01 # Length of text name\n cce = 0x001a # Length of text definition\n unknown01 = 0x0000 #\n ixals = @worksheet.index + 1 # Sheet index\n unknown02 = 0x00 #\n cch_cust_menu = 0x00 # Length of cust menu text\n cch_description = 0x00 # Length of description text\n cch_helptopic = 0x00 # Length of help topic text\n cch_statustext = 0x00 # Length of status bar text\n rgch = type # Built-in name type\n\n unknown03 = 0x29\n unknown04 = 0x0017\n unknown05 = 0x3b\n\n header = [record, length].pack(\"vv\")\n data = [grbit].pack(\"v\")\n data += [chkey].pack(\"C\")\n data += [cch].pack(\"C\")\n data += [cce].pack(\"v\")\n data += [unknown01].pack(\"v\")\n data += [ixals].pack(\"v\")\n data += [unknown02].pack(\"C\")\n data += [cch_cust_menu].pack(\"C\")\n data += [cch_description].pack(\"C\")\n data += [cch_helptopic].pack(\"C\")\n data += [cch_statustext].pack(\"C\")\n data += [rgch].pack(\"C\")\n\n # Column definition\n data += [unknown03].pack(\"C\")\n data += [unknown04].pack(\"v\")\n data += [unknown05].pack(\"C\")\n data += [ext_ref].pack(\"v\")\n data += [0x0000].pack(\"v\")\n data += [0xffff].pack(\"v\")\n data += [@col_min].pack(\"v\")\n data += [@col_max].pack(\"v\")\n\n # Row definition\n data += [unknown05].pack(\"C\")\n data += [ext_ref].pack(\"v\")\n data += [@row_min].pack(\"v\")\n data += [@row_max].pack(\"v\")\n data += [0x00].pack(\"v\")\n data += [0xff].pack(\"v\")\n # End of data\n data += [0x10].pack(\"C\")\n\n [header, data]\n end", "def byte_size()\n if @record and RECORD_INFO[@record.type].size > 0 then\n RECORD_INFO[@record.type].size * @value.length\n else\n sum = 0\n @value.each do |val|\n sum += (val.length % 2 == 0) ? val.length : val.length + 1\n end\n sum\n end\n end", "def custom_barcode\n self.barcode_type == :custom ? self.barcode : \"\"\n end", "def header_length() 3 end", "def write_multi_debug code_length\n result = ['4A000004 00000001'] # start at quantity 1\n\n write_amount = zero_pad_int(code_length, 3)\n result + [\"4#{write_amount}0010 00000001\"] # increase by 1\n end", "def length() end", "def length() end", "def length() end", "def length() end", "def render_length; end", "def target_len; genomic.len; end", "def show_scan_new_items\n Array.new(40, generate_barcode)\n end", "def length(record)\n if type.variable?\n record[:header][:field_lengths][position]\n else\n type.length\n end\n end", "def base_width; 26 + @width; end", "def barcode(args={})\n self.bare_barcode\n end", "def detalhe_posicao_395_400(pagamento, sequencial)\n\t\t\t\t\t\t\"#{sequencial}\".adjust_size_to(6, '0', :right)\n\t\t\t\t\tend", "def process_record(record, data)\n begin\n if data.nil?\n length = 0\n else\n length = data.length\n end\n STDERR.puts(\"ShardId: #{@shard_id}, Partition Key: #{record['partitionKey']}, Sequence Number:#{record['sequenceNumber']}, Length of data: #{length}\")\n rescue => e\n STDERR.puts \"#{e}: Failed to process record '#{record}'\"\n end\n end", "def barcode_string\n b_string = self.custom_barcode\n if b_string.empty?\n b_string = self.illumina_barcode_string\n end\n b_string\n end", "def length(record)\n if record.header.lengths.include?(@name)\n len = record.header.lengths[@name]\n raise \"Fixed-length mismatch\" unless variable? || len == @data_type.width\n else\n len = @data_type.width\n end\n extern?(record) ? len - EXTERN_FIELD_SIZE : len\n end", "def length\n super\n end", "def barcode=(value)\n value = value.to_s if Integer === value\n setBarcode(value)\n end", "def barcode_string\n return if not_registered\n @mim.barcode_bits.map do |b|\n b ? '1' : '0'\n end.join.reverse\n end", "def valid_ein_length?(record)\n record.ein.to_s.length != 9 ? false : true\n end", "def length\n length = width\n end", "def create\n @bar_code = BarCode.new(bar_code_params)\n gen = Barby::Code128B.new(@bar_code.text)\n send_data gen.to_png(:height => 50), :type => \"image/png\", :disposition => \"inline\"\n\n @bar_code.save\n\n\n\n end", "def header_posicao_047_a_076\n\t\t\t\t\t''.adjust_size_to(30)\n\t\t\t\tend", "def length_calculator; end", "def padding; 3; end", "def set_length(len , fill_char)\n return if len <= 0\n counter = self.length()\n return if counter >= len\n internal_object_grow( len + 1)\n fill_from_with( counter + 1 , fill_char )\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def size_mum_record\n 8\n end", "def determine_length\n determine_length_support\n end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def max_key_width; end", "def barcode_box(pdf, value)\n text_height = font_size*1.5\n code_height = pdf.bounds.height - text_height\n code = '%05d' % value\n\n # Barcode above..\n pdf.bounding_box([pdf.bounds.left, pdf.bounds.top - code_height],\n :width => pdf.bounds.width, :height => text_height) do\n pdf.text(code, :align => justification.to_sym)\n end\n\n # Text below\n pdf.bounding_box([pdf.bounds.left, pdf.bounds.top],\n :width => pdf.bounds.width, :height => code_height) do\n barcode = Barby::Code39.new(code)\n barcode.annotate_pdf(pdf, :xdim => 0.75, :height => code_height * 0.8)\n end\n end", "def on_barcode(barcode = nil)\n display.update message_for(barcode)\n nil\n end", "def initialize(barcode)\n self.barcode = barcode\n end", "def initialize(barcode)\n self.barcode = barcode\n end", "def padding; end", "def padding; end", "def store_margin_right #:nodoc:\n record = 0x0027 # Record identifier\n length = 0x0008 # Bytes to follow\n\n margin = @margin_right # Margin in inches\n\n header = [record, length].pack('vv')\n data = [margin].pack('d')\n\n data = data.reverse if @byte_order != 0 && @byte_order != ''\n\n prepend(header, data)\n end", "def analyze_barcode\n Barcode_Columns.times do |barcode_col_index|\n barcode_pos = transform_point(BPoint.new(barcode_col_index, Barcode_Row-1), :bottombias)\n @upstream.ann_point(barcode_pos.x, barcode_pos.y)\n score = shrink_to_one(:ballot, barcode_pos.x - i2p(TM_Width)/2.0, barcode_pos.y-i2p(TM_Height)/2.0, i2p(TM_Width), i2p(TM_Height))\n if score < (QuantumRange * BarCodeDetectThresh).to_int then\n @raw_barcode << barcode_col_index\n end\n end\n end", "def sequence_length\n id_line('SEQUENCE_LENGTH')\n end", "def pad(str_length=nil)\n new_arr = []\n @value.each_with_index do |string, i|\n string = string.dup # to avoid changing the original\n if str_length.nil? then\n # pad if the string is odd or use the size property if there is a\n # predefined size\n if @record and (size=RECORD_INFO[@record.type].size) > 0 then\n new_arr.push [string].pack(\"a#{size}\")\n elsif (len=string.length)%2 == 1 then\n new_arr.push [string].pack(\"a#{len+1}\")\n else\n new_arr.push string\n end\n else\n # A desired string length was given; ensure that the requested\n # length is a multiple of 2 and is not less than the string given.\n if str_length%2 == 1 then\n raise ArgumentError,\n \"Desired string length must be a multiple of 2\"\n elsif str_length < string.length then\n raise ArgumentError,\n \"Desired string length given #{str_length} is less than actual string length #{string.length}\"\n else\n new_arr.push [string].pack(\"a#{str_length}\")\n end \n end\n end\n new_arr\n end", "def size\n self.data.length + 4\n end", "def size\n @length / 4\n end", "def barcode_type\n rtn = :none\n rtn = samples[0].barcode_type if samples[0]\n rtn\n end", "def sequence_name_length\n IDENTIFIER_MAX_LENGTH\n end", "def length\n end", "def length\n end", "def length\n end", "def length\n end", "def length\n end", "def buffer_initial_length=(length)\n #This is a stub, used for indexing\n end", "def get_barcode(primer)\n # TODO: Refactor to deal with primers that don't have an overhang sequence\n barcode = \"\"\n ohang = primer.properties.fetch(\"Overhang Sequence\")\n if ohang\n if ohang.length >= INDEX_LENGTH\n tmp = ohang[(ohang.length-INDEX_LENGTH)..(ohang.length-1)].downcase.reverse!\n barcode = tmp.gsub('a','T').gsub('t','A').gsub('c','G').gsub('g','C')\n end\n end\n barcode\n end", "def post_process(record)\n len = record[@len_field.name] rescue nil\n if !len.nil? and len.is_a?(Fixnum)\n value = record[@string_field.name]\n value.slice!(len..-1)\n record[@string_field.name] = value # we can avoid reassignment assuming the value is a reference not a copy\n end\n end", "def ismn\n generate_barcode('barcode.ismn')\n end", "def byte_size()\n @value.length * 4\n end", "def byte_size()\n @value.length * 4\n end", "def trim_length\n \t400\n end", "def kex_byte_requirement; end", "def key_length_valid?(number)\n number >= 1024 && ( number & (number - 1) == 0 )\n end", "def key_length_valid?(number)\n number >= 1024 && ( number & (number - 1) == 0 )\n end", "def read\n # Obtain the \"pkt-len\"\n prefix = @input.read(4)\n\n unless prefix && prefix[/^[0-9a-f]{4}/]\n raise ProtocolError, \"invalid pkt-line prefix: #{prefix.inspect}\" \n end\n\n length = Integer(prefix, 16)\n return nil if length.zero?\n raise LengthError, \"length prefix too long\" if length > PKT_LINE_MAX\n raise LengthError, \"length prefix is malformed\" if length < 4\n\n @input.read(length - 4) || \"\"\n end" ]
[ "0.6568643", "0.6568643", "0.6193347", "0.6172301", "0.60400975", "0.60082644", "0.598168", "0.5893825", "0.5878259", "0.57244277", "0.5696949", "0.56375873", "0.56272346", "0.56210715", "0.5613167", "0.55780613", "0.5565064", "0.55514145", "0.55440646", "0.5540473", "0.551721", "0.55153537", "0.5514645", "0.5408946", "0.5386355", "0.53793395", "0.53787494", "0.53787494", "0.53787494", "0.53787494", "0.5370265", "0.53650814", "0.53598833", "0.5357607", "0.5352126", "0.53416145", "0.5320148", "0.5306369", "0.5289264", "0.52880853", "0.52661586", "0.5262595", "0.5258878", "0.52495617", "0.5248816", "0.52469844", "0.52332443", "0.5229691", "0.522358", "0.5215143", "0.52108264", "0.52108264", "0.52108264", "0.52108264", "0.52108264", "0.52108264", "0.52108264", "0.52108264", "0.52108264", "0.52108264", "0.5210355", "0.51994747", "0.51964015", "0.51964015", "0.51964015", "0.51964015", "0.51964015", "0.51964015", "0.51964015", "0.51821125", "0.51709247", "0.51688486", "0.5167466", "0.5167466", "0.5164818", "0.5164818", "0.5162775", "0.5151435", "0.51376784", "0.5135557", "0.5125836", "0.51249975", "0.511959", "0.51185995", "0.51185226", "0.51185226", "0.51185226", "0.51185226", "0.51185226", "0.51176286", "0.5096445", "0.5096202", "0.50933284", "0.50822484", "0.50822484", "0.50811523", "0.507621", "0.5074224", "0.5074224", "0.50712615" ]
0.7220451
0
Record has a variable barcode length
def shift_separator_length separator_index = data.find_index(separator) return unless separator_index && separator_index <= record.barcode_max_length shift_fixed_length(separator_index).tap do data.shift # Shift separator character end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift_barcode_length\n return unless record.barcode_length\n\n shift_fixed_length(record.barcode_length)\n end", "def length\n barcode.two_dimensional? ? encoding.first.length : encoding.length\n end", "def length\n barcode.two_dimensional? ? encoding.first.length : encoding.length\n end", "def barcode\n str_order = order.id.to_s.rjust(5, '0')\n str_cardinality = 1.to_s.rjust(3, '0')\n str_order + str_cardinality\n end", "def barcode(length: 8, bits: 10)\n rand(bits**length).to_s(bits).rjust(length, '0')\n end", "def width\n barcode.encoding.length * xdim\n end", "def barcode\n return if not_registered\n barcode_string.to_i(2)\n end", "def byte_size(); @data.byte_size + 4; end", "def trailer_arquivo_posicao_394_a_400(sequencial)\n\t\t\t\t\t\t\"#{sequencial}\".adjust_size_to(6, '0', :right)\n\t\t\t\t\tend", "def barcode\n \"*#{identifier}*\"\n end", "def data_length\n super\n end", "def data520\n max_length = 1879\n @thesis.abstract&.each_line do |line|\n # skip any blank lines. Mostly if multiple linebreaks were added to the text.\n next if line.strip.empty?\n\n # if the line length is valid for 520, add it\n if line.length < max_length\n @record.append(MARC::DataField.new(\n '520', '3', ' ',\n ['a', line.encode(options: :xml).strip]\n ))\n # split lines that remain too long into valid size strings\n else\n part = line.chars.to_a.each_slice(max_length).map(&:join)\n part.each do |part_line|\n @record.append(MARC::DataField.new(\n '520', '3', ' ',\n ['a', part_line.encode(options: :xml).strip]\n ))\n end\n end\n end\n end", "def byte_size()\n if @record and RECORD_INFO[@record.type].size > 0 then\n RECORD_INFO[@record.type].size * @value.length\n else\n sum = 0\n @value.each do |val|\n sum += (val.length % 2 == 0) ? val.length : val.length + 1\n end\n sum\n end\n end", "def genbank\n chars = 60\n lines = (length / chars.to_f).ceil\n width = length.to_s.length\n\n s = ''\n (1..lines).each do |i|\n s << \"%#{width}d\" % (chars * (i - 1) + 1)\n s << ' '\n s << to_s[chars * (i - 1), chars].scan(/\\w{1,10}/).join(' ')\n s << \"\\n\"\n end\n s\n end", "def paper_white_area() barcode_bit_area -1 end", "def current_length; end", "def is_corrected_barcode?(barcode_id, is)\n is != barcode_id && is.length != 4 && is.length != 8\n end", "def name_record_long(type, ext_ref) #:nodoc:\n record = 0x0018 # Record identifier\n length = 0x002a # Number of bytes to follow\n\n grbit = 0x0020 # Option flags\n chkey = 0x00 # Keyboard shortcut\n cch = 0x01 # Length of text name\n cce = 0x001a # Length of text definition\n unknown01 = 0x0000 #\n ixals = @worksheet.index + 1 # Sheet index\n unknown02 = 0x00 #\n cch_cust_menu = 0x00 # Length of cust menu text\n cch_description = 0x00 # Length of description text\n cch_helptopic = 0x00 # Length of help topic text\n cch_statustext = 0x00 # Length of status bar text\n rgch = type # Built-in name type\n\n unknown03 = 0x29\n unknown04 = 0x0017\n unknown05 = 0x3b\n\n header = [record, length].pack(\"vv\")\n data = [grbit].pack(\"v\")\n data += [chkey].pack(\"C\")\n data += [cch].pack(\"C\")\n data += [cce].pack(\"v\")\n data += [unknown01].pack(\"v\")\n data += [ixals].pack(\"v\")\n data += [unknown02].pack(\"C\")\n data += [cch_cust_menu].pack(\"C\")\n data += [cch_description].pack(\"C\")\n data += [cch_helptopic].pack(\"C\")\n data += [cch_statustext].pack(\"C\")\n data += [rgch].pack(\"C\")\n\n # Column definition\n data += [unknown03].pack(\"C\")\n data += [unknown04].pack(\"v\")\n data += [unknown05].pack(\"C\")\n data += [ext_ref].pack(\"v\")\n data += [0x0000].pack(\"v\")\n data += [0xffff].pack(\"v\")\n data += [@col_min].pack(\"v\")\n data += [@col_max].pack(\"v\")\n\n # Row definition\n data += [unknown05].pack(\"C\")\n data += [ext_ref].pack(\"v\")\n data += [@row_min].pack(\"v\")\n data += [@row_max].pack(\"v\")\n data += [0x00].pack(\"v\")\n data += [0xff].pack(\"v\")\n # End of data\n data += [0x10].pack(\"C\")\n\n [header, data]\n end", "def illumina_barcode\n self.barcode_type == :illumina ? self.barcode : \"\"\n end", "def show_scan_new_items\n Array.new(40, generate_barcode)\n end", "def pad_length\n offset = (lp_value_name.abs_offset + lp_value_name.to_binary_s.length) % 4\n (4 - offset) % 4\n end", "def barcode(args={})\n self.bare_barcode\n end", "def target_len; genomic.len; end", "def render_length; end", "def length() end", "def length() end", "def length() end", "def length() end", "def length(record)\n if type.variable?\n record[:header][:field_lengths][position]\n else\n type.length\n end\n end", "def process_record(record, data)\n begin\n if data.nil?\n length = 0\n else\n length = data.length\n end\n STDERR.puts(\"ShardId: #{@shard_id}, Partition Key: #{record['partitionKey']}, Sequence Number:#{record['sequenceNumber']}, Length of data: #{length}\")\n rescue => e\n STDERR.puts \"#{e}: Failed to process record '#{record}'\"\n end\n end", "def size_mum_record\n 8\n end", "def base_width; 26 + @width; end", "def create\n @bar_code = BarCode.new(bar_code_params)\n gen = Barby::Code128B.new(@bar_code.text)\n send_data gen.to_png(:height => 50), :type => \"image/png\", :disposition => \"inline\"\n\n @bar_code.save\n\n\n\n end", "def write_multi_debug code_length\n result = ['4A000004 00000001'] # start at quantity 1\n\n write_amount = zero_pad_int(code_length, 3)\n result + [\"4#{write_amount}0010 00000001\"] # increase by 1\n end", "def length_override; end", "def custom_barcode\n self.barcode_type == :custom ? self.barcode : \"\"\n end", "def analyze_barcode\n Barcode_Columns.times do |barcode_col_index|\n barcode_pos = transform_point(BPoint.new(barcode_col_index, Barcode_Row-1), :bottombias)\n @upstream.ann_point(barcode_pos.x, barcode_pos.y)\n score = shrink_to_one(:ballot, barcode_pos.x - i2p(TM_Width)/2.0, barcode_pos.y-i2p(TM_Height)/2.0, i2p(TM_Width), i2p(TM_Height))\n if score < (QuantumRange * BarCodeDetectThresh).to_int then\n @raw_barcode << barcode_col_index\n end\n end\n end", "def pad_record(text_line)\n flow_type = Inflector.underscore(self.class.to_s).split(\"_\")[0].upcase()\n record_type = text_line.slice(0..1).upcase()\n\n\n #remove x-tra spaces to right, i.e where the passed in text-line > schema required length\n if text_line.length() > RecordPadder.required_record_length(flow_type, record_type, text_line.length)\n text_line.slice!(RecordPadder.required_record_length(flow_type, record_type, text_line.length)..text_line.length())\n return text_line\n else\n text_line.ljust(RecordPadder.required_record_length(flow_type, record_type, text_line.length))\n\n end\n\n\n\n end", "def pad_length\n offset = (lp_data.abs_offset + lp_data.to_binary_s.length) % 4\n (4 - offset) % 4\n end", "def run_length_encode\n self.pack_consecutive_duplicates.inject([]) do |array, current|\n array << [current.size, current[0]]\n array \n end\n end", "def barcode=(value)\n value = value.to_s if Integer === value\n setBarcode(value)\n end", "def initialize(barcode)\n self.barcode = barcode\n end", "def initialize(barcode)\n self.barcode = barcode\n end", "def header_length() 3 end", "def barcode_string\n b_string = self.custom_barcode\n if b_string.empty?\n b_string = self.illumina_barcode_string\n end\n b_string\n end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def length; end", "def length\n super\n end", "def size\n self.data.length + 4\n end", "def length\n length = width\n end", "def barcode_string\n return if not_registered\n @mim.barcode_bits.map do |b|\n b ? '1' : '0'\n end.join.reverse\n end", "def barcode_type\n rtn = :none\n rtn = samples[0].barcode_type if samples[0]\n rtn\n end", "def length_calculator; end", "def length; @records.length; end", "def get_barcode(primer)\n # TODO: Refactor to deal with primers that don't have an overhang sequence\n barcode = \"\"\n ohang = primer.properties.fetch(\"Overhang Sequence\")\n if ohang\n if ohang.length >= INDEX_LENGTH\n tmp = ohang[(ohang.length-INDEX_LENGTH)..(ohang.length-1)].downcase.reverse!\n barcode = tmp.gsub('a','T').gsub('t','A').gsub('c','G').gsub('g','C')\n end\n end\n barcode\n end", "def byte_size()\n @value.length * 4\n end", "def byte_size()\n @value.length * 4\n end", "def size\n @length / 4\n end", "def length(record)\n if record.header.lengths.include?(@name)\n len = record.header.lengths[@name]\n raise \"Fixed-length mismatch\" unless variable? || len == @data_type.width\n else\n len = @data_type.width\n end\n extern?(record) ? len - EXTERN_FIELD_SIZE : len\n end", "def barcode_box(pdf, value)\n text_height = font_size*1.5\n code_height = pdf.bounds.height - text_height\n code = '%05d' % value\n\n # Barcode above..\n pdf.bounding_box([pdf.bounds.left, pdf.bounds.top - code_height],\n :width => pdf.bounds.width, :height => text_height) do\n pdf.text(code, :align => justification.to_sym)\n end\n\n # Text below\n pdf.bounding_box([pdf.bounds.left, pdf.bounds.top],\n :width => pdf.bounds.width, :height => code_height) do\n barcode = Barby::Code39.new(code)\n barcode.annotate_pdf(pdf, :xdim => 0.75, :height => code_height * 0.8)\n end\n end", "def initialize length\n self.length = length\n end", "def byte_size; size.y * line_byte_size; end", "def read_record\n n_read = 0\n tu = @file.read INT_SIZE\n return nil if tu.nil? || tu.bytesize < INT_SIZE\n if (tu == (ZERO_BYTE_ASCII_8BIT * INT_SIZE))\n # empty record. skip this page.\n @file.seek(PAGE_SIZE - INT_SIZE, IO::SEEK_CUR)\n return nil\n end\n n_read += tu.bytesize\n t = tu.unpack(PACK_UINT).first\n\n return nil if @file.eof?\n lu = @file.read INT_SIZE\n return nil if lu.nil? || lu.bytesize < INT_SIZE\n n_read += lu.bytesize\n l = lu.unpack(PACK_UINT).first\n\n if false # l == 7016996765293437281\n puts \"*************** #{__FILE__} #{__LINE__} *************\"\n puts \"at: #{@file.tell}\"\n end\n\n if l > MAX_VALUE_SIZE\n raise ParseError.new \"Read size that exceeds the maximum size for a value.\"\n end\n\n k = nil\n begin\n k = @file.read l\n rescue NoMemoryError => e\n # puts \"*************** #{__FILE__} #{__LINE__} *************\"\n # puts \"#{e.message} at #{l}\"\n raise\n end\n\n return nil if k.nil? || k.bytesize < l\n n_read += k.bytesize\n d = if t != WRITE_TYPE_INDEXES[:array]\n [t, k]\n else\n asu = @file.read INT_SIZE\n return nil if asu.nil? || asu.bytesize < INT_SIZE\n n_read += asu.bytesize\n as = asu.unpack(PACK_UINT).first\n [t, k, as]\n end\n return nil if d.nil?\n\n v = nil\n\n raw_v = nil\n case d[0]\n when WRITE_TYPE_INDEXES[:array]\n a = []\n d[2].times do |i|\n raw_v, b_read = read_value_s\n n_read += b_read\n break if raw_v.nil?\n a.push(raw_v)\n end\n v = a\n when WRITE_TYPE_INDEXES[:hash], WRITE_TYPE_INDEXES[:set]\n raw_v, b_read = read_value_s\n return nil if raw_v.nil?\n n_read += b_read\n v = MultiJson.decode(raw_v)\n when WRITE_TYPE_INDEXES[:string]\n v, b_read = read_value_s\n return nil if v.nil?\n n_read += b_read\n when WRITE_TYPE_INDEXES[:counter]\n v, b_read = read_value_i\n return nil if v.nil?\n n_read += b_read\n end\n\n pages_read = n_read / PAGE_SIZE\n remainder = (n_read % PAGE_SIZE)\n if remainder > 0\n @file.seek((PAGE_SIZE - remainder), IO::SEEK_CUR)\n pages_read += 1\n end\n\n [d, v, pages_read]\n end", "def detalhe_posicao_395_400(pagamento, sequencial)\n\t\t\t\t\t\t\"#{sequencial}\".adjust_size_to(6, '0', :right)\n\t\t\t\t\tend", "def max_key_width; end", "def printBarCode(zip_array)\n\tbarcode_table = {1=>'00011', 2=>'00101',3=>'00110', 4=>'01001', 5=>'01010', 6=>'01100', 7=>'10001', 8=>'10010', 9=>'10100', 0=>'11000'}\n\tbarcode = \"|\"\n\tzip_array.each{\n\t\t|digit| # each digit is a string\n\t\tcode = barcode_table[digit.to_i].scan /\\d/\n\t\tcode.each{\n\t\t\t|bit|\n\t\t\tbit == \"0\" ? barcode += \":\" : barcode += \"|\"\n\t\t}\n\t}\n\tbarcode += \"|\"\n\tputs barcode\nend", "def height\n barcode.two_dimensional? ? (ydim * encoding.length) : (@height || 100)\n end", "def height\n barcode.two_dimensional? ? (ydim * encoding.length) : (@height || 100)\n end", "def ismn\n generate_barcode('barcode.ismn')\n end", "def post_process(record)\n len = record[@len_field.name] rescue nil\n if !len.nil? and len.is_a?(Fixnum)\n value = record[@string_field.name]\n value.slice!(len..-1)\n record[@string_field.name] = value # we can avoid reassignment assuming the value is a reference not a copy\n end\n end", "def length\n end", "def length\n end", "def length\n end", "def length\n end", "def length\n end", "def increment(packet_length); end", "def valid_length?\n specification && specification['length'] - 4 == @code.length\n end", "def max_history=(length); end", "def max_history=(length); end", "def size\n self.dna_hash.size\n end", "def size\n self.dna_hash.size\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def fbe_size\n 4\n end", "def length(*) end", "def length(*) end", "def length_spec; @length && @length != 0 ? \"[#{@length}\" + (@scale ? '.' + @scale.to_s : '') + ']' : '' end", "def bgnstr_record() @records.get(GRT_BGNSTR); end", "def dump\n record = format_N(:data_type, 1) +\n dump_record\n if record.bytesize != 120\n raise IllegalStateError, \"record size #{record.bytesize} != 120\"\n end\n record\n end" ]
[ "0.6833759", "0.6680222", "0.6680222", "0.6470731", "0.6205599", "0.612365", "0.5866172", "0.585971", "0.5769487", "0.5719548", "0.57152337", "0.5704288", "0.569279", "0.56615734", "0.5647638", "0.5637222", "0.55916476", "0.5570419", "0.5544415", "0.55339706", "0.55224013", "0.55069226", "0.5499866", "0.548111", "0.545698", "0.545698", "0.545698", "0.545698", "0.5456789", "0.5412154", "0.5395751", "0.53647625", "0.5359219", "0.5340498", "0.5336108", "0.53348243", "0.5325733", "0.5315606", "0.5311463", "0.53058225", "0.53027236", "0.5288369", "0.5288369", "0.5287769", "0.5284182", "0.52772987", "0.52772987", "0.52772987", "0.52772987", "0.52772987", "0.52772987", "0.52772987", "0.52653414", "0.526259", "0.5252548", "0.524682", "0.5246244", "0.5228452", "0.52145916", "0.52143025", "0.5205836", "0.5205836", "0.52057594", "0.5205647", "0.5205175", "0.5196979", "0.51941663", "0.518257", "0.5170616", "0.5166577", "0.51641035", "0.51532465", "0.51532465", "0.5148823", "0.5132724", "0.5131772", "0.5131772", "0.5131772", "0.5131772", "0.5131772", "0.5129405", "0.51286274", "0.5099886", "0.5099886", "0.50983375", "0.50983375", "0.508998", "0.508998", "0.508998", "0.508998", "0.508998", "0.508998", "0.508998", "0.508998", "0.508998", "0.508998", "0.5082275", "0.5082275", "0.5080391", "0.50799733", "0.5079016" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def after_set_callback; end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def setup(&blk)\n @setup_block = blk\n end", "def default_action; end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def call\n setup_context\n super\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end" ]
[ "0.6165094", "0.60450804", "0.5944413", "0.5915806", "0.58885634", "0.5835225", "0.5775847", "0.5700531", "0.5700531", "0.56543404", "0.56209993", "0.54238355", "0.5410386", "0.5410386", "0.5410386", "0.5394892", "0.5377769", "0.53559244", "0.5339896", "0.53388095", "0.5330087", "0.5311993", "0.5297402", "0.5296789", "0.52957207", "0.52596015", "0.5245442", "0.5237084", "0.5237084", "0.5237084", "0.5237084", "0.5237084", "0.5235431", "0.5231888", "0.5226663", "0.52220625", "0.5217086", "0.52137345", "0.5208314", "0.5205469", "0.5175606", "0.5174914", "0.5173361", "0.51662856", "0.5161792", "0.51572216", "0.5153063", "0.5152982", "0.5152632", "0.51435786", "0.5139829", "0.51346594", "0.511372", "0.511372", "0.51136476", "0.51083213", "0.5108011", "0.5091935", "0.5089297", "0.5081576", "0.50807106", "0.50656676", "0.50548106", "0.50537366", "0.505074", "0.505074", "0.5033361", "0.5025158", "0.5020441", "0.5015611", "0.50142473", "0.5000281", "0.50001067", "0.49989453", "0.4989465", "0.4989465", "0.4985425", "0.49805096", "0.49795893", "0.49783278", "0.49676263", "0.49656346", "0.49579078", "0.4955427", "0.49554235", "0.49536413", "0.49523768", "0.49457142", "0.49433607", "0.4933641", "0.49320185", "0.49265638", "0.49262375", "0.49259067", "0.4922456", "0.49201223", "0.49165115", "0.49158815", "0.49151883", "0.49149552", "0.4914386" ]
0.0
-1
Only allow a trusted parameter "white list" through.
def user_params params.permit(:name,:email,:password, :country) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def filtered_parameters; end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\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 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 param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def filter_parameters; end", "def filter_parameters; end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def check_params; true; end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def list_params\n params.permit(:name)\n end", "def check_params\n true\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\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 additional_permitted_params\n []\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def allow_params_authentication!; 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 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 person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def quote_params\n params.permit!\n end", "def list_params\n params.permit(:list_name)\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def all_params; end", "def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def user_params\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def permitted_params\n @wfd_edit_parameters\n end", "def user_params\r\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 query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def params_permit\n params.permit(:id)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end", "def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n 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 argument_params\n params.require(:argument).permit(:name)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\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 sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\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 parameters\n nil\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\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 special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end" ]
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.63804525", "0.6373396", "0.6360051", "0.6355191", "0.62856233", "0.627813", "0.62451434", "0.6228103", "0.6224965", "0.6222941", "0.6210244", "0.62077755", "0.61762565", "0.61711127", "0.6168448", "0.6160164", "0.61446255", "0.6134175", "0.6120522", "0.6106709", "0.60981655", "0.6076113", "0.60534036", "0.60410434", "0.6034582", "0.6029977", "0.6019861", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.60184896", "0.60157263", "0.6005857", "0.6003803", "0.60012573", "0.59955895", "0.5994598", "0.5993604", "0.5983824", "0.5983166", "0.5977431", "0.597591", "0.5968824", "0.5965953", "0.59647584", "0.59647584", "0.59566855", "0.59506303", "0.5950375", "0.59485626", "0.59440875", "0.5930872", "0.5930206", "0.5925668", "0.59235454", "0.5917905", "0.59164816", "0.5913821", "0.59128743", "0.5906617", "0.59053683", "0.59052664", "0.5901591", "0.58987755", "0.5897456", "0.58970183", "0.58942604" ]
0.0
-1
attr_reader :name def name
def a_method self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name_reader\n @name\n end", "def name() return @name end", "def name() return @name end", "def name # getter method (or reader method)\n @name\n end", "def name #use and initlizer to set name as an instance variable\n @name\nend", "def getName; @name; end", "def ___name\n @name\n end", "def name() end", "def name\n end", "def get_name\n\t\treturn @name\n\tend", "def get_name\n\t\treturn @name\n\tend", "def get_name\n\t\treturn @name\n\tend", "def get_name\n\t\t@name\n\tend", "def name\n\t\t@name\n\tend", "def name\n\t\t@name\n\tend", "def name\n\t\t@name\n\tend", "def name\n\t\t@name\n\tend", "def name\n\t\t@name\n\tend", "def name\n\t\t@name\n\tend", "def name \n @name\n end", "def name\n # scope: which vars can this method 'see'?\n @name\n end", "def name \n @name\n end", "def name \n @name\n end", "def name\n return @name\n end", "def name\n return @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n @name\n end", "def name\n\n end", "def name\n @name \n end", "def name\n end", "def name\n end", "def name\n end", "def name\n end", "def name\n \n end", "def name\n @_name\n end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end" ]
[ "0.86338913", "0.8594176", "0.8594176", "0.8577292", "0.85306424", "0.84951365", "0.84216356", "0.83766085", "0.83570534", "0.8338035", "0.8338035", "0.8338035", "0.83332336", "0.8329312", "0.8329312", "0.8329312", "0.8329312", "0.8329312", "0.8329312", "0.8309918", "0.8300382", "0.8298653", "0.8298653", "0.82804555", "0.82804555", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.82793033", "0.8278042", "0.8278042", "0.8273914", "0.82604766", "0.8258108", "0.8258108", "0.8258108", "0.8258108", "0.82579046", "0.824821", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559", "0.8245559" ]
0.0
-1
used for querying a user's books in the search view mainly, when getting the book model when a search returns a book that a friend already has.
def index @books = [] if (params[:q]) @books = Book.where(params[:q]) end render :json => @books end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @books = Book.search(params[:search_term])\n @mybooks = current_user.books\n end", "def index\n \n @user = current_user\n @search = current_user.books.search(params[:q])\n @books = @search.result\n end", "def index\n books_to_consider=user_signed_in? ? (Book.where.not(owner_id: current_user.id) if stale?(Book.where.not(owner_id: current_user.id))) : (Book.all if stale?(Book.where.not(owner_id: current_user.id)))\n @books=[]\n books_to_consider.each do |book|\n unless BookTransaction.where(\"book_id=? AND (approved=false OR requested=false OR returned=false)\",book.id).exists?\n @books.push(book)\n end\n end\n @books = @books.where(genre: params[:genre]) if params[:genre].present?\n @books = @books.where(author: params[:author]) if params[:author].present?\n @books = @books.where(title: params[:title]) if params[:title].present?\n \n if params[:userid].present?\n books_by_user=[]\n @books.each do |book|\n if book.owner_id=params[:userid]\n books_by_user.push(book)\n end\n end\n @books=books_by_user\n end\n\n @books = @books.search(params[:search]) if params[:search].present?\n @books = @books.paginate(:page => params[:page], :per_page => 15)\n @unique_authors = Book.uniq.pluck(:author)\n @unique_genre = Book.uniq.pluck(:genre)\n #render :layout => false\n \n end", "def query_or_api\n books = query(self.username)\n end", "def index\n if current_student\n student_id = current_student.id \n @books = Book.fetch_books_by_university(student_id)\n elsif current_admin\n @books = Book.all\n elsif current_librarian\n library_id = current_librarian.library_id\n @books = Book.fetch_books_by_library(library_id)\n end\n\n if !params[:search].nil?\n @books = @books & Book.search(params[\"search_by\"].downcase, params[:search])\n end\n end", "def index\n if params.has_key?(:search) && params[:search].strip != \"\" #for rental search across site\n @books = Book.search(params[:search], :match_mode => :any, :star => true, :page => params[:page], :per_page => 10)\n if (@books.count == 0)\n @books = nil\n end\n\n elsif params[:category] #for category search\n @book_ids = BookCategory.where('category_id = ?', params[:category]).pluck(:book_id)\n if (@book_ids)\n @books = Book.where(:id => @book_ids).paginate(:page => params[:page], :per_page => 10)\n if (UserBook.find_by_book_id(@book_ids) == nil)\n @books = nil\n end\n else\n @books = nil\n #flash[:alert] = \"We didn't find any book in this category :(\" #not showing up\n end\n \n #elsif params[:value] #for autosuggest on search bar\n # @books = Book.search(params[:value], :match_mode => :any, :star => true)\n \n else \n @books = Book.where(:id => [1..191]).paginate(:page => params[:page], :per_page => 10) #paginate(:page => params[:page], :per_page => 1) #(limit: 10)\n flash.now[:alert] = \"Please type in something to search. Some recent listings have been shown. Also, we just opened up the listing feature :)\"\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n\n end", "def index\n @books = Book.of_user current_user\n end", "def search\n if params[:search].present?\n @books = Book.search(params[:search])\n else\n @books = Book.all\n end\n end", "def index\n #@books = Book.all\n #get current user_id\n user_id= User.find(current_user.id)\n #@books = Book.search(params[:search])\n # check if the user has any books\n books = Book.find_by_user_id(current_user.id)\n if books.nil?\n # if not redirect\n redirect_to \"/books/new\"\n else\n @books = @current_user.books\n @count = @current_user.books.count\n\n #http://railscasts.com/episodes/240-search-sort-paginate-with-ajax?autoplay=true\n @books = @books.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 5, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end\n end", "def user_books\n @title = \"My Books\"\n @user = User.find(params[:id])\n @books = @user.book_lists.paginate(page: params[:page])\n render 'user_books'\n end", "def books\n\t\tif params[:id].nil? || params[:id].to_i.eql?(@current_user.id) \n\t\t\t@user = current_user\n\t\telse\n\t\t\t@user = User.find(params[:id])\n\t\tend\n\t\t@books = @user.books\n\tend", "def index\n if current_user\n query = can?(:admin, :site) ? Book.all : Book.active_or_mine(current_user.id)\n else\n query = Book.active_books\n end\n if params[:q]\n @books = do_search query\n # not sure how to get elasticsearch to only search within the query\n # Se we have to limit it here again\n if current_user && cannot?(:admin, :site) # non admins can only view their own inactive books\n @books.reject! {|b| !b.active && b.user_id != current_user.id}\n else # guests can only view active books\n @books.reject! {|b| !b.active}\n end\n elsif params[:column]\n do_sort query\n else\n @books = query.to_a.sort {|a,b| a.rating <=> b.rating}.reverse\n end\n @user = current_user\n end", "def index\n @books = Book.where([\"name LIKE ?\", \"%#{params[:search]}%\"])\n end", "def index\n if current_user.usertype == \"admin\"\n if params[:search]\n @books = []\n Book.all.each do |book|\n if params[:title] != \"\"\n next if !book.title.downcase.include? params[:title].downcase\n end\n if params[:author] != \"\"\n next if !book.author.downcase.include? params[:author].downcase\n end\n if params[:published] != \"\"\n next if !book.published.to_s.eql? params[:published]\n end\n if params[:subject] != \"\"\n next if !book.subject.downcase.include? params[:subject].downcase\n end\n @books.push(book)\n end\n else\n @books = Book.all\n end\n end\n end", "def show\n @user = User.find(params[:id])\n @books = @user.books\n end", "def index\n @books = current_user.books.all\n end", "def index\n @books = params[:search] ? Book.select{|book| book.title.downcase.include?(params[:search].downcase)} : Book.all\n end", "def index\n if params[:search].present?\n @books = Book.search_by_name(params[:search]).order(name: :ASC).page params[:page]\n elsif params[:status].present?\n case params[:status]\n when \"Draft\"\n @books = Book.draft.search_by_name(params[:search]).order(name: :ASC).page params[:page]\n when \"Published\"\n @books = Book.published.search_by_name(params[:search]).order(name: :ASC).page params[:page]\n end\n elsif params[:person].present?\n @books = Book.joins(:compositions).where(compositions: { person_id: params[:person] }).order(name: :ASC).page params[:page]\n else\n @books = Book.order(name: :ASC).page params[:page]\n end\n end", "def index\n @booklists = Booklist.limit(10)\n #@focusbooklists=Focusbooklist.joins(:user)\n @currentuser = current_user\n @q = Booklist.ransack(params[:q])\n #@searchbooklist = @q.result(distinct: true)\n end", "def index\n @booksinlists = Booksinlist.all\n @booksinthelist = Book.joins(:booksinlists).where(booksinlists: {booklist_id: params[:id]})\n #@books = Book.find()\n end", "def new\n\n @user = User.find(current_user.id)\n @book = Book.new\n @book.user_id = @user.id\n\n @book = Book.new(:title => params[:rtitle],:author => params[:rauthor], :isbn => params[:risbn])\n # @book = Book.find_by_user_id(@user.id)\n\n isbn = @book.isbn\n user_id = @user.id\n books = Book.find_by_isbn_and_user_id(isbn,user_id)\n if books.nil?\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n else\n redirect_to \"/books/search\"\n flash[:alert] = \"the book '#{@book.title}' already exist - please search for another book!!!\"\n end\n end", "def fullsearch\n if params[:isbn]\n @books = Book.where(:ISBN => params[:isbn])\n elsif params[:title]\n @books = Book.where(\"Title LIKE :title1\", { :title1 => \"#{params[:title]}%\"})\n elsif params[:author]\n @books = Book.where(\"Authors LIKE :author1\", { :author1 => \"#{params[:author]}%\"})\n elsif params[:description]\n @books = Book.where(\"Description LIKE :description1\", { :description1 => \"#{params[:description]}%\"})\n else\n @books = Book.all\n end\n end", "def index\n @current_user = current_user\n @books = []\n if !@current_user.student?\n @books = Book.all\n end\n end", "def search\n\t authorize! :search, Book\n\n\t query = params[:search] || \"\"\n page = params[:page] ? params[:page].to_i : 1\n \n @conditions = Condition.all\n\t @result = Book.search(query, page)\n @result = Book.calculate_hidden(@result, session[:user_id])\n\n\tend", "def index\n @books = current_user.books\n end", "def my_books\n @books = current_user.books\n end", "def index\n if params[:tag]\n @search = Book.approved?(@user).search(tags_name_eq: params[:tag])\n else\n @search = Book.approved?(@user).search(params[:q])\n end\n @books = @search.result.includes(:reviews, :tags).paginate(:page => params[:page]).order(rating: :desc)\n @search.build_condition\n end", "def index\n if view_context.is_admin?\n @books = Book.all\n elsif user_signed_in?\n @books = Book.where(\"is_approved = ? or user_id = ?\", true, current_user.id)\n else\n @books = Book.where(\"is_approved = ?\", true)\n end\n end", "def index\n if params[:users_id]\n @usersbooks = User.find(params[:users_id]).usersbooks\n elsif params[:books_id]\n @usersbooks = Book.find(params[:books_id]).usersbooks\n else\n @usersbooks = Usersbook.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usersbooks }\n end\n end", "def create_search\n @book = Book.where(identifier: params[:book][:identifier]).first_or_create(book_params) # Find or create a book instance based on Google identifier\n current_user.books << @book if !current_user.books.include?(@book)\n redirect_to user_path(current_user) # Redirect to user show page \n end", "def index\n check_if_student\n @books = Book.all\n end", "def index\n \n @books = Book.search(params[:search])\n \n if params[:book] and params[:book][:genre_id] > \"\"\n genreid = params[:book][:genre_id].to_i\n @books = @books.select { |b| b.genre_id == genreid }\n end\n \n \n \n @books = @books.paginate(page: params[:page], per_page: 5)\n \n \n end", "def search_param\n return { user_id: params['user_id'] } if params['user_id'].present?\n return { book_id: params['book_id'] } if params['book_id'].present?\n end", "def list\n if params[:query]\n @searched = true\n @books = Book.active.search(params[:query])\n else\n @books = Book.active_reverse.paginate :page => params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @books }\n end\n end", "def search\n @user = User.find(params[:user_id])\n @tags = show_user_tags @user\n result_search = search_bookmarks_by params[:tag_name], @user\n\n if current_user? @user\n @bookmarks = result_search.paginate(page: params[:page], per_page: 10) \n else\n temp = []\n result_search.each do |bookmark|\n unless bookmark.privacy? then\n temp.push(bookmark)\n end\n end\n @bookmarks = temp.paginate(page: params[:page], per_page: 10)\n end\n end", "def mybooks\n @books = Book.all\n end", "def index\n @m = \"/books\" \n @books = (params[:search].blank?) ? (params[:type].blank?) ? Book.all.page(params[:page]).per(20) : Book.where(:type_id=> params[:type]).page(params[:page]).per(20) : (params[:type].blank?) ? Book.all.params[:search].page(params[:page]).per(20) : Book.where(:type_id=> params[:type]).params[:search].page(params[:page]).per(20) \n @types = Type.all\n @book = Book.new\n @bookrent = Bookrent.new\n end", "def index\n @book_searches = BookSearch.all\n end", "def get_user_books\n user = User.find_by_id(params[:user_id])\n shelves = user.bookshelves\n \n @books = Array.new\n \n shelves.each do |s|\n s.books.each do |book|\n @books << book\n end\n end\n \n #books = Book.where(user_id: params[:user_id])\n \n render json: @books\n end", "def show_search\n @book = BookFinder.search_google_books_by_identifier(params[:identifier]) # Instantiate book instance from Google Books search (by Google identifier)\n end", "def show\n \t@books = Book.find_all_by_title(params[:book_name])\n end", "def index\n @wishlist_item = WishlistItem.new\n if (!params[:search].nil?) \n @books = Book.search params[:search], :page => params[:page]\n else \n if (!params[:uid].nil?)\n @books = Book.paginate :page => params[:page], :order => 'created_at DESC'\n else\n @books = Book.search \"Inventore\", :page => params[:page]\n end\n end\n if (@books.size == 0) \n else\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @books }\n end\n end\n end", "def index\n @bookings = Booking.all\n if params[:search]\n @search_term = params[:search]\n @bookings = @bookings.search_by(@search_term)\n end\n end", "def index\n @bookings = Booking.where(\"user_id = #{current_user.id}\")\n end", "def show\n @book = Book.find(params[:id]) # Find Book instance from id in params\n @userbook = UserBook.find_by(user_id: current_user.id, book_id: @book.id) # Find UserBook instance associated with current user and book to display the current user's book activity\n end", "def search_book(query)\n\n @book = Book.where(\"title like ?\" , query + '%')\n\n @book\n\n end", "def index \n @book_shop = find_book_shop_params\n @books = @book_shop.books.all\n end", "def user_books\n @reservations = Reservation.get_reservations(current_user.id)\n end", "def show\n @book = Book.search_by_czu_number(params[:book_id])\n @user_name_surname = User.get_name(params[:user_id]).to_s + \" \" + User.get_surname(params[:user_id]).to_s\n end", "def show\n @book = Book.search_by_czu_number(params[:book_id])\n @user_name_surname = User.get_name(params[:user_id]).to_s + \" \" + User.get_surname(params[:user_id]).to_s\n end", "def set_book_search\n @book_search = BookSearch.find(params[:id])\n end", "def index\n @bookings = Booking.where(consumer_id: current_user).or(Booking.where(consultant_id: current_user))\n\n end", "def books\n @books ||= current_user.books\n end", "def index\n @books = Book.find_all_by_user_id(current_user)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n end", "def available\n @books = Book.all\n end", "def index\n @books_authors = BooksAuthor.all\n end", "def index\n if params[:author_id]\n @author = Author.find(params[:author_id])\n @books = @author.books\n else\n @books = Book.all\n end\n end", "def index\n if params[:search]\n @books = Book.search(params[:search]).order(\"created_at DESC\").paginate(page: params[:page], per_page: 3)\n else\n @books = Book.paginate(page: params[:page], per_page: 3)\n end\n end", "def index\n @users = User.all\n @books = Book.all\n @book = Book.new\n end", "def index\n @users = User.search(params[:search])\n @friends = current_user.friends\n @inverse_friends = current_user.inverse_friends\n @requests = current_user.requests.collect { |request| User.find(request.friend_id) }\n @inverse_requests = current_user.inverse_requests.collect { |request| User.find(request.user_id) }\n end", "def index\n @my_books = MyBook.all\n end", "def search\n books, editionparams, descriptionparams = searchbooks(params)\n @hitcount = books.size\n filterbooks(books, editionparams, descriptionparams)\n @books = books\n respond_to do |format|\n format.html # search.html.erb\n format.xml\n format.atom\n #format.xml { render :xml => @books }\n end\n end", "def returnbook\n @books = Book.all \n end", "def index\n @book_users = BookUser.set_current_user_records(current_user)\n end", "def index\n #puts current_user.id\n if(current_user.user_type == 2)\n @bookings = Booking.where(\"user_id = ?\", current_user.id)\n else\n if(@user == nil and @car == nil)\n @bookings = Booking.all\n elsif(@car == nil)\n @bookings = Booking.where(\"user_id = ?\", @user.id)\n else\n @bookings = Booking.where(\"car_id = ?\", @car.id)\n end\n\n #@bookings = Booking.all\n end\n end", "def index\n @books = Book.get_avaible_books\n end", "def current_user_has_book?(book)\n current_user.books.find_by(identifier: book.identifier)\n end", "def show\n @user_book = UserBook.find(params[:id])\n @user_books_count = UserBook.new.user_books_count(current_user) #for shelf Nav count\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_book }\n end\n end", "def search\n book = Book.new(params)\n render json: book.search\n end", "def books_author\n \t@books = Book.where(\"author = '#{params[:author]}'\")\n\n \trespond_to do |format|\n format.html # list_authors.html.erb\n format.json { render json: @books }\n end\n end", "def index\n @bookitems = Bookitem.all\n \n end", "def index\n @bookings = Booking.where(user_id: current_user.id)\n end", "def index\n #@books = Book.all\n end", "def index\n books_with_isbn = Book.where(isbn: params[:search])\n if books_with_isbn.any? and not request.format.json?\n redirect_to books_with_isbn.first\n return\n else\n search\n @books = @books.first(params[:limit].to_i) if params[:limit]\n @query = params[:search]\n unless request.format.json?\n @books = @books.paginate(page: params['page'])\n end\n end\n respond_to do |format|\n format.html\n format.json { 'show' }\n end\n end", "def list\n @books = Book.all\n end", "def get_user_books_by_status(status)\n case status\n when \"Read\"\n user_books.where(status: \"Read\")\n when \"Checked Out\"\n user_books.where(status: \"Checked Out\")\n when \"Not Read\"\n user_books.where(status: \"Not Read\")\n end\n end", "def book\n @books=Book.all\n @book=Book.find(params[:id])\n end", "def index\n\t\t@choice = params[:choice]\n\t\n\t\tcase @choice\n\t\t\twhen \"mine\"\n\t\t\t\tbooks = @user.books.find(:all, :order => 'title')\n\t\t\twhen \"others\"\n\t\t\t\tbooks = Book.find(:all, :conditions => ['user_id != ?', @user.id], :joins => :users, :group => \"title\", :order => \"title\")\n\t\t\telse\n\t\t\t\tbooks = Book.find(:all, :order => \"title\")\n\t\tend\n\n\t\t@books = books.paginate :page => params[:page], :per_page => 10\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\tend\n\tend", "def set_book\n @book = Book.includes(:courses, :user).find(params[:id])\n end", "def index\n\n @books = Book.all\n\n end", "def index\n ##retrieve list of libraries available for dropdown\n @libraries = fetch_libraries\n @book_categories = fetch_categories \n\n ##Verify if viewing borrowed book or genral listing\n if !params[:is_mine].blank?\n @books = Book.where(user_id: current_user.id)\n @is_mine = true\n else \n @books = Book.where(is_borrowed: false).includes(:categories, :book_categories).limit(20)\n @is_mine = false\n end \n \n #Check whether Must search or not?\n if params[:keywords] != nil\n @keywords = params[:keywords]\n @books = @books.where(\"name like ?\", '%'+ params[:keywords]+ '%')\n end\n\n\n\n if params[:categories_id] != nil \n # params[:categories_id].shift\n puts params[:categories_id].size\n @selected_categories = params[:categories_id]\n @books = Book.includes(:categories).where(categories: {id: params[:categories_id]})\n # @books = @books.where({categories: params[:categories_id]})\n end\n\n #Filtering by libraries\n puts 'Filter by libraries'\n if !params[:library_id].blank?\n puts 'inside library filter'\n @current_library = params[:library_id]\n @books = @books.where({library_id: params[:library_id]}) \n end\n\n # @books = @books.paginate(page: params[:page], per_page: 4)\n \n end", "def index \n @filter = params[:filter] || \"order_by_title\"\n @books = Book.send(@filter) # Filter book index based on a filter param - default is order by title\n end", "def index\n user_type = session[:user_type]\n case user_type\n when ApplicationController::TYPE_STUDENT\n if (params[:library_id] != nil)\n @books = Book.fetch_books(params[:library_id])\n else\n # if parameter not specified, redirect to home page saying invalid request\n flash[:notice] = \"Please select a library to browse books\"\n redirect_to libraries_path\n end\n else\n @books = Book.fetch_books(nil)\n end\n end", "def index\n if params[:search]\n @lib_books = []\n @library.lib_books.each do |lib_book|\n @book = Book.find_by_id(lib_book.book_id)\n if params[:title] != \"\"\n next if !@book.title.downcase.include? params[:title].downcase\n end\n if params[:author] != \"\"\n next if !@book.author.downcase.include? params[:author].downcase\n end\n if params[:published] != \"\"\n next if !@book.published.to_s.eql? params[:published]\n end\n if params[:subject] != \"\"\n next if !@book.subject.downcase.include? params[:subject].downcase\n end\n @lib_books.push(lib_book)\n end\n else\n @lib_books = @library.lib_books\n end\n end", "def index\n @bookings = Booking.user(@user.id)\n end", "def index\n @items = Item.select { |item| item.user == current_user}\n @bookings = Booking.select { |booking| booking.user == current_user }\n end", "def index\n @book_items = BookItem.all\n end", "def index\n @book_items = BookItem.all\n end", "def index\n unless age_group\n @books = Book.all\n @user = current_user\n end\n end", "def search\n search_room = params[:room].reject {|key, value| value.empty? }\n if search_room.values.empty?\n sql_query = \"select * from rooms\"\n @rooms = Room.find_by_sql(sql_query)\n @bookings = Booking.all\n return @rooms,@bookings\n #redirect_to '/bookings'\n else\n sql_query = \"select * from rooms where \"\n i = 1\n #Formation of SQL Query to show matching users to the search criteria.\n search_room.each do |key, value|\n sql_query = sql_query + \"lower(#{key}) LIKE lower('%#{value}%')\"\n if(i < search_room.length)\n sql_query = sql_query + \" AND \"\n i += 1\n end\n end\n @bookings = Booking.all\n @rooms = Room.find_by_sql(sql_query)\n end\n return @rooms,@bookings\n end", "def index\n @author_books = AuthorBook.all\n end", "def index\n @books = Book.search params[:search]\n\n if @books.count == 0\n flash[:notice] = \"No books found, but you can submit a request. Do any of these match?\"\n @books = goodreads\n render 'goodreads.html.erb'\n end\n end", "def index\n @books = Book.all\n if current_user.role == 'librarian'\n listtype = params[:listtype]\n if listtype == 'available'\n @books = Book.where('libraries_id is null')\n else\n @books = Book.where('libraries_id = ?', current_user.libraries_id)\n end\n elsif current_user.role == 'student'\n library_list = Library.where('universities_id = ?', current_user.universities_id)\n puts library_list\n lib = library_list.map { |l|\n l.id\n }\n @books = Book.where('libraries_id is not null')\n @books.select { |book|\n if lib.include?(book.libraries_id)\n return true\n else\n return false\n end\n }\nend\n end", "def index\n @book_authors = BookAuthor.all\n end", "def index\n @authors_books = AuthorsBook.all\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index\n @borrowed_books = BorrowedBook.all\n end", "def index\n # AR query to get all books, save into instance variable\n @books = Book.all\n end", "def index\n @users = User.find(:all)\n for user in @users\n 1.upto(Book::CATALOG) {|number| book = Book.new\n book.user_id = user.id\n book.order = number\n if user.show?\n book.browse = true\n else\n if Book::FREE.include?(number)\n book.browse = true\n else\n book.browse = false\n end\n end\n book.save}\n\n end\n\n @books = Book.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @books }\n end\n end" ]
[ "0.77267224", "0.7700092", "0.7314274", "0.7282825", "0.7265026", "0.7227536", "0.7141748", "0.7081032", "0.70346326", "0.7011905", "0.6955906", "0.6936213", "0.68576485", "0.68146014", "0.6802825", "0.6778951", "0.6761304", "0.67419374", "0.672906", "0.6715157", "0.67139125", "0.67040086", "0.6679826", "0.6665933", "0.6656411", "0.6636697", "0.66163784", "0.65799254", "0.65785676", "0.65731007", "0.6561188", "0.65368867", "0.65208745", "0.6496832", "0.6493684", "0.64935195", "0.64734787", "0.64694566", "0.64624584", "0.64439964", "0.6416007", "0.64156514", "0.64131075", "0.63938075", "0.63897926", "0.63786596", "0.63785875", "0.6375078", "0.63698083", "0.63698083", "0.6366993", "0.6360789", "0.63547987", "0.6347805", "0.6335448", "0.63247377", "0.63221157", "0.63177043", "0.6308107", "0.6307096", "0.63065386", "0.6303578", "0.6300124", "0.62978554", "0.62946886", "0.6283537", "0.6269626", "0.6264376", "0.6264239", "0.6258153", "0.6257531", "0.6255422", "0.6246961", "0.6239649", "0.62325156", "0.6215044", "0.62134254", "0.620956", "0.6200953", "0.6193473", "0.61876386", "0.6186568", "0.6180454", "0.6176706", "0.61742604", "0.61701655", "0.61659306", "0.61659306", "0.6157057", "0.61476356", "0.61474574", "0.6145373", "0.6141008", "0.61325264", "0.6129024", "0.6119126", "0.6119126", "0.6119126", "0.61185735", "0.61181295" ]
0.6288276
65
Following method needs to be updated if multi environment params passed.
def environments=(env_params) env_params.each do |env_hash| next unless env_hash[:features] env_hash[:features].each do |feature_hash| self.features.build(feature_hash) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def env=(environment); end", "def env=(environment); end", "def environment(environment); end", "def configure_environment\n\n=begin\n :: Expected Params ::\n \n Constants::REQUEST_PARAM_TEST => Server Mode (Is Production or Staging?) \n\n=end \n\n if params[Constants::REQUEST_PARAM_TEST].present?\n\n if params[Constants::REQUEST_PARAM_TEST] == \"1\"\n\n ENV[Constants::ENVIRONMENT_VAR_FOR_STAGING] = '1'\n\n else\n \n ENV.delete(Constants::ENVIRONMENT_VAR_FOR_STAGING) \n\n end \n\n end \n\n render json: {status: status_code(:ok), message: \"\", data: {:is_staging => (ENV[Constants::ENVIRONMENT_VAR_FOR_STAGING].present? ? 1 : 0)}}\n\n end", "def updated_parameters(parameters, environment)\n return parameters unless environment\n\n parameters << Parameter.new(\"environment\", environment)\n end", "def update!(**args)\n @environments = args[:environments] if args.key?(:environments)\n end", "def _get_params_from_environment(*params)\n\t\tobject = {}\n\t\tparams.each do |param|\n\n\t\t\tkey = param\n\n\t\t\tif param.kind_of? Array\n\t\t\t\tkey = key[0]\n\t\t\tend\n\n\t\t\tobject[key] = ENV[key.to_s]\n\n\t\t\tif param.kind_of? Array\n\t\t\t\tobject[key] ||= param[1]\n\t\t\tend\n\t\tend\n\n\t\tobject\n\tend", "def env\n @env ||= env_with_params\nend", "def environments(*args)\n @environments = args.map{|arg| arg.to_sym }\n end", "def normalize_env(env, client); end", "def environment; end", "def enviroment_params\n p = params.require(:enviroment).permit(:title, :default_build_number, :repository_id, :branches_filter, :issue_tracker_id,\n :target_platforms_order, :tests_executor_id, :tests_enabled_by_default,\n :delete_build_jobs_older_than, :base_version_ids => [])\n p[:target_platforms_order] = JSON.parse p[:target_platforms_order]\n p\n end", "def environment_matchers=(_arg0); end", "def environments; end", "def with_environment(env); end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env; end", "def env_config; end", "def env_config; end", "def env_config; end", "def env_config; end", "def original_env; end", "def forward_local_env(env_variable_patterns); end", "def update\n old_env = Environment.find(params[:id])\n Machine.reset_env_lists unless old_env.agents == params[:environment][:agents] and\n old_env.name == params[:environment][:name]\n @lists = List.active\n want_delete = (params['delete'] == '1')\n if @environment.deleted_at.nil? == want_delete\n params[:environment]['deleted_at'] = params['delete'] ? Time.now : nil\n end\n params[:environment][:list_ids]=[] unless params[:environment][:list_ids]\n params[:environment][:name].strip! if params[:environment][:name]\n params[:environment][:rerun] ||= nil\n respond_to do |format|\n if @environment.update_attributes(params[:environment])\n flash[:notice] = \"Environment '#{@environment.name}' was successfully updated.\"\n format.html { redirect_to environments_path }\n # format.html { redirect_to (@environment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @environment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @environment = args[:environment] if args.key?(:environment)\n @quality = args[:quality] if args.key?(:quality)\n end", "def build_environment(env, env_yaml, platform)\n # substitute vcenter resources from vcenter.yml for location defined in environment file\n env_yaml['vcenter'] = platform.vcenter[env_yaml['vcenter']]\n # merge component resources from environment file and platform definition\n # platform info will be inserted where not found in env files, env overrides will be unchanged\n #\n # Note: this function does not do error checking for components that exist in env file but\n # not in Platform definition. Such files will be retained but not have any Platform\n # component info. The Build command will run error checking before building, but to support\n # the debugging value of the list command only hash.merge! is performed at this point.\n platform.components.each do |component, _config|\n env_yaml['components'][component].merge!(platform.components[component]) { |_key, v1, _v2| v1 } unless env_yaml['components'][component].nil?\n end\n # substitute network and components for specified values from platform definition files\n env_yaml['components'].each do |component, _config|\n env_yaml['components'][component]['network'] = platform.network[env_yaml['components'][component]['network']]\n env_yaml['components'][component]['compute'] = platform.compute[env_yaml['components'][component]['compute']]\n unless env_yaml['components'][component]['runlist'].nil?\n env_yaml['components'][component]['runlist'] = run_list(env_yaml['components'][component]['runlist'], env_yaml['components'][component]['componentrole'], component)\n end\n end\n unless env_yaml['vcenter'].nil?\n # append env name to destination folder if appendenv == true\n env_yaml['vcenter']['destfolder'] += (env_yaml['vcenter']['appendenv'] ? '/' + env.to_s : '')\n # prepend app name to domain if appenddomain == true\n env_yaml['vcenter']['appenddomain'] ? env_yaml['vcenter']['domain'] = '.' + platform.name + '.' + env_yaml['vcenter']['domain'] : ''\n end\n env_yaml\n end", "def apply_environment_overrides\n @format = env(:format, @format)\n @autopath = env(:autopath, @autopath)\n @files = env(:files, @files)\n @match = env(:match, @match)\n @tags = env(:tags, @tags)\n @units = env(:units, @units)\n @requires = env(:requires, @requires)\n @loadpath = env(:loadpath, @loadpath)\n end", "def environment *environments, &block\n old = @environments\n @environments = @environments.dup.concat environments.map { |e| e.to_s }\n\n instance_eval(&block)\n ensure\n @environments = old\n end", "def environment=(env)\n @environment = env\n end", "def environment_params\n params.require(:environment).permit(:name, :supervisor_name, :supervisor_email,\n :notify_supervisor)\n end", "def setEnvironment(e=:qa, url=nil)\n env={\n :qa => { :name => 'QA', :description => 'QA Env', :url => 'https://www.qa.com' },\n :qa2 => { :name => 'QA2', :description => 'QA2 Env', :url => 'https://www.qa2.com' },\n :prod => { :name => 'PROD', :description => 'CERT', :url => 'https://www.prod.com' }\n }\n\n\n if url.nil?\n @environment_under_test=env[e]\n else\n @environment_under_test={ :name => 'custom', :url => url.to_s }\n end\n\n\n end", "def apply_environment!(hook_context, env); end", "def process_environment(env)\n request_data = { \n :url => env['REQUEST_URI'],\n :ip_address => env['HTTP_X_FORWARDED_FOR'] ? env['HTTP_X_FORWARDED_FOR'] : env['REMOTE_ADDR']\n }\n request_data[:user] = env['HTTP_USER_EMAIL'] if env['HTTP_USER_EMAIL']\n\n env['rack.input'].rewind\n parameters = ''\n env['rack.input'].each { |line| parameters += line }\n request_data[:parameters] = parameters if parameters\n\n server_name = env[\"SERVER_NAME\"].split('.').first\n env_name = @email_options['environment_name'][server_name]\n\n { :environment_data => env.map { |l| \" * #{l}\" }.join(\"\\n\"),\n :request_data => request_data,\n :server_name => server_name,\n :env_name => env_name\n }\n end", "def set_remote_env(env); end", "def default_environment=(env); end", "def prepare_environment req_path, headers, params, body\n result = Hash.new\n {'header' => headers, 'param' => params}.each do |prefix, data|\n data.each do |name, value|\n result.merge! Oaf::Util.environment_item prefix, name, value\n end\n end\n result.merge! Oaf::Util.environment_item 'request', 'path', req_path\n result.merge Oaf::Util.environment_item 'request', 'body', body\n end", "def get_env(key)\n\n end", "def environment *environments, &block\n old = @environments.dup\n @environments.concat environments.map { |e| e.to_s }\n\n begin\n yield\n ensure\n @environments = old\n end\n end", "def static_env=(_arg0); end", "def static_env=(_arg0); end", "def static_env=(_arg0); end", "def _env_change\n if @env_used\n @environments << @env\n @env = Bcpm::Tests::Environment.new\n @env_used = false\n end\n end", "def filtered_env; end", "def environment\n verify_environment\n ENV['ENV']\nend", "def apply_environment_defaults\n @format = env(:format, @format) if @format.nil?\n @autopath = env(:autopath, @autopath) if @autopath.nil?\n @files = env(:files, @files) if @files.empty?\n @match = env(:match, @match) if @match.empty?\n @tags = env(:tags, @tags) if @tags.empty?\n @units = env(:units, @units) if @units.empty?\n @requires = env(:requires, @requires) if @requires.empty?\n @loadpath = env(:loadpath, @loadpath) if @loadpath.empty?\n end", "def get_parameters\n\t\t# get available envs\n\t\tSTDOUT.puts \"Enter environment to run tests on: (mwho, etc.): \"\n\t\tENV['environment']=STDIN.gets.strip.downcase\n\t\t# validate input\n\n\t\t# get available user permission levels for the env\n\t\tSTDOUT.puts \"Enter the permission level of the USER for this test: \"\n\t\tENV['permission']=STDIN.gets.strip.downcase\n\t\t# validate input\n\t\t\n\t\t# get available url permission levels for the env\n\t\tSTDOUT.puts \"Enter the permission level of the URLS for this test (all_defaults will be used if nothing is entered): \"\n\t\tENV['urls']=STDIN.gets.strip.downcase\n\t\t# validate input\n\t\tif ENV['urls'] == \"\" || ENV['urls'] == nil\n\t\t\tENV['urls'] = \"all_defaults\"\n\t\tend\n\tend", "def update!(**args)\n @environment = args[:environment] if args.key?(:environment)\n @max_run_duration = args[:max_run_duration] if args.key?(:max_run_duration)\n @runnables = args[:runnables] if args.key?(:runnables)\n end", "def construct_environment(envs)\n envs.each do |key, value|\n if value\n value = value.to_s\n value = nil if value.length == 0\n end\n ENV[key.to_s] = value\n end\nend", "def req_env_post_parse(env); end", "def myservices_environment_details_override?\n !ENV['ENV_DETAILS'].nil?\n end", "def setup_environment; end", "def initialize( location = 'stage', env_file = File.expand_path(\"#{__FILE__}/../../config/stage.sh\"))\n @location = location\n @env_file = env_file\n envfile_hash = process_env_file( env_file )\n #ENV explicit settings override values found in a locations config file\n @data = Hash[ SQA_ECOMM_SERVER_URL: ENV.fetch( 'SQA_ECOMM_SERVER_URL', envfile_hash['SQA_ECOMM_SERVER_URL'] ),\n SQA_ECOMM_API_SERVER_URL: ENV.fetch( 'SQA_ECOMM_API_SERVER_URL', envfile_hash['SQA_ECOMM_API_SERVER_URL'] ),\n SQA_ECOMM_DB_SERVER: ENV.fetch( 'SQA_ECOMM_DB_SERVER', envfile_hash['SQA_ECOMM_DB_SERVER'] ),\n SQA_ECOMM_DB: ENV.fetch( 'SQA_ECOMM_DB', envfile_hash['SQA_ECOMM_DB'] ),\n SQA_ECOMM_DB_UPDATE_USER: ENV.fetch( 'SQA_ECOMM_DB_UPDATE_USER', envfile_hash['SQA_ECOMM_DB_UPDATE_USER'] ),\n SQA_ECOMM_DB_UPDATE_PW: ENV.fetch( 'SQA_ECOMM_DB_UPDATE_PW', envfile_hash['SQA_ECOMM_DB_UPDATE_PW'] ),\n SQA_ECOMM_DB_READONLY_USER: ENV.fetch( 'SQA_ECOMM_DB_READONLY_USER', envfile_hash['SQA_ECOMM_DB_READONLY_USER'] ),\n SQA_ECOMM_DB_READONLY_PW: ENV.fetch( 'SQA_ECOMM_DB_READONLY_PW', envfile_hash['SQA_ECOMM_DB_READONLY_PW'] ),\n SQA_ORACLE_DB_SERVER: ENV.fetch( 'SQA_ORACLE_DB_SERVER', envfile_hash['SQA_ORACLE_DB_SERVER'] ),\n SQA_ORACLE_DB_UPDATE_USER: ENV.fetch( 'SQA_ORACLE_DB_UPDATE_USER', envfile_hash['SQA_ORACLE_DB_UPDATE_USER'] ),\n SQA_ORACLE_DB_UPDATE_PW: ENV.fetch( 'SQA_ORACLE_DB_UPDATE_PW', envfile_hash['SQA_ORACLE_DB_UPDATE_PW'] ),\n SQA_ORACLE_DB_READONLY_USER: ENV.fetch( 'SQA_ORACLE_DB_READONLY_USER', envfile_hash['SQA_ORACLE_DB_READONLY_USER'] ),\n SQA_ORACLE_DB_READONLY_PW: ENV.fetch( 'SQA_ORACLE_DB_READONLY_PW', envfile_hash['SQA_ORACLE_DB_READONLY_PW'] ),\n SQA_HJ_DB_SERVER: ENV.fetch( 'SQA_HJ_DB_SERVER', envfile_hash['SQA_HJ_DB_SERVER'] ),\n SQA_HJ_DB: ENV.fetch( 'SQA_HJ_DB', envfile_hash['SQA_HJ_DB'] ),\n SQA_HJ_DB_UPDATE_USER: ENV.fetch( 'SQA_HJ_DB_UPDATE_USER', envfile_hash['SQA_HJ_DB_UPDATE_USER'] ),\n SQA_HJ_DB_UPDATE_PW: ENV.fetch( 'SQA_HJ_DB_UPDATE_PW', envfile_hash['SQA_HJ_DB_UPDATE_PW'] ),\n SQA_HJ_DB_READONLY_USER: ENV.fetch( 'SQA_HJ_DB_READONLY_USER', envfile_hash['SQA_HJ_DB_READONLY_USER'] ),\n SQA_HJ_DB_READONLY_PW: ENV.fetch( 'SQA_HJ_DB_READONLY_PW', envfile_hash['SQA_HJ_DB_READONLY_PW'] ),\n SQA_RUDI_SERVER: ENV.fetch( 'SQA_RUDI_SERVER', envfile_hash['SQA_RUDI_SERVER'] ),\n SQA_RUDI_VERSION: ENV.fetch( 'SQA_RUDI_VERSION', envfile_hash['SQA_RUDI_VERSION'] ),\n SQA_UNIBLAB_SERVER: ENV.fetch( 'SQA_UNIBLAB_SERVER', envfile_hash['SQA_UNIBLAB_SERVER'] ),\n SQA_UNIBLAB_VERSION: ENV.fetch( 'SQA_UNIBLAB_VERSION', envfile_hash['SQA_UNIBLAB_VERSION'] ) ]\n end", "def build_env(connection, request); end", "def execution_environment_params\n params.require(:execution_environment).permit(:language, :version)\n end", "def environment_params\n params.require(:environment).permit(\n :name, :k8s_master,\n :k8s_username, :k8s_password\n )\n end", "def env(signature, environment)\n if signature.is_a?(Array)\n signature.each { |s| env(s, environment) }\n return self\n end\n @environments[signature] = environment\n self\n end", "def parameters(arg=nil)\n return environment if arg.nil?\n\n # parameters is really a duplication of the environment hash from\n # the ExecuteResource, so merge the two hashes, if necessary. it seems\n # valid to continue to distinguish symantically between parameters and\n # environment because the user does not necessarily need to know that\n # they are implemented to be the same hash.\n env = environment\n if env.nil?\n env = arg\n else\n env.merge!(arg)\n end\n environment(env)\n @parameters = @environment\n end", "def environment=(environ)\n\n @environment = environ.to_sym\n\n end", "def load_envvars\n Pkg::Params::ENV_VARS.each do |v|\n if var = ENV[v[:envvar].to_s]\n case v[:type]\n when :bool\n self.instance_variable_set(\"@#{v[:var]}\", Pkg::Util.boolean_value(var))\n when :array\n self.instance_variable_set(\"@#{v[:var]}\", string_to_array(var))\n else\n self.instance_variable_set(\"@#{v[:var]}\", var)\n end\n end\n end\n end", "def initialize_environment\n end", "def initialize_environment\n end", "def update!(**args)\n @app_capabilities = args[:app_capabilities] if args.key?(:app_capabilities)\n @app_capabilities_delta = args[:app_capabilities_delta] if args.key?(:app_capabilities_delta)\n @app_integrations_settings = args[:app_integrations_settings] if args.key?(:app_integrations_settings)\n @car_assistant_capabilities = args[:car_assistant_capabilities] if args.key?(:car_assistant_capabilities)\n @clock_capabilities = args[:clock_capabilities] if args.key?(:clock_capabilities)\n @conversation_version = args[:conversation_version] if args.key?(:conversation_version)\n @cross_device_execution_capabilities = args[:cross_device_execution_capabilities] if args.key?(:cross_device_execution_capabilities)\n @gacs_capabilities = args[:gacs_capabilities] if args.key?(:gacs_capabilities)\n @gcm_capabilities = args[:gcm_capabilities] if args.key?(:gcm_capabilities)\n @home_app_capabilities = args[:home_app_capabilities] if args.key?(:home_app_capabilities)\n @live_tv_channel_capabilities = args[:live_tv_channel_capabilities] if args.key?(:live_tv_channel_capabilities)\n @oem_capabilities = args[:oem_capabilities] if args.key?(:oem_capabilities)\n @on_device_assistant_capabilities = args[:on_device_assistant_capabilities] if args.key?(:on_device_assistant_capabilities)\n @on_device_smart_home_capabilities = args[:on_device_smart_home_capabilities] if args.key?(:on_device_smart_home_capabilities)\n @on_device_storage_capabilities = args[:on_device_storage_capabilities] if args.key?(:on_device_storage_capabilities)\n @operating_system = args[:operating_system] if args.key?(:operating_system)\n @ordered_live_tv_providers = args[:ordered_live_tv_providers] if args.key?(:ordered_live_tv_providers)\n @selina_capabilities = args[:selina_capabilities] if args.key?(:selina_capabilities)\n @settings_app_capabilities = args[:settings_app_capabilities] if args.key?(:settings_app_capabilities)\n @supported_client_op = args[:supported_client_op] if args.key?(:supported_client_op)\n @supported_features = args[:supported_features] if args.key?(:supported_features)\n @supported_msg_version = args[:supported_msg_version] if args.key?(:supported_msg_version)\n @supported_provider_types = args[:supported_provider_types] if args.key?(:supported_provider_types)\n @surface_properties = args[:surface_properties] if args.key?(:surface_properties)\n end", "def extract_environment_variables! #:nodoc:\n args.delete_if do |arg|\n next unless arg.match(/^(\\w+)=(.*)$/)\n ENV[$1] = $2\n end\n end", "def enableEnvironment _args\n \"enableEnvironment _args;\" \n end", "def canvas_environments!(params = {})\n set_canvas_ext_param(:environments, params)\n end", "def setup_env_params\n {\n url: @request.respond_to?(:original_url) ? @request.original_url : @request.path_info,\n referrer: @request.referer,\n http_method: action_dispatch? ? @request.method : @request.request_method,\n ip_address: @request.respond_to?(:remote_ip) ? @request.remote_ip : @request.ip,\n user_agent: @request.user_agent\n }\n end", "def require_env(*args)\n args.each do |arg|\n env_var = \"#{arg}\".upcase\n if ENV[env_var]\n instance_variable_set(\"@#{env_var.downcase}\", ENV[env_var])\n else\n puts \"You need to provide the ENV variable '#{env_var}'\"\n exit 1\n end\n end\n end", "def process(env); end", "def environment\n return @vars unless @vars.nil?\n\n # If not set, Try to find them...\n glob_path = File.join(@deployment_home, @settings.env_file_glob_path)\n regexp_find = glob_path.gsub(/\\*/, '(.*)')\n Dir[glob_path].each do | file_name |\n # Get the environment name from the file part of the glob path:\n # e.g. given ./environments/ci_mgt/kb8or.yaml\n # get ci_mgt from ./environments/*/kb8or.yaml\n /#{regexp_find}/.match(file_name)\n env_name = $1\n if env_name == @env_name\n debug \"env=#{env_name}\"\n # Ensure we set the defaults as vars BEFORE we add environment specifics:\n @vars = @settings.defaults\n env_vars = Context.resolve_env_file(file_name)\n @vars = @vars.merge(env_vars)\n @vars = @vars.merge(@overridden_vars)\n @vars['env'] = env_name\n @environment_file = file_name\n break\n end\n end\n # Now finaly, update the settings now we know the environment!\n unless @vars\n @vars = {}\n end\n @settings = @settings.new(@vars)\n update_k8context\n debug \"vars=#{vars}\"\n @vars\n end", "def check_and_set_environment\n check_env\n set_env\n end", "def env\n super.merge(hacked_env)\n end", "def env\n env = job[:env]\n env = env - (config[:env].is_a?(Hash) && config[:env][:global] || []) if env\n env = env - config[:global_env] if config[:global_env].is_a?(Array)\n env\n end", "def params\n @env.params\n end", "def environment=(env)\n self.config[:environment] = env.to_sym\n end", "def merge_vm_parameters(host, global, vb)\n # These are arrays of hashes\n if global['vm_options'] or host['vm_options']\n merge_hash = merge_2_array_of_hashes(global['vm_options'], host['vm_options'])\n merge_hash.each do |key, value|\n vb.customize [\"modifyvm\", :id, \"--#{key}\", value]\n end\n end\nend", "def update_environment &block\n\n # get environment data from request body\n # if data could not be parsed, return with error\n\n parsed_environment = parse_body\n\n unless parsed_environment\n block.call( { :status => 400 } )\n return\n end\n\n @environment.merge!( parsed_environment )\n\n puts \"environment update for client #{uuid}: #{environment.inspect}\"\n\n # pass request to grouper\n \n em_put( \"/clients/#{uuid}/environment\", @environment.to_json ) do |response|\n block.call( response )\n begin\n content = JSON.parse( response[:content] )\n rescue\n content = { \"group\" => [] }\n end\n\n # for all clients in the same group (as returned by the grouper): update group info (if client is peeking)\n\n ids = content[\"group\"].map { |info| info[\"client_uuid\"] }\n\n puts \"updated clients after environment update for client #{uuid}: #{ids.inspect}\"\n\n Client.find_all_by_uuids( ids ).each do |client|\n group = Group.new(content['group'])\n client.update_grouped( group ) if client\n end\n end\n end", "def environment=(env)\n setup(env)\n end", "def setup_profiled(**args)\n super(**args)\n default_env_vars.each do |key, value|\n set_env_default key, value\n end\n end", "def env_from_parameters parameters, key_prefix=\"hookhand\"\n env = {}\n parameters.each do |key, value|\n if key.is_a? Enumerable\n env.merge! env_from_parameters(key, key_prefix)\n next\n end\n\n env_key = \"#{key_prefix.upcase}_#{key.to_s.upcase}\"\n if value.is_a? Enumerable\n env.merge! env_from_parameters(value, env_key)\n else\n env[env_key] = value.to_s\n end\n end\n env\n end", "def update(env=:all)\n []\n end" ]
[ "0.6749182", "0.6749182", "0.66758347", "0.6647997", "0.6559945", "0.6551102", "0.65333503", "0.63848424", "0.62014043", "0.6117982", "0.6091886", "0.60169446", "0.6010893", "0.6009778", "0.59973156", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.596351", "0.596351", "0.596351", "0.596351", "0.5960428", "0.5936738", "0.5923086", "0.5867888", "0.5859062", "0.5839394", "0.5828097", "0.5815438", "0.5813315", "0.5799032", "0.5798726", "0.5798264", "0.57980406", "0.5771317", "0.57627803", "0.5747469", "0.57465893", "0.57397455", "0.57397455", "0.57397455", "0.57339", "0.5726407", "0.5722012", "0.57149017", "0.57037276", "0.57027894", "0.5702332", "0.5686343", "0.56821674", "0.5680543", "0.5670475", "0.5655411", "0.56530786", "0.56271785", "0.5613754", "0.5603012", "0.56002975", "0.5584635", "0.55840045", "0.55840045", "0.5582851", "0.55753815", "0.5572654", "0.55653346", "0.5553877", "0.5553298", "0.5537819", "0.5519661", "0.55145097", "0.5511587", "0.5509329", "0.5500196", "0.5495167", "0.549235", "0.5489081", "0.5480723", "0.5480662", "0.5479255", "0.547742" ]
0.6269189
8
Determines the public IP address of the running AWS instance
def determine_public_ip # 169.254.169.254 is the address of the AWS instance metadata service # See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html `curl --silent -XGET http://169.254.169.254/latest/meta-data/public-ipv4` end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_aws_ip(n)\n if node['analytics-cluster']['aws']['use_private_ip_for_ssh']\n n['ec2']['local_ipv4']\n else\n n['ec2']['public_ipv4']\n end\n end", "def get_aws_ip(n)\n if node['delivery-cluster']['aws']['use_private_ip_for_ssh']\n n['ec2']['local_ipv4']\n else\n n['ec2']['public_ipv4']\n end\n end", "def public_ip\n @public_ip ||= ssh.exec!(\"curl -s ip.appspot.com\").chomp\n end", "def get_public_ip\n case host_hash[:hypervisor]\n when /^(ec2|openstack)$/\n if self[:hypervisor] == 'ec2' && self[:instance]\n return self[:instance].ip_address\n elsif self[:hypervisor] == 'openstack' && self[:ip]\n return self[:ip]\n elsif self.instance_of?(Windows::Host)\n # In the case of using ec2 instances with the --no-provision flag, the ec2\n # instance object does not exist and we should just use the curl endpoint\n # specified here:\n # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html\n execute(\"wget http://169.254.169.254/latest/meta-data/public-ipv4\").strip\n else\n execute(\"curl http://169.254.169.254/latest/meta-data/public-ipv4\").strip\n end\n end\n end", "def get_access_ip\n if @aws_instance_data.public_ip_address\n return @aws_instance_data.public_ip_address\n end\n\n @aws_instance_data.private_ip_address\n end", "def public_ip_address\n public_ip_addresses.first\n end", "def public_ipv4\n return ec2_meta_data('public-ipv4')\n end", "def public_ip\n get('tools/public_ip').body['ipv4'] || get('tools/public_ip').body['ipv6']\n end", "def public_ip_of(server)\n server[:cloud][:public_ips].first rescue server[:ipaddress]\n end", "def public_ip_address\n data[:public_ip_address]\n end", "def ipaddress(node)\n @use_private_ip_for_ssh ? node['ec2']['local_ipv4'] : node['ec2']['public_ipv4']\n end", "def public_ip() ; info[:public_ip] ; end", "def public_ip\n # For AWS and OpenStack, the elastic IP is the public IP\n # For vSphere and vCloud, the static_ip is the public IP\n @spec['properties']['vip'] || static_ip\n end", "def get_public_ip_address\n rpc_get_fact_direct('public_ip')\n end", "def get_public_ip()\n return open('http://ipinfo.io/ip').read.chomp\n end", "def aws_get_ip (method = :internal, type = :public)\n # allowed methods: :internal (check meta-data inside VM), :aws (ask API)\n # allowed types: :public, :private\n self.aws_describe_instance\n\n if method.equal?(:internal)\n key = type.equal?(:public) ? 'public-ipv4' : 'local-ipv4'\n murl = sprintf('http://169.254.169.254/latest/meta-data/%s', key)\n result = self.aws_get_url(murl)\n else\n key = type.equal?(:public) ? 'ipAddress' : 'privateIpAddress'\n result = @instance_data[key]\n end\n\n result\n end", "def acquire_ip_address\n unless public_ip = provider.provision_public_ip_address(vpc: vpc?)\n say \"Unable to acquire a public IP. Please check your account for capacity or service issues.\".red\n exit 1\n end\n public_ip\n end", "def get_public_ip_address\n get_proxy.get_public_ip_address\n end", "def hostip\n static_network_config[\"ipAddress\"]\n end", "def address(public_ip)\n addresses(public_ip)[0]\n end", "def server_get_public_ip(server_name)\n public_ip = ''\n if server_exist?(server_name)\n server = find_match(@compute.servers, server_name)\n network_name = server.addresses.keys.reduce\n server.addresses.each do |address|\n if (address.include? network_name and address.length == 2) #TODO: research why is this 'private' for a public ip?\n if address[1].length >= 2\n Puppet.debug \"found floating ip = #{address[1][1].inspect}\"\n public_ip = address[1][1].addr\n end\n end\n end\n end\n return public_ip\n end", "def public_ip_v4_address; end", "def private_ip_address\n private_ip_addresses.first\n end", "def aws_instance_elastic_ip_get(opts)\n opts[:instance].elastic_ip\n end", "def get_ip_address(machine)\n ip = nil\n unless @rs.ignore_private_ip\n machine.config.vm.networks.each do |network|\n key, options = network[0], network[1]\n ip = options[:ip] if key == :private_network\n next if ip\n end\n end\n\n ip || machine.ssh_info[:host]\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 local_ipv4\n return ec2_meta_data('local-ipv4')\n end", "def public_ipv4\n local_ipv4 - localhost_ipv4\n end", "def instance_external_ip(instance_id)\n return nil unless instance_id && !instance_id.empty?\n capistrano.logger.info(\"Getting Vagrant instance external IP\")\n get_ips_cmd = \"'ifconfig | awk \\\"/inet addr/{print substr(\\\\$2,6)}\\\"'\"\n run_vagrant_command('ssh', instance_id, \"-c #{get_ips_cmd} 2> /dev/null\") do |ips|\n ips = ips.split(/\\r?\\n/) # split on CRLF or LF\n if ips.empty?\n capistrano.logger.error(\"Unable to retrieve IP addresses from Vagrant instance\")\n nil\n else\n original_ips = ips.dup\n ips.delete_if { |x| /^127\\./.match(x) } # Delete the loopback address\n ips.delete_if { |x| /^192\\.168\\.12/.match(x) } # Delete the internally assigned Vagrant address: 192.168.12X.X\n if ips.empty?\n capistrano.logger.error(\"Vagrant instance doesn't appear to have an external IP address. IPs found are: #{original_ips.join(', ')}\")\n nil\n else\n capistrano.logger.info(\"The vagrant instance 'external' IP is #{ips.first}\")\n ips.first\n end\n end\n end\n end", "def ip\n TestLab::Utility.ip(self.address)\n end", "def ip\n # Get its IP that could have changed upon restart\n # cf https://github.com/moby/moby/issues/2801\n # Make sure we refresh its info before querying it, as we could hit a cache of a previous IP.\n _exit_status, stdout, _stderr = @cmd_runner.run_cmd \"#{podman_cmd} container inspect #{@container} | grep IPAddress\"\n stdout.strip.match(/\\d+\\.\\d+\\.\\d+\\.\\d+/)[0]\n end", "def ip\n TestLab::Utility.ip(self.address)\n end", "def ip\n self['ip'] = get_public_ip || get_ip\n end", "def ip_address\n Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address\n end", "def describe_addresses_for_instance(ec2_client, instance_id)\n response = ec2_client.describe_addresses(\n filters: [\n {\n name: \"instance-id\",\n values: [instance_id]\n }\n ]\n )\n addresses = response.addresses\n if addresses.count.zero?\n puts \"No addresses.\"\n else\n addresses.each do |address|\n puts \"-\" * 20\n puts \"Public IP: #{address.public_ip}\"\n puts \"Private IP: #{address.private_ip_address}\"\n end\n end\nrescue StandardError => e\n puts \"Error getting address information for instance: #{e.message}\"\nend", "def ip\n container.json['NetworkSettings']['IPAddress'] || 'N/A'\n rescue NoMethodError\n 'N/A'\n end", "def ip\n if ifconfig =~ /inet addr:([0-9.]+)/\n $1\n else\n \"0.0.0.0\"\n end\n end", "def ip_address(env)\n ip_address_record(env)[:address]\n end", "def ipaddress\n config[\"ipaddress\"]\n end", "def ip\n @ip ||= Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address\n end", "def get_ip(node)\n provisioning.ipaddress(node)\n end", "def with_public_ip_on_launch?\n @subnet.map_public_ip_on_launch\n end", "def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end", "def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end", "def get_tester_ip_addr\n if File.exists?(\"/var/spool/ec2/meta-data.rb\")\n require \"/var/spool/ec2/meta-data-cache\" \n else\n ENV['EC2_PUBLIC_HOSTNAME'] = \"127.0.0.1\"\n end\n my_ip_input = \"text:\" \n my_ip_input += ENV['EC2_PUBLIC_HOSTNAME']\n my_ip_input\n end", "def remote_ip\n if request.remote_ip == '127.0.0.1'\n # Hard coded remote address\n '18.228.1.115'\n else\n request.remote_ip\n end\n end", "def listIPs\n MU::Cloud::AWS::Server.getAddresses(cloud_desc).first\n end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def remote_ip; end", "def ip\n ssh.exec!(\"/sbin/ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'\").chomp\n end", "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 get_ip_address\n rpc_get_fact_direct('host_ip')\n end", "def get_ipaddress(asset_tag=asset_tag, pool)\n @connection.ipaddress_allocate!(asset_tag, pool, count = 1)\n end", "def host\n @host ||= 'ec2.amazonaws.com'\n end", "def get_nat_ip\n puts \"Getting NAT address\"\n\n # Get first instance with \"nat\" role\n instance = instances_for_role(\"nat\").first[:instances].first\n # Grab the interface that has source_dest_check set to false (most likely interface)\n primary = instance[:network_interfaces].select { |x| x[:source_dest_check] == false }.first\n nat = \"ec2-user@#{primary[:association][:public_ip]}\"\n\n puts \" - #{nat}\"\n nat\n end", "def instance_ips(instance_id)\n # If we get an Unauthorized error, it could mean that the OpenStack auth token has expired, so we are\n # going renew the fog connection one time to make sure that we get a new non-expired token.\n retried = false\n begin\n instance = openstack.servers.find { |s| s.name == instance_id }\n rescue Excon::Errors::Unauthorized => e\n unless retried\n retried = true\n @openstack = nil\n retry\n end\n raise ConnectionError, \"Unable to connect to OpenStack API: #{e.message}\"\n end\n raise InstanceNotFound, \"Instance '#{instance_id}' not found\" unless instance\n return instance.ip_addresses\n end", "def get_ip_address\n request.remote_ip\n end", "def private_ip_address\n data[:private_ip_address]\n end", "def private_ip_address\n data[:private_ip_address]\n end", "def ip\n unless @vm\n warn 'No Vm assigned to locate IP'\n return\n end\n @ip ||= detect_ip\n end", "def private_ip_of(server)\n server[:cloud][:private_ips].first rescue server[:ipaddress]\n end", "def public_hostname_of(server)\n server[:cloud][:public_hostname] rescue public_ip_of(server)\n end", "def my_instance_id\n Net::HTTP.get(URI('http://169.254.169.254/1.0/meta-data/instance-id'))\n end", "def aws_instance_elastic_ip_create(instance)\n log \"AWS: creating ElasticIP for Instance '#{instance.id}'\"\n # get elastic ip object\n elastic_ip = aws_call('aws_elastic_ip_create')\n log \"AWS: created ElasticIP '#{elastic_ip.public_ip}'\"\n\n # this is interesting, perhaps elastic ips dont have statuses like other resources, or else why not use our helper fn?\n log \"AWS: waiting for ElasticIP '#{elastic_ip.public_ip}' to exist\"\n Timeout.timeout(360) { sleep 1 while not aws_call('aws_obj_exists?', obj: elastic_ip) }\n\n # give our NAT vm its elastic IP!\n log \"AWS: associating ElastipIP '#{elastic_ip.public_ip}' with Instance '#{instance.id}'\"\n aws_call(\n 'aws_instance_elastic_ip_associate',\n instance: instance,\n elastic_ip: elastic_ip,\n errs: { AWS::EC2::Errors::InvalidAllocationID::NotFound => 60 }\n )\n \n # update ip_address_public attribute\n self.update_attribute(:ip_address_public, elastic_ip.public_ip)\n end", "def get_ip_address \t\t\t\n\t\trequest.remote_ip \n\tend", "def ip\n @vps.ip \n end", "def local_ip_address\n conf['base_address'] ||\n %x{ip addr show #{conf['base_interface'] || 'br0'} | grep inet}.split(' ')[1].to_s.strip.split('/').first.to_s\nend", "def ip_address\n nil\n end", "def ip_address\n # Does not work for now as the vmx path is not escape correctly by fission 0.4.0\n #return raw.network_info.data.first['ip_address']\n raise ::Fission::Error,\"VM #{name} does not exist\" unless self.exists?\n \n # Use alternate method to retrieve the IP address using vmrun readVariable\n \n ip_address = shell_exec(\"vmrun readVariable \\\"#{vmx_file_path}\\\" guestVar ip\", { :mute => true})\n return ip_address.stdout.strip\n \n # unless mac_address.nil?\n # lease = Fission::Lease.find_by_mac_address(mac_address).data\n # return lease.ip_address unless lease.nil?\n # return nil\n # else\n # # No mac address was found for this machine so we can't calculate the ip-address\n # return nil\n # end\n end", "def get_external_ip_address\r\n return debug('No WAN Service') unless @wan_service\r\n hash = send_action(@wan_service, 'GetExternalIPAddress', {})\r\n return hash if(hash[:is_error])\r\n return nil unless(hash[:has_xml])\r\n return hash[:xml].get_text('NewExternalIPAddress')\r\n end", "def obtain_ip_from_rails(env)\n env[\"action_dispatch.remote_ip\"].try(:to_s)\n end", "def pod_ip\n return @pod_ip\n end", "def localIP\r\n @@local_ip_address\r\n end", "def name\n ip_address\n end", "def public_ips\n filter_nics_and_return_ips {|nic| nic.internet_access == true }\n end", "def private_ip_v4_address; end", "def canonicalIP\n mu_name, config, deploydata = describe(cloud_id: @cloud_id)\n\n instance = cloud_desc\n\n if !instance\n raise MuError, \"Couldn't retrieve cloud descriptor for server #{self}\"\n end\n\n if deploydata.nil? or\n (!deploydata.has_key?(\"private_ip_address\") and\n !deploydata.has_key?(\"public_ip_address\"))\n return nil if instance.nil?\n @deploydata = {} if @deploydata.nil?\n @deploydata[\"public_ip_address\"] = instance.public_ip_address\n @deploydata[\"public_dns_name\"] = instance.public_dns_name\n @deploydata[\"private_ip_address\"] = instance.private_ip_address\n @deploydata[\"private_dns_name\"] = instance.private_dns_name\n\n notify\n end\n\n # Our deploydata gets corrupted often with server pools, this will cause us to use the wrong IP to identify a node\n # which will cause us to create certificates, DNS records and other artifacts with incorrect information which will cause our deploy to fail.\n # The cloud_id is always correct so lets use 'cloud_desc' to get the correct IPs\n if MU::Cloud::AWS::VPC.haveRouteToInstance?(cloud_desc, region: @config['region'], credentials: @config['credentials']) or @deploydata[\"public_ip_address\"].nil?\n @config['canonical_ip'] = instance.private_ip_address\n @deploydata[\"private_ip_address\"] = instance.private_ip_address\n return instance.private_ip_address\n else\n @config['canonical_ip'] = instance.public_ip_address\n @deploydata[\"public_ip_address\"] = instance.public_ip_address\n return instance.public_ip_address\n end\n end", "def member_get_ip(pool_member)\n server_ip = begin\n if pool_member.attribute?('cloud')\n if node.attribute?('cloud') && (pool_member['cloud']['provider'] == node['cloud']['provider'])\n pool_member['cloud']['local_ipv4']\n else\n pool_member['cloud']['public_ipv4']\n end\n else\n pool_member['ipaddress']\n end\n end\n server_ip\nend", "def list_instance_ip(compartment_id, instance_id)\n vcnapi = OracleBMC::Core::VirtualNetworkClient.new\n opts = { instance_id: instance_id }\n api = OracleBMC::Core::ComputeClient.new\n vnics = api.list_vnic_attachments(compartment_id, opts)\n network = vcnapi.get_vnic(vnics.data[0].vnic_id)\n return network.data.private_ip, network.data.public_ip\n end", "def public_ips\n hwaddr = self.hwaddr\n Hash[\n Meta.connection do\n Meta.interface(hwaddr, 'ipv4-associations/', not_found: '', cache: false).lines.map do |public_ip|\n public_ip.strip!\n unless private_ip = Meta.interface(hwaddr, \"ipv4-associations/#{public_ip}\", not_found: nil, cache: false)\n raise Errors::MetaBadResponse\n end\n [ private_ip, public_ip ]\n end\n end\n ]\n end", "def ip\n self.IP\n end", "def retrieve_public_ipv4(public_hostname)\n ns = ::File.read(::File.expand_path(::File.join('etc', 'resolv.conf'),'/')).\n split(\"\\n\").\n grep(/^\\s*nameserver/).\n first.\n split.\n fetch(1) || nil\n return nil unless ns\n resolver = Resolv::DNS.new(:nameserver => ns)\n resolver.getaddress(public_hostname).to_s\nrescue\n nil\nend", "def libvirt_vm_ip(name)\n mac = `sudo virsh domiflist #{name} | tail -n +3 | tr -s \" \" | cut -f 5 -d \" \"`.strip\n address = `arp | grep -i #{mac} | cut -f1 -d \" \"`.chomp\n { address: address, port: SSH_PORT }\n end", "def get_public_ipv4\n # Socket.ip_address_list.detect{|intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? and intf.ipv4_private?}\n Socket.ip_address_list.detect{|intf| intf.ipv4_private?}\nend", "def ip\n if (ip = @host.at('tag[name=host-ip]'))\n ip.inner_text\n end\n end", "def eip\n @eip ||= EC2.find_eip(interface.id)\n end", "def read_machine_ip(machine)\n machine.config.vm.networks.each do |type, options|\n if type == :private_network && options[:ip].is_a?(String)\n return options[:ip]\n end\n end\n\n nil\n end", "def get_internal_ip_address\r\n sock = UDPSocket.new\r\n sock.connect('1.0.0.1', 1) #@igd_location.split('//').last.split('/').first.split(':').first\r\n return sock.addr.last\r\n rescue Exception\r\n return \"127.0.0.1\"\r\n end", "def server_ip_address\n $tracer.trace(__method__)\n begin\n return meta.name(\"WT.sv\").content.strip\n rescue\n return \"Unknown IP Address\"\n end\n end", "def ip_address\n @ip_address ||= nil\n end", "def name\n ip_address\n end", "def public_addresses\n @public_addresses ||= Hash[addresses.map { |addr| [addr.public_ip, addr] }]\n end", "def get_server_public_ip(server, cached_rules=nil)\n return nil unless server\n\n # find the public ip\n nic = get_server_default_nic(server) || {}\n if nic['type'] == 'Virtual'\n ssh_rule = get_ssh_port_forwarding_rule(server, cached_rules)\n ssh_rule ? ssh_rule['ipaddress'] : nil\n else\n nic['ipaddress']\n end\n end", "def local_ip\n\nend", "def canonicalIP\n describe(cloud_id: @cloud_id)\n\n if !cloud_desc\n raise MuError, \"Couldn't retrieve cloud descriptor for server #{self}\"\n end\n\n private_ips = []\n public_ips = []\n\n cloud_desc.network_interfaces.each { |iface|\n private_ips << iface.network_ip\n if iface.access_configs\n iface.access_configs.each { |acfg|\n public_ips << acfg.nat_ip if acfg.nat_ip\n }\n end\n }\n\n # Our deploydata gets corrupted often with server pools, this will cause us to use the wrong IP to identify a node\n # which will cause us to create certificates, DNS records and other artifacts with incorrect information which will cause our deploy to fail.\n # The cloud_id is always correct so lets use 'cloud_desc' to get the correct IPs\n if MU::Cloud.resourceClass(\"Google\", \"VPC\").haveRouteToInstance?(cloud_desc, credentials: @config['credentials']) or public_ips.size == 0\n @config['canonical_ip'] = private_ips.first\n return private_ips.first\n else\n @config['canonical_ip'] = public_ips.first\n return public_ips.first\n end\n end" ]
[ "0.8188898", "0.80910486", "0.80247253", "0.80016977", "0.79642713", "0.7935058", "0.77813494", "0.77796614", "0.7759515", "0.7752921", "0.77118146", "0.7660461", "0.7611136", "0.7594755", "0.7531203", "0.7402093", "0.7347458", "0.72919375", "0.7099349", "0.70677626", "0.70609796", "0.69843256", "0.6943913", "0.6894272", "0.686945", "0.6865772", "0.6837803", "0.6818086", "0.679372", "0.6773826", "0.6741097", "0.66720515", "0.66622597", "0.6657145", "0.6652426", "0.66462815", "0.6604448", "0.65929353", "0.65774906", "0.6569748", "0.6552558", "0.6542424", "0.65274143", "0.65274143", "0.6515947", "0.65034294", "0.65021354", "0.6498692", "0.6498692", "0.6498692", "0.6498692", "0.6498692", "0.6498692", "0.6496008", "0.6481781", "0.6472513", "0.6472342", "0.646942", "0.6431289", "0.643059", "0.6422786", "0.6415645", "0.6391943", "0.6391943", "0.63769394", "0.6375024", "0.6337623", "0.6335819", "0.630567", "0.62867147", "0.62801826", "0.6255668", "0.6255636", "0.62523526", "0.6245229", "0.6241883", "0.6233008", "0.623226", "0.622909", "0.6220432", "0.62196827", "0.6216285", "0.6200017", "0.6194845", "0.6192244", "0.6183281", "0.61822295", "0.6158897", "0.61584514", "0.61530346", "0.6140005", "0.61340696", "0.6132093", "0.6129089", "0.61231905", "0.612265", "0.61165375", "0.6113434", "0.60892326", "0.6076518" ]
0.9010124
0
Determines the external port of the running Docker container that's associated with the port given
def determine_public_port(local_port) port = 0 count = 0 max_attempts = 30 # Give up after 30 seconds while port == 0 && count < max_attempts do hostname = ENV['HOSTNAME'] command = "curl --silent -XGET --unix-socket /var/run/docker.sock http://localhost/containers/#{hostname}/json" result = Maze::Runner.run_command(command) if result[1] == 0 begin json_string = result[0][0].strip json_result = JSON.parse(json_string) port = json_result['NetworkSettings']['Ports']["#{local_port}/tcp"][0]['HostPort'] rescue StandardError $logger.error "Unable to parse public port from: #{json_string}" return 0 end end count += 1 sleep 1 if port == 0 && count < max_attempts end $logger.error "Failed to determine public port within #{max_attempts} attempts" if port == 0 && count == max_attempts port end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def docker_port(internal_port, container_name = name)\n docker_runner = Fleetctl::Runner::SSH.new('docker', 'port', container_name, internal_port)\n docker_runner.run(host: ip)\n output = docker_runner.output\n if output\n output.rstrip!\n output.split(':').last\n end\n end", "def docker_getport(containername)\n %x{docker ps --filter name=#{containername} --format \"{{.Ports}}\" | sed \"s;->.*$;;\" | sed \"s;^.*:;;\" | head -n 1 | tr -d \"\\n\"}\n end", "def get_host_mapped_port_for_container(environment, container_name, container_port)\n container = get_docker_container(environment, \"#{container_name}_1\")\n port_info = container.json['NetworkSettings']['Ports'][container_port].first\n port_info['HostPort']\nend", "def get_port_of_container(container_id)\n @logger.info \"Getting port id for container <#{container_id}> ...\"\n port = container_port\n @logger.info \"port for container #{container_id} is : #{port}\"\n\n return port\n end", "def container_of_allocated_port(port)\n Docker::Container.all.each do |container|\n public_ports = container.info['Ports'].map { |public_port| public_port['PublicPort'] }\n return container if public_ports.include? port\n end\n nil\n end", "def determine_docker_host_for_container_ports\n\n begin\n docker_host = Resolv.getaddress('docker')\n puts \"Host alias for 'docker' found. Assuming container ports are exposed on ip '#{docker_host}'\"\n rescue\n docker_host = Resolv.getaddress(Socket.gethostname)\n puts \"No host alias for 'docker' found. Assuming container ports are exposed on '#{docker_host}'\"\n end\n\n docker_host\n\nend", "def find_port(port)\n port += 1 while port_bound?('127.0.0.1', port)\n port\nend", "def docker_port_env_var\n 'CYBER_DOJO_SAVER_PORT'\n end", "def get_docker_container(environment, container_name)\n container_id = \"#{environment.get_compose_project_name}_#{container_name}\"\n container = get_container(container_id)\n until container.json['NetworkSettings']['Ports']\n container = get_container(container_id)\n end\n container\nend", "def start_container(image, expose_port)\n container = Docker::Container.create('Image' => image, 'HostConfig' => {'PortBindings' => {\"#{expose_port}/tcp\" => [{}]}})\n container.start\n Container.new(container, expose_port)\nend", "def actual_port; end", "def actual_port; end", "def docker_routable_ip\n case @docker_url.scheme\n when 'tcp', 'http', 'https'\n docker_dns = @docker_url.host\n docker_port = @docker_url.port || 2376\n else\n # Cheap trick: for unix, file or other protocols, assume docker ports\n # are proxied to localhost in addition to other interfaces\n docker_dns = 'localhost'\n docker_port = 2376\n end\n\n addr = Addrinfo.getaddrinfo(\n docker_dns, docker_port,\n Socket::AF_INET, Socket::SOCK_STREAM).first\n\n addr && addr.ip_address\n end", "def obtain_port\n server = TCPServer.new(\"127.0.0.1\", 0)\n port = server.addr[1]\n server.close\n port\n end", "def find_open_port\n server = TCPServer.new('127.0.0.1', 0)\n port = server.addr[1]\n server.close\n port\n end", "def port\n @port ||= target.split(':',2).last.to_i\n end", "def port_from_host_entry\n port_str = NewRelic::Agent.config[:'infinite_tracing.trace_observer.host'].scan(%r{:(\\d+)$}).flatten\n if port = port_str[0]&.to_i\n NewRelic::Agent.logger.warn(\":'infinite_tracing.trace_observer.port' is ignored if present because :'infinite_tracing.trace_observer.host' specifies the port\")\n return port\n end\n end", "def server_port(id = '__default__')\n @servers[id].port\n end", "def port\n @manager.primary_pool.port\n end", "def find_available_port\n server = TCPServer.new(\"127.0.0.1\", 0)\n server.addr[1]\n ensure\n server.close if server\n end", "def beef_port\n public_port || local_port\n end", "def local_port\n get('beef.http.port') || '3000'\n end", "def port\n connect_address.ip_port\n rescue SocketError\n # Not bound to any local port\n rescue IOError\n # Socket has been closed\n end", "def findPort()\n # this is REALLY ugly\n port = @config['startPort']\n while true\n good = true\n #self.class.each { |v|\n # if (v.port == port)\n # good = false\n # break\n # end\n #}\n # Retrieve the list of all Daemons running\n if (@@inst[self.class] != nil)\n @@inst[self.class].each_value { |value|\n # For each Daemon, check its used port compared to our candidate one\n if (value.port == port)\n good = false\n break\n end\n }\n end\n if (good)\n begin\n info \"Checking port TCP:#{port}...\"\n serv = TCPServer.new(port)\n rescue\n good = false\n info \"Port TCP:#{port} is in use!\"\n else\n serv.close\n info \"Port TCP:#{port} is free!\"\n begin\n info \"Checking port UDP:#{port}...\"\n serv = UDPSocket.new\n\t serv.bind(nil,port)\n rescue\n good = false\n info \"Port UDP:#{port} is in use!\"\n else\n serv.close\n info \"Port UDP:#{port} is free!\"\n\t end\n end\n end\n return port if (good)\n # The candidate port is already used, increase it and loop again...\n port += 1\n end\n end", "def instance_for(challenge) \n instance_id = `docker run -P -d #{challenge['name']}`.chomp\n port = `docker port #{instance_id} #{challenge['port']}`.chomp.split(/:/)[1]\n [instance_id, port]\n end", "def get_open_port\n socket = Socket.new(:INET, :STREAM, 0)\n socket.bind(Addrinfo.tcp(\"127.0.0.1\", 0))\n port = socket.local_address.ip_port\n socket.close\n port\n end", "def port\n get_value :port\n end", "def base_port\n (options[:port] || env[\"PORT\"] || ENV[\"PORT\"] || 5000).to_i\n end", "def find_available_port\n server = TCPServer.new(FIND_AVAILABLE_PORT)\n server.addr[1]\n ensure\n server.close if server\n end", "def host_with_port; end", "def listening_port\n @dbi.endpoint.port\n end", "def listening_port\n @dbi.endpoint.port\n end", "def true_port\r\n port = servlet_response.getLocalPort\r\n $log.debug(\"True port is #{port}\")\r\n port\r\n end", "def port(opts={})\n # Check if port was specified in options hash\n pnum = opts[:port]\n return pnum if pnum\n\n # Check if we have an SSH forwarded port\n pnum = nil\n env.vm.vm.network_adapters.each do |na|\n pnum = na.nat_driver.forwarded_ports.detect do |fp|\n fp.name == env.config.ssh.forwarded_port_key\n end\n\n break if pnum\n end\n\n return pnum.hostport if pnum\n\n # This should NEVER happen.\n raise Errors::SSHPortNotDetected\n end", "def port\n return @port.to_i\n end", "def port\n conf['api']['port'].to_s\n end", "def port\n configuration.port\n end", "def port\n configuration.port\n end", "def get_docker_ip_address\n # first try to get the ip from docker-ip env\n if !ENV['DOCKER_IP'].to_s.empty?\n return ENV['DOCKER_IP']\n end\n\n if !ENV['DOCKER_HOST'].to_s.empty?\n \t\t# dockerhost set\n \t\thost = ENV['DOCKER_HOST'].dup\n \t\thost.gsub!(/tcp:\\/\\//, '')\n \t\thost.gsub!(/:\\d+/,'')\n\n \t\treturn host\n else\n return '127.0.0.1'\n \tend\n end", "def remote_port\n return @remote_port\n end", "def port\n @port ||= use_ssl ? 636 : 389\n end", "def port\n @hash[\"Listen\"].to_i\n end", "def local_port\n return @local_port\n end", "def searchkick_port\n return nil unless @@url.is_valid_searchkick_url?\n\n port = @@url[/:([0-9]{0,5}$)/, 1]\n return port.to_i if port.present?\n nil\n end", "def local_port\n socket = Socket.new(:INET, :STREAM, 0)\n socket.bind(Addrinfo.tcp(\"127.0.0.1\", 0))\n port = socket.local_address.ip_port\n socket.close\n port\n end", "def port\n return @forwarded_port || @port\n end", "def port\n @port ||= Port.new(@event.at('@port'), @event.at('@svc_name'), @event.at('@protocol'))\n end", "def available_endpoint\n \"0.0.0.0:#{available_port}\"\n end", "def host_port(options)\n require \"jenkins\"\n require \"jenkins/config\"\n if base_uri = ::Jenkins::Config.config['base_uri']\n uri = URI.parse(::Jenkins::Config.config['base_uri'])\n host = uri.host\n port = uri.port\n end\n host = options[\"host\"] if options[\"host\"]\n port = options[\"port\"] || port || '80'\n [host, port]\n end", "def port; config[:port]; end", "def port\n @socket.connect_address.ip_port\n rescue SocketError\n # Not bound to any local port\n rescue IOError\n # Socket has been closed\n end", "def getPort()\n return @uri.port\n end", "def port\n conf['dashboard']['port'].to_s\n end", "def port\n if !block_given?\n return @j_del.java_method(:port, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling port()\"\n end", "def port\n raise \"Http-server not spawned yet. Call Hayabusa#start to spawn it.\" if !@httpserv\n return @httpserv.server.addr[1]\n end", "def public_port\n return get('beef.http.public.port') unless get('beef.http.public.port').nil?\n\n return '443' if public_https_enabled?\n return '80' unless public_host.nil?\n\n nil\n end", "def port\n @port ||= opts.fetch(:port, parsed_uri.port)\n end", "def port\n conf['port'] || '80'\n end", "def port\n p = attributes['port'].to_i\n (p == 0 ? nil : p)\n end", "def port\n @connection.port\n end", "def probe_port\n options[:probe_port] ||\n env['GOOD_JOB_PROBE_PORT']\n end", "def port\n @attributes[:port]\n end", "def port\n nodes[0][1].to_i\n end", "def host_with_port\n [config.host, optional_port].compact.join(\":\")\n end", "def get_def_cqlsh_port()\n cassandra_home = node.default[:cassandra_home]\n cassandra_current = \"#{cassandra_home}/current\"\n yaml_file = \"#{cassandra_current}/conf/cassandra.yaml\"\n\n if node.workorder.has_key?(\"rfcCi\")\n ci = node.workorder.rfcCi.ciAttributes\n else\n ci = node.workorder.ci.ciAttributes\n end\n\n ver = ci.version.to_f\n yaml = YAML::load_file(yaml_file)\n\n if ver >= 2.1\n port = yaml['native_transport_port']\n else\n port = yaml['rpc_port']\n end\n return port\n end", "def get_available_port(host)\n (7000..7100).each do |port|\n status = `nmap -Pn -p #{port} #{host} | grep #{port} | awk '{print $2}'`.chomp(\"\\n\")\n return port if status.eql? 'closed'\n end\n nil\n end", "def ssh_port(expected)\n expected\n end", "def port\n data[:port]\n end", "def raw_host_with_port; end", "def create_new_container\n puts 'Start creating a new container..'\n host = get_available_host\n if host.nil?\n puts 'Could not found a host with limit enough to create more containers'\n return\n end\n puts \"getting an available port to #{host}\"\n port = get_available_port(host)\n if port.nil?\n puts 'Could not found an available port'\n return\n end\n\n puts \"using port #{port} from #{host}\"\n\n Docker.url = \"tcp://#{host}:#{@docker_port}/\"\n container = Docker::Container.create(\n 'Image' => \"#{@ws_image}\",\n 'ExposedPorts' => { \n '8070/tcp' => {}\n },\n 'HostConfig' => {\n 'CpuPeriod' => 25000,\n 'PortBindings' => {\n '8070/tcp' => [ { 'HostPort' => \"#{port}\" } ]\n }\n }\n )\n container.start\n register_container(host, port, container.id)\n end", "def ssh_port\n max_adapters = machine.parent.system_properties.get_max_network_adapters(machine.chipset_type)\n\n max_adapters.times do |i|\n adapter = machine.get_network_adapter(i)\n\n port_details = adapter.nat_driver.redirects.detect do |redirect|\n redirect.split(',').first == 'ssh'\n end\n\n if port_details\n return port_details.split(',')[3]\n end\n end\n\n nil\n end", "def port(port, host = T.unsafe(nil)); end", "def port_string; end", "def port\n self.port\n end", "def port\n request.port\n end", "def port\n return @port if @port\n\n @server = TCPServer.new('127.0.0.1', 0)\n @port = @server.addr[1].to_i\n @server.close\n\n return @port\n end", "def get_bind_ip\n File.exist?('/.dockerenv') ? '0.0.0.0' : '127.0.0.1'\nend", "def port\n 7779\n end", "def server_port\n AgileProxy.config.server_port\n end", "def host_with_port\n @context.registers[:host_with_port]\n end", "def optional_port; end", "def available_port\n server = TCPServer.new('0.0.0.0', 0)\n server.addr[1].tap do\n server.close\n end\n end", "def get_debugger_port\n throw \"Could not get devices from adb\" if @adb.getDevices.size == 0\n dev = @adb.getDevices[0]\n sleep(1)\n throw \"Could not get clients for device (#{dev})\" if dev.getClients.size == 0\n dev.getClients.each do |cli|\n $DEBUG and puts(\"Found process: #{cli}\")\n if(cli.getClientData.getDebuggerConnectionStatus.to_s == \"WAITING\")\n $DEBUG and puts(\"Found process waiting for debugger: #{cli} : #{cli.getDebuggerListenPort}\")\n return(cli.getDebuggerListenPort)\n end\n end\n throw(\"Could not find a process waiting for debugger.\")\n return(nil)\n end", "def get_port(port)\n send_request(FUNCTION_GET_PORT, [port], 'k', 1, 'C')\n end", "def port\n @port\n end", "def port\n @port\n end", "def port\n @port\n end", "def server_port ; @env['SERVER_PORT' ].to_i ; end", "def get_avail_port(host)\n host ||= (Socket::gethostbyname('')||['localhost'])[0]\n\n infos = Socket::getaddrinfo(host, nil, Socket::AF_UNSPEC,\n Socket::SOCK_STREAM, 0, \n Socket::AI_PASSIVE)\n fam = infos.inject({}) { |h, arr| h[arr[0]]= arr[2]; h }\n sock_host = fam['AF_INET'] || fam['AF_INET6']\n\n sock = sock_host ? TCPServer.open(sock_host, 0) : TCPServer.open(0)\n port = sock.addr[1]\n sock.close\n\n port\n end", "def port\n ENV.fetch('PORT', 8983)\n end", "def db_instance_port\n data[:db_instance_port]\n end", "def port\n 20000 + ($$ % 40000)\n end", "def port\n @options[:port]\n end", "def port_named(_name)\n @ports[_name.to_s]\n end", "def get_port(external_port, protocol = TCP, remote_host = '')\r\n return debug('No WAN Service') unless @wan_service\r\n hash = send_action(@wan_service, 'GetSpecificPortMappingEntry', \r\n NewRemoteHost: remote_host, \r\n NewExternalPort: external_port, \r\n NewProtocol: (protocol == TCP ? TCP : UDP))\r\n if hash[:is_error]\r\n return hash\r\n elsif xml = hash[:xml]\r\n return PortMapping.new(\r\n (xml.get_text('NewExternalPort') || external_port).to_s.to_i,\r\n (xml.get_text('NewProtocol') || protocol).to_s,\r\n xml.get_text('NewInternalPort').to_s.to_i,\r\n xml.get_text('NewInternalClient').to_s,\r\n xml.get_text('NewPortMappingDescription').to_s,\r\n xml.get_text('NewLeaseDuration').to_s.to_i,\r\n xml.get_text('NewEnabled').to_s == '1',\r\n (xml.get_text('NewRemoteHost') || remote_host).to_s\r\n )\r\n end\r\n return hash\r\n end", "def port_string\n (protocol == 'http://' && port == 80) || (protocol == 'https://' && port == 443) ? '' : \":#{port}\"\n end", "def connect_port(port)\n connect_host_port(\"localhost\", port)\n end", "def host_with_port\n uhost, uport = self.host, self.port\n if port != protocol.default_port\n \"#{uhost}:#{uport}\"\n else\n uhost\n end\n end", "def port\n if @port == DEFAULT_HTTP_PORT\n DEFAULT_SSL_PORT\n else\n @port\n end\n end", "def socket_port; end" ]
[ "0.80071384", "0.78971666", "0.77233523", "0.7513421", "0.7195997", "0.71907336", "0.68278325", "0.67938745", "0.6681543", "0.66604924", "0.66603935", "0.66603935", "0.6647747", "0.66083825", "0.65949947", "0.65658265", "0.6517812", "0.6487592", "0.64644194", "0.6443003", "0.6441537", "0.64409894", "0.6431822", "0.64185864", "0.63869655", "0.6383494", "0.6358211", "0.63409525", "0.631479", "0.63046664", "0.6299206", "0.6299206", "0.6299017", "0.62985784", "0.62869114", "0.62758493", "0.62285775", "0.62285775", "0.6228484", "0.62268686", "0.61993873", "0.6173417", "0.61646247", "0.61619455", "0.6157017", "0.61529934", "0.61484677", "0.61422163", "0.61335653", "0.6110378", "0.6108054", "0.60938543", "0.6083607", "0.60799724", "0.60764724", "0.6047008", "0.6032894", "0.60165775", "0.60145104", "0.60098726", "0.60095173", "0.6009113", "0.60036", "0.6000258", "0.5989558", "0.5988485", "0.5980661", "0.5974071", "0.59569263", "0.5954407", "0.5954323", "0.5950397", "0.5937691", "0.59259164", "0.5919419", "0.5910275", "0.5909736", "0.590971", "0.59065825", "0.5905987", "0.58998305", "0.58967", "0.58965755", "0.5882081", "0.587558", "0.587558", "0.587558", "0.587372", "0.5871875", "0.5847359", "0.58464366", "0.5842497", "0.58402544", "0.5838867", "0.5828593", "0.5828488", "0.5827809", "0.58177656", "0.5809392", "0.5800011" ]
0.67244875
8