query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
COUNTER TO IGNORE THE 'puts stringsHash[:start_date]' THE SECOND TIME THROUGH IF 'n' IS SELECTED BY USER
|
def getStartDate(eventName)
counter = 0
start_date_check = ""
@startDate = ""
while start_date_check != 'y' || start_date_check != "exit"
if counter == 0
puts @@stringsHash[:start_date]
end
counter += 1
start_date = gets.strip
if start_date == 'exit'
return
end
puts "\n"
puts "Is '#{start_date}' the correct start date? ---> ex. (??/??/????)\nPress 'y' for 'Yes' or 'n' for 'No' and press 'Enter'."
start_date_check = gets.strip
if start_date_check == 'exit'
return
end
if start_date_check == 'y'
@startDate = start_date
break
end
if start_date_check == 'n'
puts "\n"
puts "-------------------------------------------------------"
puts "Re-Enter the Start Date of '#{@eventName}' and press 'Enter':"
redo
end
if start_date_check != 'y' || start_date_check != 'n'
puts "\n"
puts "Please press 'y' for 'Yes' or 'n' for 'No' and hit the 'Enter' Key."
puts "If you'd like to exit the program, type 'exit' and hit the 'Enter' Key."
puts "\n"
puts "**** Now Re-Enter the Start Date of '#{@eventName}' and hit 'Enter'. ****"
redo
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def start_time_idx() return (self.start_date.strftime(\"%Y%m%d%H%M\") rescue nil); end",
"def classStart()\n ((self.date.strftime(\"%y\") == DateTime.now.strftime(\"%y\")) && \n (self.date.strftime(\"%m\") == DateTime.now.strftime(\"%m\")) && \n (self.date.strftime(\"%d\") == DateTime.now.strftime(\"%d\")) &&\n (self.date.strftime(\"%k\").to_i + 1 >= DateTime.now.strftime(\"%k\")).to_i)\n end",
"def start_time; end",
"def time_file (doc2, estimate)\n\n#Hash to store the count of [Next], [Submit], etc.\n\tcounthash = Hash.new\n\tcounthash[\"[Next]\"] = 0\n\tcounthash[\"[Submit]\"] = 0\n\n#TO DO: update so that it finds the search criteria from the entered keywords\n# Count the number of [Next]s, [Submit, Long]s\n# and multiply by the time assigned to each keyword\n\tdoc2.paragraphs.each do |p|\n\t\tcounthash[\"[Next]\"] += 6*p.to_s.scan(/(\\[(n|N)ext)|((n|N)ext\\])/).size\n\t\tcounthash[\"[Submit]\"] += estimate*p.to_s.scan(/\\[(S|s)ubmit/).size\n\tend\n\n#prints times associated with [Next], [Submit, *], etc.\n\treturn counthash\n\nend",
"def rank_times\n hours = Array.new(24){0}\n @file.each do |line|\n hour = line[:regdate].split(\" \")\n hour = hour[1].split(\":\")\n hours[hour[0].to_i] += 1\n\n end\n hours.each_with_index{ |counter,hours| puts \"#{hours}: #{counter}\"}\n end",
"def starttime; Time.parse(@starttime_str); end",
"def start_time=(_arg0); end",
"def getlogincount\n\n # darrendao: Looks like this number has to match up with how often\n # nventory-client is run in the crontab, otherwise, nventory server ends up\n # miscalculating the sum... bad...\n # How many hours of data we need to sample, not to exceed 24h\n minus_hours = 3\n\n # get unix cmd 'last' content\n begin\n content = `last`\n rescue\n warn \"Failed to run 'last' command\"\n return nil\n end\n\n\n counter = 0\n\n (0..minus_hours).each do | minus_hour |\n target_time = Time.now - 60*60*minus_hour\n time_str = target_time.strftime(\"%b %d %H\")\n content.split(\"\\n\").each do |line|\n counter += 1 if line =~ /#{time_str}/\n end\n end\n return counter\n end",
"def load_showtimes\n available_times = {\n 10.45 => \"10:45am\", 11.00 => \"11:00am\", 11.15 => \"11:15am\", 11.30 => \"11:30am\",11.45 => \"11:45am\", 12.00 => \"12:00pm\", 12.15 => \"12:15pm\", 12.30 => \"12:30pm\", 12.45 => \"12:45pm\", \n 13.00 => \"1:00pm\", 13.15 => \"1:15pm\", 13.30 => \"1:30pm\",13.45 => \"1:45pm\",14.00 => \"2:00pm\",14.15 => \"2:15pm\",14.30 => \"2:30pm\", 14.45 => \"2:45pm\", 15.00 => \"3:00pm\",15.15 => \"3:15pm\",16.00 => \"4:00pm\", 16.15 => \"4:15pm\", 16.30 => \"4:30pm\", 16.45 => \"4:45pm\", 17.00 => \"5:00pm\",17.15 => \"5:15pm\", 17.30 => \"5:30pm\",17.45 => \"5:45pm\",18.00 => \"6:00pm\", 18.15 => \"6:15pm\", 18.30 => \"6:30pm\", 18.45 => \"6:45pm\", 19.00 => \"7:00pm\", 19.15 => \"7:15pm\", 19.30 => \"7:30pm\", 19.45 => \"7:45pm\", 20.00 => \"8:00pm\", 20.15 => \"8:15pm\", 20.30 => \"8:30pm\", 20.45 => \"8:45pm\", 21.00 => \"9:00pm\", 21.15 => \"9:15pm\", 21.30 => \"9:30pm\", \n 22.00 => \"10:00pm\", 22.15 => \"10:15pm\", 22.30 => \"10:30pm\", 22.45 => \"10:45pm\", 23.00=> \"11:00pm\", 23.15 => \"11:15pm\", \n 23.30 => \"11:30pm\", 23.45 => \"11:45pm\",24.00 => \"12:00am\"}\n\n\n\n showtimes = [10.45]\n\n if self.runtime >= 1.33 && self.runtime <= 1.5\n showtimes << 12.30 << 14.00 << 15.30 << 17.00 << 18.30 << 20.00 << 21.30 << 23.00\n\n elsif self.runtime >= 1.5 && self.runtime <= 2 \n showtimes << 13.00 << 15.00 << 17.00 << 19.00 << 21.00 << 23.00 << 24.00\n\n elsif self.runtime >= 2 && self.runtime <= 3\n showtimes << 14.15 << 17.15 << 21.15 << 24.00\n end \n\n\n\n showtimes.map! do |time|\n time = Showing.create!(military_time: time.to_f, time_string: available_times[time], movie: self)\n end\n\n self.showings = showtimes\n end",
"def getTime (line, nFile)\n startT = Time.new\n \n $stdin.gets\n\n endT = Time.now\n endT = endT - startT\n line += \"#{endT}\\n\"\n nFile.puts(line)\n end",
"def date_time_url\n @slowest_time= 0\n print \"\\nTotal requests grouped by the Date/hour\\n\\n\"\n\t\t\n #taking each date&hour\n @count.each do|val1,val2|\n slowest = 0\n \n #searching on each line to find slowest\n $file.each_line do|line|\n\tif line.include? val1\n\t time = line.match /\\d+$/\n\t if time\n\t #finding slowest time\n\t time = time[0].to_i\n\t if time > slowest\n\t slowest = time\n\t end\n\t end\n\tend\n\tslowest = slowest.to_s\n\t#finding slowest url in corresponding date\n\tif line.include? slowest\n\t @url = line.match /https?:\\/\\/[\\S]+/.to_s\n\tend\n\tslowest = slowest.to_i\n end\n \n #checking plural form of request.\n request = \"request\"\n if val1.to_i > 1\n\trequest += \"s\"\n end \n print \"#{ val1 } : #{ val2 } #{ request } \\tSlowest-Time : #{ slowest } \\tSlowest-URL : #{ @url }\\n\\n\"\n \n #finding slowest URL in the log.\n if slowest > @slowest_time\n @slowest_time = slowest\n @slowest_url = @url\n end\n end \n print \"Slowest URL : #{ @slowest_url }\\n\"\n end",
"def times\n @times ||= {\n start: (starttime && starttime.strftime(\"%l:%M %P\")) || 'TBD',\n start_excel: (starttime && starttime.strftime(\"%T\")) || 'TBD',\n end: (endtime && endtime.strftime(\"%l:%M %P\")) || 'TBD',\n end_excel: (endtime && endtime.strftime(\"%T\")) || 'TBD',\n }\n end",
"def start_time\n return \"1530\";\n end",
"def parse\n line = @io.gets until md = /\\ATime before run:\\s+(?<time>.*)\\Z/.match(line)\n return unless md\n @db.date_time ||= DateTime.parse(md[:time])\n super\n @db[\"lparstat_out\"] = @db[\"lparstat_sum\"]\n end",
"def mark_start_time key\n @start_time[key] = Time.now\n end",
"def age_worker(age_date)\n age_time = age_date.to_time\n ARGF.each do |l|\n project, type, age, last_seen = l.split \n last_seen = Time.at(last_seen.to_i)\n age_date = DateTime.parse(last_seen)\n puts l unless last_seen < age_date\n end\nend",
"def script=(seconds); end",
"def prep_time_passed\n return \"7:34\"\n end",
"def measure_me(outfile)\n log_hashes = []\n log_time = time_starts_at.to_i + 86400\n log_hashes << {:eventName => 'created', :objectType => 'my_object', :objectId => 'useless_object', :timestamp => log_time}\n\n log_time = time_starts_at.to_i + 86400*2\n log_hashes << {:eventName => 'created', :objectType => 'my_object', :objectId => 'once_object', :timestamp => log_time}\n log_time += 1000\n log_hashes << {:eventName => 'measureMe', :measureName => 'best_measure', :actorType => 'my_object', :actorId => 'once_object', :targetId => 'target', :timestamp => log_time}\n\n log_time = time_starts_at.to_i + 86400*3\n log_hashes << {:eventName => 'created', :objectType => 'my_object', :objectId => 'two_targets_object', :timestamp => log_time}\n log_time += 1000\n log_hashes << {:eventName => 'measureMe', :measureName => 'best_measure', :actorType => 'my_object', :actorId => 'two_targets_object', :targetId => 'target_one', :timestamp => log_time}\n log_time += 1000\n log_hashes << {:eventName => 'measureMe', :measureName => 'best_measure', :actorType => 'my_object', :actorId => 'two_targets_object', :targetId => 'target_two', :timestamp => log_time}\n\n log_time = time_starts_at.to_i + 86400*4\n log_hashes << {:eventName => 'created', :objectType => 'my_object', :objectId => 'twice_one_target_object', :timestamp => log_time}\n log_time += 1000\n log_hashes << {:eventName => 'measureMe', :measureName => 'best_measure', :actorType => 'my_object', :actorId => 'twice_one_target_object', :targetId => 'target_three', :timestamp => log_time}\n log_time += 1000\n log_hashes << {:eventName => 'measureMe', :measureName => 'best_measure', :actorType => 'my_object', :actorId => 'twice_one_target_object', :targetId => 'target_three', :timestamp => log_time}\n\n write_logs(outfile, log_hashes)\n end",
"def startCountdown\n # get the current time in milliseconds for reference use\n @curPauseTime = Time.now\n # this tells the program to start counting\n @countdown = true\n end",
"def prompt(hash={})\n\t\t$_TAGHASH_[\"GSq\"] = hash['time'].to_i\n\t\t$_TIMEOFFSET_ = (Time.now.to_i - $_TAGHASH_[\"GSq\"].to_i)\n\tend",
"def count_time(relevant_line)\n t0 = 0\n time_between = []\n relevant_line.each do |n|\n t1 = Time.parse(n)\n d = t1 - t0\n t0 = t1\n time_between << d\n end\n time_between\nend",
"def since_launch\n t_start = Time.parse(\"November 1, 2008\")\n t_current = t_start\n t_end = Time.today\n stats = []\n while (t_current < t_end) do\n puts \"Getting stats for #{t_current.to_s(:date_only)}\"\n stats << \"#{t_current.strftime('%m/%d/%Y')}, #{User.count(:conditions => ['activated_at >= ? and activated_at < ?', t_current, t_current + 1.day])}\"\n t_current += 1.day\n end\n puts stats\n end",
"def cal_entry(starttime, endtime, text, extraargs={})\n time_to_start = Time.iso8601(starttime).localtime\n time_to_end = Time.iso8601(endtime).localtime\n\n a= ((@c_date_start.to_time .. @c_date_end.to_time).cover?(time_to_start))\n puts \"datum ausserhalb des Kalenders #{@c_date_start} < #{time_to_start} < #{@c_date_end} #{text}\" if a==false\n\n hour_to_start = time_to_start.hour\n hour_to_end = time_to_end.hour\n min_to_start = time_to_start.min / (60/@c_row_division)\n min_to_end = time_to_end.min / (60/@c_row_division)\n\n finaltext=\"<b>#{text}</b>\"\n\n # handle the case that the entry is out of bounds\n # in this case it is drawn in the extra lines\n # an start/endtime is shown as extra tet\n extratext=nil\n\n\n\n # entry starts too early\n if (hour_to_start == 0) || (hour_to_start) < @c_time_start then\n extratext = true\n hour_to_start = @c_time_start-1\n min_to_start = 0\n end\n\n # entry ends too early\n if (hour_to_end == 0) || (hour_to_end) < @c_time_start then\n extratext=true\n hour_to_end= @c_time_start\n min_to_end = 0\n end\n\n # entry starts too late\n\n if (hour_to_start == 0) || (hour_to_start >= @c_time_end+1) then\n extratext = true\n hour_to_start = @c_time_end + 1\n min_to_start = 0\n end\n\n # entry ends too late\n if (hour_to_end == 0) || (hour_to_end >= @c_time_end+1) then\n extratext = true\n hour_to_end = @c_time_end + 2\n min_to_end = 0\n end\n\n if extratext then\n finaltext = finaltext + \"<br><font size='#{@c_fontsize-2}'>#{time_to_start.strftime('%k.%M')} - #{time_to_end.strftime('%k.%M')}</font>\"\n end\n\n\n\n\n starttime_s = time_to_start.strftime(\"%k.%M\")\n endtime_s = time_to_end.strftime(\"%k.%M\")\n\n text_to_show = \"#{starttime_s} - #{endtime_s}<br/>#{text}\"\n text_to_show = \"#{finaltext}\"\n\n day = (time_to_start.wday + 6) % 7 # since we start on monday shift it one left\n column = @c_firstcol_division + day * @c_col_division\n\n srow = 2 * @c_row_division + (hour_to_start - @c_time_start) * @c_row_division + min_to_start\n erow = 2 * @c_row_division + (hour_to_end - @c_time_start) * @c_row_division -1 + min_to_end\n\n cal_entry_raw([srow, column], erow - srow, text_to_show, extraargs[:recurring])\n end",
"def update_dates ( date )\n date = Date.parse(date)\n if !DATES[date].nil?\n DATES[date] += 1\n end\nend",
"def start=(time); end",
"def getSessions(result)\n sessions = result.array.sort_by &:start\n\n groupedSession = sessions.group_by { |session| session.start }\n @massagedGroupedSession = {}\n #puts groupedSession\n\n groupedSession.each_pair do |k, v|\n startTime = Time.iso8601(k).strftime('%I:%M%p')\n @massagedGroupedSession[startTime] = v\n end\n\n #puts groupedSession.keys.size\n\n=begin\n datesCollection = sessions.uniq { |x| x.start }\n\n zdatesCollection.each { |x|\n puts x.start\n\n }\n=end\n\n #sessions.sort_by &:start\n @massagedGroupedSession\n end",
"def cstime=(*) end",
"def find_show_start_time(start_of_show)\n empty_block_count = 0\n check_if_show_within_hour(start_of_show)\n while @current_time_check <= start_of_show\n if empty_block_count == 4\n @shows_with_blanks << Event.new(start_date_time: @current_time_check - 1.hour, end_date_time: @current_time_check)\n check_if_show_within_hour(start_of_show)\n empty_block_count = 0\n else\n @current_time_check += 15.minutes\n empty_block_count += 1\n end\n end\n return @shows_with_blanks\n end",
"def search_time_sheet_events(options={})\n days = {}\n method = 'search.messages'\n max_cnt = 15\n cnt = 0\n cur_date = options[:start]\n total_hours = 0.0\n\n loop do\n entries = []\n fdate = cur_date.strftime('%Y-%m-%d')\n printf \"\\n>>> processing #{fdate}\"\n \n query = \"in:engineering from:me on:#{fdate} biab\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n {state: :off, ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n\n query = \"in:engineering from:me on:#{fdate} brb\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n {state: :off, ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n \n query = \"in:engineering from:me on:#{fdate} back\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n {state: :on, ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n \n query = \"in:engineering from:me on:#{fdate} good\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n state = (x['text'] =~ /evening|night/) ? :off : :on\n {state: state, ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n\n entries = entries.sort_by { |h| h[:ts] }\n days[fdate] = {entries: entries}\n\n start_entry = nil\n last_entry = nil\n seconds = 60*15\n total_time_for_day = 0.0\n start = nil\n entries.each do |entry|\n begin\n printf \".\"\n entry[:diff] = 0\n\n if(entry[:state] == :off)\n stop = Time.at((entry[:ts].to_f / seconds).round * seconds)\n start = nil\n entry[:ts] = stop\n next unless start_entry\n\n diff = entry[:ts] - start_entry[:ts]\n start_entry[:diff] = (diff/(60*60))\n\n total_time_for_day += start_entry[:diff]\n start_entry = nil\n else\n time = Time.at((entry[:ts].to_f / seconds).round * seconds)\n entry[:ts] = time\n\n start_entry = entry if start_entry.nil?\n end\n rescue Exception => e\n puts \"Problem with entry: #{entry.inspect}\nstart_entry: #{start_entry.inspect}\n\"\n raise e\n end\n last_entry = entry\n end\n\n if(start_entry)\n today = Time.now.strftime(\"%Y%m%d\")\n process_day = start_entry[:ts].strftime(\"%Y%m%d\")\n\n if(today == process_day)\n time = Time.at((Time.now.to_f / seconds).round * seconds)\n\n diff_work = time - start_entry[:ts]\n start_entry[:diff] = diff_work/(60*60)\n total_time_for_day += start_entry[:diff]\n \n entries << {state: :pending, ts: time, text: \"still working\"}\n\n else\n entries << {state: :off, ts: last_entry[:ts], text: \"good day/evening (you never checked out?)\"}\n end\n end\n\n if entries.length > 0\n entries[entries.length-1][:diff] = 0.0 \n days[fdate][:hours] = total_time_for_day\n total_hours += days[fdate][:hours]\n printf \"=> #{days[fdate][:hours]} for day; #{total_hours} for range\"\n end\n\n break unless(cnt > max_cnt or cur_date < options[:stop])\n\n # go to next day\n cur_date += (60*60*24)\n cnt += 1\n end\n\n days[:hours] = total_hours\n report = {report: days}\n puts \"\\n>>> DONE!\"\n report\n end",
"def process(date, institutes)\n ids = Set.new\n latest_institutes = {}\n changed = 0\n statuses = {}\n institutes.each do |institute|\n id = institute.delete(\"id\")\n ids.add( id )\n latest_institutes[ id ] = institute\n\n if INSTITUTES.key?(id )\n changed +=1 if INSTITUTES[id] != institute\n #we've encountered this before, look for edits\n calculate_edits(date, INSTITUTES[id], institute)\n end\n\n statuses[institute[\"status\"]] ||= 0\n statuses[institute[\"status\"]] += 1\n end\n\n STATS[:counts][ date ] = {\n total: institutes.size,\n new: (ids - PREVIOUS_IDS).size,\n deleted: (PREVIOUS_IDS - ids).size,\n changed: changed,\n statuses: statuses\n }\n PREVIOUS_IDS.clear.merge(ids)\n INSTITUTES.clear.merge!( latest_institutes )\nend",
"def retrieve_and_print_worktime\n times = retrieve_worktime\n\n puts \"printing new worktime\"\n if (times[:over] > 0)\n puts \"Worktime: #{times[:over]} h\"\n else\n puts \"tasks.over: 0.0 h\"\n puts \"tasks.during: #{times[:during]} h\"\n puts \"tasks.into: #{times[:into]} h\"\n puts \"tasks.beyond: #{times[:beyond]} h\"\n end\n end",
"def writeNextStartTimeFile\n fileName = makeSiteFileName\n file = File.new(fileName,\"w+\")\n @startTimeHash.each do |key,value|\n time = Time.now.utc.iso8601\n file.puts(\"#{key}=\" + time)\n end\n file.close()\n end",
"def initialize\n @count = Time.secsIn25Mins\n end",
"def print_body(day2, k)\n print \"|\"\n count_events = @ary_event.count do |event|\n event.start_date.day == day2\n end\n if count_events == 1\n ary_time_and_name = convert_time_and_name(@ary_event.find{ |event| event.start_date.day == day2})\n temp_str = ary_time_and_name[k]\n if temp_str.nil? == false\n print temp_str + \" \" * (9 - temp_str.length)\n else\n print \" \" * 9\n end\n elsif count_events >= 2 && k <= 1\n if k == 0\n print count_events.to_s + \" events \"\n else\n print \"scheduled\"\n end\n else\n print \" \" * 9\n end\n end",
"def init\n @by_day = {}\n if File.exist?('result.txt')\n File.readlines('result.txt').each do |line|\n a = line.chomp.split(\"\\t\")\n @by_day[a.first] = a\n end\n end \nend",
"def start_time\n eval(start) if start.present?\n end",
"def createDailyWins(contest,cp)\n cdate = contest.start_date.to_date\n prize_per_day = 2\n while cdate <= contest.end_date.to_date\n for i in (1..prize_per_day)\n time = \"#{(0..23).to_a.sample}:#{(0..59).to_a.sample}:#{(0..59).to_a.sample} Rome\"\n wintime = Time.parse(cdate.strftime(\"%Y-%m-%d\") +\" \"+ time)\n wintime_end = Time.parse(cdate.strftime(\"%Y-%m-%d\") +\" 23:59:59\")\n \n unique_id = Digest::MD5.hexdigest(\"#{@hash_counter}\")\n while Instantwin.where(\"unique_id=?\",unique_id).present?\n @hash_counter += 1\n unique_id = Digest::MD5.hexdigest(\"#{@hash_counter}\")\n end\n \n iw = Instantwin.new\n iw.contest_periodicity_id = cp.id\n iw.title = \"Daily\"\n iw.time_to_win_start = wintime\n iw.time_to_win_end = wintime_end\n iw.unique_id = unique_id\n iw.save\n @hash_counter += 1\n end\n cdate += 1\n end\n end",
"def hash_in_sec(hash)\n\thash_in_sec = hash\n\thash_in_sec.each { |name, time| hash_in_sec[name] = to_sec(time) }\n\thash_in_sec\nend",
"def start_time\n start\n end",
"def start_traction(step_name)\n\n scriptstart_time = Time.now\n\nend",
"def days_of_development(lines)\n num = 0\n dates = []\n lines.each { |line|\n words = line.split(' ')\n if words[0] == \"Date:\"\n words.shift\n time = \"\"\n words.each { |word| time = time + word + \" \" }\n date = DateTime.parse(time)\n dates << date\n end\n }\n if dates.length == 0\n return 0\n end\n start_late = dates.fetch(0)\n dates.each { |date_late|\n if date_late > start_late\n start_late = date_late\n end\n }\n start_early = dates.fetch(0)\n dates.each { |date_early|\n if date_early < start_early\n start_early = date_early\n end\n }\n num = (start_late - start_early).to_i\n num + 1\nend",
"def results(stop,start)\n hours = stop.hour - start.hour\n mins = stop.min - start.min\n secs = stop.sec - start.sec\n (mins = mins + 60) && (hours = hours - 1) if mins < 0\n (secs = secs + 60) && (mins = mins - 1) if secs < 0\n puts \"Done in #{hours}:#{mins}:#{secs}\"\n puts \"Got: #{Group.count} groups, #{Category.count} categories, #{Product.count} products\"\n end",
"def count number\r\n start = Time.now # store the start time\r\n countOriginal number # call the original function\r\n stop = Time.now # store the end time\r\n\r\n # We should have very little overhead timing \r\n # above and after the original function\r\n $gRec.push ['count '+number.to_s, stop-start]\r\nend",
"def cook_time_prompts\n print \"Please provide cooking time desired: \"\n ##TODO Error here if given time is not in the data base\n lowest_cook_time = $default_recipe.recipe_name_and_cooktime.values.sort.first\n cooking_time = gets.chomp.to_i\n raise InvalidCookingTimeError if cooking_time == 0\n raise NotInDatabaseError if cooking_time < lowest_cook_time\n search_by_cooking_time(cooking_time)\nend",
"def test_format\n\n\t data = analyse_log(@filename,@keywords, @start, Time.parse(\"31.12.3000\"), @output_file)\n \tdata_hist = prepare_data(data, @keywords, @start, 3600)\n\n \tassert_equal(true, data_hist.keys[0].class == String)\n \tassert_equal(true, data_hist[@keywords[0]].keys[0].class == Time)\n \tassert_equal(true, data_hist[@keywords[0]][0].class == Fixnum)\n\tend",
"def user_seen\n Date.parse(match(/User\\sseen\\s+:\\s+(\\w+ [0-9]{2} [0-9(:?)]+ [0-9]{4})/)) rescue nil\n end",
"def showDate(date)\n puts \"#{date}\"\n items = @logHash[date]\n items.each do |item|\n puts \" #{item.name}\"\n end\n end",
"def display_time(start, finish)\r\n puts \"Time used: \" + Time.at(finish - start).utc.strftime(\"%H:%M:%S\")\r\n end",
"def start_time_input_parser\n\tparams[:micropost][:time] = parse_start_time(params[:micropost][:time])\n end",
"def create_new_report_hash\n new_report_hash = {}\n\n puts \"Great! Now lets create a report about the sighting!\"; sleep(1)\n\n puts \"In what month (MM) did the sighting take place.\"\n new_report_hash[:month] = gets.chomp\n\n puts \"Please title your report.\"\n new_report_hash[:title] = gets.chomp\n\n puts \"What city did you see the animal in?\"\n new_report_hash[:city] = gets.chomp\n\n new_report_hash\nend",
"def countdown_display_before_restart_in_minutes\n return @countdown_display_before_restart_in_minutes\n end",
"def sea_start(sea_dir)\n line = {}\n line[:name] = sea_dir.split(\"/\")[-1]\n line[:start] = Helpers::start_end_time_output(sea_dir).split(\",\")[0]\n line\nend",
"def create_hourly_report(url)\n @total_serv_time = 0\n @time_spent_g = 0\n @time_spent_p = 0\n @user_list = []\n @g_count = 0\n @p_count = 0\n @n = 1\n puts \"24 Hour Report for #{url}\"\n puts \"---------------------------------------------------------------------------------------------\"\n puts \"TH HOUR---# USER---# GET---# POST---TOTAL_TIME_GET(ms)---TOTAL_TIME_POST(ms)---TOTAL_TIME(ms)\"\n puts \"---------------------------------------------------------------------------------------------\"\n for n in 1..24\n $all_user_data.each do |k,v|\n if v[:th_hour] == n && !v[:uri].to_s.string_contains(url).nil? \n @total_serv_time += v[:time].to_i\n if v[:method] == 'G'\n @time_spent_g += v[:time].to_i\n @g_count += 1 \n end\n if v[:method] == 'P'\n @time_spent_p += v[:time].to_i\n @p_count += 1 \n end\n @user_list << v[:user].to_s\n end \n end\n #puts \"#{n}TH HOUR---#{@user_list.uniq.length} users---#{@g_count} GET REQs---#{@p_count} POST REQs---#{@time_spent_g}ms in GET---#{@time_spent_p}ms in POST---#{@total_serv_time}ms in Total\"\n puts \"#{n}TH HOUR---#{@user_list.length} users---#{@g_count} GET REQs---#{@p_count} POST REQs---#{@time_spent_g}ms in GET---#{@time_spent_p}ms in POST---#{@total_serv_time}ms in Total\"\n #pp @@user_list.uniq\n @total_serv_time = 0\n @time_spent_g = 0\n @time_spent_p = 0\n @g_count = 0\n @p_count = 0\n @user_list.clear\n end\n end",
"def day_stats\n days = Array.new(7){0}\n @file.each do |line|\n date = line[:regdate].split(\" \")\n date = Date.strptime(date[0],\"%m/%d/%y\")\n days[date.wday.to_i] += 1\n end\n days.each_with_index{ |counter, days| puts \"#{days}: #{counter}\"}\n\n end",
"def p(s) puts \"-- #{Time.now.strftime('[%H:%M:%S]')} #{s}\" end",
"def p(s) puts \"-- #{Time.now.strftime('[%H:%M:%S]')} #{s}\" end",
"def collect_time_information\n ### Time information\n mark_data_time_information = Array.new\n time_information = @case_details[:case][:system][:time]\n\n mark_data_time_information << 'Answer the following about each time period present in the evidence on the system'\n time_information.each do | key, value | mark_data_time_information << \"-#{key.capitalize}::#{value}\"\n end\n mark_data_time_information << ''\n\n return mark_data_time_information\n end",
"def scan_for_times(token, options = T.unsafe(nil)); end",
"def initialize\n @seconds = 0 #Sets starting time at 0\n end",
"def starts\n form_print(starts_at)\n end",
"def starts\n form_print(starts_at)\n end",
"def save_start_at\n self.start_time = Time.zone.parse(\"#{date_published} #{@start_time_input}\" ) if ( @start_time_input.present? && date_published.present? )\n end",
"def speak(number_of_times)\n\t\tindex = 0\n\t\tuntil number_of_times == index \n\t\t\tputs \"Ho, ho, ho!, Haaaappy holidays!\"\n\t\t\tindex +=1\n\t\tend \n\tend",
"def store_start_timestamp(experiment, timestamp)\n set(experiment.handle.to_s, 'started_at', timestamp.utc.strftime('%FT%TZ'))\n end",
"def start\n @workflow[:started_at] = timeString\n end",
"def start_time\n session[:start_time] ||= (Time.now).to_s\nend",
"def print_by_count(organized_data)\n\n organized_dates_only = organized_data.keys.sort\n\n puts \"***RESULTS START***\"\n puts \"\"\n\n organized_dates_only.each do |date| \n puts date\n site_to_hits = organized_data[date].sort_by {|site, hits| -hits}\n\n site_to_hits.each do |hit| \n site_name = hit[0]\n total_hits = hit[1]\n puts \"#{site_name} #{total_hits}\"\n end\n\n puts \"\"\n\n end\n\n puts \"***RESULTS END***\" \n puts \"\"\n \nend",
"def start\n starts_at.strftime(\"%R\")\n end",
"def parse_start_date(y, m, d, t)\n Time.strptime([y, m, d, t, 'UTC'].join(' '), START_DATE).to_i * 1_000\n end",
"def print_prefix\n\t\tif(\n\t\t\tdatastore['TimestampOutput'] =~ /^(t|y|1)/i or\n\t\t\tframework.datastore['TimestampOutput'] =~ /^(t|y|1)/i\n\t\t)\n\t\t\treturn \"[#{Time.now.strftime(\"%Y.%m.%d-%H:%M:%S\")}] \"\n\t\tend\n\t\t\"\"\n\tend",
"def after_perform_do_stats(*args)\n Stats.increx hourly_key, 3600 * 24 # 24h\n Stats.increx daily_key, 3600 * 24 * 31 # 31d\n redis.incr monthly_key\n end",
"def compute_date_stats tweets\n dates = {}\n tweets.each do |x|\n rec = dates[x.created_at.to_date] ||= 0\n rec+=1\n dates[x.created_at.to_date] = rec\n end\n dates\n end",
"def print_more(s)\n time = Time.now.localtime.strftime(\"[%k:%M:%S]\")\n lines = s.split(\"\\n\")\n\n lines.each_with_index do |line, index|\n if ((index+1) == lines.size)\n puts \"#{time} |_ #{line}\"\n else\n puts \"#{time} | #{line}\"\n end\n end\nend",
"def sick_mention_count(date)\n @range_center = date\n twenty_four_hour_count = Mention.find(:all, :select => \"DATE(mentioned_at) as mentioned_at_date, mentioned_at, substring_index(mentioner, ' (', 1) as mentioner_stripped, mentioner, link, exact_location\", :group => 'mentioner_stripped, mentioned_at_date', :conditions => {:city_id => self.id, :mentioned_at => (\"#{@range_center.year}-#{@range_center.month.to_s.rjust(2, '0')}-#{@range_center.day.to_s.rjust(2, '0')} 00:00\"..\"#{@range_center.year}-#{@range_center.month.to_s.rjust(2, '0')}-#{@range_center.day.to_s.rjust(2, '0')} 23:59\")})\n twenty_four_hour_count.length\n end",
"def total_time=(_arg0); end",
"def in_words(t)\n # to get the number of minutes subtract out days\n # Then calculate hours and subtract those out to get minutes.\n s = []\n days = t.round(4).to_i\n s << \"#{ days } day(s)\" unless days == 0\n \n remainder = t - days\n minutes = remainder * 1440.0 # number of minutes in a day\n hours = (minutes / 60.0).round.to_i\n s << \"#{ hours } hours\" unless hours == 0\n \n # round to 2 decimal places and call it\n minutes = (minutes - hours * 60).round\n s << \"#{ minutes } minutes\" unless minutes == 0\n \n if s.empty?\n s << \"now\"\n else\n s << \"ago\"\n end\n \n s.join(\" \")\n end",
"def running_time(word, word_times)\n t = Time.now\n word.reverse * word_times\n t2 = Time.now\n running_time = t2 - t\nend",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def insist_times\n @insist || 3\n end",
"def started_at=(_arg0); end",
"def started_at=(_arg0); end",
"def started_at=(_arg0); end",
"def cstime(*) end",
"def reading_time(index)\n words_per_second = 270 / 60\n total_words = description(index).scan(/\\s+/).count\n article_time_seconds = total_words / words_per_second\n article_time_minutes = (article_time_seconds / 60).round\n\n return \"less than a minute read\" unless article_time_minutes > 0\n \"#{article_time_minutes} min read\"\n end",
"def isDateDuplicated?(date)\n # binding.pry\n self.user_times.none?{ |day_time| day_time.clock_in.to_s.slice(8, 2) == date }\n # binding.pry \n end",
"def generate_username(first, last, year, level=0)\n # creating username variable by taking in the build_username function from before\n username = build_username(first, last, year, level)\n\n if $user_counts[username].nil?\n $user_counts[username] = 0;\n username\n # appends a username count when the username already exists\n # along with stringfying the given input\n # this will also return if the username has been used along with how many times its been used\n else\n $user_counts[username] +=1\n user_count = $user_counts[username].to_s\n username + \"_\" + user_count\n end\nend",
"def first_sessions(outfile)\n log_hashes = []\n\n user_id = \"member_via_google\"\n current_time = time_starts_at.to_i + rand(86400)\n log_hashes = log_hashes + make_session_logs(user_id, current_time, 1000, true, nil, {:referrer => 'http://google.com'})\n log_hashes = log_hashes + become_member(user_id, current_time + 100)\n\n user_id = \"eunknown\"\n current_time = time_starts_at.to_i + rand(86400)\n log_hashes = log_hashes + make_session_logs(user_id, current_time, 1000, true, nil, {:referrer => ''})\n\n user_id = \"hatchery_references\"\n current_time = time_starts_at.to_i + rand(86400)\n log_hashes = log_hashes + make_session_logs(user_id, current_time, 1000, true, nil, {:referrer => 'http://hatchery.cc'})\n\n user_id = \"bot\"\n current_time = time_starts_at.to_i + rand(86400)\n log_hashes = log_hashes + make_session_logs(user_id, current_time, 0, true, nil, {:userAgent => 'GoogleBot'})\n\n write_logs(outfile, log_hashes)\n end",
"def starttimefirst\n (Time.now.strftime(\"%d-%b-%Y_%H%M\")).to_s\nend",
"def start(example_count)\n end",
"def start(example_count)\n end",
"def runtime\n details.at(\"div.subtext time[itemprop='duration']\")['datetime'].gsub(/[^\\d+]/, '').to_i rescue nil\n end",
"def start_time_text\n if (started_at == nil)\n return \"Don't know\"\n end\n diff = started_at.yday - Time.now.yday\n sameyear = (started_at.year == Time.now.year)\n if (diff == 0 && sameyear)\n started_at.strftime(\"TODAY at %I:%M %p\")\n elsif (diff == -1 && sameyear)\n started_at.strftime(\"YESTERDAY at %I:%M %p\")\n else\n started_at.strftime(\"%A, %B %d, %Y at %I:%M %p\")\n end\n end",
"def get_writing_stats_in_week( in_date )\n \n # Initialize Hash\n stats = { \"total\" => 0, \"editing\" => 0, \"writing\" => 0, \"words\" => 0 }\n \n # Get the current day of week\n dayCurrent = in_date.wday().to_i\n \n # Get date at the start of the week\n timeStart = Time.utc( in_date.year, in_date.month, in_date.day )\n timeStart = timeStart - 24 * 60 * 60 * dayCurrent\n \n # Get date at the end of the week\n timeEnd = Time.utc( in_date.year, in_date.month, in_date.day )\n timeEnd = timeEnd + 24 * 60 * 60 * ( 7 - dayCurrent )\n \n # Loop through entries and increment totals\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n user_entries.each do |entry|\n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n timeEntry = Time.utc( entry.starttime.year, entry.starttime.month, entry.starttime.day, entry.starttime.hour, entry.starttime.min )\n \n if( timeStart.to_i <= timeEntry.to_i && timeEnd.to_i >= timeEntry.to_i )\n stats[ \"words\" ] += entry.words\n stats[ \"total\" ] += entry.hours + entry.minutes.to_f / 60\n if entry.editing\n stats[ \"editing\" ] += entry.hours + entry.minutes.to_f / 60\n else\n stats[ \"writing\" ] += entry.hours + entry.minutes.to_f / 60\n end \n end\n end\n \n return stats\n \n end",
"def eval_date\n # FIXME: Make pref?\n h = Hash[\"mo\", 1, \"di\", 2, \"mi\", 3, \"do\", 4, \"fr\", 5, \"???\", 6]\n h.merge(Hash[\"mo\", 1, \"tu\", 2, \"we\", 3, \"th\", 4, \"fr\", 5, \"???\", 6])\n a = description.strip.downcase\n a = \"???\" if a.length < 3 || !h.include?(a[0..1])\n day = h[a[0..1]]\n time = a[2..a.length-1].strip.rjust(3, \"0\")\n \"#{day} #{time}\"\n end",
"def CountingMinutesI(str)\n parts = str.scan(/(\\d+):(\\d\\d)(..)-(\\d+):(\\d\\d)(..)/).flatten\n\n first_min = (parts[0].to_i * 60) + (parts[1].to_i) + (parts[2] == \"pm\" ? 720 : 0)\n second_min = (parts[3].to_i * 60) + (parts[4].to_i) + (parts[5] == \"pm\" ? 720 : 0)\n\n second_min += 1440 if first_min > second_min\n\n second_min - first_min\nend"
] |
[
"0.56199473",
"0.54287827",
"0.53694415",
"0.5353047",
"0.53209764",
"0.5209749",
"0.51826984",
"0.5119688",
"0.510041",
"0.5026047",
"0.50255984",
"0.5024649",
"0.50157815",
"0.49879625",
"0.49699816",
"0.49606282",
"0.49587578",
"0.49352416",
"0.48904616",
"0.4843789",
"0.4842211",
"0.48169264",
"0.4814237",
"0.4811498",
"0.48063487",
"0.4805818",
"0.48028702",
"0.47973022",
"0.47586685",
"0.47459707",
"0.47435406",
"0.47378248",
"0.4735918",
"0.4733785",
"0.47236392",
"0.47215694",
"0.47146112",
"0.47145447",
"0.4707787",
"0.46982282",
"0.4691203",
"0.4691051",
"0.46886376",
"0.4657358",
"0.46549794",
"0.46434742",
"0.46434417",
"0.46397856",
"0.46393445",
"0.4638306",
"0.46382725",
"0.46307522",
"0.46272784",
"0.46170762",
"0.46152163",
"0.46145996",
"0.46145996",
"0.46144348",
"0.4613903",
"0.46106055",
"0.46034607",
"0.46034607",
"0.46014458",
"0.4597088",
"0.45930895",
"0.45914587",
"0.45890567",
"0.45855817",
"0.4580545",
"0.4570519",
"0.45681053",
"0.45664456",
"0.4564997",
"0.45600337",
"0.4559172",
"0.45585313",
"0.45542893",
"0.45525628",
"0.45519418",
"0.45519418",
"0.45519418",
"0.45519418",
"0.45519418",
"0.4548528",
"0.45452365",
"0.45452365",
"0.45452365",
"0.45433852",
"0.4542531",
"0.45411217",
"0.45401257",
"0.45382476",
"0.4530333",
"0.45298648",
"0.45298648",
"0.45291382",
"0.452553",
"0.45244703",
"0.45232168",
"0.45215"
] |
0.54278487
|
2
|
COUNTER TO IGNORE THE 'puts stringsHash[:total_days]' THE SECOND TIME THROUGH IF 'n' IS SELECTED BY USER
|
def getTotalDays(eventName)
counter = 0
total_days_check = ""
@totalDays = ""
while total_days_check != 'y' || total_days_check != "exit"
if counter == 0
puts @@stringsHash[:total_days]
end
counter += 1
total_days = gets.strip
if total_days == 'exit'
return
end
puts "\n"
puts "Is '#{total_days}' the total amount of days of #{@eventName}?\nPress 'y' for 'Yes' or 'n' for 'No' and press 'Enter'."
total_days_check = gets.strip
if total_days_check == "exit"
return
end
if total_days_check == 'y'
@totalDays = total_days
break
end
if total_days_check == 'n'
puts "\n"
puts "-------------------------------------------------------"
puts "Re-Enter the correct amount of days for '#{@eventName}' and press 'Enter':"
redo
end
if total_days_check != 'y' || total_days_check != 'n'
puts "Please press 'y' for 'Yes' or 'n' for 'No' and hit the 'Enter' Key."
puts "If you'd like to exit the program, type 'exit' and hit the 'Enter' Key."
puts "\n"
puts "**** Now Re-Enter the amount of days for '#{@eventName}' and hit 'Enter'. ****"
redo
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def countPresents(days)\n\tcount = sum = 0\n\tdays.times do\n\t\tcount += 1\n\t\tcountdown = count\n\t\tcount.times do\n\t\t\t#puts \"Adding #{countdown} to #{sum}\"\n\t\t\tsum += countdown\n\t\t\tcountdown -= 1\n\t\tend\n\tend\n\tputs \"after #{days} days of christmas you'd receive #{sum.to_s} presents!\"\nend",
"def day_stats\n days = Array.new(7){0}\n @file.each do |line|\n date = line[:regdate].split(\" \")\n date = Date.strptime(date[0],\"%m/%d/%y\")\n days[date.wday.to_i] += 1\n end\n days.each_with_index{ |counter, days| puts \"#{days}: #{counter}\"}\n\n end",
"def total_students( students_hash)\n st_counter =0\n students_hash.each do |key,value|\n st_counter += value\n #puts (\"#{key}: #{value} students\")\n end\n return st_counter\nend",
"def validate_time_total(hash, date)\n if hash.values.map(&:to_i).inject(:+) > (MINUTES_PER_HOUR * HOURS_IN_DAY)\n session[:message] = \"You cannot exceed 24 hours in a day. Please try again.\"\n redirect \"/edit_activities/\" + date\n end\n hash\n end",
"def getlogincount\n\n # darrendao: Looks like this number has to match up with how often\n # nventory-client is run in the crontab, otherwise, nventory server ends up\n # miscalculating the sum... bad...\n # How many hours of data we need to sample, not to exceed 24h\n minus_hours = 3\n\n # get unix cmd 'last' content\n begin\n content = `last`\n rescue\n warn \"Failed to run 'last' command\"\n return nil\n end\n\n\n counter = 0\n\n (0..minus_hours).each do | minus_hour |\n target_time = Time.now - 60*60*minus_hour\n time_str = target_time.strftime(\"%b %d %H\")\n content.split(\"\\n\").each do |line|\n counter += 1 if line =~ /#{time_str}/\n end\n end\n return counter\n end",
"def time_file (doc2, estimate)\n\n#Hash to store the count of [Next], [Submit], etc.\n\tcounthash = Hash.new\n\tcounthash[\"[Next]\"] = 0\n\tcounthash[\"[Submit]\"] = 0\n\n#TO DO: update so that it finds the search criteria from the entered keywords\n# Count the number of [Next]s, [Submit, Long]s\n# and multiply by the time assigned to each keyword\n\tdoc2.paragraphs.each do |p|\n\t\tcounthash[\"[Next]\"] += 6*p.to_s.scan(/(\\[(n|N)ext)|((n|N)ext\\])/).size\n\t\tcounthash[\"[Submit]\"] += estimate*p.to_s.scan(/\\[(S|s)ubmit/).size\n\tend\n\n#prints times associated with [Next], [Submit, *], etc.\n\treturn counthash\n\nend",
"def track_daily_stats\n # if there is no constant defined,\n unless defined?(DOCS_DAILY)\n keys = DOCS.dup\n keys.delete_if {|k,v| DOCS_DAILY_REMOVE.include?(k)}\n self.class.const_set(\"DOCS_DAILY\", keys)\n end\n\n\n # create the daily stat indicator key\n today = Time.now.strftime(\"%Y%m%d\") #20120614\n todays_stats_key = \"stats::#{today}\"\n\n # check if stats have been run today\n todays_stats_exist = DocumentStore.document_exists?(todays_stats_key)\n\n # if not, run the stats for today\n unless todays_stats_exist\n\n # set today's stat key immediately, this just indicates that the stats have been run today\n # this will fail if the key gets added between check above and now (nanoseconds),\n # will rescue below and do nothing\n DocumentStore.create_document(todays_stats_key, 1, {:quiet => false})\n\n # iterate through and retrieve values for each key, and store them as a daily value\n DOCS_DAILY.each do |k,doc_key|\n # get value of document\n doc_val = DocumentStore.get_document(doc_key)\n\n # create key for today's stats for that key\n daily_key = doc_key + \"::#{today}\"\n\n # store value with daily stat key\n DocumentStore.create_document(daily_key, doc_val)\n end\n end\n\n\n rescue Couchbase::Error::KeyExists\n # do nothing if todays_stats_key exists when trying to create\n\n end",
"def total_day_kwh_usage_on(date)\n raise \"Invalid argument: Please use a date value that is not in the future\" if (date > Time.now.utc.to_date)\n\n cumulative_hourly_kwh_usage = 0.0\n (0..23).each do |i|\n cumulative_hourly_kwh_usage += self.total_hour_kwh_usage_on(date, i)\n #puts cumulative_hourly_kwh_usage.to_s\n end\n cumulative_hourly_kwh_usage\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 after_perform_do_stats(*args)\n Stats.increx hourly_key, 3600 * 24 # 24h\n Stats.increx daily_key, 3600 * 24 * 31 # 31d\n redis.incr monthly_key\n end",
"def get_data_words_every_week\n words_per_day = Array.new( 7, 0 )\n \n # Get current day\n timeNow = Time.now\n time60Days = timeNow - 60 * 24 * 60 * 60\n \n # Loop through entries and increment totals\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n user_entries.each do |entry|\n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n # Must have occurred in the last 60 days\n if( entry.starttime.time < time60Days )\n next\n end\n \n dayEntry = entry.starttime.wday().to_i\n\n words_per_day[dayEntry] += entry.words\n end\n \n # Assemble Data String\n data_string = \"\"\n \n (0..(words_per_day.length - 1)).each do |i|\n data_string = data_string + words_per_day[i].to_s\n if( i < words_per_day.length - 1 )\n data_string = data_string + \",\"\n end\n end\n \n return data_string\n end",
"def findNumCycles(output)\n value = 0\n temp = output.slice(/NUMBER_OF_CYCLES_READ[12]=\\d+/)\n if temp != nil && !temp.eql?(\"\")\n value = Integer(temp.split(\"=\")[1]) - 1\n end\n\n if value > @numCycles\n @numCycles = value\n end \n end",
"def get_writing_stats_since( in_days_ago )\n get_writing_stats_in_week( DateTime.now )\n \n # Initialize Hash\n stats = { \"total\" => 0, \"editing\" => 0, \"writing\" => 0, \"words\" => 0 } \n \n # Get all entries from this user\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n # Loop through entries and increment totals \n user_entries.each do |entry|\n \n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n # Get number of days since entry\n d_days = ( Time.now - entry.starttime ) / ( 60 * 60 * 24 )\n \n # Add if within last seven days\n if( d_days < in_days_ago || in_days_ago == -1 )\n stats[ \"words\" ] += entry.words\n stats[ \"total\" ] += entry.hours + entry.minutes.to_f / 60\n if entry.editing\n stats[ \"editing\" ] += entry.hours + entry.minutes.to_f / 60\n else\n stats[ \"writing\" ] += entry.hours + entry.minutes.to_f / 60\n end \n end\n end \n \n return stats \n end",
"def response_by_days\n selected_files.each do |file_name|\n key = file_name[0,6]\n next if @by_day[key]\n result = [key, 0, 0, 0]\n File.readlines(file_name).each do |line|\n next unless line.match 'Completed 200 OK in'\n time = $'.split('ms').first.strip.to_i\n result[1] += 1\n result[2] += time\n end\n# average \n result[3] += result[2]/result[1]\n p result\n @by_day[key] = result\n end\nend",
"def display_student(s) #method to iterate through any hash\n sum = 0 # declares initial value of sum\n s.each do|k,v|\n puts \" #{k}: has #{(v*1.05).round} students\" #increase class size by 5% and round down\n\n sum +=v #counter for sum of values\n end\n puts \"#{sum} total students\"# puts sum of values\nend",
"def get_num_staff_needed\n time_loc = user_choice_of_object_in_class(TimeSlot)\n puts \"You will need #{time_loc.num_staff_needed} staff for that time.\"\n analyze_menu\n end",
"def record_questions_skipped_and_asked(skips_hash)\n skips_hash[:days].each do |date, hash|\n day = survey_version_days.find_or_create_by(date: date)\n day.questions_asked = hash[:total]\n day.questions_skipped = hash[:skip]\n end\n self.questions_asked = survey_version_days.pluck(:questions_asked).compact.sum\n self.questions_skipped = survey_version_days.pluck(:questions_skipped).compact.sum\n save\n skips_hash[:choice_days].each do |id, days|\n cqr = choice_question_reporters.where(q_id: id).first\n next unless cqr\n days.each do |date, hash|\n day = cqr.choice_question_days.find_or_create_by(date: date)\n day.questions_asked = hash[:total]\n day.questions_skipped = hash[:skip]\n end\n cqr.questions_asked = cqr.choice_question_days.pluck(:questions_asked).compact.sum\n cqr.questions_skipped = cqr.choice_question_days.pluck(:questions_skipped).compact.sum\n cqr.save\n end\n skips_hash[:text_days].each do |id, days|\n tqr = text_question_reporters.where(q_id: id).first\n next unless tqr\n days.each do |date, hash|\n day = tqr.text_question_days.find_or_create_by(date: date)\n day.questions_asked = hash[:total]\n day.questions_skipped = hash[:skip]\n end\n tqr.questions_asked = tqr.text_question_days.pluck(:questions_asked).compact.sum\n tqr.questions_skipped = tqr.text_question_days.pluck(:questions_skipped).compact.sum\n tqr.save\n end\n end",
"def scan_for_day_portions(token, options = T.unsafe(nil)); end",
"def check_day_coverage\n #Create a hash to count the day-of-week settings from all profiles\n week = {}; DAYS.each { |d,name| week[d] = 0 }\n\n # Only check profiles that are not marked for destruction\n non_destroyed_profiles = profiles.select {|p| not p.marked_for_destruction?}.compact\n \n #count 'em\n non_destroyed_profiles.each do |p|\n DAYS.each {|d,name| week[d] += 1 if p.send(d) }\n end\n\n week.each do |day, count|\n if count == 0\n create_profile_set_error(\"<b>#{DAYS[day]}</b> is not set\")\n elsif count > 1\n create_profile_set_error(\"<b>#{DAYS[day]}</b> is set in multiple profiles\")\n end\n end\n end",
"def countingValleys(n, s)\n valleysNum = 0\n level = 0\n s.each_char do | step |\n step == \"D\" ? level -= 1 : level += 1\n valleysNum += 1 if (level == 0 && step == \"U\")\n end\n p valleysNum\nend",
"def get_expiry_from(monitor_output)\n index = monitor_output.index(\"will expire in\")\n return EXPIRY_MAX if !index\n text = monitor_output[index, 25]\n num_days = text.split()[3].to_i\n return num_days\nend",
"def daily_totals(emoji)\n\n @day_zero = self.last_day.where(emoji: emoji).pluck(:created_at).size\n @day_one = self.last_day_plus_one.where(emoji: emoji).pluck(:created_at).size\n @day_two = self.last_day_plus_two.where(emoji: emoji).pluck(:created_at).size\n some_days = [@day_zero, @day_one, @day_two]\n\n end",
"def days\n return \"There are #{self * (24 * 60 * 60)} seconds in #{self} days\"\n end",
"def rank_times\n hours = Array.new(24){0}\n @file.each do |line|\n hour = line[:regdate].split(\" \")\n hour = hour[1].split(\":\")\n hours[hour[0].to_i] += 1\n\n end\n hours.each_with_index{ |counter,hours| puts \"#{hours}: #{counter}\"}\n end",
"def print_used_per_period(center_id)\n\t\tquery = []\n\t\tquery << \"select created_on as start, ifnull(paid_on, Now()) as end, survey_id, center_id, sum(used) as used \"\n\t\tquery << \" from periods where center_id = #{center_id} \"\n\t\tquery << \" group by start, end\"\n\t\tperiods_count = ActiveRecord::Base.connection.execute(query.join).each(:as => :hash).inject([]) do |col,j| \n\t\t\tcol << \"#{j['start']} - #{j['end']} \\tsurvey: #{j['survey_id']} \\tc: #{j['center_id']} \\tused: #{j['used']}\"\n \t\t\tcol\n \tend\n \tputs periods_count.join(\"\\n\")\n \tperiods_count\n end",
"def caliper_count(event_name, sent, expected)\n \n # original hash, cloned, compact (no nil), strings, keys\n copy_sent = sent.clone.compact.stringify_keys.keys\n copy_expected = expected.clone.stringify_keys.keys\n \n # what's missing, get the difference\n missing = copy_sent - copy_expected # | copy_expected - copy_sent\n missing = missing.reject { |k| ['id'].include? k }\n if missing.size.positive?\n sample = missing.map { |k| \"#{k}:::#{sent.fetch(k)}\"}\n err = <<~ERRLOG\n event_name: ims_#{event_name}\n count: { sent: #{sent.keys.count}, defined: #{copy_expected.count} }\n summary: { event_name: ims_#{event_name}, undefined: #{missing.to_s.gsub('\"', '')} }\n sample: { event_name: ims_#{event_name}, undefined: #{sample} }\n message: #{sent.to_json}\n\n ERRLOG\n # store in log file, print if interactive\n open('log/ddl-undefined.log', 'a') { |f| f << err }\n puts err if $stdout.isatty\n end\nend",
"def num_days_online(days)\n return (1..days).inject(0) { |sum, i| (i%100==0 or i%14==0 or i%3==0) ? sum : sum + 1 }\nend",
"def summarise days = 7, debug = nil\n days = days.to_i\n data = [ ]\n file = self.get_summary_file.gsub 'summary', 'daily'\n daily = self.class.get_json file\n start_date = 0\n d = nil\n last = 0\n prev = 0\n cut_off_date = ( DateTime.now - days ).to_s\n File.open( self.get_log_file, 'r' ).each_line do | line |\n begin\n line = JSON.parse line\n rescue\n line = nil\n end\n if line and line['timestamp'] and ( last != line['message']['usage'] )\n next if ( cut_off_date > line['timestamp'] )\n new_line = []\n d = line['timestamp'][2..3] + line['timestamp'][5..6] + line['timestamp'][8..9] # compact version of date\n ts = Time.parse( line['timestamp'] ).strftime '%s'\n ts = ts.to_i\n ts = ts - start_date\n if start_date == 0\n # start_date = ts # can't get this delta working\n end\n new_line << ts\n smoothedUsage = line['message']['usage'].to_i\n if last != 0 and prev != 0\n smoothedUsage = ( smoothedUsage + last + prev ) / 3 # average of last 3 readings\n end\n new_line << smoothedUsage\n if line['message']['annotation'] and line['message']['annotation']['title'] and line['message']['annotation']['text']\n new_line << line['message']['annotation']['title']\n new_line << line['message']['annotation']['text']\n end\n data << new_line\n if (( ! daily[d] ) or ( line['message']['today'].to_i > daily[d]['today'].to_i ))\n daily[d] = line['message']\n daily[d].delete 'usage'\n end\n prev = last\n last = line['message']['usage'].to_i\n end\n end\n if data and data.first\n if data.first.first != start_date\n data.first[0] += start_date\n end\n end\n summary_file = self.get_summary_file\n File.open( summary_file, 'w' ) do |file|\n file.write( JSON.pretty_generate( data ))\n end\n File.open( summary_file.gsub( 'summary', 'daily' ), 'w' ) do | file |\n file.write daily.to_json.to_s\n end\n File.open( summary_file.gsub( 'summary', 'daily.' + d ), 'w' ) do | file |\n file.write daily.select { |key| key == daily.keys.last }.to_json.to_s\n end\n end",
"def generate_sleep_freq(sleep_mins)\n freq = Hash.new(0)\n sleep_mins.each { |m| freq[m] += 1 }\n freq\nend",
"def update_dates ( date )\n date = Date.parse(date)\n if !DATES[date].nil?\n DATES[date] += 1\n end\nend",
"def get_writing_stats_in_week( in_date )\n \n # Initialize Hash\n stats = { \"total\" => 0, \"editing\" => 0, \"writing\" => 0, \"words\" => 0 }\n \n # Get the current day of week\n dayCurrent = in_date.wday().to_i\n \n # Get date at the start of the week\n timeStart = Time.utc( in_date.year, in_date.month, in_date.day )\n timeStart = timeStart - 24 * 60 * 60 * dayCurrent\n \n # Get date at the end of the week\n timeEnd = Time.utc( in_date.year, in_date.month, in_date.day )\n timeEnd = timeEnd + 24 * 60 * 60 * ( 7 - dayCurrent )\n \n # Loop through entries and increment totals\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n user_entries.each do |entry|\n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n timeEntry = Time.utc( entry.starttime.year, entry.starttime.month, entry.starttime.day, entry.starttime.hour, entry.starttime.min )\n \n if( timeStart.to_i <= timeEntry.to_i && timeEnd.to_i >= timeEntry.to_i )\n stats[ \"words\" ] += entry.words\n stats[ \"total\" ] += entry.hours + entry.minutes.to_f / 60\n if entry.editing\n stats[ \"editing\" ] += entry.hours + entry.minutes.to_f / 60\n else\n stats[ \"writing\" ] += entry.hours + entry.minutes.to_f / 60\n end \n end\n end\n \n return stats\n \n end",
"def is_repeated_day(day_int)\n if day_int.is_a?(Date)\n day_int = day_int.wday\n end\n\n day_int = DAY_VALUES[day_int]\n act_int = repeated\n\n if act_int.nil? or day_int.nil?\n return false\n end\n\n return (act_int % day_int) == 0\n \n end",
"def countingValleys(n, s)\n valleys, counter, flag, prev_flag = 0, 0, \"sea level\", \"\"\n s.chars.each do |x|\n prev_flag = flag\n if x == \"U\" \n counter += 1 \n elsif x == \"D\"\n counter -= 1\n end\n flag = \"valley\" if counter < 0\n flag = \"sea level\" if counter == 0 \n if prev_flag == \"valley\" && flag == \"sea level\"\n valleys += 1\n elsif prev_flag == \"sea level\" && flag == \"valley\"\n valleys += 1\n end\n end\n valleys/2\nend",
"def calculate_days_hours_minutes(output)\n return unless output =~ /(\\d+) day(?:s|\\(s\\))?,?\\s+(\\d+):-?(\\d+)/\n\n SECS_IN_A_DAY * Regexp.last_match(1).to_i +\n SECS_IN_AN_HOUR * Regexp.last_match(2).to_i +\n SECS_IN_A_MINUTE * Regexp.last_match(3).to_i\n end",
"def timer_checkpoints\n t = self.time_remaining\n if @timer_checkpoint_hash[30] < 3 && t <= 40\n @timer_checkpoint_hash[30] += 1\n tab; \"#{@time_remaining} seconds left.\\n\".typing\n elsif @timer_checkpoint_hash[120] == 0 && t.between?(60, 140)\n @timer_checkpoint_hash[120] += 1\n tab; \"Cutting it close, #{codename}\".typing\n elsif @timer_checkpoint_hash[180] == 0 && t.between?(140, 180)\n @timer_checkpoint_hash[180] += 1\n tab; \"3 minutes. Finish the job.\\n\".typing\n elsif @timer_checkpoint_hash[240] == 0 && t.between?(200, 240)\n @timer_checkpoint_hash[240] += 1\n tab; \"Doing good. 4 minutes left.\\n\".typing\n end\n end",
"def letter_count limit\n letters = Hash[0, 0, 1, 3, 2, 3, 6, 3, 10, 3, 4, 4, 5, 4, 9, 4, 3, 5, 7, 5, 8, 5, 40, 5, 50, 5, 60, 5, 11, 6, 12, 6, 20, 6, 30, 6, 80, 6, 90, 6, 15, 7, 16, 7, 70, 7, 13, 8, 14, 8, 18, 8, 19, 8, 17, 9]\n words = Hash[\"and\", 3, \"hundred\", 7, \"thousand\", 8]\n num = 1\n digits = []\n count = 0\n i = 0\n\n letters.each do |k, v|\n # puts \"#{k}, #{v}\"\n end\n\n # puts \"HASH: #{letters[13]}\"\n\n\n while num <= limit\n count_for_word = 0\n\n if num > 9\n digits = num.to_s.reverse.split(//)\n \n # puts \"DIGITS[0]: #{digits[0]}, #{i}\"\n \n if digits[1] == \"1\"\n count_for_word = letters[[digits[0], digits[1]].join.reverse.to_i]\n\n else\n count_for_word = letters[digits[0].to_i] +\n letters[digits[1].to_i * 10]\n end\n count_for_word += letters[digits.fetch(2, 0).to_i] +\n letters[digits.fetch(3, 0).to_i]\n\n if digits[2] != nil && digits[2] != \"0\"\n # if letters[[digits[0], digits[1]].join.reverse.to_i] != 0 \n if [digits[0], digits[1]].join.reverse != \"00\" \n puts count_for_word\n\n count_for_word += words[\"hundred\"] + words[\"and\"]\n else\n count_for_word += words[\"hundred\"]\n end\n end\n\n puts count_for_word\n\n if digits[3] != nil\n count_for_word += words[\"thousand\"]\n end\n\n else\n count_for_word = letters[num].to_i\n end\n\n count += count_for_word\n num += 1\n end\n\n count \nend",
"def word_counter(mots,dictionnaire)\n words = word_counter.downcase.split(\" \")\n #puts words => [\"howdy\",....\"going?\"]\n frequencies = Hash.new(0)\n words.each{ |mot| \n if mot.include?(dictionnaire) #si le mot est dans le dictionnaire\n frequencies[mot] += 1 #si oui\n end\n \n }\n puts frequencies\nend",
"def get_data_words_this_week\n words_per_day = Array.new( 7, 0 )\n \n # Get the current day of week\n dateCurrent = DateTime.now\n dayCurrent = dateCurrent.wday().to_i\n \n # Get date at the start of the week\n timeStart = Time.utc( dateCurrent.year, dateCurrent.month, dateCurrent.day )\n timeStart = timeStart - 24 * 60 * 60 * dayCurrent\n \n # Get date at the end of the week\n timeEnd = Time.utc( dateCurrent.year, dateCurrent.month, dateCurrent.day )\n timeEnd = timeEnd + 24 * 60 * 60 * ( 7 - dayCurrent )\n \n # Loop through entries and increment totals\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n user_entries.each do |entry|\n if( entry.words.nil? || entry.hours.nil? || entry.minutes.nil? )\n next \n end\n \n dayEntry = entry.starttime.wday().to_i\n timeEntry = Time.utc( entry.starttime.year, entry.starttime.month, entry.starttime.day, entry.starttime.hour, entry.starttime.min )\n \n if( timeStart.to_i <= timeEntry.to_i && timeEnd.to_i >= timeEntry.to_i )\n words_per_day[dayEntry] += entry.words\n end\n end\n \n # Assemble Data String\n data_string = \"\"\n \n (0..(words_per_day.length - 1)).each do |i|\n data_string = data_string + words_per_day[i].to_s\n if( i < words_per_day.length - 1 )\n data_string = data_string + \",\"\n end\n end\n \n return data_string\n end",
"def create_new_report_hash\n new_report_hash = {}\n\n puts \"Great! Now lets create a report about the sighting!\"; sleep(1)\n\n puts \"In what month (MM) did the sighting take place.\"\n new_report_hash[:month] = gets.chomp\n\n puts \"Please title your report.\"\n new_report_hash[:title] = gets.chomp\n\n puts \"What city did you see the animal in?\"\n new_report_hash[:city] = gets.chomp\n\n new_report_hash\nend",
"def in_words(t)\n # to get the number of minutes subtract out days\n # Then calculate hours and subtract those out to get minutes.\n s = []\n days = t.round(4).to_i\n s << \"#{ days } day(s)\" unless days == 0\n \n remainder = t - days\n minutes = remainder * 1440.0 # number of minutes in a day\n hours = (minutes / 60.0).round.to_i\n s << \"#{ hours } hours\" unless hours == 0\n \n # round to 2 decimal places and call it\n minutes = (minutes - hours * 60).round\n s << \"#{ minutes } minutes\" unless minutes == 0\n \n if s.empty?\n s << \"now\"\n else\n s << \"ago\"\n end\n \n s.join(\" \")\n end",
"def get_daily(user)\n weeks = get_calendar(user)\n ret = {}\n count = 0\n weeks.each do |k|\n k.children.each do |day|\n val = day.attribute('data-count').value.to_i\n ret[count] = val\n count += 1\n end\n end\n ret\n end",
"def dictionary_attack()\n puts \"Entered Attack\"\n $encoded.each do |i|\n #Process clock time looks at the monotonic clock which maximizes accuracy and prevents time skips (each call gets the system time)\n starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n #Querries the hash map to find the given element of the encoded passwords\n hash = $digest[i]\n elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - starting\n $f.write(\"The password for the hash value #{i} is #{hash}, it takes the program #{elapsed} sec to recover this password.\\n\")\n end\nend",
"def total_cal\n weight = @snacker.favorite_snacks.reload\n weight.each_with_index do |fave, i|\n recipe = Recipe.find(fave.recipe_id)\n puts \"#{i+1}. #{recipe.name} #{recipe.calories}\"\n sleep(1.0)\n end\n self.snacker_menu\n end",
"def updateStats\n \n totalDays = 0\n\n @week.days.each do |day|\n if day.wr\n totalDays += 1\n updateTempValues(day.oTotal, day.dTotal)\n end\n end\n\n assignStats(totalDays)\n\n end",
"def clockHandler(userInfo)\n @adjusted_time = Time.now + @offset\n \n # @label.text = \"#{self.current_tod_string} \"\n @device_clock_label.text = \"Device Clock #{current_tod_string}\"\n # puts \"#{current_tod_string_with_offset} #{countdown_time}\"\n @adjusted_clock_label.text = \"#{current_tod_string_with_offset} #{countdown_time}\"\n @offset_label.text = \"Offset #{@offset.round(1)}\"\n # @countdown_label.text = \"Countdown: #{start_time_diff}\"\n \n \n if NSUserDefaults.standardUserDefaults[\"computerEnabled\"] == true\n @calc_controller.update_calcs\n end\n if NSUserDefaults.standardUserDefaults[\"calcMileageEnabled\"] == true\n @calc_controller.calc_model.update_units_per_minute\n end\n end",
"def get_count_text\n cs = get_condition_string\n approx_text = \"\"\n unless params[:slow_count] \n approx_text = \"Approximate/cached values! \"\n total_count = count_fast()\n now_count = count_fast(cs)\n else\n total_count = count_fast()\n now_count = count_slow(cs)\n end \n\n ret = \"\"\n if total_count\n ret += approx_text + \"There are total #{pluralize(total_count,'record')}.\"\n end \n if now_count\n ret += \" You have selected #{pluralize(now_count,'record')}\"\n end\n if total_count and total_count > 0 and now_count\n ret += \" (#{((now_count.to_f / total_count.to_f * 1000).round().to_f/10)}%)\" \n end\n return ret\n end",
"def add_days(count)\n 24*60*60*count.to_i\n end",
"def solution(log)\n return 0 if log.strip.empty?\n \n total_cents = 0\n \n book = Hash.new(0)\n \n log.each_line do |line|\n duration, phone_number = line.chomp.split(\",\", 2)\n\n h, m, s = time.split(\":\", 3).map(&:to_i)\n total_sec = h * 3600 + m * 60 + s\n \n book[phone_number] += total_sec\n end\n \n max_key = book.max_by{ |k, v| v }[0]\n \n phones.delete(max_key)\n \n phones.each do |phone, total_sec|\n if total_sec < 300\n res += total_sec * 3\n else\n res += total_sec / 60 * 150\n res += 150 if total_sec % 60 != 0\n end\n end\n \n res\nend",
"def speak(number_of_times)\n\t\tindex = 0\n\t\tuntil number_of_times == index \n\t\t\tputs \"Ho, ho, ho!, Haaaappy holidays!\"\n\t\t\tindex +=1\n\t\tend \n\tend",
"def dice_outcomes (number_dice, number_rolls)\n outcomes_hash = Hash.new\n (number_dice..number_dice*6).to_a.each do |x|\n outcomes_hash[x] = 0\n end\n \n number_rolls.times do\n roll_outcome = roll_dice(number_dice)\n outcomes_hash[roll_outcome] = outcomes_hash[roll_outcome] + 1\n end\n\n outcomes_hash.each do |key, value|\n if key<10\n puts \"#{key}: #{'#'*value} \"\n else\n puts \"#{key}: #{'#'*value} \"\n end\n end \n return outcomes_hash\nend",
"def load_showtimes\n available_times = {\n 10.45 => \"10:45am\", 11.00 => \"11:00am\", 11.15 => \"11:15am\", 11.30 => \"11:30am\",11.45 => \"11:45am\", 12.00 => \"12:00pm\", 12.15 => \"12:15pm\", 12.30 => \"12:30pm\", 12.45 => \"12:45pm\", \n 13.00 => \"1:00pm\", 13.15 => \"1:15pm\", 13.30 => \"1:30pm\",13.45 => \"1:45pm\",14.00 => \"2:00pm\",14.15 => \"2:15pm\",14.30 => \"2:30pm\", 14.45 => \"2:45pm\", 15.00 => \"3:00pm\",15.15 => \"3:15pm\",16.00 => \"4:00pm\", 16.15 => \"4:15pm\", 16.30 => \"4:30pm\", 16.45 => \"4:45pm\", 17.00 => \"5:00pm\",17.15 => \"5:15pm\", 17.30 => \"5:30pm\",17.45 => \"5:45pm\",18.00 => \"6:00pm\", 18.15 => \"6:15pm\", 18.30 => \"6:30pm\", 18.45 => \"6:45pm\", 19.00 => \"7:00pm\", 19.15 => \"7:15pm\", 19.30 => \"7:30pm\", 19.45 => \"7:45pm\", 20.00 => \"8:00pm\", 20.15 => \"8:15pm\", 20.30 => \"8:30pm\", 20.45 => \"8:45pm\", 21.00 => \"9:00pm\", 21.15 => \"9:15pm\", 21.30 => \"9:30pm\", \n 22.00 => \"10:00pm\", 22.15 => \"10:15pm\", 22.30 => \"10:30pm\", 22.45 => \"10:45pm\", 23.00=> \"11:00pm\", 23.15 => \"11:15pm\", \n 23.30 => \"11:30pm\", 23.45 => \"11:45pm\",24.00 => \"12:00am\"}\n\n\n\n showtimes = [10.45]\n\n if self.runtime >= 1.33 && self.runtime <= 1.5\n showtimes << 12.30 << 14.00 << 15.30 << 17.00 << 18.30 << 20.00 << 21.30 << 23.00\n\n elsif self.runtime >= 1.5 && self.runtime <= 2 \n showtimes << 13.00 << 15.00 << 17.00 << 19.00 << 21.00 << 23.00 << 24.00\n\n elsif self.runtime >= 2 && self.runtime <= 3\n showtimes << 14.15 << 17.15 << 21.15 << 24.00\n end \n\n\n\n showtimes.map! do |time|\n time = Showing.create!(military_time: time.to_f, time_string: available_times[time], movie: self)\n end\n\n self.showings = showtimes\n end",
"def task_count_instances\n #ex_count = find_exception_count\n if self.occurrence_type.eql?(\"count\")\n count = self.count.to_i\n return count\n elsif self.occurrence_type.eql?(\"until\")\n if self.start_date and self.until\n case(self.repeat)\n when \"DAI\" then daily_count\n when \"WEE\" then weekly_count\n when \"MON\" then monthly_count\n when \"YEA\" then yearly_count\n end\n end\n else\n 1 \n end\n end",
"def time_sums(n)\n times = []\n hr = 0\n until hr == 24\n min = 0\n until min == 60\n min_sum = min.to_s.split('').map(&:to_i).reduce(&:+)\n hr_sum = hr.to_s.split('').map(&:to_i).reduce(&:+)\n sum = min_sum + hr_sum\n\n minString = min.to_s.split('')\n hrString = hr.to_s.split('')\n\n minString.unshift('0') until minString.length == 2\n hrString.unshift('0') until hrString.length == 2\n\n times << hrString.join('') + \":\" + minString.join('') if sum == n\n\n min += 1\n end\n hr += 1\n end\n times\nend",
"def countingValleys(n, s)\n elevation = 0\n valley_count = 0\n steps = s.split('')\n steps.each do |s|\n if s == \"U\"\n elevation += 1\n elsif s == \"D\" && elevation == 0\n valley_count += 1\n elevation -= 1\n elsif s == \"D\"\n elevation -= 1\n end\n end\n\nreturn valley_count\nend",
"def execute!(frequencies)\n last_key_read = nil\n cumulative_value = 0.0\n\n # for all keys except those ending with a space (which are a special case)\n frequencies.select {|ok| ok[1] != ' '}.keys.sort.each do |key|\n if last_key_read != nil && last_key_read[0] != key[0]\n cumulative_value = 0.0\n end\n\n cumulative_value += frequencies[key]\n\n # simple round-off to 1.0 to prevent any gaps\n cumulative_value = roundoff(cumulative_value)\n\n frequencies[key] = cumulative_value\n last_key_read = key\n end\n\n # now take care of the special case of keys ending with a space\n cumulative_value = 0.0\n frequencies.select {|ok| ok[1] == ' '}.keys.sort.each do |key|\n cumulative_value += frequencies[key]\n\n # simple round-off to 1.0 to prevent any gaps\n cumulative_value = roundoff(cumulative_value)\n\n frequencies[key] = cumulative_value\n end\n end",
"def show_total_unattendance_number\n puts 'show_total_unattendance_number'\n total_unattendance_number = @data.inject (0) do |mem, e|\n num_exams = e.size - 1.0\n mem + e.last(num_exams).count('00')\n end\n puts total_unattendance_number.to_s\n end",
"def hash_in_sec(hash)\n\thash_in_sec = hash\n\thash_in_sec.each { |name, time| hash_in_sec[name] = to_sec(time) }\n\thash_in_sec\nend",
"def get_writing_stats\n \n # Initialize Hash\n stats_seven_days = { \"total\" => 0, \"editing\" => 0, \"writing\" => 0, \"words\" => 0 }\n stats_thirty_days = { \"total\" => 0, \"editing\" => 0, \"writing\" => 0, \"words\" => 0 }\n stats_all_time = { \"total\" => 0, \"editing\" => 0, \"writing\" => 0, \"words\" => 0 }\n stats_this_week = { \"total\" => 0, \"editing\" => 0, \"writing\" => 0, \"words\" => 0 }\n writing_stats = { \"seven_days\" => stats_seven_days, \"thirty_days\" => stats_thirty_days, \"all_time\" => stats_all_time, \"this_week\" => stats_this_week }\n \n # Get all entries from this user\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"] )\n \n # Get Week Stats\n stats_week = get_writing_stats_in_week( DateTime.now )\n writing_stats[\"this_week\"] = stats_week\n \n # Get 7-Day Stats\n stats_seven = get_writing_stats_since( 7 )\n writing_stats[\"seven_days\"] = stats_seven\n\n # Get 30-Day Stats\n stats_thirty = get_writing_stats_since( 30 )\n writing_stats[\"thirty_days\"] = stats_thirty\n \n # Get All-Time Stats\n stats_alltime = get_writing_stats_since( -1 )\n writing_stats[\"all_time\"] = stats_alltime \n \n return writing_stats \n end",
"def print_body(day2, k)\n print \"|\"\n count_events = @ary_event.count do |event|\n event.start_date.day == day2\n end\n if count_events == 1\n ary_time_and_name = convert_time_and_name(@ary_event.find{ |event| event.start_date.day == day2})\n temp_str = ary_time_and_name[k]\n if temp_str.nil? == false\n print temp_str + \" \" * (9 - temp_str.length)\n else\n print \" \" * 9\n end\n elsif count_events >= 2 && k <= 1\n if k == 0\n print count_events.to_s + \" events \"\n else\n print \"scheduled\"\n end\n else\n print \" \" * 9\n end\n end",
"def countingValleys(n, s)\n level = valleys = 0\n s.each_char do |step|\n valleys +=1 if level==0 && step =='D'\n level = step == 'D' ? level-1 : level+1\n end\n valleys\nend",
"def f(n,d) # returns total number of times d shows up in range 0..n including n\n total = 0\n (n+1).times do |k|\n total += k.to_s.count(d.to_s)\n end\n return total\nend",
"def checkcounter\n begin\n puts \"COUNTER\"\n puts @session[:shopname]\n puts params[:entry][:ShopName]\n puts params[:entry][:Date]\n #params[:entry][:ShopName]=@session['shop']\n \n if (params[:entry][:ShopName]==\"\" or params[:entry][:ShopName]==nil) and @session[:shopname]==nil #IF SHOPID NOT SELECTED THEN \n puts \"in ERROR\"\n session[:errmsg]=\"Please select ShopID\"\n \n render :update do |page|\n page.redirect_to url_for(:controller=>'entries', :action=>'new')\n end \n else\n puts \"in else\"\n puts params[:entry][:ShopName]\n if(params[:entry][:ShopName]==\"\" and @session[:shopname]!=nil)\n params[:entry][:ShopName]=@session[:shopname]\n puts \"in if@@@@@@@@@@\"\n end\n @mcount=Machine.count([\"ShopName=?\",params[:entry][:ShopName]]) #MACHINE COUNT WITH GIVEN SHOPID\n @date=Date.parse(params[:entry][:Date])\n puts @date\n @c =Entry.count([\"ShopName=? and Date=? \",params[:entry][:ShopName],@date]) #ENTRY COUNT WITH GIVEN SHOPID AND DATE\n puts \"mcount#{@mcount}\"\n puts \"entrycount#{@c}\"\n if(@mcount==@c and @mcount!=0 and @c!=0)\n puts \"total matched hghghg\" \n @pcount=Previousrecord.count([\"ShopName=?\",params[:entry][:ShopName]]) #PREVIOUSRECORD COUNT WITH SELECTED SHOPID\n puts @pcount\n @session['shop']=params[:entry][:ShopName]\n @session['date']=params[:entry][:Date]\n \n if(@pcount==0)\n @session['shop']=params[:entry][:ShopName]\n @session['date']=params[:entry][:Date]\n render :update do |page|\n page.redirect_to url_for(:controller=>'previousrecords', :action=>'new')\n end \n else\n @date=Date.parse(params[:entry][:Date])\n @ccount=Countercollection.count([\"ShopName=? and Date=?\",params[:entry][:ShopName],@date])\n puts \"Counter count\"\n puts @ccount\n if(@ccount==0)\n @p=Previousrecord.find_first([\"ShopName=?\",params[:entry][:ShopName]]) \n puts \"values for COLUNTER\"\n puts @p.Xcredit\n puts @p.Xcash\n puts @date\n @session['credit']=@p.Xcredit\n @session['cash']=@p.Xcash\n #@session['obal']=@p.Xcredit.to_i+@p.Xcash.to_i\n @session['obal']=@p.Openingbal\n @session['date']=@date\n @session['sname']=params[:entry][:ShopName] \n render :update do |page|\n page.redirect_to url_for(:controller=>'countercollections', :action=>'new')\n end \n \n else\n @date=Date.parse(params[:entry][:Date])\n \n @counter=Countercollection.find_first([\"ShopName=? and Date=?\",params[:entry][:ShopName],@date])\n \n puts \"CODE FOR EDITING COUNTER COLLECTION\"\n @session['sname']=@counter.ShopName\n @session['obal']=@counter.Openingbal\n @session['credit']=@counter.Credit\n @session['cash']=@counter.Cash\n @session['total1']=@counter.Cash.to_i+@counter.Exp.to_i+@counter.HC.to_i+@counter.Credit.to_i+@counter.Short_Ext.to_i\n @session['total2']=@counter.Openingbal.to_i+@counter.KEY1.to_i+@counter.KEY2.to_i+@counter.KEY3.to_i+@counter.KEY4+@counter.Outstanding.to_i\n \n @session['id']=@counter.id\n render :update do |page|\n page.redirect_to url_for(:controller=>'countercollections', :action=>'edit',:id=>@counter.id)\n end \n end\n end\n else\n if(@mcount==0 and @c==0)\n session[:errmsg]=\"NO MACHINES MAPPED TO THE SELECTED SHOP\"\n render :update do |page|\n page.redirect_to url_for(:controller=>'entries', :action=>'new')\n end \n else\n \n render :update do |page|\n page.redirect_to url_for(:action=>'confirm')\n end \n end\n end\n end \n rescue Exception=>ex\n puts ex.message \n end\nend",
"def compute_total_seconds\n exercise_seconds = exercise_rows.inject(0) do |sum, row|\n sum + row.compute_total_seconds # (default: exclude pause from sum)\n end\n if exercise_seconds == 0 # Found zero esteemed duration (excluding pause) ?\n if start_and_rest > 0\n start_and_rest * times + (pause * times)\n elsif distance > 0\n (pause + ExerciseRow.esteem_time_in_seconds(distance)) * times\n else\n pause * times\n end\n else\n exercise_rows.inject(0) do |sum, row|\n sum + row.compute_total_seconds(true) # (include pause)\n end * times + (pause * times)\n end\n end",
"def dumptotal\n # expire > 15minute dumps\n @dumptrack.reject! { |r| (r[3] + 900) < Time.now }\n total = 0\n @dumptrack.each do |t|\n if t[2] == \"bid\"\n total += t[0].to_i\n elsif t[2] == \"ask\"\n total -= t[0].to_i\n else\n debug(\"failed to match #{t[2]} trade type for total.\")\n end\n end\n # get 5 minute\n alert_msg = \"Sum of whale action; In the last 15 minutes:\"\n add_message(\"*** 15 minute whale action is over the 375 btc threshold! #{total} BTC (alert sleep timer set 1000s)\") if total.abs >= 375\n if total > 0\n return alert_msg + \" + #{total.abs} BTC (bought)\"\n elsif total < 0\n return alert_msg + \"- #{total.abs} BTC (sold)\"\n else\n return \"Last 15 minutes: nothing happening..\"\n end\n end",
"def evaporator(content, evap_per_day, threshold)\n days = 0\n threshold_amount = threshold.fdiv(100) * content\n until content < threshold_amount do\n content -= evap_per_day.fdiv(100) * content\n days += 1\n end\n days\nend",
"def success\n @log[Date.today.iso8601] = 0\n\n puts \"Well done, #{@username}! You haven't smoked for #{@log.count { |value| value = 0 }} days! \"\n end",
"def compute_date_stats tweets\n dates = {}\n tweets.each do |x|\n rec = dates[x.created_at.to_date] ||= 0\n rec+=1\n dates[x.created_at.to_date] = rec\n end\n dates\n end",
"def get_days_last_use\n days_last_use = 9999\n \n # Get all entries from this user\n user_entries = Entry.find( :all, :conditions => [\"userid = #{id}\"], :order => \"starttime desc\" )\n \n if !user_entries.empty?\n timestart = user_entries[0][:starttime]\n timenow = Time.now\n \n dseconds = timenow.to_i - timestart.to_i\n days_last_use = dseconds / ( 60 * 60 * 24 )\n end\n \n return days_last_use\n end",
"def days_since_transaction\n\t\tif @ledger.empty?\n\t\t\treturn 1\n\t\telse\n\t\t\tlast_date = @ledger.keys.last \n\t\tend\n\t\tdays = Date.today - last_date\t\t\n\tend",
"def week_3\n wait(0)\n say \"Start your first short run.\"\n count_down(90, 'running')\n say \"Stop running now. You have 1 long run and two short ones left.\"\n count_down(90, 'walking')\n\n say \"Start the first long run now.\"\n count_down(3*60, 'running')\n say \"Stop running now. You have a short run and a long run left.\"\n count_down(3*60, 'walking')\n\n say \"Start your second short run.\"\n count_down(90, 'running')\n say \"Stop running. You have 1 more long run left.\"\n count_down(90, 'walking')\n\n say \"Start your last run now.\"\n count_down(3*60, 'running')\n say \"Stop running. After this walk, you will have finished.\"\n count_down(3*60, 'walking')\n\n say \"Great! You've finished for today.\"\nend",
"def set_repeated(days)\n # must pass in an array\n if days.class != Array\n puts \"days must be an array\"\n return nil\n end\n\n # convert the array values\n count = 1\n days.each do |day|\n result = DAY_VALUES[day]\n if !result.nil?\n count = count * result\n end\n end\n\n # set the repeated attribute\n if count != 1\n self.repeated = count\n self.save!\n return count\n else\n return nil\n end\n end",
"def num_repeats(string)\n tallies = {}\n\n (0..string.length - 1).each do |idx|\n letter = string[idx]\n tallies[letter] ||= 0\n tallies[letter] += 1\n end\n\n count_tallies_greater_than_two(tallies)\nend",
"def countingValleys(n, s)\n # check constraints\n # do steps match string length\n n_does_not_equal_s_length = n != s.scan(/[UD]/).count\n steps_are_invalid = n < 2 && n > 10**6\n\n returned_to_sea_level_count = 0\n sea_level = 0\n\n if (steps_are_invalid || n_does_not_equal_s_length)\n return 0\n end\n\n # s.scan(/(DU{1}U{2,}UD{1})/).count\n s.split('').each do |l|\n previous_sea_level = sea_level\n\n if l == 'U'\n sea_level += 1\n elsif l == 'D'\n sea_level -= 1\n end\n\n if sea_level == 0 && previous_sea_level < 0\n returned_to_sea_level_count += 1\n end\n end\n\n returned_to_sea_level_count\nend",
"def number_of_events_expressed_at(login=nil)\n count_by_frbr(login, :presented_at, :how_many_events?) \n end",
"def get_frequency\n PROMPT.select(\"\\nHow often would you like to do this task?\".light_white) do |menu|\n menu.choice 'Just once'.light_white, :once\n menu.choice 'Every Minute'.light_white, :every_minute\n menu.choice 'Hourly'.light_white, :hourly\n menu.choice 'Daily'.light_white, :daily\n menu.choice 'Weekly'.light_white, :weekly\n menu.choice 'Monthly'.light_white, :monthly\n menu.choice 'Yearly'.light_white, :yearly\n end\n end",
"def build_hash hash, date, worked_hours, departur_hour\n hash[\"#{date.strftime(\"%F\")}\"] = {total: worked_hours, arrival_hour: date, departur_hour: departur_hour}\n hash[:total_worked] += worked_hours\n hash[:total_days] += 1\n return hash\n end",
"def number_rides(whatever)\n whatever.each do |key,value|\n y = \"Driver #{key} has #{(value.length)} ride(s).\"\n puts y\n end\nputs\nend",
"def time_days() (@time_end.jd - @time_start.jd) + 1; end",
"def create_hourly_report(url)\n @total_serv_time = 0\n @time_spent_g = 0\n @time_spent_p = 0\n @user_list = []\n @g_count = 0\n @p_count = 0\n @n = 1\n puts \"24 Hour Report for #{url}\"\n puts \"---------------------------------------------------------------------------------------------\"\n puts \"TH HOUR---# USER---# GET---# POST---TOTAL_TIME_GET(ms)---TOTAL_TIME_POST(ms)---TOTAL_TIME(ms)\"\n puts \"---------------------------------------------------------------------------------------------\"\n for n in 1..24\n $all_user_data.each do |k,v|\n if v[:th_hour] == n && !v[:uri].to_s.string_contains(url).nil? \n @total_serv_time += v[:time].to_i\n if v[:method] == 'G'\n @time_spent_g += v[:time].to_i\n @g_count += 1 \n end\n if v[:method] == 'P'\n @time_spent_p += v[:time].to_i\n @p_count += 1 \n end\n @user_list << v[:user].to_s\n end \n end\n #puts \"#{n}TH HOUR---#{@user_list.uniq.length} users---#{@g_count} GET REQs---#{@p_count} POST REQs---#{@time_spent_g}ms in GET---#{@time_spent_p}ms in POST---#{@total_serv_time}ms in Total\"\n puts \"#{n}TH HOUR---#{@user_list.length} users---#{@g_count} GET REQs---#{@p_count} POST REQs---#{@time_spent_g}ms in GET---#{@time_spent_p}ms in POST---#{@total_serv_time}ms in Total\"\n #pp @@user_list.uniq\n @total_serv_time = 0\n @time_spent_g = 0\n @time_spent_p = 0\n @g_count = 0\n @p_count = 0\n @user_list.clear\n end\n end",
"def pass_count(days=30)\n latest_executions(days).where(success: true).count\n end",
"def tiredness (hours)\n if hours == 'ok'\n @rested += 1\n elsif hours == 'bad'\n @rested -= 1\n elsif hours == 'shit'\n @rested -= 5\n elsif hours == 'amazing'\n @rested += 5\n end\n end",
"def get_week_daily_loads(weeks_surveys)\n daily_hash = {\"Monday\":0, \"Tuesday\":0, \"Wednesday\":0, \"Thursday\":0, \"Friday\":0, \"Saturday\":0, \"Sunday\":0}\n weeks_surveys.each do |survey|\n survey_day_key = get_day_of_week(survey.completed_time)\n daily_hash[survey_day_key] += survey.session_load\n end\n return daily_hash.values\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 weekday(days)\nt = Date.today\narr = []\n days.times do\n arr << \"ok\" if t.saturday? || t.sunday?; t = t - 1\n end\n arr.count\nend",
"def days(n)\n n * 3600 * 24\nend",
"def days_validation\n @start_cycle = @vote_setting.start_cycle.to_date \n @end_cycle = @vote_setting.end_cycle.to_date\n @days_count = (@end_cycle - @start_cycle).round\n end",
"def gatherInfo()\n\tputs \"Where did you drive to?\"\n\tputs \"331, prp, para, portsmouth, tval, or town?\"\n\t\tdest = gets.chomp.downcase.to_sym\n\t\t\tif $log[dest].nil?\n\t\t\t\tputs \"How many times did you make this trip?\"\n\t\t\t\ttimes = gets.chomp.to_i\n\t\t\t\t$log[dest] = times\n\t\t\telse\n\t\t\t\tputs \"destination already exists,would you like to update instead?\"\n\t\t\t\tneedupdate = gets.chomp\n\t\t\t\tif needupdate == \"yes\"\n\t\t\t\t\tupdate\n\t\t\t\telse\n\t\t\t\tend\n\t\t\tend\nend",
"def confirm_rainfall(rainfall)\r\n days = self.get_days(rainfall[1],rainfall[2])\r\n confirm_loop = true\r\n while confirm_loop\r\n puts \"Rainfall collection for #{rainfall[0]} in #{rainfall[2]} of #{rainfall[1]} was:\"\r\n print \"\\nDay: \"\r\n # display rainfall days bewteen 1 to 12\r\n for i in 1..11\r\n print \"#{i}\".rjust(5)\r\n end\r\n puts \"\"\r\n print \" mm: \"\r\n for i in 3..13\r\n print \"#{rainfall[i]}\".rjust(5)\r\n end\r\n\r\n # display rainfall days bewteen 13 to 24\r\n print \"\\n\\n\"\r\n print \"Day: \"\r\n for i in 12..22\r\n print \"#{i}\".rjust(5)\r\n end\r\n print \"\\n\"\r\n print \" mm: \"\r\n for i in 14..24\r\n print \"#{rainfall[i]}\".rjust(5)\r\n end\r\n\r\n # display rainfall days bewteen 25 to EOM\r\n print \"\\n\\n\"\r\n print \"Day: \"\r\n for i in 23..days\r\n print \"#{i}\".rjust(5)\r\n end\r\n print \"\\n\"\r\n print \" mm: \"\r\n for i in 25..days+2\r\n print \"#{rainfall[i]}\".rjust(5)\r\n end\r\n print \"\\n\\n\"\r\n puts \"Do you wish to change the Rainfall values? \"\r\n puts \"If not then hit Enter, otherwise enter the Day number.\"\r\n update_element = $stdin.gets.chomp.to_i\r\n if update_element == 0 # When using gets.chomp.to_i a nil return is 0\r\n # place details into CSV file\r\n confirm_loop = false\r\n else\r\n puts \"The recorded rainfall for day #{update_element} was #{rainfall[update_element+2]}. \"\r\n puts \"Please enter the new recording:\"\r\n rainfall[update_element+2] = $stdin.gets.chomp\r\n end\r\n end # end for confirm_loop\r\n return rainfall\r\n\r\n end",
"def total_by_time_period(options = {})\n response = options[:response] || {}\n search_options = {}\n search_options[:query] = options[:query] || ''\n search_options[:bucket] = options[:bucket] || 'day'\n search_options[:fromDate] = Gnip.format_date(options[:date_from]) if options[:date_from]\n search_options[:toDate] = Gnip.format_date(options[:date_to]) if options[:date_to]\n search_options[:next] = options[:next_cursor] if options[:next_cursor]\n\n url = [counts_url, search_options.to_query].join('?')\n call_done = 0\n\n begin\n gnip_call = self.class.get(url, basic_auth: @auth)\n\n parsed_response = gnip_call.parsed_response\n parsed_response = (parsed_response || {}).with_indifferent_access\n\n raise gnip_call.response.message unless parsed_response.present?\n\n if parsed_response[:error].present?\n response = { results: [], next: nil, error: parsed_response[:error][:message], code: gnip_call.response.code.to_i, calls: (response[:calls] || 0) + 1 }\n else\n call_done = 1 # we have received a valid response\n parsed_response[:results].each_with_index do |item, i|\n parsed_response[:results][i] = item.merge(timePeriod: DateTime.parse(item[:timePeriod]).to_s)\n end\n response = { results: (response[:results] || []) + parsed_response[:results], next: parsed_response[:next], code: gnip_call.response.code.to_i, calls: (response[:calls] || 0) + 1 }\n end\n rescue StandardError => e\n response = { results: [], next: nil, error: e.message, code: 500, calls: (response[:calls] || 0) + call_done }\n end\n # If the next cursor is not present we fetched all the data\n # It happens that twitter returns the same cursor, in that case we stop\n return response if !parsed_response[:next].to_s.present? || (parsed_response[:next].to_s.present? && parsed_response[:next] == search_options[:next])\n\n total_by_time_period(query: search_options[:query],\n date_from: search_options[:fromDate],\n date_to: search_options[:toDate],\n bucket: search_options[:bucket],\n next_cursor: parsed_response[:next],\n response: response)\n end",
"def days() 24 * hours end",
"def unify_meals_per_day\n user = self\n meals = {}\n sorted_food = user.patient_foods.order(meal_time: :desc)\n unique_days = sorted_food.select(:meal_time).uniq\n unique_days.each do |date|\n begining_day = date.meal_time.to_date.to_datetime\n end_day = (date.meal_time + 1.day).to_date.to_datetime - 1.second\n meals[date.meal_time.to_date.to_s.to_sym] = sorted_food.where(meal_time: begining_day..end_day)\n end\n meals\nend",
"def how_many(srt)\n arr = srt.split(\" \")\n count = {}\n\n #arr.map{ |s| \"#{s} #{arr.count s}\" }\n\n # arr.each do |s|\n # s.downcase!\n # count[s] = count.key?(s) ? count[s]+1 : 1\n # end\nend",
"def dinosaurii_count\n @@count += 1\n end",
"def valleyCounter(n,s)\n currentAltitude = 0\n lastAltitude = 0\n index = 0\n numberOfValleys = 0\n s.each_char do |char|\n if char == \"U\"\n currentAltitude += 1\n lastAltitude = currentAltitude - 1\n else\n currentAltitude -= 1\n lastAltitude = currentAltitude + 1\n end\n if currentAltitude == 0 && lastAltitude < 0\n numberOfValleys += 1\n end\n end\n puts numberOfValleys\nend",
"def second_round_nos\n count = 0\n No.all.each do |no|\n if self.leads.include?(no.lead) && no.date < Time.now - self.days_old_nos.days\n no.destroy\n count += 1\n end\n end\n count\n end",
"def hacking_attempts(dictionary_name, pass)\n data_pass = File.open(\"#{dictionary_name}.txt\").read.split(\"\\n\")\n attempts = 0\n data_pass.each do |e|\n if e != pass\n attempts += 1 \n else\n return attempts\n end\n end\nend",
"def script=(seconds); end",
"def peak_reg_time()\n arr_hour = $reg_cluster[\"hour\"]\n arr_hour.map { |h| [h, arr_hour.count(h)] }.sort { |a,b| b[1] <=> a[1] }[0..2].map { |val| if !$reg_cluster[\"peak_times\"].include?(val)\n $reg_cluster[\"peak_times\"].push(val)\n end }\n\n #format hour \n def format_hour (hour)\n if hour.to_i > 12 \n hour = (hour.to_i - 12).to_s + \" P.M.\" \n else \n hour = hour + \" A.M.\"\n end \n end \n\n #peak registration days\n arr_day = $reg_cluster[\"days\"]\n arr_day.map { |d| [d, arr_day.count(d)] }.sort { |a,b| b[1] <=> a[1] }.map { |val| if !$reg_cluster[\"peak_days\"].include?(val)\n $reg_cluster[\"peak_days\"].push(val)\n end }\n\n #format day\n def format_day (day)\n case day\n when 0\n \"Sunday\"\n when 1\n \"Monday\"\n when 2\n \"Tuesday\"\n when 3\n \"Wednesday\"\n when 4\n \"Thursday\"\n when 5\n \"Friday\"\n when 6\n \"Saturday\"\n else \"day error\"\n end\n end \n \n #marketing message\n puts \"Peak registration times are #{format_hour($reg_cluster[\"peak_times\"][0][0])} and #{format_hour($reg_cluster[\"peak_times\"][1][0])} on #{format_day($reg_cluster[\"peak_days\"][0][0])}s and #{format_day($reg_cluster[\"peak_days\"][1][0])}s\"\n\nend",
"def days_of_week_string\n dow = days_of_week_hash\n\n @days_of_week_string ||=\n (dow[:sunday] ? \"Su\" : \"\") +\n (dow[:monday] ? \"M\" : \"\") +\n (dow[:tuesday] ? \"Tu\" : \"\") +\n (dow[:wednesday] ? \"W\" : \"\") +\n (dow[:thursday] ? \"Th\" : \"\") +\n (dow[:friday] ? \"F\" : \"\") +\n (dow[:saturday] ? \"Sa\" : \"\")\n end",
"def times\n # if session[:count] exists, leave it as is. Else set it to 0\n session[:count] ||= 0\n render text: \"You have visited this url #{session[:count] += 1} time(s)\"\n end"
] |
[
"0.55449504",
"0.5464194",
"0.5410608",
"0.53638107",
"0.5330613",
"0.52116936",
"0.5118696",
"0.5083235",
"0.5075419",
"0.50424284",
"0.50354594",
"0.5028951",
"0.5008341",
"0.4965378",
"0.49121645",
"0.49115393",
"0.48953375",
"0.48889992",
"0.48869395",
"0.48756734",
"0.4848127",
"0.4837571",
"0.48311728",
"0.48236194",
"0.48217794",
"0.48161432",
"0.48125726",
"0.4811589",
"0.48034105",
"0.47927076",
"0.47839743",
"0.47828943",
"0.4779295",
"0.47773686",
"0.4771774",
"0.47699878",
"0.47676373",
"0.47674882",
"0.47611666",
"0.47602862",
"0.4760165",
"0.47593287",
"0.4749208",
"0.4747467",
"0.47472188",
"0.47425953",
"0.473872",
"0.4737988",
"0.47321382",
"0.4728071",
"0.47279978",
"0.47173825",
"0.47079542",
"0.4693251",
"0.46909207",
"0.468984",
"0.46834463",
"0.46821517",
"0.467938",
"0.46705082",
"0.46628162",
"0.46618596",
"0.46606985",
"0.46531108",
"0.4652696",
"0.46522605",
"0.46513322",
"0.46471006",
"0.4646181",
"0.4644623",
"0.46357542",
"0.46345988",
"0.4631596",
"0.46164057",
"0.4611914",
"0.4602404",
"0.4602092",
"0.4600399",
"0.4598291",
"0.45982483",
"0.4597456",
"0.45965046",
"0.45954728",
"0.45943874",
"0.45933548",
"0.45859134",
"0.4583042",
"0.45820457",
"0.45814446",
"0.45814255",
"0.4581121",
"0.4580703",
"0.4580606",
"0.45732555",
"0.45714444",
"0.45679265",
"0.45677528",
"0.45647737",
"0.456474",
"0.4562437"
] |
0.6000548
|
0
|
COUNTER TO IGNORE THE 'puts stringsHash[:band_num]' THE SECOND TIME THROUGH IF 'n' IS SELECTED BY USER
|
def getBandNum(eventName)
counter = 0
band_num_check = ""
@bandNum = ""
while band_num_check != 'y' || band_num_check != "exit"
if counter == 0
puts @@stringsHash[:band_num]
end
counter += 1
band_num = gets.strip
if band_num == "exit"
return
end
puts "\n"
puts "Is '#{band_num}' the correct BAND number for #{@eventName}?\nPress 'y' for 'Yes' or 'n' for 'No' and press 'Enter'."
band_num_check = gets.strip
if band_num_check == "exit"
return
end
if band_num_check == 'y'
@bandNum = band_num
break
end
if band_num_check == 'n'
puts "\n"
puts "-------------------------------------------------------"
puts "Re-Enter the correct BAND number for '#{@eventName}' and press 'Enter':"
redo
end
if band_num_check != 'y' || band_num_check != 'n'
puts "Please press 'y' for 'Yes' or 'n' for 'No' and hit the 'Enter' Key."
puts "If you'd like to exit the program, type 'exit' and hit the 'Enter' Key."
puts "\n"
puts "**** Now Re-Enter the BAND number for #{@eventName} 'Enter'. ****"
redo
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def line_count_experiment\n @letters_two.dump\n lines = @letters_two.xlate(@line_count_map)\n lines << @extra_digits\n lines.flatten!\n lines.dump('append')\n lines.chunk(2).to_i.collect { |d| d.to_s(5) }.dump(:from_base_5).to_i.to_letter\nend",
"def main\n results = {}\n strings = Hash.new(Array.new)\n 0.upto(10000).each do |ind|\n result = Helper.to_power_3(ind)\n results[ind] = result\n key = result.to_s.split(//).sort.join\n strings[key] += [ind]\n if strings[key].size == 5\n puts strings[key][0] \n puts results[strings[key][0]]\n break\n end\n \n end\n\n#puts results[345]\n#puts results[384]\n#puts results[405]\n\n#strings.each do |key,value|\n#pp results[value[0]] if value.length == 5\n#end\n \nend",
"def num_repeats(string)\nnums = Hash.new(0)\ncount = 0\n\nstring.each_char do |letter| nums[letter] += 1 end\n\nnums.keys.each do |key|\n\tif nums[key] > 1\n\t\tcount += 1\n\tend\nend\ncount\n\nend",
"def countingValleys(n, s)\n valleysNum = 0\n level = 0\n s.each_char do | step |\n step == \"D\" ? level -= 1 : level += 1\n valleysNum += 1 if (level == 0 && step == \"U\")\n end\n p valleysNum\nend",
"def thousand_lights3(n)\n lights = {}\n 1.upto(n) { |i| lights[i] = false }\n 1.upto(n) { |i| i.step(n, i) { |j| lights[j] = !lights[j] } }\n lights.keys.select { |idx| lights[idx] }\nend",
"def num_repeats(string)\n\n\tletters = string.split('')\n\tfrequencies = Hash.new(0)\n\n\tletters.each do |letter|\n \tfrequencies[letter] += 1\n\tend\n\n\t#puts frequencies\n\n\ttarget_count = 0\n\tfrequencies.values.select do |value|\n\t\tif value > 1\n\t\t\ttarget_count += 1\n\t\tend\n\tend\n\t\n\tputs target_count\n\treturn target_count\nend",
"def valleyCounter(n,s)\n currentAltitude = 0\n lastAltitude = 0\n index = 0\n numberOfValleys = 0\n s.each_char do |char|\n if char == \"U\"\n currentAltitude += 1\n lastAltitude = currentAltitude - 1\n else\n currentAltitude -= 1\n lastAltitude = currentAltitude + 1\n end\n if currentAltitude == 0 && lastAltitude < 0\n numberOfValleys += 1\n end\n end\n puts numberOfValleys\nend",
"def num_repeats(string)\n tallies = {}\n\n (0..string.length - 1).each do |idx|\n letter = string[idx]\n tallies[letter] ||= 0\n tallies[letter] += 1\n end\n\n count_tallies_greater_than_two(tallies)\nend",
"def letter_count limit\n letters = Hash[0, 0, 1, 3, 2, 3, 6, 3, 10, 3, 4, 4, 5, 4, 9, 4, 3, 5, 7, 5, 8, 5, 40, 5, 50, 5, 60, 5, 11, 6, 12, 6, 20, 6, 30, 6, 80, 6, 90, 6, 15, 7, 16, 7, 70, 7, 13, 8, 14, 8, 18, 8, 19, 8, 17, 9]\n words = Hash[\"and\", 3, \"hundred\", 7, \"thousand\", 8]\n num = 1\n digits = []\n count = 0\n i = 0\n\n letters.each do |k, v|\n # puts \"#{k}, #{v}\"\n end\n\n # puts \"HASH: #{letters[13]}\"\n\n\n while num <= limit\n count_for_word = 0\n\n if num > 9\n digits = num.to_s.reverse.split(//)\n \n # puts \"DIGITS[0]: #{digits[0]}, #{i}\"\n \n if digits[1] == \"1\"\n count_for_word = letters[[digits[0], digits[1]].join.reverse.to_i]\n\n else\n count_for_word = letters[digits[0].to_i] +\n letters[digits[1].to_i * 10]\n end\n count_for_word += letters[digits.fetch(2, 0).to_i] +\n letters[digits.fetch(3, 0).to_i]\n\n if digits[2] != nil && digits[2] != \"0\"\n # if letters[[digits[0], digits[1]].join.reverse.to_i] != 0 \n if [digits[0], digits[1]].join.reverse != \"00\" \n puts count_for_word\n\n count_for_word += words[\"hundred\"] + words[\"and\"]\n else\n count_for_word += words[\"hundred\"]\n end\n end\n\n puts count_for_word\n\n if digits[3] != nil\n count_for_word += words[\"thousand\"]\n end\n\n else\n count_for_word = letters[num].to_i\n end\n\n count += count_for_word\n num += 1\n end\n\n count \nend",
"def countingValleys(n, s)\n valleys, counter, flag, prev_flag = 0, 0, \"sea level\", \"\"\n s.chars.each do |x|\n prev_flag = flag\n if x == \"U\" \n counter += 1 \n elsif x == \"D\"\n counter -= 1\n end\n flag = \"valley\" if counter < 0\n flag = \"sea level\" if counter == 0 \n if prev_flag == \"valley\" && flag == \"sea level\"\n valleys += 1\n elsif prev_flag == \"sea level\" && flag == \"valley\"\n valleys += 1\n end\n end\n valleys/2\nend",
"def presses(phrase)\n # Your Code Here!\n presses = 0\n \n myhash= { \"0\" =>2,\"1\"=>1, \"2\"=> 4,\"3\" =>4 ,\"4\"=>4, \"5\"=>4, \"6\" => 4,\"7\"=>5, \"8\"=>4, \"9\"=>5 ,\"*\"=>1, \"#\"=>1, \n \"a\"=>1,\"b\"=>2,\"c\"=> 3,\"d\" =>1, \"e\" =>2, \"f\" =>3, \n \"g\" =>1, \"h\" =>2, \"i\" =>3, \"j\" =>1, \"k\" =>2, \"l\" =>3, \"m\" =>1, \"n\" =>2, \"o\" =>3, \"p\" =>1 ,\"q\" =>2, \"r\" =>3, \"s\"=>4,\n \"t\"=>1, \"u\"=>2, \"v\"=>3, \"w\" =>1, \"x\"=>2 ,\"y\"=>3, \"z\"=>4 }\n phrase.each_char do |x|\n \tresultingaray=myhash.values_at(x)\n keyvalue= resultingaray.fetch()\n\n presses = presses + keyvalue\nend\n p presses\n \nend",
"def num_repeats(string)\n\t#Counter to track the number of numbers greater than 1\n\tcounter = 0\n\tletter_count = {}\n\t#Remove spaces by splitting the string into an array and then back again\n\tinput_line = string.scan(/[a-zA-Z]/).join.downcase\n\tfor x in 0...input_line.length do\n\t\tif letter_count.has_key?(input_line[x])\n\t\t\tletter_count[input_line[x]] += 1\n\t\telse\n\t\t\tletter_count[input_line[x]] = 1\n\t\tend\n\tend\n\tletter_count.each do |letter, count|\n\t\tif count > 1\n\t\t\tcounter += 1\n\t\t\tputs \"Test num_repeats: adding #{letter} to list\"\n\t\tend\n\tend\n\treturn counter\nend",
"def six\n puts \"Type a sentence and lets see what the most common letter is\"\n input = gets.strip\n input = input.split(\"\")\n arr =[]\n arr << input\n counts = Hash.new(0)\n b = counts.each { |x| counts[x] += 1 }\n binding.pry\nend",
"def num_repeats(string)\n h = Hash.new(0)\n string.each_char do |c| \n h[c] = h[c] ? h[c]+1 : 1\n end \n repeated = h.values.select {|n| n > 1 }\n return repeated.length\n \n \n # I'm just going to leave this right here so you remember how much time you wasted trying to write javascript in ruby. There's a method for everything!\n #\n # repeated = 0\n # i = 0\n # count = 0\n # while i < string.length\n # #count up the times a letter occurs in a string\n # j = 0\n # while j < string.length\n # if string[i] == string[j]\n # count += 1\n # end\n # j += 1 \n # #if the answer is greater than 1, increment repeated\n # if count > 1\n # repeated += 1\n # end\n # count = 0\n # i += 1\n # end \n \n # #split string into array\n # strArray = string.split(\"\")\n # #iterate over array\n # i = 0\n # while i < strArray.length\n # #for each letter the first letter matches, update counter\n # for j in strArray\n # if strArray[i] == j\n # counter += 1\n # end \n # #if counter > 1 \n # end\n # if counter > 1\n # #update repeated variable\n # repeated += 1\n # end \n # counter = 0\n # i += 1\n \n # puts repeated\n # return repeated\nend",
"def count number\r\n start = Time.now # store the start time\r\n countOriginal number # call the original function\r\n stop = Time.now # store the end time\r\n\r\n # We should have very little overhead timing \r\n # above and after the original function\r\n $gRec.push ['count '+number.to_s, stop-start]\r\nend",
"def intelligent_guesses(num)\n word_options = File.readlines('dictionary.txt').select do |word|\n word.length == num\n end\n\n most_common_letters = {}\n word_options.join(\"\").split(\"\\n\").join(\"\").each_char do |letter|\n if most_common_letters.has_key?(letter)\n most_common_letters[letter] += 1\n else\n most_common_letters[letter] = 1\n end\n end\n\n @most_common_letters = most_common_letters\n\n end",
"def rampant_repeats(str, hash)\n new_str = ''\n str.each_char do |char|\n if hash.has_key?(char)\n hash[char].times do\n new_str << char\n end\n else\n new_str << char\n end\n end\n new_str\nend",
"def number_rides(whatever)\n whatever.each do |key,value|\n y = \"Driver #{key} has #{(value.length)} ride(s).\"\n puts y\n end\nputs\nend",
"def countletters(number)\n\n numerical = number.to_s\n\n dictionary = {\n 1 => \"one\", 2 => \"two\", 3 => \"three\", 4 => \"four\", 5 => \"five\",\n 6 => \"six\", 7 => \"seven\", 8 => \"eight\", 9 => \"nine\", 10 => \"ten\",\n 11 => \"eleven\", 12 => \"twelve\", 13 => \"thirteen\", 14 => \"fourteen\",\n 15 => \"fifteen\", 16 => \"sixteen\", 17 => \"seventeen\", 18 => \"eighteen\",\n 19 => \"nineteen\", 20 => \"twenty\", 30 => \"thirty\", 40 => \"fourty\", 50 => \"fifty\",\n 60 => \"sixty\", 70 => \"seventy\", 80 => \"eighty\", 90 => \"ninety\", 100 => \"hundred\",\n 1000 => \"thousand\", 1000000 => \"million\", 1000000000 => \"billion\"\n }\n\n if numerical.length == 2\n if numerical[0]\n p \"#{dictionary[20]}#{dictionary[number-20]}\"\n end\n end\n\nend",
"def how_many_times_is_repeated(str)\n #create hash to store key and value\n h={}\n #split up the string into individual characters and put it in an array\n arr = str.split(\"\")\n #for each character in the array, if it does not have a previous occurence in the 'h' hash, add it to the hash with a value of '1'\n arr.each do |n|\n if h.has_key?(n) == false\n h[n]=1\n #if it does have a previous occurence in the 'h' hash, add '1' to the previously occuring value of that key\n elsif h.has_key?(n) == true\n h[n]= h[n] +1\n end\n #return the completed hash\n end\n return h\nend",
"def ngram_analysis(str, n)\r\n # use a hash to store ngram - frequency mapping\r\n freq = Hash.new\r\n bigram = \"\"\r\n count = n-1\r\n i = 0\r\n\r\n # get the first ngram\r\n for i in 0..count\r\n bigram[i] = str[i]\r\n end\r\n\r\n freq[bigram] = 1\r\n\r\n str.each_char do |char|\r\n if i>=n then\r\n\r\n # bigram, trigram or quadrigram?\r\n bigram[0] = bigram[1]\r\n if n==2 then\r\n bigram[1] = char\r\n elsif n==3 then\r\n bigram[1] = bigram[2]\r\n bigram[2] = char\r\n elsif n==4 then\r\n bigram[1] = bigram[2]\r\n bigram[2] = bigram[3]\r\n bigram[3] = char\r\n end\r\n\r\n # updates values in the hash\r\n if freq.key?(bigram)==false then\r\n freq[bigram] = 1\r\n else \r\n freq[bigram] = freq[bigram]+1\r\n end\r\n\r\n end\r\n i = i + 1\r\n end\r\n\r\n # sort and print\r\n freq = freq.sort_by {|_key, value| value}.reverse.to_h\r\n i=0\r\n puts \"N-gram Analysis Results:\"\r\n freq.each do |key, value|\r\n if value!=1 && i<20 then\r\n puts key.to_s+\"\\t\"+value.to_s\r\n end\r\n i = i + 1\r\n end\r\nend",
"def shots\n puts \"How many shots would you like?\"\n #shots = gets.to_i\n $drink[:shots] = gets.to_i\n puts\nend",
"def hashNQS()\n @hash_nqs={}\n nqsReader=File.open(@nqsFile,\"r\")\n nqsReader.each do |line|\n cols=line.split(/\\s+/)\n \n name=cols[0]\n next if name==\"readName\"\n length=cols[1]\n dist=cols[2]\n qual=cols[3].to_i\n pass=cols[4]\n \n str_result=length+'.'+pass\n str=name+'.'+dist\n if @hash_nqs[str]==nil\n @hash_nqs[str]=str_result\n end\n end\n nqsReader.close\n $stderr.puts @hash_nqs.size\nend",
"def lets_go\n puts \"Welcome to Tunr!\"\n play = 'Y'\n upvotes ={}\n while play == 'Y'\n puts \"What type of search will you do? (P = 'play random song by band', T = 'show band's tracks)\"\n type_of_search = gets.chomp.downcase\n\n if type_of_search == \"\"\n puts \"We did not recived any digit from you, please enter your search\"\n exit\n elsif type_of_search == 'p'\n puts \"enter your favorite band\"\n term = gets.chomp.gsub(' ', '+') # gsub? What's that? Why?\n play_random_song_from_band(term)\n elsif type_of_search == 't'\n puts \"enter your favorite band\"\n term = gets.chomp.gsub(' ', '+')\n list_songs_by_band(term)\n end\n\n puts \"Continue? (y/n)\"\n\n play = gets.chomp.upcase\n\n upvotes[term] ||= 0\n if type_of_search.include?(term) and type_of_search.include?(term)\n upvotes[term] += 10\n else type_of_search.include?(term) || type_of_search.include?(term)\n upvotes[term] += 5\n end\n\n puts \"New music searched! #{term}, Current Upvotes: #{upvotes[term]}\"\n\n \n end\nend",
"def set_band(band)\n puts \"Setting band to #{band}\" if $verbose\n b='BN'+(('00'+band.to_s)[-2..-1])+';'\n puts b if $verbose\n ret=send_cmd(b,'BN;',b,0.5,1.5,3)\n if(ret)\n return(ret.gsub(/^BN/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def toggle_lights(n)\n multipled_substring = []\n\n (1..n).each do |count|\n multiplier = 1\n\n loop do\n product = count * multiplier\n break if product > n\n multipled_substring << product\n multiplier += 1\n end\n end\n #multipled_substring\n\n final_result = []\n (1..n).each do |number|\n times_of_toggle = multipled_substring.count(number)\n \n final_result << number if times_of_toggle.odd?\n end\n p final_result\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char| \n if hash[char]\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def rampant_repeats(str, hash)\n new_str = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def take_a_number(katz_deli, name)\n \n \n people_waiting = katz_deli.count\n\n katz_deli << name\n \n \n while people_waiting > 0\n \n \n puts \"#{name} your place in line is #{people_waiting+1}\"\n \n \n break\n \n \n\n end\n \n end",
"def next_interesting\n loop_until(->(hash) { /^0{5}/ =~ hash }) do\n @hasher.call(\"#{@id}#{@i += 1}\")\n end\n end",
"def instrument_repeat_key(survey)\n response_sets_for_survey = response_sets.select { |rs| rs.survey.title == survey.title }\n response_sets_for_survey.blank? ? 0 : response_sets_for_survey.size - 1\n end",
"def display(hashName)\n system \"clear\" \n puts \"Aluno: Notas [ N1, N2, N3, Media ] cadastradas:\"\n puts \"----------------------------------\"\n hashName.each do |a, b|\n puts \"#{a}: \\t #{b}\"\n end\n puts \"----------------------------------\"\n countKeys = hashName.keys.count\n puts \"[ #{countKeys} ] aluno(s) cadastrado(s)\"\n voltar\nend",
"def count_nucleotides dna\n bases_count = {\n 'A' => 0,\n 'C' => 0, \n 'T' => 0,\n 'G' => 0,\n }\n \n \n #\n dna.each_char do |x|\n if bases_count.key? base\n bases_count[ base ] += 1\n else \n puts \"#{base} not a valid nucleotide\"\n end # if\n end # DNA.each_char end\n\n bases_count.each do |key, val|\n puts \"#{key} : #{val}\"\n end #bases_count.each end\n \n\nend",
"def countingValleys(n, s)\n vcount = 0\n level = 0\n n.times do |i|\n if s[i] == \"U\"\n level +=1\n vcount +=1 if level == 0\n elsif s[i] == \"D\"\n level -=1\n end\n end\n return vcount \nend",
"def update_output_hash(word, output_hash)\n output_hash.key?(word) ? output_hash[word] += 1 : output_hash[word] = 1\n output_hash\nend",
"def sampling\n\t\t@input_ary.each_with_index { |line,i|\n\t\t\tif line =~ /^SAMPLING=([0-9]*)\\s*/\n\t\t\t\t@fileinfo[:sampling] = $1.to_i \n\t\t\t\tat = i+1\n\t\t\tend\n\t\t}\n\t\traise DTA_ReaderErr, \"Cannot find sampling time!\" unless @fileinfo[:sampling]\n\t\traise DTA_ReaderErr, \"Error parsing sampling time :: #{@input_file}:#{at} :: SAMPLING=\" + $1.inspect if @fileinfo[:count] == 0\n\tend",
"def repeat_yourself(str, int)\n count = 0\n loop do\n break if count == int \n\t puts str\n count +=1\n end\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char|\n if hash.key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char \n end\n end\n new_str\nend",
"def countingValleys(n, s)\n level = 0; valleys = 0; isDownSeaLevel = false\n for i in 0..n\n level += (s[i] == 'U' ? 1 : -1)\n isDownSeaLevel = true if level == -1\n if level == 0 && isDownSeaLevel\n valleys += 1\n isDownSeaLevel = false\n end\n end\n valleys\nend",
"def print_words_based_on_phone_no(ph_no)\n if (ph_no.is_a?(Integer) && (ph_no.to_s.split(\"\").include?(\"1\") || ph_no.to_s.split(\"\").include?(\"0\")))\n puts \"Phone number should be Number and should not include 0 and 1 digits\"\n else\n initializeDigits = { \n \"2\" => [\"a\",\"b\",\"c\"],\n \"3\" => [\"d\",\"e\",\"f\"],\n \"4\" => [\"g\",\"h\",\"i\"],\n \"5\" => [\"j\",\"k\",\"l\"],\n \"6\" => [\"m\",\"n\",\"o\"],\n \"7\" => [\"p\",\"q\",\"r\", \"s\"],\n \"8\" => [\"t\",\"u\",\"v\"],\n \"9\" => [\"w\",\"x\",\"y\", \"z\"]\n }\n file_read = File.read(\"dictionary.txt\")\n hash_file = file_read.split(\" \").group_by {|k| k[0,1].downcase}\n ph_no_array = ph_no.to_s.split(\"\")\n result = []\n default_val = 3\n ph_no_array.each_with_index do |x,i|\n if default_val < 8\n one = hash_file[initializeDigits[ph_no_array[i...default_val].first].first].detect{ |e| e.length == default_val }\n if (default_val > 5)\n two = hash_file[initializeDigits[ph_no_array[i..9].first].last].detect{ |e| e.length == 9 - (default_val - 1) } \n else\n two = hash_file[initializeDigits[ph_no_array[i+1..9].first].first].detect{ |e| e.length == 9 - (default_val - 1) } \n end\n result << [one, two]\n default_val+=1\n result << hash_file[initializeDigits[ph_no_array.first].first].detect{ |e| e.length == 10 } if(default_val == 8)\n end\n end\n puts result.to_s \n end\n end",
"def count_guess \r\n\t\t@num_guess = @secret_word.length \r\n\t\t@num_guess.times do \r\n\t\t\t@word_length_array << \"_\"\r\n\t\tend \r\n\t\tp @word_length_array\r\n\tend",
"def increment_counter!\n # Increment the counter\n sql(:execute, %(\n INSERT INTO knifeswitch_counters (name,counter)\n VALUES (?, 1)\n ON DUPLICATE KEY UPDATE counter=counter+1\n ), namespace)\n\n # Possibly open the circuit\n sql(\n :execute,\n %(\n UPDATE knifeswitch_counters\n SET closetime = ?\n WHERE name = ? AND COUNTER >= ?\n ),\n DateTime.now + error_timeout.seconds,\n namespace, error_threshold\n )\n end",
"def counter\n # I can't modify counts directly, since it's a method. I can, however, make a copy of it. The copy (valids) is what I'll be adding nucleotide counts to.\n valids = counts\n # Start out with an empty string that I'll append message text to.\n message = \"\"\n # Take the string passed into the new method, upcase the letters in that string, split it into an array of its characters, and loop over each of the characters in that array (calling each one 'el' at one time)\n @string.upcase.chars.each do |el|\n # Call the valid? method, passing in the character, and - if it's valid - look up the corresponding key/value pair in the valids hash and increment its value by 1.\n if valid?(el)\n valids[el] += 1\n else\n # If it's not valid, just add the fact that it's not valid to the message.\n message += \"#{el} is not a valid nucleotide.\\n\"\n end\n end\n # Once we've looped through all the characters in the string, go through the valids hash, and for each one, add a string (interpolating the key and value of each pair) to the message.\n valids.each do |k, v|\n message += \"There are #{v} #{k}s in #{@string}\\n\"\n end\n # Then return the message.\n message\n end",
"def q1_print_times(str, num)\n num.times {|num_here|\n p str\n }\nend",
"def init_guess_count\n @guess_count = 12\n end",
"def my_counter_function()\n puts(\"Text:\");\n text = gets().chop().downcase; # \"Hallo\"\n puts (\"Buchstabe:\") ;\n letter = gets()[0 ,1].downcase; #wir speichern nur den ersten Buchstaben\n count = count_occurrences(text,letter);\n puts(\"Der Buchstabe '\" + letter + \"' kommt \" + count.to_s() + \" mal vor.\");\nend",
"def total_students( students_hash)\n st_counter =0\n students_hash.each do |key,value|\n st_counter += value\n #puts (\"#{key}: #{value} students\")\n end\n return st_counter\nend",
"def rampant_repeats(str, hash)\n str.chars.map { |c| hash.key?(c) ? c * hash[c] : c }.join\nend",
"def run(n)\n puts \"start\"\n puts @building.to_s, \"\"\n n.times do |tick|\n puts \"Tick #{tick+1}\"\n @registered_items.each{ |item| item.tick }\n puts @building.to_s, \"\"\n end\n end",
"def list_count\n\t\tThread.start do\n\t\t\tnotifier = @ts.notify 'write', [:old_n, nil]\n\t\t\tnotifier.each do |_, t|\n\t\t\t #puts t.last\n \t puts \"n: #{@ts.read([:old_n, nil]).sort.last} a: #{@ts.read([:a, nil]).last} b: #{@ts.read([:b, nil]).last} a*b: #{@ts.read([:a, nil]).last.to_i* @ts.read([:b, nil]).last.to_i}\"\n\t\t\tend\n\t\tend\n\tend",
"def rank_times\n hours = Array.new(24){0}\n @file.each do |line|\n hour = line[:regdate].split(\" \")\n hour = hour[1].split(\":\")\n hours[hour[0].to_i] += 1\n\n end\n hours.each_with_index{ |counter,hours| puts \"#{hours}: #{counter}\"}\n end",
"def test_many\n result_hash={}\n 1000.times do\n x = square_same_color?(random_chess_board_square, random_chess_board_square)\n result_hash[x] ? result_hash[x] += 1 : result_hash[x] = 1\n end\n p result_hash\nend",
"def game_of_thrones string\n s1 = string.chars\n freq = Hash.new(0)\n count = 0\n\n s1.each{ |key| freq[key]+=1 }\n\n freq.each{ |k,v| count+=1 if v.odd? }\n\n puts count < 2 ? 'YES' : 'NO'\n \nend",
"def add_salt(count)\n puts \"How many pinches of salt\"\n userinput = gets.chomp\n counter = 1\n until counter > userinput.to_i\n puts \"Adding a pinch of salt\"\n sleep 0.5\n if counter == 3\n puts \"You like a lot of salt!\"\n sleep 0.5\n end\n if counter == 5\n puts \"You ruined your omelette!\"\n sleep 0.5\n end\n counter += 1\n end\n puts \"Done adding salt!\"\n count += 1\n what_to_do(count)\nend",
"def CheckUniqDigits(n)\n\n h1 = Hash.new\n\n arr = n.digits\n\n for onedig in arr\n\n h1.key?(onedig) ? (return 0) : (h1[onedig] = 1)\n\n end\n\n return 1\n\nend",
"def find_hundreds (n)\n words =\"\"\n num_words = Hash.new(0)\n num_words = {1=>\"One\",2=>\"Two\",3=>\"Three\",4=>\"Four\",5=>\"Five\",6=>\"Six\",7=>\"Seven\",8=>\"Eight\",9=>\"Nine\",10=>\"Ten\",11=>\"Eleven\",12=>\"Twelve\",13=>\"Thirteen\",14=>\"Fourteen\",15=>\"Fifteen\",16=>\"Sixteen\",17=>\"Seventeen\",18=>\"Eighteen\",19=>\"Nineteen\",20=>\"Twenty\",30=>\"Thirty\",40=>\"Fourty\",50=>\"Fifty\",60=>\"Sixty\",70=>\"Seventy\",80=>\"Eighty\",90=>\"Ninety\"}\n\n if n/100 > 0\n # Append the String you get to the string that holds the words\n words = num_words[n/100] +\" Hundred \"\n if n%10 !=0\n words= words + \"and \"\n end\n n=n%100\n end\n\n if n/10 > 0\n if n/10 == 1\n words = words+num_words[n]+ \" \"\n elsif n%10 == 0\n words = words +num_words[n]\n else\n words = words +num_words[n/10*10] +\" \"+ num_words[n%10]\n end\n elsif n == 0\n words\n else\n words = words +num_words[n]\n end\n words\nend",
"def findNumCycles(output)\n value = 0\n temp = output.slice(/NUMBER_OF_CYCLES_READ[12]=\\d+/)\n if temp != nil && !temp.eql?(\"\")\n value = Integer(temp.split(\"=\")[1]) - 1\n end\n\n if value > @numCycles\n @numCycles = value\n end \n end",
"def count ( nucleotide, strand )\n\tstrand.upcase.count( nucleotide )\nend",
"def count_frequencies s\n s.downcase.split(//).inject(Hash.new(0)) do |hash,item|\n hash[item] += 1\n hash\n end\n end",
"def getfreqs\n @freqs = Hash.new\n @fieldvalues.each do |v|\n @freqs[v] = @db.execute(\"select count(*) from #{@tablename} where #{@fieldname} = '#{v}'\").to_s \n end\nend",
"def count_contestants_by_hometown(data, hometown)\n counter = 0 # COUNTER VALUE HAS TO BE HERE\n data.each do |season, season_array|\n season_array.each do |into_array|\n if into_array[\"hometown\"] == hometown\n counter += 1\n # binding.pry\n end \n end \n end\n counter\nend",
"def count\n @letters = Hash.new(0)\n puts \"Hey let's find how many times each letter shows up in your sentence\"\n input = gets.strip.gsub(' ','').split('').sort\n input.each do |x|\n @letters[x] += 1\n end\n \n @letters.each do |key, value|\n puts \"Ther letter #{key} is in your sentence #{value} times.\"\n end\n\nend",
"def dictionary_attack()\n puts \"Entered Attack\"\n $encoded.each do |i|\n #Process clock time looks at the monotonic clock which maximizes accuracy and prevents time skips (each call gets the system time)\n starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n #Querries the hash map to find the given element of the encoded passwords\n hash = $digest[i]\n elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - starting\n $f.write(\"The password for the hash value #{i} is #{hash}, it takes the program #{elapsed} sec to recover this password.\\n\")\n end\nend",
"def stats_from_string(str, number)\n # puts \"\\nStart array: #{str}\\n\\n\"\n a = str.split.sort\n results = {}\n a.each { |c| results[c] = (results[c] || 0) + 1 }\n results['total'] = a.count\n puts \"Occurance in strip #{number}: #{results}\"\n results.each { |key, val| results[key] = \"#{val} / #{results['total']}.0\" }\n # puts \"Probability: #{results}\"\n results\nend",
"def additivePersistence(number, times)\n # your magic\n numString = number.to_s\n sum = 0\n numString.each_char {|digit| sum += digit.to_i}\n\n if sum > 9 \n\t times += 1\n puts additivePersistence(sum, times)\n else\n puts times\n end\nend",
"def roundTime(hash={})\n\t\t$_TAGHASH_[\"GSQ\"] = hash['value']\n\tend",
"def presses(str)\n # Your Code Here!\n num_press = 0\n str.downcase.each_char do |letter|\n \tif \" 1adgjmptw*#\".include? letter\n \t\tnum_press += 1\n \telsif \"0behknqux\".include? letter\n \t\tnum_press += 2\n \telsif \"234568sz\".include? letter\n \t\tnum_press += 4\n \telsif \"cfilorvy\".include? letter\n \t\tnum_press += 3\n \telsif \"79\".include? letter\n \t\tnum_press += 5\n \telsif \"0behknqux\".include? letter\n \t\tnum_press += 2\n \tend\nend\n \treturn num_press\nend",
"def featured(number)\n loop do\n number +=1\n characters = number.to_s.split('')\n if (number.odd?) && (number % 7 == 0) && (characters.uniq == characters) \n p number\n break\n end \n end \nend",
"def sheetlisten()\n n=0.5\n i=0\n while i<@songstr.length-1\n case @songstr[i]\n when 'a' \n play :a\n when 'b' \n play :b\n when 'c' \n play :c\n when 'd' \n play :d\n when 'e' \n play :e\n when 'f' \n play :f\n when 'g' \n play :g\n else\n if(!is_numeric?(@songstr[i]))\n puts(\"invalid char\")\n end\n end\n if(!is_numeric?(@songstr[i+1]))\n sleep 0.5\n else\n case @songstr[i+1]\n when '2' \n #for halfnote at regular speed: sleep 1\n n=1\n when '8' \n #for eighth\n n=0.25\n when '6' \n #for sixteenth note\n n=0.125\n end\n sleep n\n i+=1\n end\n i+=1\n end\n end",
"def genome(liszt)\n=begin\n[samopen] SAM header is present: 2 sequences\n7621912 reads; of these:\n 4009241 (52.60%) were paired; of these:\n 1983557 (49.47%) aligned concordantly 0 times\n 1818685 (45.36%) aligned concordantly exactly 1 time\n 206999 (5.16%) aligned concordantly >1 times\n ----\n 1983557 pairs aligned concordantly 0 times; of these:\n 409503 (20.64%) aligned discordantly 1 time\n ----\n 1574054 pairs aligned 0 times concordantly or discordantly; of these:\n 3148108 mates make up the pairs; of these:\n 1009275 (32.06%) aligned 0 times\n 35392 (1.12%) aligned exactly 1 time\n 2103441 (66.82%) aligned >1 times\n 3612671 (47.40%) were unpaired; of these:\n 498719 (13.80%) aligned 0 times\n 2246121 (62.17%) aligned exactly 1 time\n 867831 (24.02%) aligned >1 times\n=end\n #puts(liszt);exit\n dict={}; liszt.shift\n dict[\"total\"]=liszt.shift.split[0]; #liszt.shift\n dict[\"paired\"]=liszt.shift.split[0]; liszt.shift #conc 0\n dict[\"conc_once\"]=liszt.shift.split[0]\n dict[\"conc_mult\"]=liszt.shift.split[0]\n liszt.shift(2); dict[\"disc_once\"]=\"\"; dict[\"disc_mult\"]=\"\"\n line=liszt.shift\n line.include?(\">1 times\") ? dict[\"disc_mult\"]=line.split[0] : dict[\"disc_once\"]=line.split[0]\n liszt.shift\n dict[\"unaligned_pairs\"]=liszt.shift.split[0]\n liszt.shift\n dict[\"unmates\"]=liszt.shift.split[0] #unaligned mates\n dict[\"mate_once\"]=liszt.shift.split[0]\n dict[\"mate_mult\"]=liszt.shift.split[0]\n dict[\"unpaired\"]=liszt.shift.split[0]\n dict[\"unpair_unaligned\"]=liszt.shift.split[0]\n dict[\"unpair_once\"]=liszt.shift.split[0]\n dict[\"unpair_mult\"]=liszt.shift.split[0]\n dict\nend",
"def get_count_text\n cs = get_condition_string\n approx_text = \"\"\n unless params[:slow_count] \n approx_text = \"Approximate/cached values! \"\n total_count = count_fast()\n now_count = count_fast(cs)\n else\n total_count = count_fast()\n now_count = count_slow(cs)\n end \n\n ret = \"\"\n if total_count\n ret += approx_text + \"There are total #{pluralize(total_count,'record')}.\"\n end \n if now_count\n ret += \" You have selected #{pluralize(now_count,'record')}\"\n end\n if total_count and total_count > 0 and now_count\n ret += \" (#{((now_count.to_f / total_count.to_f * 1000).round().to_f/10)}%)\" \n end\n return ret\n end",
"def sample(n = 1)\n keys = self.dna_hash.keys\n sampled_keys = keys.sample(n)\n sampled_nt = {}\n sampled_aa = {}\n sampled_qc = {}\n sampled_title = self.title + \"_sampled_\" + n.to_s\n sampled_keys.each do |k|\n sampled_nt[k] = self.dna_hash[k]\n sampled_aa[k] = self.aa_hash[k]\n sampled_qc[k] = self.qc_hash[k]\n end\n return ViralSeq::SeqHash.new(sampled_nt, sampled_aa, sampled_qc, sampled_title, self.file)\n end",
"def change hash, n\n if n > 0\n hash[\"New Stuff #{n}\"] = 1\n change hash, n - 1\n end\nend",
"def statistic_run\n\n puts 'You want statistics about CS Air'\n\n # print out what to type in for each command\n @num_to_detail.each { |num, string| puts \"Type #{num} for #{string}\" }\n \n command = gets.chomp.to_i\n\n # wait till you receive correct input\n while not @num_to_detail.has_key?(command)\n puts 'Please try again'\n command = gets.chomp.to_i\n end\n \n case\n when command == 1\n puts \"#{@ui_lib.longest_single_flight}\"\n when command == 2\n puts \"#{@ui_lib.shortest_single_flight}\"\n when command == 3\n puts \"#{@ui_lib.average_flight_length}\"\n when command == 4\n puts \"#{@ui_lib.biggest_population_city}\"\n when command == 5\n puts \"#{@ui_lib.smallest_population_city}\"\n when command == 6\n puts \"#{@ui_lib.average_population}\"\n when command == 7\n @ui_lib.list_of_continents.each {|continent, list| puts \"#{continent},#{list}\"}\n when command == 8\n puts \"#{@ui_lib.list_of_hubs}\"\n end\n\n end",
"def dump_bigram_info_from_hash()\n\n cumulative_bigram_count = 0\n\n $bigram_count.keys.sort.each do |bigram|\n local_lead_word = bigram.split(/\\s/)[0] #shouldn't need to extract this each time\n cumulative_bigram_count += $bigram_count[bigram]\n cumulative_proportion = cumulative_bigram_count.to_f / $lead_word_count[local_lead_word].to_f\n puts sprintf(\"%s\\t%f\", bigram, cumulative_proportion )\n end\n\nend",
"def countingValleys(n, s)\n level = valleys = 0\n s.each_char do |step|\n valleys +=1 if level==0 && step =='D'\n level = step == 'D' ? level-1 : level+1\n end\n valleys\nend",
"def record_count\n pair = text_blocks.each_cons(2)\n .select { |cons| cons[1] == \"Record Count:\" }.first\n pair && pair[0].to_i\n end",
"def nb_dig(n, d)\n counter = 0\n string_of_squares(n).split(\"\").each { |c| counter += 1 if d == c.to_i }\n counter\nend",
"def repeatedString(s, n)\r\n # Write your code here\r\n numOfA = 0\r\n index = 0\r\n \r\n if s.length == 1 && s[0] == 'a'\r\n return n\r\n elsif s.length == 1 && s[0] != 'a'\r\n return 0\r\n \r\n else\r\n firstRoundUpperLimit = n < s.length ? n : s.length\r\n \r\n for i in 0 ... firstRoundUpperLimit\r\n if s[i] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n\r\n if (numOfA > 0 && n > s.length) \r\n repeatingOccurrences = (n / s.length) - 1\r\n remainingOccurrences = n % s.length\r\n\r\n\r\n\r\n numOfA = numOfA + (numOfA * repeatingOccurrences)\r\n\r\n for j in 0 ... remainingOccurrences\r\n if s[j] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n end\r\n\r\n \r\n end\r\n return numOfA\r\nend",
"def look_and_say(n)\n prev = \"1\"\n curr = \"\"\n\n while(n > 1)\n i = 0\n\n while(i < prev.length)\n\n char = prev[i]\n count = count_digits(i, prev)\n i += count\n\n curr << count.to_s << char\n end\n\n prev = curr.dup\n curr = \"\"\n n -= 1\n end\n\n prev\nend",
"def word_count_tracker\n a_file = File.open('words.txt')\n words = Hash.new(0)\n a_file.each do |line|\n \tarray = line_to_array(line)\n \tarray.each do |word|\n \t words[word.downcase] += 1\t\n \tend\n end\n a_file.close\n puts \"please enter the desired word\"\n word = gets.chomp.downcase\n puts \"#{word} appears #{words[word]} time(s)\"\n puts \"\\n#{words}\" \nend",
"def lineN_stations \n puts \"The list of stations for line N: \"\n puts \"[0] - Time Square\"\n puts \"[1] - 34th\"\n puts \"[2] - 28th\"\n puts \"[3] - 23rd\"\n puts \"[4] - Union Square\"\n puts \"[5] - 8th\"\nend",
"def count_blacks\r\n black_count = Hash.new(0)\r\n code.length.times { |i| black_count[code[i]] += 1 if code[i] == guess[i] } ## DRT\r\n black_sum = 0\r\n black_count.each { |k,v| black_sum += v }\r\n black_sum\r\n end",
"def nucleotide_counts\n hash = {}\n @valid_inputs.each do |i|\n hash[i] = @dna.count i\n end\n hash\n end",
"def rampant_repeats(str, hash)\n n_str = ''\n str.each_char do |char|\n if hash.has_key?(char) \n n_str += char * hash[char]\n else\n n_str += char\n end\n end\n n_str\nend",
"def substrings(dict,str)\n hash = Hash.new\n #checks how many times str shows up in dictionary\n dict.each do |astring|\n if astring == str\n\t if hash[str]\n\t hash[str] += 1\n\t else\n\t hash[str] = 1\n\t end\n\t \n\tend\n end\n dict.each do |astring|\n if str.include?(astring)\n\t if hash[astring]\n\t hash[astring] += 1\n\t else\n\t hash[astring] = 1\n\t end\n\tend\n end\n hash\nend",
"def rampant_repeats(str, hash)\n\n new_str = \"\"\n\n str.each_char { |char| new_str += char * ( hash[char] || 1) }\n\n new_str\n\nend",
"def persistence(n)\n count = 0\n while n > 9 do\n n = n.digits.inject(:*)\n count += 1\n end\n count\nend",
"def update_matches_played(match)\n for i in 0...2\n $matches_played[match[i]] = $matches_played[match[i]].to_i + 1\n end\nend",
"def track_string( info_index, result_index )\n\t\t\tresult=\" \" # This space is necessary for proper identification of whole page names\n\t\t\tn = self\n\t\t\trepeat_counter = 1\n\t\t\twhile n != nil\n\n\t\t\t\tnext_value = nil\n\t\t\t\tdisplay_value = n.info[ result_index ]\n\t\t\t\tif ( n.next[ info_index ] != nil )\n\t\t\t\t\tnext_value = n.next[ info_index ].info[ result_index ]\n\t\t\t\tend\n\n\t\t\t\tif ( display_value != next_value || n.next[ info_index ] == nil )\n\t\t\t\t\tresult=\"#{result}#{display_value}\"\n\t\t\t\t\tif repeat_counter > 1\n\t\t\t\t\t\tresult = \"#{result} (#{repeat_counter})\"\n\t\t\t\t\tend\n\t\t\t\t\tif ( n.next[ info_index ] != nil )\n\t\t\t\t\t\tresult = \"#{result} -> \"\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif ( display_value == next_value)\n\t\t\t\t\trepeat_counter = repeat_counter + 1\n\t\t\t\telse \n\t\t\t\t\trepeat_counter = 1\n\t\t\t\tend\n\n\n\t\t\t\tn = n.next[ info_index ]\n\t\t\t\tprevious_display_value = display_value\n\t\t\tend\n\t\t\tresult = \"#{result} \" # this space is necessary for proper identification of whole names\n\t\t\t\n\t\t\treturn result\n\t\tend",
"def bts_sw_level(a_logfile)\r\n cmdRXMOP = cmd_get(a_logfile, 'RXMOP') \r\n result = {}\r\n cmdRXMOP.each_index do |i|\r\n if cmdRXMOP[i].include?('SWVERACT')\r\n sw = cmdRXMOP[i+1].split.last\r\n if result.include?(sw)\r\n result[sw]+=1\r\n else\r\n result[sw]=1\r\n end\r\n end\r\n end\r\n output = \"\"\r\n output << \"There are:\\n\"\r\n result.each_pair do |sw, n|\r\n output << \"#{n} BTSs Sw level #{sw}.\\n\"\r\n end\r\n print output\r\n clip = Clipboard.instance\r\n clip.paste(output)\r\nend",
"def increment_guess_count(current_guess_count)\n\tcurrent_guess_count += 1\nend",
"def num_repeats(string)\n\n # number of repeating characters\n n = 0\n # tracks the character frequency\n repeats = Hash.new(0)\n\n string.each_char do |c|\n repeats[c] += 1\n if repeats[c] == 2\n n += 1\n end\n end\n n\nend",
"def rampant_repeats(str, hash)\n (str.split(\"\").map do |char| \n if hash.keys.include?(char)\n # if hash.has_key?(char)\n char * hash[char] \n else\n char\n end\n end).join(\"\")\nend",
"def rampant_repeats(str, hash)\n (str.split(\"\").map do |char| \n if hash.keys.include?(char)\n char * hash[char] \n else\n char\n end\n end).join(\"\")\nend",
"def pumps\n if $drink[:flavor] == nil\n #if drink[:flavor] == nil\n #puts \"No worries\"\n #pumps = 0\n $drink[:pumps_flavor] = 0\n puts\n else\n #elsif drink[:flavor] \n puts \"How many pumps?\"\n $drink[:pumps_flavor] = gets.to_i\n puts\n end\n end",
"def countingValleys(_n, s)\n array = s.split('')\n altitude = 0\n valleys = 0\n # start at sea level. If there is a step up\n # add 1 to altitude. If there is a step down\n # minus 1 from altitude.\n # if there was a step down from 0, altitude will equal -1\n # if there was a second step down, altitude will equal -2\n # if there is a step up now, altitude will equal -1\n # if there is another step up, valleys will equal to 1,\n # altitude will equal to 0.\n array.each do |step|\n if step == 'U'\n valleys += 1 if altitude == -1\n altitude += 1\n end\n altitude -= 1 if step == 'D'\n end\n valleys\nend",
"def repeat(str, num)\n counter = 0\n\n loop do\n break if counter == num\n\n puts str\n counter += 1\n end\nend",
"def increment_tries\n @tries += 1\n end",
"def new_guess(tries)\n\tputs \"You have #{3-tries} more tries:\"\n\tgets\nend"
] |
[
"0.5538354",
"0.5352194",
"0.50657946",
"0.49728096",
"0.496525",
"0.49447787",
"0.49235386",
"0.4869195",
"0.48553243",
"0.48549515",
"0.48541936",
"0.4850281",
"0.4849404",
"0.48452908",
"0.48217136",
"0.48202857",
"0.48188376",
"0.48031962",
"0.48030567",
"0.48015586",
"0.4794923",
"0.47812456",
"0.4777826",
"0.47686094",
"0.47677103",
"0.47634992",
"0.47515607",
"0.47510177",
"0.47462308",
"0.474383",
"0.47371918",
"0.47317857",
"0.47317517",
"0.47267428",
"0.4724306",
"0.4720869",
"0.47156706",
"0.47139713",
"0.47097462",
"0.46978992",
"0.4692394",
"0.4689616",
"0.46792984",
"0.4676774",
"0.4674868",
"0.46621674",
"0.46523815",
"0.46462634",
"0.46398893",
"0.46305895",
"0.4621691",
"0.46191952",
"0.4618993",
"0.46136352",
"0.46028134",
"0.46016747",
"0.46012986",
"0.45991835",
"0.45980147",
"0.4596563",
"0.45941344",
"0.4592783",
"0.45915154",
"0.4581808",
"0.45817143",
"0.45792067",
"0.45764893",
"0.45751724",
"0.45745516",
"0.4574272",
"0.45728892",
"0.457092",
"0.45687023",
"0.45643854",
"0.45636228",
"0.45617115",
"0.45610687",
"0.455425",
"0.4553155",
"0.45530096",
"0.4539916",
"0.4539508",
"0.4538956",
"0.4537333",
"0.45371363",
"0.4536437",
"0.45222732",
"0.451882",
"0.4518384",
"0.45179328",
"0.4516376",
"0.45099953",
"0.45059845",
"0.45044747",
"0.45032346",
"0.45019835",
"0.4501582",
"0.449945",
"0.44980645",
"0.44919074"
] |
0.5766622
|
0
|
Compute the size via Carrierwave Set a value to 0 if something goes wrong So that size won't be "blank"
|
def compute_size
return false if self.mp3_file.blank?
self.size = self.mp3_file.size || 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def size!\n @size = nil\n self.size\n end",
"def size size = nil\n @size = size.to_i if size\n @size\n end",
"def size\n @size \n end",
"def size\n @size \n end",
"def size\n\t\t7500\n\tend",
"def size_ls=(value)\n self.size_l = value.blank? ? '' : value\nend",
"def get_size\n\t\treturn @size\n\tend",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def set_size\n self.size = attachment.size if attachment.size\n end",
"def field_size\n if self[:field_size].present? && self[:field_size] > 0\n self[:field_size]\n else\n results.size\n end\n end",
"def size\n @size.size\n end",
"def picture_size\n #errors.add(:image, 'should be less than 1MB') if image.size > 1.megabytes\n end",
"def get_size\n\t\tend",
"def size_from_default\n DEFAULT_SIZE\n end",
"def size\n \t@size\n end",
"def set_file_size\n write_attribute(:file_size, File.size(file_name)) if (file_size.blank? and !file_name.blank?)\n end",
"def default_size\n @total_memory ? @total_memory * @weighting : nil\n end",
"def size=(size)\n end",
"def size\n 4\n end",
"def size\n @sizes ||= strip(:size)\n end",
"def size=(value)\n @size = value\n end",
"def size=(value)\n @size = value\n end",
"def size\r\n\t\t@size\r\n\t\t#el tamaño\r\n\tend",
"def size\n # return the value of the instance variable @size\n @size\n # end size method\n end",
"def file_size\n @file_size ||= 0\n end",
"def size\nend",
"def size\n instance_read(:file_size) || (@queued_for_write[:original] && @queued_for_write[:original].size)\n end",
"def photo__size\r\nif File.exist?(self.photo__path)\r\n return File.size(self.photo__path)\r\nelse\r\n return self.photo ? self.photo.length : 0\r\nend\r\nend",
"def size\n super\n end",
"def size\n super\n end",
"def image_size\n if prescription.size > 5.megabytes\n errors.add(:prescription, \"should be less than 5MB\")\n end\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def size\n\n\n end",
"def size\n Float::MAX.to_i\n end",
"def file_size\n number_to_human_size(super)\n end",
"def size\n\n end",
"def size; '' end",
"def size\n\tend",
"def validate_entry_sizes; end",
"def update_file_size\n size = File.size(self.file_path)\n if !self.image_size? or self.image_size != size\n self.update_attributes({:image_size => size})\n end\n end",
"def size\n end",
"def size\n end",
"def size\n end",
"def canonic_size( size )\n if canonic_type == :decimal && size.is_a?( Integer )\n [ size, 0 ]\n else\n size\n end\n end",
"def size\n 0\n end",
"def size\n 0\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size_mb \n return size / 1048576 # (1024 * 1024) \n end",
"def field_size\n if self[:field_size] and self[:field_size] > 0\n self[:field_size]\n else\n results.size\n end\n end",
"def picture_size\n if picture.size > 15.megabytes\n errors.add(:picture, \"should be less than 15MB\")\n end\n end",
"def size\n size = File.size(@path).to_i\n case\n when size.to_i == 1; \"1 byte\"\n when size < 1024; \"%d bytes\" % size\n when size < (1024*1024); \"%.2f kilobytes\" % (size / 1024.0)\n else \"%.2f megabytes\" % (size / (1024 * 1024.0))\n end.sub(/([0-9])\\.?0+ /, '\\1 ' )\n end",
"def size\n return params[\"size\"] if visibility == \"open\"\n if visibility == \"low_res\" || visibility == \"emory_low\"\n return \",#{IiifController.max_pixels_for_low_res}\" if size_requested_larger_than_allowed?\n params[\"size\"]\n end\n params[\"size\"]\n rescue\n IiifController.max_pixels_for_low_res\n end",
"def size\n # returns the value of the instance var @size\n @size\n # end of size method\n end",
"def size\n @size\n end",
"def file_size\n self.file_file_size\n end",
"def size\n 0\n end",
"def picture_size\n \tif picture.size > 5.megabytes\n \t\terrors.add(:picture, \"should be less than 5MB\")\n \tend\n \tend",
"def size\n @size = File.size(self.path) unless @size\n @size\n end",
"def size\n @size ||= @request[FSIZE].to_i\n end",
"def file_size\n 1000 # temporarily disable file size calculation\n # TODO: fix this in production env (perhaps zencoder is not replacing target file?)\n # self.file.size\n end",
"def picture_size\n\t\t\tif rest_err_img.size > 10.megabytes\n\t\t\t\terrors.add(:rest_err_img, \"10MB를 넘는 사진입니다.\")\n\t\t\tend\n\t\tend",
"def size\n @size\n end",
"def recalculate_filesize\n @filesize = @collection.reduce(0) {|sum,asset| sum + asset.size}\n end",
"def image_size\n end",
"def recalc_size\n if @mail.nil? or @mail.raw_source.nil?\n new_size = self.get_raw.length\n if new_size == 0\n new_size += self.subject.length unless self.subject.nil?\n new_size += self.message.length unless self.message.nil?\n new_size += self.get_attach_size\n end\n self.size = new_size\n else\n self.size = @mail.raw_source.length\n end\n end",
"def display_size\n # (1.9 ** @magnitude) / 3.0 + 2.5\n (2.15 ** @magnitude) / 3.6 + 2.5\n end",
"def size\n return @size\n end",
"def size\n return @size\n end",
"def get_shirt_size\n return @size\n end"
] |
[
"0.7068882",
"0.6993421",
"0.69619656",
"0.69619656",
"0.6867582",
"0.67240024",
"0.6692501",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66816366",
"0.66717154",
"0.66639626",
"0.664238",
"0.6637336",
"0.65943503",
"0.6589736",
"0.6584381",
"0.6574642",
"0.6571898",
"0.65643775",
"0.6559948",
"0.6549202",
"0.6548408",
"0.6548408",
"0.6528725",
"0.65216887",
"0.65204597",
"0.6484539",
"0.6480417",
"0.64718294",
"0.6466374",
"0.6466374",
"0.6462254",
"0.64606744",
"0.64606744",
"0.64606744",
"0.64606744",
"0.64606744",
"0.64606744",
"0.64606744",
"0.6458791",
"0.64579624",
"0.6448423",
"0.6446135",
"0.6440352",
"0.64359325",
"0.64298123",
"0.64288723",
"0.6418765",
"0.6418765",
"0.6418765",
"0.6414777",
"0.6408145",
"0.6408145",
"0.6401088",
"0.6401088",
"0.6401088",
"0.6396213",
"0.6390144",
"0.6389721",
"0.6386819",
"0.63818157",
"0.6378364",
"0.63779515",
"0.63747996",
"0.6349315",
"0.6346662",
"0.63386756",
"0.63360345",
"0.63324165",
"0.63312984",
"0.6331233",
"0.63308513",
"0.6330231",
"0.63184965",
"0.6303429",
"0.63019484",
"0.63019484",
"0.62964034"
] |
0.6730728
|
5
|
Use callbacks to share common setup or constraints between actions.
|
def set_event
@event = ::Event.find(params[:event_id] || params[:rollcall][:event_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
|
Only allow a trusted parameter "white list" through.
|
def rollcall_params
params.fetch(:rollcall, {}).permit(:attendance, :unregistered)
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
|
given a Rack::Request object, find which Route matches the requested path by using a regular expression via a `Regexp` object then, instantiate the Route's controller, and run the appropriate method
|
def initialize(pattern, http_method, controller_class, action_name)
@pattern = pattern
@http_method = http_method
@controller_class = controller_class
@action_name = action_name
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run(req, res)\n # The #run method will figure out what URL was requested, match it to\n # the path regex of one Route object, and finally ask the Route to\n # instantiate the appropriate controller, and call the appropriate method.\n end",
"def run(request, response)\n\n match_data = @pattern.match(request.path)\n\n route_params = Hash[match_data.names.zip(match_data.captures)]\n\n @controller_class\n .new(request, response, route_params)\n .invoke_action(action_name)\n end",
"def run(req, res)\n regex = Regexp.new(@pattern.to_s)\n match_data = regex.match(req.path)\n route_params = {}\n match_data.names.each do |key|\n route_params[key] = match_data[key]\n end\n control = @controller_class.new(req, res, route_params)\n control.invoke_action(@action_name)\n end",
"def run(req, res)\n match_data = @pattern.match(req.path)\n\n route_params = {}\n match_data.names.each do |name|\n route_params[name] = match_data[name]\n end\n\n @controller_class.new(req, res, route_params).invoke_action(action_name)\n end",
"def run(req, res)\n match_data = @pattern.match(req.path)\n route_params = (match_data) ?\n match_data.names.zip(match_data.captures).to_h\n : {}\n\n controller_instance = @controller_class.new(req, res, route_params)\n\n controller_instance.invoke_action(@action_name)\n end",
"def run(req, res)\n if matches?(req)\n controller_instance = controller_class.new(req, res, route_params(req))\n controller_instance.invoke_action(action_name)\n else\n # extra precaution! won't be hit if `Router#run` is used\n res.status = 404\n res.write(\"No route matches for #{http_method} on #{controller_class}\")\n end\n end",
"def run(req, res)\n route_params = {}\n\n match_data = @pattern.match(req.path)\n match_data.names.each do |key|\n route_params[key] = match_data[key]\n end\n\n controller = @controller_class.new(req, res, route_params)\n controller.invoke_action(@action_name)\n end",
"def run(req, res)\n @route_params = {}\n\n # I need to build route_params from the URL params\n # @pattern is the regexp\n match_data = @pattern.match(req.path)\n # * @pattern is the regexp given in the router.draw block in\n # p06_router_server.rb\n # * req.path is the url we are matching against\n # match_data gives us the MatchData object\n match_data.names.each do |name|\n @route_params[name] = match_data[name]\n end\n #this loop creates the params!\n\n controller_instance = @controller_class.new(req, res, @route_params)\n controller_instance.invoke_action(@action_name)\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def run(req, res)\n match_data = pattern.match(req.path)\n # hash = {}\n # match_data.names.each do |name|\n # hash[name] = match_data[name]\n # end\n hash = match_data.names.each_with_object({}) do |name, h|\n h[name] = match_data[name]\n end\n controller_class.new(req, res, hash).invoke_action(action_name)\n end",
"def run(req, res)\n first_matched_route = match(req)\n\n if first_matched_route\n first_matched_route.run(req, res)\n else\n res.status = 404\n res.write(\"No route matches for #{req.request_method} for #{req.path}\")\n end\n end",
"def handle(request, env)\n params = @params.dup\n path_info, script_name = env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"]\n \n return unless request_conditions.all? do |method_name, condition|\n # TODO: Refactor this... it lacks awesome\n next true unless request.respond_to?(method_name)\n matched, captures = condition.match(request)\n if matched\n params.merge!(captures)\n if method_name == :path_info\n new_path_info = @path_info.dup if @path_info\n new_path_info ||= env[\"PATH_INFO\"].sub(/^#{Regexp.escape(matched)}/, '')\n new_path_info.gsub!(SEGMENT_REGEXP) { |s| params[$2.to_sym] }\n env[\"SCRIPT_NAME\"] = Utils.normalize(request.env[\"SCRIPT_NAME\"] + matched)\n env[\"PATH_INFO\"] = Utils.normalize(new_path_info)\n end\n true\n end\n end\n \n env[\"rack_router.route\"] = self\n env[\"rack_router.params\"].merge! params\n \n @app.call(env)\n ensure\n env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"] = path_info, script_name\n end",
"def run(request, response)\n matching_route = match(request)\n\n if matching_route.nil?\n response.status = 404\n\n response.write(\"Sorry! The requested URL #{request.path} was not not found!\")\n else\n matching_route.run(request, response)\n end\n end",
"def run(req, res)\n parse_http_methods!(req)\n matching_route = match(req)\n if matching_route\n matching_route.run(req, res)\n else\n res.status = 404\n res.write \"404 route not found\"\n end\n end",
"def run(req, res)\n matched_route = match(req)\n if matched_route\n matched_route.run(req, res)\n else\n res.status = 404\n res.write(\"No route matches #{req.fullpath}\")\n end\n end",
"def do_dispatch(env)\n path = env['PATH_INFO']\n\n # Try to serve a public file\n ret = dispatch_public(env, path)\n return ret if not ret.nil?\n\n log.debug \"Checking for routes that match: #{path}\"\n route = router.match(env)\n\n if route.has_key? :ok\n dispatch_controller(route, env)\n else\n [404, {\"Content-Type\" => \"text/plain\"}, [\"404 Not Found: #{path}\"]]\n end\n end",
"def process(request_hash)\n request = Request.new(request_hash)\n case request.path\n when '/'\n index_route(request)\n when %r{^/sleep/\\d+$}\n sleep_route(request)\n else\n Response.new(\n \"No route found for #{request.path}. Try '/' or '/sleep/3'.\",\n status: 404\n )\n end\n end",
"def run(req, res)\n route_params = self.make_match_hash(req)\n controller = @controller_class.new(req, res, route_params)\n controller.invoke_action(@action_name)\n end",
"def call(env)\n route = @routes.map do |exp, meta|\n next unless matches = env[\"PATH_INFO\"].match(exp)\n meta.merge(captures: matches)\n end.compact.first\n\n return Yokunai::ErrorsController.new(env).not_found unless route\n\n request_method = env[\"REQUEST_METHOD\"]\n if route[:methods].include?(request_method)\n Object.const_get(route[:class])\n .new(env, route[:captures])\n .public_send(request_method.downcase)\n else\n Yokunai::ErrorsController.new(env).unsupported_method\n end\n end",
"def match(request)\n path = String.normalize_path(request.path)\n method = request.method\n\n match, data = nil\n @sets.each { |set|\n match, data = set[1].match(path, method)\n break if match\n }\n\n fns = []\n if match\n fns = match[3]\n\n # handle route params\n #TODO where to do this?\n request.params.merge!(Hash.strhash(self.data_from_path(path, data, match[1])))\n\n #TODO where to do this?\n request.route_path = match[4]\n end\n\n fns\n end",
"def run(req, res)\n if matches?(req)\n controller = @controller_class.new(req, res)\n controller.send(@action_name)\n end\n end",
"def route() request.route end",
"def call(request)\n compile! unless compiled?\n pattern, verb, params = *parse_request(request)\n pattern = pattern.encode(Encoding.default_external)\n candidacies = match_with(pattern)\n raise_exception(404) if candidacies.empty?\n candidacies, allows = *candidacies.partition{ |route| route.verb == verb }\n raise_exception(405, :verbs => allows.map(&:verb)) if candidacies.empty?\n candidacies.map{ |route| [route, route.params_for(pattern, params)] }\n end",
"def call_by_request(request)\n rotation do |offset|\n pattern = decode_pattern(request.path_info)\n if route = match?(offset, pattern)\n params = route.params_for(pattern, request.params)\n yield(route, params) if route.verb == request.request_method\n route\n end\n end\n end",
"def match(req)\n request = req\n @routes.each do |route|\n return route if route.matches?(request)\n end\n end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def recognized_request_for(path, request_method = nil)\n path = \"/#{path}\" unless path.first == '/'\n\n # Assume given controller\n request = ActionController::TestRequest.new({}, {}, nil)\n request.env[\"REQUEST_METHOD\"] = request_method.to_s.upcase if request_method\n request.path = path\n\n ActionController::Routing::Routes.recognize(request)\n request\n end",
"def run(req, res)\n if req.body\n check_method_param(req)\n end\n route = match(req)\n if route.nil?\n res.status = 404\n res.body = \"Cannot find route for #{req.request_method} #{req.path}\"\n else\n route.run(req, res)\n end\n end",
"def call(env)\n # Grab the verb and requested path from the env parameter\n @request = Rack::Request.new(env)\n verb = @request.request_method\n requested_path = @request.path_info\n\n # Grab the handler block from @routes if it exists\n handler = @routes.fetch(verb, {}).fetch(requested_path, nil)\n\n if handler\n # Evaluate our route handler block in the context of that instance,\n # to give it access to all of the methods (Compare: handler.call)\n result = instance_eval(&handler)\n\n if result.class == String\n # For convenience, if a handler returns a string,\n # assume that it is a successful response.\n [200, {}, [result]]\n else\n # Otherwise, return the result of the block as-is.\n result\n end\n else\n # Return a 404 with a custom error message\n # instead of the default Internal Server Error\n [404, {}, [\"Oops! No routes for #{verb} #{requested_path}\"]]\n end\n end",
"def recognize_request(path, verb=nil)\n path = \"/#{path}\" unless path.first == '/'\n # Assume given controller\n request = ActionController::TestRequest.new({})\n request.env[\"REQUEST_METHOD\"] = verb.to_s.upcase if verb\n request.path = path\n ActionController::Routing::Routes.recognize(request)\n request\n end",
"def service(request, response)\n params = @router.resolve_uri(request.request_uri)\n controller = Acoustic::Controller.from_symbol(params[:controller])\n action = params[:action]\n controller.process(action, params, request, response)\n rescue Acoustic::UnresolvableUri, Acoustic::ControllerNameError\n raise Acoustic::NotFound.new(request.request_uri)\n end",
"def run(req, res)\n route = match(req)\n if route\n route.run(req, res)\n else\n res.status = 404\n controller = Controller::Base.new(req, res)\n controller.render_content(\"404: Unable to find page '#{req.path}' \", 'text/html')\n end\n end",
"def match(req)\n @routes.each do |route|\n if route.matches?(req)\n return route\n end\n end\n\n nil\n end",
"def match(req)\n @routes.find { |route| route.matches?(req)}\n end",
"def dispatch env\n raise Gin::NotFound,\n \"No route exists for: #{env[REQ_METHOD]} #{env[PATH_INFO]}\" unless\n env[GIN_TARGET]\n\n env[GIN_APP] = self\n env[GIN_TARGET][0].call(env)\n\n rescue ::Exception => err\n handle_error(err, env)\n end",
"def match(req)\n @routes.each do |route|\n if route.matches?(req)\n return route\n end\n end\n return nil\n end",
"def route!(request)\n @@request = request\n @@routes.each do |route|\n if route.first == request.path\n return route.last.call\n break\n end\n end\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.select{|rt| rt.matches?(req) }.first\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def call(env)\n request = Rack::Request.new(env)\n raise_exception(400) unless valid_verb?(request.request_method)\n recognize(request).each do |route, params|\n catch(:pass){ return invoke(route, params) }\n end\n rescue BadRequest, NotFound, MethodNotAllowed\n $!.call\n end",
"def call(env)\n @request = Rack::Request.new(env)\n verb = @request.request_method\n requested_path = @request.path_info\n handler = @routes.fetch(verb, {}).fetch(requested_path, nil)\n\n if handler\n # give handler access to all of the methods, on the instance of Nancy::Base\n result = instance_eval(&handler)\n # If a handler returns a string, assume that it is a successful response, and so we construct a successful Rack response\n # otherwise, we return the result of the block as-is\n # [status, header, body]\n if result.class == String\n [200, {}, [result]]\n else\n result\n end\n else\n [404, {}, [\"Oops! No route for #{verb} #{requested_path}\"]]\n end\n end",
"def find_match(env)\n path = env['REQ_PATH']\n @serve.each do |pattern, block|\n case pattern\n when FalseClass\n when TrueClass\n return Match.new(self, path, block)\n when String\n if pattern=='*'\n return Match.new(self, path, block)\n elsif /^\\*?\\.[a-z]+$/ =~ pattern\n return Match.new(self, path, block) if File.extname(realpath(path))==pattern\n else\n return Match.new(self, path, block) if File.basename(realpath(path))==pattern\n end\n when Regexp\n if matchdata = pattern.match(path)\n return Match.new(self, path, block, *matchdata.to_a)\n end\n when Waw::Validation::Validator\n if pattern.validate(matching_file(path))\n return Match.new(self, path, block) \n end\n when StaticController::AbstractMatcher\n if pattern.matches?(env)\n return Match.new(self, path, block)\n end\n else\n raise WawError, \"Unrecognized wawaccess pattern #{pattern}\"\n end\n end\n nil\n end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def get_route( request )\n return nil unless defined?( RAILS_ENV ) \n ::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )\n end",
"def call(env)\n route = self.route(env)\n if route\n env['params'] = route.match(env) || {}\n route.call(env)\n else\n env['params'] = {}\n not_found.call(env)\n end\n end",
"def recognize(request)\n prepare! unless prepared?\n pattern, verb, params = parse_request(request)\n fetch(pattern, verb){|route| [route, params_for(route, pattern, params)] }\n end",
"def compile\n @clazz = eval(@controller) if not @controller.blank?\n create_segments()\n route_str = \"\"\n i = 0\n @segments.each { |seg|\n case seg\n when ControllerSegment\n @controller = seg\n route_str << \"([^/]+)\"\n seg.pos = (i += 1)\n when ActionSegment\n @action = seg\n route_str << \"([^/]+)?\"\n seg.pos = (i += 1)\n when ParamSegment\n #@action = seg\n route_str << \"([^/]+)\"\n seg.pos = (i += 1)\n else\n route_str << seg.path\n end \n }\n puts route_str\n @regex = Regexp.new(route_str)\n end",
"def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end",
"def call(env)\n rr = Rack::Request.new(env)\n l = env['rack.logger']\n db = l ? l.method(:debug) : DEBUG_NULL\n db.call(DEBUG_NAME) do\n \"[ ? ] url: #{rr.url.inspect}, path: #{rr.fullpath.inspect}\"\n end\n matches = routes_for(rr.fullpath, rr.url)\n result = nil\n matches.each do |addressive|\n env[ADDRESSIVE_ENV_KEY] = addressive\n begin\n result = (addressive.spec.callback || addressive.spec.app).call(env)\n db.call(DEBUG_NAME) do\n \"[#{result[0]}] #{addressive.spec.template.pattern} with #{addressive.variables.inspect} on #{addressive.spec.app} ( route #{addressive.data[:'routes.scanned']} / #{addressive.data[:'routes.total']} ) after #{'%.6f' % addressive.data[:duration]}\"\n end\n rescue\n db.call(DEBUG_NAME) do\n \"[!!!] #{addressive.spec.template.pattern} with #{addressive.variables.inspect} on #{addressive.spec.app} ( route #{addressive.data[:'routes.scanned']} / #{addressive.data[:'routes.total']} ) after #{'%.6f' % addressive.data[:duration]}\"\n end\n raise\n end\n if result[0] != 404\n break\n end\n end\n if result.nil?\n db.call(DEBUG_NAME) do\n \"[404] Nothing found\"\n end\n return not_found(env)\n end\n return result\n end",
"def run(req, res)\n #@action = :index\n #@method = :get\n #@pattern = /^\\/users$/\n #@class = DummyController\n \n @params = req.path\n #route_params = @params\n ControllerBase.new(req, res, @params).invoke_action(@method, @pattern, @class, @action)\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def find_by(request_or_env)\n request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env\n pattern = decode_pattern(request.path_info)\n verb = request.request_method\n rotation { |offset| match?(offset, pattern) }.select { |route| route.verb == verb }\n end",
"def run(req, res)\n route_to_run = self.match(req)\n if route_to_run.nil?\n res.status = 404\n else\n route_to_run.run(req, res)\n end\n end",
"def route_for_path(path, method=nil)\n env = Rack::MockRequest.env_for(path || \"\", {:method => method})\n req = ActionDispatch::Request.new(env)\n route, matches, params = Rails.application.routes.set.recognize(req)\n return route\n end",
"def route_to(klass_or_name, action)\n RouteToMatcher.new(klass_or_name, action)\n end",
"def run(req, res)\n matched_route = match(req)\n \n if matched_route.nil?\n res.status = 404\n else\n matched_route.run(req, res)\n end\n end",
"def run(req, res)\n controller = controller_class.new(req, res, route_params(req))\n controller.invoke_action(action_name)\n end",
"def match(request, service_request, routes) \n routes.each do |method, options|\n unless method.match(':action')\n return options[:action] if service_request.methodname == method\n else \n matcher = Regexp.escape(method).sub(':action', '([A-Za-z0-9_]*)')\n matcher = \"^#{matcher}$\"\n if match = service_request.methodname.match(matcher)\n return match[1]\n end\n end\n end\n raise \"no service route matches #{service_request.methodname}\"\n end",
"def route(agi, params=nil)\n request = {\n :uri => @uri,\n :controller => @controller,\n :method => @method,\n :id => @id,\n :options => @options\n }\n\n return if !@controller\n\n controller_name = if !@controller[/controller/]\n \"#{@controller}_controller\"\n else\n \"#{@controller}\"\n end\n\n controller_name = controller_name.classify\n controller = get_controller(controller_name)\n\n @@logger.info \"Processing Route to #{controller_name}##{@method}\"\n @@logger.info \"#{@uri}\"\n\n unless controller\n @@logger.warn(\"Nonexistant controller\")\n return set_invalid_extension(agi)\n end\n\n unless check_controller(controller)\n @@logger.warn \"Unroutable method\"\n return set_invalid_extension(agi)\n end\n\n unless check_route(controller, @method)\n @@logger.warn \"Unroutable method\"\n return set_invalid_extension(agi)\n end\n\n ctrl_instance = controller.new({\n :agi => agi,\n :params => params,\n :request => request\n })\n\n begin\n ctrl_instance.run_filter_chain :before\n ctrl_instance.method(@method).call()\n ctrl_instance.run_filter_chain :after\n rescue AGIFilterHalt => e\n LOGGER.warn e.message\n end\n end",
"def dispatch_action(request)\n method = request_method(request)\n path = request.path.sub(/\\.\\w+$/, '')\n route = @routing.detect { |r| r[0] == method && r[1] == path }\n route[2] if route\n end",
"def match(req)\n # @routes.each do |route|\n # return route if route.matches?(req)\n # end\n #\n # nil\n @routes.find { |route| route.matches?(req) }\n end",
"def handler_for_request(req)\n req.path =~ /^#{@url_prefix}\\/([^\\/]+)/\n\n return @entry_points[$1] || Borges::NotFoundHandler.new\n end",
"def add_route(string_or_regex, opts = {})\n raise \"You have to provide an :action method to call\" unless opts[:action]\n method = (opts.delete(:method) || 'GET').to_s.upcase\n # If a string, convert it to a rack-mount compatable regex, eg\n # /some/:var/in/path => /some/(?<var>.*)/in/path\n if string_or_regex.is_a?(String)\n regex_string = \"^\" + string_or_regex.gsub(/:(([^\\/]+))/){|s| \"(?<#{$1}>.*)\" } + \"$\"\n regex = %r{#{regex_string}}\n #puts regex_string # dbg\n else\n regex = string_or_regex\n end\n\n # Add the route to rack-mount\n @set.add_route(self,\n {:path_info => regex, :request_method => method.upcase},\n opts)\n end",
"def match(matcher, handler)\n routes << Route.new(matcher, handler)\n end",
"def find_route(routes, request)\n transport = request.websocket? ? 'WS' : 'HTTP'\n routes.match(request.request_method, transport, request.path)\n end",
"def match(req)\n end",
"def process(context)\n request = context.request\n\n router = @processor_map[request.request_method.downcase.to_sym]\n return 404 unless router\n begin\n processor, params = router.routing(request.path)\n rescue FancyServer::PathRouter::NoRouteMatched\n return 404\n rescue FancyServer::PathRouter::DestinationDuplicated => ex\n return {:status => 503, :body => ex.message}\n end\n return 404 unless processor\n context.params.merge!(params)\n processor.respond_to?(:to_proc) ? context.instance_eval(&processor) : processor\n end",
"def run url\n # We need to tell Micon about the `:request` scope, so the `:request` component will be\n # destroyed automatically.\n micon.activate :request, {} do\n self.request = Request.new url\n\n # Using router to get controller class and method from the url.\n # Note that You using the `:router` component as if it's just an attribute.\n controller_class, method = router.decode url\n\n # Creating controller and calling it to generate output.\n controller = controller_class.new\n\n # Note we don't need to explicitly pass the `request` to controller, it will be automatically injected.\n controller.send method\n end\n end",
"def handle_request(request)\n if request =~ /^(\\w+)\\s+(.*)\\s+HTTP/ then\n r_type = $1.downcase.to_sym\n path = $2\n log(\"Request: [#{r_type}] '#{path}'\")\n found = false\n value = nil\n @handlers.each do |handler|\n if handler[:methods].index(r_type) != nil and handler[:expr].match(path) then\n found = true\n value = handler[:handler].call(self, path, Regexp.last_match)\n break\n end\n end\n (found and value) ? value : respond_resource_not_found(path)\n else\n make_response(type = \"text/html\", compressed = false, code = 400, msg = \"Bad Request\")\n end\n end",
"def call(env)\n # Rack::Request provides convenient methods\n # for the incoming request\n request = Rack::Request.new(env)\n\n # return a 200 status for all matching routes\n @routes.each do |route|\n content = route.match(request)\n # [][-1] is an enumerable of stringable objects\n # => sometimes you want to return responses lazily (through an enumerable)\n # .to_s because you don't want this to blow up when\n # a route handler returns an array or other format\n return [200, { 'Content-Type' => 'text/plain' }, [content.to_s]] if content\n end\n\n # otherwise, return 404\n [404, {}, ['Not Found']]\n end",
"def call(env)\n request = Rack::Request.new(env)\n if redirect_trailing_slash? && (request.head? || request.get?) && request.path_info[-1] == ?/\n response = Rack::Response.new\n response.redirect(request.path_info[0, request.path_info.size - 1], 302)\n response.finish\n else\n response = recognize(request)\n env['router'] = self\n if response.is_a?(RoutingResponse)\n [response.status, response.headers, []]\n elsif response && response.route.dest && response.route.dest.respond_to?(:call)\n process_params(env, response)\n consume_path!(request, response) if response.partial_match?\n response.route.dest.call(env)\n else\n @default_app.call(env)\n end\n end\n end",
"def call(env)\n @request = Dolphy::Request.new(env)\n @response = Dolphy::Response.new\n\n router.find_route_for(request).each do |matcher, block|\n if match = router.find_match_data_for(request, with: matcher)\n response.body = [block.call(*match.captures)]\n end\n end\n\n response.status = 404 if response.body.empty?\n response.body << \"Page not found.\" if response.body.empty?\n response.finish\n end",
"def around_recognition(route, path, env, &block)\r\n unless path =~ %r(^/admin) # TODO ... should be defined through the dsl in routes.rb\r\n if match = path.match(@@pattern)\r\n section = Site.find_by_host(env[:host_with_port]).sections.root\r\n path.sub! /^#{match[0]}/, \"#{match[1]}/#{section.type.pluralize.downcase}/#{section.id}#{match[2]}\"\r\n end\r\n end\r\n yield path, env\r\n end",
"def match(req)\n @routes.detect { |route| route.matches?(req) }\n end",
"def find_route(request)\n @routes.find {|r| r.match?(request) }\n end",
"def match_for(path)\n @routes.select { |rt| rt.match?(path) }.first\n end",
"def run(req, res)\n good_route = match(req)\n if good_route.nil?\n res.status = 404\n else\n good_route.run(req, res)\n end\n end",
"def route_request\n env.logger.debug \"#{self.class} ROUTING - #{env[Goliath::Request::PATH_INFO]}\"\n if has_path = ( env[Goliath::Request::PATH_INFO] =~ /^\\/(\\w+)(\\/\\w+)*/ )\n env.logger.debug \"#{self.class} route_request:\\t pathinfo = #{$1} extended = #{$2}\"\n path_info = $1\n extended_path_info = $2\n has_path = true #it will be a number or nil - let's just make it a bool\n elsif params[:id]\n has_path = true\n end\n \n method = env[Goliath::Request::REQUEST_METHOD]\n action = case method\n when 'GET'\n has_path ? 'show' : 'index'\n when 'POST'\n has_path ? ( raise BadRequestError, \"can't post to this resource\" ) : 'create'\n when 'PUT'\n !has_path ? ( raise BadRequestError, \"no resource to PUT to\" ) : 'update'\n when 'DELETE'\n !has_path ? ( raise BadRequestError, \"no resource to DELETE\" ) : 'delete'\n else\n raise MethodNotAllowedError, \"unknown request method\"\n end\n env.logger.info \"#{self.class} route_request:\\t attempting to call #{action} action\"\n if self.respond_to?(action, true) #second param includes private methods\n env['params']['id'] = params[:id] || (path_info if has_path)\n self.send(action)\n else\n error_on MethodNotAllowedError, \"#{action} not supported for this resource\"\n end\n end",
"def route_for(name, *args); end",
"def route(path = request.path_info)\n path = path.gsub(%r{//+}, '/').gsub(%r{^/|/$}, '')\n return route_index if path.empty? || path == docs_prefix\n case path\n when %r{^(#{docs_prefix}|#{list_prefix}|#{search_prefix}|#{static_prefix})(/.*|$)}\n prefix = $1\n paths = $2.gsub(%r{^/|/$}, '').split('/')\n library, paths = *parse_library_from_path(paths)\n return unless library\n return case prefix\n when docs_prefix; route_docs(library, paths)\n when list_prefix; route_list(library, paths)\n when search_prefix; route_search(library, paths)\n when static_prefix; route_static(library, paths)\n end\n end\n nil\n end",
"def route(env)\n routes.each do |route|\n return route if route.match(env)\n end\n\n nil\n end",
"def resolve(env)\n @request = Rack::Request.new(env)\n method = env['REQUEST_METHOD']\n path = env['PATH_INFO']\n key = \"#{method} #{path}\"\n do_action(key)\n rescue StandardError => e\n puts e.message\n puts e.backtrace\n Controller.new.internal_error\n end",
"def call(env)\n @request = Rack::Request.new(env)\n @params = @path_params.merge(@request.params.symbolize_keys)\n process_response(instance_exec(self, params, request, &@block))\n end",
"def route\n @base_controller.route if @base_controller\n end",
"def recognize_with_filtering(request, &block)\n path, route, matches, params = request.env['PATH_INFO'], nil, nil, nil\n original_path = path.dup\n\n filters.run(:around_recognize, path, request.env) do\n route, matches, params = recognize_without_filtering(request)\n params || {}\n end\n\n request.env['PATH_INFO'] = original_path # hmm ...\n return nil unless route\n\n if block_given?\n return block.call(route, matches, params)\n else\n return route, matches, params\n end\n end",
"def run(req, res, options = {})\n route = match(req)\n if route\n route.run(req, res, options)\n else\n res.status = 404\n res.write(\"page #{req.path} not found\")\n res.finish\n end\n end",
"def call env\r\n raw = nil\r\n self.class.env = env\r\n #\r\n # match route\r\n # support : String, Regexp\r\n # rel - nil| body| [status,{header},[bodys]]\r\n #\r\n req = Rack::Request.new env\r\n self.class.params = req.params\r\n method = env[\"REQUEST_METHOD\"].downcase\r\n settings[:route][method.to_sym].each do |p|\r\n case p[:path]\r\n when String\r\n if env[\"REQUEST_PATH\"] == p[:path]\r\n raw = p[:proc].call\r\n end\r\n when Regexp\r\n if env[\"REQUEST_PATH\"] =~ p[:path]\r\n if !p[:extend_key].nil? # analize extend_params like /hehe/:id\r\n req.params[p[:extend_key].to_sym] = $1\r\n end\r\n raw = p[:proc].call\r\n end\r\n else\r\n throw :illegal_route\r\n end\r\n end\r\n #\r\n # anaylize raw\r\n # nil - return not_found\r\n # Array - return raw if match [fixnum, hash, array]\r\n # other - return [200, {}, [other.to_s]]\r\n #\r\n status = 200\r\n header = {}\r\n bodys = \"\"\r\n if raw.nil?\r\n not_found\r\n else\r\n bodys = raw\r\n if Array === raw\r\n status = raw[0]\r\n header = raw[1]\r\n bodys = raw[2]\r\n end\r\n if settings[:json] == true\r\n bodys = bodys.to_json\r\n end\r\n if Array === bodys\r\n bodys = bodys.map{|e| e.to_s}\r\n [status, header, bodys]\r\n else\r\n [status, header, [bodys.to_s]]\r\n end\r\n end\r\n end",
"def recognize(request, path = request.path)\n response = @root.find(request, path, @splitter.split(path))\n if response && !response.path.dynamic?\n response.path.cached_response = response\n end\n response\n end",
"def map route_object\n klass = nil\n route = nil\n action = nil\n\n # map 'root' do\n # ...\n if block_given?\n @lux_action_target = route_object\n yield\n @lux_action_target = nil\n return\n elsif @lux_action_target\n klass = @lux_action_target\n route = route_object\n action = route_object\n\n # map :foo => :some_action\n if route_object.is_a?(Hash)\n route = route_object.keys.first\n action = route_object.values.first\n end\n\n if test?(route)\n call klass, action\n else\n return\n end\n end\n\n case route_object\n when String\n # map 'root#call'\n call route_object\n when Hash\n route = route_object.keys.first\n klass = route_object.values.first\n\n if route.class == Array\n # map [:foo, :bar] => 'root'\n for route_action in route\n if test?(route_action)\n call klass, route_action\n end\n end\n\n return\n elsif route.is_a?(String) && route[0,1] == '/'\n # map '/skils/:skill' => 'main/skills#show'\n return match route, klass\n end\n when Array\n # map [:foo, 'main/root']\n route, klass = *route_object\n else\n Lux.error 'Unsupported route type \"%s\"' % route_object.class\n end\n\n test?(route) ? call(klass) : nil\n end",
"def route_path(path)\n AutoRouter::Router.map_controller(self, path: path)\n end",
"def Controller(matcher)\n make(matcher)\n end",
"def recognized_route\n unless @recognized_route\n path = params[:resource_path] || params[:erp] || request.path\n environment = ::ActionController::Routing::Routes.extract_request_environment(request)\n environment.merge!(:method => params[:resource_method]) if params[:resource_method]\n @recognized_route ||= ::ActionController::Routing::Routes.routes_for_controller_and_action(controller_path, action_name).find do |route|\n route.recognize(path, environment)\n end or ResourcesController.raise_no_recognized_route(self)\n end\n @recognized_route\n end",
"def match base, target\n base = base.split('/').slice(1, 100)\n\n base.each_with_index do |el, i|\n if el[0,1] == ':'\n params[el.sub(':','').to_sym] = nav.path[i]\n else\n return unless el == nav.path[i]\n end\n end\n\n call target\n end",
"def route(path, controller)\n plezi_initialize\n Plezi::Base::Router.route path, controller\n end",
"def match(path)\n if match = @regexp.match(path)\n params = {}\n @named.each_with_index { |name, i| params[name] = match[i + 1] } if @type == :handlers\n {\n path: path,\n title: self.flags.fetch(:title){nil},\n params: params,\n route: self\n }\n else\n false\n end\n end",
"def call(env)\n resp = Rack::Response.new\n req = Rack::Request.new(env)\n\n if req.path.match(/items/)\n item_name = req.path.split(\"/items/\").last #uses regex to split and remove the folder\n #remember that split needs to be on a string\n #ex; turn /songs/Sorry into Sorry\n item = @@items.find{|i| i.name == item_name}\n if item\n resp.write item.price #price and name are the two attributes of the item class\n else\n resp.write \"Item not found\"\n resp.status = 400\n end\n else #returns 404 status code for a bad route\n resp.status = 404\n resp.write \"Route not found\"\n end\n\n resp.finish\n end",
"def route6\n name = params[:name]\n regex = Regexp.new(Regexp.escape(name))\n end",
"def route_for(path, env = {}, &block)\n request = fake_request(env_for(path, env))\n yield request if block_given?\n Merb::Router.route_for(request)\n end"
] |
[
"0.77231866",
"0.7621417",
"0.7260797",
"0.7239324",
"0.71949935",
"0.7081032",
"0.7033232",
"0.6927674",
"0.68186677",
"0.67729425",
"0.6658452",
"0.6621485",
"0.65781134",
"0.6573535",
"0.6513002",
"0.65113986",
"0.65094686",
"0.6483362",
"0.64708066",
"0.64500195",
"0.6424005",
"0.641408",
"0.6412605",
"0.6384527",
"0.63579476",
"0.63140905",
"0.630655",
"0.6298689",
"0.6260901",
"0.6199927",
"0.6179631",
"0.6161063",
"0.6152807",
"0.6103374",
"0.60973096",
"0.60962844",
"0.60877854",
"0.60623693",
"0.60623693",
"0.6049998",
"0.6039568",
"0.6030367",
"0.6026518",
"0.5990078",
"0.59859645",
"0.5983359",
"0.5981978",
"0.598194",
"0.5962141",
"0.59596515",
"0.5942254",
"0.59421694",
"0.59374416",
"0.59374416",
"0.5920029",
"0.59119534",
"0.59070736",
"0.58818436",
"0.5871575",
"0.585806",
"0.58511335",
"0.58429855",
"0.5833073",
"0.5820315",
"0.58192366",
"0.5796357",
"0.5795778",
"0.57909566",
"0.578531",
"0.57658005",
"0.5749323",
"0.57282674",
"0.5721851",
"0.5714924",
"0.5695273",
"0.56893504",
"0.568198",
"0.5679238",
"0.56582284",
"0.56438524",
"0.5612863",
"0.5600236",
"0.5592361",
"0.5583568",
"0.55644226",
"0.55524427",
"0.55274165",
"0.55093795",
"0.5509039",
"0.54851055",
"0.5468302",
"0.5436717",
"0.54225063",
"0.541778",
"0.54163843",
"0.540537",
"0.538079",
"0.5369043",
"0.5352278",
"0.5351838",
"0.53311133"
] |
0.0
|
-1
|
true if pattern matches request path and http method matches request method
|
def matches?(req)
pattern.match(req.path) && req.request_method.downcase == http_method.to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def matches?(req)\n @pattern.match?(req.path) && @http_method.to_s.downcase == req.request_method.downcase\n end",
"def matches?(req)\n req.path =~ pattern && http_method == req.request_method.downcase.to_sym\n end",
"def matches?(req)\n match_method = req.request_method.downcase.to_sym == @http_method\n # match_pattern = req.path.match(Regexp.new(@pattern))\n match_pattern = req.path =~ @pattern\n match_method && match_pattern\n end",
"def matches?(req)\n req.path =~ pattern && req.request_method.to_s.upcase == http_method\n end",
"def matches?(req)\n @pattern.to_s.match(req.path) && @http_method.to_s.match(req.request_method.downcase)\n end",
"def matches?(req)\n !(@pattern =~ req.path).nil? && req.request_method.downcase == @http_method.to_s.downcase\n end",
"def matches?(req)\n regex = Regexp.new(@pattern.to_s)\n match_data = regex.match(req.path)\n if match_data.nil?\n return false\n else\n req.request_method.downcase.to_sym == @http_method\n end\n end",
"def matches?(req)\n !!(req.request_method.downcase.to_sym == @http_method && @pattern.match(req.path))\n end",
"def matches?(request)\n (http_method == request.request_method.downcase.to_sym) &&\n !!(pattern =~ request.path)\n end",
"def matches?(req)\n !(req.path =~ @pattern).nil? && \n req.request_method.downcase.to_sym == @http_method\n end",
"def matches?(req)\n\n @method == req.request_method.downcase.to_sym && @pattern.match(req.path)\n end",
"def matches_directly?(request_path, http_method)\n @paths.path[request_path]&.operation(http_method)\n end",
"def applies_to?(request)\n return false unless pattern\n request.path =~ Mustermann.new(pattern)\n end",
"def path_matches?(path)\n case path\n when String\n # Convert string to regex.\n pattern = path.gsub(/\\*(\\*)?/) do |match|\n if match[1]\n '.*'\n else\n '[^\\/]*'\n end\n end\n\n if Regexp.new(\"^#{pattern}$\").match request.path\n true\n else\n false\n end\n when Regexp\n if path.match request.path\n true\n else\n false\n end\n end\n end",
"def match!(env)\n return false unless @http_methods.include?(env[\"REQUEST_METHOD\"])\n return false unless @path =~ env[\"PATH_INFO\"]\n return false unless @host.nil? || @host =~ env[\"HTTP_HOST\"]\n\n true\n end",
"def matches?(path)\n return false if path.nil?\n\n send match_method, Pathname.new(path)\n end",
"def respond? request, vhost\n (request.path =~ @regex) != nil\n end",
"def matches_path?(pattern, path); end",
"def path_match(request_path)\n request_path.start_with?(path)\n end",
"def accept?(path_info)\n\t\t1\n\tend",
"def handleRequest?(path)\n\t\t\ttrue\n\t\tend",
"def route_api?\n request.get? && path.match(%r{^/api})\n end",
"def match?(_request)\n true\n end",
"def matches?(request)\n # this treats */* as html request\n return false unless request.format\n return false unless request.format.html?\n\n @exceptions.each {|p|\n return false if p.match request.path\n }\n\n true\n end",
"def ===(request)\n request.match?(@method, @path, @params)\n end",
"def route! env\n http_route = \"#{env[REQ_METHOD]} #{env[PATH_INFO]}\"\n return true if env[GIN_ROUTE] == http_route\n\n env[GIN_TARGET], env[GIN_PATH_PARAMS] =\n router.resources_for env[REQ_METHOD], env[PATH_INFO]\n\n env[GIN_ROUTE] = http_route\n\n !!env[GIN_TARGET]\n end",
"def get?\r\nHTTP_METHOD_LOOKUP[request_method] == :get\r\nend",
"def request_matches_criteria( request, pattern )\n\t\tself.log.debug \"Testing request '%s %s' against pattern: %p\" %\n\t\t\t[ request.verb, request.app_path, pattern ]\n\n\t\tcase pattern\n\t\twhen nil\n\t\t\tself.log.debug \" no pattern; calling the block\"\n\t\t\treturn yield( request )\n\n\t\twhen Regexp\n\t\t\tself.log.debug \" checking app_path with regexp: %p\" % [ pattern ]\n\t\t\tmatchdata = pattern.match( request.app_path ) or return false\n\t\t\tself.log.debug \" matched: calling the block\"\n\t\t\treturn yield( request, matchdata )\n\n\t\twhen String\n\t\t\tself.log.debug \" checking app_path: %p\" % [ pattern ]\n\t\t\trequest.app_path.gsub( %r{^/+|/+$}, '' ) == pattern or return false\n\t\t\tself.log.debug \" matched: calling the block\"\n\t\t\treturn yield( request )\n\n\t\telse\n\t\t\traise ScriptError, \"don't know how to match a request with a %p\" % [ pattern.class ]\n\t\tend\n\tend",
"def match_rule?(options)\n rules = [options].flatten\n rules.any? do |pattern|\n if pattern.is_a?(Regexp)\n @req.path =~ pattern\n else\n @req.path[0, pattern.length] == pattern\n end\n end\n end",
"def match?(path)\n has_real_path? path\n end",
"def request_path\n @path = controller_path + '#' + action_name\n def @path.is(*str)\n str.map{|s| self.include?(s)}.include?(true)\n end\n end",
"def match(request)\n path = String.normalize_path(request.path)\n method = request.method\n\n match, data = nil\n @sets.each { |set|\n match, data = set[1].match(path, method)\n break if match\n }\n\n fns = []\n if match\n fns = match[3]\n\n # handle route params\n #TODO where to do this?\n request.params.merge!(Hash.strhash(self.data_from_path(path, data, match[1])))\n\n #TODO where to do this?\n request.route_path = match[4]\n end\n\n fns\n end",
"def recognize_request(path, verb=nil)\n path = \"/#{path}\" unless path.first == '/'\n # Assume given controller\n request = ActionController::TestRequest.new({})\n request.env[\"REQUEST_METHOD\"] = verb.to_s.upcase if verb\n request.path = path\n ActionController::Routing::Routes.recognize(request)\n request\n end",
"def route? method\n if @tracker.routes[:allow_all_actions] or @tracker.options[:assume_all_routes]\n true\n else\n routes = @tracker.routes[@current_class]\n routes and (routes.include? :allow_all_actions or routes.include? method)\n end\n end",
"def post?\r\nHTTP_METHOD_LOOKUP[request_method] == :post\r\nend",
"def method_pattern\n @method_pattern || /^test_/\n end",
"def recognized_request_for(path, request_method = nil)\n path = \"/#{path}\" unless path.first == '/'\n\n # Assume given controller\n request = ActionController::TestRequest.new({}, {}, nil)\n request.env[\"REQUEST_METHOD\"] = request_method.to_s.upcase if request_method\n request.path = path\n\n ActionController::Routing::Routes.recognize(request)\n request\n end",
"def match?( path )\n path_matcher =~ path\n end",
"def check_method_param(req)\n params = URI.decode_www_form(req.body)\n method_params = params.find { |param| param.first = \"_method\" }\n if method_params\n req.instance_variable_set(:@request_method, method_params[1])\n #!!!!!!!!!!!!!!!!!!!!!!!!!!\n end\n end",
"def patch?\r\nHTTP_METHOD_LOOKUP[request_method] == :patch\r\nend",
"def api?(req)\n (req.path.start_with?('/api') || req.path.start_with?('/version.json'))\n end",
"def different_depth_or_method?(splitted_schema_path, splitted_request_path, path_item, http_method)\n splitted_schema_path.size != splitted_request_path.size || !path_item.operation(http_method)\n end",
"def jmaki_match_url(pattern)\n (pattern == '*') or (request.request_uri == pattern)\n end",
"def match?(_request)\n fail NotImplementedError\n end",
"def allowed_methods( path_components )\n\t\ttype = path_components.empty? ? :collection : :single\n\t\tallowed = HTTP_METHOD_MAPPING[ type ].keys.\n\t\t\tfind_all {|msym| self.respond_to?(msym) }.\n\t\t\tinject([]) {|ary,msym| ary << HTTP_METHOD_MAPPING[type][msym]; ary }\n\n\t\tallowed += ['HEAD'] if allowed.include?( 'GET' )\n\t\treturn allowed.uniq.sort\n\tend",
"def matches? meth\n Citero.map(\"\").respond_to?(meth) && ( directionize(meth).eql?(\"to\") || directionize(meth).eql?(meth.to_s) )\n end",
"def update_request?(http_method = nil)\n http_method = http_method.downcase.to_sym if http_method.is_a?(String)\n %i[put post patch].include?(http_method || @verb)\n end",
"def route_upload?\n request.post? && path.match(%r{^/#{doc}/upload$})\n end",
"def route?(*subdir_patterns)\n regexp = generate_regex(subdir_patterns)\n Munge::Util::BooleanRegex.match?(regexp, @route)\n end",
"def match?(path)\n @regex.match?(path)\n end",
"def request_method\r\n@request_method ||= check_method(env[\"REQUEST_METHOD\"])\r\nend",
"def http_method_modifies_resource?\n ['PUT','POST','PATCH'].include?(method.to_s.upcase)\n end",
"def respond_to?(method, include_all = false)\n if method.to_s.end_with?('_path', '_url')\n if main_app.respond_to?(method)\n true\n else\n super\n end\n else\n super\n end\n end",
"def match(path)\n if match = @regexp.match(path)\n params = {}\n @named.each_with_index { |name, i| params[name] = match[i + 1] } if @type == :handlers\n {\n path: path,\n title: self.flags.fetch(:title){nil},\n params: params,\n route: self\n }\n else\n false\n end\n end",
"def http_methods(_path)\n []\n end",
"def item_paths_match?(item)\n if item[:paths]\n\n item[:paths].each do |path|\n if path.kind_of?(Array)\n # IF path matches perfectly\n request_type_option = path[1] || \"\"\n if ((@current_path == path[0].chomp('/') and @request_type == request_type_option.downcase) or \n # OR IF * wildcard is used and path matches\n (path[0] =~ /\\*$/ and @current_path =~ /^#{path[0].chomp('*')}(.+)?$/)) and \n # all listed request params match\n params_match?(path)\n return true \n end\n else\n return true if @current_path == path\n end\n end\n\n end\n return false\n end",
"def request_type_find?\n request.env[\"PATH_INFO\"][-4..-1] == \"find\"\n end",
"def cltn_request?( path )\n path.size == 3\n end",
"def match?(request)\n request.content_type =~ %r{^application/json.*}\n end",
"def supports_path?; end",
"def authorized_path?(path, method: :get, using: nil, skip_scoping: false)\n recognized_ca = Rails.application.routes.recognize_path path,\n method: method\n controller_name = recognized_ca[:controller]\n action_name = recognized_ca[:action]\n authorized?(controller: controller_name,\n action: action_name,\n using: using,\n skip_scoping: skip_scoping)\n end",
"def http_verb(params)\n [:post, :put, :delete].detect { |method_name|\n params.key?(method_name)\n } || :get\n end",
"def match(path, method)\n path = StringUtils.normalize_path(path)\n\n @routes[method.to_sym].each{|r| \n case r[0]\n when Regexp\n if data = r[0].match(path)\n return r, data\n end\n when String\n if r[0] == path\n return r, nil\n end\n end\n }\n\n nil\n end",
"def match(request, service_request, routes) \n routes.each do |method, options|\n unless method.match(':action')\n return options[:action] if service_request.methodname == method\n else \n matcher = Regexp.escape(method).sub(':action', '([A-Za-z0-9_]*)')\n matcher = \"^#{matcher}$\"\n if match = service_request.methodname.match(matcher)\n return match[1]\n end\n end\n end\n raise \"no service route matches #{service_request.methodname}\"\n end",
"def respond_to?(method, include_private=false)\n route_macro = self.class.macros[method]\n if route_macro.nil?\n super\n else\n true\n end\n end",
"def routable_request?(env)\n return true unless defined?(Rails) # If not running on a Rails app, we can't verify if it is invalid\n Rails.application.routes.recognize_path(env['PATH_INFO'])\n true\n rescue ActionController::RoutingError\n false\n end",
"def valid_request?(request)\n request.post? && request.path == NOTIFY_PATH\n end",
"def pattern_match?\n @pattern_match\n end",
"def request_method\n {:filter => :post,\n :sample => :get,\n :firehose => :get,\n :retweet => :get\n }.fetch(@path, :get)\n end",
"def in_path?(path); end",
"def query_api_pattern(method_name, verb, path='', opts={}, &block)\n self.class.query_api_pattern(method_name, verb, path, opts, @query_api_patterns, &block)\n end",
"def match?(path)\n path =~ to_regexp\n end",
"def parse_http_methods!(req)\n if (method = req.params['_method'])\n if ['delete', 'put', 'patch'].include?(method.downcase)\n req.env['REQUEST_METHOD'] = method.upcase\n end\n end\n end",
"def request_match?(request_uri)\n uri = request_uri.is_a?(URI) ? request_uri : URI.parse(request_uri)\n domain_match(uri.host) && path_match(uri.path) && port_match(uri.port)\n end",
"def binder_routing_ok?(binder, action)\n\n\t\treturn request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)\n\n\tend",
"def respond_to? meth, include_private=false\n if(matches? meth)\n return true\n else\n super\n end\n end",
"def recognized_pattern?(pattern)\n [FalseClass, TrueClass, String, \n Regexp, Waw::Validation::Validator, StaticController::AbstractMatcher].any?{|c| c===pattern}\n end",
"def request_type_find_all?\n request.env[\"PATH_INFO\"][-8..-1] == \"find_all\"\n end",
"def is_true?(request, params)\n return (evaluate_path(params) & expected_values).any?\n end",
"def match?(request)\n match_library?(request) &&\n match_location?(request) &&\n match_current_location?(request) &&\n match_types?(request)\n end",
"def is_pathtype?(); @type == GRT_PATHTYPE; end",
"def matches_path? path\n if path_string_or_regexp.is_a?(Regexp)\n !(path_string_or_regexp =~ path).nil?\n else\n path_string_or_regexp == path\n end\n end",
"def requested_method\n\t\t\t\t# respond to websocket special case\n\t\t\t\treturn :pre_connect if request.upgrade?\n\t\t\t\t# respond to save 'new' special case\n\t\t\t\treturn (self.class.has_method?(:save) ? :save : false) if (request.request_method =~ /POST|PUT|PATCH/i.freeze) && (params[:id].nil? || params[:id] == 'new'.freeze)\n\t\t\t\t# set DELETE method if simulated\n\t\t\t\trequest.request_method = 'DELETE'.freeze if params[:_method] && params[:_method].to_s.downcase == 'delete'.freeze\n\t\t\t\t# respond to special :id routing\n\t\t\t\tparams[:id].to_s.downcase.to_sym.tap { |met| return met if self.class.has_exposed_method?(met) } if params[:id]\n\t\t\t\t#review general cases\n\t\t\t\tcase request.request_method\n\t\t\t\twhen 'GET'.freeze, 'HEAD'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:index) ? :index : false) unless params[:id]\n\t\t\t\t\treturn (self.class.has_method?(:show) ? :show : false)\n\t\t\t\twhen 'POST'.freeze, 'PUT'.freeze, 'PATCH'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:update) ? :update : false)\n\t\t\t\twhen 'DELETE'.freeze\n\t\t\t\t\treturn (self.class.has_method?(:delete) ? :delete : false)\n\t\t\t\tend\n\t\t\t\tfalse\n\t\t\tend",
"def pattern_match?\n @pattern_match == true\n end",
"def is_url?\n path =~ URL_PATHS\n end",
"def match(re)\n @method_name.match(re)\n end",
"def routable?(path)\n !!Rails.application.routes.recognize_path(path, method: :get)\n rescue ActionController::RoutingError\n false\n end",
"def test_request(method, path, params={})\n @params = indifferent_params(params)\n\n @request = Sinatra::Request.new(env)\n @request.path_info = path # sinatra 1.3.3\n\n @__protected_ivars = instance_variables + [\"@__protected_ivars\"]\n\n # routes are stored by uppercase method, but I wanted the test interface\n # to accept :get or 'get' as well as 'GET'\n test_request_internal self.class, method.to_s.upcase\n end",
"def matches_dynamic_permission_check?(method_id)\n /^can_([a-zA-Z]\\w*)\\?$/.match(method_id.to_s)\n end",
"def is_exact?\n @path.include?('*') == false\n end",
"def path?(instance, *method_names)\n !path(instance, *method_names, try: true).nil?\n end",
"def route?(path)\n path = Path.new(path)\n endpoint = endpoints[path]\n route = nil\n\n unless endpoint\n route = route_for(path)\n endpoint = endpoints[route]\n end\n\n endpoint\n end",
"def method?(meth)\n get_method(meth)\n end",
"def respond_to?(method, include_private = false)\n (actions(current_api).include? method) ? true : super\n end",
"def try_route\n\t\t\t\thttp_method = request.http_method\n\t\t\t\thttp_method = :GET if http_method == :HEAD\n\t\t\t\treturn unless available_endpoint\n\n\t\t\t\troute = available_endpoint[http_method]\n\t\t\t\treturn unless route || available_endpoint.allow\n\n\t\t\t\thalt(405, nil, 'Allow' => available_endpoint.allow) unless route\n\t\t\t\tstatus 200\n\t\t\t\texecute_route route\n\t\t\t\ttrue\n\t\t\tend",
"def check_routes_for(path, to: :somewhere, verbs: :any)\n valid_verbs = Array(verbs).map {|verb| key_http_verb(verb)}.compact.presence || http_verbs\n valid_verbs.each do |verb|\n if [:anywhere, :somewhere, nil, false].include?(to)\n expect(verb => path).to be_routable\n else\n expect(verb => path).to route_to(*Array(to))\n end\n end\n end",
"def match(path, *rest, &block); end",
"def matches_path?(expected_paths, actual_path = params, options = {})\r\n #puts \"matches_path?(expected_paths=#{expected_paths.inspect}, actual_path=#{actual_path.inspect}, options=#{options.inspect})\"\r\n options[:match] = :any\r\n actual_path = PathHash.new(actual_path)\r\n result = options[:match] == :any ? false : true\r\n\r\n expected_paths.each do |path|\r\n is_a_match = true\r\n if path.kind_of? String # do not path @TODO: should we evaluate the request URI for this?\r\n is_a_match &= false\r\n elsif path.kind_of? Proc # evaluate the proc\r\n a = path.call\r\n if (a.is_a?(TrueClass) || a.is_a?(FalseClass))\r\n is_a_match &= a\r\n else\r\n raise 'proc pathing rules must evaluate to TrueClass or FalseClass'\r\n end\r\n elsif path.kind_of? Hash\r\n h = PathHash.new(path)\r\n h.each_key do |key|\r\n # remove first slash from <tt>:controller</tt> key otherwise this could fail with urls such as {:controller => \"/base\"</tt>\r\n val = h[key].to_param.to_s.dup\r\n val.gsub!(/^\\//,\"\") if key == :controller\r\n is_a_match &= (val==actual_path[key].to_s)\r\n end\r\n else\r\n raise 'pathing rules should be String, Proc or Hash'\r\n end\r\n\r\n if options[:match] == :any\r\n result |= is_a_match and break\r\n elsif options[:match] == :all\r\n result &= is_a_match or break\r\n else\r\n raise ArgumentError, \"options[:match] must be either :any or :all but was #{options[:match]}\"\r\n end\r\n end\r\n #puts \"returning #{result}\"\r\n return result\r\n end",
"def method\r\n@method ||= check_method(env[\"rack.methodoverride.original_method\"] || env['REQUEST_METHOD'])\r\nend",
"def valid_path?(path)\n !!self.run_state.active_permissions.map(&:pattern).detect do |regex|\n regex.match(path)\n end\n end"
] |
[
"0.8694062",
"0.8691883",
"0.86916023",
"0.8680453",
"0.8507347",
"0.84543496",
"0.84454685",
"0.8444336",
"0.84255177",
"0.84204125",
"0.84002584",
"0.7951292",
"0.76980054",
"0.70834005",
"0.70634305",
"0.7055721",
"0.7008742",
"0.6931867",
"0.6877601",
"0.67988724",
"0.678209",
"0.67692715",
"0.6737022",
"0.6724663",
"0.66377634",
"0.65704435",
"0.6509717",
"0.6422242",
"0.6418135",
"0.64090896",
"0.6381244",
"0.6355475",
"0.63423294",
"0.63269013",
"0.6313675",
"0.62997955",
"0.6289559",
"0.6289445",
"0.62383604",
"0.623317",
"0.621045",
"0.62041855",
"0.6194817",
"0.61908615",
"0.61853164",
"0.61734366",
"0.6170714",
"0.61689943",
"0.6168783",
"0.6164984",
"0.61621195",
"0.6129965",
"0.6107144",
"0.6075265",
"0.6069526",
"0.6046627",
"0.6046459",
"0.60225594",
"0.6010789",
"0.59907746",
"0.59630835",
"0.5939264",
"0.5932109",
"0.59319085",
"0.5931712",
"0.59300727",
"0.59149575",
"0.59124875",
"0.5911243",
"0.58983517",
"0.5894447",
"0.5875825",
"0.5870904",
"0.5869764",
"0.5868782",
"0.5863154",
"0.5860826",
"0.5856974",
"0.5852969",
"0.58513665",
"0.58506286",
"0.58405787",
"0.58388656",
"0.5809893",
"0.57907134",
"0.57762206",
"0.5775133",
"0.57627434",
"0.57542646",
"0.574593",
"0.5743665",
"0.57430524",
"0.5739597",
"0.57379025",
"0.57231337",
"0.57141393",
"0.5705727",
"0.5700173",
"0.5699477",
"0.56983393"
] |
0.8767666
|
0
|
instantiates an instance of the controller class calls the controller's action via `ControllerBaseinvoke_action`
|
def run(req, res)
if matches?(req)
controller_instance = controller_class.new(req, res, route_params(req))
controller_instance.invoke_action(action_name)
else
# extra precaution! won't be hit if `Router#run` is used
res.status = 404
res.write("No route matches for #{http_method} on #{controller_class}")
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def call(controller, action)\n lambda {\n controller = Object.const_get(controller)\n action ||= Configuration::Base.app.default_action\n\n instance = controller.new\n request.controller = instance\n request.action = action\n\n instance.send(action)\n }\n end",
"def method_missing *args\n @controller_instance.send *args\n end",
"def call_action(handler, params, query_params)\n controller_name, action_name = handler.split('#')\n controller_class = lookup_controller(controller_name)\n controller = controller_class.new(self, params, query_params)\n controller.execute_action(action_name)\n end",
"def invoke_action(path)\n controller(path).send(action_name)\n end",
"def route(controller, action, **args)\n klass = Object.const_get(klass_for(controller)).new(**args)\n klass.send(action)\n end",
"def route(controller, action, **args)\n klass = Object.const_get(klass_for(controller)).new(**args)\n klass.send(action)\n end",
"def dispatch_to(controller_klass, action, params = {}, env = {}, &blk)\n params = merge_controller_and_action(controller_klass, action, params)\n dispatch_request(build_request(params, env), controller_klass, action.to_s, &blk)\n end",
"def route(controller, action, **args)\n klass = Object.const_get(klass_for(controller)).new(**args)\n klass.send(action)\n end",
"def initialize(controller)\n @controller = controller\n @actions = []\n end",
"def run(req, res)\n controller = controller_class.new(req, res, route_params(req))\n controller.invoke_action(action_name)\n end",
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def run(req, res)\n @params = req.params\n controller_class.send(action_name)\n end",
"def run(req, res)\n route_params = self.make_match_hash(req)\n controller = @controller_class.new(req, res, route_params)\n controller.invoke_action(@action_name)\n end",
"def run(req, res)\n if matches?(req)\n controller = @controller_class.new(req, res)\n controller.send(@action_name)\n end\n end",
"def dispatch_action(klass, action, request, response, status=200)\n # build controller\n controller = klass.build(request, response, status)\n # complete setup benchmarking\n #controller._benchmarks[:setup_time] = Time.now - start\n if @@use_mutex\n @@mutex.synchronize { controller.dispatch(action) }\n else\n controller.dispatch(action)\n end\n [controller, action]\n end",
"def controller_instance(controller_class)\n # ensure protocol compliance\n unless controller_class.method_defined?(:call) \\\n && controller_class.instance_method(:call).arity == 2\n return\n end\n controller = controller_class.new\n controller.kenji = self if controller.respond_to?(:kenji=)\n return controller if controller\n nil # default return value\n end",
"def controller(controller); end",
"def method_missing(method, *args, &block)\n if controller.respond_to?(method)\n define_singleton_method(method) do |*args, &block|\n controller.send(method, *args, &block)\n end\n send(method, *args, &block)\n else\n super\n end\n end",
"def instantiate_controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n end",
"def instantiate_controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n end",
"def instantiate_controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n end",
"def instantiate_controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n end",
"def run_action\n raise \"Action for resource #{self.class} is nil!\" if @action.nil?\n\t\t\tif (self.respond_to? @action)\n\t\t\t\tself.send(@action)\n\t\t\tend\n\t\tend",
"def initialize(controller)\n @controller = controller\n end",
"def initialize(controller)\n @controller = controller\n end",
"def _call_action(action)\n send(action)\n end",
"def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end",
"def instantiate_controller_and_action_names\n\t @current_action = action_name\n\t @current_controller = controller_name\n\tend",
"def requestAction(controller,action,params={})\n controller.class_eval{\n def params=(params); @params = params end\n def params; @params end\n }\n c = controller.new\n c.request = @_request\n c.response = @_response\n c.params = params\n c.send(action)\n c.response.body\n end",
"def invoke_action(name)\n # used for self-reflection in views\n @action = name\n\n send(name)\n end",
"def execute(*args)\n\n # Verify if the controller answers to the @action_name value\n raise WebFlowError, \"The action step #{@action_name} is not defined in your controller.\" unless args[0].respond_to? lookup_method_to_call(@action_name)\n \n # The controller defines a method with the same name as @action_name.\n # Kewl! A 'someone else problem' !!!\n args[0].send( lookup_method_to_call( @action_name ) )\n \n end",
"def rails_controller_eval(&block)\n rails_controller_instance.instance_exec(&block)\n end",
"def create_controller(ctrl_action)\n ctrl_name, action_name = ctrl_action.split('#')\n klass = Object.const_get \"#{ctrl_name.capitalize}Controller\"\n klass.new(name: ctrl_name, action: action_name.to_sym, request: request)\n end",
"def mock_action_view(base = MockActionView)\n controller = ActionView::TestCase::TestController.new\n\n base.new(view_paths, {}, controller)\n end",
"def invoke_action(action, args = {})\n raise ArgumentError, \"Browser.invoke_action expects an ActionController::Action as first parameter\"\\\n unless ::Waw::ActionController::Action===action\n location, response = fetch(relative_uri(action.uri), :post, args)\n apply_action_routing(action, JSON.parse(response.body))\n self.response\n end",
"def method_missing(method_name, *args, &block)\n if controller.respond_to? method_name\n controller.send method_name, *args, &block\n else\n super\n end\n end",
"def invoke_action(opt = {})\n raise(\"Method not implemented for this class: #{@klass}\")\n end",
"def invoke_action(name)\n check_authenticity_token unless req.request_method == 'GET'\n self.send(name)\n self.render(name.to_s) unless already_built_response?\n end",
"def receive_action(action)\n self.define_singleton_method(:perform_action, &action)\n end",
"def action _obj, _args\n \"_obj action _args;\" \n end",
"def run(req, res)\n #@action = :index\n #@method = :get\n #@pattern = /^\\/users$/\n #@class = DummyController\n \n @params = req.path\n #route_params = @params\n ControllerBase.new(req, res, @params).invoke_action(@method, @pattern, @class, @action)\n end",
"def initialize(action, model_name, controller: nil,\n parent: nil,\n models: nil,\n use_model_name: nil,\n use_base: false,\n class_name: nil,\n module_name: nil,\n grand_parent: nil,\n variables: [],\n wrapper: nil)\n self.action = action\n\n self.controller = controller\n\n self.model_name = model_name\n\n self.parent = parent\n\n self.models = models\n\n # Specify a model name as opposed to an instance in an instance variable\n # It's because there is no model in the actions 'index' and 'new'\n self.use_model_name = if use_model_name.nil?\n models ? true : false \n else\n use_model_name\n end\n\n self.grand_parent = grand_parent\n\n self.variables = variables\n\n self.wrapper = wrapper\n\n self.viewer_class = ViewerCallStringClass.new(controller, model_name,\n use_base,\n class_name, module_name)\n end",
"def exec_action_object(action)\n\t\t\taction.execute\n\t\tend",
"def method_missing(method_name, *arguments, &block)\n if controller.respond_to?(method_name)\n controller.public_send(method_name, *arguments, &block)\n else\n super\n end\n end",
"def invoke_action(name)\n self.send(name)\n render unless self.already_built_response?\n\n end",
"def renderActionInOtherController(controller,action,params)\n # controller.class_eval{\n # def params=(params); @params = params end\n # def params; @params end\n # }\n c = controller.new\n c.request = @_request\n c.response = @_response\n c.params = params\n c.send(action)\n c.response.body\n end",
"def make_controller(klass)\n @controller = eval(\"#{klass.to_s.camelize}Controller\").new\n end",
"def controller=(_arg0); end",
"def controller=(_arg0); end",
"def controller=(_arg0); end",
"def controller ; OpenStruct.new(action: :create) ; end",
"def action(klass)\n def_delegator :default, klass.action_name\n define_method klass.action_name do |*args, &block|\n new_action = klass.new self, action\n directives.values.each {|it| it.setup! new_action }\n new_action.setup! *args, &block\n new_action.new_flow\n end\n end",
"def call(*args)\n @ctx.instance_exec(args, &action)\n end",
"def controller\n @controller ||= MainController.new\n end",
"def initialize(controller)\n @controller = controller\n end",
"def invoke_action(name)\n self.send(name)\n render(name.to_s) unless already_built_response?\n end",
"def perform(action)\n case action\n when :index, :new then get action\n when :show, :edit then get action, id: 1\n when :update then put :update, id: 1\n when :create then post :create\n when :destroy then delete :destroy, id: 1\n end\n end",
"def i_invoke(action, args = {})\n result = case action\n when String\n browser.invoke_service(action, args)\n when ::Waw::ActionController::Action\n browser.invoke_action(action, args)\n else\n raise ArgumentError, \"Unable to apply i_invoke on #{action.inspect}, unable to catch the associated action\"\n end\n assert Net::HTTPSuccess===result, __last_because + \" (invoking #{action.inspect} led to: #{result})\"\n result\n end",
"def invoke_action(command, args, allow_private = false)\n session = request ? request.session || {} : {}\n if self.has_action? command, allow_private\n self.send :\"action_#{command}\", session, args\n else\n nil\n end # if-else\n end",
"def action_run\n end",
"def invoke_action(name)\n # debugger\n self.send(name)\n render(name.to_s) unless already_built_response?\n end",
"def action_start\n proxy_action(:start)\n end",
"def action_missing(name, *args)\n if name == action_name\n perform\n else\n raise AbstractController::ActionNotFound\n end\n end",
"def run(request, response)\n\n match_data = @pattern.match(request.path)\n\n route_params = Hash[match_data.names.zip(match_data.captures)]\n\n @controller_class\n .new(request, response, route_params)\n .invoke_action(action_name)\n end",
"def perform(action)\n @action_name = action\n begin\n self.send(@action_name)\n rescue\n Skates.logger.error {\n \"#{$!}:\\n#{$!.backtrace.join(\"\\n\")}\"\n }\n end\n self.render\n end",
"def run(*args)\n @action.call(args)\n end",
"def run(*args)\n @action.call(args)\n end",
"def call_action action=nil\n action ||= @action\n invoke{ dispatch action }\n invoke{ handle_status(@response.status) }\n content_type self.class.content_type unless @response[CNT_TYPE]\n @response.finish\n end",
"def call(env)\n Rango::Router.set_rack_env(env) # See rango/router/adapters/*\n request = Rango::Request.new(env)\n options = env[\"rango.router.params\"] || raise(\"rango.router.params property has to be setup at least to empty hash\")\n method = env[\"rango.controller.action\"].to_sym\n controller = self.new(env, options.merge(request.params))\n begin\n unless controller.respond_to?(method) # TODO: what about method_missing?\n raise NotFound, \"Controller #{self.name} doesn't have method #{method}\"\n end\n controller.run_filters(:before, method.to_sym)\n # If you don't care about arguments or if you prefer usage of params.\n if controller.method(method).arity.eql?(0)\n Rango.logger.debug(\"Calling method #{self.name}##{method} without arguments\")\n controller.response.body = controller.method(method).call\n else\n args = controller.params.values\n Rango.logger.debug(\"Calling method #{self.name}##{method} with arguments #{args.inspect}\")\n controller.response.body = controller.method(method).call(*args)\n end\n controller.run_filters(:after, method)\n return controller.response.finish\n rescue HttpError => exception\n controller.rescue_http_error(exception)\n end\n end",
"def invoke_action(name)\n self.send(name)\n render(name) unless already_built_response?\n end",
"def invoke_action(name)\n self.send(name)\n render(name) unless already_built_response?\n end",
"def dispatch_request(request, controller_klass, action, &blk)\n controller = controller_klass.new(request)\n yield controller if block_given?\n controller._dispatch(action)\n\n Merb.logger.info controller._benchmarks.inspect\n Merb.logger.flush\n\n controller\n end",
"def controller\n @controller ||= ApplicationController.new\n end",
"def dispatch(request)\n # {{{\n benchmark_start_time = Time.now \n\n params = Aurita::Attributes.new(request)\n params[:_request] = request\n params[:_session] = Aurita::Session.new(request)\n params[:_logger] = @logger\n params[:_application] = @application\n status = 200\n response_body = ''\n response_header = {}\n\n controller = params[:controller]\n action = params[:action]\n mode = params[:mode]\n controller ||= 'App_Main'\n action ||= 'start'\n mode ||= 'default'\n\n Thread.current['request'] = params\n\n Lore::Connection.reset_query_count()\n Lore::Connection.reset_result_row_count()\n\n begin\n raise ::Exception.new('No controller given') if(controller.nil? || controller == '') \n\n model_klass = @application.get_model_klass(controller)\n controller_klass = @application.get_controller_klass(controller)\n\n raise ::Exception.new('Unknown controller: ' << controller.inspect) unless controller_klass\n \n controller_instance = controller_klass.new(params, model_klass)\n\n response = false\n @logger.debug(\"Calling model interface method #{controller}.#{action}\")\n\n element = controller_instance.call_guarded(action)\n response = controller_instance.response\n if response[:html] == '' then\n if element.is_a?(Aurita::GUI::XML::Document) then\n # Don't use default decorator for XML documents: \n response[:mode] = :none if (!response[:mode] || response[:mode] == :default)\n response[:html] = element.string \n elsif element.respond_to?(:string) then\n # Response is an instance of Aurita::GUI::Element\n response[:html] = element.string \n response[:script] << element.script if element.respond_to?(:script) && element.script\n elsif element.is_a?(Array) then\n element.each { |e|\n response[:html] << e.to_s\n }\n end\n end\n\n response_header.update(response[:http_header]) if response[:http_header]\n if response_header['status_code'] then\n status = response_header['status_code'].to_i \n response_header.delete('status_code')\n end\n\n mode = response[:mode].to_sym if response && response[:mode]\n mode ||= :default \n response[:mode] = mode\n params[:_controller] = controller_instance\n\n response_body = @decorator.render(model_klass, response, params)\n\n @num_dispatches += 1\n\n @benchmark_time = Time.now-benchmark_start_time\n @num_queries = Lore::Connection.query_count\n @num_tuples = Lore::Connection.result_row_count\n Aurita::Plugin_Register.call(Hook.dispatcher.request_finished, \n controller_instance, \n :dispatcher => self, \n :controller => controller_instance, \n :action => action, \n :time => @benchmark_time, \n :num_queries => @num_queries, \n :num_tuples => @num_tuples)\n @logger.debug(\"Num queries: #{@num_queries}\")\n rescue Exception => excep\n @logger.error(excep.message)\n @logger.error(excep.backtrace.join(\"\\n\"))\n response_body = GUI::Error_Page.new(excep).string\n response_body = ''\n end\n\n return [ status, response_header, response_body ]\n end",
"def controller_class; end",
"def controller_class; end",
"def initialize(controller)\n @controller = controller\n end",
"def run(req, res)\n match_data = @pattern.match(req.path)\n route_params = (match_data) ?\n match_data.names.zip(match_data.captures).to_h\n : {}\n\n controller_instance = @controller_class.new(req, res, route_params)\n\n controller_instance.invoke_action(@action_name)\n end",
"def instance\n @controller.instance_variable_get(:\"@#{instance_name}\")\n end",
"def initialize(controller)\n end",
"def invoke_action(name)\n check_authenticity_token if self.class.protect_from_forgery? && !get_request?\n\n send( name )\n render( name ) unless already_built_response?\n end",
"def method_missing(*args, &block)\n return nil unless @controller_context\n @controller_context.send(*args, &block)\n end",
"def load\n @load_controller = @controller\n end",
"def invoke_action(name)\n self.send(name)\n #Rails Magic: Default calls render on appropriate method even if the programmer doesn't :\n render(name) unless already_rendered?\n end",
"def initialize(name, run_context=nil)\n super\n @action = :create\nend",
"def _rails_controller_instance\n controller = rails_controller.new\n rails_request = ActionDispatch::Request.new(scope.env)\n\n prepare_rails_controller(controller, rails_request)\n\n controller\n end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def entry\n @controller.send(:entry)\n end",
"def method_for_action(action_name); end"
] |
[
"0.7474626",
"0.72478616",
"0.7019688",
"0.68259573",
"0.6815727",
"0.6815727",
"0.67436266",
"0.67423713",
"0.6707092",
"0.6687487",
"0.6666688",
"0.6666688",
"0.66661525",
"0.657121",
"0.65226966",
"0.65173906",
"0.65009356",
"0.64606637",
"0.64088315",
"0.63938195",
"0.63457775",
"0.6320858",
"0.6320858",
"0.6320858",
"0.6304023",
"0.63010967",
"0.63010967",
"0.6300507",
"0.62856436",
"0.6268571",
"0.6267415",
"0.6266922",
"0.62521094",
"0.6239338",
"0.62200063",
"0.621859",
"0.6203237",
"0.61752623",
"0.6163083",
"0.61147976",
"0.6108866",
"0.61018354",
"0.60955155",
"0.60943043",
"0.607261",
"0.6044862",
"0.60408175",
"0.60259074",
"0.6019379",
"0.60102636",
"0.60102636",
"0.60102636",
"0.5987902",
"0.5986191",
"0.59822035",
"0.5980438",
"0.59799135",
"0.5968178",
"0.59604925",
"0.5955456",
"0.59452474",
"0.59446216",
"0.59435207",
"0.5934526",
"0.59324175",
"0.59284663",
"0.5913681",
"0.5907289",
"0.5907289",
"0.5906315",
"0.5893147",
"0.58789647",
"0.58789647",
"0.58685875",
"0.58669466",
"0.58420587",
"0.5837333",
"0.5837333",
"0.58336306",
"0.5825614",
"0.58191466",
"0.5818795",
"0.581499",
"0.58109146",
"0.57963353",
"0.57934624",
"0.5790015",
"0.57862145",
"0.578451",
"0.578451",
"0.578451",
"0.578451",
"0.578451",
"0.578451",
"0.578451",
"0.578451",
"0.578451",
"0.578451",
"0.57757056",
"0.5775295"
] |
0.6194275
|
37
|
append new route to the list of routes
|
def add_route(pattern, method, controller_class, action_name)
@routes << Route.new(pattern, method, controller_class, action_name)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add(new)\n @routes << new\n end",
"def add_route(route)\n @routes << route\n route\n end",
"def append(&block)\n prepare(routes, [], &block)\n end",
"def add_route(*p, &b)\n @routes ||= routes.dup\n @routes.route(*p, &b)\n end",
"def add_route(*args)\n custom_routes << args\n end",
"def add(routes_refine)\n\t\t\troutes.deep_merge! routes_refine.routes\n\t\t\treverse_routes.merge! routes_refine.reverse_routes\n\t\tend",
"def add_route_with_a_vengeance(route) #:nodoc:\n last_route = routes.pop\n raise \"the default route is not the last route in config/routes.rb\" unless last_route.to_s == \"ANY /:controller/:action/:id/ {}\"\n routes << route << last_route\n end",
"def add_route(*args, &block)\n route = Route.new(*args, &block)\n @routes << route\n route\n end",
"def addRoute(route)\n @routes.push route\n addRouteValue(@fromNodeMap, route.startStation, route)\n addRouteValue(@toNodeMap, route.endStation, route)\n end",
"def add_route(route)\n @cache.clear\n process_route(route)\n end",
"def add_routes(&block)\n @router ||= Routes.new\n @router.define(&block)\n url.router = @router\n end",
"def add_route(route)\n @stations[@index].departure(self) unless @current_station.nil?\n @stations = route.stations\n @index = 0\n @current_station = @stations[@index]\n @stations[@index].arrival(self)\n end",
"def add_route( verb, path, route )\n\t\tre = Regexp.compile( '^' + path.join('/') + '$' )\n\n\t\t# Make the Hash for the specified HTTP verb if it hasn't been created already\n\t\tself.routes[ re ][ verb ] = route\n\tend",
"def add_route(pattern, method, controller_class, action_name)\n new_route = Route.new(pattern, method, controller_class, action_name)\n @routes << new_route\n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def add(path, vertical=nil)\n sr = path\n sr = SimpleRoute.new(path) unless path.is_a?(SimpleRoute)\n self << sr\n @by_path[path] = sr\n @by_name[sr.name] = sr\n add_to_vertical(sr, vertical) if vertical\n end",
"def addRouteValue(nodeMap, station, route)\n routeList = nodeMap[station]\n \n if (routeList == nil)\n routeList = nodeMap[station] = []\n end\n \n routeList.push(route)\n end",
"def add_route(pattern, method, controller_class, action_name)\n @routes << Route.new(pattern, method, controller_class, action_name)\n end",
"def add_route(pattern, method, controller_class, action_name)\n @routes << Route.new(pattern, method, controller_class, action_name)\n end",
"def add_route(pattern, method, controller_class, action_name)\n @routes << Route.new(pattern, method, controller_class, action_name)\n end",
"def add_route(pattern, method, controller_class, action_name)\n @routes << Route.new(pattern, method, controller_class, action_name)\n end",
"def << route\n raise \"Argument must be an Endpoint\" unless Endpoint === route\n _base, *subroute = route[:_path].split '/' # Split out first element\n if subroute.count == 0\n route[:_path] = \"\"\n @endpoints << route\n else\n route[:_path] = subroute.join '/'\n self[subroute[0]] << route\n end\n end",
"def add(verb, path, options = {}, &block)\n routes << (route = Route.new(path, verb, options, &block))\n route.router = self\n route\n end",
"def route(path, opts = {}, &block)\n @@routes << [path, opts, block]\n end",
"def add(path, options = nil)\n add_route route(path.dup).with_options(options)\n end",
"def add_route(route={})\n request :post, '/routes', route\n end",
"def routes\n @routes ||= []\n end",
"def register\n @index = Router.routes.size\n Router.routes << self\n self\n end",
"def <<(new_path)\n @locations.unshift(new_path)\n end",
"def add_route_to_locale(locale, route)\n for i in 1..6\n existing = locale.send(\"route_#{i}\")\n \n # If there is no route at the given index, create a route and add it at the given index\n if existing.nil?\n locale.send(\"route_#{i}=\", route)\n locale.save\n break\n end\n end \n end",
"def add_route(*args)\n route = super\n @named_routes[route.name] = route if route.name\n @generation_key_analyzer << route.generation_keys\n route\n end",
"def ensure_route(route)\n unless self.routes.member?(route) or route.blank?\n self.routes << route\n end\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def <<(route)\n unless route.is_valid_route?\n @errors += \"Route #{route.start_city}-#{route.end_city}#{route.distance} is invalid\\n\"\n end\n self.push route\n end",
"def add_station_in_to_route\n if @routes.empty?\n routes_void\n else\n request = [\"Enter route name [#{@routes.keys.join(', ')}]: \"]\n route = getting(request, :approve_route_selection, :select_route)\n request = request_station\n station = getting(request, :approve_station_for_route, :select_station)\n station_added if route.add_station(station)\n end\n end",
"def add(resource)\n if @list.key? resource.route\n raise DuplicateResource, \"A resource accessible via #{resource.http_verb} #{resource.url} already exists\"\n end\n @list[resource.route] = resource\n end",
"def add(*nodes)\n @mutex.synchronize do\n raise \"Trying to add nodes to a sealed router!\" if @sealed \n nodes.each do |node|\n node.uri_specs.each do |action, specs|\n specs.each do |spec|\n if spec.valid? and spec.app and spec.route != false\n @routes << spec\n @actions[spec] = [node, action]\n end\n end\n end\n end\n @immaterial = true\n end\n return self\n end",
"def add_route path, controller, &block\n\t\t\t\t@active_host ||= add_host :default\n\t\t\t\t@active_host.routes << ::Plezi::Base::Route.new(path, controller, &block)\n\t\t\tend",
"def add_resource_route( resource, info)\n\n namespaces = resource.split('::')\n resource_name = namespaces.pop\n h = @resources_routes\n namespaces.each do |namespace|\n h[namespace] ||= {}\n h = h[namespace]\n end\n h[resource_name] ||= []\n h[resource_name].push(info)\n\n# @resources_routes[resource.to_sym] ||= []\n# @resources_routes[resource.to_sym].push( info )\n end",
"def add_to_routes m\n file_to_update = 'config/routes.rb'\n line_to_add = \"map.resources :casein_#{controller_file_name}\"\n insert_sentinel = 'CaseinAddRoutes::mapper map'\n gsub_add_once m, file_to_update, \" \" + line_to_add, insert_sentinel\n logger.route line_to_add\n end",
"def add(verb, path, options = {}, &block)\n route = Route.new(path, verb, options, &block)\n route.router = self\n @routes << route\n route\n end",
"def add_shared_route path, controller, &block\n\t\t\t\tadd_host :default if @hosts.empty?\n\t\t\t\t@hosts.each {|n, h| h.routes << ::Plezi::Base::Route.new(path, controller, &block) }\n\t\t\tend",
"def add(entry)\n _check_open!\n ::Dnet.route_add(@handle, entry)\n end",
"def parse_routes!\n allowed_routes.each do |route|\n if (endpoint = endpoints.find_from_route(route))\n endpoint.merge_http_methods!(route[:http_methods])\n else\n controller = controllers.find_or_create_from_route(route)\n endpoint = endpoints.create_from_route(route, controller)\n\n controller.add_endpoint(endpoint)\n end\n end\n end",
"def add(pattern, dest, options)\n options[:prio]=255 unless options[:prio] # default\n @route[pattern]=RouteEntry.new(dest, options)\n end",
"def add_to_routes(route_str = '')\n inject_into_file('config/routes.rb', optimize_indentation(\"#{route_str.strip}\\n\", 2), after: \"\\s# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html\\n\")\nend",
"def add(route_id, source_path, target_url, request_method)\n if source_path.start_with?('/admin')\n Rails.logger.error(\"😱 Attempt to add admin route '#{source_path}' was cancelled.\")\n return\n end\n\n route = create_route_object(route_id, source_path, target_url, request_method)\n\n Disraptor::RouteStore.add_route(route_id, route)\n\n return route\n end",
"def handle(pattern, &block)\n @routes << [pattern, block]\n end",
"def routes\n @route_map.dup\n end",
"def inject_routes\n routing_code = \"Hydra::BatchEdit.add_routes(self)\"\n sentinel = /HydraHead.add_routes\\(self\\)/\n inject_into_file 'config/routes.rb', \"\\n #{routing_code}\\n\", { :after => sentinel, :verbose => false }\n\n routing_code = \"\\n # This must be the very last route in the file because it has a catch all route for 404 errors.\n # This behavior seems to show up only in production mode.\n mount Sufia::Engine => '/'\\n\"\n sentinel = /devise_for :users/\n inject_into_file 'config/routes.rb', routing_code, { :after => sentinel, :verbose => false }\n \n end",
"def add_item_routing_rule(rule)\n @item_routing_rules << rule\n end",
"def for(path, *args)\n arg = args[0]\n log.debug \"Adding route, path: #{path}, args: #{args.inspect}\"\n\n match = get_regex_for_route(path, arg)\n hash = get_to_hash(arg)\n route_info = {:regex => match[:regex], :args => arg, :vars => match[:vars], :hash => hash}\n \n # Add the HTTP methods for this route if they exist in options\n route_info[:methods] = arg[:methods] if not arg.nil? and arg.has_key? :methods\n \n self.routes.push(route_info)\n end",
"def addRoute(id, likes, dislikes)\n\t\t@routes.push({:id => id, :likes => likes, :dislikes => dislikes})\n\t\taverageRanking = likes * 1.0 / (likes + dislikes)\n\t\ttotalRanking = 0\n\t\t\n\t\tfor i in 0..(@averageRank.count)\n\t\t\ttotalRanking = totalRanking + averageRanking\n\t\tend\n\t\t\n\t\taverage = (totalRanking + averageRanking) / totalRanking\n\t\t\n\t\t@averageRank.push({:id => id, :average => average})\n\tend",
"def data_add_stations\n @routes[0].stations.insert(-2, @stations[1])\n @routes[0].stations.insert(-2, @stations[2])\n @routes[2].stations.insert(-2, @stations[1])\n end",
"def match(*options)\n @matches << Route.new(options)\n end",
"def map(path, options = {}, method = nil, &block)\n route = router.add(path, options)\n route.send(method) if method\n route.to(&block)\n @ins << router unless @ins.last == router\n route\n end",
"def relation_user_route event\n return if event.nil? or event.route.nil?\n\n self.user.routes << event.route\n event.route.save\n end",
"def initialize( routes=[], options={} )\n\t\troutes.each do |tuple|\n\t\t\tself.log.debug \" adding route: %p\" % [ tuple ]\n\t\t\tself.add_route( *tuple )\n\t\tend\n\tend",
"def post_route(route, message)\n raise TypeError unless route.is_a? Route\n @changeset = @api.create_changeset(message, tags={'created_by'=>'ITCR'})\n ways_list = []\n nodes_list = create_node_list(route.path)\n\n until nodes_list.empty? # For node's maximum limit of a way\n way_nodes = nodes_list.take(MAX_NODES)\n nodes_list = nodes_list.drop(MAX_NODES)\n way_id = create_way(way_nodes)\n ways_list << way_id\n end\n\n relation = create_relation(ways_list) # Link ways to relation\n relation = add_stops(relation, route.stops) # Add bus stops to relation\n\n @api.save(relation, @changeset) # Save relation using the API\n puts 'Relation created succesfuly.'\n @api.close_changeset(@changeset)\n @changeset.id\n end",
"def add ctrl, base_path=nil, &block\n base_path ||= ctrl.controller_name\n\n mount = Mount.new(ctrl, base_path, @sep, &block)\n\n mount.each_route do |route_ary, name, val|\n curr_node = @routes_tree\n\n route_ary.each do |part|\n curr_node.add_child part\n curr_node = curr_node[part]\n end\n\n curr_node.value = val\n route = [route_ary[0], \"/\" << route_ary[1..-1].join(@sep), val[2]]\n\n @routes_lookup[name] = route if name\n @routes_lookup[val[0..1]] = route\n end\n end",
"def route(args)\n routes=Routes.instance\n (cmd, pattern, dest, opts)=args\n\n d=URI::parse(dest)\n\n case cmd # route [add|remove]\n when :add\n routes.add(pattern, d, opts)\n when :remove\n routes.remove(pattern, d, opts)\n end\nend",
"def reload_routes!; end",
"def reload_routes!; end",
"def add_station_to_route(route)\n available_stations = Station.all.reject { |item| route.stations.include?(item) }\n\n return add_station_to_route_core(available_stations, route) unless available_stations.empty?\n\n show_info_for_action('adding Station to Route')\n show_info_you_need_at_least('1 Station not assigned to Route', 0)\n\n create_station_advanced\n\n add_station_to_route(route)\n end",
"def routes_normal\n return Array.new\n end",
"def <<(token)\n route, field, data = token.as_result\n\n if @routes.key? route\n @routes[route][field] = data\n else\n @routes[route] = field == :body ? data : { field => data }\n end\n end",
"def match(matcher, handler)\n routes << Route.new(matcher, handler)\n end",
"def append(*paths) = add(paths, position: :last)",
"def add_route( rule, output_channel )\n validate_arguments( binding() )\n routes.push( RouteSpecification.new( rule, output_channel ) )\n end",
"def add_route_to_locale(locale, source, points)\n for i in 1..6\n route = locale.send(\"route_#{i}\")\n \n # If there is no route at the given index, create a route and add it at the given index\n if route.nil?\n route = Route.create(name: \"Route #{DateTime.now}\", points_on_route: points)\n route.sources.push(Source.create(link: source))\n route.save\n locale.send(\"route_#{i}=\", route)\n locale.save\n break\n elsif route.points_on_route == points\n route.sources.push(Source.create(link: source))\n route.save\n break\n end\n end \n end",
"def add_route(station, line)\n Neo4j::Transaction.run do\n rel = Neo4j::Relationship.create(:route, self, station)\n rel[:distance] = 1.0\n rel[:line] = line\n end\n\n self\n end",
"def prepend(&block)\n prepare([], routes, &block)\n end",
"def routes(&block); end",
"def routes(&block); end",
"def append(path_step)\n\t\t@sequence.push(path_step)\n\tend",
"def register_route(protocol, verb, match, args, block)\n @routes[protocol] ||= {}\n @routes[protocol][verb] ||= {}\n @routes[protocol][verb][match] = { block: block, args: args }\n end",
"def add_routes(routes)\n \n return if skip_method(__method__)\n \n write_artifact(\"config/routes.rb\") do |file|\n file.puts(\"Rails.application.routes.draw do\")\n file.puts(\"\n concern :common_routes do\n get :range, on: :collection\n # handles requests where relation is a query param (RestAngularBuilder)\n # e.g. users/1/related.json?relation=department\n get :related \n post :search\n end\")\n \n if namespace\n file.puts(\" namespace :#{namespace} do\")\n end\n routes.each do |route|\n namespace.nil? ? file.puts(route) : file.puts(indent(route))\n end\n if namespace\n file.puts(\" end\")\n end\n file.puts(\"end\")\n end\n\n end",
"def add_path(station_id1, station_id2, minutes)\n\t\taction = [\"MOVE\", station_id1, station_id2, minutes]\n\t\t@path.push(action)\n\tend",
"def add_route(url_string, rack_app)\n @mount_points = @mount_points || []\n @mount_points << {url_string: url_string, rack_app: rack_app}\n end",
"def method_added(id)\n\t\t\t\treset_routing_cache\n\t\t\tend",
"def method_added(id)\n\t\t\t\t\treset_routing_cache\n\t\t\t\tend",
"def add(path); end",
"def manage_routes_add_route\n @ui.manage_routes_add_route_msg(routes, stations)\n station_one_name = gets.chomp\n station_two_name = gets.chomp\n manage_routes_add_route_adding(station_one_name, station_two_name)\n rescue RuntimeError => e\n puts e.inspect\n @attempt += 1\n if @attempt < 3\n puts @ui.wrong_input_msg\n retry\n end\n @attempt = 0\n end",
"def routes\n routes_method.call\n end",
"def route(verb, path, &block)\n signature = compile!(verb, path, block, {})\n (routes[verb] ||= []) << signature\n end",
"def _routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end"
] |
[
"0.814691",
"0.7889601",
"0.75391996",
"0.7270183",
"0.71935594",
"0.6888049",
"0.6882136",
"0.6855779",
"0.68339396",
"0.67256325",
"0.6723671",
"0.6703784",
"0.6680658",
"0.6605853",
"0.65420145",
"0.65420145",
"0.6529651",
"0.6513503",
"0.64754647",
"0.64754647",
"0.64754647",
"0.64754647",
"0.6452305",
"0.64274025",
"0.6392681",
"0.6387223",
"0.6370942",
"0.6368902",
"0.63455933",
"0.6334687",
"0.6327347",
"0.63262486",
"0.6316551",
"0.6305781",
"0.6305781",
"0.6287945",
"0.6286966",
"0.626327",
"0.62487614",
"0.62437093",
"0.62325937",
"0.6146236",
"0.61161655",
"0.6070856",
"0.6042031",
"0.6001451",
"0.5995215",
"0.5968063",
"0.5961245",
"0.59507525",
"0.59489226",
"0.5945221",
"0.5941437",
"0.5915345",
"0.5904605",
"0.5882253",
"0.58638066",
"0.58287126",
"0.5805514",
"0.579739",
"0.5791377",
"0.5784371",
"0.5763056",
"0.57608634",
"0.57608634",
"0.57544816",
"0.57468766",
"0.57412213",
"0.5736945",
"0.5714128",
"0.5705079",
"0.5703992",
"0.56973916",
"0.5651324",
"0.56175864",
"0.56175864",
"0.56125784",
"0.5605908",
"0.55974525",
"0.5593185",
"0.5592424",
"0.5576206",
"0.55552226",
"0.5534279",
"0.5533129",
"0.55181116",
"0.55006254",
"0.54957193",
"0.5491703",
"0.5491703",
"0.5491703",
"0.5491703",
"0.5491703",
"0.5491703"
] |
0.665532
|
16
|
return the route that matches this request
|
def match(req)
@routes.find { |route| route.matches?(req) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def route\n @route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}\n end",
"def get_route( request )\n return nil unless defined?( RAILS_ENV ) \n ::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )\n end",
"def match(req)\n @routes.select{|rt| rt.matches?(req) }.first\n end",
"def route\n @route\n end",
"def find_route(request)\n @routes.find {|r| r.match?(request) }\n end",
"def match(req)\n @routes.each do |route|\n if route.matches?(req)\n return route\n end\n end\n\n nil\n end",
"def extract_route\n Xhive::Router::Route.find(request.path)\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def match(req)\n request = req\n @routes.each do |route|\n return route if route.matches?(request)\n end\n end",
"def route() request.route end",
"def match_for(path)\n @routes.select { |rt| rt.match?(path) }.first\n end",
"def match(req)\n @routes.each do |route|\n if route.matches?(req)\n return route\n end\n end\n return nil\n end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def route(env)\n routes.each do |route|\n return route if route.match(env)\n end\n\n nil\n end",
"def route\n return @children['route'][:value]\n end",
"def get_requested_route(env)\n request = Rack::Request.new(env)\n \n http_method = request.request_method.downcase\n path = request.path_info\n\n [http_method, path]\n end",
"def match(req)\n # @routes.each do |route|\n # return route if route.matches?(req)\n # end\n #\n # nil\n @routes.find { |route| route.matches?(req) }\n end",
"def recognized_route\n unless @recognized_route\n path = params[:resource_path] || params[:erp] || request.path\n environment = ::ActionController::Routing::Routes.extract_request_environment(request)\n environment.merge!(:method => params[:resource_method]) if params[:resource_method]\n @recognized_route ||= ::ActionController::Routing::Routes.routes_for_controller_and_action(controller_path, action_name).find do |route|\n route.recognize(path, environment)\n end or ResourcesController.raise_no_recognized_route(self)\n end\n @recognized_route\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.find { |route| route.matches?(req)}\n end",
"def find_route(routes, request)\n transport = request.websocket? ? 'WS' : 'HTTP'\n routes.match(request.request_method, transport, request.path)\n end",
"def came_from_route\n @came_from_route\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def match(req)\n @routes.find { |route| route.matches?(req) }\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def route_name; end",
"def route_name; end",
"def route!(request)\n @@request = request\n @@routes.each do |route|\n if route.first == request.path\n return route.last.call\n break\n end\n end\n end",
"def match(req)\n @routes.detect { |route| route.matches?(req) }\n end",
"def route_name_for_padrino(request)\n request.route_obj.original_path\n rescue\n nil\n end",
"def route(stock_url)\n url=stock_url.split(/\\/+/).join(\"/\")\n @routes.keys.each do |x|\n #@logger.msginfo(\"Main:route:Looking at '#{url}' (#{url[0,@routes[x]['path_length']]}) for '#{x}'\")\n if (x == url[0,@routes[x][\"path_length\"]])\n #@logger.msginfo(\"Main:route: #{@routes[x][\"handler\"].class.to_s} will do '#{url}'\")\n return @routes[x][\"handler\"]\n end\n end\n return nil #Bad, nothing matched\n end",
"def routes\n request :get, '/routes'\n end",
"def processed_route\n return @original_route unless any_wildcard?\n as_regex\n end",
"def match(path, method)\n path = StringUtils.normalize_path(path)\n\n @routes[method.to_sym].each{|r| \n case r[0]\n when Regexp\n if data = r[0].match(path)\n return r, data\n end\n when String\n if r[0] == path\n return r, nil\n end\n end\n }\n\n nil\n end",
"def route\n #TODO\n end",
"def find_route(url)\n @routes.each do |route|\n if route.match(url)\n return route\n end\n end\n nil\n end",
"def full_route\n @parent ? (ancestors.reverse + [self]).map(&:route).join('/').squeeze('/') : route\n end",
"def inspect\n route.to_s\n end",
"def route\n @route ||= self.route_id ? Route.find_by_id(self.route_id) : nil\n end",
"def route\n @route ||= self.route_id ? Route.find_by_id(self.route_id) : nil\n end",
"def check_request_for_route(request)\n match = ::Merb::Router.match(request)\n if match[0].nil? && match[1].empty?\n raise ::Merb::ControllerExceptions::BadRequest, \"No routes match the request. Request uri: #{request.uri}\"\n else\n match[1]\n end\n end",
"def routes\n [@name.downcase]\n end",
"def first\n @routes[0]\n end",
"def action_for route\n raise \"Argument must be an Endpoint\" unless Endpoint === route\n action = @prefix[-1]\n action = PARAM_ROUTES[route[:method]] if self.action_mode == :param\n action = RESOURCE_ROUTES[route[:method]] if self.route_mode == :resource && self.action_mode == :collection\n action\n end",
"def all_routes\n matching_routes\n end",
"def route_name\n @route_name || default_route_name\n end",
"def recognized_routes_for(env)\n Array(router.recognize(env).first)\n end",
"def route_for_path(path, method=nil)\n env = Rack::MockRequest.env_for(path || \"\", {:method => method})\n req = ActionDispatch::Request.new(env)\n route, matches, params = Rails.application.routes.set.recognize(req)\n return route\n end",
"def get_default_route\n return @m_default_route\n end",
"def routes\n context[:routes]\n end",
"def path_of(route_or_controller, action = nil)\n\t\t\tif route_or_controller.is_a?(Flame::Router::Route)\n\t\t\t\troute = route_or_controller\n\t\t\t\tcontroller = route.controller\n\t\t\t\taction = route.action\n\t\t\telse\n\t\t\t\tcontroller = route_or_controller\n\t\t\tend\n\t\t\treverse_routes.dig(controller.to_s, action)\n\t\tend",
"def route_mode\n mode = :resource\n mode = :namespace if @endpoints.count == 0\n mode = :action if @subroutes.count == 0 && @parent && @parent.route_mode == :resource\n mode = :param if /^:/ === @prefix.last\n mode\n end",
"def routing_number; end",
"def match(request, service_request, routes) \n routes.each do |method, options|\n unless method.match(':action')\n return options[:action] if service_request.methodname == method\n else \n matcher = Regexp.escape(method).sub(':action', '([A-Za-z0-9_]*)')\n matcher = \"^#{matcher}$\"\n if match = service_request.methodname.match(matcher)\n return match[1]\n end\n end\n end\n raise \"no service route matches #{service_request.methodname}\"\n end",
"def route(name, group = nil)\n @sets.each { |set|\n if r = set[1].route(name, group)\n return r\n end\n }\n\n raise MissingRoute, \"Could not find route '#{name}'\"\n end",
"def select_route(uri)\n variables = nil\n selected_route = nil\n cached_route = self.cached_routes[uri.to_s]\n if cached_route == nil\n for route in self.routes\n variables = uri.extract_mapping(\n route.pattern, route.processor)\n if variables != nil\n selected_route = route\n self.cached_routes[uri.to_s] =\n selected_route\n break\n end\n end\n else\n selected_route = cached_route\n end\n return selected_route\n end",
"def dispatch_action(request)\n method = request_method(request)\n path = request.path.sub(/\\.\\w+$/, '')\n route = @routing.detect { |r| r[0] == method && r[1] == path }\n route[2] if route\n end",
"def path\n return @path unless @path.nil?\n\n substitute_keys_with(@route_params)\n substitute_keys_with(known_params)\n @path = @route\n end",
"def find_by(request_or_env)\n request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env\n pattern = decode_pattern(request.path_info)\n verb = request.request_method\n rotation { |offset| match?(offset, pattern) }.select { |route| route.verb == verb }\n end",
"def route\n @base_controller.route if @base_controller\n end",
"def route?(path)\n path = Path.new(path)\n endpoint = endpoints[path]\n route = nil\n\n unless endpoint\n route = route_for(path)\n endpoint = endpoints[route]\n end\n\n endpoint\n end",
"def route\n \"#{@http_verb.to_s.upcase} #{@url}\"\n end",
"def _routes; end",
"def get_route(path, options = nil)\n conditions = options && options.delete(:conditions) || nil\n requirements = options && options.delete(:requirements) || nil\n default_values = options && options.delete(:default_values) || nil\n generate_with = options && options.delete(:generate_with) || nil\n priority = options && options.delete(:priority) || nil\n if options\n options.delete_if do |k, v|\n if v.is_a?(Regexp) || v.is_a?(Proc)\n (requirements ||= {})[k] = v\n true\n end\n end\n end\n\n if conditions && !conditions.empty?\n conditions.keys.all?{|k| request_methods.include?(k)} or raise(\"You are trying to use request methods that don't exist in the request_methods supplied #{conditions.keys.join(', ')} -> #{(conditions.keys - request_methods).join(\", \")}\")\n end\n\n if priority\n enable_priority_lookups!\n end\n\n route = parser.generate_route(path, conditions, requirements, default_values, generate_with, priority)\n raise(MultipleParameterException.new) if !allow_identical_variable_names? and route.paths.first.dynamic? and route.paths.first.dynamic_keys.uniq.size != route.paths.first.dynamic_keys.size\n route.to(options) if options && !options.empty?\n route\n end",
"def match(request)\n path = String.normalize_path(request.path)\n method = request.method\n\n match, data = nil\n @sets.each { |set|\n match, data = set[1].match(path, method)\n break if match\n }\n\n fns = []\n if match\n fns = match[3]\n\n # handle route params\n #TODO where to do this?\n request.params.merge!(Hash.strhash(self.data_from_path(path, data, match[1])))\n\n #TODO where to do this?\n request.route_path = match[4]\n end\n\n fns\n end",
"def get_route\n data = {\n visits: visits,\n fleet: fleet\n }\n\n data[:options] = options if options\n result = Util.send_request(\"POST\", \"vrp\", Routific.token, data)\n RoutificApi::Route.parse(result)\n end",
"def find_by_path(request_path)\n routes = Disraptor::RouteStore.get_routes()\n\n return routes.values.detect do |route|\n route['sourcePath'] == request_path\n end\n end",
"def last_action\n Rails.application.routes.recognize_path(request.referrer)[:action]\n end",
"def routes\n @routes || self.class.routes\n end",
"def last\n @routes[-1]\n end",
"def path\n @path ||= if Symbol === _path\n find_route_for(_path, *options)\n elsif _path\n _path\n else\n '#'\n end\n end",
"def route_request\n env.logger.debug \"#{self.class} ROUTING - #{env[Goliath::Request::PATH_INFO]}\"\n if has_path = ( env[Goliath::Request::PATH_INFO] =~ /^\\/(\\w+)(\\/\\w+)*/ )\n env.logger.debug \"#{self.class} route_request:\\t pathinfo = #{$1} extended = #{$2}\"\n path_info = $1\n extended_path_info = $2\n has_path = true #it will be a number or nil - let's just make it a bool\n elsif params[:id]\n has_path = true\n end\n \n method = env[Goliath::Request::REQUEST_METHOD]\n action = case method\n when 'GET'\n has_path ? 'show' : 'index'\n when 'POST'\n has_path ? ( raise BadRequestError, \"can't post to this resource\" ) : 'create'\n when 'PUT'\n !has_path ? ( raise BadRequestError, \"no resource to PUT to\" ) : 'update'\n when 'DELETE'\n !has_path ? ( raise BadRequestError, \"no resource to DELETE\" ) : 'delete'\n else\n raise MethodNotAllowedError, \"unknown request method\"\n end\n env.logger.info \"#{self.class} route_request:\\t attempting to call #{action} action\"\n if self.respond_to?(action, true) #second param includes private methods\n env['params']['id'] = params[:id] || (path_info if has_path)\n self.send(action)\n else\n error_on MethodNotAllowedError, \"#{action} not supported for this resource\"\n end\n end",
"def get_routes\n raise \"Method not implemented\"\n end",
"def routes\n routes_method.call\n end",
"def named_route; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def matches?(req)\n req.path =~ pattern && http_method == req.request_method.downcase.to_sym\n end",
"def call_routes\n return @call_routes\n end",
"def get_route_target server_type, msg, route_param, &block\n if @router_type\n router = case @router_type\n when :roundrobin\n method :rr_route\n when :weight_roundrobin\n method :wrr_route\n when :least_active\n method :la_route\n when :consistent_hash\n method :ch_route\n else\n method :rd_route\n end\n router.call(self, server_type, msg) { |err, server_id|\n block_given? and yield err, server_id\n }\n else\n unless @router.respond_to? :call\n block_given? and yield Exception.new 'invalid router method'\n return\n end\n @router.call(route_param, msg, @route_context) { |err, server_id|\n block_given? and yield err, server_id\n }\n end\n end",
"def path\n request.path\n end",
"def route(path = request.path_info)\n path = path.gsub(%r{//+}, '/').gsub(%r{^/|/$}, '')\n return route_index if path.empty? || path == docs_prefix\n case path\n when %r{^(#{docs_prefix}|#{list_prefix}|#{search_prefix}|#{static_prefix})(/.*|$)}\n prefix = $1\n paths = $2.gsub(%r{^/|/$}, '').split('/')\n library, paths = *parse_library_from_path(paths)\n return unless library\n return case prefix\n when docs_prefix; route_docs(library, paths)\n when list_prefix; route_list(library, paths)\n when search_prefix; route_search(library, paths)\n when static_prefix; route_static(library, paths)\n end\n end\n nil\n end",
"def recognize_path(path_info)\n prepare! unless prepared?\n route = @engine.find_by_pattern(path_info).first\n [route.name, route.params_for(path_info, {})]\n end",
"def route_for_current_step\n steps_routes_mapping[state] || steps_routes_mapping[:pending]\n end",
"def route *args\n locked? || raise(\"`route' works only on mounted apps. Please consider to use `base_url' instead.\")\n return base_url if args.size == 0\n (route = self[args.first]) && args.shift\n build_path(route || base_url, *args)\n end",
"def routes\n raise NotImplementedError\n end",
"def get_user_route(user)\n try_route(:user, user)\n end",
"def timeline_route\n @timeline_route ||= begin\n result = @timeline.route_for_kind(Activr::Timeline::Route.kind_for_routing_and_activity(@routing_kind, @activity.kind))\n raise \"Failed to find a route for #{@routing_kind} / #{@activity.kind}: #{self.inspect}\" if result.nil?\n result\n end\n end",
"def call_by_request(request)\n rotation do |offset|\n pattern = decode_pattern(request.path_info)\n if route = match?(offset, pattern)\n params = route.params_for(pattern, request.params)\n yield(route, params) if route.verb == request.request_method\n route\n end\n end\n end",
"def route_end\n inheritable_setting.route_end\n end"
] |
[
"0.8132401",
"0.77498764",
"0.7607261",
"0.753187",
"0.7494161",
"0.72898215",
"0.7284538",
"0.7282092",
"0.7270861",
"0.7245141",
"0.72393835",
"0.7237337",
"0.71793336",
"0.7179079",
"0.7058991",
"0.7018041",
"0.69962186",
"0.6936506",
"0.691659",
"0.691659",
"0.6871855",
"0.6853353",
"0.6797409",
"0.67582005",
"0.67582005",
"0.6728614",
"0.65831566",
"0.65831566",
"0.65810746",
"0.65615445",
"0.64740187",
"0.64122933",
"0.63729954",
"0.6348315",
"0.6342764",
"0.6321589",
"0.6267146",
"0.6190597",
"0.61655265",
"0.61627394",
"0.61627394",
"0.61626494",
"0.6151414",
"0.6131688",
"0.6105053",
"0.6103133",
"0.60852075",
"0.608255",
"0.6079463",
"0.6070916",
"0.60523975",
"0.60359126",
"0.6004875",
"0.598802",
"0.59595126",
"0.59531766",
"0.59365785",
"0.59319067",
"0.5930658",
"0.59153396",
"0.59032714",
"0.59023386",
"0.58873445",
"0.58831704",
"0.5882789",
"0.58673865",
"0.5854011",
"0.58538735",
"0.5815777",
"0.5812903",
"0.5811325",
"0.57772005",
"0.5771564",
"0.57674634",
"0.5757459",
"0.5734481",
"0.57213",
"0.57213",
"0.57213",
"0.57213",
"0.57213",
"0.57213",
"0.57213",
"0.57213",
"0.57213",
"0.57213",
"0.57213",
"0.57193923",
"0.5719149",
"0.5704548",
"0.5685882",
"0.5681839",
"0.5668986",
"0.56628895",
"0.56542903",
"0.564792",
"0.56464374",
"0.5639251",
"0.5637163",
"0.562966"
] |
0.6835848
|
22
|
call run on the first matching route. find the requested URL match it to the path regex of one Route object ask the Route to instantiate the appropriate controller and call the appropriate method corresponding to the action else if no matched route, throw 404 & add message
|
def run(req, res)
first_matched_route = match(req)
if first_matched_route
first_matched_route.run(req, res)
else
res.status = 404
res.write("No route matches for #{req.request_method} for #{req.path}")
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run(req, res)\n # The #run method will figure out what URL was requested, match it to\n # the path regex of one Route object, and finally ask the Route to\n # instantiate the appropriate controller, and call the appropriate method.\n end",
"def run(req, res)\n route = match(req)\n if route\n route.run(req, res)\n else\n res.status = 404\n controller = Controller::Base.new(req, res)\n controller.render_content(\"404: Unable to find page '#{req.path}' \", 'text/html')\n end\n end",
"def run(request, response)\n matching_route = match(request)\n\n if matching_route.nil?\n response.status = 404\n\n response.write(\"Sorry! The requested URL #{request.path} was not not found!\")\n else\n matching_route.run(request, response)\n end\n end",
"def run(req, res)\n route_to_run = self.match(req)\n if route_to_run.nil?\n res.status = 404\n else\n route_to_run.run(req, res)\n end\n end",
"def run(req, res)\n parse_http_methods!(req)\n matching_route = match(req)\n if matching_route\n matching_route.run(req, res)\n else\n res.status = 404\n res.write \"404 route not found\"\n end\n end",
"def run(req, res)\n matched_route = match(req)\n if matched_route\n matched_route.run(req, res)\n else\n res.status = 404\n res.write(\"No route matches #{req.fullpath}\")\n end\n end",
"def run(req, res)\n if matches?(req)\n controller_instance = controller_class.new(req, res, route_params(req))\n controller_instance.invoke_action(action_name)\n else\n # extra precaution! won't be hit if `Router#run` is used\n res.status = 404\n res.write(\"No route matches for #{http_method} on #{controller_class}\")\n end\n end",
"def run(req, res)\n matched_route = match(req)\n \n if matched_route.nil?\n res.status = 404\n else\n matched_route.run(req, res)\n end\n end",
"def run(req, res)\n good_route = match(req)\n if good_route.nil?\n res.status = 404\n else\n good_route.run(req, res)\n end\n end",
"def run(request, response)\n\n match_data = @pattern.match(request.path)\n\n route_params = Hash[match_data.names.zip(match_data.captures)]\n\n @controller_class\n .new(request, response, route_params)\n .invoke_action(action_name)\n end",
"def run(req, res)\n match_data = @pattern.match(req.path)\n\n route_params = {}\n match_data.names.each do |name|\n route_params[name] = match_data[name]\n end\n\n @controller_class.new(req, res, route_params).invoke_action(action_name)\n end",
"def run(req, res)\n route_params = {}\n\n match_data = @pattern.match(req.path)\n match_data.names.each do |key|\n route_params[key] = match_data[key]\n end\n\n controller = @controller_class.new(req, res, route_params)\n controller.invoke_action(@action_name)\n end",
"def run(req, res)\n regex = Regexp.new(@pattern.to_s)\n match_data = regex.match(req.path)\n route_params = {}\n match_data.names.each do |key|\n route_params[key] = match_data[key]\n end\n control = @controller_class.new(req, res, route_params)\n control.invoke_action(@action_name)\n end",
"def run(req, res)\n match_data = @pattern.match(req.path)\n route_params = (match_data) ?\n match_data.names.zip(match_data.captures).to_h\n : {}\n\n controller_instance = @controller_class.new(req, res, route_params)\n\n controller_instance.invoke_action(@action_name)\n end",
"def handle_route_not_found\n raise ActionController::RoutingError.new(params[:path])\n end",
"def do_dispatch(env)\n path = env['PATH_INFO']\n\n # Try to serve a public file\n ret = dispatch_public(env, path)\n return ret if not ret.nil?\n\n log.debug \"Checking for routes that match: #{path}\"\n route = router.match(env)\n\n if route.has_key? :ok\n dispatch_controller(route, env)\n else\n [404, {\"Content-Type\" => \"text/plain\"}, [\"404 Not Found: #{path}\"]]\n end\n end",
"def route_eval\n super\n rescue ActiveRecord::RecordNotFound\n not_found\n end",
"def run(req, res)\n if req.body\n check_method_param(req)\n end\n route = match(req)\n if route.nil?\n res.status = 404\n res.body = \"Cannot find route for #{req.request_method} #{req.path}\"\n else\n route.run(req, res)\n end\n end",
"def route_to(klass_or_name, action)\n RouteToMatcher.new(klass_or_name, action)\n end",
"def run(req, res)\n match_data = pattern.match(req.path)\n # hash = {}\n # match_data.names.each do |name|\n # hash[name] = match_data[name]\n # end\n hash = match_data.names.each_with_object({}) do |name, h|\n h[name] = match_data[name]\n end\n controller_class.new(req, res, hash).invoke_action(action_name)\n end",
"def run(req, res, options = {})\n route = match(req)\n if route\n route.run(req, res, options)\n else\n res.status = 404\n res.write(\"page #{req.path} not found\")\n res.finish\n end\n end",
"def routing_error\n render_not_found\n end",
"def run(req, res)\n @route_params = {}\n\n # I need to build route_params from the URL params\n # @pattern is the regexp\n match_data = @pattern.match(req.path)\n # * @pattern is the regexp given in the router.draw block in\n # p06_router_server.rb\n # * req.path is the url we are matching against\n # match_data gives us the MatchData object\n match_data.names.each do |name|\n @route_params[name] = match_data[name]\n end\n #this loop creates the params!\n\n controller_instance = @controller_class.new(req, res, @route_params)\n controller_instance.invoke_action(@action_name)\n end",
"def route\n @base_controller.route if @base_controller\n end",
"def try_route\n\t\t\t\thttp_method = request.http_method\n\t\t\t\thttp_method = :GET if http_method == :HEAD\n\t\t\t\treturn unless available_endpoint\n\n\t\t\t\troute = available_endpoint[http_method]\n\t\t\t\treturn unless route || available_endpoint.allow\n\n\t\t\t\thalt(405, nil, 'Allow' => available_endpoint.allow) unless route\n\t\t\t\tstatus 200\n\t\t\t\texecute_route route\n\t\t\t\ttrue\n\t\t\tend",
"def process(request_hash)\n request = Request.new(request_hash)\n case request.path\n when '/'\n index_route(request)\n when %r{^/sleep/\\d+$}\n sleep_route(request)\n else\n Response.new(\n \"No route found for #{request.path}. Try '/' or '/sleep/3'.\",\n status: 404\n )\n end\n end",
"def raise_not_found!\n\n raise ActionController::RoutingError.new(\"No route matches #{params[:unmatched_route]}\")\n\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def recognized_route\n unless @recognized_route\n path = params[:resource_path] || params[:erp] || request.path\n environment = ::ActionController::Routing::Routes.extract_request_environment(request)\n environment.merge!(:method => params[:resource_method]) if params[:resource_method]\n @recognized_route ||= ::ActionController::Routing::Routes.routes_for_controller_and_action(controller_path, action_name).find do |route|\n route.recognize(path, environment)\n end or ResourcesController.raise_no_recognized_route(self)\n end\n @recognized_route\n end",
"def run(req, res)\n route_params = self.make_match_hash(req)\n controller = @controller_class.new(req, res, route_params)\n controller.invoke_action(@action_name)\n end",
"def route() request.route end",
"def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def not_found\n raise ActionController::RoutingError.new 'Not Found'\n end",
"def not_found\n raise ActionController::RoutingError.new 'Not found'\n end",
"def not_found\n raise ActionController::RoutingError.new('Not Found')\n end",
"def not_found\n raise ActionController::RoutingError.new('Not Found')\n end",
"def not_found\n raise ActionController::RoutingError.new('Not Found')\n end",
"def not_found\n raise ActionController::RoutingError.new('Not Found')\n end",
"def not_found\n raise ActionController::RoutingError.new('Not Found')\n end",
"def not_found\n raise ActionController::RoutingError.new('Not Found')\n end",
"def match_for(path)\n @routes.select { |rt| rt.match?(path) }.first\n end",
"def not_found\n raise ActionController::RoutingError, 'Not Found'\n end",
"def index\n raise ActionController::RoutingError.new('Not Found')\n end",
"def not_found\n raise ActionController::RoutingError.new('Not Found')\n end",
"def raise_not_found\n\t\traise ActionController::RoutingError.new(\"No route matches #{params[:unmatched_route]}\")\n\tend",
"def get_destination(destination, routing_params = {})\n if destination.respond_to?(:call)\n return destination\n end\n\n #if destination is something like books#welcome\n if destination =~ /^([^#]+)#([^#]+)$/\n #name will be Books\n name = $1.capitalize\n #controller will be the Constant BooksController\n controller = Object.const_get(\"#{name}Controller\")\n #ah, now here we use the class.action from above. passing in\n #welcome as the action, and routing params as the response object\n return controller.action($2, routing_params)\n end\n #otherwise we messed up by coming here\n raise \"Destination no found: #{destination}\"\n end",
"def process(context)\n request = context.request\n\n router = @processor_map[request.request_method.downcase.to_sym]\n return 404 unless router\n begin\n processor, params = router.routing(request.path)\n rescue FancyServer::PathRouter::NoRouteMatched\n return 404\n rescue FancyServer::PathRouter::DestinationDuplicated => ex\n return {:status => 503, :body => ex.message}\n end\n return 404 unless processor\n context.params.merge!(params)\n processor.respond_to?(:to_proc) ? context.instance_eval(&processor) : processor\n end",
"def run(req, res)\n #@action = :index\n #@method = :get\n #@pattern = /^\\/users$/\n #@class = DummyController\n \n @params = req.path\n #route_params = @params\n ControllerBase.new(req, res, @params).invoke_action(@method, @pattern, @class, @action)\n end",
"def route_index; end",
"def not_found\n raise ActionController::RoutingError.new('Not Found')\n rescue\n render_404\n end",
"def run(req, res)\n if matches?(req)\n controller = @controller_class.new(req, res)\n controller.send(@action_name)\n end\n end",
"def match(path, *rest, &block)\n if rest.empty? && Hash === path\n options = path\n path, to = options.find { |name, _value| name.is_a?(String) }\n\n raise ArgumentError, \"Route path not specified\" if path.nil?\n\n case to\n when Symbol\n options[:action] = to\n when String\n if to.include?(\"#\")\n options[:to] = to\n else\n options[:controller] = to\n end\n else\n options[:to] = to\n end\n\n options.delete(path)\n paths = [path]\n else\n options = rest.pop || {}\n paths = [path] + rest\n end\n\n if options.key?(:defaults)\n defaults(options.delete(:defaults)) { map_match(paths, options, &block) }\n else\n map_match(paths, options, &block)\n end\n end",
"def start_call(node)\n if s(:call, s(:lvar, :map), :connect, s(:arglist, s(:str, \":controller/:action/:id\"))) == node ||\n s(:call, s(:lvar, :map), :connect, s(:arglist, s(:str, \":controller/:action/:id.:format\"))) == node ||\n s(:call, nil, :match, s(:arglist, s(:str, \":controller(/:action(/:id(.:format)))\"))) == node\n add_error \"not use default route\"\n end\n end",
"def dispatch_action(request)\n method = request_method(request)\n path = request.path.sub(/\\.\\w+$/, '')\n route = @routing.detect { |r| r[0] == method && r[1] == path }\n route[2] if route\n end",
"def error_route_not_found\n render 'errors/route_not_found', status: :not_found rescue last_chance\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def not_found(message='Not Found')\n raise ActionController::RoutingError.new(message)\n end",
"def match(request, service_request, routes) \n routes.each do |method, options|\n unless method.match(':action')\n return options[:action] if service_request.methodname == method\n else \n matcher = Regexp.escape(method).sub(':action', '([A-Za-z0-9_]*)')\n matcher = \"^#{matcher}$\"\n if match = service_request.methodname.match(matcher)\n return match[1]\n end\n end\n end\n raise \"no service route matches #{service_request.methodname}\"\n end",
"def routing_mismatch\n raise ::ActionController::RoutingError,\"URL not supported\"\n end",
"def route(stock_url)\n url=stock_url.split(/\\/+/).join(\"/\")\n @routes.keys.each do |x|\n #@logger.msginfo(\"Main:route:Looking at '#{url}' (#{url[0,@routes[x]['path_length']]}) for '#{x}'\")\n if (x == url[0,@routes[x][\"path_length\"]])\n #@logger.msginfo(\"Main:route: #{@routes[x][\"handler\"].class.to_s} will do '#{url}'\")\n return @routes[x][\"handler\"]\n end\n end\n return nil #Bad, nothing matched\n end",
"def routing_error\n redirect_to \"/404\"\n end",
"def call(env)\n route = @routes.map do |exp, meta|\n next unless matches = env[\"PATH_INFO\"].match(exp)\n meta.merge(captures: matches)\n end.compact.first\n\n return Yokunai::ErrorsController.new(env).not_found unless route\n\n request_method = env[\"REQUEST_METHOD\"]\n if route[:methods].include?(request_method)\n Object.const_get(route[:class])\n .new(env, route[:captures])\n .public_send(request_method.downcase)\n else\n Yokunai::ErrorsController.new(env).unsupported_method\n end\n end",
"def run(req, res)\n if match(req).nil?\n res.status = 404\n else\n match(req).run(req, res)\n end\n end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def not_found\n rescue_404(ActionController::RoutingError.new(\"No route matches #{request.request_method} #{request.path}\"))\n end",
"def call(env)\n route = self.route(env)\n if route\n env['params'] = route.match(env) || {}\n route.call(env)\n else\n env['params'] = {}\n not_found.call(env)\n end\n end",
"def run(req, res)\n if match(req).nil?\n res.status = 404\n else\n match(req).run(req, res)\n end\n end",
"def service(request, response)\n params = @router.resolve_uri(request.request_uri)\n controller = Acoustic::Controller.from_symbol(params[:controller])\n action = params[:action]\n controller.process(action, params, request, response)\n rescue Acoustic::UnresolvableUri, Acoustic::ControllerNameError\n raise Acoustic::NotFound.new(request.request_uri)\n end",
"def suggest\n raise ActionController::RoutingError.new('Not Found')\n end",
"def handle_GET(initial)\n\trequest_path = get_Path(initial)\n\trequest_path = request_path[1..-1] if request_path[0] == '/'\n\tif File.exist?(request_path)\n\t\tcreate_Found_Response(request_path)\n\telse\n\t\tcreate_Not_Found_Response(request_path)\n\tend\nend",
"def match(req)\n @routes.select{|rt| rt.matches?(req) }.first\n end",
"def method_missing(m, *args, &block)\n respond('Error', 404, 'page not found')\n end",
"def routing\n referer = request.env['HTTP_REFERER']\n if referer.present? && referer.include?(request.host)\n Rails.logger.fatal \"#{referer} directs to non-existent route: \" \\\n \"#{request.protocol}#{request.host_with_port}#{request.fullpath}\"\n else\n Rails.logger.warn 'There was an attempt to access non-existent route: ' \\\n \"#{request.protocol}#{request.host_with_port}#{request.fullpath}\"\n end\n render file: Rails.root.join('public', '404.html'), status: :not_found\n end",
"def render_404\n raise ActionController::RoutingError.new('Not Found')\n end",
"def call(env)\n # Grab the verb and requested path from the env parameter\n @request = Rack::Request.new(env)\n verb = @request.request_method\n requested_path = @request.path_info\n\n # Grab the handler block from @routes if it exists\n handler = @routes.fetch(verb, {}).fetch(requested_path, nil)\n\n if handler\n # Evaluate our route handler block in the context of that instance,\n # to give it access to all of the methods (Compare: handler.call)\n result = instance_eval(&handler)\n\n if result.class == String\n # For convenience, if a handler returns a string,\n # assume that it is a successful response.\n [200, {}, [result]]\n else\n # Otherwise, return the result of the block as-is.\n result\n end\n else\n # Return a 404 with a custom error message\n # instead of the default Internal Server Error\n [404, {}, [\"Oops! No routes for #{verb} #{requested_path}\"]]\n end\n end",
"def route_for(name, *args); end",
"def edit; raise ActionController::RoutingError.new('Not Found'); end",
"def route_request\n env.logger.debug \"#{self.class} ROUTING - #{env[Goliath::Request::PATH_INFO]}\"\n if has_path = ( env[Goliath::Request::PATH_INFO] =~ /^\\/(\\w+)(\\/\\w+)*/ )\n env.logger.debug \"#{self.class} route_request:\\t pathinfo = #{$1} extended = #{$2}\"\n path_info = $1\n extended_path_info = $2\n has_path = true #it will be a number or nil - let's just make it a bool\n elsif params[:id]\n has_path = true\n end\n \n method = env[Goliath::Request::REQUEST_METHOD]\n action = case method\n when 'GET'\n has_path ? 'show' : 'index'\n when 'POST'\n has_path ? ( raise BadRequestError, \"can't post to this resource\" ) : 'create'\n when 'PUT'\n !has_path ? ( raise BadRequestError, \"no resource to PUT to\" ) : 'update'\n when 'DELETE'\n !has_path ? ( raise BadRequestError, \"no resource to DELETE\" ) : 'delete'\n else\n raise MethodNotAllowedError, \"unknown request method\"\n end\n env.logger.info \"#{self.class} route_request:\\t attempting to call #{action} action\"\n if self.respond_to?(action, true) #second param includes private methods\n env['params']['id'] = params[:id] || (path_info if has_path)\n self.send(action)\n else\n error_on MethodNotAllowedError, \"#{action} not supported for this resource\"\n end\n end",
"def route\n #TODO\n end",
"def run(req, res)\n controller = controller_class.new(req, res, route_params(req))\n controller.invoke_action(action_name)\n end",
"def action_missing(name, *args)\n if name == action_name\n perform\n else\n raise AbstractController::ActionNotFound\n end\n end",
"def find_route(url)\n @routes.each do |route|\n if route.match(url)\n return route\n end\n end\n nil\n end",
"def not_found(path)\n raise ActionController::RoutingError.new(\"Route not found for #{path}\")\n end",
"def find_route(request)\n @routes.find {|r| r.match?(request) }\n end",
"def routes_not_found\n respond_to do |f|\n f.html{ render :template => \"errors/404\", :status => 404}\n end\n end",
"def route\n @route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}\n end",
"def method_missing(method, *params, &block)\n route_macro = self.class.macros[method]\n if route_macro.nil?\n super\n else\n pattern = params.shift || route_macro[:pattern]\n options = route_macro[:options].merge(params.shift || {})\n if !params.empty?\n raise ArgumentError,\n \"wrong number of arguments (#{params.size + 2} for 2)\"\n end\n route(pattern, options)\n end\n end",
"def route!(request)\n @@request = request\n @@routes.each do |route|\n if route.first == request.path\n return route.last.call\n break\n end\n end\n end",
"def route_path(path)\n AutoRouter::Router.map_controller(self, path: path)\n end",
"def map route_object\n klass = nil\n route = nil\n action = nil\n\n # map 'root' do\n # ...\n if block_given?\n @lux_action_target = route_object\n yield\n @lux_action_target = nil\n return\n elsif @lux_action_target\n klass = @lux_action_target\n route = route_object\n action = route_object\n\n # map :foo => :some_action\n if route_object.is_a?(Hash)\n route = route_object.keys.first\n action = route_object.values.first\n end\n\n if test?(route)\n call klass, action\n else\n return\n end\n end\n\n case route_object\n when String\n # map 'root#call'\n call route_object\n when Hash\n route = route_object.keys.first\n klass = route_object.values.first\n\n if route.class == Array\n # map [:foo, :bar] => 'root'\n for route_action in route\n if test?(route_action)\n call klass, route_action\n end\n end\n\n return\n elsif route.is_a?(String) && route[0,1] == '/'\n # map '/skils/:skill' => 'main/skills#show'\n return match route, klass\n end\n when Array\n # map [:foo, 'main/root']\n route, klass = *route_object\n else\n Lux.error 'Unsupported route type \"%s\"' % route_object.class\n end\n\n test?(route) ? call(klass) : nil\n end",
"def resolve_path(path, *args)\n # logger.debug \"resolve_path: #{path}, args = #{args}\"\n m = /^(([^_]+)_)?((\\w+?)?)$/.match(path)\n if m\n action_with_underscore = m[1]\n action = m[2]\n resource = m[3]\n\n # logger.debug \"resolve_path: matched pattern: #{m}, action = #{action.inspect}, resource = #{resource}\"\n\n return self.class.routes.match_path(resource, action, *args)\n else\n raise \"unable to match path: #{path}_path\"\n end\n end",
"def routing_error\n raise ActionController::RoutingError.new(params[:path])\n end",
"def route(agi, params=nil)\n request = {\n :uri => @uri,\n :controller => @controller,\n :method => @method,\n :id => @id,\n :options => @options\n }\n\n return if !@controller\n\n controller_name = if !@controller[/controller/]\n \"#{@controller}_controller\"\n else\n \"#{@controller}\"\n end\n\n controller_name = controller_name.classify\n controller = get_controller(controller_name)\n\n @@logger.info \"Processing Route to #{controller_name}##{@method}\"\n @@logger.info \"#{@uri}\"\n\n unless controller\n @@logger.warn(\"Nonexistant controller\")\n return set_invalid_extension(agi)\n end\n\n unless check_controller(controller)\n @@logger.warn \"Unroutable method\"\n return set_invalid_extension(agi)\n end\n\n unless check_route(controller, @method)\n @@logger.warn \"Unroutable method\"\n return set_invalid_extension(agi)\n end\n\n ctrl_instance = controller.new({\n :agi => agi,\n :params => params,\n :request => request\n })\n\n begin\n ctrl_instance.run_filter_chain :before\n ctrl_instance.method(@method).call()\n ctrl_instance.run_filter_chain :after\n rescue AGIFilterHalt => e\n LOGGER.warn e.message\n end\n end",
"def route_for routename\n case routename\n when 'Start'\n \"index\"\n when 'Login'\n \"login\"\n when 'Mitarbeiterübersicht'\n \"employees\"\n when 'Neuer Mitarbeiter'\n \"employees.new\"\n when 'FAQ'\n \"faq\"\n else\n raise \"No route defined for route named '#{routename}'.\"\n end\nend",
"def handler_for_request(req)\n req.path =~ /^#{@url_prefix}\\/([^\\/]+)/\n\n return @entry_points[$1] || Borges::NotFoundHandler.new\n end",
"def not_found! redirect = root_path\n raise ActionController::RoutingError.new(\"Sorry, I could not find the requested item!\")\n end",
"def routes; end",
"def routes; end",
"def routes; end"
] |
[
"0.73926985",
"0.71203727",
"0.70796734",
"0.7006488",
"0.6895496",
"0.68064445",
"0.6767146",
"0.67607725",
"0.6737907",
"0.6676973",
"0.66755813",
"0.65358615",
"0.6520496",
"0.64698565",
"0.64448565",
"0.6409749",
"0.639779",
"0.6356208",
"0.6295131",
"0.6277916",
"0.62606055",
"0.6257022",
"0.61510146",
"0.61485136",
"0.61074775",
"0.61021113",
"0.6099985",
"0.60836065",
"0.6065768",
"0.6050888",
"0.60494334",
"0.6048896",
"0.6037857",
"0.6030238",
"0.6029527",
"0.6009936",
"0.6009936",
"0.6009936",
"0.6009936",
"0.6009936",
"0.6009936",
"0.6008069",
"0.60004413",
"0.5989135",
"0.5986731",
"0.59820026",
"0.5976614",
"0.5963844",
"0.59634286",
"0.59269005",
"0.59183633",
"0.588309",
"0.5879776",
"0.58719677",
"0.58707535",
"0.5855642",
"0.58275855",
"0.5824729",
"0.5820279",
"0.5806265",
"0.5802749",
"0.5796785",
"0.57740057",
"0.5762264",
"0.57590866",
"0.5754114",
"0.57422036",
"0.5728911",
"0.57288426",
"0.5708961",
"0.5705935",
"0.57047087",
"0.5702917",
"0.56770957",
"0.56705934",
"0.56622154",
"0.5660455",
"0.5641763",
"0.56236386",
"0.5619933",
"0.56101626",
"0.5575106",
"0.5569938",
"0.55654854",
"0.5557542",
"0.55520135",
"0.55515647",
"0.55510795",
"0.55360526",
"0.5535032",
"0.55342406",
"0.55270046",
"0.5521753",
"0.5508604",
"0.55006343",
"0.5497049",
"0.54918104",
"0.5490871",
"0.5490871",
"0.5490871"
] |
0.7081169
|
2
|
Time complexity O(1) Space complexity O(1)
|
def add_first(data)
@head = Node.new(data, head)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"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 solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend",
"def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend",
"def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend",
"def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend",
"def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend",
"def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\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 solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend",
"def find_unique_elements(arr)\n \nend",
"def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend",
"def solution(a)\n a.uniq.count\nend",
"def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend",
"def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend",
"def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend",
"def solution(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\nend",
"def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend",
"def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend",
"def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend",
"def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend",
"def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend",
"def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend",
"def findlargestdrop(arr)\n\n\n\nend",
"def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend",
"def solution(a)\n # write your code in Ruby 2.2\n numbers = Array(1..(a.size + 1))\n res = numbers - a\n res[0]\nend",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def solution4(a)\n left = 0\n right = a.size - 1\n distinct = 0\n\n while left <= right\n # puts \"left: #{left}, right: #{right}\"\n # puts \"a[l]: #{a[left]}, a[r]: #{a[right]}\"\n # puts \"distinct: #{distinct}\"\n if a[left].abs > a[right].abs\n begin\n left += 1\n end until a[left] != a[left - 1]\n elsif a[left].abs < a[right].abs\n begin\n right -= 1\n end until a[right] != a[right + 1]\n else\n begin\n left += 1\n end until a[left] != a[left - 1]\n begin\n right -= 1\n end until a[right] != a[right + 1] \n end\n\n distinct += 1\n end\n distinct\nend",
"def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend",
"def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend",
"def solution(a)\n ((1..a.size + 1).to_a - a).first\nend",
"def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend",
"def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend",
"def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend",
"def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend",
"def find_unique_elements(arr)\n arr_fin=[]\n arr.each do |x|\n arr.count(x)\n if arr.count(x)==1\n arr_fin << x\n end\n end\n return arr_fin\nend",
"def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend",
"def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend",
"def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend",
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def find_unsorted_subarray(nums)\n \nend",
"def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend",
"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 naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend",
"def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend",
"def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend",
"def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend",
"def solution1(a)\n a.map(&:abs).uniq.size\nend",
"def solution(a)\n result = 0\n tmp_count = 0\n a.each_with_index do |val, idx|\n if val.zero?\n tmp_count += 1\n else\n result += tmp_count\n end\n end\n return result > 1000000000 ? -1 : result\nend",
"def find_unique_elements(arr)\n arr_unique = []\n arr.each do |elem1|\n var1 = 0\n arr.each do |elem2|\n if elem1 == elem2\n var1 = var1 + 1\n end\n end\n if var1 <= 1\n arr_unique.push(elem1)\n end\n end\nend",
"def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \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 find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend",
"def find_unique_elements(arr)\n \n#Algorithmic Process\n#Create an array that includes elements without the repeats\n#Create a hash that pairs each element of the new array with how many times it appears in the original array\n#Any key-value pair that has 1 for a value is unique and gets placed in the desired array\n \nnew_hash = {}\narr.each do |x|\n new_hash[x] = 0 if new_hash[x].nil?\n new_hash[x] = new_hash[x] + 1\nend\n\nnew_hash.delete_if {|key, value| value != 1}\nnew_hash.each_key {|key| puts key}\n\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend",
"def two_sum(numbers, target)\n ##set hash\n hash = {}\n ##set array\n arr = []\n\n numbers.each_with_index do |val, idx|\n if hash.key?(target - val)\n arr.push(hash[target - val])\n arr.push(idx + 1)\n break\n else\n hash[val] = idx + 1\n end\n end\n\n arr\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 optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend",
"def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend",
"def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend",
"def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end",
"def awesome(arr, target)\n hash = Hash.new(0)\n i = 0\n j = i + 1\n while i < arr.size\n hash[arr[i] + arr[j]] += 1 \n if j < arr.size\n j += 1\n else\n i += 1\n if j = i + 1 > arr.length\n j = i \n else\n j = i + 1\n \n end\n\n end\n \n end\n return true if hash[target] >= 1\n false\nend",
"def unique_in_order(iterable) \n# create an empty array\ncontent = []\n\n # check each letter/number of `iterable` \n for e in (0..iterable.length()-1) \n\n# compare current element to previous element\n# if array is empty\n if e == 0 or \n# \n# if current element is not the same with previous element, push current index to content array\n iterable[e] != iterable[e-1] \n content.push(iterable[e])\n end\n end\n# return new content array\n return content\nend",
"def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend",
"def collisions(arr)\n new_arr = []\n result = []\n arr.each do |i|\n if i > 0\n new_arr << i\n else\n if new_arr.empty?\n result << i\n else\n if new_arr[-1] == -(i)\n new_arr.pop\n else\n while !new_arr.empty? && new_arr[-1] < -(i)\n new_arr.pop\n end\n if new_arr.empty?\n result << i\n end\n end\n end\n end\n end\n return (result.concat(new_arr))\nend",
"def find_duplicate(nums)\n intersection = find_first_meeting(nums)\n find_cycle_start(nums,intersection)\nend",
"def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend",
"def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend",
"def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend",
"def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend",
"def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend",
"def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end",
"def cnts a\n r = []\n found = false\n a.each do |x|\n r.each do |y|\n if y[0] === x\n y[1] += 1\n found = true\n break\n end\n end\n if !found\n r.push([x, 1])\n else\n found = false\n end\n end\n r\nend",
"def solution(a)\n counts = {}\n for i in a\n counts[i] ||= 0\n counts[i] += 1\n end\n for i in (1..a.count)\n return 0 if counts[i] != 1\n end\n return 1\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend",
"def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend",
"def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend",
"def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend",
"def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend",
"def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend",
"def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend",
"def lcs_phase_two(arr)\n return arr.max if arr.max < 0 #edge case\n\n current = 0\n largest = 0\n\n arr.each do |ele|\n current += ele\n current = 0 if current < 0 #bookmark\n largest = current if largest < current\n end\n\n largest\nend",
"def solution(arr)\n temp_hash_odd_balls = {}\n\n arr.each { |el| temp_hash_odd_balls[el] ? temp_hash_odd_balls.delete(el) : temp_hash_odd_balls[el] = 0 }\n\n temp_hash_odd_balls.keys.first\nend",
"def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend",
"def sub_sum2(array)\n arr = []\n sum = 0\n array.each do |el|\n arr << [el] \n end\n array.each do |el|\n array.shift\n arr << array\n end\n # p arr\n result = 0\n arr.each do |set|\n if set.reduce(:+) > result\n result = set.reduce(:+)\n end \n end \n result\nend",
"def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend",
"def f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend",
"def dominant_octopus(fish)\n #sorted = []\n return fish if fish.length < 2\n pivot = fish.first\n left = fish[1..-1].select { |feesh| feesh.length <= pivot.length }\n #p left\n right = fish[1..-1].select { |feesh| feesh.length > pivot.length }\n\n dominant_octopus(left) + [pivot] + dominant_octopus(right)\n \n\n\nend",
"def sq_arr(a)\n # require 'debug'\n a.map! { |x| x**2 }\n j = (a.length - 1)\n return a if j == 0\n while a[0] >= a[1] && j >= 0\n p j\n if a[0] > a[j]\n a.insert(j, a.shift)\n else\n j -= 1\n end\n end\n a\nend",
"def solution(a)\n # write your code in Ruby 2.2\n permutation = Array(1..a.size)\n # puts permutation\n return 1 if permutation - a == []\n 0\nend",
"def c v1, v2, o\n m = false\n d = []\n (0...v2.size).each{ |j|\n if !v1.include? v2[j] + o\n d << v2[j]\n m = true\n end\n }\n for x in d\n v2.delete x\n end\n m\nend",
"def equil_idcs(a)\n left = 0\n sum = a.inject(:+)\n equils = []\n a.each_with_index do |num, idx|\n sum -= num\n equils << idx if left == sum\n left += num\n end\n equils.empty? ? -1 : equils\nend",
"def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend",
"def solution(a)\n # write your code in Ruby 2.2 \n frecuencies = a.each_with_object(Hash.new(0)) { |key, value| value[key] += 1 } \n \n frecuencies.each do |key, value|\n if value.odd? then return key end\n end\nend",
"def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend",
"def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend",
"def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend",
"def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend"
] |
[
"0.65076977",
"0.6224968",
"0.59870076",
"0.59614",
"0.592963",
"0.5878061",
"0.5871787",
"0.58503795",
"0.58141303",
"0.5810536",
"0.5783606",
"0.5758984",
"0.5741224",
"0.57400525",
"0.5717067",
"0.5695446",
"0.56916237",
"0.5682769",
"0.56791544",
"0.56744385",
"0.56462455",
"0.56403905",
"0.56355983",
"0.56148314",
"0.5609005",
"0.5607288",
"0.5604348",
"0.56018645",
"0.5600563",
"0.5593942",
"0.558283",
"0.5582329",
"0.5580358",
"0.55733967",
"0.55704725",
"0.5568864",
"0.55608475",
"0.55544275",
"0.554988",
"0.5549293",
"0.55459195",
"0.5545592",
"0.5544114",
"0.5537456",
"0.553246",
"0.55293894",
"0.5528896",
"0.5520509",
"0.5520253",
"0.551982",
"0.5518587",
"0.55160594",
"0.55106336",
"0.5498553",
"0.5492679",
"0.5492065",
"0.54912525",
"0.549038",
"0.5489442",
"0.5483485",
"0.54815364",
"0.5479698",
"0.54748607",
"0.54739094",
"0.54717714",
"0.54707825",
"0.54688394",
"0.54685116",
"0.54661",
"0.54639995",
"0.5461305",
"0.546011",
"0.5459417",
"0.5458572",
"0.54553246",
"0.54547024",
"0.545129",
"0.5449906",
"0.5447548",
"0.5441376",
"0.54389584",
"0.5436833",
"0.5436647",
"0.5435451",
"0.5431747",
"0.5431689",
"0.5426796",
"0.5424433",
"0.5416063",
"0.5414151",
"0.5404067",
"0.54038966",
"0.5400079",
"0.5393501",
"0.5392692",
"0.53889656",
"0.5387861",
"0.5386957",
"0.538585",
"0.5381257",
"0.5381094"
] |
0.0
|
-1
|
Time complexity O(1) Space complexity O(1)
|
def get_first
return @head if @head.nil?
return @head.data
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"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 solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend",
"def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend",
"def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend",
"def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend",
"def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend",
"def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\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 solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend",
"def find_unique_elements(arr)\n \nend",
"def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend",
"def solution(a)\n a.uniq.count\nend",
"def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend",
"def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend",
"def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend",
"def solution(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\nend",
"def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend",
"def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend",
"def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend",
"def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend",
"def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend",
"def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend",
"def findlargestdrop(arr)\n\n\n\nend",
"def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend",
"def solution(a)\n # write your code in Ruby 2.2\n numbers = Array(1..(a.size + 1))\n res = numbers - a\n res[0]\nend",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def solution4(a)\n left = 0\n right = a.size - 1\n distinct = 0\n\n while left <= right\n # puts \"left: #{left}, right: #{right}\"\n # puts \"a[l]: #{a[left]}, a[r]: #{a[right]}\"\n # puts \"distinct: #{distinct}\"\n if a[left].abs > a[right].abs\n begin\n left += 1\n end until a[left] != a[left - 1]\n elsif a[left].abs < a[right].abs\n begin\n right -= 1\n end until a[right] != a[right + 1]\n else\n begin\n left += 1\n end until a[left] != a[left - 1]\n begin\n right -= 1\n end until a[right] != a[right + 1] \n end\n\n distinct += 1\n end\n distinct\nend",
"def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend",
"def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend",
"def solution(a)\n ((1..a.size + 1).to_a - a).first\nend",
"def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend",
"def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend",
"def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend",
"def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend",
"def find_unique_elements(arr)\n arr_fin=[]\n arr.each do |x|\n arr.count(x)\n if arr.count(x)==1\n arr_fin << x\n end\n end\n return arr_fin\nend",
"def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend",
"def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend",
"def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend",
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def find_unsorted_subarray(nums)\n \nend",
"def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend",
"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 naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend",
"def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend",
"def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend",
"def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend",
"def solution1(a)\n a.map(&:abs).uniq.size\nend",
"def solution(a)\n result = 0\n tmp_count = 0\n a.each_with_index do |val, idx|\n if val.zero?\n tmp_count += 1\n else\n result += tmp_count\n end\n end\n return result > 1000000000 ? -1 : result\nend",
"def find_unique_elements(arr)\n arr_unique = []\n arr.each do |elem1|\n var1 = 0\n arr.each do |elem2|\n if elem1 == elem2\n var1 = var1 + 1\n end\n end\n if var1 <= 1\n arr_unique.push(elem1)\n end\n end\nend",
"def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \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 find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend",
"def find_unique_elements(arr)\n \n#Algorithmic Process\n#Create an array that includes elements without the repeats\n#Create a hash that pairs each element of the new array with how many times it appears in the original array\n#Any key-value pair that has 1 for a value is unique and gets placed in the desired array\n \nnew_hash = {}\narr.each do |x|\n new_hash[x] = 0 if new_hash[x].nil?\n new_hash[x] = new_hash[x] + 1\nend\n\nnew_hash.delete_if {|key, value| value != 1}\nnew_hash.each_key {|key| puts key}\n\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend",
"def two_sum(numbers, target)\n ##set hash\n hash = {}\n ##set array\n arr = []\n\n numbers.each_with_index do |val, idx|\n if hash.key?(target - val)\n arr.push(hash[target - val])\n arr.push(idx + 1)\n break\n else\n hash[val] = idx + 1\n end\n end\n\n arr\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 optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend",
"def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend",
"def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend",
"def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end",
"def awesome(arr, target)\n hash = Hash.new(0)\n i = 0\n j = i + 1\n while i < arr.size\n hash[arr[i] + arr[j]] += 1 \n if j < arr.size\n j += 1\n else\n i += 1\n if j = i + 1 > arr.length\n j = i \n else\n j = i + 1\n \n end\n\n end\n \n end\n return true if hash[target] >= 1\n false\nend",
"def unique_in_order(iterable) \n# create an empty array\ncontent = []\n\n # check each letter/number of `iterable` \n for e in (0..iterable.length()-1) \n\n# compare current element to previous element\n# if array is empty\n if e == 0 or \n# \n# if current element is not the same with previous element, push current index to content array\n iterable[e] != iterable[e-1] \n content.push(iterable[e])\n end\n end\n# return new content array\n return content\nend",
"def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend",
"def collisions(arr)\n new_arr = []\n result = []\n arr.each do |i|\n if i > 0\n new_arr << i\n else\n if new_arr.empty?\n result << i\n else\n if new_arr[-1] == -(i)\n new_arr.pop\n else\n while !new_arr.empty? && new_arr[-1] < -(i)\n new_arr.pop\n end\n if new_arr.empty?\n result << i\n end\n end\n end\n end\n end\n return (result.concat(new_arr))\nend",
"def find_duplicate(nums)\n intersection = find_first_meeting(nums)\n find_cycle_start(nums,intersection)\nend",
"def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend",
"def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend",
"def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend",
"def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend",
"def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend",
"def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end",
"def cnts a\n r = []\n found = false\n a.each do |x|\n r.each do |y|\n if y[0] === x\n y[1] += 1\n found = true\n break\n end\n end\n if !found\n r.push([x, 1])\n else\n found = false\n end\n end\n r\nend",
"def solution(a)\n counts = {}\n for i in a\n counts[i] ||= 0\n counts[i] += 1\n end\n for i in (1..a.count)\n return 0 if counts[i] != 1\n end\n return 1\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend",
"def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend",
"def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend",
"def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend",
"def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend",
"def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend",
"def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend",
"def lcs_phase_two(arr)\n return arr.max if arr.max < 0 #edge case\n\n current = 0\n largest = 0\n\n arr.each do |ele|\n current += ele\n current = 0 if current < 0 #bookmark\n largest = current if largest < current\n end\n\n largest\nend",
"def solution(arr)\n temp_hash_odd_balls = {}\n\n arr.each { |el| temp_hash_odd_balls[el] ? temp_hash_odd_balls.delete(el) : temp_hash_odd_balls[el] = 0 }\n\n temp_hash_odd_balls.keys.first\nend",
"def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend",
"def sub_sum2(array)\n arr = []\n sum = 0\n array.each do |el|\n arr << [el] \n end\n array.each do |el|\n array.shift\n arr << array\n end\n # p arr\n result = 0\n arr.each do |set|\n if set.reduce(:+) > result\n result = set.reduce(:+)\n end \n end \n result\nend",
"def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend",
"def f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend",
"def dominant_octopus(fish)\n #sorted = []\n return fish if fish.length < 2\n pivot = fish.first\n left = fish[1..-1].select { |feesh| feesh.length <= pivot.length }\n #p left\n right = fish[1..-1].select { |feesh| feesh.length > pivot.length }\n\n dominant_octopus(left) + [pivot] + dominant_octopus(right)\n \n\n\nend",
"def sq_arr(a)\n # require 'debug'\n a.map! { |x| x**2 }\n j = (a.length - 1)\n return a if j == 0\n while a[0] >= a[1] && j >= 0\n p j\n if a[0] > a[j]\n a.insert(j, a.shift)\n else\n j -= 1\n end\n end\n a\nend",
"def solution(a)\n # write your code in Ruby 2.2\n permutation = Array(1..a.size)\n # puts permutation\n return 1 if permutation - a == []\n 0\nend",
"def c v1, v2, o\n m = false\n d = []\n (0...v2.size).each{ |j|\n if !v1.include? v2[j] + o\n d << v2[j]\n m = true\n end\n }\n for x in d\n v2.delete x\n end\n m\nend",
"def equil_idcs(a)\n left = 0\n sum = a.inject(:+)\n equils = []\n a.each_with_index do |num, idx|\n sum -= num\n equils << idx if left == sum\n left += num\n end\n equils.empty? ? -1 : equils\nend",
"def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend",
"def solution(a)\n # write your code in Ruby 2.2 \n frecuencies = a.each_with_object(Hash.new(0)) { |key, value| value[key] += 1 } \n \n frecuencies.each do |key, value|\n if value.odd? then return key end\n end\nend",
"def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend",
"def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend",
"def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend",
"def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend"
] |
[
"0.65076977",
"0.6224968",
"0.59870076",
"0.59614",
"0.592963",
"0.5878061",
"0.5871787",
"0.58503795",
"0.58141303",
"0.5810536",
"0.5783606",
"0.5758984",
"0.5741224",
"0.57400525",
"0.5717067",
"0.5695446",
"0.56916237",
"0.5682769",
"0.56791544",
"0.56744385",
"0.56462455",
"0.56403905",
"0.56355983",
"0.56148314",
"0.5609005",
"0.5607288",
"0.5604348",
"0.56018645",
"0.5600563",
"0.5593942",
"0.558283",
"0.5582329",
"0.5580358",
"0.55733967",
"0.55704725",
"0.5568864",
"0.55608475",
"0.55544275",
"0.554988",
"0.5549293",
"0.55459195",
"0.5545592",
"0.5544114",
"0.5537456",
"0.553246",
"0.55293894",
"0.5528896",
"0.5520509",
"0.5520253",
"0.551982",
"0.5518587",
"0.55160594",
"0.55106336",
"0.5498553",
"0.5492679",
"0.5492065",
"0.54912525",
"0.549038",
"0.5489442",
"0.5483485",
"0.54815364",
"0.5479698",
"0.54748607",
"0.54739094",
"0.54717714",
"0.54707825",
"0.54688394",
"0.54685116",
"0.54661",
"0.54639995",
"0.5461305",
"0.546011",
"0.5459417",
"0.5458572",
"0.54553246",
"0.54547024",
"0.545129",
"0.5449906",
"0.5447548",
"0.5441376",
"0.54389584",
"0.5436833",
"0.5436647",
"0.5435451",
"0.5431747",
"0.5431689",
"0.5426796",
"0.5424433",
"0.5416063",
"0.5414151",
"0.5404067",
"0.54038966",
"0.5400079",
"0.5393501",
"0.5392692",
"0.53889656",
"0.5387861",
"0.5386957",
"0.538585",
"0.5381257",
"0.5381094"
] |
0.0
|
-1
|
Time complexity O(n) n is the size of the list Space complexity O(1)
|
def length
count = 0
current = head
until current.nil?
count += 1
current = current.next
end
return count
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend",
"def max_in_list(list, n = 1)\n list.group_by { |v| v }.sort_by do |_, s|\n -s.length\n end.first(n).map(&:first)\nend",
"def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\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 top_k_frequent_elements(list, k)\n results = []\n\n return list if list.length == k\n return results if list.length == 0 \n\n list = list.sort.uniq\n\n i = 0\n k.times do \n results << list[i]\n i += 1\n end \n return results\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def duplin(list, n)\n list.map { |i| [i] * n }.flatten\nend",
"def my_better_min(list)\n min = list[0] #1\n\n list.each_with_index do |ele_1, i| #n\n if ele_1 < min # 1 *n\n min = ele_1 #1 *n\n end\n end\n\n min #1\n # (i...list.length).each do |j|\n # if list[i] list[j]\nend",
"def take list, n\n #first do this without take...\n #n > 0 ? list[0..(n-1)] : []\n list.take(n)\nend",
"def twist length\n # Compute the subset of the list\n sub = (0...length).map do |i|\n @list[(@position + i) % @list.size]\n end\n\n # Replace the subset with its reverse\n sub.reverse.each_with_index do |el, i|\n @list[(@position + i) % @list.size] = el\n end\n\n @position = (@position + length + @skip_size) % @list.size\n @skip_size += 1\n end",
"def top_k_frequent_elements(list, k)\n return nil if !list\n # intialze an empty hash\n ## iterate throught the list\n #chechk if the key is in the hash,\n # if key is in the hash ++ value\n # otherwise add key and value as 1 since it's first occurance\n # now the key(uniqe) and value(how many time the int_value) happend is in the hash,\n # my_hash.sort_by { |_, value| value }.each { |key, value| puts key } (iterate throught the hash, (hash.each {|key, value|}) )\n # before pushing the key into the initalized array, check to see if the length is less than k\n # if\n hash = Hash.new\n list.each do |int_value|\n if hash.key?(int_value)\n hash[key] = +1\n else\n hash[key] = 1\n end\n end\n kth_frequent_elements = []\n counter = 0 \n pervisou_value = 0\n hash.sort_by { |k, v| -v }.each do |key, value|\n if counter < k\n kth_frequent_elements << key\n if pervisou_value != value\n pervisou_value = value\n counter += 1\n end\n # end\n # if kth_frequent_elements.length < k\n # kth_frequent_elements << key\n else\n break\n end\n end\n return kth_frequent_elements\nend",
"def top_k_frequent_elements(list, k)\n element_occurrence = {}\n list.each do |element|\n if element_occurrence[element]\n element_occurrence[element] += 1\n else\n element_occurrence[element] = 1\n end\n end\n \n sorted_pairs = element_occurrence.sort_by {|key, value| -value }\n output = []\n k.times do |index|\n return output if sorted_pairs[index].nil?\n output << sorted_pairs[index].first\n end\n return output\nend",
"def top_k_frequent_elements(list, k)\n return list if list.empty? || list.size == 2\n\n elements = []\n hash = {}\n\n list.each do |elem|\n if hash[elem]\n hash[elem] += 1\n else\n hash[elem] = 1\n end\n end\n\n k.times do\n max_key = hash.key(hash.values.max)\n elements << max_key\n hash.delete(max_key)\n end\n return elements\nend",
"def top_k_frequent_elements(list, k)\n counter_hash = {}\n list.each do |value|\n if counter_hash[value].nil?\n counter_hash[value] = 1\n else\n counter_hash[value] += 1\n end\n end \n \n values_sort = counter_hash.sort_by {|key, value| -value}\n k_values = values_sort.slice(0..(k-1))\n final_values = []\n k_values.each do |value|\n final_values << value[0]\n end\n \n return final_values\nend",
"def sub_sum(list)\n array = []\n (0...list.length).each do |idx1|\n (idx1...list.length).each do |idx2|\n array << list[idx1..idx2] #O(n)\n end\n end \n array.map {|sub| sub.length > 1 ? sub.sum : sub.first}.max\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty? \n # list tracking quantities\n total_ele = list.length # O(n) operation\n return list if total_ele == 1\n top_k = Array.new(total_ele + 1){[]} # plus one for better tracking\n count_hash = {}\n\n # get frequencies of each element, O(n)\n list.each do |e|\n count_hash[e] ||= 1\n count_hash[e] += 1\n end\n\n # use a non-nested O(n) operation to sort\n # frequencies in top_k\n count_hash.each do |k,v|\n top_k[v] << k\n end\n\n return_arr = []\n \n # sort array in order now\n until total_ele == 0\n if(!top_k[total_ele].empty?)\n return_arr += top_k[total_ele]\n end\n\n total_ele -= 1\n end\n\n return return_arr[0...k]\nend",
"def top_k_frequent_elements(list, k)\n res = []\n return res if list.empty?\n hash = {}\n list.each do |num|\n if hash[num]\n hash[num] += 1\n else\n hash[num] = 1\n end\n end\n \n k.times do \n max = nil\n hash.each do |num, v|\n if v && (max.nil? || v > max)\n max = num \n end\n end\n if max\n hash[max] = nil\n res << max\n end\n end\n \n return res\nend",
"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 top_k_frequent_elements(list, k)\n return [] if list.empty?\n \n element_count = {}\n \n list.each do |element|\n if element_count[element].nil?\n element_count[element] = 1\n else\n element_count[element] += 1\n end\n end\n \n sorted_elements = element_count.sort_by(&:first)\n \n i = 0\n max_nums = []\n k.times do\n max_nums << sorted_elements[i][0]\n i += 1\n end\n \n return max_nums\nend",
"def top_k_frequent_elements(list, k)\n if list.length == 0 \n return []\n end \n nums = {}\n list.each do |num|\n if !nums[num]\n nums[num] = 1\n else\n nums[num] += 1\n end\n end \n\n sorted = nums.sort_by {|k, v| -v}\n top_k = []\n k.times do |k|\n top_k << sorted[k][0]\n end \n return top_k\nend",
"def DistinctList(arr)\n\n return arr.size - arr.uniq.size\n \nend",
"def top_k_frequent_elements(list, k)\n # load a hash table which has elements & their frequency \n element_frequency = {}\n array = []\n return array if list.length == 0\n\n list.each do |val|\n if !(element_frequency[val])\n element_frequency[val] = 1\n else\n element_frequency[val] += 1\n end\n end\n\n values = element_frequency.values.sort!\n inverted_hash = element_frequency.invert\n \n k.times do |i|\n array << inverted_hash[values[i]]\n end\n\n return array \nend",
"def top_k_frequent_elements(list, k)\n h = {}\n solution = []\n return solution if list.nil? || list.empty? || !list.is_a?(Array)\n list.each do |element|\n if h.include?(element)\n h[element] += 1\n else\n h[element] = 1\n end\n end\n k.times do\n top = nil\n h.each do |element,value| \n if value && (top.nil? || value > top)\n top = element\n end\n end \n if top \n h[top] = nil\n solution << top\n end\n end \n return solution\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n return list if list.length == 1\n\n element_count = Hash.new()\n\n list.each do |element|\n if element_count[element]\n element_count[element] += 1\n else\n element_count[element] = 1\n end\n end\n\n result = []\n\n k.times do |i|\n count = 0\n frequent_element = nil\n element_count.each do |element, frequency|\n if frequency > count\n count = frequency\n frequent_element = element\n end\n end\n result << frequent_element\n element_count[frequent_element] = 0 if frequent_element\n end\n\n return result\n\nend",
"def sub_sum(list)\n sub_arrs = []\n # byebug\n list.each_index do |i|\n list.each_index do |j|\n if j >= i\n sub_arrs << list[i..j]\n end\n end\n end\n size = []\n sub_arrs.each do |arr|\n size << arr.inject(&:+)\n end\n size.max\nend",
"def sort_it(list_, n)\n # Your code goes here\nend",
"def top_k_frequent_elements(list, k)\n return [] if list == []\n\n frequency = {}\n list.each do |element|\n if frequency[element]\n frequency[element] += 1\n else\n frequency[element] = 1\n end\n end\n\n k_frequent_elements = []\n\n k.times do |i|\n max_freq = 0\n max_freq_element = nil\n frequency.each do |element, freq|\n if freq > max_freq\n max_freq = freq\n max_freq_element = element\n end\n end\n k_frequent_elements << max_freq_element\n frequency[max_freq_element] = 0 if max_freq_element\n end\n\n return k_frequent_elements\nend",
"def element(n, list)\n list[n - 1]\n end",
"def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend",
"def OG_list1(list)\n if list.size % 2 == 1\n #odd length lists\n return list[list.size/2] \n else\n # even length lists\n (list[list.size/2] + list[list.size / 2 - 1]) / 2.0\n end\nend",
"def uniques(list)\n fa = []\n \n list.map do |n|\n while !(fa.include?(n))\n fa.push(n)\n end\n end\n \n #puts fa\n return fa\nend",
"def unique_sum(lst)\n return nil if lst.empty?\n\n staging_arr = []\n total = 0\n\n lst.each do |num|\n staging_arr << num unless staging_arr.include?(num)\n end\n\n staging_arr.each do |uniq_num|\n total += uniq_num\n end\n\n total\nend",
"def top_k_frequent_elements(list, k)\n result_arr = []\n return result_arr if list.length == 0\n\n frequency_hash = {}\n\n list.each do |element|\n if frequency_hash[element]\n frequency_hash[element] += 1\n else\n frequency_hash[element] = 1\n end\n end\n\n k.times do\n top_element = nil\n top_frequency = 0 \n\n frequency_hash.each do |element, frequency|\n top_frequency = frequency && top_element = element if frequency > top_frequency\n end\n\n result_arr << top_element\n frequency_hash[top_element] = 0\n end\n\n return result_arr\nend",
"def rearrangeLastN(l, n)\n return l if n == 0\n fast, slow = l, l\n n.times do\n if fast\n fast = fast.next\n end\n end\n return l unless fast\n while fast.next\n slow = slow.next\n fast = fast.next\n end\n\n result = slow.next\n slow.next = nil\n fast.next = l\n result\nend",
"def my_min_2(list) # n\n min_value = list.first\n i = 0\n while i < list.length\n min_value = list[i] if list[i] < min_value\n i += 1\n end\n min_value\nend",
"def count(list)\n list.length\nend",
"def list_size(list)\n return 0 if list.head.nil?\n 1 + list_size(LinkedList.new(list.head.link))\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n frequency = {}\n list.each do |i|\n frequency[i] ? (frequency[i] += 1) : (frequency[i] = 1)\n end\n\n nums = []\n unique = list.uniq\n max = frequency.values.max\n\n until max == 0 || nums.length == k\n unique.each do |i|\n break if nums.length == k\n if frequency[i] == max\n nums << i\n end\n end\n max -= 1\n end\n\n return nums\nend",
"def top_k_frequent_elements(list, k)\n result = []\n\n hash = Hash.new\n \n list.each do |letter|\n if hash[letter]\n hash[letter] += 1\n else \n hash[letter] = 1\n end \n end \n\n k.times do \n max = nil\n hash.each do |num, value|\n\n if value && (max.nil? || value > max)\n max = num \n end \n end \n\n if max \n hash[max] = nil \n result << max \n end \n end \n return result end",
"def largest_contiguous_subsum(list)\r\n sub_arr = []\r\n list.each_with_index do |ele1,idx1|\r\n list.each_with_index do |ele2,idx2|\r\n sub_arr<< list[idx1..idx2] if idx2>=idx1\r\n end\r\n end\r\n p sub_arr.size\r\n sub_arr.map{ |sub| sub.sum}.max\r\n #(O(n^2 + m)\r\nend",
"def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end",
"def top_k_frequent_elements(list, k)\n return [] if list == []\n hash = Hash.new(0)\n counter = 0;\n list.each do |value|\n hash[value] = [] if hash[value].nil?\n hash[value]+=1\n end\n \n if k > hash.size()\n raise ArgumentError, \"Not Enough Values to Display\"\n end\n \n solution = hash.max(k){ |a, b| b<=>a} \n p solution\n numbers = []\n solution.each do |array|\n numbers << array[0]\n end\n return numbers\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n count_hash = Hash.new(0)\n result = []\n\n list.each do |element|\n count_hash[element] += 1\n end\n\n max_array = count_hash.sort_by { |k, v| -v }\n\n (0...k).each do |i|\n result << max_array[i][0]\n end\n\n return result\nend",
"def size\n self.list.length\n end",
"def top_k_frequent_elements(list, k)\n hash = {}\n \n list.each do |value|\n if hash[value]\n hash[value] += 1\n else\n hash[value] = 1\n end\n end\n \n top_elements = Array.new(k)\n return top_elements = hash.sort_by{ |key, value| value } \nend",
"def top_k_frequent_elements(list, k)\n # build hashmap\n num_hash = {}\n list.each do |num|\n if num_hash[num]\n num_hash[num] += 1\n else\n num_hash[num] = 1\n end\n end\n\n # convert hashmap to array\n array_num_hash = num_hash.to_a\n\n # sort by occurences\n sorted_array_num_hash = array_num_hash.sort_by {|num| -num[1]}\n\n # sorted elements only\n sorted_numbers = sorted_array_num_hash.map{|num| num[0]}\n\n # slice sorted array by k elements\n return sorted_numbers.slice(0, k)\nend",
"def find_k_to_last_size_known linked_list, k\n k_to_last = linked_list.length - k\n current = linked_list.head\n k_to_last.times do\n current = current.next\n end\n current.data\nend",
"def top_k_frequent_elements(list, k)\n \n return [] if list.empty?\n ranked_hash = {}\n ranked = []\n\n list.each do |element|\n if ranked_hash.has_key?(element)\n ranked_hash[element] += 1\n else\n ranked_hash[element] = 1\n end\n end\n\n sorted = ranked_hash.sort_by { | k, v | -v }\n\n k.times do \n max = sorted.shift\n ranked << max[0]\n k -= 1\n end\n\n return ranked \n\nend",
"def drop(list, n)\n result = []\n list.each_index do |i| \n if i % n != n - 1 \n result << list[i] \n end \n end\n result\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n hash = {}\n\n list.each do |element|\n if hash[element]\n hash[element] += 1\n else\n hash[element] = 1\n end\n end\n\n answer = []\n answer_length = 0\n\n highest_freq = hash.values.max\n\n while answer_length < k\n hash.each do |element, count|\n if count == highest_freq\n answer << element\n answer_length += 1\n end\n\n break if answer_length == k\n end\n\n highest_freq -= 1\n end\n\n return answer\nend",
"def delete_over_nth(list,n)\n x = list[0]\n list.each do |item|\n if item == x\n return true\n else\n return false\n end\n p x\n end\n \nend",
"def top_k_frequent_elements(list, k)\n k_freq = []\n return k_freq if list.empty?\n \n hash_map = Hash.new\n\n list.each do |element| \n hash_map[element] ? hash_map[element] += 1 : hash_map[element] = 1\n end\n \n vals = hash_map.values \n max_vals = vals.max(k) \n \n max_vals.each do |val| \n key = hash_map.key(val)\n k_freq << key\n hash_map.delete(key)\n end\n return k_freq\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n counts_hash = {}\n\n list.each do |number|\n if !counts_hash[number]\n counts_hash[number] = 1 \n else\n counts_hash[number] = counts_hash[number] + 1\n end\n end\n\n length_to_num_hash = {}\n\n counts_hash.keys.each do |number|\n if !length_to_num_hash[counts_hash[number]]\n length_to_num_hash[counts_hash[number]] = []\n end\n length_to_num_hash[counts_hash[number]] << number\n end\n\n result_length = k\n result = []\n most_freq_num = length_to_num_hash.keys.max\n\n while result_length > 0 && most_freq_num != nil && most_freq_num >= 0\n if length_to_num_hash[most_freq_num]\n length_to_num_hash[most_freq_num].each do |num|\n result << num\n result_length -= 1\n break if result_length <= 0\n end\n end\n most_freq_num -= 1\n end\n\n return result\nend",
"def nth_element_from_end(head,n)\n return head unless head\n length_of_list = 0\n current_node = head\n while(current_node != nil)\n length_of_list += 1\n current_node = current_node.next\n end\n\n position_of_node = length_of_list - (n+1)\n return nil if position_of_node < 0\n current_node = head\n 0.upto(position_of_node) do \n if current_node != nil\n current_node = current_node.next\n end\n end\n return current_node.val\nend",
"def remove_dupes list\n cur = list.head\n i = 0\n while cur != nil\n list.remove i\n if !contains(list, cur.node)\n list.insert cur.node, i\n i += 1\n end\n cur = cur.nxt\n end\n\n return list\nend",
"def size\n list.size\n end",
"def top_k_frequent_elements(list, k)\n # list = [1,1,1,2,2,3]\n # k = 2\n return [] if list == []\n\n counter = {}\n\n list.each do |value|\n if counter[value]\n counter[value] += 1\n else\n counter[value] = 1\n end\n end\n\n puts counter\n\n ordered = counter.sort_by{ |key, value| value } \n\n k_most = []\n\n k.times do |i|\n k_most << ordered[-i]\n end\n\n return k_most\nend",
"def get(n)\n\t\ti = 0\n\t\taux = @head\n\t\twhile i < n do\n\t\t\taux = aux.next\n\t\ti += 1\n\t\tend\n\n\t\treturn aux\n\t\t\t\n\tend",
"def top_k_frequent_elements(list, k)\n return list if list.empty? || list.length == k\n count = {}\n \n list.each do |num|\n count[num] ? count[num] += 1 : count[num] = 1\n end\n \n sorted = count.sort_by { |k, v| -v }\n \n most_frequent = Array.new(k)\n k.times { |i| most_frequent[i] = sorted[i][0] } \n \n return most_frequent\nend",
"def largest(list)\n time = Time.now\n arr = []\n list.each_with_index do |el, i|\n list.each_with_index do |el2, i2|\n arr << list[i..i + i2]\n end\n end\n max = arr[0].sum\n arr.each do |el|\n max = el.sum if el.sum > max\n end\n puts Time.now - time\n max\nend",
"def nub(xs)\n if(xs.length<=1)\n return xs\n\tend\n newList = []\n for x in xs\n if !newList.include? x \n newList.push(x)\n\t\tend\n\tend\n\treturn newList\nend",
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend",
"def take(n=@size)\n a = []\n n.times{a.push(pop)}\n a\n end",
"def largest_contiguous_subsum(list)\n # l = list.length # 1\n # result = [] # 1\n # hash = Hash.new(0) # 1\n\n # (0...l).each do |i1| # n\n # (0...l).each do |i2| # n\n # result << list[i1..i2] if i2 >= i1 # 1\n # end\n # end\n\n # result.each do |sub_arr| # n\n # hash[sub_arr] = sub_arr.sum # 1\n # end\n\n # sorted_by_val = hash.sort_by { |k, v| v } # n, \n # sorted_by_val[-1][1] # \nend",
"def top_k_frequent_elements(list, k)\n return [] if k == 0\n\n frequency = {}\n list.each do |element|\n frequency[element] ? frequency[element] += 1 : frequency[element] = 1\n end\n\n return frequency.keys[0...k]\nend",
"def unique (mylist)\n # Your code here\nend",
"def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend",
"def largest_contiguous_subsum_n(list2)\n large = 0\n \n list2.inject do |sum, n|\n if (sum + n) > sum\n sum += n \n large = sum if sum > large\n sum\n else\n sum = 0\n end\n end\n\n large\nend",
"def partition list, x\n # TODO implement size property in list class\n cur = list.head\n size = 0\n while cur != nil\n size += 1\n cur = cur.nxt\n end\n\n cur = list.head\n i = 0\n while i < size\n mv = cur\n list.remove(i)\n if mv.node < x\n list.insert(mv.node, 0)\n else\n list.insert(mv.node, size - 1)\n end\n cur = cur.nxt\n i += 1\n end\n\n return list\nend",
"def remove_duplicates(list)\n if list.length == 0\n return []\n end\n \n length = list.length\n i = 0\n j = 0\n while i < length-1\n if list[i] != list[i+1]\n list[j] = list[i]\n j += 1\n end\n i += 1\n end\n list[j] = list[length - 1]\n \n ((j+1)..(length-1)).each do |index|\n list.pop()\n end\n \n # list.each_with_index do |item,index|\n # if item == nil\n # list.delete_at(index)\n # end\n # end\n \n # list = list[0..j]\n return list\nend",
"def largest_contiguous_subsum_1(list)\r\n subarrays = [] #1\r\n list.each_with_index do |ele1, i| #n\r\n list[i...list.length].each_with_index do |ele2,i2| #(n-1)\r\n subarrays << list[i..i2+i] #k \r\n end\r\n end # n^2\r\n subarrays.map { |subarray| subarray.sum}.max # n^x\r\nend",
"def num_removed(list)\n full_list = (1..100).to_a\n missing_num = (full_list - list)[0]\nend",
"def sub_sum(list)\n subs = []\n\n list.each_with_index do |el1, i|\n # debugger\n (0...list.length - i).each do |len|\n subs << list[i..i + len]\n end\n\n end\n\n subs.map! do |subset|\n subset.inject(:+)\n end\n\n subs.max\nend",
"def sumarr(list)\n list2=list.sort\n total = 0\n i=0\n while i<list2.length\n len=list2.length-i\n list2[0..len].each do |x|\n total+=x\n total2=total-x\n puts \"#{x} plus #{total2} equals #{total}\"\n i+=1\n end\n end\nend",
"def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend",
"def sub_sum_2(list)\r\n largest_sum = list.first\r\n current_sum = list.first\r\n \r\n # one loop only\r\n # need to get all subarr\r\n i = 1\r\n while i < list.length #loop to create subarr\r\n if current_sum < 0\r\n current_sum = 0\r\n end \r\n current_sum += list[i]\r\n if current_sum > largest_sum\r\n largest_sum = current_sum\r\n end\r\n i += 1\r\n end\r\n largest_sum\r\n end",
"def each_cons list, n\n list.each_cons(n).to_a\nend",
"def given\n [6,5,3,1,8,7,2,3]\nend",
"def numUnique2 list\n current_num = list[0]\n unique_numbers = [list[0]]\n\n list.each do |num|\n if num != current_num\n current_num = num\n unique_numbers << num\n end\n end\n return \"**#{unique_numbers.length}**\"\nend",
"def remove_duplicates(list)\n if list.length < 2\n return list\n else\n i = 0\n list.each do |num|\n if num == list[(i+1)]\n list.delete_at(i)\n end\n i += 1\n end\n return list\n end\nend",
"def nthElementFromTheEnd(l, n)\n out, ln = [], l\n while ln do\n out.push ln.value\n ln = ln.next\n end\n return n > out.size ? -1 : out[out.size - n]\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n frequency_count = Hash.new(0)\n list.each do |num|\n frequency_count[num] += 1\n end\n\n top_k = frequency_count.to_a.sort_by { |e| e[1] }\n\n if k == 1\n top_k.first(k).map { |e| e[0] }\n else\n top_k.last(k).map { |e| e[0] }\n end\nend",
"def size\n @exact.size + @list.size\n end",
"def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend",
"def length\n # calculates the length of the list\n end",
"def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend",
"def size\n @list.size\n end",
"def size\n @list.size\n end",
"def top_k_frequent_elements(list, k)\n return list if list.empty?\n\n num_frequency = {}\n\n list.each do |num|\n num_frequency[num] ? num_frequency[num] += 1 : num_frequency[num] = 1\n end\n\n top_frequent_nums = []\n\n k.times do\n max_frequency = 0\n max_frequent_num = nil\n\n num_frequency.each do |key, value|\n if value > max_frequency\n max_frequency = value\n max_frequent_num = key\n end\n end\n\n top_frequent_nums << max_frequent_num\n num_frequency[max_frequent_num] = 0\n end\n\n return top_frequent_nums\nend",
"def unordered_list; end",
"def top_k_frequent_elements(list, k)\n return [] if list.empty? || k == 0\n\n item_with_freq = []\n item_freq = {}\n\n # make hash with freq of each element\n list.each do |item|\n if item_freq[item]\n item_freq[item] += 1\n else\n item_freq[item] = 1\n end\n end\n\n # turn hash into array and sort by freq\n item_with_freq = item_freq.to_a\n item_with_freq.sort_by { |item| item[1] }\n\n # iterate through sorted array k times and pull out top items\n top_items = []\n k.times do |i|\n top_items << item_with_freq[i][0]\n end\n\n return top_items\nend",
"def hufflepuff(list)\nend"
] |
[
"0.6275876",
"0.6265622",
"0.6179918",
"0.6111067",
"0.60622835",
"0.60542345",
"0.6053093",
"0.6053093",
"0.6053093",
"0.6053093",
"0.60321534",
"0.60281676",
"0.6019597",
"0.6019358",
"0.59654766",
"0.5963915",
"0.5962168",
"0.594031",
"0.5933971",
"0.5926341",
"0.5917202",
"0.59115446",
"0.58809847",
"0.5879988",
"0.58756363",
"0.58667755",
"0.5859831",
"0.5857229",
"0.5850229",
"0.5796746",
"0.5788356",
"0.5786681",
"0.5770047",
"0.5762592",
"0.57572806",
"0.57497525",
"0.5744325",
"0.5740512",
"0.57318544",
"0.57277083",
"0.5720272",
"0.5715964",
"0.57153004",
"0.5714596",
"0.5711721",
"0.5707113",
"0.5704232",
"0.56917745",
"0.5691426",
"0.5677124",
"0.56729865",
"0.56682545",
"0.5665906",
"0.5663366",
"0.56565386",
"0.5653659",
"0.56531245",
"0.5649518",
"0.56434363",
"0.5641668",
"0.5637723",
"0.5632247",
"0.5616011",
"0.5611371",
"0.560028",
"0.5599146",
"0.55946934",
"0.5587874",
"0.5580625",
"0.5576408",
"0.55738705",
"0.55720496",
"0.5571667",
"0.5568221",
"0.55621785",
"0.5551883",
"0.5549919",
"0.5549606",
"0.5549461",
"0.5545682",
"0.55396914",
"0.5538409",
"0.5526927",
"0.55227166",
"0.55214274",
"0.5512923",
"0.5512679",
"0.5509122",
"0.55085284",
"0.55081993",
"0.55081993",
"0.55081993",
"0.5506545",
"0.5487321",
"0.54872006",
"0.5479454",
"0.5479454",
"0.5469827",
"0.5465379",
"0.5459746",
"0.5443235"
] |
0.0
|
-1
|
Time complexity O(n) n is the length of the list Space complexity O(1)
|
def add_last(data)
if !@head
@head = Node.new(data)
else
current = @head
while current.next
current = current.next
end
current.next = Node.new(data)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def twist length\n # Compute the subset of the list\n sub = (0...length).map do |i|\n @list[(@position + i) % @list.size]\n end\n\n # Replace the subset with its reverse\n sub.reverse.each_with_index do |el, i|\n @list[(@position + i) % @list.size] = el\n end\n\n @position = (@position + length + @skip_size) % @list.size\n @skip_size += 1\n end",
"def length\n # calculates the length of the list\n end",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend",
"def count(list)\n list.length\nend",
"def max_in_list(list, n = 1)\n list.group_by { |v| v }.sort_by do |_, s|\n -s.length\n end.first(n).map(&:first)\nend",
"def take list, n\n #first do this without take...\n #n > 0 ? list[0..(n-1)] : []\n list.take(n)\nend",
"def length(list)\n number(list.to_a.size)\n end",
"def DistinctList(arr)\n\n return arr.size - arr.uniq.size\n \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 my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend",
"def list_size(list)\n return 0 if list.head.nil?\n 1 + list_size(LinkedList.new(list.head.link))\nend",
"def OG_list1(list)\n if list.size % 2 == 1\n #odd length lists\n return list[list.size/2] \n else\n # even length lists\n (list[list.size/2] + list[list.size / 2 - 1]) / 2.0\n end\nend",
"def size\n self.list.length\n end",
"def sub_sum(list)\n array = []\n (0...list.length).each do |idx1|\n (idx1...list.length).each do |idx2|\n array << list[idx1..idx2] #O(n)\n end\n end \n array.map {|sub| sub.length > 1 ? sub.sum : sub.first}.max\nend",
"def my_better_min(list)\n min = list[0] #1\n\n list.each_with_index do |ele_1, i| #n\n if ele_1 < min # 1 *n\n min = ele_1 #1 *n\n end\n end\n\n min #1\n # (i...list.length).each do |j|\n # if list[i] list[j]\nend",
"def top_k_frequent_elements(list, k)\n results = []\n\n return list if list.length == k\n return results if list.length == 0 \n\n list = list.sort.uniq\n\n i = 0\n k.times do \n results << list[i]\n i += 1\n end \n return results\nend",
"def sub_sum(list)\n sub_arrs = []\n # byebug\n list.each_index do |i|\n list.each_index do |j|\n if j >= i\n sub_arrs << list[i..j]\n end\n end\n end\n size = []\n sub_arrs.each do |arr|\n size << arr.inject(&:+)\n end\n size.max\nend",
"def length\r\n @list.length\r\n end",
"def duplin(list, n)\n list.map { |i| [i] * n }.flatten\nend",
"def nth_element_from_end(head,n)\n return head unless head\n length_of_list = 0\n current_node = head\n while(current_node != nil)\n length_of_list += 1\n current_node = current_node.next\n end\n\n position_of_node = length_of_list - (n+1)\n return nil if position_of_node < 0\n current_node = head\n 0.upto(position_of_node) do \n if current_node != nil\n current_node = current_node.next\n end\n end\n return current_node.val\nend",
"def size\n list.size\n end",
"def length_of_lis(nums)\n len = []\n (0...nums.size).map { |i|\n len[i] = (0...i)\n .select { |j| nums[j] < nums[i] }\n .map { |j| len[j] + 1 }.max || 1\n }.max || 0\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"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 find_k_to_last_size_known linked_list, k\n k_to_last = linked_list.length - k\n current = linked_list.head\n k_to_last.times do\n current = current.next\n end\n current.data\nend",
"def rearrangeLastN(l, n)\n return l if n == 0\n fast, slow = l, l\n n.times do\n if fast\n fast = fast.next\n end\n end\n return l unless fast\n while fast.next\n slow = slow.next\n fast = fast.next\n end\n\n result = slow.next\n slow.next = nil\n fast.next = l\n result\nend",
"def top_k_frequent_elements(list, k)\n return nil if !list\n # intialze an empty hash\n ## iterate throught the list\n #chechk if the key is in the hash,\n # if key is in the hash ++ value\n # otherwise add key and value as 1 since it's first occurance\n # now the key(uniqe) and value(how many time the int_value) happend is in the hash,\n # my_hash.sort_by { |_, value| value }.each { |key, value| puts key } (iterate throught the hash, (hash.each {|key, value|}) )\n # before pushing the key into the initalized array, check to see if the length is less than k\n # if\n hash = Hash.new\n list.each do |int_value|\n if hash.key?(int_value)\n hash[key] = +1\n else\n hash[key] = 1\n end\n end\n kth_frequent_elements = []\n counter = 0 \n pervisou_value = 0\n hash.sort_by { |k, v| -v }.each do |key, value|\n if counter < k\n kth_frequent_elements << key\n if pervisou_value != value\n pervisou_value = value\n counter += 1\n end\n # end\n # if kth_frequent_elements.length < k\n # kth_frequent_elements << key\n else\n break\n end\n end\n return kth_frequent_elements\nend",
"def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend",
"def nthElementFromTheEnd(l, n)\n out, ln = [], l\n while ln do\n out.push ln.value\n ln = ln.next\n end\n return n > out.size ? -1 : out[out.size - n]\nend",
"def element(n, list)\n list[n - 1]\n end",
"def length\n return @list.length\n end",
"def top_k_frequent_elements(list, k)\n return [] if list.empty? \n # list tracking quantities\n total_ele = list.length # O(n) operation\n return list if total_ele == 1\n top_k = Array.new(total_ele + 1){[]} # plus one for better tracking\n count_hash = {}\n\n # get frequencies of each element, O(n)\n list.each do |e|\n count_hash[e] ||= 1\n count_hash[e] += 1\n end\n\n # use a non-nested O(n) operation to sort\n # frequencies in top_k\n count_hash.each do |k,v|\n top_k[v] << k\n end\n\n return_arr = []\n \n # sort array in order now\n until total_ele == 0\n if(!top_k[total_ele].empty?)\n return_arr += top_k[total_ele]\n end\n\n total_ele -= 1\n end\n\n return return_arr[0...k]\nend",
"def list_size()\n counter = 0\n temp_node = @head #start traversting from first elemnt\n until temp_node == nil #stop when reach end of list\n temp_node = temp_node.link #step though list with link variable\n counter += 1\n end\n counter\n end",
"def num_removed(list)\n full_list = (1..100).to_a\n missing_num = (full_list - list)[0]\nend",
"def sumarr(list)\n list2=list.sort\n total = 0\n i=0\n while i<list2.length\n len=list2.length-i\n list2[0..len].each do |x|\n total+=x\n total2=total-x\n puts \"#{x} plus #{total2} equals #{total}\"\n i+=1\n end\n end\nend",
"def initialize(n)\n self.length = n\n self.list = (1..n).to_a\n end",
"def my_min_2(list) # n\n min_value = list.first\n i = 0\n while i < list.length\n min_value = list[i] if list[i] < min_value\n i += 1\n end\n min_value\nend",
"def top_k_frequent_elements(list, k)\n element_occurrence = {}\n list.each do |element|\n if element_occurrence[element]\n element_occurrence[element] += 1\n else\n element_occurrence[element] = 1\n end\n end\n \n sorted_pairs = element_occurrence.sort_by {|key, value| -value }\n output = []\n k.times do |index|\n return output if sorted_pairs[index].nil?\n output << sorted_pairs[index].first\n end\n return output\nend",
"def length_of_lis(nums)\n return 0 if !nums\n return 1 if nums.size == 1\n arr = [0] * nums.size\n max = 0\n for i in 0...nums.size do \n arr[i] = 1\n for j in 0...i do \n if nums[j] < nums[i]\n arr[i] = arr[i] > arr[j] + 1 ? arr[i] : arr[j] + 1 \n end\n end\n max = [max, arr[i]].max\n end\n max\nend",
"def sort_it(list_, n)\n # Your code goes here\nend",
"def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend",
"def top_k_frequent_elements(list, k)\n counter_hash = {}\n list.each do |value|\n if counter_hash[value].nil?\n counter_hash[value] = 1\n else\n counter_hash[value] += 1\n end\n end \n \n values_sort = counter_hash.sort_by {|key, value| -value}\n k_values = values_sort.slice(0..(k-1))\n final_values = []\n k_values.each do |value|\n final_values << value[0]\n end\n \n return final_values\nend",
"def top_k_frequent_elements(list, k)\n return list if list.empty? || list.size == 2\n\n elements = []\n hash = {}\n\n list.each do |elem|\n if hash[elem]\n hash[elem] += 1\n else\n hash[elem] = 1\n end\n end\n\n k.times do\n max_key = hash.key(hash.values.max)\n elements << max_key\n hash.delete(max_key)\n end\n return elements\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n return list if list.length == 1\n\n element_count = Hash.new()\n\n list.each do |element|\n if element_count[element]\n element_count[element] += 1\n else\n element_count[element] = 1\n end\n end\n\n result = []\n\n k.times do |i|\n count = 0\n frequent_element = nil\n element_count.each do |element, frequency|\n if frequency > count\n count = frequency\n frequent_element = element\n end\n end\n result << frequent_element\n element_count[frequent_element] = 0 if frequent_element\n end\n\n return result\n\nend",
"def uniques(list)\n fa = []\n \n list.map do |n|\n while !(fa.include?(n))\n fa.push(n)\n end\n end\n \n #puts fa\n return fa\nend",
"def unordered_list; end",
"def top_k_frequent_elements(list, k)\n if list.length == 0 \n return []\n end \n nums = {}\n list.each do |num|\n if !nums[num]\n nums[num] = 1\n else\n nums[num] += 1\n end\n end \n\n sorted = nums.sort_by {|k, v| -v}\n top_k = []\n k.times do |k|\n top_k << sorted[k][0]\n end \n return top_k\nend",
"def drop(list, n)\n result = []\n list.each_index do |i| \n if i % n != n - 1 \n result << list[i] \n end \n end\n result\nend",
"def numUnique2 list\n current_num = list[0]\n unique_numbers = [list[0]]\n\n list.each do |num|\n if num != current_num\n current_num = num\n unique_numbers << num\n end\n end\n return \"**#{unique_numbers.length}**\"\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n \n element_count = {}\n \n list.each do |element|\n if element_count[element].nil?\n element_count[element] = 1\n else\n element_count[element] += 1\n end\n end\n \n sorted_elements = element_count.sort_by(&:first)\n \n i = 0\n max_nums = []\n k.times do\n max_nums << sorted_elements[i][0]\n i += 1\n end\n \n return max_nums\nend",
"def top_k_frequent_elements(list, k)\n h = {}\n solution = []\n return solution if list.nil? || list.empty? || !list.is_a?(Array)\n list.each do |element|\n if h.include?(element)\n h[element] += 1\n else\n h[element] = 1\n end\n end\n k.times do\n top = nil\n h.each do |element,value| \n if value && (top.nil? || value > top)\n top = element\n end\n end \n if top \n h[top] = nil\n solution << top\n end\n end \n return solution\nend",
"def size\n @list.size\n end",
"def size\n @list.size\n end",
"def top_k_frequent_elements(list, k)\n res = []\n return res if list.empty?\n hash = {}\n list.each do |num|\n if hash[num]\n hash[num] += 1\n else\n hash[num] = 1\n end\n end\n \n k.times do \n max = nil\n hash.each do |num, v|\n if v && (max.nil? || v > max)\n max = num \n end\n end\n if max\n hash[max] = nil\n res << max\n end\n end\n \n return res\nend",
"def nub(xs)\n if(xs.length<=1)\n return xs\n\tend\n newList = []\n for x in xs\n if !newList.include? x \n newList.push(x)\n\t\tend\n\tend\n\treturn newList\nend",
"def given\n [6,5,3,1,8,7,2,3]\nend",
"def size\n result, list = 0, self\n until list.empty?\n if list.cached_size?\n return result + list.size\n else\n result += 1\n end\n list = list.tail\n end\n result\n end",
"def length\n array_list.length\n end",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n frequency = {}\n list.each do |i|\n frequency[i] ? (frequency[i] += 1) : (frequency[i] = 1)\n end\n\n nums = []\n unique = list.uniq\n max = frequency.values.max\n\n until max == 0 || nums.length == k\n unique.each do |i|\n break if nums.length == k\n if frequency[i] == max\n nums << i\n end\n end\n max -= 1\n end\n\n return nums\nend",
"def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end",
"def each_cons list, n\n list.each_cons(n).to_a\nend",
"def size\n @exact.size + @list.size\n end",
"def sub_sum(list)\n subs = []\n\n list.each_with_index do |el1, i|\n # debugger\n (0...list.length - i).each do |len|\n subs << list[i..i + len]\n end\n\n end\n\n subs.map! do |subset|\n subset.inject(:+)\n end\n\n subs.max\nend",
"def top_k_frequent_elements(list, k)\n return [] if list == []\n\n frequency = {}\n list.each do |element|\n if frequency[element]\n frequency[element] += 1\n else\n frequency[element] = 1\n end\n end\n\n k_frequent_elements = []\n\n k.times do |i|\n max_freq = 0\n max_freq_element = nil\n frequency.each do |element, freq|\n if freq > max_freq\n max_freq = freq\n max_freq_element = element\n end\n end\n k_frequent_elements << max_freq_element\n frequency[max_freq_element] = 0 if max_freq_element\n end\n\n return k_frequent_elements\nend",
"def largest_contiguous_subsum(list)\r\n sub_arr = []\r\n list.each_with_index do |ele1,idx1|\r\n list.each_with_index do |ele2,idx2|\r\n sub_arr<< list[idx1..idx2] if idx2>=idx1\r\n end\r\n end\r\n p sub_arr.size\r\n sub_arr.map{ |sub| sub.sum}.max\r\n #(O(n^2 + m)\r\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n counts_hash = {}\n\n list.each do |number|\n if !counts_hash[number]\n counts_hash[number] = 1 \n else\n counts_hash[number] = counts_hash[number] + 1\n end\n end\n\n length_to_num_hash = {}\n\n counts_hash.keys.each do |number|\n if !length_to_num_hash[counts_hash[number]]\n length_to_num_hash[counts_hash[number]] = []\n end\n length_to_num_hash[counts_hash[number]] << number\n end\n\n result_length = k\n result = []\n most_freq_num = length_to_num_hash.keys.max\n\n while result_length > 0 && most_freq_num != nil && most_freq_num >= 0\n if length_to_num_hash[most_freq_num]\n length_to_num_hash[most_freq_num].each do |num|\n result << num\n result_length -= 1\n break if result_length <= 0\n end\n end\n most_freq_num -= 1\n end\n\n return result\nend",
"def top_k_frequent_elements(list, k)\n # load a hash table which has elements & their frequency \n element_frequency = {}\n array = []\n return array if list.length == 0\n\n list.each do |val|\n if !(element_frequency[val])\n element_frequency[val] = 1\n else\n element_frequency[val] += 1\n end\n end\n\n values = element_frequency.values.sort!\n inverted_hash = element_frequency.invert\n \n k.times do |i|\n array << inverted_hash[values[i]]\n end\n\n return array \nend",
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def walker(list)\nidx = 1\n if list.length <= 2\n return list.flatten,list.length\n end\n walked = [list[0]]\n starting_list = list[1,list.length]\n starting_list.each do |el|\n if el == walked[-1] + 1\n walked.append(el)\n idx += 1\n else\n break\n end\n end\n if walked.length >= 3\n return \"#{walked[0]}-#{walked[-1]}\",idx\n else\n return walked.flatten,idx\n end\nend",
"def remove_duplicates(list)\n if list.length == 0\n return []\n end\n \n length = list.length\n i = 0\n j = 0\n while i < length-1\n if list[i] != list[i+1]\n list[j] = list[i]\n j += 1\n end\n i += 1\n end\n list[j] = list[length - 1]\n \n ((j+1)..(length-1)).each do |index|\n list.pop()\n end\n \n # list.each_with_index do |item,index|\n # if item == nil\n # list.delete_at(index)\n # end\n # end\n \n # list = list[0..j]\n return list\nend",
"def unique_sum(lst)\n return nil if lst.empty?\n\n staging_arr = []\n total = 0\n\n lst.each do |num|\n staging_arr << num unless staging_arr.include?(num)\n end\n\n staging_arr.each do |uniq_num|\n total += uniq_num\n end\n\n total\nend",
"def how_much_i_love_you(n)\nf = [\"I love you\",\n \"a little\",\n \"a lot\",\n \"passionately\",\n \"madly\",\n \"not at all\"]*n\nf[n-n+n-1]\nend",
"def f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend",
"def delete_over_nth(list,n)\n x = list[0]\n list.each do |item|\n if item == x\n return true\n else\n return false\n end\n p x\n end\n \nend",
"def top_k_frequent_elements(list, k)\n result_arr = []\n return result_arr if list.length == 0\n\n frequency_hash = {}\n\n list.each do |element|\n if frequency_hash[element]\n frequency_hash[element] += 1\n else\n frequency_hash[element] = 1\n end\n end\n\n k.times do\n top_element = nil\n top_frequency = 0 \n\n frequency_hash.each do |element, frequency|\n top_frequency = frequency && top_element = element if frequency > top_frequency\n end\n\n result_arr << top_element\n frequency_hash[top_element] = 0\n end\n\n return result_arr\nend",
"def takeList( list1, num )\n if ( num < 0 )\n list1\n elsif num <= list1.size\n list1[ 0 ... num ]\n else\n list1\n end\n end",
"def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend",
"def top_k_frequent_elements(list, k)\n return [] if list == []\n hash = Hash.new(0)\n counter = 0;\n list.each do |value|\n hash[value] = [] if hash[value].nil?\n hash[value]+=1\n end\n \n if k > hash.size()\n raise ArgumentError, \"Not Enough Values to Display\"\n end\n \n solution = hash.max(k){ |a, b| b<=>a} \n p solution\n numbers = []\n solution.each do |array|\n numbers << array[0]\n end\n return numbers\nend",
"def get(n)\n\t\ti = 0\n\t\taux = @head\n\t\twhile i < n do\n\t\t\taux = aux.next\n\t\ti += 1\n\t\tend\n\n\t\treturn aux\n\t\t\t\n\tend",
"def find_nth_from_end_list(n)\n return nil if (n < 0 || n > @length || !@head)\n\n current_node = @head\n i = 0\n\n while(current_node)\n if(i + n == @length)\n return current_node\n else\n i += 1\n current_node = current_node.next\n end\n end\n end",
"def nombre_handle(list)\n return list.size\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n hash = {}\n\n list.each do |element|\n if hash[element]\n hash[element] += 1\n else\n hash[element] = 1\n end\n end\n\n answer = []\n answer_length = 0\n\n highest_freq = hash.values.max\n\n while answer_length < k\n hash.each do |element, count|\n if count == highest_freq\n answer << element\n answer_length += 1\n end\n\n break if answer_length == k\n end\n\n highest_freq -= 1\n end\n\n return answer\nend",
"def largest(list)\n time = Time.now\n arr = []\n list.each_with_index do |el, i|\n list.each_with_index do |el2, i2|\n arr << list[i..i + i2]\n end\n end\n max = arr[0].sum\n arr.each do |el|\n max = el.sum if el.sum > max\n end\n puts Time.now - time\n max\nend",
"def max_span(list)\n count = 0\n list.sort\n a = list\n a.shift\n last_item = a.pop\n a\n list.each do |i|\n count = i + 1\n return count\n end\nend",
"def top_k_frequent_elements(list, k)\n result = []\n\n hash = Hash.new\n \n list.each do |letter|\n if hash[letter]\n hash[letter] += 1\n else \n hash[letter] = 1\n end \n end \n\n k.times do \n max = nil\n hash.each do |num, value|\n\n if value && (max.nil? || value > max)\n max = num \n end \n end \n\n if max \n hash[max] = nil \n result << max \n end \n end \n return result end",
"def take(n=@size)\n a = []\n n.times{a.push(pop)}\n a\n end",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n count_hash = Hash.new(0)\n result = []\n\n list.each do |element|\n count_hash[element] += 1\n end\n\n max_array = count_hash.sort_by { |k, v| -v }\n\n (0...k).each do |i|\n result << max_array[i][0]\n end\n\n return result\nend",
"def size\n @lists.length\n end",
"def unique (mylist)\n # Your code here\nend",
"def size\n node = @list\n size = 0\n while node != nil\n size += 1\n node = node.nextNode\n end\n size\n end",
"def largest_contiguous_subsum_1(list)\r\n subarrays = [] #1\r\n list.each_with_index do |ele1, i| #n\r\n list[i...list.length].each_with_index do |ele2,i2| #(n-1)\r\n subarrays << list[i..i2+i] #k \r\n end\r\n end # n^2\r\n subarrays.map { |subarray| subarray.sum}.max # n^x\r\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend",
"def find_number_of_lis(nums)\n return 0 if nums.empty?\n lengths = Array.new(nums.size, 1)\n counts = Array.new(nums.size, 1)\n\n for i in 1...nums.size\n for j in 0...i\n if nums[i] > nums[j]\n if lengths[j] + 1 == lengths[i]\n counts[i] += counts[j]\n elsif lengths[j] + 1 > lengths[i]\n counts[i] = counts[j]\n lengths[i] = lengths[j] + 1\n end\n end\n end\n end\n\n max_length = lengths.max\n result = 0\n \n counts.each_with_index do |count, i|\n result += count if lengths[i] == max_length\n end\n \n result\nend",
"def kth_to_last(linked_list, k)\n current_node = linked_list\n length = 0\n\n while current_node != null \n current_node = current_node.next\n length += 1\n end\n\n num = length - k\n current_node = linked_list\n num.each do |i| \n current_node = current_node.next\n end\n\n return current_node\nend"
] |
[
"0.6534956",
"0.63627845",
"0.6354613",
"0.6354613",
"0.6354613",
"0.6269643",
"0.62626785",
"0.6261166",
"0.61547714",
"0.60820186",
"0.6080095",
"0.6059509",
"0.60406107",
"0.6009159",
"0.5997664",
"0.59689486",
"0.5934405",
"0.592205",
"0.5921917",
"0.59205085",
"0.58714247",
"0.5864712",
"0.58631814",
"0.5844731",
"0.58423746",
"0.5839242",
"0.5837918",
"0.5837918",
"0.5837918",
"0.5837918",
"0.5815448",
"0.58132213",
"0.5799907",
"0.5778626",
"0.57757473",
"0.5757222",
"0.5734576",
"0.57342315",
"0.5721309",
"0.5720652",
"0.57173",
"0.5717279",
"0.5713789",
"0.57132375",
"0.570842",
"0.5707879",
"0.57074356",
"0.5704464",
"0.5696298",
"0.5696141",
"0.5683102",
"0.56811476",
"0.56775117",
"0.5674592",
"0.5672765",
"0.56710917",
"0.5667035",
"0.5663411",
"0.5655591",
"0.5655591",
"0.5646545",
"0.5636011",
"0.56296027",
"0.56279206",
"0.56260455",
"0.5625255",
"0.5624766",
"0.5618353",
"0.56181943",
"0.5614029",
"0.5606428",
"0.56012934",
"0.5590615",
"0.5584134",
"0.55828893",
"0.55815595",
"0.5580746",
"0.5577217",
"0.55701697",
"0.5566201",
"0.55568886",
"0.554922",
"0.55411017",
"0.55294776",
"0.5525947",
"0.55234575",
"0.5523023",
"0.55221504",
"0.55162835",
"0.5508964",
"0.55074626",
"0.5491523",
"0.54883623",
"0.5479305",
"0.547831",
"0.54780114",
"0.54720837",
"0.54665834",
"0.5465605",
"0.5465073",
"0.5460444"
] |
0.0
|
-1
|
Time complexity O(n) where n is the length of the list Space complexity O(1)
|
def get_last
return nil unless @head
current = @head
while current.next
current = current.next
end
return current.data
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def twist length\n # Compute the subset of the list\n sub = (0...length).map do |i|\n @list[(@position + i) % @list.size]\n end\n\n # Replace the subset with its reverse\n sub.reverse.each_with_index do |el, i|\n @list[(@position + i) % @list.size] = el\n end\n\n @position = (@position + length + @skip_size) % @list.size\n @skip_size += 1\n end",
"def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\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 my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend",
"def my_better_min(list)\n min = list[0] #1\n\n list.each_with_index do |ele_1, i| #n\n if ele_1 < min # 1 *n\n min = ele_1 #1 *n\n end\n end\n\n min #1\n # (i...list.length).each do |j|\n # if list[i] list[j]\nend",
"def sub_sum(list)\n array = []\n (0...list.length).each do |idx1|\n (idx1...list.length).each do |idx2|\n array << list[idx1..idx2] #O(n)\n end\n end \n array.map {|sub| sub.length > 1 ? sub.sum : sub.first}.max\nend",
"def max_in_list(list, n = 1)\n list.group_by { |v| v }.sort_by do |_, s|\n -s.length\n end.first(n).map(&:first)\nend",
"def uniques(list)\n fa = []\n \n list.map do |n|\n while !(fa.include?(n))\n fa.push(n)\n end\n end\n \n #puts fa\n return fa\nend",
"def OG_list1(list)\n if list.size % 2 == 1\n #odd length lists\n return list[list.size/2] \n else\n # even length lists\n (list[list.size/2] + list[list.size / 2 - 1]) / 2.0\n end\nend",
"def top_k_frequent_elements(list, k)\n results = []\n\n return list if list.length == k\n return results if list.length == 0 \n\n list = list.sort.uniq\n\n i = 0\n k.times do \n results << list[i]\n i += 1\n end \n return results\nend",
"def remove_duplicates(list)\n if list.length == 0\n return []\n end\n \n length = list.length\n i = 0\n j = 0\n while i < length-1\n if list[i] != list[i+1]\n list[j] = list[i]\n j += 1\n end\n i += 1\n end\n list[j] = list[length - 1]\n \n ((j+1)..(length-1)).each do |index|\n list.pop()\n end\n \n # list.each_with_index do |item,index|\n # if item == nil\n # list.delete_at(index)\n # end\n # end\n \n # list = list[0..j]\n return list\nend",
"def take list, n\n #first do this without take...\n #n > 0 ? list[0..(n-1)] : []\n list.take(n)\nend",
"def DistinctList(arr)\n\n return arr.size - arr.uniq.size\n \nend",
"def duplin(list, n)\n list.map { |i| [i] * n }.flatten\nend",
"def top_k_frequent_elements(list, k)\n element_occurrence = {}\n list.each do |element|\n if element_occurrence[element]\n element_occurrence[element] += 1\n else\n element_occurrence[element] = 1\n end\n end\n \n sorted_pairs = element_occurrence.sort_by {|key, value| -value }\n output = []\n k.times do |index|\n return output if sorted_pairs[index].nil?\n output << sorted_pairs[index].first\n end\n return output\nend",
"def unique_sum(lst)\n return nil if lst.empty?\n\n staging_arr = []\n total = 0\n\n lst.each do |num|\n staging_arr << num unless staging_arr.include?(num)\n end\n\n staging_arr.each do |uniq_num|\n total += uniq_num\n end\n\n total\nend",
"def my_min_2(list) # n\n min_value = list.first\n i = 0\n while i < list.length\n min_value = list[i] if list[i] < min_value\n i += 1\n end\n min_value\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n raise NotImplementedError, \"Method hasn't been implemented yet!\"\nend",
"def top_k_frequent_elements(list, k)\n counter_hash = {}\n list.each do |value|\n if counter_hash[value].nil?\n counter_hash[value] = 1\n else\n counter_hash[value] += 1\n end\n end \n \n values_sort = counter_hash.sort_by {|key, value| -value}\n k_values = values_sort.slice(0..(k-1))\n final_values = []\n k_values.each do |value|\n final_values << value[0]\n end\n \n return final_values\nend",
"def given\n [6,5,3,1,8,7,2,3]\nend",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def length_of_lis(nums)\n return 0 if nums.length < 1\n lis(nums, nums.length - 1)\nend",
"def remove_duplicates(list)\n if list.length < 2\n return list\n else\n i = 0\n list.each do |num|\n if num == list[(i+1)]\n list.delete_at(i)\n end\n i += 1\n end\n return list\n end\nend",
"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 largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend",
"def rearrangeLastN(l, n)\n return l if n == 0\n fast, slow = l, l\n n.times do\n if fast\n fast = fast.next\n end\n end\n return l unless fast\n while fast.next\n slow = slow.next\n fast = fast.next\n end\n\n result = slow.next\n slow.next = nil\n fast.next = l\n result\nend",
"def top_k_frequent_elements(list, k)\n return list if list.empty? || list.size == 2\n\n elements = []\n hash = {}\n\n list.each do |elem|\n if hash[elem]\n hash[elem] += 1\n else\n hash[elem] = 1\n end\n end\n\n k.times do\n max_key = hash.key(hash.values.max)\n elements << max_key\n hash.delete(max_key)\n end\n return elements\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty? \n # list tracking quantities\n total_ele = list.length # O(n) operation\n return list if total_ele == 1\n top_k = Array.new(total_ele + 1){[]} # plus one for better tracking\n count_hash = {}\n\n # get frequencies of each element, O(n)\n list.each do |e|\n count_hash[e] ||= 1\n count_hash[e] += 1\n end\n\n # use a non-nested O(n) operation to sort\n # frequencies in top_k\n count_hash.each do |k,v|\n top_k[v] << k\n end\n\n return_arr = []\n \n # sort array in order now\n until total_ele == 0\n if(!top_k[total_ele].empty?)\n return_arr += top_k[total_ele]\n end\n\n total_ele -= 1\n end\n\n return return_arr[0...k]\nend",
"def twos_difference(lst)\n lst.sort!\n\n result = []\n\n lst.each do |num|\n if lst.include?(num+2)\n result << [num, num +2]\n end\n end\n\n result\n\nend",
"def sub_sum(list)\n sub_arrs = []\n # byebug\n list.each_index do |i|\n list.each_index do |j|\n if j >= i\n sub_arrs << list[i..j]\n end\n end\n end\n size = []\n sub_arrs.each do |arr|\n size << arr.inject(&:+)\n end\n size.max\nend",
"def top_k_frequent_elements(list, k)\n return nil if !list\n # intialze an empty hash\n ## iterate throught the list\n #chechk if the key is in the hash,\n # if key is in the hash ++ value\n # otherwise add key and value as 1 since it's first occurance\n # now the key(uniqe) and value(how many time the int_value) happend is in the hash,\n # my_hash.sort_by { |_, value| value }.each { |key, value| puts key } (iterate throught the hash, (hash.each {|key, value|}) )\n # before pushing the key into the initalized array, check to see if the length is less than k\n # if\n hash = Hash.new\n list.each do |int_value|\n if hash.key?(int_value)\n hash[key] = +1\n else\n hash[key] = 1\n end\n end\n kth_frequent_elements = []\n counter = 0 \n pervisou_value = 0\n hash.sort_by { |k, v| -v }.each do |key, value|\n if counter < k\n kth_frequent_elements << key\n if pervisou_value != value\n pervisou_value = value\n counter += 1\n end\n # end\n # if kth_frequent_elements.length < k\n # kth_frequent_elements << key\n else\n break\n end\n end\n return kth_frequent_elements\nend",
"def remove_dupes list\n cur = list.head\n i = 0\n while cur != nil\n list.remove i\n if !contains(list, cur.node)\n list.insert cur.node, i\n i += 1\n end\n cur = cur.nxt\n end\n\n return list\nend",
"def unique (mylist)\n # Your code here\nend",
"def top_k_frequent_elements(list, k)\n if list.length == 0 \n return []\n end \n nums = {}\n list.each do |num|\n if !nums[num]\n nums[num] = 1\n else\n nums[num] += 1\n end\n end \n\n sorted = nums.sort_by {|k, v| -v}\n top_k = []\n k.times do |k|\n top_k << sorted[k][0]\n end \n return top_k\nend",
"def sumarr(list)\n list2=list.sort\n total = 0\n i=0\n while i<list2.length\n len=list2.length-i\n list2[0..len].each do |x|\n total+=x\n total2=total-x\n puts \"#{x} plus #{total2} equals #{total}\"\n i+=1\n end\n end\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n return list if list.length == 1\n\n element_count = Hash.new()\n\n list.each do |element|\n if element_count[element]\n element_count[element] += 1\n else\n element_count[element] = 1\n end\n end\n\n result = []\n\n k.times do |i|\n count = 0\n frequent_element = nil\n element_count.each do |element, frequency|\n if frequency > count\n count = frequency\n frequent_element = element\n end\n end\n result << frequent_element\n element_count[frequent_element] = 0 if frequent_element\n end\n\n return result\n\nend",
"def drop(list, n)\n result = []\n list.each_index do |i| \n if i % n != n - 1 \n result << list[i] \n end \n end\n result\nend",
"def nub(xs)\n if(xs.length<=1)\n return xs\n\tend\n newList = []\n for x in xs\n if !newList.include? x \n newList.push(x)\n\t\tend\n\tend\n\treturn newList\nend",
"def largest_contiguous_subsum_1(list) \n subs = [] #O(1)\n (0...list.length).each do |start_num| #O(n)\n (start_num...list.length).each do |end_num| #O(n)\n subs << list[start_num..end_num] #O(n)\n end\n end\n subs_sum = [] #O(1)\n subs.each do |sub| #O(n**2)\n sub_sum = 0 #O(1)\n sub.each {|s| sub_sum += s} #O(n)\n subs_sum << sub_sum #O(1)\n end\n subs_sum.inject do |acc,el| #O(n)\n if acc > el #O(1)\n acc #O(1)\n else\n el #O(1)\n end\n end\n end",
"def top_k_frequent_elements(list, k)\n res = []\n return res if list.empty?\n hash = {}\n list.each do |num|\n if hash[num]\n hash[num] += 1\n else\n hash[num] = 1\n end\n end\n \n k.times do \n max = nil\n hash.each do |num, v|\n if v && (max.nil? || v > max)\n max = num \n end\n end\n if max\n hash[max] = nil\n res << max\n end\n end\n \n return res\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n \n element_count = {}\n \n list.each do |element|\n if element_count[element].nil?\n element_count[element] = 1\n else\n element_count[element] += 1\n end\n end\n \n sorted_elements = element_count.sort_by(&:first)\n \n i = 0\n max_nums = []\n k.times do\n max_nums << sorted_elements[i][0]\n i += 1\n end\n \n return max_nums\nend",
"def solution(list)\n split_list = list.sort!.chunk_while { |n, m| n.next == m }\n split_list.map do |ary|\n if ary.length > 2\n \"#{ary.first}-#{ary.last}\"\n else\n ary.join(',')\n end\n end.join(',')\nend",
"def top_k_frequent_elements(list, k)\n h = {}\n solution = []\n return solution if list.nil? || list.empty? || !list.is_a?(Array)\n list.each do |element|\n if h.include?(element)\n h[element] += 1\n else\n h[element] = 1\n end\n end\n k.times do\n top = nil\n h.each do |element,value| \n if value && (top.nil? || value > top)\n top = element\n end\n end \n if top \n h[top] = nil\n solution << top\n end\n end \n return solution\nend",
"def count(list)\n list.length\nend",
"def remove_duplicates(list)\n length = list.length\n i = 0\n while i < length - 1\n if list[i] == list[i + 1]\n list.delete_at(i + 1)\n end \n i += 1\n end \n return list \nend",
"def my_min(list)\r\n list.inject { |min,ele| min < ele ? min : ele }\r\n \r\n # Time : O(n)\r\n # Space : O(1)\r\nend",
"def top_k_frequent_elements(list, k)\n # load a hash table which has elements & their frequency \n element_frequency = {}\n array = []\n return array if list.length == 0\n\n list.each do |val|\n if !(element_frequency[val])\n element_frequency[val] = 1\n else\n element_frequency[val] += 1\n end\n end\n\n values = element_frequency.values.sort!\n inverted_hash = element_frequency.invert\n \n k.times do |i|\n array << inverted_hash[values[i]]\n end\n\n return array \nend",
"def num_removed(list)\n full_list = (1..100).to_a\n missing_num = (full_list - list)[0]\nend",
"def sub_sum(list)\n subs = []\n\n list.each_with_index do |el1, i|\n # debugger\n (0...list.length - i).each do |len|\n subs << list[i..i + len]\n end\n\n end\n\n subs.map! do |subset|\n subset.inject(:+)\n end\n\n subs.max\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n frequency = {}\n list.each do |i|\n frequency[i] ? (frequency[i] += 1) : (frequency[i] = 1)\n end\n\n nums = []\n unique = list.uniq\n max = frequency.values.max\n\n until max == 0 || nums.length == k\n unique.each do |i|\n break if nums.length == k\n if frequency[i] == max\n nums << i\n end\n end\n max -= 1\n end\n\n return nums\nend",
"def numUnique2 list\n current_num = list[0]\n unique_numbers = [list[0]]\n\n list.each do |num|\n if num != current_num\n current_num = num\n unique_numbers << num\n end\n end\n return \"**#{unique_numbers.length}**\"\nend",
"def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend",
"def hufflepuff(list)\nend",
"def top_k_frequent_elements(list, k)\n result_arr = []\n return result_arr if list.length == 0\n\n frequency_hash = {}\n\n list.each do |element|\n if frequency_hash[element]\n frequency_hash[element] += 1\n else\n frequency_hash[element] = 1\n end\n end\n\n k.times do\n top_element = nil\n top_frequency = 0 \n\n frequency_hash.each do |element, frequency|\n top_frequency = frequency && top_element = element if frequency > top_frequency\n end\n\n result_arr << top_element\n frequency_hash[top_element] = 0\n end\n\n return result_arr\nend",
"def walker(list)\nidx = 1\n if list.length <= 2\n return list.flatten,list.length\n end\n walked = [list[0]]\n starting_list = list[1,list.length]\n starting_list.each do |el|\n if el == walked[-1] + 1\n walked.append(el)\n idx += 1\n else\n break\n end\n end\n if walked.length >= 3\n return \"#{walked[0]}-#{walked[-1]}\",idx\n else\n return walked.flatten,idx\n end\nend",
"def top_k_frequent_elements(list, k)\n return [] if list == []\n\n frequency = {}\n list.each do |element|\n if frequency[element]\n frequency[element] += 1\n else\n frequency[element] = 1\n end\n end\n\n k_frequent_elements = []\n\n k.times do |i|\n max_freq = 0\n max_freq_element = nil\n frequency.each do |element, freq|\n if freq > max_freq\n max_freq = freq\n max_freq_element = element\n end\n end\n k_frequent_elements << max_freq_element\n frequency[max_freq_element] = 0 if max_freq_element\n end\n\n return k_frequent_elements\nend",
"def delete_over_nth(list,n)\n x = list[0]\n list.each do |item|\n if item == x\n return true\n else\n return false\n end\n p x\n end\n \nend",
"def odd(list)\n count = 0\n odd_list = list.each_with_object([]) {|x, odd| odd.push(x) if count.odd? ; count += 1}\nend",
"def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend",
"def sort_it(list_, n)\n # Your code goes here\nend",
"def oddities(list)\n new_list = []\n list.each_index do |ind|\n new_list << list[ind] if (ind + 1).odd?\n end\n new_list\nend",
"def largest_contiguous_subsum(list)\r\n sub_arr = []\r\n list.each_with_index do |ele1,idx1|\r\n list.each_with_index do |ele2,idx2|\r\n sub_arr<< list[idx1..idx2] if idx2>=idx1\r\n end\r\n end\r\n p sub_arr.size\r\n sub_arr.map{ |sub| sub.sum}.max\r\n #(O(n^2 + m)\r\nend",
"def each_cons list, n\n list.each_cons(n).to_a\nend",
"def largest(list)\n time = Time.now\n arr = []\n list.each_with_index do |el, i|\n list.each_with_index do |el2, i2|\n arr << list[i..i + i2]\n end\n end\n max = arr[0].sum\n arr.each do |el|\n max = el.sum if el.sum > max\n end\n puts Time.now - time\n max\nend",
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def top_k_frequent_elements(list, k)\n result = []\n\n hash = Hash.new\n \n list.each do |letter|\n if hash[letter]\n hash[letter] += 1\n else \n hash[letter] = 1\n end \n end \n\n k.times do \n max = nil\n hash.each do |num, value|\n\n if value && (max.nil? || value > max)\n max = num \n end \n end \n\n if max \n hash[max] = nil \n result << max \n end \n end \n return result end",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n count_hash = Hash.new(0)\n result = []\n\n list.each do |element|\n count_hash[element] += 1\n end\n\n max_array = count_hash.sort_by { |k, v| -v }\n\n (0...k).each do |i|\n result << max_array[i][0]\n end\n\n return result\nend",
"def my_min_phase_2(list)\n min = list[0]\n (1...list.length).each do |i|\n min = list[i] if list[i] < min\n end\n min\nend",
"def element(n, list)\n list[n - 1]\n end",
"def top_k_frequent_elements(list, k)\n return [] if list == []\n hash = Hash.new(0)\n counter = 0;\n list.each do |value|\n hash[value] = [] if hash[value].nil?\n hash[value]+=1\n end\n \n if k > hash.size()\n raise ArgumentError, \"Not Enough Values to Display\"\n end\n \n solution = hash.max(k){ |a, b| b<=>a} \n p solution\n numbers = []\n solution.each do |array|\n numbers << array[0]\n end\n return numbers\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n hash = {}\n\n list.each do |element|\n if hash[element]\n hash[element] += 1\n else\n hash[element] = 1\n end\n end\n\n answer = []\n answer_length = 0\n\n highest_freq = hash.values.max\n\n while answer_length < k\n hash.each do |element, count|\n if count == highest_freq\n answer << element\n answer_length += 1\n end\n\n break if answer_length == k\n end\n\n highest_freq -= 1\n end\n\n return answer\nend",
"def sub_sum(list)\n result = []\n i = 0\n while i < list.length\n result << [list[i]]\n j = i + 1\n while j < list.length\n result << list[i..j]\n j += 1\n end\n i += 1\n end\n\n result.map! { |arr| arr.reduce(:+) }\n result.max\nend",
"def nth_element_from_end(head,n)\n return head unless head\n length_of_list = 0\n current_node = head\n while(current_node != nil)\n length_of_list += 1\n current_node = current_node.next\n end\n\n position_of_node = length_of_list - (n+1)\n return nil if position_of_node < 0\n current_node = head\n 0.upto(position_of_node) do \n if current_node != nil\n current_node = current_node.next\n end\n end\n return current_node.val\nend",
"def takeList( list1, num )\n if ( num < 0 )\n list1\n elsif num <= list1.size\n list1[ 0 ... num ]\n else\n list1\n end\n end",
"def largest_contiguous_subsum1(list)\n p Time.now\n sub_arrays = []\n list.each_index do |i|\n list.each_index do |j|\n next if j < i\n sub_arrays << list[i..j]\n end\n end\n sub_arrays.map{|numbers| numbers.inject(:+)}.max\n p Time.now\nend",
"def iterativeMap(list)\n list.each do |i|\n list[i-1] = list[i-1] * 2\n end\n return list\nend",
"def top_k_frequent_elements(list, k)\n hash = {}\n \n list.each do |value|\n if hash[value]\n hash[value] += 1\n else\n hash[value] = 1\n end\n end\n \n top_elements = Array.new(k)\n return top_elements = hash.sort_by{ |key, value| value } \nend",
"def sub_sum_2(list)\r\n largest_sum = list.first\r\n current_sum = list.first\r\n \r\n # one loop only\r\n # need to get all subarr\r\n i = 1\r\n while i < list.length #loop to create subarr\r\n if current_sum < 0\r\n current_sum = 0\r\n end \r\n current_sum += list[i]\r\n if current_sum > largest_sum\r\n largest_sum = current_sum\r\n end\r\n i += 1\r\n end\r\n largest_sum\r\n end",
"def sub_sum_1(list)\r\n subarr = []\r\n\r\n list.each_with_index do |ele1, idx1|\r\n list.each_with_index do |ele2, idx2|\r\n if idx2 >= idx1\r\n subarr << list[idx1..idx2]\r\n end\r\n end\r\n end\r\n subarr.map { |sub| sub.sum }.max\r\n\r\nend",
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def top_k_frequent_elements(list, k)\n k_freq = []\n return k_freq if list.empty?\n \n hash_map = Hash.new\n\n list.each do |element| \n hash_map[element] ? hash_map[element] += 1 : hash_map[element] = 1\n end\n \n vals = hash_map.values \n max_vals = vals.max(k) \n \n max_vals.each do |val| \n key = hash_map.key(val)\n k_freq << key\n hash_map.delete(key)\n end\n return k_freq\nend",
"def unique_sum(lst)\n lst.uniq.reduce(:+)\nend",
"def top_k_frequent_elements(list, k)\n \n return [] if list.empty?\n ranked_hash = {}\n ranked = []\n\n list.each do |element|\n if ranked_hash.has_key?(element)\n ranked_hash[element] += 1\n else\n ranked_hash[element] = 1\n end\n end\n\n sorted = ranked_hash.sort_by { | k, v | -v }\n\n k.times do \n max = sorted.shift\n ranked << max[0]\n k -= 1\n end\n\n return ranked \n\nend",
"def nthElementFromTheEnd(l, n)\n out, ln = [], l\n while ln do\n out.push ln.value\n ln = ln.next\n end\n return n > out.size ? -1 : out[out.size - n]\nend",
"def top_k_frequent_elements(list, k)\n return [] if list.empty?\n\n counts_hash = {}\n\n list.each do |number|\n if !counts_hash[number]\n counts_hash[number] = 1 \n else\n counts_hash[number] = counts_hash[number] + 1\n end\n end\n\n length_to_num_hash = {}\n\n counts_hash.keys.each do |number|\n if !length_to_num_hash[counts_hash[number]]\n length_to_num_hash[counts_hash[number]] = []\n end\n length_to_num_hash[counts_hash[number]] << number\n end\n\n result_length = k\n result = []\n most_freq_num = length_to_num_hash.keys.max\n\n while result_length > 0 && most_freq_num != nil && most_freq_num >= 0\n if length_to_num_hash[most_freq_num]\n length_to_num_hash[most_freq_num].each do |num|\n result << num\n result_length -= 1\n break if result_length <= 0\n end\n end\n most_freq_num -= 1\n end\n\n return result\nend",
"def combination(sorted, list)\n if list.size == 1\n puts sorted+list[0].to_s;\n else\n 0.upto(list.size - 1) do |i|\n dest = list.clone;\n n = dest.delete_at(i);\n combination(sorted + n.to_s, dest);\n end\n end\nend",
"def sub_sum_better(list)\n largest_sum = list.first\n\n #iterate over once.\n # as you iterate keep a tally of the sum.\n # indexing into an array is O(1)\n # [2, 3, -6, 7, -6, 7]\n\n sub_sum = 0\n list.each do |el|\n sub_sum += el\n largest_sum = sub_sum if sub_sum > largest_sum\n\n sub_sum = 0 if sub_sum < 0\n end\n\n largest_sum\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend",
"def permute(list)\n if (list.length <= 1)\n return [list]\n end\n permutations = []\n count = 1\n list.each do |item|\n sublist_permutations = permute(list - [item])\n sublist_permutations.each do |permutation|\n permutation.unshift(item)\n permutations << permutation\n #puts \"Permutations : #{permutations.join(', ')}\"\n #puts \"permutation lists: #{permutations.each {permutation.join(', ')}}\"\n end\n end\n return permutations\nend",
"def largest_contiguous_subsum(list)\n new_arr = []\n\n (0...list.length).each do |idx1| #O(n)\n (0...list.length).each do |idx2| #O(n)\n if idx2 >= idx1 #O(1)\n new_arr << list[idx1..idx2].sum #O(1)\n end \n end \n \n end \n \n return new_arr.max #O(n)\nend",
"def buy_fruit(list)\n new_list = []\n list.each { |arr| arr[1].times { new_list << arr[0] } }\n new_list\nend",
"def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend",
"def top_k_frequent_elements(list, k)\n # build hashmap\n num_hash = {}\n list.each do |num|\n if num_hash[num]\n num_hash[num] += 1\n else\n num_hash[num] = 1\n end\n end\n\n # convert hashmap to array\n array_num_hash = num_hash.to_a\n\n # sort by occurences\n sorted_array_num_hash = array_num_hash.sort_by {|num| -num[1]}\n\n # sorted elements only\n sorted_numbers = sorted_array_num_hash.map{|num| num[0]}\n\n # slice sorted array by k elements\n return sorted_numbers.slice(0, k)\nend",
"def largest_contiguous_subsum(list)\n # l = list.length # 1\n # result = [] # 1\n # hash = Hash.new(0) # 1\n\n # (0...l).each do |i1| # n\n # (0...l).each do |i2| # n\n # result << list[i1..i2] if i2 >= i1 # 1\n # end\n # end\n\n # result.each do |sub_arr| # n\n # hash[sub_arr] = sub_arr.sum # 1\n # end\n\n # sorted_by_val = hash.sort_by { |k, v| v } # n, \n # sorted_by_val[-1][1] # \nend",
"def unordered_list; end",
"def reverse!(list)\n list_copy = list.dup\n counter = list.size\n list.map! do |elem|\n counter -= 1\n list_copy[counter]\n end\nend"
] |
[
"0.6483076",
"0.6482063",
"0.6443559",
"0.63825905",
"0.6204356",
"0.6191089",
"0.61864936",
"0.6075261",
"0.60657686",
"0.6055977",
"0.60048425",
"0.5979811",
"0.59785426",
"0.5963864",
"0.5944869",
"0.59355223",
"0.5926216",
"0.5924984",
"0.5924171",
"0.5924171",
"0.5924171",
"0.5924171",
"0.592131",
"0.5916737",
"0.59117496",
"0.59117496",
"0.59117496",
"0.5906621",
"0.58961236",
"0.58597744",
"0.585471",
"0.58325917",
"0.5832451",
"0.58317304",
"0.58307636",
"0.5818605",
"0.5810757",
"0.58054435",
"0.57913834",
"0.57906914",
"0.5787317",
"0.57814693",
"0.57767487",
"0.57692146",
"0.57602483",
"0.5758578",
"0.5757879",
"0.57569575",
"0.5756709",
"0.57534313",
"0.5741299",
"0.5737758",
"0.5722611",
"0.57179433",
"0.5715716",
"0.57152104",
"0.5714776",
"0.5709514",
"0.5677289",
"0.5677142",
"0.5673699",
"0.5656903",
"0.564813",
"0.5645821",
"0.56422323",
"0.5640397",
"0.56343526",
"0.5628151",
"0.562442",
"0.56229246",
"0.5620289",
"0.5619942",
"0.561913",
"0.5616502",
"0.56160396",
"0.56073743",
"0.5606217",
"0.5604927",
"0.56047857",
"0.56022006",
"0.5598326",
"0.55911374",
"0.5588757",
"0.5585029",
"0.5580254",
"0.5573001",
"0.55690193",
"0.5565907",
"0.5564192",
"0.5563732",
"0.55631024",
"0.55559474",
"0.5555037",
"0.5548298",
"0.5548235",
"0.55445445",
"0.5543639",
"0.55429316",
"0.5542349",
"0.55384046",
"0.55335253"
] |
0.0
|
-1
|
Time complexity O(n) where n is the index Space complexity O(1)
|
def get_at_index(index)
return nil unless @head
current = @head
index.times do
return nil unless current.next
current = current.next
end
return current.data
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index(element); end",
"def slow_dance(tile, array)\n array.each_with_index do |el, i|\n return i if el == tile\n end\nend",
"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 magic_slow(arr)\n arr.each_with_index do |val, index|\n return index if val === index\n end\nend",
"def linear_search(n)\n\t(1..100).to_a.shuffle.each do |x|\n\t\tif x == n\n\t\t\tbreak\n\t\tend\n\tend\nend",
"def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend",
"def lazy_index(index)\n index -= @map.keys.select{|e| e < index}.size\n result = 0\n @deleted.each do |deleted_index|\n if deleted_index - result > index\n return result + index\n else\n index -= deleted_index - result\n result = deleted_index + 1\n end\n end\n result + index\n end",
"def magic_slow(arr)\n arr.each_with_index do |val, index|\n if val === index\n return index\n end\n end\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend",
"def find_missing(array, n)\n i = 0\n\n (1..n).each { |number| i = i ^ number }\n array.each { |number| i = i ^ number }\n\n i\nend",
"def slow_dance(tile, tiles_array)\n tiles_array.each_with_index do |direction, idx|\n return idx if direction == tile\n end\nend",
"def linear_search(array, n, x)\n answer_index = 'NOT-FOUND'\n array.each_with_index do |a, i|\n if a == x\n answer_index = i\n end\n end\n answer_index\nend",
"def element_times_index(nums)\n indexed_nums = []\n i = 0\n\n while i < nums.length\n num_indexed = nums[i] * i\n indexed_nums << num_indexed\n i += 1\n end\n\n return indexed_nums\nend",
"def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend",
"def map_then_iterate_two_sum(array, target)\n hash = {}\n array.each.with_index do |i, index|\n hash[i] = index\n end\n indexes = []\n array.each.with_index do |ii, index|\n complement = target - ii \n if hash.has_key?(complement) && hash.fetch(complement) != index\n indexes.push(index, hash.fetch(complement))\n return indexes\n end\n end\nend",
"def slow_dance(target_tile, tiles_array)\n tiles_array.each_with_index do |tile, index|\n return index if target_tile == tile\n end\n\n nil\nend",
"def slow_dance(direction, arr)\n arr.each_with_index do |el, i|\n return i if el == direction\n end\nend",
"def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend",
"def slow_dance(move, tiles_array)\n tiles_array.each_with_index {|tile, i| return i if tile == move}\nend",
"def two_sum nums\n # nums[index] : index\n map = {}\n\n nums.each_with_index do |n, i|\n if map[-n]\n return map[-n], i\n end\n map[n] = i\n end\n nil\nend",
"def two_sum(n, target)\n n.each_with_object({}).with_index do |(v,o),j|\n i = o[target - v]\n return [i,j] if i\n o[v] = j\n end\n raise \"Cannot Find Answer\"\nend",
"def element(n,k,row)\n return 1 if k == 0 or k==n\n previous_element = row[k-1] #we can\n return previous_element * (n+1-k)/k\nend",
"def solution(x,a)\n counter_hash = {}\n a.each_with_index do |value, index|\n counter_hash[value] = true\n return index if counter_hash.size == x\n end\n -1\nend",
"def slow_dance(direction, array)\n array.each_with_index do |tile, idx|\n return idx if tile == direction\n end\n\n nil\nend",
"def index(p0) end",
"def index(p0) end",
"def solution(a)\n a.each do |element|\n return element if a.index(element) == a.rindex(element)\n end\nend",
"def slow_dance(direction, array)\n array.each_with_index do |tile, idx|\n return idx if tile == direction\n end\nend",
"def solution(n, a)\n # write your code in Ruby 2.2\n arr = [0] * n\n max_c = 0\n \n a.each_with_index do |value,index|\n if value == n + 1\n arr = [max_c] * n\n else\n arr[value - 1] = arr[value - 1] + 1\n max_c = (arr[value -1] > max_c ? arr[value -1] : max_c)\n end\n end\n arr\nend",
"def pick(n,history)\n i = -1\n j = 0\n while j < (n + 1)\n i += 1\n j += 1 if history[i] == nil\n \n end\n \n return i\nend",
"def get_new_idx(i, n)\n # I use the number 4 here but it correlates to the number of series.\n # For example, I only have \"a\", \"b\", \"c\", and \"d\" series so I use 4.\n (i % 4) * n + (i / 4)\nend",
"def solution(a)\n left = 0\n right = a.sum\n a.each_with_index do |element, index|\n right -= element\n return index if left == right\n left += element\n end\n -1\nend",
"def slow_dance(target, tiles_array)\n tiles_array.each_with_index do |tile, idx|\n return idx if tile == target\n end\nend",
"def slow_dance(step, array)\n index = 0\n array.each_with_index do |el, i|\n index = i if el == step\n end\n index\nend",
"def element_times_index(nums)\n nums.map.with_index{|num, idx| num * idx}\nend",
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def find_1(arr, k)\n l = arr.length\n result = []\n arr.each_index do |i|\n (i+1).upto(l-1) do |j|\n result << [arr[i], arr[j]] if (arr[i] + arr[j]) == k\n end\n end\n result\nend",
"def at(index); end",
"def slow_dance(dir, arr)\n arr.each_with_index do |tile, index|\n return index if tile == dir\n end\nend",
"def find_pair(array,sum)\n indices = []\n hash = Hash.new\n array.each_with_index do |element,i|\n if hash[sum - element] != nil then\n indices.push(\"#{hash[sum - element]},#{i}\")\n end\n hash[element] = i\n end\n indices\nend",
"def two_sum(nums, target)\n # i,j = 0, nums.length-1\n i = 0\n j = nums.length-1\n output = []\n while i < nums.length-1\n while j > i\n if nums[i] + nums[j] == target\n output << i << j\n end\n j-=1\n end\n i+=1\nend\nreturn output #returning index\nend",
"def index(key, size)\n i = key.sum % size \n end",
"def find_even_index(arr)\n i = 0\n a = 0\n b = 1\n for i in 0...arr.length\n a = arr.slice(0, i).sum\n b = arr.slice(i + 1, arr.length - 1).sum\n if a != b && i == arr.length - 1\n return -1\n elsif a != b\n i += 1\n else\n return i\n end\n end\nend",
"def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend",
"def slow_dance(move, arr)\n arr.each_with_index do |dir, idx|\n return idx if move == dir\n end\nend",
"def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend",
"def linear_search(sorted_array, desired_item)\n index = 0\n sorted_array.length.times do \n if desired_item == sorted_array[index]\n break \n else \n index += 1\n end\n if index > sorted_array.length - 1\n index = nil \n end\n end\n return index \nend",
"def element_times_index(arr)\n result = []\n i = 0\n while i < arr.length\n result << arr[i] * i\n i+= 1\n end\n return result\nend",
"def index(key, size)\n return key.sum%size\n end",
"def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend",
"def findIndex(a, x)\n\tn = a.length\n\ti = n - 1\n\tj = 0\n\twhile a[i][j] != x do\n\t\tif a[i][j + 1] <= x then\n\t\t\tj += 1\n\t\telse\n\t\t\ti -= 1\n\t\tend\n\tend\n\treturn i, j\nend",
"def select_every_n(arr, n=1)\n arr.each_index.select {|index| index%n==0}.map{|index| index=arr[index]}\nend",
"def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend",
"def index(key, size)\n # Look into this. Same as previous ???\n # Review the base of tens to get a better understanding.\n return key.sum % size\n end",
"def pairs_given_sum num, arr\n the_hash, indices = Hash.new, []\n arr.each_with_index do |x,xi|\n complement = num - x\n lookup = the_hash[complement]\n lookup.nil? ? the_hash[x] = xi : indices << [lookup, xi]\n # puts the_hash\n end\n indices\nend",
"def indexTest(data,i)\n if data.is_a?(Array) and i<data.length and i>=-1*data.length\n return data[i]\n elsif data.is_a?(Hash) and data.keys.include? i\n return data[i]\n else\n return 0\n end\nend",
"def slow_dance(direction, tiles_array)\n tiles_array.each.with_index do |move, i|\n return i if move == direction\n end\nend",
"def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend",
"def array_sum_with_index(arr)\n sum = 0\n arr.each_with_index {|n, i| sum += n*i}\n sum\nend",
"def [](index)\n i = 0\n each { |x| return x if i == index; i += 1 }\n nil # out of index\n end",
"def boustrophedon_at(k,n)\n raise ArgumentError.new \"k must be < size\" unless k < size\n raise ArgumentError.new \"n must be < size\" unless n < size\n return 0 if n < 0 || k < n\n @b_cache ||= []\n @b_cache[k] ||= []\n\n @b_cache[k][n] ||= if k==0\n self[k]\n else\n boustrophedon_at(k,n-1) + boustrophedon_at(k-1,k-n)\n end\n end",
"def solution(a)\n candidate = a[0]\n count = 0\n index = 0\n a.each_with_index do |d, idx|\n count = candidate == d ? count += 1 : count -= 1\n if count == 0\n candidate = d\n count = 1\n index = idx\n end\n end\n a.count { |d| d == candidate } * 2 > a.length ? index : -1\nend",
"def find_even_index(array)\n array.size.times do |i|\n left_array = array[0...i]\n right_array = array[(i+1)..-1]\n return i if left_array.sum == right_array.sum\n end\n -1\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 two_sum(nums, target)\n\n numsSearch = {}\n nums.each_with_index do |value, index|\n ### Storing the value as index of hash\n second_value = numsSearch[target - value]\n\n ### checking if hash return value\n if second_value != nil\n return [second_value, index]\n end\n\n ### inserting the value as index and index as value in hash map\n numsSearch[value] = index\n end\n\n return []\nend",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend",
"def two_sum(integers, target)\n # O(n)\n integers_with_index = integers.each_with_index.to_a\n # O(n*log(n))\n integers_with_index = integers_with_index.sort_by { |(n, _)| n }\n\n front, back = 0, integers_with_index.count - 1\n\n until front == back\n sum = integers_with_index[front][0] + integers_with_index[back][0]\n if sum == target\n return [integers_with_index[front][1], integers_with_index[back][1]].sort\n elsif sum > target\n back -= 1\n else\n front += 1\n end\n end\nend",
"def array_sum_by_index(arr)\n\nend",
"def odd_indexed_integers(array)\n\nend",
"def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |string_tile, i|\n return i if direction == string_tile\n end\nend",
"def index_for_insert(element, arr)\n arr.each_with_index { |num,i| if element <= num then return i end}\n -1\nend",
"def slow_dance(direction, array)\n array.each_with_index do |el, idx|\n return idx if el == direction\n end\nend",
"def two_sum(numbers, target)\n n_index = {} \n (0...numbers.length).each do |i1|\n i2 = n_index[target - numbers[i1]]\n return [i1 + 1, i2 + 1].sort if i2 && i2 != i1 \n n_index[numbers[i1]] = i1\n end\nend",
"def index(key, size)\n return key.sum % size \n end",
"def answer(n, a)\n count = 0\n n.times do |nn|\n next if a[nn] != nn + 1\n a[nn], a[nn + 1] = a[nn + 1], a[nn]\n count += 1\n end\n count\nend",
"def find_even_index(arr)\n left_sum = 0\n right_sum = arr.sum\n arr.each_with_index do |e, ind|\n right_sum -= e\n\n return ind if left_sum == right_sum\n\n left_sum += e\n end\n\n -1\nend",
"def element_times_index(numbers)\n i = 0\n count = 0\n while i < numbers.length\n numbers[i] = numbers[i] * count\n count += 1\n i += 1\n end\n return numbers\nend",
"def index(key, size)\n code = key.sum\n return code % size\n end",
"def at(n)\n return nil if n >= count\n first(n+1).pop\n end",
"def pick_these(arr, i, j)\n\nend",
"def oddities(arr)\n # Same problem here. arr.index returns the index of the first element with that value. Do not use!\n arr.select.with_index do |elem, index|\n index % 2 == 0\n end\nend",
"def bisect\n n = self.size\n l = n / 2\n [self[0...l], self[l...n]]\n end",
"def delete_nth(arr, n)\n results = []\n arr.each do |current_num|\n times_it_appears_in_results = results.count(current_num)\n results << current_num if times_it_appears_in_results < n\n end\n results\nend",
"def array_sum_with_index(arr)\n acc = 0\n arr.each_with_index {|int, id| acc += (int * id)}\n acc\nend",
"def find_all arr, n\n answer = []\n (0..arr.length - 1).each do |i|\n if arr[i] == n\n answer << i\n end\n end\n answer\nend",
"def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |tile, idx|\n return idx if tile == direction\n end\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def oddities(array)\nselected_index = []\nindex = 0\n\n\tloop do \n\tcurrent_array = array[index]\n\t\tif index.even?\n\t\t\tselected_index << current_array\n\t\tend\n\tindex += 1\n\tbreak if index == array.size\n\tend\nselected_index\n\nend",
"def slow_dance(dir, array)\n array.each.with_index do |el, idx|\n return idx if dir == el\n end\nend",
"def fast_dance(tile_direction, new_tiles_data_structure)\n new_tiles_data_structure.each do |ele|\n return new_tiles_data_structure.index(ele) if ele == tile_direction\n end\nend",
"def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend",
"def kthIndex(k)\n if(@indexList[k] < 0) then\n return @base.size + 1 + @indexList[k] + k ;\n else\n return @indexList[k] + k ;\n end\n end",
"def sum_of_n(n)\n # your code here\n # result = []\n # if n >= 0\n # ary = (0..n).to_a\n # else\n # ary = (n..0).to_a.reverse\n # end\n # ary.each_with_index do |_numb, index|\n # somme = 0\n # result << somme += ary[0..index].sum + somme\n # end\n # result\n sum = 0\n (n.negative? ? 0.downto(n) : 0.upto(n)).map do |number|\n sum += number\n end\nend",
"def fibonacci_index(array)\n fibonacci_sequence = create_fibonacci(array.size)\n new_array = array.select { |num| fibonacci_sequence.include?(array.index(num)) }\nend",
"def nth_prime(n)\n nums = (0..10000).to_a\n result = []\n\n nums.each do |i| \n if prime?(i) == true\n result.push(i)\n end\n end\n\n\n return result[n]\nend",
"def element_times_index(numbers)\n\tfor i in 0..numbers.length-1\n numbers[i] *= i\n end\n return numbers\nend",
"def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |tile, index|\n return index if tile == direction\n end\nend",
"def two_sum_indices(arr, target_sum)\n complements = {}\n arr.each_with_index do |el, i|\n complement, j = complements[target_sum - el] # these will both be nil if the complement doesn't exist\n return [i, j] if complement\n \n complements[el] = [el, i]\n end\n nil\nend",
"def final(arr,key)\n\tright = arr.length-1\n\tleft = 0\n\n\tresult = Array.new(2)\n\tresult[0] = -1\n\tresult[1] = -1\n\n\tsearch_range(arr,key,right,left,result)\n\tp result\nend",
"def two_sum_hash(numbers, target)\n n_index = {} \n (0...numbers.length).each do |i2|\n i1 = n_index[target - numbers[i2]] \n\n # We know that n[i2] > n[i1] because input array is sorted.\n return [i1 + 1, i2 + 1] if i1 && i1 != i2\n n_index[numbers[i2]] = i2\n end\nend"
] |
[
"0.64947075",
"0.6469912",
"0.63268155",
"0.63093156",
"0.6266377",
"0.6220291",
"0.6213645",
"0.6201271",
"0.619608",
"0.61645323",
"0.6153693",
"0.61362296",
"0.60819685",
"0.60739404",
"0.6073693",
"0.6065342",
"0.6031495",
"0.6013581",
"0.59994996",
"0.5984989",
"0.59823716",
"0.596447",
"0.59640336",
"0.5961732",
"0.5951015",
"0.5951015",
"0.5948752",
"0.5946508",
"0.59418094",
"0.594043",
"0.59364396",
"0.5933762",
"0.59331477",
"0.5928636",
"0.59276515",
"0.59181476",
"0.5917647",
"0.5915027",
"0.5912343",
"0.59067",
"0.5904873",
"0.5897372",
"0.5896102",
"0.5890652",
"0.5880443",
"0.5877559",
"0.586902",
"0.5860138",
"0.584373",
"0.5842961",
"0.58390206",
"0.5837824",
"0.5832817",
"0.58274424",
"0.58188146",
"0.58174306",
"0.5814747",
"0.580721",
"0.580529",
"0.58020175",
"0.57910675",
"0.5786272",
"0.5784308",
"0.5778812",
"0.57768184",
"0.5773282",
"0.5766718",
"0.5762662",
"0.5758906",
"0.5757485",
"0.57545096",
"0.5747977",
"0.57478386",
"0.5743188",
"0.57413995",
"0.57328385",
"0.57321423",
"0.5731371",
"0.5731144",
"0.5728826",
"0.572723",
"0.57260084",
"0.5724539",
"0.5721616",
"0.5720973",
"0.5715612",
"0.57153636",
"0.57147825",
"0.5708942",
"0.5706659",
"0.5706029",
"0.570293",
"0.57022333",
"0.5701518",
"0.5701413",
"0.5698328",
"0.5693831",
"0.568989",
"0.56884956",
"0.56824493",
"0.5680933"
] |
0.0
|
-1
|
Creamos una lista e inicializamos los valores
|
def initialize (head, tail)
@head = head
@tail = tail
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_listas\n #@locais = Local.all.map{|l| [l.nome,l.id]}\n @locais = Local.all\n @periodos = ['Manhã','Tarde','Noite']\n @publicos = ['Infantil','Adulto']\n end",
"def initialize\n @lista_contas = []\n end",
"def init_value_list \n unless @value_list.nil?\n @value_list = manager_send(:GetValueListItems, self)\n end\n end",
"def create_list\n list = {} \nend",
"def initialize_list\n Array(value.value).each_with_index do |val, index|\n ordered_list.insert_proxy_for_at(index, calling_mapper.for(Property.new(value.subject, :member_id, val, value.adapter, value.resource)).result.value)\n end\n end",
"def initialize(list)\n @list = list\n end",
"def initialize(list)\n @list = list\n end",
"def initialize()\n\t@list_arr\t= []\nend",
"def initialize\n @list = {}\n end",
"def initialize\n @lists = []\n bootstrap\n populate\n end",
"def initialize\n self.list = []\n end",
"def initialize\n @list = {}\n end",
"def create_list\n\t{}\nend",
"def set_list_form\n @states = [{\"name\":\"DISPONIBLE\"},{\"name\":\"OBSOLETO\"}]\n @hometowns = [{\"name\":\"PRODUCCION\"},{\"name\":\"SEGREGADO\"},{\"name\":\"INVENTARIO\"},{\"name\":\"DEVOLUCIONES\"},{\"name\":\"OTROS\"}]\n @dispositions = [{\"name\":\"SOBRANTES\"},{\"name\":\"MOLINO\"}]\n end",
"def set_lists \n if cookies[:list].blank?\n @lists=[]\n else\n cookies[:list][0]=\"\"\n lasts=cookies[:list].split(',').last(5)\n @lists=List.find(lasts)\n end\n end",
"def initialize\n @listOfItem = Array.new\n end",
"def initialize data\n @listOfItem = data\n end",
"def list=(value)\n @list = value\n end",
"def make_new_list\n list = {}\nend",
"def initialize \n @rechnungen = []\n end",
"def initialize list\n\t\traise \"La lista #{list} no puede ser vacía.\" if list.empty?\n\n\t\tself.list = list.uniq\n\t\tself.list.each do |m|\n\t\t\tif m != :Rock and m != :Paper and m != :Scissors\n\t\t\t\traise \"Los elementos de la lista #{list} deben ser \"\\\n\t\t\t\t\"':Rock', ':Paper' o ':Scissors'.\"\n\t\t\tend\n\t\tend\n\t\tself.gen = Random.new(SEED)\n\tend",
"def initialize(base_list)\n @list = base_list\n end",
"def populate_list(list)\n list.clear\n events = $script.to_s.split(\"&&&\")\n list.insert_items(events, 0)\n end",
"def set_list(list)\n @item_list = list\n end",
"def set_default_lists(list, lists)\n # Combines :list and :lists parameters into one array\n @icontact_default_lists = []\n @icontact_default_lists << list if list\n @icontact_default_lists += lists if lists\n end",
"def initialize\n @exact = []\n @list = []\n end",
"def get_list_data\n\t\tlist_data = Array.new\n\t\tlist = get_list\n\t\tlist.each do |item|\n\t\t\tvoc = Voc.find(item)\n\t\t\tvoc.wylie = Functions.disparse_a(voc.wylie)\t\n\t\t\tlist_data.push( voc )\n\t\tend\n\t\treturn list_data\n\tend",
"def set_lista\n @lista = Lista.find(params[:id])\n end",
"def set_lists\n\t\t\t@lists = @intranet.lists\n\t\tend",
"def list\n @list ||= []\n end",
"def initialize\n @rechnungen = []\n end",
"def initialize\n @rechnungen = []\n end",
"def initialize\n @items_list = []\n end",
"def initialize(nombre, platos)\n\t\t@nombre = nombre\n\t\t@platos = List.new\n\t\tfor plato in platos do\n\t\t\t@platos << plato\n\t\tend\n\tend",
"def set_lista_valor\n @lista_valor = ListaValor.find(params[:id])\n end",
"def list alist=nil\n return @list if alist.nil?\n #@list = Canis::ListDataModel.new(alist)\n @list = alist\n end",
"def limpar!\n @produtos = []\n end",
"def initialize\n self.list = []\n self.refresh\n end",
"def set_values(*items)\r\n items = *items\r\n @value = [nil]\r\n items.each do |item|\r\n @value.push(item)\r\n end\r\n end",
"def new_list\n list = {}\n return list\nend",
"def initialize(nome, comentario)\n @nome = nome\n @comentario = comentario\n @estrelando = []\n end",
"def list\n @list ||= []\n end",
"def list\n @list ||= []\n end",
"def initialize\n @ville = [] # Je vais me servir de ces array car ce sera bien plus simple pour la sauvegarde\n @email = [] \n end",
"def initialize attributes = {}\n @nombre = attributes[:nombre]\n @nit = attributes[:nit]\n @empleados = []\n @clientes = []\n end",
"def init; @entries = [] end",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def list; end",
"def list; end",
"def list; end",
"def list; end",
"def list; end",
"def initialize\n self.daily = Array.new\n self.incluidos=Array.new\n self.ingresados=Array.new\n\n end",
"def initialize (nombre, lista_alimentos, lista_cantidades)\n\t\t@nombre = nombre\n\t\t@lista_alimentos = lista_alimentos\n\t\t@lista_cantidades = lista_cantidades\n\tend",
"def make_item_list\n @data = equips_for_enchant\n end",
"def set_value_list\n @value_list = ValueList.find(params[:id])\n end",
"def get_list(objs)\n new_list = []\n if objs and defined? Rho::RhoConfig::sources[self.name.to_s]\n attrib_length = Rho::RhoConfig::sources[self.name.to_s]['attribs'].length\n list_length = 0\n list_length = (objs.length / attrib_length) unless attrib_length == 0\n new_obj = nil\n # iterate over the array and determine object\n # structure based on attribute/value pairs\n list_length.times do |i|\n new_obj = get_new_obj(objs[i*attrib_length])\n attrib_length.times do |j|\n # setup index and assign accessors\n idx = i*attrib_length+j\n begin\n # only update attributes if they belong\n # to the current object\n if objs[idx]['object'] == strip_braces((new_obj.send 'object'.to_sym))\n attrib = objs[idx]['attrib'].to_s\n value = objs[idx]['value'].to_s\n new_obj.send attrib.to_sym, value\n end\n rescue\n puts \"failed to reference objs[#{idx}]...\"\n end\n end\n new_list << new_obj\n end\n else\n # source attributes are not initialized, \n # try again\n RhomObjectFactory::init_sources\n end\n new_list\n end",
"def initialize(nome = \"Sem nome\")\r\n @nome = nome\r\n @livros = []\r\n end",
"def incluir_inicial\n ['casoid', 'fecha', 'ubicaciones', 'presponsables',\n 'tipificacion', 'victimas', 'memo']\n end",
"def initialize(nombre,lista,listagr)\n super(nombre,lista,listagr)\n @gei = 0\n\t\t@terreno = 0\n end",
"def populate\n storage = MultiJson.decode(collection.find_one['boom']) || []\n \n storage['lists'].each do |lists|\n lists.each do |list_name, items|\n @lists << list = List.new(list_name)\n\n items.each do |item|\n item.each do |name,value|\n list.add_item(Item.new(name,value))\n end\n end\n end\n end \n end",
"def initialize\n super()\n @i_keys = List.new()\n @i_values = List.new()\n end",
"def list alist=nil\n return @list if alist.nil?\n @list = RubyCurses::ListDataModel.new(alist)\n end",
"def initialize(list_title)\n @title = list_title\n @items = Array.new\n end",
"def db_listing\n lista = [] \n achado = $db.query \"SELECT * FROM produtos\" \n achado.each do |vals| \n lista.push vals\n end\n return lista\nend",
"def initialize(new_array)\n\t\t@list = new_array\n\tend",
"def set_list\n @list = List.find(params[:id])\n end",
"def data=(list)\n #puts \"got data: #{list.size} \" if !$log\n #puts list if !$log\n @list = list\n end",
"def data=(list)\n #puts \"got data: #{list.size} \" if !$log\n #puts list if !$log\n @list = list\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def create_list(list = {})\n list\nend",
"def initialize(values = [])\n @count = 0\n build_list_from_array(values)\n end",
"def instanciar_marcas_detalles(params)\n @marca_ids ||= []\n params[:marcas].keys.sort.each do |k|\n # Array de marcas que mejora la velocidad para el listado\n self.consulta_detalles.build(\n :marca_id => params[:marcas][k]#,\n #:tipo => params[:tipos][k]\n )\n end\n end",
"def init_lists(hash)\n self.methods = nil\n self.names = List.new\n self.types = List.new\n raise \"No type Type in #{hash}\" unless hash[:type]\n private_add_instance_variable(:type , hash[:type]) #first\n hash.each do |name , type|\n private_add_instance_variable(name , type) unless name == :type\n end\n end",
"def populate( list )\n\t\t\t@iconlist.clearItems\n\t\t\t\n\t\t\tgetApp().handler.each([]) do |item|\n\t\t\t\t\n\t\t\t\tcolor = \"\"\n\t\t\t\tcolor = getApp.options.gui[\"colors\"][ item.data.severity ] if getApp.options.gui and getApp.options.gui[\"colors\"] and item.data.severity\n\t\t\t\ti = ColorizedIconItem.new( \"[#{item.idstring}] #{item.data.name}\\t#{item.data.severity}\\t#{item.data.status}\\t#{item.data.created}\\t#{item.data.updated}\\t#{item.data.created_by}\\t#{item.data.vote}\", nil, nil, color,item )\n\t\t\t\t@iconlist << i\n\t\t\tend\n\t\tend",
"def list(*) end",
"def load_item_list\n @item_quantity = []\n get_list_item\n get_definitive_list_price\n check_if_shop_empty\n @index = 0\n @last_index = @list_item.size - 1\n end",
"def word_list=(list)\n end"
] |
[
"0.7043068",
"0.67493373",
"0.6499564",
"0.6489405",
"0.6418114",
"0.63373804",
"0.6271528",
"0.62527937",
"0.6196765",
"0.6179144",
"0.6167553",
"0.6158723",
"0.61073613",
"0.61045855",
"0.6083225",
"0.60636425",
"0.60548544",
"0.605378",
"0.60305357",
"0.60293376",
"0.6003694",
"0.599232",
"0.5959914",
"0.5952619",
"0.59334797",
"0.59169626",
"0.5902454",
"0.5897919",
"0.5892587",
"0.5889725",
"0.5875224",
"0.5875224",
"0.58727545",
"0.58552766",
"0.5805753",
"0.5798653",
"0.5793721",
"0.5789936",
"0.57821107",
"0.57716185",
"0.5770269",
"0.5748502",
"0.5748502",
"0.5722419",
"0.57200545",
"0.57164705",
"0.5715578",
"0.5715578",
"0.5715578",
"0.5699187",
"0.5699187",
"0.5699187",
"0.5699187",
"0.5699187",
"0.568809",
"0.5686937",
"0.56594235",
"0.5658397",
"0.5649813",
"0.5644774",
"0.561035",
"0.5605628",
"0.5602503",
"0.5601419",
"0.55792636",
"0.55779624",
"0.5568379",
"0.5564639",
"0.556181",
"0.55583405",
"0.55583405",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.5546858",
"0.55458015",
"0.5538648",
"0.552098",
"0.55203336",
"0.5513172",
"0.55062014",
"0.55016303",
"0.5492171"
] |
0.0
|
-1
|
Metodo insertar nodo por cola
|
def insertar_por_cola(value)
nodo=Node.new(value,nil,nil)
if(@tail==nil)
@tail=nodo
@head=nodo
else
nodo.prev=@tail
@tail.nest=nodo
@tail=nodo
nodo.nest=nil
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def insert(nodo, pos)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la posicion la debe indicar un entero\" unless ( pos.instance_of? Integer)\n raise \"Error posicion inadecuada\" unless ( pos <= @nodos )\n if pos == 0\n insert_head(nodo)\n elsif pos == @nodos\n insert_tail(nodo)\n else\n i = 1\n a = @head\n while i != pos\n i = i+1\n a = a.next\n end\n b = a.next\n nodo.prev = a\n nodo.next = b\n a.next = nodo\n b.prev = nodo\n @nodos = @nodos +1\n nodo\n end\n end",
"def insertar_elemento(nodo)\n \n @nodo = Nodo_.new(nil, nodo, nil)\n \n if @tail == nil\n @head = @nodo\n @tail = @nodo\n #@nodo\n else\n @nodo.next = @head\n @head.prev = @nodo\n @head = @nodo\n #@nodo\n end\n \n end",
"def insert()\n\n end",
"def insertar(x)\n nodo = Nodo.new(x, nil, nil) \n if @head == nil && @tail==nil\n nodo.next=@head\n nodo.prev=@tail\n @head=nodo\n @tail=nodo\n else\n nodo.prev=@head\n nodo.next=nil\n @head.next=nodo\n @head=nodo\n end\n \n end",
"def insert(etiqueta)\n nodo = Node.new(etiqueta, nil, nil)\n\n if self.empty\n nodo.next=nodo\n nodo.prev=nodo\n @head=nodo\n @tail=nodo\n\n else\n nodo.prev = @tail\n nodo.next = nil\n @tail.next = nodo\n @tail = nodo\n end\n end",
"def insert(clave, valor)\r\n @grafo[clave] = valor\r\n end",
"def insertar_elemento(nodo)\n \n if @elemento != nil\n \n nodo.next = @elemento\n @elemento = nodo\n end\n end",
"def insert token, tipo, variable = true\n\n\t\tif variable \n\t\t\tif @tabla.has_key? (token.texto)\n\t\t\t\traise RedefinirError.new(token, self.find(token.texto)[:token], variable)\n\t\t\telse\n\t\t\t\t@tabla[token.texto] = {:token => token, :tipo => tipo, :valor => nil}\n\t\t\tend\n\t\telse\n\t\t\tif @tabla.has_key? (token.idFuncion.nombre.texto)\n\t\t\t\traise RedefinirError.new(token.idFuncion.nombre, self.find(token.idFuncion.nombre.texto)[:instancia].idFuncion.nombre, variable)\t\n\t\t\telse\n\t\t\t\t@tabla[token.idFuncion.nombre.texto] = {:instancia => token, :tipo => tipo}\n\t\t\tend\n\t\tend\t\n\tend",
"def insertar_varios(nodos)\n \n nodos.each do |nodoo|\n \n insertar(nodoo)\n \n end\n \n end",
"def insertar (id_usu_den,id_tip_doc,num_doc_den,fec_exp_doc_den,fec_nac_den,pri_nom_den,seg_nom_den,pri_ape_den,seg_ape_den,tel_den,dir_den,push_den,ema_den)\n \tputs \"insertar: \"\n \tprint \"INSERT INTO public.denunciante(\n id_usu_den, id_tip_doc, num_doc_den, fec_exp_doc_den, fec_nac_den, \n pri_nom_den, seg_nom_den, pri_ape_den, seg_ape_den, tel_den, \n dir_den, push_den, ema_den)\n VALUES (?, ?, ?, ?, ?, \n ?, ?, ?, ?, ?, \n ?, ?, ?);\"\n\n end",
"def insert(value)\n #YOUR WORK HERE\n end",
"def insert(value)\n # YOUR WORK HERE\n end",
"def insert(key)\n end",
"def insert(item)\n\n\n\n\n end",
"def insert_head (value) # Insertar desde la cabeza\n\t nodo=Node.new(value,nil,nil)\n nodo.nest = @head\n @head = nodo # el head ahora apunta a este nodo\n if (@tail == nil)\n @tail = nodo\n end\n nodo.prev = nil\n if (nodo.nest != nil)\n nodo.nest.prev = nodo\n end\n end",
"def insert_head(nodo)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la lista debe contener nodos\" unless ( nodo.instance_of? Nodo )\n nodo.next = @head\n @head.prev = nodo\n nodo.prev = nil\n @nodos = @nodos +1\n @head = nodo\n end",
"def insert_child\n insert_node('insert_child')\n end",
"def insert_successor\n insert_node('insert_successor')\n end",
"def insertar(identificador, tipo, tamanio, asignacion, modificable = true)\n\t\t@tabla.store(identificador.valor.str, tipo)\n\n\t\tif tamanio != nil then\n\t\t\t@tamanio.store(identificador.valor.str, tamanio)\n\t\tend\n\n\t\tif asignacion != nil then\n\t\t\t@asignacion.store(identificador.valor.str, asignacion)\n\n\t\telse\n\n\t\t\tif tipo.str == \"int\" then\n\t\t\t\t# token = Token.new(\"0\", -1, -1)\n\t\t\t\t# nodo = NodoInt.new(token)\n\t\t\t\t@asignacion.store(identificador.valor.str, 0)\n\n\t\t\telsif tipo.str == \"bool\" then\n\t\t\t\t# token = Token.new(\"false\", -1, -1)\n\t\t\t\t# nodo = NodoBool.new(token)\n\t\t\t\t@asignacion.store(identificador.valor.str, false)\n\n\t\t\telsif tipo.str == \"bits\" && (tamanio.is_a?(Integer) || tamanio.is_a?(String)) then\n\n\t\t\t\ti = 0\n\t\t\t\tvalor = \"0b\"\n\t\t\t\twhile (i<Integer(tamanio))\n\t\t\t\t\tvalor += \"0\"\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\n\t\t\t\t@asignacion.store(identificador.valor.str, valor)\n\n\t\t\tend\n\n\t\tend\n\n\t\t@modificable.store(identificador.valor.str, modificable)\n\n\tend",
"def insertar(value)\n insert(Node.new(value, nil, nil))\n end",
"def insertar_por_cabeza(value)\n\t\tnodo=Node.new(value,nil,nil)\n\t\tif(@head==nil)\n\t\t\t@tail=nodo\n\t\t\t@head=nodo\n\t\telse\n\t\t\tnodo.nest=@head\n\t\t\t@head.prev=nodo\n\t\t\t@head=nodo\n\t\t\tnodo.prev=nil\n\t\tend\n\n\tend",
"def insert(index,object)\n\nend",
"def <<(p)\n raise TypeError, \"Esperada pregunta para inserción\" unless p.is_a? (Pregunta)\n if (@total == 0)\n @cabeza = Nodo.new(p, nil, nil)\n @cola = @cabeza\n else\n @cola.next = Nodo.new(p, nil, @cola)\n @cola = @cola.next\n @cola.value\n end\n @total += 1\n end",
"def insertar_lista_principio(referencia)\n if @principio != nil && @principio.siguiente != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n elsif @principio != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n @final = n\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end",
"def insert_at(index)\n at(index)\n temp = @current_node.next\n blankNode = Node.new('Inserted Node')\n @current_node.next = blankNode\n blankNode.next = temp\n end",
"def insert(**opts)\n add(**opts)\n save!\n end",
"def insert(key,value)\n tree = insert_help(key,value)\n if tree.kick?\n tree.to_tree\n else\n tree\n end\n end",
"def insert(v)\n \n end",
"def insert\n print(\"[en]> \")\n en = STDIN.gets.chomp\n print(\"[ru]> \")\n ru = STDIN.gets.chomp\n model.insert(en, ru)\n end",
"def insert_node(index, word, definition)\n node_before_index = find_node(index - 1)\n node_at_current_index = find_node(index)\n new_node = Node.new(word, definition, node_at_current_index)\n node_before_index.next_node = new_node\n @counter += 1\n end",
"def insert(nodo)\n\t\t\n\t\tif(@head == nil)\n\t\t\t@head=nodo\n\t\t\t@tail=nodo\n\t\telsif (@head == @tail)\n\t\t\t@head=nodo\n\t\t\t@head.prev=@tail\n\t\t\t@tail.next=@head\n\t\telse\n\t\t\t@head.next=nodo\n\t\t\tnodo.prev=@head\n\t\t\t@head=nodo\n\t\tend\n\t\treturn true\n\tend",
"def insert(data) \n set data, 1\n end",
"def insert(data) \n set data, 1\n end",
"def insert()\n\t\t@db.execute(\"insert into ausgaben (jahr, monat, name, betrag, gemeinsam, tags) values(:jahr, :monat, :name, :betrag, :gemeinsam, :tags)\", @options)\n\tend",
"def insert_after(child1, child2); end",
"def insertar(texto,timestamp,usuario,fotousuario)\n\t\n\t\tlistaobjeto=[texto,timestamp,usuario,fotousuario]\n\t\t@Lista+=[listaobjeto]\n\tend",
"def insert(position, surname)\n new_node = Node.new(surname)\n current = self[position-1] #self is [] method\n add_to_count\n saved_node = current.next_node\n current.next_node = new_node\n new_node.next_node = saved_node\n return new_node\n end",
"def insert(word)\r\n n = @root\r\n word.chars.each_with_index do |chr, i|\r\n if !n.next.has_key?(chr)\r\n n.next[chr] = Node.new\r\n end\r\n n = n.next[chr]\r\n end\r\n #puts \"insert n=#{n}\"\r\n\r\n n.is_end = true\r\n end",
"def insert(value, index)\n end",
"def addTelefone(contato)\n\tputs(\"\\n\\nDigite o novo numero:\")\n\ttel = Telefone.new\n\ttel.numero = Validacao.validaTelefone(gets.chomp)\n\ttel.id_contato = contato.id\n\tcontato.telefones.push(tel)\n\tContatoDAO.new.addTelefone(tel)\nend",
"def insert(p0, p1) end",
"def insert_tail(nodo)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la lista debe contener nodos\" unless ( nodo.instance_of? Nodo )\n @tail.next = nodo\n nodo.prev = @tail\n nodo.next = nil\n @nodos = @nodos +1\n @tail = nodo\n end",
"def insert(todo)\n todo = Rutodo::Database::Todo.new(\n title: todo.title,\n description: todo.description,\n done: todo.status == :finished\n )\n\n todo.save\n\n todo.as_entity\n end",
"def insert_node\n insert_node_helper(@root)\n end",
"def insert(sql, name = nil, pk = nil, id_value = nil) end",
"def insert_node(parent, type, text, additional = '', object = nil)\n text = text.to_s\n additional = additional.to_s if additional\n iter = self.model.append(parent)\n iter.set_value(Value::ICON, render_icon(@formats[type][0], Gtk::IconSize::MENU, text))\n iter.set_value(Value::TEXT, text)\n iter.set_value(Value::ADDITIONAL_TEXT, additional) if additional\n iter.set_value(Value::OBJECT, object) if object\n iter\n end",
"def insertar_lista_final(referencia)\n if @final != nil\n @final = Nodo.new(referencia, nil, @final)\n n = @final.anterior\n n.siguiente = @final\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end",
"def insert(elemN:)\n\t\tif(elemN < elem)\n\t\t\tif(elemG.nil?)\n\t\t\t\t@elemG = Arbre.new(elem: elemN)\n\t\t\telse\n\t\t\t\t@elemG.insert(elemN: elemN)\n\t\t\tend\n\t\tend\n\t\t\n\t\tif(elemN > elem)\n\t\t\tif(elemD.nil?)\n\t\t\t\t@elemD = Arbre.new(elem: elemN)\n\t\t\telse\n\t\t\t\t@elemD.insert(elemN: elemN)\n\t\t\tend\n\t\tend\n\t\t\n\t\tif(elemN == elem)\n\t\t\traise \"#{elem} est déjà présent dans l'arbre !\"\n\t\tend\n\tend",
"def insert_at(data, index)\n\t\t@current_node = at(index)\n\t\t@insert_node = Node.new(data, @current_node)\n\n\t\t#Handeling the case that user inserts a node at head position (even though prepend exists for that)\n\t\tif @current_node != @head\n\t\t\t@old_link_node = at(index - 1)\n\t\t\t@old_link_node.next_node = @insert_node\n\t\telse\n\t\t\t@head = @insert_node\n\t\tend\n\tend",
"def insert_tail (value) # Insertar desde la cola ( este es el que usaremos para practica 7)\n\tnodo=Node.new(value,nil,nil)\n nodo.prev = @tail\n @tail = nodo\n if (@head == nil)\n @head = nodo\n end\n nodo.nest = nil\n if (nodo.prev != nil)\n nodo.prev.nest = nodo\n end\n end",
"def insert(table,doc)\n connection.insert(path(table),doc)\n end",
"def insert(params)\n params[:real_at] ||= AtStructure.new(params[:at])\n\n if ['_space_', '_return_'].include?(params[:content])\n params.merge!(is_balise: true)\n end\n\n params.merge!(operation: 'insert') unless params.key?(:operation)\n # On ajoute si nécessaire le text-item de référence, qui permettra,\n # notamment, de renseigner les messages, de récupérer le file_id si c'est\n # un projet Scrivener, pour l'affecter aux nouveaux text-items et\n # d'enregistrer les messages d'opération.\n params.merge!(titem_ref: params[:real_at].first_titem) unless params.key?(:titem_ref)\n # Sauf si c'est une balise (*), on crée la simulation pour voir si on va vraiment faire\n # cete opération.\n # (*) Car on ne peut pas occasionner de proximités quand c'est une balise.\n unless params[:is_balise]\n new_titems = simulation(params.merge(debug: debug_insert?)) || return\n end\n\n if params[:operation] == 'insert'\n msg = \"Insertion de “#{params[:content]}” à l’index #{params[:real_at].abs(:at)} (avant “#{extrait_titems[params[:real_at].at].content}”)\"\n log(msg, true)\n end\n\n # :is_balise est true quand on donne '_space_' ou '_return_' comme texte\n unless params[:is_balise]\n # Si c'est une pure insertion, il faut ajouter une espace soit avant\n # soit après les nouveaux items. On l'ajoute après si le titem d'après\n # est un mot (.mot?) et on l'ajoute avant si le titem avant est un mot.\n if params[:operation] == 'insert'\n next_titem = extrait_titems[params[:real_at].at]\n prev_titem = extrait_titems[params[:real_at].first - 1]\n if next_titem && next_titem.mot? && new_titems.last.mot?\n # Dans le cas où l'item suivant existe, que c'est un mot, et que\n # le dernier titem à insérer est aussi un mot, il faut ajouter\n # une espace à la fin des nouveaux items.\n new_titems << NonMot.new(SPACE, type: 'space')\n elsif prev_titem && prev_titem.mot? && new_titems.first.mot?\n # Sinon, dans le cas où l'item précédent existe, que c'est un mot\n # et que le premier item à insérer est aussi un mot, il faut ajouter\n # une espace au début des nouveaux items\n new_titems.unshift(NonMot.new(SPACE, type:'space'))\n end\n end\n else\n new_item = case params[:content]\n when '_space_' then NonMot.new(SPACE, type:'space')\n when '_return_' then NonMot.new(RC, type:'paragraphe')\n end\n new_titems = [new_item]\n end\n # log(\"Nouveaux items ajoutés (#{new_titems.count}) : \")\n # log(new_titems.inspect)\n\n # Si c'est un projet Scrivener, il faut ajouter le file_id de l'item\n # de référence aux nouveaux items\n if itexte.projet_scrivener?\n new_titems.each {|titem| titem.file_id = params[:titem_ref].file_id}\n end\n\n # Insertion des nouveaux titems dans l'extrait\n extrait_titems.insert(params[:real_at].at, *new_titems)\n # Insertion des nouveaux titems dans la base de données\n start_abs_index = params[:real_at].abs(:at)\n new_titems.each_with_index { |i, idx| i.index = idx + start_abs_index }\n itexte.db.insert_text_items(new_titems)\n\n # Pour l'annulation (sauf si c'est justement une annulation)\n if params.key?(:cancellor)\n idx = params[:real_at].abs(:at)\n new_titems.each do |titem|\n content = titem.space? ? '_space_' : titem.content\n params[:cancellor] << {operation: :remove, index:idx, content:content}\n # Note : le content, ci-dessus, ne servira que pour la vérification\n end\n end\n\n # Si c'est vraiment une opération d'insertion, on l'enregistre\n # en tant qu'opération.\n # Noter qu'il faut le faire avant l'update suivant, sinon tous les\n # index et indices seront recalculés et donc faux.\n if params[:operation] == 'insert'\n itexte.operator.add_text_operation(params)\n end\n\n unless params[:noupdate]\n update\n end\nend",
"def insert(index, string)\n execute_only(:insert, index, string)\n end",
"def insert()\n\n # Kräver att det finns ett \"set_table(\"Table\")\" i klassen\n @insertable_vars_full = self.instance_variables # Ta med namnen user.username osv\n @insertable_vars_full.shift(1) # Kinda frisky\n @insertable_vars = []\n @insertable_values = []\n @insertable_vars_full.each do |var|\n @insertable_vars << var[1..-1]\n @insertable_values << self.instance_variable_get(var)\n end\n\n\n @insertable_vars_str = @insertable_vars.join(\", \")\n\n @question_marks = \"\"\n @insertable_vars.each do |key|\n @question_marks.concat(\"?,\")\n end\n @question_marks = @question_marks[0..-2]\n\n DB.execute(\"INSERT INTO #{@table} (#{@insertable_vars_str})\n VALUES (#{@question_marks})\", @insertable_values)\n\n end",
"def insert(nodos)\n for i in (0.. nodos.size-1)\n insert_tail(nodos[i])\n end\n end",
"def add(value)\n if @root == nil\n @root = Node.new(value)\n startMethods()\n else\n @addMethods.add(value)\n end\n puts \"* DATO INSERTADO CORRECTAMENTE !\"\n\n end",
"def insert_node( word, definition, index )\n\n\t\tcount = 0\n\t\tcurrent_node = @head\n\t\tlast_node = nil\n\n\n\t\tlast_node, count = find_node( index )\n\t\tcurrent_node = last_node.next\n\n\t\tif last_node.next.nil?\n\n\t\t\tadd_node( word, definition )\n\n\t\telse\n\n\t\t\tnew_node = Node.new( word, definition )\n\t\t\tnew_node.next = current_node\n\t\t\tlast_node.next = new_node\n\n\t\t\tputs \"Inserted #{new_node.word} at index: #{count}\"\n\n\t\tend\n\n\tend",
"def insert(index, content)\n\t\tif index==1 and @length!=0\n\t\t\tnode = Node.new(content, nil, @first)\n\t\t\t@first = node\n\t\telsif @length+1==index\n\t\t\tpush(content)\n\t\telse\n\t\t\ttmp = get(index)\n\t\t\tnode = Node.new(content, tmp.back, tmp)\n\t\t\ttmp.back.front = node\n\t\t\ttmp.back = node\n\t\tend\n\t\t@length+=1\n\tend",
"def insert_first(new)\n insert_after(nil, new)\n end",
"def insert(name)\n CONN.execute(\"INSERT INTO artits(name) VALUES(?)\", name)\nend",
"def insert(key)\n @root = insert_helper(@root, key)\n end",
"def insert_kcup(kcup)\n end",
"def insertAfter(node, new_node)\n end",
"def insert_data(data)\n self.root = insert(data)\n end",
"def insert(index,element)\n return nil if index < 0 || index > @size\n if element.new?\n pair = [element,element.class]\n else\n pair = [element.rod_id,element.class]\n end\n @map.keys.sort.reverse.each do |key|\n if key >= index\n value = @map.delete(key)\n @map[key+1] = value\n end\n end\n @map[index] = @added.size\n @added << pair\n #@commands << [:insert,pair]\n @size += 1\n self\n end",
"def insertarHead(value)\n nodo = Node.new(value)\n if @head == nil and @tail == nil\n @head = nodo\n @tail = nodo\n else\n @head.next = nodo\n nodo.prev = @head\n @head = nodo\n end\n @size+=1\n end",
"def insert_node(atlas_node_id, node_name, node)\n return if atlas_node_id.blank? || node_name.blank?\n current_node = TaxGenerator::TaxonomyNode.new(atlas_node_id, node_name)\n node << current_node\n current_node\n end",
"def insert_at(position = 1)\n move_to_child_with_index(parent, position - 1)\n end",
"def insert_before(child1, child2); end",
"def insert key, value\n begin\n db.putnr(key, value)\n rescue StandardError => e ; handle_error(\"Insert #{[key, value].inspect}\", e); end\n end",
"def insert(cartridge)\n end",
"def agregar_docente\n\t\t@seccion = \"Docentes\"\n @titulo = \"Agregar docente\"\n\tend",
"def insert_after(key, to_insert)\n insert_after_node(find(key), to_insert)\n end",
"def insert_beginning(*val)\n \n val.each do |nuevo_nodo|\n \n if @head != nil\n \n @head.previous = nuevo_nodo\n nuevo_nodo.next = @head\n @head = nuevo_nodo\n else\n @head = nuevo_nodo\n end\n @num_nodos += 1\n \n end\n end",
"def add_chores(db, name, complete_by_day)\r\n\tdb.execute(\"INSERT INTO chores (name, complete_by_day, family_id) VALUES (?, ?, 0)\", [name, complete_by_day])\r\nend",
"def insert_at(i,data)\n if i<0 || i>= @size\n \treturn nil\n end\n node=Node.new\n node.value=data\n if i==0\n \tnode.next_node=@root\n \t@root=node\n else\n pre_node=at(i-1)\n node.next_node=pre_node.next_node\n pre_node.next_node=node\n end\n @size+=1\n end",
"def insert(anEntry)\n symbol_table.insert(anEntry)\n end",
"def insert(table, id, attributes) # abstract\n end",
"def _insert(*)\n fail NotImplementedError\n end",
"def inserta\n\t\tnum_pago = 1\n\t\tmonto = divide_pagos()\n\t\tfecha_pago = suma_dias()\n\t\tpago_total = calcula_pago_total()\n\n\t\t\tpagos = Payment.new(num_pago: num_pago, monto: pago_total, fecha_pago: fecha_pago, registro: \"\", client_id: self.id)\n\t\t pagos.save!\n\n\tend",
"def insert(data)\n @head = Node.new(data, @head)\n end",
"def insert(text)\n normal \"i#{text}\"\n end",
"def insert(character, trie)\n found = trie.find do |n|\n n.value == character\n end\n\n add_node(character, trie) unless found\n end",
"def insert(x)\n @info.push(x)\n self\n end",
"def insert(x)\n @info.push(x)\n self\n end",
"def insert(x)\n @info.push(x)\n self\n end",
"def add_node(node); end",
"def insert_at(data, index)\n return nil if index < 0 || index > @size \n new_node = Node.new(data, at(index))\n at(index - 1).next_node = new_node\n @size += 1\n end",
"def insert(name, tag, value)\n set_text_content(name, tag, @klass, value)\n end",
"def insert(node, identifier = nil)\n if identifier\n insert_after(node, identifier)\n else \n node.next = @first_node\n @first_node = node\n end\n end",
"def insert(word, definition, index)\n new_node = Node.new(word, definition, nil)\n count = 2\n current_node = @head\n next_node = @head.next\n while count < index\n current_node = current_node.next\n next_node = next_node.next\n count += 1\n end\n new_node.next = next_node\n current_node.next = new_node\n end",
"def insert(node, &block); end",
"def insert(node, &block); end",
"def insert_node(word, definition, index)\n node = Node.new(word, definition, nil)\n if index == 0\n node.next = @head\n @head = node\n else\n counter = 0\n current_node = @head\n prev_node = nil\n while counter < index\n prev_node = current_node\n current_node = current_node.next\n counter += 1\n end\n node.next = current_node\n prev_node.next = node\n puts \"Inserting node at index #{index} with value: #{node.word}\"\n end\n end",
"def agregar_compra(producto, unidades = 1)\n DB.execute(\"insert into compras values ( ?, ?)\", producto, unidades)\nend",
"def insert(word)\n tmp = self\n word.split(\"\").each do |char|\n tmp.childs[char] ||= Trie.new\n tmp = tmp.childs[char]\n end\n tmp.isend = true\n nil\n end",
"def insert_piece(piece,x,y) \n piece.points.each { |point| \n #puts \"Inserting #{point[0]},#{point[1]} to #{x},#{y}\" \n @pole[x+point[0]][y-point[1]] = piece.name\n }\n end",
"def insert_object g\n @objects.add g\n end",
"def test_insert_adds_node_at_root\n @tree.insert(\"a\")\n assert_equal \"a\", @tree.root.value\n end",
"def insert(str)\n child_node = get_or_create str[0]\n if str.length == 1 # terminal condition\n child_node.end_of_word!\n else\n child_node.insert str[1..-1] # recursively call itself on the child node\n end\n end"
] |
[
"0.6946411",
"0.6882428",
"0.6740654",
"0.6694569",
"0.662445",
"0.6572449",
"0.6569499",
"0.656519",
"0.65568364",
"0.6477227",
"0.6469679",
"0.64676845",
"0.64276177",
"0.64200675",
"0.64142686",
"0.63971347",
"0.6332909",
"0.6323786",
"0.628781",
"0.62370896",
"0.62359214",
"0.6210681",
"0.6196295",
"0.61923397",
"0.61902916",
"0.6176418",
"0.6122345",
"0.6112995",
"0.6091281",
"0.6064439",
"0.6060964",
"0.60569364",
"0.60569364",
"0.6045595",
"0.603587",
"0.6028063",
"0.60034317",
"0.60015565",
"0.59944856",
"0.59929633",
"0.5991065",
"0.5966197",
"0.5955767",
"0.5940287",
"0.5938818",
"0.59348184",
"0.59282887",
"0.59196347",
"0.5919482",
"0.5910074",
"0.58948493",
"0.58896875",
"0.5854931",
"0.585188",
"0.5847508",
"0.583801",
"0.5830355",
"0.5827556",
"0.58184624",
"0.58133215",
"0.5797733",
"0.5791886",
"0.57880235",
"0.57814634",
"0.57591105",
"0.57517487",
"0.57458884",
"0.5737585",
"0.5736934",
"0.5729963",
"0.5727302",
"0.5726621",
"0.5726416",
"0.5723556",
"0.5723351",
"0.5704974",
"0.5701983",
"0.56816536",
"0.5676925",
"0.5670532",
"0.56606555",
"0.5659815",
"0.56507033",
"0.56454253",
"0.56454253",
"0.56454253",
"0.5638834",
"0.5631963",
"0.5629638",
"0.56204706",
"0.56185913",
"0.56051743",
"0.56051743",
"0.5594071",
"0.55894923",
"0.55893916",
"0.5587456",
"0.55833685",
"0.5582278",
"0.55746675"
] |
0.6509025
|
9
|
Metodo insertar nodo por cabeza
|
def insertar_por_cabeza(value)
nodo=Node.new(value,nil,nil)
if(@head==nil)
@tail=nodo
@head=nodo
else
nodo.nest=@head
@head.prev=nodo
@head=nodo
nodo.prev=nil
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def insert()\n\n end",
"def insert(clave, valor)\r\n @grafo[clave] = valor\r\n end",
"def insert(value)\n #YOUR WORK HERE\n end",
"def insert(value)\n # YOUR WORK HERE\n end",
"def insertar_elemento(nodo)\n \n @nodo = Nodo_.new(nil, nodo, nil)\n \n if @tail == nil\n @head = @nodo\n @tail = @nodo\n #@nodo\n else\n @nodo.next = @head\n @head.prev = @nodo\n @head = @nodo\n #@nodo\n end\n \n end",
"def insert(item)\n\n\n\n\n end",
"def insert(nodo, pos)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la posicion la debe indicar un entero\" unless ( pos.instance_of? Integer)\n raise \"Error posicion inadecuada\" unless ( pos <= @nodos )\n if pos == 0\n insert_head(nodo)\n elsif pos == @nodos\n insert_tail(nodo)\n else\n i = 1\n a = @head\n while i != pos\n i = i+1\n a = a.next\n end\n b = a.next\n nodo.prev = a\n nodo.next = b\n a.next = nodo\n b.prev = nodo\n @nodos = @nodos +1\n nodo\n end\n end",
"def insertar(identificador, tipo, tamanio, asignacion, modificable = true)\n\t\t@tabla.store(identificador.valor.str, tipo)\n\n\t\tif tamanio != nil then\n\t\t\t@tamanio.store(identificador.valor.str, tamanio)\n\t\tend\n\n\t\tif asignacion != nil then\n\t\t\t@asignacion.store(identificador.valor.str, asignacion)\n\n\t\telse\n\n\t\t\tif tipo.str == \"int\" then\n\t\t\t\t# token = Token.new(\"0\", -1, -1)\n\t\t\t\t# nodo = NodoInt.new(token)\n\t\t\t\t@asignacion.store(identificador.valor.str, 0)\n\n\t\t\telsif tipo.str == \"bool\" then\n\t\t\t\t# token = Token.new(\"false\", -1, -1)\n\t\t\t\t# nodo = NodoBool.new(token)\n\t\t\t\t@asignacion.store(identificador.valor.str, false)\n\n\t\t\telsif tipo.str == \"bits\" && (tamanio.is_a?(Integer) || tamanio.is_a?(String)) then\n\n\t\t\t\ti = 0\n\t\t\t\tvalor = \"0b\"\n\t\t\t\twhile (i<Integer(tamanio))\n\t\t\t\t\tvalor += \"0\"\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\n\t\t\t\t@asignacion.store(identificador.valor.str, valor)\n\n\t\t\tend\n\n\t\tend\n\n\t\t@modificable.store(identificador.valor.str, modificable)\n\n\tend",
"def insert(key)\n end",
"def insert token, tipo, variable = true\n\n\t\tif variable \n\t\t\tif @tabla.has_key? (token.texto)\n\t\t\t\traise RedefinirError.new(token, self.find(token.texto)[:token], variable)\n\t\t\telse\n\t\t\t\t@tabla[token.texto] = {:token => token, :tipo => tipo, :valor => nil}\n\t\t\tend\n\t\telse\n\t\t\tif @tabla.has_key? (token.idFuncion.nombre.texto)\n\t\t\t\traise RedefinirError.new(token.idFuncion.nombre, self.find(token.idFuncion.nombre.texto)[:instancia].idFuncion.nombre, variable)\t\n\t\t\telse\n\t\t\t\t@tabla[token.idFuncion.nombre.texto] = {:instancia => token, :tipo => tipo}\n\t\t\tend\n\t\tend\t\n\tend",
"def insertar (id_usu_den,id_tip_doc,num_doc_den,fec_exp_doc_den,fec_nac_den,pri_nom_den,seg_nom_den,pri_ape_den,seg_ape_den,tel_den,dir_den,push_den,ema_den)\n \tputs \"insertar: \"\n \tprint \"INSERT INTO public.denunciante(\n id_usu_den, id_tip_doc, num_doc_den, fec_exp_doc_den, fec_nac_den, \n pri_nom_den, seg_nom_den, pri_ape_den, seg_ape_den, tel_den, \n dir_den, push_den, ema_den)\n VALUES (?, ?, ?, ?, ?, \n ?, ?, ?, ?, ?, \n ?, ?, ?);\"\n\n end",
"def insert()\n\t\t@db.execute(\"insert into ausgaben (jahr, monat, name, betrag, gemeinsam, tags) values(:jahr, :monat, :name, :betrag, :gemeinsam, :tags)\", @options)\n\tend",
"def insert(**opts)\n add(**opts)\n save!\n end",
"def insertar_elemento(nodo)\n \n if @elemento != nil\n \n nodo.next = @elemento\n @elemento = nodo\n end\n end",
"def insertar_por_cola(value)\n\t\tnodo=Node.new(value,nil,nil)\n if(@tail==nil)\n @tail=nodo\n @head=nodo\n else\n nodo.prev=@tail\n @tail.nest=nodo\n @tail=nodo\n\t\t\tnodo.nest=nil\n end\n\n\tend",
"def insert(index,object)\n\nend",
"def insert(etiqueta)\n nodo = Node.new(etiqueta, nil, nil)\n\n if self.empty\n nodo.next=nodo\n nodo.prev=nodo\n @head=nodo\n @tail=nodo\n\n else\n nodo.prev = @tail\n nodo.next = nil\n @tail.next = nodo\n @tail = nodo\n end\n end",
"def addTelefone(contato)\n\tputs(\"\\n\\nDigite o novo numero:\")\n\ttel = Telefone.new\n\ttel.numero = Validacao.validaTelefone(gets.chomp)\n\ttel.id_contato = contato.id\n\tcontato.telefones.push(tel)\n\tContatoDAO.new.addTelefone(tel)\nend",
"def insertar(x)\n nodo = Nodo.new(x, nil, nil) \n if @head == nil && @tail==nil\n nodo.next=@head\n nodo.prev=@tail\n @head=nodo\n @tail=nodo\n else\n nodo.prev=@head\n nodo.next=nil\n @head.next=nodo\n @head=nodo\n end\n \n end",
"def insertar_varios(nodos)\n \n nodos.each do |nodoo|\n \n insertar(nodoo)\n \n end\n \n end",
"def insertar_lista_principio(referencia)\n if @principio != nil && @principio.siguiente != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n elsif @principio != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n @final = n\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end",
"def insert(sql, name = nil, pk = nil, id_value = nil) end",
"def insert_head (value) # Insertar desde la cabeza\n\t nodo=Node.new(value,nil,nil)\n nodo.nest = @head\n @head = nodo # el head ahora apunta a este nodo\n if (@tail == nil)\n @tail = nodo\n end\n nodo.prev = nil\n if (nodo.nest != nil)\n nodo.nest.prev = nodo\n end\n end",
"def insert(data) \n set data, 1\n end",
"def insert(data) \n set data, 1\n end",
"def insert_child\n insert_node('insert_child')\n end",
"def insertar(value)\n insert(Node.new(value, nil, nil))\n end",
"def insert_kcup(kcup)\n end",
"def insertar(texto,timestamp,usuario,fotousuario)\n\t\n\t\tlistaobjeto=[texto,timestamp,usuario,fotousuario]\n\t\t@Lista+=[listaobjeto]\n\tend",
"def insert_successor\n insert_node('insert_successor')\n end",
"def insert(v)\n \n end",
"def insert(params)\n params[:real_at] ||= AtStructure.new(params[:at])\n\n if ['_space_', '_return_'].include?(params[:content])\n params.merge!(is_balise: true)\n end\n\n params.merge!(operation: 'insert') unless params.key?(:operation)\n # On ajoute si nécessaire le text-item de référence, qui permettra,\n # notamment, de renseigner les messages, de récupérer le file_id si c'est\n # un projet Scrivener, pour l'affecter aux nouveaux text-items et\n # d'enregistrer les messages d'opération.\n params.merge!(titem_ref: params[:real_at].first_titem) unless params.key?(:titem_ref)\n # Sauf si c'est une balise (*), on crée la simulation pour voir si on va vraiment faire\n # cete opération.\n # (*) Car on ne peut pas occasionner de proximités quand c'est une balise.\n unless params[:is_balise]\n new_titems = simulation(params.merge(debug: debug_insert?)) || return\n end\n\n if params[:operation] == 'insert'\n msg = \"Insertion de “#{params[:content]}” à l’index #{params[:real_at].abs(:at)} (avant “#{extrait_titems[params[:real_at].at].content}”)\"\n log(msg, true)\n end\n\n # :is_balise est true quand on donne '_space_' ou '_return_' comme texte\n unless params[:is_balise]\n # Si c'est une pure insertion, il faut ajouter une espace soit avant\n # soit après les nouveaux items. On l'ajoute après si le titem d'après\n # est un mot (.mot?) et on l'ajoute avant si le titem avant est un mot.\n if params[:operation] == 'insert'\n next_titem = extrait_titems[params[:real_at].at]\n prev_titem = extrait_titems[params[:real_at].first - 1]\n if next_titem && next_titem.mot? && new_titems.last.mot?\n # Dans le cas où l'item suivant existe, que c'est un mot, et que\n # le dernier titem à insérer est aussi un mot, il faut ajouter\n # une espace à la fin des nouveaux items.\n new_titems << NonMot.new(SPACE, type: 'space')\n elsif prev_titem && prev_titem.mot? && new_titems.first.mot?\n # Sinon, dans le cas où l'item précédent existe, que c'est un mot\n # et que le premier item à insérer est aussi un mot, il faut ajouter\n # une espace au début des nouveaux items\n new_titems.unshift(NonMot.new(SPACE, type:'space'))\n end\n end\n else\n new_item = case params[:content]\n when '_space_' then NonMot.new(SPACE, type:'space')\n when '_return_' then NonMot.new(RC, type:'paragraphe')\n end\n new_titems = [new_item]\n end\n # log(\"Nouveaux items ajoutés (#{new_titems.count}) : \")\n # log(new_titems.inspect)\n\n # Si c'est un projet Scrivener, il faut ajouter le file_id de l'item\n # de référence aux nouveaux items\n if itexte.projet_scrivener?\n new_titems.each {|titem| titem.file_id = params[:titem_ref].file_id}\n end\n\n # Insertion des nouveaux titems dans l'extrait\n extrait_titems.insert(params[:real_at].at, *new_titems)\n # Insertion des nouveaux titems dans la base de données\n start_abs_index = params[:real_at].abs(:at)\n new_titems.each_with_index { |i, idx| i.index = idx + start_abs_index }\n itexte.db.insert_text_items(new_titems)\n\n # Pour l'annulation (sauf si c'est justement une annulation)\n if params.key?(:cancellor)\n idx = params[:real_at].abs(:at)\n new_titems.each do |titem|\n content = titem.space? ? '_space_' : titem.content\n params[:cancellor] << {operation: :remove, index:idx, content:content}\n # Note : le content, ci-dessus, ne servira que pour la vérification\n end\n end\n\n # Si c'est vraiment une opération d'insertion, on l'enregistre\n # en tant qu'opération.\n # Noter qu'il faut le faire avant l'update suivant, sinon tous les\n # index et indices seront recalculés et donc faux.\n if params[:operation] == 'insert'\n itexte.operator.add_text_operation(params)\n end\n\n unless params[:noupdate]\n update\n end\nend",
"def insert(key,value)\n tree = insert_help(key,value)\n if tree.kick?\n tree.to_tree\n else\n tree\n end\n end",
"def <<(p)\n raise TypeError, \"Esperada pregunta para inserción\" unless p.is_a? (Pregunta)\n if (@total == 0)\n @cabeza = Nodo.new(p, nil, nil)\n @cola = @cabeza\n else\n @cola.next = Nodo.new(p, nil, @cola)\n @cola = @cola.next\n @cola.value\n end\n @total += 1\n end",
"def add_chores(db, name, complete_by_day)\r\n\tdb.execute(\"INSERT INTO chores (name, complete_by_day, family_id) VALUES (?, ?, 0)\", [name, complete_by_day])\r\nend",
"def insert\n print(\"[en]> \")\n en = STDIN.gets.chomp\n print(\"[ru]> \")\n ru = STDIN.gets.chomp\n model.insert(en, ru)\n end",
"def insert(cartridge)\n end",
"def insert(todo)\n todo = Rutodo::Database::Todo.new(\n title: todo.title,\n description: todo.description,\n done: todo.status == :finished\n )\n\n todo.save\n\n todo.as_entity\n end",
"def insert_head(nodo)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la lista debe contener nodos\" unless ( nodo.instance_of? Nodo )\n nodo.next = @head\n @head.prev = nodo\n nodo.prev = nil\n @nodos = @nodos +1\n @head = nodo\n end",
"def insert(name)\n CONN.execute(\"INSERT INTO artits(name) VALUES(?)\", name)\nend",
"def agregar_compra(producto, unidades = 1)\n DB.execute(\"insert into compras values ( ?, ?)\", producto, unidades)\nend",
"def insert(value, index)\n end",
"def insert()\n\n # Kräver att det finns ett \"set_table(\"Table\")\" i klassen\n @insertable_vars_full = self.instance_variables # Ta med namnen user.username osv\n @insertable_vars_full.shift(1) # Kinda frisky\n @insertable_vars = []\n @insertable_values = []\n @insertable_vars_full.each do |var|\n @insertable_vars << var[1..-1]\n @insertable_values << self.instance_variable_get(var)\n end\n\n\n @insertable_vars_str = @insertable_vars.join(\", \")\n\n @question_marks = \"\"\n @insertable_vars.each do |key|\n @question_marks.concat(\"?,\")\n end\n @question_marks = @question_marks[0..-2]\n\n DB.execute(\"INSERT INTO #{@table} (#{@insertable_vars_str})\n VALUES (#{@question_marks})\", @insertable_values)\n\n end",
"def insert key, value\n begin\n db.putnr(key, value)\n rescue StandardError => e ; handle_error(\"Insert #{[key, value].inspect}\", e); end\n end",
"def insert(table,doc)\n connection.insert(path(table),doc)\n end",
"def insert(index, string)\n execute_only(:insert, index, string)\n end",
"def insert(p0, p1) end",
"def inserta\n\t\tnum_pago = 1\n\t\tmonto = divide_pagos()\n\t\tfecha_pago = suma_dias()\n\t\tpago_total = calcula_pago_total()\n\n\t\t\tpagos = Payment.new(num_pago: num_pago, monto: pago_total, fecha_pago: fecha_pago, registro: \"\", client_id: self.id)\n\t\t pagos.save!\n\n\tend",
"def insert_node(parent, type, text, additional = '', object = nil)\n text = text.to_s\n additional = additional.to_s if additional\n iter = self.model.append(parent)\n iter.set_value(Value::ICON, render_icon(@formats[type][0], Gtk::IconSize::MENU, text))\n iter.set_value(Value::TEXT, text)\n iter.set_value(Value::ADDITIONAL_TEXT, additional) if additional\n iter.set_value(Value::OBJECT, object) if object\n iter\n end",
"def insertar_lista_final(referencia)\n if @final != nil\n @final = Nodo.new(referencia, nil, @final)\n n = @final.anterior\n n.siguiente = @final\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end",
"def insert_at(index)\n at(index)\n temp = @current_node.next\n blankNode = Node.new('Inserted Node')\n @current_node.next = blankNode\n blankNode.next = temp\n end",
"def insert(table, id, attributes) # abstract\n end",
"def insert(word)\r\n n = @root\r\n word.chars.each_with_index do |chr, i|\r\n if !n.next.has_key?(chr)\r\n n.next[chr] = Node.new\r\n end\r\n n = n.next[chr]\r\n end\r\n #puts \"insert n=#{n}\"\r\n\r\n n.is_end = true\r\n end",
"def add(value)\n if @root == nil\n @root = Node.new(value)\n startMethods()\n else\n @addMethods.add(value)\n end\n puts \"* DATO INSERTADO CORRECTAMENTE !\"\n\n end",
"def insert(index,element)\n return nil if index < 0 || index > @size\n if element.new?\n pair = [element,element.class]\n else\n pair = [element.rod_id,element.class]\n end\n @map.keys.sort.reverse.each do |key|\n if key >= index\n value = @map.delete(key)\n @map[key+1] = value\n end\n end\n @map[index] = @added.size\n @added << pair\n #@commands << [:insert,pair]\n @size += 1\n self\n end",
"def _insert(*)\n fail NotImplementedError\n end",
"def insert_data(data)\n self.root = insert(data)\n end",
"def insert(key)\n @root = insert_helper(@root, key)\n end",
"def insert_after(child1, child2); end",
"def insert_takoble\n\t\tsql = \"insert into TAKO_List values (?, ?)\"\n\t\treturn sql\n\tend",
"def insert(character, trie)\n found = trie.find do |n|\n n.value == character\n end\n\n add_node(character, trie) unless found\n end",
"def insert(key, value=nil)\n if key.kind_of?(Array)\n key, value = key\n end\n if key.nil? || value.nil?\n raise CorpusError.new(\"Invalid key/value: #{key} - #{value}\")\n end\n\n ret = @db.put(key.to_s.downcase ,value.to_s.downcase)\n if !ret\n raise CorpusError.new(\"#{@db.errmsg}: #{key} - #{value}\")\n end\n end",
"def insert(elemN:)\n\t\tif(elemN < elem)\n\t\t\tif(elemG.nil?)\n\t\t\t\t@elemG = Arbre.new(elem: elemN)\n\t\t\telse\n\t\t\t\t@elemG.insert(elemN: elemN)\n\t\t\tend\n\t\tend\n\t\t\n\t\tif(elemN > elem)\n\t\t\tif(elemD.nil?)\n\t\t\t\t@elemD = Arbre.new(elem: elemN)\n\t\t\telse\n\t\t\t\t@elemD.insert(elemN: elemN)\n\t\t\tend\n\t\tend\n\t\t\n\t\tif(elemN == elem)\n\t\t\traise \"#{elem} est déjà présent dans l'arbre !\"\n\t\tend\n\tend",
"def insert(index, content)\n\t\tif index==1 and @length!=0\n\t\t\tnode = Node.new(content, nil, @first)\n\t\t\t@first = node\n\t\telsif @length+1==index\n\t\t\tpush(content)\n\t\telse\n\t\t\ttmp = get(index)\n\t\t\tnode = Node.new(content, tmp.back, tmp)\n\t\t\ttmp.back.front = node\n\t\t\ttmp.back = node\n\t\tend\n\t\t@length+=1\n\tend",
"def insert_kanji(kanji)\n kanji = kanji.clone\n kanji_id = kanji.id\n\n @index_kanji ||= @database.prepare('insert into kanji_fts values (?, ?)')\n @insert_kanji ||= @database.prepare('insert into kanji values (?, ?)')\n \n @index_kanji.execute(kanji.character, kanji_id)\n\n # We can derive these data from FTS table.\n kanji.id = 0\n kanji.character = ''\n\n @insert_kanji.execute(kanji_id, Kanji.encode(kanji))\n end",
"def insert_node\n insert_node_helper(@root)\n end",
"def insert_into_article(title, content, price, user_id, adress, phone_number, date_created, tag_id) \n return get_db().execute(\"INSERT INTO article (title, content, price, user_id, adress, phone_number, date_created, tag_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)\", title, content, price, user_id, adress, phone_number, date_created, tag_id)\n end",
"def insert_first(new)\n insert_after(nil, new)\n end",
"def insert_at(data, index)\n\t\t@current_node = at(index)\n\t\t@insert_node = Node.new(data, @current_node)\n\n\t\t#Handeling the case that user inserts a node at head position (even though prepend exists for that)\n\t\tif @current_node != @head\n\t\t\t@old_link_node = at(index - 1)\n\t\t\t@old_link_node.next_node = @insert_node\n\t\telse\n\t\t\t@head = @insert_node\n\t\tend\n\tend",
"def db_insert a, b, c\n if a == \"\" or b == \"\" \n return 'blank'\n end\n $db.execute \"INSERT INTO produtos (cod, prod, prec) VALUES(?, ?, ?)\", a, b, c\nend",
"def insert_tail (value) # Insertar desde la cola ( este es el que usaremos para practica 7)\n\tnodo=Node.new(value,nil,nil)\n nodo.prev = @tail\n @tail = nodo\n if (@head == nil)\n @head = nodo\n end\n nodo.nest = nil\n if (nodo.prev != nil)\n nodo.prev.nest = nodo\n end\n end",
"def add_to (table_name,title,code)\r\n\t\"INSERT INTO \" + table_name + \r\n\t\"(title,code) VALUES \r\n\t('\" + title + \"','\" + code + \"')\"\r\nend",
"def insert(nodo)\n\t\t\n\t\tif(@head == nil)\n\t\t\t@head=nodo\n\t\t\t@tail=nodo\n\t\telsif (@head == @tail)\n\t\t\t@head=nodo\n\t\t\t@head.prev=@tail\n\t\t\t@tail.next=@head\n\t\telse\n\t\t\t@head.next=nodo\n\t\t\tnodo.prev=@head\n\t\t\t@head=nodo\n\t\tend\n\t\treturn true\n\tend",
"def insert_node(index, word, definition)\n node_before_index = find_node(index - 1)\n node_at_current_index = find_node(index)\n new_node = Node.new(word, definition, node_at_current_index)\n node_before_index.next_node = new_node\n @counter += 1\n end",
"def insert(position, surname)\n new_node = Node.new(surname)\n current = self[position-1] #self is [] method\n add_to_count\n saved_node = current.next_node\n current.next_node = new_node\n new_node.next_node = saved_node\n return new_node\n end",
"def insert_object g\n @objects.add g\n end",
"def insert (args)\n #p @name\n #p '.......'\n p args\n p self.rarray\n if self.rarray.get(args[:id]).nil?\n model={:mod_name=>@name}\n p self\n #self.rarray << args.merge(model)\n self.rarray << args \n self.store\n else\n raise ArgumentError, 'Cannot insert - id already exists', caller\n end\n end",
"def insert(anEntry)\n symbol_table.insert(anEntry)\n end",
"def add_doi(doi_n)\n #$log.info(\"Agregar #{doi_n} a #{self[:id]}\")\n status=Result.new\n\n crossref_doi=CrossrefDoi.process_doi(doi_n)\n\n unless crossref_doi\n status.error(I18n::t(\"add_doi.cant_process_doi\", doi:doi_n))\n return status\n end\n\n $db.transaction do\n ##$log.info(co)\n if self[:doi]==doi_n\n status.info(I18n::t(\"add_doi.doi_already_on_reference\", doi:doi_n, reference:self[:text]))\n else\n self.update(:doi=>doi_without_http(doi_n))\n status.success(I18n::t('add_doi.doi_set_to_reference', doi:doi_n, reference:self[:text]))\n end\n\n if self[:canonical_document_id].nil?\n can_doc=CanonicalDocument[:doi=>doi_without_http(doi_n)]\n if can_doc\n self.update(:canonical_document_id=>can_doc[:id])\n status.info(I18n::t('add_doi.reference_to_canonical_document', canonical_document:can_doc[:title], reference:self[:text] ))\n else # No existe el canónico, lo debo crear\n integrator=CrossrefDoi.reference_integrator_json(doi)\n ##$log.info(integrator)\n fields = [:title,:author,:year,:journal, :volume, :pages, :doi, :journal_abbr,:abstract]\n fields_update=fields.inject({}) {|ac,v|\n ac[v]= integrator.send(v); ac;\n }\n\n # En casos muy raros no está el año. Tengo que reportar error, no más\n if fields_update[:year].nil?\n status.error(I18n::t('add_doi.doi_without_year', doi:doi_n))\n fields_update[:year]=0\n end\n can_doc_id=CanonicalDocument.insert(fields_update)\n self.update(:canonical_document_id=>can_doc_id)\n status.success(I18n::t('add_doi.new_canonical_document', can_doc_id:can_doc_id, can_doc_text:integrator.ref_apa_6))\n end\n $db.after_rollback {\n status=Result.new\n status.error(I18n::t('add_doi.rollback', reference:self[:text]))\n }\n end\n end\n\n status\n end",
"def insert\n DATABASE.execute(\"INSERT INTO terms (term, definition, phonetic) VALUES \n ('#{@term}', '#{@definition}', '#{@phonetic}')\")\n @id = DATABASE.last_insert_row_id\n end",
"def insert\n array = [[@name, @tagline, @github, @twitter, @blog_url, @image_url, @biography]]\n ins = DB[:conn].prepare(\"INSERT INTO students (name, tagline, github, twitter, blog_url, image_url, biography) VALUES (?, ?, ?, ?, ?, ?, ?);\")\n array.each { |s| ins.execute(s)}\n self.id = DB[:conn].execute(\"SELECT last_insert_rowid() FROM students;\")[0][0]\n #ask steven re. index figures\n #inserting data into an instance\n end",
"def save_endereco(log, numero, comp) \n e = Endereco.where(logradouro: log, numero: numero, complemento: comp).first\n if e == nil\n puts \"Criando novo endereco...\"\n e = Endereco.create!(logradouro: log, numero: numero, complemento: comp)\n puts e\n else\n puts \">>> Endereco ja cadastrado #{log.cep} #{numero}\"\n end\n e\n end",
"def strInsertEntry(xmlNode)\n name = xmlNode.name ;\n scanSchemaFromDB(name) ;\n element = @xsd.findElement(name) ;\n sqlRow = element.expandedStructure.xml2sqlRow(xmlNode) ;\n return element.sqlTable.strSimpleInsert(sqlRow) ;\n end",
"def handle_insert action, result; end",
"def insert_node(atlas_node_id, node_name, node)\n return if atlas_node_id.blank? || node_name.blank?\n current_node = TaxGenerator::TaxonomyNode.new(atlas_node_id, node_name)\n node << current_node\n current_node\n end",
"def insert(x)\n @info.push(x)\n self\n end",
"def insert(x)\n @info.push(x)\n self\n end",
"def insert(x)\n @info.push(x)\n self\n end",
"def insert(category,task,priority)\n @todo_container[category] ||= []\n last_task = @todo_container[category].last\n next_index = last_task ? (last_task.index + 1): 0\n @todo_container[category] << OpenStruct.new(:priority => priority, :text => task.gsub(/\\n/,' '), :flag => true,:index => next_index)\n end",
"def insert(word)\n tmp = self\n word.split(\"\").each do |char|\n tmp.childs[char] ||= Trie.new\n tmp = tmp.childs[char]\n end\n tmp.isend = true\n nil\n end",
"def insert_tail(nodo)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la lista debe contener nodos\" unless ( nodo.instance_of? Nodo )\n @tail.next = nodo\n nodo.prev = @tail\n nodo.next = nil\n @nodos = @nodos +1\n @tail = nodo\n end",
"def test_insert_adds_node_at_root\n @tree.insert(\"a\")\n assert_equal \"a\", @tree.root.value\n end",
"def insert(key, value = nil)\n node = @root\n if node.full? \n @root = Btree::Node.new(@degree)\n @root.add_child(node)\n @root.split(@root.children.size - 1)\n #puts \"After split, root = #{@root.inspect}\"\n # split child(@root, 1)\n node = @root\n end\n node.insert(key, value)\n @size += 1\n return self\n end",
"def insert_after(key, to_insert)\n insert_after_node(find(key), to_insert)\n end",
"def add_data_object(dato, options = {})\n if dato.data_type_id == DataType.text.id\n toc_item = dato.info_items[0] ? dato.info_items[0].toc_item : dato.toc_items.first\n begin\n DataObjectsTableOfContent.gen(:data_object => dato, :toc_item => toc_item)\n rescue ActiveRecord::RecordNotUnique\n # do nothing\n end\n dato.save!\n end\n DataObjectsHierarchyEntry.gen(:data_object => dato, :hierarchy_entry => hierarchy_entries.first)\n DataObjectsTaxonConcept.gen(:taxon_concept => self, :data_object => dato)\n end",
"def insert_member(fedora_object)\n if (fedora_object.instance_of?(Bplmodels::ObjectBase))\n\n #add to the members ds\n #members.insert_member(:member_id=>fedora_object.pid, :member_title=>fedora_object.titleSet_display, :member_type=>fedora_object.fedora_name\n\n #add to the rels-ext ds\n #fedora_object.collections << self\n #self.objects << fedora_object\n #self.add_relationship(:has_image, \"info:fedora/#{fedora_object.pid}\")\n elsif (fedora_object.instance_of?(Bplmodels::Institution))\n #add to the members ds\n members.insert_member(:member_id=>fedora_object.pid, :member_title=>fedora_object.titleSet_display, :member_type=>fedora_object.fedora_name)\n\n #add to the rels-ext ds\n fedora_object.collections << self\n self.institutions << fedora_object\n\n end\n\n fedora_object.save!\n self.save!\n\n end",
"def insert_before(child1, child2); end",
"def insert(name, tag, value)\n set_text_content(name, tag, @klass, value)\n end",
"def add_obrigacao(conta_id, estabelecimento_id, obrigacao_id, dia_entrega)\n obest = Taxcalendario::Admin::Client::Entities::ObrigacaoEstabelecimento.new\n obest.dia_entrega = dia_entrega\n obest.obrigacao_id = obrigacao_id\n map = JSON.parse(post_and_give_me_a_json(\"/estabelecimentos/obrigacoes/#{conta_id}/#{estabelecimento_id}\",obest)) \n obj = Taxcalendario::Admin::Client::Entities::ObrigacaoEstabelecimento.new\n obj.from_hash(map)\n obj\n end",
"def insert_node (insert_mode)\n reference_node = Node.find(params[:id])\n if !reference_node\n render_reference_node_error\n return\n end\n\n node_to_insert = Node.find(params[:node][:id])\n if !node_to_insert\n render_node_to_insert_error\n return\n end\n\n reference_node.send(insert_mode, node_to_insert)\n\n respond_to do |format|\n format.json { render json: node_to_insert, status: :created, location: node_to_insert }\n end\n end"
] |
[
"0.6854826",
"0.6695791",
"0.6641629",
"0.6634402",
"0.6599649",
"0.6591634",
"0.6576441",
"0.6574138",
"0.6571803",
"0.6536611",
"0.64992374",
"0.6355666",
"0.63382196",
"0.6319927",
"0.6307169",
"0.6279133",
"0.6272425",
"0.6271726",
"0.6259754",
"0.62520206",
"0.62463754",
"0.62293816",
"0.622492",
"0.6204805",
"0.6204805",
"0.6199454",
"0.61879826",
"0.6160755",
"0.61418426",
"0.6139509",
"0.6135816",
"0.6127",
"0.61199766",
"0.6116517",
"0.6114703",
"0.6046856",
"0.60286105",
"0.6021574",
"0.6012616",
"0.5999386",
"0.59893936",
"0.5968689",
"0.5965762",
"0.5946637",
"0.5911871",
"0.58980805",
"0.58772296",
"0.5873963",
"0.58722353",
"0.5872123",
"0.58631295",
"0.5861415",
"0.5840084",
"0.58323187",
"0.5824467",
"0.5822733",
"0.58131194",
"0.58061475",
"0.580038",
"0.5797479",
"0.5781492",
"0.57799816",
"0.5771228",
"0.57618743",
"0.5759616",
"0.5755755",
"0.5752791",
"0.57434416",
"0.57346886",
"0.5733333",
"0.57216597",
"0.5716455",
"0.5709623",
"0.57050914",
"0.57007134",
"0.56876564",
"0.5679501",
"0.5675988",
"0.56634414",
"0.5660368",
"0.5624787",
"0.5623162",
"0.562109",
"0.5619768",
"0.5612975",
"0.561057",
"0.561057",
"0.561057",
"0.5605821",
"0.56034523",
"0.56027687",
"0.560221",
"0.56008327",
"0.5600544",
"0.5593651",
"0.5585498",
"0.5583923",
"0.5583236",
"0.55821437",
"0.55804485"
] |
0.6386132
|
11
|
Metodo extraer nodo por cabeza
|
def extraer_por_cabeza
if(@head==nil)
puts "No hay nada que extraer (lista vacia)"
else
aux=@head
@head=@head.nest
if(head!=nil)
@head.prev=nil
end
aux.nest=nil
if(@head==nil)
@tail=nil
end
end
return aux
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sonido()\n return super << \" miaaauuu\"\n end",
"def extra; end",
"def sigla; @nome; end",
"def mi_carrera\n\n\tend",
"def nombre_completo\n\tprimer_nombre+\" \"+primer_apellido\n#fin del metodo\nend",
"def suivre; end",
"def donizetti; end",
"def asignar_titulo_propiedad()\n \n end",
"def metodo\n #corpo do metodo\n puts 'corpo do metodo'\n end",
"def metodo\n #corpo do metodo\n puts 'corpo do metodo'\n end",
"def metodo\n #corpo do metodo\n puts 'corpo do metodo'\n end",
"def nome_proprio\nStringFix.nome_proprio(self)\nend",
"def extraer_elemento\n \n @nodo = Nodo_.new(nil, @head.value, nil)\n \n @head = @head.next\n @head.prev = nil\n return @nodo\n \n #nodo = @head\n #if @head.next == nil\n # @head = nil\n # else\n # @head = @head.next\n #end\n #return nodo\n \n #nodo = @head\n #@head = @head.next\n \n #nodo.next = nil\n #nodo.prev = nil\n \n #if @head == nil\n # @tail = nil\n #end\n \n #return nodo\n end",
"def metodo_publico\n puts \"\\nmétodo privado\"\n end",
"def titulo\n return nil\n end",
"def titulo\n return nil\n end",
"def terpene; end",
"def traktiNodon(nod, stato)\n\n objekto = {\"tipo\" => nod.name, \"filoj\" => [], \"tradukoj\" => {}, \"filNombro\" => 0}\n stato[\"super\"] << nod.name\n\n miaMarko = false\n\n if nod[\"mrk\"] != nil\n objekto[\"mrk\"] = nod[\"mrk\"]\n stato[\"marko\"] << nod[\"mrk\"]\n miaMarko = true\n end\n\n teksto = \"\"\n \n nod.children().each do |fil|\n\n if fil.name == \"kap\"\n novaKapo = traktiKapon(fil, stato)\n objekto[\"nomo\"] = novaKapo[\"nomo\"]\n objekto[\"tildo\"] = novaKapo[\"tildo\"]\n objekto[\"kapo\"] = novaKapo\n if nod.name == \"drv\"\n # Registri tradukojn en esperanton\n\t for nom in objekto[\"nomo\"].split(\", \")\n\t @esperantaj << fariSerchTradukon(nom, nom, stato[\"nomo\"], stato[\"artikolo\"][\"indekso\"], stato[\"marko\"].last, 0)\n\t end\n end\n elsif fil.name == \"uzo\"\n novaUzo = traktiUzon(fil, stato)\n \t if objekto[\"uzoj\"] == nil\n\t objekto[\"uzoj\"] = []\n\t end\n\t objekto[\"uzoj\"] << novaUzo\n elsif fil.name == \"gra\"\n fil.children().each do |fil2|\n if fil2.name == \"vspec\"\n objekto[\"vspec\"] = fil2.text\n end\n end\n elsif fil.name == \"subart\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"drv\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"subdrv\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"snc\"\n objekto[\"filNombro\"] += 1\n stato[\"senco\"] = objekto[\"filNombro\"]\n novaSenco = traktiNodon(fil, stato)\n objekto[\"filoj\"] << novaSenco\n if novaSenco[\"mrk\"] != nil\n @indikiloDeMarko[novaSenco[\"mrk\"]] = objekto[\"filNombro\"].to_s\n end\n stato[\"senco\"] = 0\n elsif fil.name == \"subsnc\"\n objekto[\"filNombro\"] += 1\n novaSubSenco = traktiNodon(fil, stato)\n objekto[\"filoj\"] << novaSubSenco\n if novaSubSenco[\"mrk\"] != nil\n litero = (\"a\"..\"z\").to_a[objekto[\"filNombro\"]-1]\n numero = stato[\"senco\"].to_s + litero\n @indikiloDeMarko[novaSubSenco[\"mrk\"]] = numero\n end\n elsif fil.name == \"dif\"\n novaDifino = traktiDifinon(fil, stato)\n objekto[\"filoj\"] << novaDifino\n elsif fil.name == \"rim\"\n novaRimarko = traktiRimarkon(fil, stato)\n objekto[\"filoj\"] << novaRimarko\n elsif fil.name == \"ref\"\n stato[\"refspac\"] = objekto[\"filoj\"].count > 0\n novaRefo = traktiRefon(fil, stato)\n objekto[\"filoj\"] << novaRefo\n elsif fil.name == \"refgrp\"\n stato[\"refspac\"] = objekto[\"filoj\"].count > 0\n novaRefgrupo = traktiRefgrupon(fil, stato)\n objekto[\"filoj\"] << novaRefgrupo\n elsif fil.name == \"ekz\"\n novaEkzemplo = traktiEkzemplon(fil, stato)\n #teksto += novaEkzemplo[\"teksto\"]\n\t objekto[\"filoj\"] << novaEkzemplo\n elsif fil.name == \"trd\"\n traktiTradukon(fil, stato)\n elsif fil.name == \"trdgrp\"\n traktiTradukGrupon(fil, stato)\n elsif fil.name == \"text\"\n #puts \"teksto: \" + fil.text + \"|\"\n #objekto[\"filoj\"] << {\"tipo\" => \"teksto\", \"teksto\" => fil.text}\n elsif fil.name == \"frm\"\n novaFormulo = traktiFormulon(fil, stato)\n\t teksto += novaFormulo[\"teksto\"]\n else\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n end\n end\n\n for fil in objekto[\"filoj\"]\n if fil[\"teksto\"] != nil\n if fil[\"tipo\"] == \"refo\" or fil[\"tipo\"] == \"refgrupo\"\n\t teksto += \" \"\n\t end\n teksto += fil[\"teksto\"]\n end\n end\n\n # atendu ghis la fino de drv antau enmeti tradukojn el ekzemploj -\n # tiuj ghenerale rilatas al dirajhoj, ke ne estas baza vortoj por serchi\n if stato[\"super\"].count == 1 and stato[\"ekzTradukoj\"] != []\n for lng, tradoj in stato[\"ekzTradukoj\"]\n for trad in tradoj\n\t stato[\"artikolo\"][\"tradukoj\"][lng] << trad\n\t end\n end\n\n stato[\"ekzTradukoj\"] = {}\n end\t \t \n\n if miaMarko then stato[\"marko\"].pop end\n\n #objekto[\"teksto\"] = teksto\n stato[\"super\"].pop\n return objekto\nend",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def get_nombre # la convencion de ruby es def nombre\n @nombre # el nombre es implicito\n end",
"def get_modo()\r\n\t\treturn \"tipo\"\r\n\tend",
"def extra; @extra; end",
"def specialty; end",
"def nature; end",
"def preencher\n nome.set 'leticia'\n \n end",
"def zuruecksetzen()\n end",
"def letzte_komponente\n \n end",
"def konversiMenit(menit) \n # =================================\n # Area Kode Kode di sini\n \n \n \n # =================================\n end",
"def mi_horario\n\n\tend",
"def semplice\r\n puts \"senza parentesi\"\r\nend",
"def relatorios\n end",
"def extrato\n\n end",
"def agregar_metodo (unaClase,nombre,&bloque)\n if (!unaClase.instance_methods.include?(nombre))\n unaClase.send :define_method, nombre, bloque\n end\n end",
"def metodo\n puts 'metodo'\n end",
"def Nombre\n\t\treturn @name\n\tend",
"def verdi; end",
"def funktionsname\n\tanweisung\nend",
"def nome\n @nome\n end",
"def agregar_docente\n\t\t@seccion = \"Docentes\"\n @titulo = \"Agregar docente\"\n\tend",
"def noun; end",
"def noun; end",
"def nome_perfil\n \tself.descricao\n end",
"def usar_metodo\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n\n return_value = UsarMetodoReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __LPAR157__ = nil\n __RPAR159__ = nil\n qualified_name156 = nil\n parametros158 = nil\n\n\n tree_for_LPAR157 = nil\n tree_for_RPAR159 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 160:4: qualified_name LPAR ( parametros )? RPAR\n @state.following.push( TOKENS_FOLLOWING_qualified_name_IN_usar_metodo_723 )\n qualified_name156 = qualified_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, qualified_name156.tree )\n end\n\n __LPAR157__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_usar_metodo_725 )\n if @state.backtracking == 0\n tree_for_LPAR157 = @adaptor.create_with_payload( __LPAR157__ )\n @adaptor.add_child( root_0, tree_for_LPAR157 )\n\n end\n\n # at line 160:24: ( parametros )?\n alt_21 = 2\n look_21_0 = @input.peek( 1 )\n\n if ( look_21_0 == COMILLA || look_21_0.between?( DOUBLEDOT, DecimalLiteral ) || look_21_0 == Identificador || look_21_0.between?( T__81, T__82 ) )\n alt_21 = 1\n end\n case alt_21\n when 1\n # at line 160:24: parametros\n @state.following.push( TOKENS_FOLLOWING_parametros_IN_usar_metodo_727 )\n parametros158 = parametros\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, parametros158.tree )\n end\n\n\n end\n __RPAR159__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_usar_metodo_730 )\n if @state.backtracking == 0\n tree_for_RPAR159 = @adaptor.create_with_payload( __RPAR159__ )\n @adaptor.add_child( root_0, tree_for_RPAR159 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\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\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\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 32 )\n\n\n end\n\n return return_value\n end",
"def get_nombre # definicion del metodo get para el nombre no esperamos ningun argumento \n @nombre # hacemos un return de la variable, la variable como atributo hasta que nosotros usamos @nombre por primera vez\n end",
"def e010_nome(pedido)\n return \"%-100s\" % remover_acentos(pedido.pessoa.nome.upcase)\n end",
"def get_nombre; @nombre; end",
"def nome\n @nome\n end",
"def priority_note; super; end",
"def nombre\n\t\t@nombre\n\tend",
"def name\n nome\n end",
"def ino() end",
"def main_description; end",
"def the_doctor; end",
"def full_descripcion \n \"#{asunto.nombre} - \"+\"#{nombre}\" \n end",
"def child_node; end",
"def nombre\r\n return @nombre\r\n \r\n end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def nombre_completo\n\t\t\"#{nombre} #{apellido}\"\n\tend",
"def description\n \"#{super} - Tramezzino\"\n end",
"def nombre_y_apellido \n primer_nombre + ' ' + primer_apellido\n end",
"def set_nodo\n @nodo = Nodo.find(params[:id])\n end",
"def motto; end",
"def somme\n fail \"Doit etre defini dans la sous-classe\"\n end",
"def nome\n @nome \n end",
"def nasa_space_craft; end",
"def forkless(interspinous_interdevour, cladodontid_michel)\n end",
"def sub_e\n end",
"def extra=(_arg0); end",
"def objet_designation\n \"Objet de classe #{objet.class} et d'ID ##{objet.id}\"\n 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 ano_eleicao\n puts \"esta eleição esta acontecendo no ano de #{@ano}\"\n \n end",
"def entry; end"
] |
[
"0.65126777",
"0.6200819",
"0.61943936",
"0.6159478",
"0.61465544",
"0.61164594",
"0.6062954",
"0.59990954",
"0.5984348",
"0.5984348",
"0.5984348",
"0.59673977",
"0.5958856",
"0.58051735",
"0.5801822",
"0.5801822",
"0.5748059",
"0.5747469",
"0.57197785",
"0.57197785",
"0.57197785",
"0.57197785",
"0.5693061",
"0.568724",
"0.568251",
"0.5679098",
"0.56765544",
"0.56670284",
"0.5628201",
"0.5593722",
"0.5589424",
"0.5571253",
"0.55674523",
"0.5544531",
"0.5540445",
"0.55254495",
"0.55203944",
"0.55198526",
"0.5519089",
"0.55113286",
"0.5504437",
"0.55039096",
"0.5475348",
"0.5475348",
"0.5457719",
"0.54558897",
"0.54486823",
"0.5437703",
"0.5432838",
"0.5429701",
"0.5428399",
"0.5407834",
"0.5406941",
"0.5397136",
"0.5392121",
"0.5387728",
"0.53870726",
"0.5385114",
"0.53845847",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5381297",
"0.5379999",
"0.5379616",
"0.5375452",
"0.5370014",
"0.53624994",
"0.5362221",
"0.5354658",
"0.5335337",
"0.53326184",
"0.5332373",
"0.5329111",
"0.5326736",
"0.5323963",
"0.53238505",
"0.5323108"
] |
0.0
|
-1
|
Metodo extraer nodo por cola
|
def extraer_por_cola
if(@tail==nil)
puts "No hay nada que extraer (lista vacia)"
else
aux=@tail
@tail=@tail.prev
aux.prev=nil
if(@tail!=nil)
@tail.nest=nil
end
end
return aux
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def metodo\n #corpo do metodo\n puts 'corpo do metodo'\n end",
"def metodo\n #corpo do metodo\n puts 'corpo do metodo'\n end",
"def metodo\n #corpo do metodo\n puts 'corpo do metodo'\n end",
"def sonido()\n return super << \" miaaauuu\"\n end",
"def donizetti; end",
"def extraer_elemento\n \n @nodo = Nodo_.new(nil, @head.value, nil)\n \n @head = @head.next\n @head.prev = nil\n return @nodo\n \n #nodo = @head\n #if @head.next == nil\n # @head = nil\n # else\n # @head = @head.next\n #end\n #return nodo\n \n #nodo = @head\n #@head = @head.next\n \n #nodo.next = nil\n #nodo.prev = nil\n \n #if @head == nil\n # @tail = nil\n #end\n \n #return nodo\n end",
"def metodo\n puts 'metodo'\n end",
"def asignar_titulo_propiedad()\n \n end",
"def noun; end",
"def noun; end",
"def nombre_completo\n\tprimer_nombre+\" \"+primer_apellido\n#fin del metodo\nend",
"def sigla; @nome; end",
"def extra; end",
"def metodo_publico\n puts \"\\nmétodo privado\"\n end",
"def nosotros\n end",
"def e010_nome(pedido)\n return \"%-100s\" % remover_acentos(pedido.pessoa.nome.upcase)\n end",
"def agregar_docente\n\t\t@seccion = \"Docentes\"\n @titulo = \"Agregar docente\"\n\tend",
"def suivre; end",
"def terpene; end",
"def titulo\n return nil\n end",
"def titulo\n return nil\n end",
"def set_nodo\n @nodo = Nodo.find(params[:id])\n end",
"def forkless(interspinous_interdevour, cladodontid_michel)\n end",
"def nodoc\n @hide_commands_without_desc and description.nil?\n end",
"def motto; end",
"def nome_proprio\nStringFix.nome_proprio(self)\nend",
"def extrato\n\n end",
"def mi_carrera\n\n\tend",
"def nombre_y_apellido \n primer_nombre + ' ' + primer_apellido\n end",
"def nn\n end",
"def metodo\n puts \"Hola metodo 2\"\nend",
"def traktiNodon(nod, stato)\n\n objekto = {\"tipo\" => nod.name, \"filoj\" => [], \"tradukoj\" => {}, \"filNombro\" => 0}\n stato[\"super\"] << nod.name\n\n miaMarko = false\n\n if nod[\"mrk\"] != nil\n objekto[\"mrk\"] = nod[\"mrk\"]\n stato[\"marko\"] << nod[\"mrk\"]\n miaMarko = true\n end\n\n teksto = \"\"\n \n nod.children().each do |fil|\n\n if fil.name == \"kap\"\n novaKapo = traktiKapon(fil, stato)\n objekto[\"nomo\"] = novaKapo[\"nomo\"]\n objekto[\"tildo\"] = novaKapo[\"tildo\"]\n objekto[\"kapo\"] = novaKapo\n if nod.name == \"drv\"\n # Registri tradukojn en esperanton\n\t for nom in objekto[\"nomo\"].split(\", \")\n\t @esperantaj << fariSerchTradukon(nom, nom, stato[\"nomo\"], stato[\"artikolo\"][\"indekso\"], stato[\"marko\"].last, 0)\n\t end\n end\n elsif fil.name == \"uzo\"\n novaUzo = traktiUzon(fil, stato)\n \t if objekto[\"uzoj\"] == nil\n\t objekto[\"uzoj\"] = []\n\t end\n\t objekto[\"uzoj\"] << novaUzo\n elsif fil.name == \"gra\"\n fil.children().each do |fil2|\n if fil2.name == \"vspec\"\n objekto[\"vspec\"] = fil2.text\n end\n end\n elsif fil.name == \"subart\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"drv\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"subdrv\"\n objekto[\"filNombro\"] += 1\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n elsif fil.name == \"snc\"\n objekto[\"filNombro\"] += 1\n stato[\"senco\"] = objekto[\"filNombro\"]\n novaSenco = traktiNodon(fil, stato)\n objekto[\"filoj\"] << novaSenco\n if novaSenco[\"mrk\"] != nil\n @indikiloDeMarko[novaSenco[\"mrk\"]] = objekto[\"filNombro\"].to_s\n end\n stato[\"senco\"] = 0\n elsif fil.name == \"subsnc\"\n objekto[\"filNombro\"] += 1\n novaSubSenco = traktiNodon(fil, stato)\n objekto[\"filoj\"] << novaSubSenco\n if novaSubSenco[\"mrk\"] != nil\n litero = (\"a\"..\"z\").to_a[objekto[\"filNombro\"]-1]\n numero = stato[\"senco\"].to_s + litero\n @indikiloDeMarko[novaSubSenco[\"mrk\"]] = numero\n end\n elsif fil.name == \"dif\"\n novaDifino = traktiDifinon(fil, stato)\n objekto[\"filoj\"] << novaDifino\n elsif fil.name == \"rim\"\n novaRimarko = traktiRimarkon(fil, stato)\n objekto[\"filoj\"] << novaRimarko\n elsif fil.name == \"ref\"\n stato[\"refspac\"] = objekto[\"filoj\"].count > 0\n novaRefo = traktiRefon(fil, stato)\n objekto[\"filoj\"] << novaRefo\n elsif fil.name == \"refgrp\"\n stato[\"refspac\"] = objekto[\"filoj\"].count > 0\n novaRefgrupo = traktiRefgrupon(fil, stato)\n objekto[\"filoj\"] << novaRefgrupo\n elsif fil.name == \"ekz\"\n novaEkzemplo = traktiEkzemplon(fil, stato)\n #teksto += novaEkzemplo[\"teksto\"]\n\t objekto[\"filoj\"] << novaEkzemplo\n elsif fil.name == \"trd\"\n traktiTradukon(fil, stato)\n elsif fil.name == \"trdgrp\"\n traktiTradukGrupon(fil, stato)\n elsif fil.name == \"text\"\n #puts \"teksto: \" + fil.text + \"|\"\n #objekto[\"filoj\"] << {\"tipo\" => \"teksto\", \"teksto\" => fil.text}\n elsif fil.name == \"frm\"\n novaFormulo = traktiFormulon(fil, stato)\n\t teksto += novaFormulo[\"teksto\"]\n else\n objekto[\"filoj\"] << traktiNodon(fil, stato)\n end\n end\n\n for fil in objekto[\"filoj\"]\n if fil[\"teksto\"] != nil\n if fil[\"tipo\"] == \"refo\" or fil[\"tipo\"] == \"refgrupo\"\n\t teksto += \" \"\n\t end\n teksto += fil[\"teksto\"]\n end\n end\n\n # atendu ghis la fino de drv antau enmeti tradukojn el ekzemploj -\n # tiuj ghenerale rilatas al dirajhoj, ke ne estas baza vortoj por serchi\n if stato[\"super\"].count == 1 and stato[\"ekzTradukoj\"] != []\n for lng, tradoj in stato[\"ekzTradukoj\"]\n for trad in tradoj\n\t stato[\"artikolo\"][\"tradukoj\"][lng] << trad\n\t end\n end\n\n stato[\"ekzTradukoj\"] = {}\n end\t \t \n\n if miaMarko then stato[\"marko\"].pop end\n\n #objekto[\"teksto\"] = teksto\n stato[\"super\"].pop\n return objekto\nend",
"def oknodo\n @commands_and_opts.push OPTIONAL_OPTS[:oknodo]\n self\n end",
"def priority_note; super; end",
"def ino() end",
"def description\n super + \", Whip\"\n end",
"def texte_aide\n <<-EOT\n=== Aide pour les tâches ===\\033[0m\n\nAjouter une tâche (avec ou sans description)\n #{jaune('add \"<tâche>\"[ \"description\"][ <priorité>]')}\n La priorité est un nombre de 0 (aucune priorité) à\n 9 (priorité maximale).\n\nMarquer une tâche finie\n #{jaune('close/done <id tâche>')}\n\nVoir toutes les informations de la tâche\n #{jaune('show <id tâche>')}\n\n(Re)définir les attributs d'une tâche\n #{jaune('set <id tâche> m=\"contenu\" d=\"description\" p=[0-9]')}\n p pour la priorité (0 par défaut)\n\nDétruire une tâche\n #{jaune('remove/delete <id tâche>')}\n\nQuitter\n #{jaune('q/quit/quitter')}\n\n EOT\n end",
"def wine_comment\n end",
"def konversiMenit(menit) \n # =================================\n # Area Kode Kode di sini\n \n \n \n # =================================\n end",
"def nature; end",
"def ano_eleicao\n puts \"esta eleição esta acontecendo no ano de #{@ano}\"\n \n end",
"def relatorios\n end",
"def main_description; end",
"def description\n \"#{super} - Tramezzino\"\n end",
"def notes; end",
"def notes; end",
"def notes; end",
"def semplice\r\n puts \"senza parentesi\"\r\nend",
"def toronto\n\n end",
"def dish; end",
"def specialty; end",
"def metodo\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 58 )\n\n\n return_value = MetodoReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_DEF312__ = nil\n __K_VOID313__ = nil\n __Identificador314__ = nil\n __LPAR315__ = nil\n __RPAR317__ = nil\n __LLAIZQ318__ = nil\n __LLADER320__ = nil\n parametros_tipos316 = nil\n bodyexp319 = nil\n\n\n tree_for_K_DEF312 = nil\n tree_for_K_VOID313 = nil\n tree_for_Identificador314 = nil\n tree_for_LPAR315 = nil\n tree_for_RPAR317 = nil\n tree_for_LLAIZQ318 = nil\n tree_for_LLADER320 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 263:4: K_DEF K_VOID Identificador LPAR ( parametros_tipos )? RPAR LLAIZQ bodyexp LLADER\n __K_DEF312__ = match( K_DEF, TOKENS_FOLLOWING_K_DEF_IN_metodo_1308 )\n if @state.backtracking == 0\n tree_for_K_DEF312 = @adaptor.create_with_payload( __K_DEF312__ )\n @adaptor.add_child( root_0, tree_for_K_DEF312 )\n\n end\n\n __K_VOID313__ = match( K_VOID, TOKENS_FOLLOWING_K_VOID_IN_metodo_1310 )\n if @state.backtracking == 0\n tree_for_K_VOID313 = @adaptor.create_with_payload( __K_VOID313__ )\n @adaptor.add_child( root_0, tree_for_K_VOID313 )\n\n end\n\n __Identificador314__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_metodo_1312 )\n if @state.backtracking == 0\n tree_for_Identificador314 = @adaptor.create_with_payload( __Identificador314__ )\n @adaptor.add_child( root_0, tree_for_Identificador314 )\n\n end\n\n __LPAR315__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_metodo_1314 )\n if @state.backtracking == 0\n tree_for_LPAR315 = @adaptor.create_with_payload( __LPAR315__ )\n @adaptor.add_child( root_0, tree_for_LPAR315 )\n\n end\n\n # at line 263:36: ( parametros_tipos )?\n alt_43 = 2\n look_43_0 = @input.peek( 1 )\n\n if ( look_43_0 == TIPO )\n alt_43 = 1\n end\n case alt_43\n when 1\n # at line 263:36: parametros_tipos\n @state.following.push( TOKENS_FOLLOWING_parametros_tipos_IN_metodo_1316 )\n parametros_tipos316 = parametros_tipos\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, parametros_tipos316.tree )\n end\n\n\n end\n __RPAR317__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_metodo_1319 )\n if @state.backtracking == 0\n tree_for_RPAR317 = @adaptor.create_with_payload( __RPAR317__ )\n @adaptor.add_child( root_0, tree_for_RPAR317 )\n\n end\n\n __LLAIZQ318__ = match( LLAIZQ, TOKENS_FOLLOWING_LLAIZQ_IN_metodo_1321 )\n if @state.backtracking == 0\n tree_for_LLAIZQ318 = @adaptor.create_with_payload( __LLAIZQ318__ )\n @adaptor.add_child( root_0, tree_for_LLAIZQ318 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_bodyexp_IN_metodo_1323 )\n bodyexp319 = bodyexp\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, bodyexp319.tree )\n end\n\n __LLADER320__ = match( LLADER, TOKENS_FOLLOWING_LLADER_IN_metodo_1325 )\n if @state.backtracking == 0\n tree_for_LLADER320 = @adaptor.create_with_payload( __LLADER320__ )\n @adaptor.add_child( root_0, tree_for_LLADER320 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\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\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\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 58 )\n\n\n end\n\n return return_value\n end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def troop; end",
"def actionNom\n\t\treturn \"Acheter potion (100or)\"\n\tend",
"def headline; end",
"def nebula; end",
"def node_entry\n \"node #{name}\"\n end",
"def usar_metodo\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n\n return_value = UsarMetodoReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __LPAR157__ = nil\n __RPAR159__ = nil\n qualified_name156 = nil\n parametros158 = nil\n\n\n tree_for_LPAR157 = nil\n tree_for_RPAR159 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 160:4: qualified_name LPAR ( parametros )? RPAR\n @state.following.push( TOKENS_FOLLOWING_qualified_name_IN_usar_metodo_723 )\n qualified_name156 = qualified_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, qualified_name156.tree )\n end\n\n __LPAR157__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_usar_metodo_725 )\n if @state.backtracking == 0\n tree_for_LPAR157 = @adaptor.create_with_payload( __LPAR157__ )\n @adaptor.add_child( root_0, tree_for_LPAR157 )\n\n end\n\n # at line 160:24: ( parametros )?\n alt_21 = 2\n look_21_0 = @input.peek( 1 )\n\n if ( look_21_0 == COMILLA || look_21_0.between?( DOUBLEDOT, DecimalLiteral ) || look_21_0 == Identificador || look_21_0.between?( T__81, T__82 ) )\n alt_21 = 1\n end\n case alt_21\n when 1\n # at line 160:24: parametros\n @state.following.push( TOKENS_FOLLOWING_parametros_IN_usar_metodo_727 )\n parametros158 = parametros\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, parametros158.tree )\n end\n\n\n end\n __RPAR159__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_usar_metodo_730 )\n if @state.backtracking == 0\n tree_for_RPAR159 = @adaptor.create_with_payload( __RPAR159__ )\n @adaptor.add_child( root_0, tree_for_RPAR159 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\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\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\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 32 )\n\n\n end\n\n return return_value\n end",
"def prepend_kontena_cli(tree)\n [:Kontena, :Cli] + (tree - [:Cli])\n end",
"def mi_horario\n\n\tend",
"def preencher\n nome.set 'leticia'\n \n end",
"def nasa_space_craft; end",
"def initialize(nodo, izquierdo=nil, derecho=nil)\n\t\t@nodo = nodo\n\t\t@izquierdo = izquierdo\n\t\t@derecho = derecho\n\tend",
"def private_notes\n \n end",
"def extra; @extra; end",
"def the_doctor; end",
"def get_nombre # la convencion de ruby es def nombre\n @nombre # el nombre es implicito\n end",
"def quando_incluso(*args)\n end",
"def agregar_metodo (unaClase,nombre,&bloque)\n if (!unaClase.instance_methods.include?(nombre))\n unaClase.send :define_method, nombre, bloque\n end\n end",
"def get_title(n)\n description = Nokogiri::HTML(@description_xpath[n].text).text\n if description.include?(\"IF YOU GO\")\n description = description.split(\"IF YOU GO\")[1]\n if description.include?(\"Where\")\n title = description.split(\"Where\")[0]\n # Title must fit on single line\n title.gsub!(\"\\n\", \" \").strip!\n title\n else\n super(n)\n end\n else\n super(n)\n end\n end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end"
] |
[
"0.6318074",
"0.6318074",
"0.6318074",
"0.6210854",
"0.60286134",
"0.59805936",
"0.5865697",
"0.58568704",
"0.5832501",
"0.5832501",
"0.5824129",
"0.5805948",
"0.5756682",
"0.57355636",
"0.5728636",
"0.5644247",
"0.5642884",
"0.55677015",
"0.5548537",
"0.5533236",
"0.5533236",
"0.55186206",
"0.54866636",
"0.547717",
"0.5462384",
"0.54420334",
"0.5427831",
"0.54273456",
"0.5426403",
"0.54133415",
"0.54041356",
"0.5403864",
"0.5379028",
"0.53722525",
"0.537204",
"0.5365266",
"0.53628004",
"0.5360548",
"0.53573936",
"0.5356207",
"0.53509873",
"0.53503364",
"0.5344373",
"0.5340485",
"0.5336228",
"0.5336228",
"0.5336228",
"0.5327206",
"0.53244066",
"0.53223723",
"0.5310201",
"0.5302191",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.5298179",
"0.52957994",
"0.5291239",
"0.52828246",
"0.5280407",
"0.5279844",
"0.52725935",
"0.5256788",
"0.5253187",
"0.5250137",
"0.5250006",
"0.5248665",
"0.5233133",
"0.5229044",
"0.52280575",
"0.52157354",
"0.52100456",
"0.5207719",
"0.519246",
"0.51840365",
"0.51840365",
"0.51840365",
"0.51840365"
] |
0.0
|
-1
|
Metodo convertir a cadena
|
def to_s
puntero=@head
cadena='['
if(@head!=nil)
while (puntero!= nil) do
cadena+=puntero.value.to_s + ']'
if(puntero.nest!=nil)
puntero=puntero.nest
cadena+= '['
else
puntero=nil
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pasar_cadena(cadena)\n letra = \"\"\n i = 0\n aux =\"\"\n \n cadena.bytes do |c|\n # 32 es el espacio Se pone un 0 para que se de 8 bit\n i = i + 1\n if( i==8) then\n aux << c\n letra << aux.to_i(2).chr\n aux =\"\"\n i=0\n elsif \n \n aux << c\n \n end\n \n # binario << \"0\" + c.to_s(2)\n end\n return letra\n end",
"def cobranca_interna_formatada\n\t\t\t\tcobranca_interna = { '21' => '21 – Cobrança Interna Com Registro', '22' => '22 – Cobrança Interna sem registro' }\n\t\t\t\tcobranca_interna[carteira.to_s]\n\t\t\tend",
"def cad(cents); end",
"def iconv() end",
"def ubicacion2(cadena)\n cad=cadena.split(/\\s|,/)\n cad[0]=cad[0].to_i\n cad[1]=cad[1].to_i\n return cad #[2,2,\"S\"]\nend",
"def as_ca_dollar\n exchange_to(\"CAD\")\n end",
"def as_ca_dollar\n exchange_to(\"CAD\")\n end",
"def as_ca_dollar\n exchange_to(\"CAD\")\n end",
"def as_ca_dollar\n exchange_to(\"CAD\")\n end",
"def to_cdfa\n fa.to_cdfa\n end",
"def as_euro; end",
"def special2csa(str)\n {\n '中断' => 'CHUDAN',\n '投了' => 'TORYO',\n '持将棋' => 'JISHOGI',\n '千日手' => 'SENNICHITE',\n '詰み' => 'TSUMI',\n '不詰' => 'FUZUMI',\n '切れ負け' => 'TIME_UP',\n '反則勝ち' => 'ILLEGAL_ACTION', # 直前の手が反則(先頭に+か-で反則した側の情報を含める必要が有る)\n '反則負け' => 'ILLEGAL_MOVE' # ここで手番側が反則,反則の内容はコメントで表現\n }[str] || (raise ParseError)\n end",
"def kind2csa(kind)\n if kind[0] == '成'\n {\n '香' => 'NY',\n '桂' => 'NK',\n '銀' => 'NG'\n }[kind[1]]\n else\n {\n '歩' => 'FU',\n '香' => 'KY',\n '桂' => 'KE',\n '銀' => 'GI',\n '金' => 'KI',\n '角' => 'KA',\n '飛' => 'HI',\n '玉' => 'OU',\n '王' => 'OU',\n 'と' => 'TO',\n '杏' => 'NY',\n '圭' => 'NK',\n '全' => 'NG',\n '馬' => 'UM',\n '竜' => 'RY',\n '龍' => 'RY'\n }[kind]\n end\n end",
"def as_ca_dollar; end",
"def convertDecades(decade=\"\") \n\t decade.gsub!(\"s\",\"\")\n\t decadeInt = decade.to_i + 9\n\t \"#{decade}-#{decadeInt.to_s}\"\n\tend",
"def codon_to_char(codon)\n # the whole \"code\" is really redundant, so the original character\n # can be derived from the first character of the codon\n ((codon.chars.first.to_i(BASE) - CHAR_OFFSET) % BASE).to_s(BASE)\n end",
"def currency()\n return \" ש\\\"ח\"\n end",
"def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # digito agencia 1\n # conta corrente 8\n # digito da conta 1\n # numero convenio 6\n cc = conta_corrente.to_s.rjust(8, '0')\n \"#{agencia}#{agencia_dv}#{cc}#{conta_corrente_dv}#{''.rjust(6, '0')}\"\n end",
"def from_french(num)\nend",
"def getASCII(c)\n c.ord\nend",
"def spanish_foreign_citizen_number; end",
"def to_geo\n self.translate(KA, GEO)\n end",
"def çς\n \"Magnitude\"\n end",
"def convert(degree_fahrenheit)\n \n degree_celius = (degree_fahrenheit - 32)/1.8\n\nend",
"def cambia_especiales(txt, ind)\n ret = txt\n if ind == true\n ret.gsub!(\"+\",\"-\")\n ret.gsub!(\"/\",\"_\")\n ret.gsub!(\"=\",\".\")\n else\n ret.gsub!(\"-\",\"+\")\n ret.gsub!(\"_\",\"/\")\n ret.gsub!(\".\",\"=\")\n end\n return ret\n end",
"def iso_code; end",
"def iso_code; end",
"def to_clp\n val = self.gsub(/[\"]/,\"\\\"\\\"\")\n #val = val.gsub(/[~]/,\"\")\n end",
"def english_character_to_braille(text)\n convert_braille_matrix_to_string.each do |initial, conversion|\n text.gsub!(initial, conversion)\n end\n end",
"def translate(codon)\n x = Bio::Sequence::NA.new(codon)\n a = x.translate # or a = x.translate.codes \n return a\nend",
"def cyc\n CYC\n end",
"def e010_cep(pedido)\n return \"%08d\" % 13073340\n end",
"def convert\n ocr_arr = build_ocr_arr\n # puts \"ocr_arr == #{ocr_arr}\"\n ocr_arr.map do |ocr_char|\n # puts \"ocr_char ==\\n#{ocr_char}\"\n raise InvalidInputError unless valid?(ocr_char)\n if OCR_CHARS.include?(ocr_char)\n ocr_char == ',' ? ocr_char : OCR_CHARS.index(ocr_char).to_s\n else\n '?'\n end\n end.join\n end",
"def çς\n \"±Magnitude\"\n end",
"def caesar_decode(word,offset)\n caesar_encode(word,offset*-1)\nend",
"def Mayuscula_Cadena\n print \"Ingrese su cadena: \"\n cadena = gets.chomp\n puts cadena.upcase\n end",
"def spanish_citizen_number; end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def currency_denoted\n '$'\n end",
"def convert_map_coordinate(map_coordinate)\n coordinate = map_coordinate.to_s # in case it was a symbol\n # converts first character \"ABCDEFGHIJ\" <=> \"0123456789\"\n one = coordinate[0]\n two = coordinate[1,2]\n\n if one.ord < \"A\".ord\n # \"00\"..\"09\" to \"A1\"..\"J1\"\n two = (two.ord + 17).chr # convert digits to characters\n one = (one.to_i + 1).to_s\n coordinate = (two + one).to_sym\n else\n one = (one.ord - 17).chr # convert characters to digits\n two = (two.to_i - 1).to_s\n coordinate = two + one # allows A1 J1 map to 00..09\n end\n return coordinate\nend",
"def word2\n return ($en_cz == 'Y') ? @czech : @english\n end",
"def convert(degrees_fahrenheit)\n celsius = (degrees_fahrenheit.to_f - 32) * 5/9\nend",
"def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # complemento 2\n # conta corrente 5\n # digito da conta 1\n # complemento 8\n \"#{agencia}00#{conta_corrente}#{digito_conta}#{''.rjust(8, ' ')}\"\n end",
"def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # complemento 2\n # conta corrente 5\n # digito da conta 1\n # complemento 8\n \"#{agencia}00#{conta_corrente}#{digito_conta}#{''.rjust(8, ' ')}\"\n end",
"def to_celsius(**options) = convert_to('celsius', **options)",
"def genclase\n \"M\"\n end",
"def to_char(c)\n CHARSET.at(to_integer(c))\n end",
"def convert\n match('term', 'name')\n\n # API-specific parameters.\n equal('key', 'open_duka_api_key')\n\n output\n end",
"def format_fecha_conversion(fecha)\n unless fecha.to_s ==''\n\n if I18n.locale.to_s==\"es\" || I18n.locale.to_s==\"fr\" || I18n.locale.to_s==\"ar\" || I18n.locale.to_s==\"cs\" || I18n.locale.to_s==\"da\" || I18n.locale.to_s==\"de\" || I18n.locale.to_s==\"fi\" || I18n.locale.to_s==\"hu\" || I18n.locale.to_s==\"it\" || I18n.locale.to_s==\"ru\" || I18n.locale.to_s==\"nl\" || I18n.locale.to_s==\"pl\" || I18n.locale.to_s==\"pt\" || I18n.locale.to_s==\"sl\" || I18n.locale.to_s==\"sv\"\n fecha_busqueda = fecha[6,4].to_s + '-' + fecha[3,2].to_s + '-' + fecha[0,2].to_s\n elsif I18n.locale.to_s==\"ja\"\n fecha_busqueda = fecha[0,4].to_s + '-' + fecha[5,2].to_s + '-' + fecha[8,2].to_s\n else\n fecha_busqueda = fecha[6,4].to_s + '-' + fecha[0,2].to_s + '-' + fecha[3,2].to_s\n end\n\n else\n fecha_busqueda = \"\"\n end\n end",
"def convert(fahrenheit)\n celsius = (5 * (fahrenheit - 32))/9\nend",
"def accents\n @input = @input.unicode_normalize(:nfd).gsub(/\\p{M}/,'')\n end",
"def toutf16; Kconv.toutf16(self) end",
"def c_name_to_ruby(name)\r\n name.to_s.\r\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\r\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\r\n tr('-', '_').\r\n gsub(/\\s/, '_').\r\n gsub(/__+/, '_').\r\n gsub(/^SU_/, \"\").\r\n gsub(/3_D/, \"3d\").\r\n gsub(/2_D/, \"2d\").\r\n downcase\r\nend",
"def convert_tocelsius(fahrenheit)\n # return (fahrenheit - 32) * (5/9)\n return fahrenheit*5/9 - 32*5/9 \nend",
"def convert(value) value end",
"def convert\n end",
"def convert\n end",
"def as_ca_euro\n exchange_to(\"EUR\")\n end",
"def relacion_cc\n\t\t(ccintura / ccadera).round(2)\n\tend",
"def copia_mapa(mapa)\n novo_mapa = mapa.join(\"\\n\").tr(\"F\", \" \").split \"\\n\"\n\n return novo_mapa\nend",
"def canolical(palabra)\n#convierte string a array y ordena las letras alfabeticamente\n palabra.split('').sort.join\nend",
"def dean_label\n 'děkan'\n end",
"def db2disco_parse(data)\n\t\tres = data.split(\"\\x00\")\n\t\t\"#{res[2]}_#{res[1]}\"\n\tend",
"def to_lat\n self.translate(\"#{GEO}#{KA}\", \"#{LAT}#{LAT}\")\n end",
"def convert_encoding(content); end",
"def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # zeros 2\n # conta corrente 7\n # digito da conta 1\n # complemento 6\n \"#{agencia}00#{conta_corrente}#{digito_conta}#{''.rjust(6, ' ')}\"\n end",
"def jal(c)\n\n end",
"def conta_corrente=(valor)\n @conta_corrente = valor.to_s.rjust(8, '0') if valor\n end",
"def tuc(arg)\n h = Hash.[](\".\"=>\"་\", \"/\"=>\"།\", \";\"=>\"༔\", \"\"=>\"\",\n \"ka\"=>\"ཀ\", \"kha\"=>\"ཁ\", \"ga\"=>\"ག\", \"nga\"=>\"ང\",\n \"ca\"=>\"ཅ\", \"cha\"=>\"ཆ\", \"ja\"=>\"ཇ\", \"nya\"=>\"ཉ\",\n \"ta\"=>\"ཏ\", \"tha\"=>\"ཐ\", \"da\"=>\"ད\", \"na\"=>\"ན\",\n \"pa\"=>\"པ\", \"pha\"=>\"ཕ\", \"ba\"=>\"བ\", \"ma\"=>\"མ\",\n \"tsa\"=>\"ཙ\", \"tsha\"=>\"ཚ\", \"dza\"=>\"ཛ\", \"wa\"=>\"ཝ\",\n \"zha\"=>\"ཞ\", \"za\"=>\"ཟ\", \"'a\"=>\"འ\", \"ya\"=>\"ཡ\",\n \"ra\"=>\"ར\", \"la\"=>\"ལ\", \"sha\"=>\"ཤ\", \"sa\"=>\"ས\",\n \"ha\"=>\"ཧ\", \"a\"=>\"ཨ\",\n # numbers !!! better include number_generator\n \"0\"=>\"༠\", \"1\"=>\"༡\", \"2\"=>\"༢\", \"3\"=>\"༣\",\n \"4\"=>\"༤\", \"5\"=>\"༥\", \"6\"=>\"༦\", \"7\"=>\"༧\",\n \"8\"=>\"༨\", \"9\"=>\"༩\",\n # vowel signs\n \".e\"=>\"ེ\", \".i\"=>\"ི\", \".o\"=>\"ོ\", \".u\"=>\"ུ\",\n # double vowel signs\n \"E\" => \"ཻ\", \"O\" => \"ཽ\",\n # subscribed characters\n \"x_ka\"=>\"ྐ\", \"x_kha\"=>\"ྑ\", \"x_ga\"=>\"ྒ\", \"x_nga\"=>\"ྔ\",\n \"x_ca\"=>\"ྕ\", \"x_cha\"=>\"ྖ\", \"x_ja\"=>\"ྗ\", \"x_nya\"=>\"ྙ\",\n \"x_ta\"=>\"ྟ\", \"x_tha\"=>\"ྐ\", \"x_da\"=>\"ྡ\", \"x_na\"=>\"ྣ\",\n \"x_pa\"=>\"ྤ\", \"x_pha\"=>\"ྥ\", \"x_ba\"=>\"ྦ\", \"x_ma\"=>\"ྨ\",\n \"x_tsa\"=>\"ྩ\", \"x_tsha\"=>\"ྪ\", \"x_dza\"=>\"ྫ\", \"x_wa\"=>\"ྭ\",\n \"x_zha\"=>\"ྮ\", \"x_za\"=>\"ྯ\", \"x_'a\"=>\"ཱ\", \"x_ya\"=>\"ྱ\",\n \"x_ra\"=>\"ྲ\", \"x_la\"=>\"ླ\", \"x_sha\"=>\"ྴ\", \"x_sa\"=>\"ྶ\",\n \"x_ha\"=>\"ྷ\", \"x_a\"=>\"ྸ\",\n # superscribed character\n \"ra_x\"=>\"ར\",\n # revered letters\n \"Ta\"=>\"ཊ\", \"Tha\" => \"ཋ\", \"Da\" => \"ཌ\", \"Na\" => \"ཎ\",\n \"Sha\" => \"ཥ\")\n\n result = h[arg]\n if result != nil\n erg = result\n else\n erg = \"\"\n end\n return erg\n end",
"def char_to_codon(char)\n (1..SIZE).map { |mult|\n offset = mult * CHAR_OFFSET\n encoded_char = (offset + char.to_i(BASE)) % BASE\n encoded_char.to_s(BASE)\n }.join\n end",
"def hecho_en\n 'china'\n end",
"def to_deca\n big_self / DECA\n end",
"def to_ascii!; replace(to_ascii); end",
"def decode_char(input)\n\n input.mark\n first = input.next\n if first.nil?\n input.reset\n return nil\n end\n # check to see if we are dealing with an encoded char\n if first!= \"\\\\\"\n input.reset\n return nil\n end\n second = input.next\n if second.nil?\n input.reset\n return nil\n end\n\n #Check octal codes\n return 0x08.chr if second == \"b\"\n return 0x09.chr if second == \"t\"\n return 0x0a.chr if second == \"n\"\n return 0x0b.chr if second == \"v\"\n return 0x0c.chr if second == \"f\"\n return 0x0d.chr if second == \"r\"\n return 0x22.chr if second == \"\\\"\"\n return 0x27.chr if second == \"\\'\"\n return 0x5c.chr if second == \"\\\\\"\n if second.downcase == \"x\" # Hex encoded value\n temp = ''\n for i in 0..1 do\n c = input.next_hex\n temp << c unless c.nil?\n if c.nil?\n input.reset\n return nil\n end\n end\n i = temp.hex\n begin\n return i.chr(Encoding::UTF_8) if i >= START_CODE_POINT and i <= END_CODE_POINT\n rescue Exception => e\n input.reset\n return nil\n end\n elsif second.downcase == \"u\" # Unicode encoded value\n temp = ''\n for i in 0..3 do\n c = input.next_hex\n temp << c unless c.nil?\n if c.nil?\n input.reset\n return nil\n end\n end\n i = temp.hex\n begin\n return i.chr(Encoding::UTF_8) if i >= START_CODE_POINT and i <= END_CODE_POINT\n rescue Exception => e\n input.reset\n return nil\n end\n elsif input.octal?(second) # Octal encoded value\n temp = second\n c = input.next\n unless input.octal?(c)\n input.push(c)\n else\n temp << c\n c = input.next\n unless input.octal?(c)\n input.push(c)\n else\n temp << c\n end\n end\n # build a number\n i = temp.to_i(8)\n begin\n return i.chr(Encoding::UTF_8) if i >= START_CODE_POINT and i <= END_CODE_POINT\n rescue Exception => e\n input.reset\n return nil\n end\n end\n second\n end",
"def unformat(cnpj)\n cnpj.gsub(/\\D/, '')\n end",
"def anstatauKodo(teksto)\n\n trovoj = teksto.scan(/&(.*?);/)\n if trovoj == nil or trovoj.size <= 0 then return teksto end\n\n for i in 0..trovoj.size do\n \n\ttrov = trovoj[i].to_s[2..-3]\n if @literoj[trov] != nil\n\t teksto.sub!(\"&#{trov};\", @literoj[trov])\n\telse\n\t #puts \"Eraro! Ne trovis [#{trov}]\"\n\tend\n end\n\n teksto = CGI::unescapeHTML(teksto)\n return teksto\nend",
"def lunar_date_in_chinese\n lunar_date = yang_to_nong(@date.year, @date.month, @date.day)\n solar_year = cyclical_year(lunar_date[0]) + '年'\n solar_month = [lunar_date[6] == 1 ? '闰' : '', @@nstr[lunar_date[1]], '月'].join\n solar_day = get_day_in_chinese(lunar_date[2])\n\n {\n :year => @date.year,\n :month => @date.month,\n :day => @date.day,\n :wday => @date.wday,\n :solar_year => solar_year,\n :solar_month => solar_month,\n :solar_day => solar_day,\n :lunar_term => lunar_term,\n :lunar_festival => lunar_festival,\n :solar_festival => solar_festival\n }\n end",
"def convert_to_celsius(fahrenheit)\n \"%.2f\" % ((fahrenheit.to_f-32) * 5 / 9 )\nend",
"def to_century(**options) = convert_to('century', **options)",
"def to_celsius(degree_farhenheit)\n celsius = (degree_farhenheit - 32.0) * 5/9\nend",
"def climate_zone_to_short\n return {\n 'CEC T24-CEC1' => 'CZ01',\n 'CEC T24-CEC2' => 'CZ02',\n 'CEC T24-CEC3' => 'CZ03',\n 'CEC T24-CEC4' => 'CZ04',\n 'CEC T24-CEC5' => 'CZ05',\n 'CEC T24-CEC6' => 'CZ06',\n 'CEC T24-CEC7' => 'CZ07',\n 'CEC T24-CEC8' => 'CZ08',\n 'CEC T24-CEC9' => 'CZ09',\n 'CEC T24-CEC10' => 'CZ10',\n 'CEC T24-CEC11' => 'CZ11',\n 'CEC T24-CEC12' => 'CZ12',\n 'CEC T24-CEC13' => 'CZ14',\n 'CEC T24-CEC14' => 'CZ14',\n 'CEC T24-CEC15' => 'CZ15',\n 'CEC T24-CEC16' => 'CZ16'\n }\n end",
"def co\n field_fetch('CO')\n end",
"def normal_to_C(name)\n name = name.to_s.dup\n\n name.sub!(/==$/, '_equals2')\n name.sub!(/=$/, '_equals')\n name.sub!(/\\?$/, '_p')\n name.sub!(/\\!$/, '_bang')\n\n return name\n end",
"def cosine_to_Earth() \r\n cos( Celes.nut06a(@ajd, 0)[ 1 ] + Celes.obl06(@ajd, 0) ) \r\n end",
"def solve_cypher (phrase, key=3)\n\t\n\t#Array de minusculas\n\tfirst_low=\"a\".ord\n\tlast_low=\"z\".ord\n\n\tarray_low = []\n\twhile first_low <= last_low\n\tarray_low << first_low.chr\n\tfirst_low += 1\n\tend\n\n\t#Array de mayusculas\n\tfirst_upp=\"A\".ord\n\tlast_upp=\"Z\".ord\n\n\tarray_upp = []\n\twhile first_upp <= last_upp\n\tarray_upp << first_upp.chr\n\tfirst_upp += 1\n\tend\n\n\t#Por cada letra del mesaje, se invoca la funcion decode\t\n\titer = 0\n\tresult = ''\n\twhile iter < phrase.length\n\t\t#Comprueba primero minusculas\n\t\titem = decode(phrase[iter], array_low, key)\n\t\t#Despues mayusculas\n\t\titem = decode(item, array_upp, key)\n\t\t#Se concatena en el resultado\n\t\tresult += item\n\t\titer += 1\n\tend\n\treturn result\nend",
"def to_kelvin(**options) = convert_to('kelvin', **options)",
"def _convert_vietnamese_to_english(name)\n if name == nil then return end\n name = name.downcase.strip \n name = name.gsub /[áàảãạâấầẩẫậăắằẳẵặAÀÁẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶ]/, 'a' \n name = name.gsub /[éèẻẽẹêềếểễệEÉÈẺẼẸÊẾỀỂỄỆ]/, 'e' \n name = name.gsub /[íìỉĩịIÍÌỈĨỊ]/, 'i' \n name = name.gsub /[óòỏõọôốồổỗộơớờởỡợOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢ]/, 'o' \n name = name.gsub /[úùủũụưứừửữựÚÙỦŨỤƯỨỪỬỮỰ]/, 'u' \n name = name.gsub /[ýỳỷỹỵÝỲỶỸỴ]/, 'y' \n name = name.gsub /[Đđ]/, 'd' \n name = name.gsub /[^a-zA-Z0-9 ]/, \"\"\n name\n end",
"def convert(str)\n\t\t@result=convert_han(convert_words(str))\n\t\t# @result=convert_words(str)\n\t\t@result.gsub!(\" #%\",\"\")\n\t\t@result.gsub!(\"%# \",\"\")\n\t\t@result\n\tend",
"def convertFahrToCelsius(degrees) \n degrees = (degrees.to_f - 32) * 5 / 9 \nend",
"def to_de(label=nil)\n self.to_euro(label, :precision => 0)\n end",
"def cm_isolatin(text_utf8)\n return Iconv.new('iso-8859-1', 'utf-8').iconv(text_utf8)\n end",
"def to_english\n places = to_s.split(//).collect {|s| s.to_i}.reverse\n name = []\n ((places.length + 2) / 3).times do |p|\n strings = Integer.trio(places[p * 3, 3])\n name.push(MEGAS[p]) if strings.length > 0 and p > 0\n name += strings\n end\n name.push(ONES[0]) unless name.length > 0\n name.reverse.join(\" \")\n end",
"def to_french(string)\nend",
"def translate_data(data)\n if data[0..3] == \"\\x4c\\x6f\\xa7\\x94\"\n # EBCDIC\n data = _ebcdic_to_ascii(data)\n elsif data[0..3] == \"\\x00\\x3c\\x00\\x3f\"\n # UTF-16BE\n data = uconvert(data, 'utf-16be', 'utf-8')\n elsif data.size >= 4 and data[0..1] == \"\\xfe\\xff\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16BE with BOM\n data = uconvert(data[2..-1], 'utf-16be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x3f\\x00\"\n # UTF-16LE\n data = uconvert(data, 'utf-16le', 'utf-8')\n elsif data.size >=4 and data[0..1] == \"\\xff\\xfe\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16LE with BOM\n data = uconvert(data[2..-1], 'utf-16le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\x00\\x3c\"\n # UTF-32BE\n data = uconvert(data, 'utf-32be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x00\\x00\"\n # UTF-32LE\n data = uconvert(data, 'utf-32le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\xfe\\xff\"\n # UTF-32BE with BOM\n data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')\n elsif data[0..3] == \"\\xff\\xfe\\x00\\x00\"\n # UTF-32LE with BOM\n data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')\n elsif data[0..2] == \"\\xef\\xbb\\xbf\"\n # UTF-8 with BOM\n data = data[3..-1]\n else\n # ASCII-compatible\n end\n return data\nend",
"def to_katakana(src)\n src\n .gsub(\"わ゙\",\"ヷ\")\n .gsub(\"い゙\",\"ヸ\")\n .gsub(\"え゙\",\"ヹ\")\n .gsub(\"を゙\",\"ヺ\")\n .tr(\"ぁ-ゖゝゞゟ\",\"ァ-ヶヽヾヿ\")\nend",
"def convert_to_character_code(word)\n code_array = []\n word.each_char do |character|\n character_code = character.ord\n code_array.push(character_code)\n end\n average_code = code_array.inject(0.0) { |sum, el| sum + el } / code_array.size\n average_code = average_code.ceil\nend",
"def processChar(c)\n if @target == 'utf8'\n return LATEX_TO_UTF8[c]\n end\n if @target == 'html'\n return LATEX_TO_HTML_ENTITIES[c]\n end\n if @target == \"mc\"\n return LATEX_TO_MACRONS_CHARACTERS[c]\n end\n end",
"def dna_to_rna(dna)\n dna.tr('T', 'U')\nend",
"def char_to_id(ch); end",
"def hex_to_dez\n self.hex_to_bin.bin_to_dez\n end",
"def braille_to_english(text)\n braille_suite\n braille_string_to_braille_integer(text).each do |line, braille_array|\n convert_braille_by_line(braille_array)\n end\n update_character_horizontal_braille\n replace_braille_char_with_letter\n end"
] |
[
"0.66062087",
"0.6274999",
"0.6262965",
"0.6042937",
"0.592585",
"0.5918859",
"0.5918859",
"0.5918859",
"0.5918859",
"0.5842082",
"0.5799133",
"0.5790587",
"0.57016593",
"0.5669223",
"0.56667763",
"0.5662757",
"0.5631286",
"0.55696297",
"0.5501721",
"0.5468187",
"0.54591894",
"0.54229385",
"0.541817",
"0.5412608",
"0.5407642",
"0.53967863",
"0.53967863",
"0.53954625",
"0.5385945",
"0.5378717",
"0.537816",
"0.5370345",
"0.53486234",
"0.5309613",
"0.5302196",
"0.5298501",
"0.5284074",
"0.5270851",
"0.5262586",
"0.5257602",
"0.5251524",
"0.52503526",
"0.5240932",
"0.5240932",
"0.5234596",
"0.5233005",
"0.5229589",
"0.5228908",
"0.5222847",
"0.52186114",
"0.5210295",
"0.5209697",
"0.51968074",
"0.5187474",
"0.51845056",
"0.5184193",
"0.5184193",
"0.5183042",
"0.51729405",
"0.5166981",
"0.51563746",
"0.51563656",
"0.51554954",
"0.5149784",
"0.514962",
"0.5148202",
"0.5145818",
"0.5137573",
"0.5135882",
"0.51308846",
"0.51270616",
"0.5125506",
"0.5117333",
"0.5116388",
"0.51118785",
"0.50995237",
"0.5098565",
"0.5098493",
"0.5093617",
"0.5088832",
"0.50834274",
"0.50829315",
"0.5080142",
"0.50761986",
"0.50761193",
"0.50734514",
"0.50728023",
"0.5070125",
"0.5057791",
"0.5054276",
"0.5053938",
"0.5052888",
"0.50509745",
"0.50502694",
"0.5041537",
"0.50373363",
"0.5035964",
"0.5026653",
"0.5025198",
"0.502471",
"0.5016458"
] |
0.0
|
-1
|
GET /lists/1 GET /lists/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_list(list_id)\n rest(\"get\", \"lists/#{list_id}\")\n end",
"def get_list(user, list)\n get(\"/#{user}/lists/#{list}.json\")\n end",
"def index\n @list_items = List.find(params[:list_id]).list_items\n\n render json: @list_items\n end",
"def show\n @list = current_project.lists.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list }\n end\n end",
"def index\n @lists = List.all\n render json: @lists\n end",
"def index\n @lists = current_user.lists\n #@lists = List.all\n render json: @lists\n end",
"def index\n @lists = current_project.lists\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lists }\n end\n end",
"def index\n @lists = List.all\n @list = List.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lists }\n end\n end",
"def show\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(params[:list_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_item }\n end\n end",
"def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end",
"def show\n @list = List.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list }\n end\n end",
"def show\n @list = List.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list }\n end\n end",
"def show\n @list = List.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list }\n end\n end",
"def show\n @list = List.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def index\n @tasks = current_user.lists.find(params[:list_id]).tasks\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tasks }\n end\n end",
"def list(id)\n get(\"lists/#{id}\").list\n end",
"def get_lists\n response = rest(\"get\", \"lists\")\n\n return response[\"lists\"]\n end",
"def show\n @list = List.find(params[:id])\n respond_with(@list)\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render json: { status: 200, item: @list } }\n end\n end",
"def get_lists(user)\n get(\"/#{user}/lists.json\")\n end",
"def index\n json_response(@board.lists)\n end",
"def show\n\t\t@list = List.find_by(id: params[:id])\n\t\t@locations = Location.where(list_id: params[:id]).order('id asc')\n\t\tsession[:list_id]= params[:id]\n\n\t\trespond_to do |format|\n\t\t\tformat.html do\n\t\t\t\trender 'show'\n\t\t\tend\n\t\t\tformat.json do\n\t\t\t\trender :json => @list, :except => [:id, :user_id], :include => :locations\n\t\t\tend\n\t\tend\n\tend",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def get_list(id)\n record \"/todos/list/#{id}\"\n end",
"def list\n get('/')\n end",
"def show\n @list = List.find(params[:id])\n end",
"def new\n @list = current_user.lists.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def list\n get()\n end",
"def index\n @lists = List.all\n end",
"def index\n @lists = List.all\n end",
"def index\n @lists = List.all\n end",
"def index\n @lists = List.all\n end",
"def index\n @todo_lists = TodoList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @todo_lists }\n end\n end",
"def index\n @lists = @user.lists\n end",
"def show\n @list = List.find(params[:id])\n\n respond_to do |format|\n\n if !@list.public && @list.user != current_user\n\n format.html { redirect_to lists_url, alert: \"You cannot view that list\" }\n format.json { head :no_content, status: :unauthorized }\n\n else\n format.html # show.html.erb\n format.json { render json: @list }\n end\n\n end\n end",
"def show\n @list = List.find(params[:id])\n end",
"def show\n @list = List.find(params[:id])\n end",
"def lists\n client.get_lists\n end",
"def index\n\t\tu = User.find_by(:id => session[:user_id]) \n\t\tif u \n\t\t\t@lists = u.lists.order('id asc')\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tformat.html do\n\t\t\t\trender 'index'\n\t\t\tend\n\t\t\tformat.json do\n\t\t\t\trender :json => @lists, :except => [:id, :user_id], :include => :locations\n\t\t\tend\n\t\tend\n\tend",
"def index\n @list_items = @list.list_items\n end",
"def index\n @lists = List.inactive.paginate(page: params[:page], per_page: PER_PAGE)\n\n respond_to do |format|\n format.html\n format.json { render json: { status: 200, items: @lists } }\n end\n end",
"def index\n @todos = @list.todos\n render json: @todos\n end",
"def index\n @lists = List.all\n\n end",
"def index(list_name, site_path = '', fields = [])\n url = computed_web_api_url(site_path)\n url = \"#{url}lists/GetByTitle('#{odata_escape_single_quote(list_name)}')/items\"\n url += \"?$select=#{fields.join(\",\")}\" if fields\n\n process_url( uri_escape(url), fields )\n end",
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def index\n\n # Set Filter defaults\n\n if params[ :my_lists ].nil? &&\n params[ :public_lists ].nil? then\n\n params[ :my_lists ] = true\n\n end\n\n if params[ :lang ].nil?\n\n params[ :lang ] = Hash[ Language.all.map { |l| [l.id.to_s, \"1\"] } ]\n\n end\n\n if params[ :sortBy ].nil?\n\n params[ :sortBy ] = 'name'\n params[ :dir ] = 'asc'\n\n end\n\n @lists = List.filter( params, current_user ).page( params[:page] || 1 )\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lists }\n end\n end",
"def set_list\n @list = @lists.find(params[:id])\n end",
"def new\n @list = List.find(params[:id])\n @todolist = @list.todolists.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todolist }\n end\n end",
"def show\n render json: @list_item\n end",
"def find_list\n @list = List.find(params[:id])\n end",
"def show\n @twitter_list = TwitterList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @twitter_list }\n end\n end",
"def create_list(name)\n path = \"lists\"\n params = { list: { name: name }}\n list = request(path, params, :post)\n list_id = list[:id]\n # output full list again\n show_list(list_id)\n end",
"def index\n @listes = Liste.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listes }\n end\n end",
"def show\n @lista = Lista.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lista }\n end\n end",
"def show\n @todo_list = TodoList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=>@todo_list }\n end\n end",
"def lists\n response = get 'lists'\n response.map{|item| Hashie::Mash.new(item)}\n end",
"def show\n @todo_list = TodoList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @todo_list }\n end\n end",
"def find_list\n @list = current_user.lists.find params[:id]\n end",
"def index\n\t\t@list = current_user.lists.find(params[:list_id])\n @todos = @list.todos\n end",
"def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end",
"def index\n @lists = current_user.lists\n end",
"def index\n @lists = current_user.lists\n end",
"def show\n @todo = @list.todos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @todo }\n end\n end",
"def index\n @todos = @list.todos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @todos }\n end\n end",
"def new\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list_item }\n end\n end",
"def getLists()\n url = \"https://api.nytimes.com/svc/books/v3/lists/names.json\"\n params = {}\n self.request(url, params)\n end",
"def show\n @liste = Liste.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @liste }\n end\n end",
"def show\n @list_to_do = ListToDo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_to_do }\n end\n end",
"def index\n @lists = current_user.lists.all\n end",
"def list_items_list(page_id = current_page_id, list_id = current_list_id)\n request \"page/#{page_id}/lists/#{list_id}/items/list\"\n end",
"def show\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list_item }\n end\n end",
"def show\n if user_signed_in?\n @list = List.includes( listeds: [:listable] ).find(params[:id])\n render layout: 'layouts/twoColumn'\n else\n respond_to do |format|\n format.html { redirect_to management_lists_path(:user), notice: 'You must have an account to manage lists' }\n format.json { head :no_content }\n end\n end\n end",
"def load_list(index)\n list = session[:lists][index] if index && session[:lists][index]\n return list if list\n\n session[:error] = \"The specified list was not found.\"\n redirect \"/lists\"\nend",
"def new\n @list = List.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def new\n @list = List.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def new\n @list = List.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list }\n end\n end",
"def index\n @api_v1_shopping_lists = ShoppingList.all\n end",
"def index\n @lists = current_user.lists.includes(:tasks)\n @list_feeds = current_user.list_feeds.eager_build\n respond_with(@lists)\n end",
"def get_list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/\", params)\n end",
"def index\n @watch_lists = WatchList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @watch_lists }\n end\n end",
"def index\n # @playlists = Playlist.all\n # @playlists = @playlists.page(params[:page] || 1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: { playlists: @playlists } }\n end\n end",
"def new\n @list = List.find(params[:list_id])\n @item = @list.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def find_list(id)\n check_token\n response = self.class.get(\"/lists/#{id}\", headers: headers)\n check_and_raise_errors(response)\n Todoable::List.build_from_response(response.parsed_response)\n end",
"def list\n session[:list_type_id] = ListType.find(:first).id if session[:list_type_id] == nil\n @list_items = ListItem.find_all_by_user_id_and_list_type_id(\n session[:user_id], \n session[:list_type_id],\n :order => \"position\") \n if @list_items.size > 0\n @list_item = @list_items.first\n session[:list_item_id] = @list_items.first.id\n else\n session[:list_item_id] = nil\n end\n end",
"def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end",
"def list(*args)\n fail \"Unacceptable HTTP Method #{request.env['REQUEST_METHOD']} for list\" unless request.get?\n {:action => 'list',\n :args => args}\n end",
"def index\n @lists = current.user.list\n end",
"def index\n @lists = @organization.lists.all\n end",
"def index\n @list_items = ListItem.all\n end",
"def index\n @list_items = ListItem.all\n end",
"def get_list(access_token, list_id)\n url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.list'), list_id)\n url = build_url(url)\n response = RestClient.get(url, get_headers(access_token))\n Components::ContactList.create(JSON.parse(response.body))\n end",
"def lists(params = {})\n @api.get(\"#{@api.path}/User/Lists\", params: params)\n end",
"def update\n @list = current_user.lists.find(params[:id])\n @list.update_attributes(params[:list])\n respond_with(@list, :location => my_list_url(@list))\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def set_list\n @list = List.find(params[:id])\n end",
"def get_list_with_http_info(list_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ListsApi.get_list ...'\n end\n # verify the required parameter 'list_id' is set\n if @api_client.config.client_side_validation && list_id.nil?\n fail ArgumentError, \"Missing the required parameter 'list_id' when calling ListsApi.get_list\"\n end\n # resource path\n local_var_path = '/contacts/lists/{listId}'.sub('{' + 'listId' + '}', list_id.to_s)\n\n # query parameters\n query_params = {}\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', 'partner-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 => 'GetExtendedList')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ListsApi#get_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_items(projectid, todolistid)\n get(\"projects/#{projectid}/todolists/#{todolistid}.json\")\n end"
] |
[
"0.8099958",
"0.7619997",
"0.761726",
"0.75235164",
"0.7344148",
"0.73051035",
"0.7288008",
"0.72827184",
"0.7276825",
"0.7225588",
"0.7191228",
"0.7191228",
"0.7191228",
"0.7191228",
"0.7183411",
"0.70508593",
"0.6998307",
"0.6960058",
"0.69095707",
"0.68436193",
"0.6841866",
"0.67955124",
"0.67922306",
"0.6774321",
"0.67737085",
"0.6734134",
"0.664782",
"0.6647463",
"0.66375834",
"0.6630131",
"0.6630131",
"0.6630131",
"0.6630131",
"0.66300124",
"0.66281736",
"0.66249853",
"0.66238487",
"0.66238487",
"0.6621678",
"0.6603326",
"0.660235",
"0.6601921",
"0.65946436",
"0.65865445",
"0.65834713",
"0.65676236",
"0.6559905",
"0.6558541",
"0.6549538",
"0.6542037",
"0.65368164",
"0.65343475",
"0.65328705",
"0.65298444",
"0.6515015",
"0.6510506",
"0.6503932",
"0.65003896",
"0.6499364",
"0.6499053",
"0.6472925",
"0.64679897",
"0.6461007",
"0.6461007",
"0.64265645",
"0.6422106",
"0.6402482",
"0.63712454",
"0.6362532",
"0.6361672",
"0.6358802",
"0.6357442",
"0.6341598",
"0.63413155",
"0.6324848",
"0.6323907",
"0.6323907",
"0.6323907",
"0.631288",
"0.6303218",
"0.6298898",
"0.6286327",
"0.62848",
"0.62724787",
"0.6268944",
"0.62524766",
"0.6252309",
"0.62500846",
"0.6243134",
"0.6241051",
"0.62410396",
"0.62410396",
"0.62342525",
"0.62282234",
"0.62280446",
"0.6216349",
"0.6216349",
"0.6216349",
"0.6216349",
"0.62126356",
"0.618848"
] |
0.0
|
-1
|
Edit takes you TO the form to be edited GET /lists/1/edit
|
def edit
@list = current_user.lists.find params[:list_id]
@item = @list.items.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def edit\n @list = List.find(params[:id])\n end",
"def edit\n @list = List.find(params[:id])\n end",
"def edit\n @list = List.find(params[:id])\n end",
"def editList\n\t\t@list = List.find(params[:id])\n\tend",
"def edit\n\t\t@todolist = Todolist.find(params[:id])\n\tend",
"def edit\n\n end",
"def edit\n # Renders the edit form\n end",
"def edit\n # this allows the user to edit an existing todo item\n # this is done by first finding the the todo items listing params :id\n @listing = Listing.find(params[:id])\n end",
"def edit\r\n end",
"def edit\n\n end",
"def edit\r\n \r\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def update\n\t\t@list = List.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @list.update_attributes(params[:list])\n\t\t\t\tformat.html\t{ redirect_to(root_url) }\n\t\t\t\tformat.xml\t{ head :ok }\n\t\t\telse\n\t\t\t\tformat.html\t{ render :action => \"edit\" }\n\t\t\t\tformat.xml\t{ render :xml => @list.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def edit\n \n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end",
"def edit\n end"
] |
[
"0.86814773",
"0.8553767",
"0.8553767",
"0.8379192",
"0.7918611",
"0.7615994",
"0.7549246",
"0.74886066",
"0.74688184",
"0.74496806",
"0.74235564",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.74207413",
"0.73752326",
"0.73512125",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425",
"0.7307425"
] |
0.8196853
|
4
|
New takes you TO the form to be created Does not create, shows new
|
def new
@list = current_user.lists.find params[:list_id]
@item = @list.items.build
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n\t\t# no code needed here; all handled in the view\n\tend",
"def new\n \n @form =Forms.new \n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n\t\t\n\tend",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end"
] |
[
"0.8284708",
"0.82449496",
"0.80218345",
"0.80218345",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79622835",
"0.79350597",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403",
"0.793403"
] |
0.0
|
-1
|
Actually creates after form is filled out
|
def create
@list = current_user.lists.find params[:list_id]
@item = @list.items.build(item_params)
respond_to do |format|
if @item.save
format.html { redirect_to list_items_path(@list), notice: 'Item was successfully created.' }
#format.json { render :show, status: :created, location: @item }
else
format.html { render :new }
#format.json { render json: @item.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\r\n\r\n\r\n end",
"def create_form\n new_form = Form.create_form(current_user[\"id\"])\n\n if new_form[:status] \n return redirect_to \"/f/#{new_form[:form_code]}/create\"\n end \n end",
"def create\r\n end",
"def create\n \n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n\n\tend",
"def create\n self.done_add_button\n wait_for_ajax\n end",
"def create\n \t\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def create\n\tend",
"def create\n\tend",
"def create\n\tend",
"def create\n\tend",
"def create\n\tend",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n end",
"def create\n @form = Form.new(params[:form])\n\n respond_to do |format|\n if params[:commit] == \"Save\" && @form.save\n user = User.find(Session.find_by_session_id(params[:ssnid]).user_id) \n @form.create_by = user.firstname + ' ' + user.lastname\n @form.create_date = Time.now\n @form.updated_by = user.firstname + ' ' + user.lastname\n @form.updated_date = Time.now\n @form.save\n format.html { redirect_to edit_form_path(@form), notice: 'Form was successfully created.' }\n format.json { render json: @form, status: :created, location: @form }\n else\n format.html { render action: \"new\" }\n format.json { render json: @form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n end",
"def create \n end",
"def create\n @form_template = FormTemplate.find(params[:form_template_id])\n @filled_form = @form_template.filled_forms.create(params[:filled_form].merge(:user_id => current_user.id.to_i))\n\n respond_to do |format|\n if @filled_form.save\n format.html { redirect_to form_templates_path, notice: 'Filled form was successfully created.' }\n format.js { @current_form_template = @form_template; @current_filled_form = @filled_form }\n format.json { render json: @filled_form, status: :created, location: @filled_form }\n else\n format.html { render action: \"new\" }\n format.json { render json: @filled_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts \".............. >>> extraction_form_armms_controller::create \"\n @extraction_form_arm = ExtractionFormArm.new(params[:extraction_form_arm])\n\t@extraction_form = ExtractionForm.find(@extraction_form_arm.extraction_form_id)\n\t@project = Project.find(@extraction_form.project_id)\n\t@error_div = \"validation_message_arms\"\t\n\tif (@saved = @extraction_form_arm.save)\n\t\t@arms = ExtractionFormArm.where(:extraction_form_id => @extraction_form_arm.extraction_form_id)\n\t\t@efid = @extraction_form_arm.extraction_form_id\n\t\t@extraction_form_arm = ExtractionFormArm.new\n\t\t@message_div = \"saved_indicator_arms\"\n\t\t@table_container = \"arms_table\"\n\t\t@table_partial = \"extraction_form_arms/table\"\n\t\t@entry_container = \"new_arm_entry\"\n\t\t@entry_partial = \"extraction_form_arms/form\"\n\t\t@close_window = \"new_arm_entry\"\n\telse\n\t\tproblem_html = create_error_message_html(@extraction_form_arm.errors)\n\t\tflash[:modal_error] = problem_html\n\t\t@error_partial = 'layouts/modal_info_messages'\n\tend\n\trender \"shared/saved.js.erb\"\n end",
"def create\n @form = Form.new(form_params)\n return unless can_form_be_created?(@form)\n @form.created_by = current_user\n @form.form_questions = create_form_questions\n if @form.save\n render :show, status: :created, location: @form\n else\n render json: @form.errors, status: :unprocessable_entity\n end\n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n \n end",
"def create\n #\n end",
"def create\n #\n end",
"def create\n #\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end",
"def create\n\n end"
] |
[
"0.71176445",
"0.7005531",
"0.68967515",
"0.6782489",
"0.67694694",
"0.66864693",
"0.66864693",
"0.66864693",
"0.6662378",
"0.66586185",
"0.664274",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6626749",
"0.6623326",
"0.6623326",
"0.6623326",
"0.6623326",
"0.6623326",
"0.6613486",
"0.6613486",
"0.6613486",
"0.6613486",
"0.6613486",
"0.6613486",
"0.6613486",
"0.6613486",
"0.6604357",
"0.6601818",
"0.65979373",
"0.65979373",
"0.65888",
"0.65735084",
"0.65699714",
"0.65525216",
"0.65525216",
"0.65525216",
"0.65525216",
"0.65420485",
"0.65420485",
"0.65420485",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074",
"0.6532074"
] |
0.0
|
-1
|
Update actually updates the edited form PATCH/PUT /lists/1 PATCH/PUT /lists/1.json
|
def update
@list = current_user.lists.find params[:list_id]
@item = @list.items.find(params[:id])
respond_to do |format|
if @item.update(item_params)
format.html { redirect_to list_items_path(@list), notice: 'Item was successfully updated.' }
#format.json { render :show, status: :ok, location: @item }
else
format.html { render :edit }
#format.json { render json: @item.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @list = List.find(params[:id])\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to management_lists_path, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(_list_params)\n format.html { redirect_to @list, notice: \"List was successfully updated.\" }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@list = List.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @list.update_attributes(params[:list])\n\t\t\t\tformat.html\t{ redirect_to(root_url) }\n\t\t\t\tformat.xml\t{ head :ok }\n\t\t\telse\n\t\t\t\tformat.html\t{ render :action => \"edit\" }\n\t\t\t\tformat.xml\t{ render :xml => @list.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: blog_list_path(@list) }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'The List was updated.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list= List.find(params[:id])\n if @list.update(list_params)\n \tflash[:notice] = \"List successfully updated!\"\n redirect_to list_path(@list)\n else\n render :edit\n flash[:alert] = \"ERROR :(\"\n end\n end",
"def update\n @list = @project.lists.find(params[:id])\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { redirect_to [@project, @list], notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render layout: 'form', action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def update\n @list.update_attributes list_params\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n\n if @list_item.update_attributes(params[:list_item])\n flash[:success] = \"List item was successfully updated.\"\n redirect_to list_path(@list) \n else\n flash[:errror] = \"Unable to update item.\"\n redirect_to edit_list_list_item_path(@list, @list_item)\n end\n end",
"def update\n authorize @list\n\n if @list.update(list_params)\n json_response(@list.decorate, :ok)\n else\n json_response(@list.errors, :unprocessable_entity)\n end\n end",
"def update\n respond_to do |format|\n if @list.update(existing_list_params)\n format.html { redirect_to my_list_path(@list), notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: my_list_path(@list) }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n\n else\n format.html { render :edit }\n\n end\n end\n end",
"def update\n \n list_attributes = params[:list] || params[:check_list]\n \n if @list.update(list_attributes)\n flash[:notice] = t(:list_saved)\n redirect_to @list\n else\n render :action => 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @todo_list.update(todo_list_params)\n format.html { redirect_to root_path, notice: 'Todo list was successfully updated.' }\n format.json { render :show, status: :ok, location: @todo_list }\n else\n format.html { render :edit }\n format.json { render json: @todo_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list_item, notice: 'List item was successfully updated.' }\n format.json { render json: @list_item, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to list_path(@list), notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n prepare_form\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'Os dados do funcionario foram atualizados com sucesso.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = current_user.lists.find(params[:id])\n @list.update_attributes(params[:list])\n respond_with(@list, :location => my_list_url(@list))\n end",
"def update\n \n @list_item = ListItem.find(params[:id])\n\n if @list_item.update(list_item_params)\n head :no_content\n else\n render json: @list_item.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list, notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list, notice: 'Changes and Additions Successful.' }\n format.json { render :show, status: :ok, location: @list }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n flash[:notice] = '修改成功!'\n format.html { redirect_to action: \"index_admin\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @listed.update(listed_params)\n format.html { redirect_to session[:previous_url], notice: 'List item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @listed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo_list = TodoList.find(params[:id])\n\n respond_to do |format|\n if @todo_list.update_attributes(params[:todo_list])\n format.html { redirect_to @todo_list, notice: 'Todo list was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @todo_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item_list.update(item_list_params)\n format.html { redirect_to @item_list, notice: 'Item list was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_list }\n else\n format.html { render :edit }\n format.json { render json: @item_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo_list = TodoList.find(params[:id])\n\n respond_to do |format|\n if @todo_list.update_attributes(params[:todo_list])\n format.html { redirect_to @todo_list, :notice=>\"Todo list was successfully updated.\"}\n format.json { head :ok }\n else\n format.html { render :action=>\"edit\" }\n format.json { render :json=>@todo_list.errors, :status=>\"unprocessable_entry\" }\n end\n end\n end",
"def update\n if @list.update(list_params)\n respond_successfully(I18n.t('integral.backend.lists.notification.edit_success'), backend_list_path(@list))\n else\n respond_failure(I18n.t('integral.backend.lists.notification.edit_failure'), :show)\n end\n end",
"def update\n respond_to do |format|\n if @list_item.update(list_item_params)\n format.html { redirect_to @list_item, notice: 'List item was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_item }\n else\n format.html { render :edit }\n format.json { render json: @list_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @todo_list.update(todo_list_params)\n format.html { redirect_to work_todo_list_path, notice: 'Todo list was successfully updated.' }\n format.json { render :show, status: :ok, location: work_todo_list_path }\n else\n format.html { render :edit }\n format.json { render json: @todo_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @task_list = TaskList.find(params[:id])\n\n respond_to do |format|\n if @task_list.update_attributes(params[:task_list])\n format.html { redirect_to @task_list, notice: 'Task list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @twitter_list = TwitterList.find(params[:id])\n\n respond_to do |format|\n if @twitter_list.update_attributes(params[:twitter_list])\n format.html { redirect_to @twitter_list, notice: 'Twitter list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @twitter_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to [@list.organization, @list], notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: [@list.organization, @list] }\n else\n format.html { render :edit }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n\n nested = params[:list].delete( :list_items_attributes )\n\n new_items = []\n\n if nested then\n nested.each do |i, r|\n\n if !r.key?( \"id\" )\n\n new_items << ListItem.new( { \"list\" => @list }.merge( r ) ) if !item_blank?( r )\n\n nested.delete( i )\n\n else\n\n r[ \"_destroy\" ] = \"true\" if item_blank?( r )\n\n end\n\n end\n end\n\n respond_to do |format|\n if @list.update_attributes( params[ :list ] ) && \n @list.update_attributes( list_items_attributes: (nested || {}) ) &&\n new_items.map( &:save ).all? then\n\n format.html { redirect_to @list, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n\n else\n\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n @list.user = current_user\n @user = @list.user\n\n respond_to do |format|\n if @list.update_attributes(params[:todo])\n format.html { redirect_to root_path, notice: 'List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @list_item.update(list_item_params)\n redirect_to @list_item, notice: 'List item was successfully updated.' \n else\n render action: 'edit' \n end\n end",
"def update\n respond_to do |format|\n if @saved_list.update(saved_list_params)\n format.html { redirect_to @saved_list, notice: \"Saved list was successfully updated.\" }\n format.json { render :show, status: :ok, location: @saved_list }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @saved_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @model_list.update(model_list_params)\n format.html { redirect_to @model_list, notice: 'Model list was successfully updated.' }\n format.json { render :show, status: :ok, location: @model_list }\n else\n format.html { render :edit }\n format.json { render json: @model_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_list(list_id, name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"patch\", \"lists/#{list_id}\", data)\n end",
"def update\n respond_to do |format|\n if @task_list.update(task_list_params)\n @task_lists = TaskList.all\n format.html { render :index, notice: 'Task list was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_list }\n else\n format.html { render :edit }\n format.json { render json: @task_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @todoit_list.update(todoit_list_params)\n format.html { redirect_to @todoit_list, notice: 'Todoit list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @todoit_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @task_list = TaskList.find(params[:id])\n respond_to do |format|\n if @task_list.update_attributes(params[:task_list])\n format.html { redirect_to @task_list, notice: 'Task list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list = List.find(params[:id])\n @show_list = true\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { render @list }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @adventure.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @todolist.update(todolist_params)\n format.html { redirect_to @todolist, notice: 'Todolist was successfully updated.' }\n format.json { render :show, status: :ok, location: @todolist }\n else\n format.html { render :edit }\n format.json { render json: @todolist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @listtodo.update(listtodo_params)\n format.html { redirect_to @listtodo, notice: 'Listtodo was successfully updated.' }\n format.json { render :show, status: :ok, location: @listtodo }\n else\n format.html { render :edit }\n format.json { render json: @listtodo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing_list = ThingList.find(params[:id])\n\n respond_to do |format|\n if @thing_list.update_attributes(params[:thing_list])\n format.html { redirect_to(@thing_list, :notice => 'Thing list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thing_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @todo_list = TodoList.find(params[:id])\n\n respond_to do |format|\n if @todo_list.update_attributes(params[:todo_list])\n flash[:notice] = 'TodoList was successfully updated.'\n format.html { redirect_to(@todo_list) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @todo_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @task_list.update(task_list_params)\n format.html { redirect_to @task_list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_list }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @task_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page_title = \"Task List Update\"\n @task_list = TaskList.find(params[:id])\n\n respond_to do |format|\n if @task_list.update_attributes(params[:task_list])\n flash[:notice] = 'TaskList was successfully updated.'\n format.html { redirect_to(@task_list) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @todoslist.update(todoslist_params)\n format.html { redirect_to @todoslist, notice: \"Todoslist was successfully updated.\" }\n format.json { render :show, status: :ok, location: @todoslist }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @todoslist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item.update_attributes(item_params)\n @items = List.find(item_params[:list_id]).items.order(\"id ASC\")\n @list_id = @item.list.id\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to lists_path, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer_list.update(answer_list_params)\n format.html { redirect_to @answer_list, notice: 'Answer list was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer_list }\n else\n format.html { render :edit }\n format.json { render json: @answer_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = @list.todos.find(params[:id])\n\n respond_to do |format|\n if @todo.update_attributes(params[:todo])\n format.html { redirect_to list_todo_path(@list, @todo), notice: 'Todo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question_list.update(question_list_params)\n format.html { redirect_to @question_list, notice: 'Question list was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_list }\n else\n format.html { render :edit }\n format.json { render json: @question_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe_list.update(recipe_list_params)\n format.html { redirect_to @recipe_list, notice: 'Recipe list was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_list }\n else\n format.html { render :edit }\n format.json { render json: @recipe_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lista = Lista.find(params[:id])\n\n respond_to do |format|\n if @lista.update_attributes(params[:lista])\n format.html { redirect_to @lista, notice: 'Lista was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lista.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @job_list = JobList.find(params[:id])\n\n respond_to do |format|\n if @job_list.update_attributes(params[:job_list])\n format.html { redirect_to @job_list, notice: 'Job list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @job_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(options = {})\n self.merge!(Vermonster::Client.connection.put(\"lists/#{self[\"id\"]}\", \"{\\\"list\\\": #{options.to_json}}\").body)\n end",
"def update\n @order_list = OrderList.find(params[:id])\n\n respond_to do |format|\n if @order_list.update_attributes(params[:order_list])\n format.html { redirect_to(@order_list, :notice => 'OrderList was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @invite_list = InviteList.find(params[:id])\n\n respond_to do |format|\n if @invite_list.update_attributes(params[:invite_list])\n format.html { redirect_to @invite_list, notice: 'Invite list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invite_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @url_list.update(url_list_params)\n format.html { redirect_to @url_list, notice: 'Url list was successfully updated.' }\n format.json { render :show, status: :ok, location: @url_list }\n else\n format.html { render :edit }\n format.json { render json: @url_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @email_list.update(email_list_params)\n format.html { redirect_to @email_list, notice: 'Email list was successfully updated.' }\n format.json { render :show, status: :ok, location: @email_list }\n else\n format.html { render :edit }\n format.json { render json: @email_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @list_value.update(list_value_params)\n format.html { redirect_to @list_value, notice: 'List value was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_value }\n else\n format.html { render :edit }\n format.json { render json: @list_value.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @ml_list\n respond_to do |format|\n if @ml_list.update(ml_list_params)\n format.html { redirect_to @ml_list, notice: 'List was successfully updated.' }\n format.json { render :show, status: :ok, location: @ml_list }\n else\n format.html { render :edit }\n format.json { render json: @ml_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @set_list.update(set_list_params)\n format.html { redirect_to @set_list, notice: 'Set list was successfully updated.' }\n format.json { render :show, status: :ok, location: @set_list }\n else\n format.html { render :edit }\n format.json { render json: @set_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mylist = Mylist.find(params[:id])\n\n respond_to do |format|\n if @mylist.update_attributes(params[:mylist])\n format.html { redirect_to(@mylist, :notice => 'Mylist was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mylist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_list(user, list, options={})\n post(\"/#{user}/lists/#{list}.json\", options)\n end",
"def update\n respond_to do |format|\n if @list.update(list_params)\n format.html { redirect_to @list.entity, notice: 'La Liste de propositions pour la semaine ' + @list.date.to_time.strftime(\"%W\") + ' a été modifiée avec succès.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n list = List.find_by_title(params[:task][:list_title])\n task_params = Task.format_params(params[:task][:title], params[:task][:description], list.id)\n respond_to do |format|\n if @task.update(task_params)\n format.html { redirect_to lists_url, 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 @list_to_do = ListToDo.find(params[:id])\n\n respond_to do |format|\n if @list_to_do.update_attributes(params[:list_to_do])\n format.html { redirect_to new_list_to_do_path, notice: 'List to do was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list_to_do.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @search_list = SearchList.find(params[:id])\n\n respond_to do |format|\n if @search_list.update_attributes(params[:search_list])\n format.html { redirect_to @search_list, notice: 'Search list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @search_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_list(list_id:, name:)\n check_token\n list = Todoable::List.new(name: name)\n response = self.class.patch(\n \"/lists/#{list_id}\",\n body: list.post_body,\n headers: headers,\n format: :text\n )\n check_and_raise_errors(response)\n # This endpoint returns a plaintext body: \"<new name> updated\", so\n # while I'd like to return a List with ListItems, that would require\n # first looking up the list which isn't ideal. So we'll return true, ask\n # todoable to fix this endpoint, and make developers keep track of the\n # name change\n true\n end",
"def update\n respond_to do |format|\n if @list_element.update(list_element_params)\n format.html { redirect_to @list_element, notice: 'List element was successfully updated.' }\n format.json { render :show, status: :ok, location: @list_element }\n else\n format.html { render :edit }\n format.json { render json: @list_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book_list = BookList.find(params[:id])\n\n respond_to do |format|\n if @book_list.update_attributes(params[:book_list])\n format.html { redirect_to(@book_list, :notice => 'Book list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @book_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @listitem.update(listitem_params)\n render :show, status: :ok, location: todolist_listitem_path(@todolist, @listitem)\n else\n render json: @listitem.errors, status: :unprocessable_entity\n end\nend",
"def update\n @liste = Liste.find(params[:id])\n\n respond_to do |format|\n if @liste.update_attributes(params[:liste])\n format.html { redirect_to @liste, notice: 'Liste was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @liste.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @list_items = args[:list_items] if args.key?(:list_items)\n end",
"def update\n respond_to do |format|\n if @check_list.update(check_list_params)\n format.html { redirect_to @check_list, notice: \"Check list was successfully updated.\" }\n format.json { render :show, status: :ok, location: @check_list }\n else\n format.html { render :edit }\n format.json { render json: @check_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @data_list = DataList.find(params[:id])\n\n respond_to do |format|\n if @data_list.update_attributes(params[:data_list])\n format.html { redirect_to(@data_list, :notice => 'Data list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @data_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_list(id, list)\n record \"/todos/update_list/#{id}\", :list => list\n end",
"def update\n @ota_code_list_list = Ota::CodeList::List.find(params[:id])\n\n respond_to do |format|\n if @ota_code_list_list.update_attributes(params[:ota_code_list_list])\n format.html { redirect_to(@ota_code_list_list, :notice => 'List was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ota_code_list_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @email_list = EmailList.find(params[:id])\n\n respond_to do |format|\n if @email_list.update_attributes(params[:email_list])\n format.html { redirect_to(@email_list, :notice => 'Email list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @email_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @todolist.update_attributes(todolist_params)\n redirect_to todolist_path(@todolist)\n else\n render :action => :edit\n end\n\n end",
"def update\n respond_to do |format|\n if @applist.update(applist_params)\n format.html { redirect_to @applist, notice: 'Applist was successfully updated.' }\n format.json { render :show, status: :ok, location: @applist }\n else\n format.html { render :edit }\n format.json { render json: @applist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @todolists.update(todolist_params)\n format.html { redirect_to @todolists, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @todolists }\n else\n format.html { render :edit }\n format.json { render json: @todolists.errors, status: :unprocessable_entity }\n end\n end\nend",
"def update\n respond_to do |format|\n if @feed_list.update(feed_list_params)\n format.html { redirect_to @feed_list, notice: 'Feed list was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed_list }\n else\n format.html { render :edit }\n format.json { render json: @feed_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @service_list.update(service_list_params)\n format.html { redirect_to @service_list, notice: 'Service list was successfully updated.' }\n format.json { render :show, status: :ok, location: @service_list }\n else\n format.html { render :edit }\n format.json { render json: @service_list.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.82539254",
"0.8233802",
"0.8233802",
"0.8157004",
"0.8157004",
"0.8147768",
"0.81287605",
"0.80909014",
"0.80861956",
"0.80861956",
"0.80861956",
"0.80861956",
"0.80861956",
"0.80807054",
"0.8056709",
"0.8055855",
"0.80550617",
"0.80249447",
"0.8015926",
"0.801169",
"0.79794955",
"0.79670495",
"0.7964608",
"0.7962282",
"0.7949237",
"0.79130083",
"0.7841346",
"0.7837235",
"0.78315616",
"0.78313416",
"0.7828934",
"0.7804717",
"0.779443",
"0.77929515",
"0.77912855",
"0.7777269",
"0.7769789",
"0.77602684",
"0.7758173",
"0.7731621",
"0.77150345",
"0.7701523",
"0.7699542",
"0.76978296",
"0.76760435",
"0.76749486",
"0.7669355",
"0.7661397",
"0.76574767",
"0.7653499",
"0.76484066",
"0.7645237",
"0.762097",
"0.76169974",
"0.75943047",
"0.75547177",
"0.75196725",
"0.7511502",
"0.7506157",
"0.74949133",
"0.7483006",
"0.7476372",
"0.7468572",
"0.7446563",
"0.74418694",
"0.74240375",
"0.74188495",
"0.7417513",
"0.74056625",
"0.7403951",
"0.74033934",
"0.74024016",
"0.7402321",
"0.7401611",
"0.7395004",
"0.73932856",
"0.73908496",
"0.73816",
"0.7377388",
"0.73726237",
"0.7348958",
"0.73478055",
"0.7340541",
"0.73299754",
"0.7322041",
"0.7305565",
"0.73019063",
"0.72904277",
"0.7283009",
"0.7276885",
"0.72646797",
"0.7259507",
"0.7254193",
"0.7248736",
"0.72450924",
"0.72431123",
"0.7233236",
"0.7232583",
"0.7229905",
"0.722157"
] |
0.78546494
|
26
|
DELETE /lists/1 DELETE /lists/1.json
|
def destroy
@list = current_user.lists.find params[:list_id]
@item = @list.items.find(params[:id])
@item.destroy
respond_to do |format|
format.html { redirect_to list_items_path(@list), notice: 'Item was successfully removed.' }
#format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_list(list_id)\n rest(\"delete\", \"lists/#{list_id}\")\n\n return true\n end",
"def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end",
"def destroy\n @list = List.find(params[:id])\n @list.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @list = List.find(params[:id])\n @list.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list = List.find(params[:id])\n @list.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list = List.find(params[:id])\n @list.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :no_content }\n end\n end",
"def delete(list_id)\n Iterable.request(conf, \"/lists/#{list_id}\").delete\n end",
"def delete_list(id)\n record \"/todos/delete_list/#{id}\"\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: \"List was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list = @project.lists.find(params[:id])\n @list.destroy\n\n respond_to do |format|\n format.html { redirect_to project_lists_url(@project) }\n format.json { head :no_content }\n end\n end",
"def delete_list(id)\n query(\"DELETE FROM todos WHERE list_id = $1\", id)\n query(\"DELETE FROM lists WHERE id = $1\", id)\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to my_lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to management_lists_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'The List was destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to list_types_url, notice: \"Check ya later list.\" }\n format.json { head :no_content }\n end\n end",
"def delete_list(params={})\n @obj.delete('delete', @auth.merge(params))\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url, notice: 'Funcionario deletado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_item = ListItem.find(params[:id])\n @list_item.destroy\n\n respond_to do |format|\n format.html { render :nothing => true}\n format.json { head :no_content }\n end\n end",
"def destroy\n @saved_list.destroy\n respond_to do |format|\n format.html { redirect_to saved_lists_url, notice: \"Saved list was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to organization_lists_url(@organization), notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo_list = TodoList.find(params[:id])\n @todo_list.destroy\n\n respond_to do |format|\n format.html { redirect_to todo_lists_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @todo_list = TodoList.find(params[:id])\n @todo_list.destroy\n\n respond_to do |format|\n format.html { redirect_to todo_lists_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @list = current_user.lists.find(params[:id])\n @list.destroy\n respond_with(@list, :location => my_lists_url)\n end",
"def destroy\n @todoit_list.destroy\n respond_to do |format|\n format.html { redirect_to todoit_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @list=List.find(params[:list_id])\n @list_item=@list.list_items.find(params[:id])\n @list_item.destroy\n respond_to do |format|\n format.html { redirect_to @list, notice: 'List item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_list.destroy\n respond_to do |format|\n format.html { redirect_to item_lists_url, notice: 'Item list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mustdo_list.destroy\n respond_to do |format|\n format.html { redirect_to mustdo_lists_url, notice: 'Mustdo list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :ok }\n end\n end",
"def destroy\n authorize! :delete, @ml_list\n @ml_list.destroy\n respond_to do |format|\n format.html { redirect_to ml_lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @url_list.destroy\n respond_to do |format|\n format.html { redirect_to url_lists_url, notice: 'Url list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @liste = Liste.find(params[:id])\n @liste.destroy\n\n respond_to do |format|\n format.html { redirect_to listes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @lista = Lista.find(params[:id])\n @lista.destroy\n\n respond_to do |format|\n format.html { redirect_to listas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_item.destroy\n respond_to do |format|\n format.html { redirect_to list_path(@list), notice: 'List item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list = List.find(params[:id])\n\n respond_to do |format|\n\n if @list.user == current_user\n\n @list.destroy\n\n format.html { redirect_to lists_url }\n format.json { head :no_content }\n\n else\n\n format.html { redirect_to lists_url, alert: \"You cannot delete that list\" }\n format.json { head :no_content, status: :unauthorized }\n\n end\n\n end\n end",
"def destroy\n @twitter_list = TwitterList.find(params[:id])\n @twitter_list.destroy\n\n respond_to do |format|\n format.html { redirect_to twitter_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @check_list.destroy\n respond_to do |format|\n format.html { redirect_to check_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @checklist = Checklist.find(params[:id])\n @checklist.destroy\n\n respond_to do |format|\n format.html { redirect_to checklists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list = current_user.lists.find(list_params)\n @list.destroy\n flash[:success] = \"List deleted\"\n redirect_to current_user\n end",
"def destroy\n # @task_list = TaskList.find(params[:id])\n @task_list.destroy\n\n respond_to do |format|\n format.html { redirect_to task_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list = List.find(params[:id])\n @list.destroy\n flash[:notice] = \"List successfully deleted\"\n \n @lists = current_user.lists\n @feeds = current_user.feeds\n\n respond_to do |format|\n format.html { redirect_to(lists_url) }\n format.xml { head :ok }\n format.js {render :layout => false}\n end\n end",
"def delete_item(list_id:, id:)\n path = \"lists/#{list_id}/items/#{id}\"\n request(method: :delete, path: path)\n end",
"def destroy\n @todoslist.destroy\n respond_to do |format|\n format.html { redirect_to todoslists_url, notice: \"Todoslist was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo = @list.todos.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to list_todos_url(@list) }\n format.json { head :ok }\n end\n end",
"def destroy\n @bulk_insert_list.destroy\n respond_to do |format|\n format.html { redirect_to bulk_insert_lists_url, notice: 'Bulk insert list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mylist = Mylist.find(params[:id])\n @mylist.destroy\n\n respond_to do |format|\n format.html { redirect_to(mylists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @task_list.destroy\n respond_to do |format|\n format.html { redirect_to task_lists_url, notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo_list.destroy\n respond_to do |format|\n format.html { redirect_to todo_lists_url, notice: 'Todo list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @list\n @list.destroy\n head :no_content\n end",
"def destroy\n @list_item.destroy\n\n head :no_content\n end",
"def destroy\n @list = List.find(params[:list_id])\n @list_item = @list.list_items.find(params[:id])\n @list_item.destroy\n\n if @list_item.destroy\n flash[:success] = \"Item deleted\"\n redirect_to list_path(@list)\n else\n flash[:error] = \"Item not deleted\"\n redirect_to list_path(@list)\n end\n end",
"def destroy\n @api_v1_shopping_list.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_shopping_lists_url, notice: 'Shopping list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@list = List.find(params[:id])\n\t\t@list.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html\t{ redirect_to(root_url) }\n\t\t\tformat.xml\t{ head :ok }\n\t\tend\n\tend",
"def destroy\n @thing_list = ThingList.find(params[:id])\n @thing_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(thing_lists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @keylist.destroy\n respond_to do |format|\n format.html { redirect_to keylists_url, notice: 'Keylist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mydo_list.destroy\n respond_to do |format|\n format.html { redirect_to mydo_lists_url, notice: 'Mydo list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite_list = InviteList.find(params[:id])\n @invite_list.destroy\n\n respond_to do |format|\n format.html { redirect_to invite_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_item.destroy\n respond_to do |format|\n format.html { redirect_to list_items_url, notice: 'List item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @toread_list.destroy\n respond_to do |format|\n format.html { redirect_to toread_lists_url, notice: 'Toread list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fwlist = Fwlist.find(params[:id])\n @fwlist.destroy\n\t\n respond_to do |format|\n format.html { redirect_to fwlists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @model_list.destroy\n respond_to do |format|\n format.html { redirect_to model_lists_url, notice: 'Model list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @listed.destroy\n respond_to do |format|\n format.html { redirect_to session[:previous_url] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @email_list.destroy\n respond_to do |format|\n format.html { redirect_to email_lists_url, notice: 'Email list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @task_list.destroy\n respond_to do |format|\n format.html { redirect_to task_lists_url, notice: 'Task list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_list(id:)\n check_token\n response = self.class.delete(\"/lists/#{id}\", headers: headers)\n check_and_raise_errors(response)\n true\n end",
"def destroy\n @mailee_list = Mailee::List.find(params[:id])\n @mailee_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(mailee_lists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @list.destroy\n redirect_to lists_url, notice: 'List was successfully destroyed.'\n end",
"def destroy\n @todolist.destroy\n respond_to do |format|\n format.html { redirect_to todolists_url, notice: 'Todolist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coffeeshoplist.destroy\n respond_to do |format|\n format.html { redirect_to coffeeshoplists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sent_list.destroy\n respond_to do |format|\n format.html { redirect_to sent_lists_url, notice: 'Sent list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @check_list.destroy\n respond_to do |format|\n format.html { redirect_to check_lists_url, notice: \"Check list was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @listtodo.destroy\n respond_to do |format|\n format.html { redirect_to listtodos_url, notice: 'Listtodo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @data_list = DataList.find(params[:id])\n @data_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(data_lists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @applist.destroy\n respond_to do |format|\n format.html { redirect_to applists_url, notice: 'Applist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo_list.destroy\n respond_to do |format|\n format.html { redirect_to todo_lists_url, notice: 'Todo list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agent_list.destroy\n respond_to do |format|\n format.html { redirect_to agent_lists_url, notice: 'Agent list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n cookies[:list]=cookies[:list].gsub(\",#{@list.id}\",\"\")\n format.html { redirect_to \"/\", notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @watch_list = WatchList.find(params[:id])\n @watch_list.destroy\n\n respond_to do |format|\n format.html { redirect_to watch_lists_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @service_list.destroy\n respond_to do |format|\n format.html { redirect_to service_lists_url, notice: 'Service list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @set_list.destroy\n respond_to do |format|\n format.html { redirect_to set_lists_url, notice: 'Set list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @doulist.destroy\n respond_to do |format|\n format.html { redirect_to doulists_url, notice: 'Doulist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @search_list = SearchList.find(params[:id])\n @search_list.destroy\n\n respond_to do |format|\n format.html { redirect_to search_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @actionlist.destroy\n respond_to do |format|\n format.html { redirect_to actionlists_url, notice: 'Actionlist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete!(id:)\n client.delete_list(id: id)\n end",
"def destroy\n @menu_list = MenuList.find(params[:id])\n @menu_list.destroy\n\n respond_to do |format|\n format.html { redirect_to menu_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @list.name == 'Default'\n format.html { redirect_to @user.lists.find_by(name: 'Default'), data: { confirm: 'You can\\'t delete your default list'} }\n else\n @list.destroy\n respond_to do |format|\n format.html { redirect_to @user.lists.find_by(name: 'Default') }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @mebrat_list.destroy\n respond_to do |format|\n format.html { redirect_to mebrat_lists_url, notice: 'Mebrat list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy_multiple\n\t @list.delete(params[:id])\n\t redirect_to '/tasks'\n\tend",
"def destroy\n @todolists.destroy\n respond_to do |format|\n format.html { redirect_to todolist_url, notice: 'Task was successfully destroyed.' }\n format.json { head :no_content }\n end\nend",
"def destroy\n @menu_lists.destroy\n respond_to do |format|\n format.html { redirect_to menu_lists_url, notice: 'Menu list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end"
] |
[
"0.7905714",
"0.7809364",
"0.7780575",
"0.77566075",
"0.77566075",
"0.77566075",
"0.77175426",
"0.77175426",
"0.77175426",
"0.75786066",
"0.750991",
"0.7501654",
"0.7501654",
"0.7501654",
"0.7501654",
"0.7501654",
"0.7501654",
"0.7501654",
"0.7498501",
"0.7476957",
"0.7471059",
"0.7465852",
"0.7464357",
"0.7427202",
"0.7359984",
"0.7357202",
"0.7319476",
"0.73084384",
"0.7262891",
"0.7259669",
"0.72563213",
"0.7256021",
"0.72098637",
"0.719305",
"0.7174434",
"0.71538323",
"0.71527857",
"0.7147388",
"0.714256",
"0.7122252",
"0.7118374",
"0.7085914",
"0.70844483",
"0.70834184",
"0.70775473",
"0.7036017",
"0.70339817",
"0.7031074",
"0.7019155",
"0.70137334",
"0.70134085",
"0.70031655",
"0.700184",
"0.70016986",
"0.69997776",
"0.6997138",
"0.6994727",
"0.69834",
"0.6979137",
"0.69780433",
"0.69723225",
"0.6964517",
"0.69634044",
"0.6962718",
"0.6960178",
"0.69548833",
"0.6952883",
"0.6930801",
"0.6930185",
"0.6922417",
"0.6922201",
"0.6918892",
"0.6918428",
"0.69161814",
"0.6905148",
"0.69018245",
"0.68972594",
"0.6897111",
"0.6883828",
"0.68671185",
"0.6863377",
"0.6858233",
"0.68525195",
"0.6852466",
"0.6846843",
"0.6844299",
"0.6838546",
"0.68361706",
"0.6835495",
"0.6830329",
"0.6829805",
"0.6828901",
"0.6828642",
"0.68086374",
"0.68071383",
"0.68026686",
"0.6800252",
"0.67975503",
"0.6794486",
"0.678483"
] |
0.7221024
|
32
|
Never trust parameters from the scary internet, only allow the white list through. Protects from people passing in something they shouldn't, only accept these parameters
|
def item_params
params.require(:item).permit(:name, :max_price, :url, :notes, :model_number)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def valid_params_request?; end",
"def param_whitelist\n [:role, :title]\n end",
"def check_params; true; end",
"def valid_params?; 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 strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:rating, :review]\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 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 expected_permitted_parameter_names; end",
"def filtered_parameters; 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 permitir_parametros\n \t\tparams.permit!\n \tend",
"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 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_for_params_auth?; end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def check_params\n true\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\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 safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def parameters(params)\n allowed = [:start,:num,:type,:id,:filter,:tagged,:search,:state,:email,:password]\n params.merge! defaults if defaults\n params.reject {|key,value| !allowed.include? key }\n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def ignore_parameter(key)\n ignore_params[key] = nil\n end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def validate_smurl_params params, blacklisted=[]\n errors = []\n\n url = params[:url]\n errors << \"Url cannot be empty\" if url.nil? || url.gsub(/[[:space:]]/, '').empty?\n\n vanity = params[:vanity]\n\n if vanity\n # illegal characters\n if /[^a-zA-Z0-9]/.match(vanity)\n errors << \"Custom url can only contain a-z, A-Z, and 0-9\"\n end\n\n # blacklisted value\n if blacklisted and blacklisted.include?(vanity)\n errors << \"That custom url cannot be used at this time\"\n end\n end\n\n errors\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def quote_params\n params.permit!\n end",
"def quote_params(params); 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 linted_params\n url = params.require(:url)\n begin\n URI.parse(url)\n rescue URI::InvalidURIError\n raise ActionController::BadRequest\n end\n params.permit(:url, :maxwidth, :maxheight, :format, :fullheight,\n :hide_title, :hide_embed, :hide_download, :hide_search, :min_files_to_search,\n :canvas_id, :canvas_index, :search, :suggested_search, :image_tools, :cdl_hold_record_id)\n end",
"def paramunold_params\n params.require(:paramunold).permit!\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 params_not_permitted\n logger.warn('exception: params not permitted')\n render plain: \"403 ForbiddEn\", status: 403\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def validate_params_present!\n raise ArgumentError, \"Please provide one or more of: #{ACCEPTED_PARAMS}\" if params.blank?\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def url_whitelist=(_arg0); end",
"def url_allowlist=(_arg0); 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 permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def blacklisted_search_session_params\n PARAM_NOT_PERSISTED\n end",
"def cleanup_parameters\n original_count = params.keys.size\n\n # Eliminate \"noise\" parameters.\n params.delete_if { |k, v| k.blank? || v.blank? }\n %w[utf8 commit].each { |k| params.delete(k) }\n\n # If parameters were removed, redirect to the corrected URL.\n will_redirect unless params.keys.size == original_count\n end",
"def validate_email_parameters(params, whitelist)\n # delets all non-whitelisted params, and returns a safe list.\n params = trim_whitelisted(params, whitelist)\n # Check for missing parameters\n raise MissingEmailFromAddress if params[\"from\"].to_s.length == 0\n raise MissingEmailToAddress if params[\"to\"].to_s.length == 0\n raise MissingEmailSubject if params[\"subject\"].to_s.length == 0\n raise MissingEmailText if params[\"text\"].to_s.length == 0\n # Perform validations\n # raise InvalidEmailSubject if <consider validations here>\n raise InvalidEmailFromAddress if !validate_email(params[\"from\"])\n raise InvalidEmailToAddress if !validate_email(params[\"to\"])\n\n return params\n end",
"def valid_params_request?\n true\n end",
"def valid_params_request?\n true\n end",
"def url_whitelist; end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def unpermitted_parameters\n fail 'Define me!'\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def unsolved_params\n \n end",
"def url_allowlist; end",
"def some_thing_params\n params.require(:some_thing).permit(:val)\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 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 ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def anonymous_filter_params\n p = params.required('payload')\n # p.permit!('controls_params')\n # p.permit!('columns_params')\n # p.permit!('sorting')\n # p.permit!('global_config')\n p.permit(\n 'name',\n 'controls_list' => [],\n 'controls_hl_mode' => [],\n 'controls_params' => {},\n 'columns_list' => [],\n 'columns_params' => {},\n 'sorting' => {},\n 'global_config' => {}\n ).merge(permit_hashes(p, [\n 'controls_params',\n 'columns_params',\n 'sorting',\n 'global_config'\n ]))\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def blacklisted_params\n params.keys.each_with_object({}) do |param, hash|\n param = param.to_sym\n hash[param] = nil unless WHITELIST_PAGINATION_PARAMS.include?(param)\n end\n end",
"def validate_params(params)\n # This will be implemented by Validators which take parameters\n end",
"def skip_parameter_encoding(action); end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\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 validate_params!\n self.params ||= Hash.new\n self.class.instance_variable_get(:@__required_params).each do |e|\n raise ArgumentError, \"Insufficient parameters set (#{e} not supplied)\" if self.params[e].nil?\n end\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def dog_params\n allowed_params = %w(name birthdate breed image_url)\n params.select {|param,value| allowed_params.include?(param)}\n end",
"def validate_only_alphanumeric\n bad_params = []\n params.delete_if{|k,v| v.kind_of?(Array)}.each do |k,v|\n if k == 'limit' or k == 'offset'\n bad_params << k unless v.match(/^\\d+$/) unless v.nil?\n end\n end\n\n throw_error 400, :message => \"Wrong parameter format in #{bad_params.inspect.gsub('\"','')}.\" if bad_params.length > 0\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 clean_params(params)\n params.slice()\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def kladr_params\n params.require(:str) #address from user\n end",
"def request_params; end",
"def sanitize_params(params = params)\n params = walk_hash(params) if params\n end",
"def validate_params?\n true # TODO: add validation\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def strip_non_model_safe_params parameters\n safe_params = if include_only = self._wrapper_options[:include]\n parameters.slice(*include_only)\n else\n exclude = _wrapper_options[:exclude] || []\n parameters.except(*(exclude + EXCLUDE_PARAMETERS))\n end \n return safe_params\n end",
"def param_whitelist\n [\n :school_name,\n :school_id,\n :degree,\n :started_at,\n :finished_at,\n majors: [],\n minors: []\n ]\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def sanitize_search_params source_params\n\n my_params = source_params.reject { |k,v| v.nil? }\n\n my_params.except(:action, :controller, :id, :commit, :utf8)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def check_params(params, allowed_params)\n if (params.keys - allowed_params).empty?\n return params\n else\n raise Bitfinex::ParamsError\n end\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def query_parameters; end"
] |
[
"0.7140684",
"0.70953345",
"0.7071303",
"0.7022501",
"0.70146924",
"0.6992742",
"0.6945231",
"0.683342",
"0.6793334",
"0.6788039",
"0.67348784",
"0.67133284",
"0.66921747",
"0.6647876",
"0.6647047",
"0.6633178",
"0.6609358",
"0.660617",
"0.6591118",
"0.6590045",
"0.657402",
"0.654232",
"0.6520902",
"0.6518792",
"0.65170366",
"0.6498957",
"0.6488767",
"0.6471488",
"0.6461429",
"0.6454961",
"0.64319587",
"0.6402058",
"0.6392642",
"0.6386588",
"0.6384282",
"0.6384282",
"0.6364723",
"0.6353163",
"0.63482744",
"0.63350725",
"0.6323675",
"0.63228625",
"0.62928224",
"0.626987",
"0.6264635",
"0.62565297",
"0.62381756",
"0.6233277",
"0.62325794",
"0.6222107",
"0.61892134",
"0.61853653",
"0.61792815",
"0.61771464",
"0.61764973",
"0.61739165",
"0.6167796",
"0.6167796",
"0.6167606",
"0.6165783",
"0.6159644",
"0.61517245",
"0.61215866",
"0.6113218",
"0.61043084",
"0.6101072",
"0.60910213",
"0.6086479",
"0.6081213",
"0.607771",
"0.6071038",
"0.60686016",
"0.60678864",
"0.60658634",
"0.6064491",
"0.6060125",
"0.6053844",
"0.6047338",
"0.6045566",
"0.6035676",
"0.603517",
"0.60287666",
"0.6023219",
"0.6022355",
"0.60169417",
"0.6013838",
"0.60124844",
"0.6010133",
"0.6007333",
"0.60045165",
"0.5986483",
"0.59854096",
"0.5981797",
"0.5979779",
"0.5972608",
"0.5972174",
"0.5965715",
"0.5963081",
"0.59576964",
"0.5955268",
"0.5944503"
] |
0.0
|
-1
|
Flush Memcache Author: Aman Date: 30/05/2019 Reviewed By:
|
def memcache_flush
customer_memcache_key = Customer.get_memcache_key_object.key_template % {id: self.id}
Memcache.delete(customer_memcache_key)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def memcache_flush\n memcache_key = self.singleton_class.get_memcache_key_object.key_template % {\n shard_identifier: self.singleton_class.shard_identifier,\n aml_search_uuid: aml_search_uuid\n }\n Memcache.delete(memcache_key)\n end",
"def memcache_flush\n ukcd_memcache_key = self.singleton_class.get_by_ued_memcache_key_object.key_template % {\n user_extended_detail_id: self.user_extended_detail_id,\n shard_identifier: self.singleton_class.shard_identifier\n }\n Memcache.delete(ukcd_memcache_key)\n end",
"def memcache_flush\n memcache_key = self.singleton_class.get_memcache_key_object.key_template % {\n shard_identifier: self.singleton_class.shard_identifier,\n user_kyc_detail_id: self.user_kyc_detail_id,\n user_extended_detail_id: self.user_extended_detail_id\n }\n Memcache.delete(memcache_key)\n end",
"def memcache_flush\n client_memcache_key = ClientKycPassSetting.get_memcache_key_object.key_template % {client_id: self.client_id}\n Memcache.delete(client_memcache_key)\n end",
"def memcache_flush\n admin_memcache_key = EntityDraft.get_memcache_key_object.key_template % {id: self.id}\n Memcache.delete(admin_memcache_key)\n end",
"def flush_memos\n CACHE.clear\n end",
"def memcache_flush\n admin_session_setting_memcache_key = AdminSessionSetting.get_active_memcache_key_object.key_template % {client_id: self.client_id}\n Memcache.delete(admin_session_setting_memcache_key)\n end",
"def flush!\n @_cache = {}\n end",
"def memcache_flush\n client_pepo_campaign_details_memcache_key = ClientPepoCampaignDetail.get_memcache_key_object.key_template % {client_id: self.client_id}\n Memcache.delete(client_pepo_campaign_details_memcache_key)\n end",
"def memcache_flush\n memcache_key = ClientWebhookSetting.get_memcache_key_object.key_template % {id: self.id}\n Memcache.delete(memcache_key)\n\n memcache_key = ClientWebhookSetting.get_active_memcache_key_object.key_template % {client_id: self.client_id}\n Memcache.delete(memcache_key)\n\n if self.previous_changes[\"secret_key\"].present?\n memcache_key = ClientWebhookSetting.get_decrypted_secret_key_memcache_key_object.key_template % {id: self.id, client_id: self.client_id}\n Memcache.delete(memcache_key)\n end\n\n end",
"def flush_cache; end",
"def memcache_flush\n entity_group_draft_memcache_key = EntityGroupDraft.get_memcache_key_object.key_template % {entity_group_id: self.entity_group_id}\n Memcache.delete(entity_group_draft_memcache_key)\n end",
"def flush\n File.open(\"data/#{Time.now.to_i.to_s}\",'w') { |f| Marshal.dump(@cache, f) }\n File.open(\"data2/#{Time.now.to_i.to_s}\",'w') { |f| Marshal.dump(@cache, f) }\n puts \"=\"\n end",
"def flush!\n unless @cache.empty?\n $stderr.puts \" FLUSHING CACHE!\"\n @cache.clear\n end\n self\n end",
"def flush\n write_cache if @dirty\n @dirty = false\n end",
"def cache_clear\n @store.flush_all\n rescue ::MemCache::MemCacheError => e\n Log.error(e)\n nil\n end",
"def test_flush\n cached = TestCache.new\n \n cached.m1\n assert cached.cached?(:m1)\n cached.flush(:m1)\n assert !cached.cached?(:m1)\n \n cached.m3('test')\n assert cached.cached?(:m3, 'test')\n cached.flush(:m3, 'test')\n assert !cached.cached?(:m3, 'test')\n end",
"def flush_cache!\n flush!(:manually_requested)\n end",
"def flush!\n @redis.flushdb\n end",
"def flush\n LegacyFacter.flush\n SessionCache.invalidate_all_caches\n nil\n end",
"def clear\r\n @cache.flush\r\n end",
"def clear_cache; end",
"def cache_clear\n @client.flushall\n end",
"def flush_cache\n Linker.flush_cache\n end",
"def ensure_flush\n flush if @cache.size > 0\n end",
"def flush\n check_return_code(\n Lib.memcached_flush(@struct, IGNORED)\n )\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end",
"def flush\n redis.del(bucket_key)\n end",
"def clear_cache() @cache = {}; end",
"def flush_cache(cache)\n File.open(@data_file, 'w') do |out|\n YAML.dump(cache, out)\n end\n end",
"def flush_cache\n self.class.flush_cache(gem.name)\n end",
"def flushdb\n redis.flushdb\n end",
"def flushdb\n @redis.flushdb\n end",
"def flush_cache\n Rails.cache.delete([self.class.name, symbol_was.to_s])\n Rails.cache.delete([self.class.name, id])\n end",
"def flush_cache\n # needed on at least fc23/fc24 sometimes to deal with the dnf cache getting out of sync with the rpm db\n FileUtils.rm_f \"/var/cache/dnf/@System.solv\"\n Chef::Provider::Package::Dnf::PythonHelper.instance.reap\n end",
"def flush()\n #This is a stub, used for indexing\n end",
"def flush_cache(cache)\n cache[:last_checked] = @last_checked\n File.open(@data_file, 'w') do |out|\n YAML.dump(cache, out)\n end\n end",
"def flush\n manager.flush\n end",
"def local_flush\n end",
"def flushall; end",
"def invalidateCache()\n begin\n return @db.execute(\"DELETE FROM cache WHERE key LIKE '/%'\")\n rescue => error\n puts error\n end\n end",
"def flush # :nodoc:\n end",
"def flush\n @h.flush\n end",
"def clear(options = nil)\n @client.flush_all\n rescue Spymemcached::Error => e\n logger.error(\"Spymemcached::Error (#{e}): #{e.message}\") if logger\n nil\n end",
"def flush\n #\n end",
"def clear\n @redis.flushdb\n end",
"def flush_cache\n Rails.cache.delete([self, 'comments'])\n end",
"def reset\r\n @cache.reset\r\n end",
"def quit\n Lib.memcached_quit(@struct)\n self\n end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flushdb\n\t\t\t@redis.flushdb\n\t\t\t@log.info(\"Flushing database\")\n\t\tend",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush\n data = {}\n end",
"def clear!\n @cache = {}\n end",
"def flush\n Dir[ File.join( store, '*.cache' ) ].each do |file|\n File.delete(file)\n end\n end",
"def flush() end",
"def flush() end",
"def flush() end",
"def clear_cache!\n @cache = {}\n end",
"def clear_cache!\n @cache = {}\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush(name=nil, *args)\n return if Rails.env == 'development'\n \n name = name.to_sym\n cache = Cacheable.cache[self]\n if name.nil?\n cache.each do |method, params|\n params.clear\n end\n elsif args.nil? || args.empty?\n cache[name].clear\n else\n cache[name].delete(args)\n end\n end",
"def flush_cache!\n @cached_dependencies = {}\n end",
"def flush_cache\n KitSaasSharedCacheManagement::TokenDetails.new([client_id]).clear\n KitSaasSharedCacheManagement::TokenByTokenId.new([id]).clear\n end",
"def clear_cache\n @cache = {}\n end",
"def clear_cache\n $redis.del self.id\n end",
"def clear_cache\n $redis.del self.id\n end",
"def flush\n\n # Flushing is usually very fast, but always fix it so that the\n # entire thing is based on a constant start time\n # Saves on time syscalls too\n flush_start = Time.now.to_i\n \n @retentions.each_with_index do |retention, index|\n @current_slots[index] += 1 \n @current_slots[index] = 0 if @current_slots[index] == @slots[index] \n \n ts = (flush_start - flush_start % retention.to_i)\n counters = @counters[index][@current_slots[index]].dup\n @counters[index][@current_slots[index]] = {}\n\n if index.zero?\n counters.each_slice(50) do |keys|\n threadpool.queue ts, keys do |timestamp, keys|\n keys.each do |key, value|\n redis.client.zadd key, timestamp, \"#{timestamp}<X>#{value}\"\n end\n end\n end\n else\n counters.each_slice(100) do |keys|\n threadpool.queue ts, keys, retention do |timestamp, keys, retention|\n keys.each do |key, value|\n key = \"#{key}:#{retention}\"\n if value\n value = \"#{ts} #{value}\"\n decode_key = \"v#{DATASTORE_VERSION} #{key}\"\n diskstore.append_value_to_file(diskstore.build_filename(key), value, 0, decode_key)\n end\n end\n end\n end\n end\n\n # If this is the last retention we're handling, flush the\n # counters list to redis and reset it\n if retention == @retentions.last\n redis.add_datapoint counters.keys\n end\n\n end\n\n end",
"def clear\n cache.clear\n end",
"def drop_caches\n # old habits die hard\n logger.info \" dropping caches\"\n 3.times { %x[ /bin/sync ] }\n File.open( \"/proc/sys/vm/drop_caches\", \"w\" ) do |f|\n f.puts 3\n end\n end",
"def invalidate\n @cache_version ||= 0\n @cache_version += 1\n end",
"def clear\n @cache.clear\n end",
"def cache_clear\n @moneta.clear\n end",
"def clear_cache\n\t\tprint \"Clearing cache...\"\n\t\turl = get_url(\"clear\", @uid, @password, @sid)\n\t\trun_1010(url, \"\") { puts \"done\" }\n\tend",
"def invalidate!\n @cache = MiniCache::Store.new\n return nil\n end",
"def clear\n\n set_id_to_cache_key_map\n\n cache_response = fetch\n @id_to_cache_key_map.each do |id, key|\n Memcache.delete(key)\n Memcache.delete(\"ca_sa_shared_de_sa_cs_#{cache_response[id][:api_key]}\")\n end\n\n nil\n\n end",
"def flush\n # super \n # self.info \"FLUSH_CALLED\"\n end",
"def flush!(reason, notification_options = { })\n if @cache\n instrument('cache_flush', notification_options.merge(:reason => reason)) do\n @cache = nil\n end\n end\n\n @low_card_model.reset_column_information\n end",
"def memoize_cache_clear\n __memoize_cache__.clear\n self\n end",
"def _flush_cache(*types)\n if types.size == 0 or types.include?(:hash)\n @cache_hash = { }\n @hash_times = Hash.new(0)\n end\n\n if types.size == 0 or types.include?(:file)\n @file_times = Hash.new(0)\n @file_cache = { }\n end\n self\n end",
"def flush\n remove!\n store!\n end",
"def clear_cache\n $redis.del \"posts\"\n end",
"def flush\n @head.flush\n @txns.flush\n end",
"def free\n cache.clear\n nil\n end",
"def clear_buffer_cache!\n @buffers = nil\n end",
"def reset_cache\n self.class.reset_cache\n end",
"def clear_memo!\n self.class.clear_memo!\n end",
"def clear\n @cache = {}\n end",
"def clear_cache\n ccs.each(&:clear_cache)\n end",
"def clear\n @metadata = {}\n clear_cache\n end"
] |
[
"0.81474984",
"0.8116679",
"0.80214494",
"0.77528214",
"0.7752181",
"0.76064587",
"0.752923",
"0.7505315",
"0.7474541",
"0.7429203",
"0.7372363",
"0.7306038",
"0.72701627",
"0.7215428",
"0.7210591",
"0.71594685",
"0.7099951",
"0.6777171",
"0.67485064",
"0.67278665",
"0.6668121",
"0.6614118",
"0.6599474",
"0.65906227",
"0.6589303",
"0.6526318",
"0.6480035",
"0.6440336",
"0.64382213",
"0.6422163",
"0.6413668",
"0.6396729",
"0.6351878",
"0.6295364",
"0.6266785",
"0.62546486",
"0.6252803",
"0.62502474",
"0.6241506",
"0.62394255",
"0.62234783",
"0.62158823",
"0.6212834",
"0.6212746",
"0.61991775",
"0.61811215",
"0.6173051",
"0.6172137",
"0.6151587",
"0.6151587",
"0.6151587",
"0.6151587",
"0.6151587",
"0.6144431",
"0.6128326",
"0.6128326",
"0.6128326",
"0.6128326",
"0.6128326",
"0.6098535",
"0.6097661",
"0.60946244",
"0.6093971",
"0.6093971",
"0.6093971",
"0.6091349",
"0.6091349",
"0.60848475",
"0.60848475",
"0.60848475",
"0.60848475",
"0.6078772",
"0.6078001",
"0.6071274",
"0.60271233",
"0.6021628",
"0.6021628",
"0.60176766",
"0.6013769",
"0.6009856",
"0.6009408",
"0.5993137",
"0.5991742",
"0.5988213",
"0.5982414",
"0.5973064",
"0.5964538",
"0.59189445",
"0.59116125",
"0.5900141",
"0.5897762",
"0.5891453",
"0.58879274",
"0.58872646",
"0.5884408",
"0.5862534",
"0.5861795",
"0.58612734",
"0.58484644",
"0.5837616"
] |
0.7665477
|
5
|
Uses model's publisher's country_codes to determine how to validate zip
|
def validates_zip_code_according_to_publisher(*config)
validates_each(:zip_code, *config) do |model, attr, zip|
if zip.present?
valid = false
if model.publisher
model.publisher.country_codes.each do |country_code|
regex = postal_code_regex(country_code)
if regex.present?
valid = true if regex =~ zip
else
# valid if there's no validation regex
valid = true
end
end
else
valid = true
end
unless valid
model.errors.add(attr, I18n.t("activerecord.errors.messages.invalid"))
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validates_zip_code(*config)\n validates_each(:zip_code, *config) do |model, attr, zip|\n if zip.present?\n regex = postal_code_regex(model.country_code)\n if regex.present?\n unless regex =~ zip\n model.errors.add(attr, I18n.t(\"activerecord.errors.messages.invalid\"))\n end\n end\n end\n end\n end",
"def validate_zipcode(province_id, zipcode)\n zipcode = zipcode.to_i\n url = \"/provincia/#{province_id}/validar-codigo-postal\"\n query = \"codigo_postal=#{zipcode}\"\n get_response(url, query)\n end",
"def validate_zip_or_state\n # check format of zip and state\n enough = false\n if zip.present? && ::Geocode::ZipCode.is_valid_usa_zip_code?(zip)\n #\n enough = true\n elsif state.present?\n if ::Geocode::State::USA_STATE_CODES_TO_NAMES_MAP.include?(state.strip.upcase)\n enough = true\n else\n self.errors.add(:state, \"Invalid State\")\n end\n end\n unless enough\n self.errors.add(:zip, \"Required to set either State or Zip Code\")\n end\n end",
"def validate_zip(address)\n return SOAZipValidator(address.city, address.zipcode)\n end",
"def country_code; end",
"def country_code; end",
"def postal_code\n self[:zip]\n end",
"def zip_code_label(publisher)\n case publisher.currency_code\n when \"USD\"\n \"ZIP Code\"\n when \"GBP\"\n \"Postcode\"\n else\n \"Postal Code\"\n end\n end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def zip_code\n @zip_code || (@address_line3 if @address_line3 =~ /(?i)^[a-z0-9][a-z0-9\\- ]{0,10}[a-z0-9]$/)\n end",
"def country_codes\n raise_invalid_data_source('country_codes')\n end",
"def zip_code\n Faker::Address.zip\n end",
"def zip_code\n Faker::Address.zip\n end",
"def zipvalidate(postcode)\n !!postcode.match(/\\A[1-46][\\d]{5}\\z/)\nend",
"def zipcode\n return poi.zip unless poi.nil?\n return place.zip unless place.nil?\n return get_zipcode\n end",
"def needs_country_code?\n country_code.nil?\n end",
"def zip_code\n self[:zip]\n end",
"def zip\n self[:address][:postalCode]\n end",
"def zipcode_isValid?(zipcode)\n if(zipcode.length != 8 || !zipcode.numeric?)\n false\n else\n true\n end\nend",
"def aramex_address_validation\n zones = Spree::ShippingMethod.where(['LOWER(admin_name) like ?', '%aramex%']).map(&:zones).flatten\n if zones.map(&:countries).flatten.map(&:iso).include?(country.iso)\n response = JSON.parse(validate_address(city, zipcode, country.iso))\n if response['HasErrors'] == true && errors[:zipcode].blank?\n if response['SuggestedAddresses'].present?\n errors.add(:base, response['Notifications'].map { |data| data['Message'] }.join(', ') + ', Suggested city name is - ' + response['SuggestedAddresses'].map { |data| data['City'] }.join(', '))\n else\n cities_response = JSON.parse(fetch_cities(country.iso, city[0..1]))\n errors.add(:base, cities_response['Notifications'].map { |data| data['Message'] }.join(', ') + ', Suggested city name is - ' + cities_response['Cities'].join(' ,'))\n end\n end\n end\n rescue\n return true\n end",
"def get_zipcode\n return zip\n end",
"def check_zipcode_validity\n\t\tif (zip_code =~ /\\d{5}/) == 0\n\t\t\t#zip_code.length == 5 and \n\t\t\t# !zip_code.include? \"abcdefghijklmnopqrstuvwxyz!@#$%^&*()\"\n\t\t\tputs 'Thanks for a valid zip code!'\n\t\t\tself.call_api\n\t\t\tself.parse_api\n\t\telse\n\t\t\tputs 'Sorry friend, that zipcode is not valid. Please try again!'\n\t\tend\n\tend",
"def force_address_zipcode_numeric\n before(:each) do\n Spree::Address.class_eval do\n validates_numericality_of :zipcode\n end\n end\n\n after(:each) do\n # http://stackoverflow.com/a/11268726/737303 was useful\n Spree::Address._validators[:zipcode].reject!{|z| z.is_a?(ActiveModel::Validations::NumericalityValidator) }\n cb = Spree::Address._validate_callbacks.find{|z|\n z.raw_filter.is_a?(ActiveModel::Validations::NumericalityValidator) && z.raw_filter.attributes.include?(:zipcode)\n }\n Spree::Address._validate_callbacks.delete(cb)\n end\n end",
"def zip_code(restrictions={state: [], zip_code: []})\n zip_code = nil\n state = restrictions[:state].is_a?(Array) and !restrictions[:state].blank? ? restrictions[:state] : []\n zip_codes = restrictions[:zip_code].is_a?(Array) and !restrictions[:zip_code].blank? ? restrictions[:zip_code] : []\n\n unless @config[:location_db][:adapter].eql?(:none)\n zip_code = find_location(state, zip_codes)[\"#{@config[:location_db][:column_mapping][:zip_code]}\"]\n end\n\n zip_code = Faker::Address.zip_code if zip_code.blank?\n\n zip_code\n end",
"def is_zip_code?(user_zip)\n if user_zip.nil?\n false\n else\n user_zip.size == 5 && user_zip.to_i.to_s == user_zip && !user_zip.nil?\n end\n end",
"def check_zip_code\n zip_string = @zipcode.to_s\n raise InvalidParameterException if zip_string.size != 5\n # raise InvalidParameterException if (@zipcode.to_s =~ pattern)\n check_patterns(zip_string)\n end",
"def country_code\n end",
"def country_code\n Geocoder.search(hotel.city).first.country_code\n rescue Exception\n 'CZ'\n end",
"def has_valid_postal_code_prefix\n return unless format.is_a?(LocalPostal::Format)\n return if \"#{format.postal_code_prefix}\".empty?\n return if postal_code.start_with?(\"#{format.postal_code_prefix}\")\n\n errors.add(:postal_code, 'has an invalid prefix')\n end",
"def country_code\n end",
"def zip_code\n zip_codes = self.zip_codes.pluck(:zip)\n if self.zip_codes.count == 1 \n return self.zip.zip\n else \n return zip_codes.to_s\n end \n end",
"def geocode_postal_code\n return unless self.postal_code\n if self.postal_code && (!!self.geo_coded? || !!self.changes.symbolize_keys[:postal_code])\n res = GeoKit::Geocoders::MultiGeocoder.geocode(\"#{self.postal_code}, DE\")\n if res.success\n self.lat = res.lat\n self.lng = res.lng\n self.province_code = Project.province_name_to_code(res.state)\n end\n end\n rescue GeoKit::Geocoders::GeocodeError => ex\n logger.error \"Exception #{ex.message} caught when geocoding #{self.postal_code}, DE\"\n return\n end",
"def validation_of_zip_code(code)\n\n # check type\n for str in code.chars\n if !/\\A\\d+\\z/.match(code)\n return false\n end \n end\n\n # check length\n if code.length == 5\n return true\n else\n return false\n end\nend",
"def admin_allowed_zip_code_params\n params.require(:allowed_zip_code).permit(:zip)\n end",
"def is_regional?\n regional_code.present?\n end",
"def scotland_country_code_valid?(country)\n country == Rails.configuration.x.allowed_property_country_code\n end",
"def has_valid_postal_code_pattern\n return unless format.is_a?(LocalPostal::Format)\n\n matches = Regexp.new(format.postal_code_pattern).match(postal_code)\n\n errors.add(:postal_code, 'is invalid') unless matches.to_a.length > 0\n end",
"def check_values\n check_numericity\n check_zip_code\n end",
"def postal_code_search(_zip, _city, _country, or_search)\n unless or_search\n Rails.logger.debug \"\\t1) Determine longitude/latitude using exact search (AND)\" \n else\n Rails.logger.debug \"\\t\\t1.1) Determine longitude/latitude using matched search (OR)\"\n end\n \n geo_query = Geonames::PostalCodeSearchCriteria.new\n geo_query.place_name = [zip, city, correct(country)].compact.reject { |s| s.strip.empty? }.join(\" \")\n geo_query.max_rows = or_search ? '10' : '1'\n geo_query.is_or_operator = or_search\n \n results = Geonames::WebService.postal_code_search(geo_query)\n ensure_it_fits(results, _country)\n end",
"def is_zipcode?(address_or_zipcode)\n\t\t/\\d{5}(-| )\\d{4}$|^\\d{5}$/.match(address_or_zipcode) != nil\n\tend",
"def set_zipcode\n @zipcode = Zipcode.find(params[:zipcode])\n end",
"def require_country?\n true\n end",
"def parisian?\n return self.zip_code.starts_with? '75','77','78','91','92','93','94','95'\n end",
"def zipcode_matches_state?\n zipArray = Array.new\n zipArray[0] = /CT|MA|ME|NH|NJ|RI|VT/\n zipArray[1] = /DE|NY|PA/\n zipArray[2] = /DC|MD|NC|SC|VA|WV/\n zipArray[3] = /AL|FL|GA|MS|TN/\n zipArray[4] = /IN|KY|MI|OH/\n zipArray[5] = /IA|MN|MT|ND|SD|WI/\n zipArray[6] = /IL|KY|MO|NE/\n zipArray[7] = /AR|LA|OK|TX/\n zipArray[8] = /AZ|CO|ID|NM|NV|UT|WY/\n zipArray[9] = /AK|CA|HI|OR|WA/\n (zipArray[postalcode.chars.first.to_i] =~ province) != nil\n end",
"def indexable_zip_codes\n zip_codes = self.zip_codes.collect(&:zip_code) \n zip_codes << original_address.zip_code if original_address\n zip_codes\n end",
"def zip_service_area\n errors.add(:base, \"Zip not in current PixiPost service area.\") if PixiPostZip.find_by_zip(zip.to_i) == nil\n end",
"def find_and_save_zip(zip)\r\n # find url\r\n result = self.find_city_and_state(zip)\r\n \r\n # save result if its not nil\r\n unless result.nil?\r\n self.save_to_db(result)\r\n true\r\n else\r\n false\r\n end\r\n end",
"def valid_code?(some_code)\n country_codes.has_key?(some_code)\n end",
"def postal_code=(value)\n @postal_code = value\n end",
"def phone_number_with_country_code; end",
"def clean_zipcodes(original)\n zipcode = \"#{INVALID_ZIPCODE}#{original}\"\n zipcode = zipcode[-5..-1]\n return zipcode\n end",
"def enter_zip_and_search(code)\n fill_in 'tZip', :with => code\n click_button 'Find'\n \n # checks if it found a valid zip code.\n # 2 conditions to fail a search.\n # 1. if zip is in a valid format and no city is found.\n # 2. if zip is not in a valid format.\n # pages contains those strings.\n strs = ['Sorry', 'You did not enter a valid ZIP Code']\n if ScrapeUtil.has_content_or?(page, strs)\n false\n else\n # found a valid zip.\n # the first p tag contains the city.\n result = first(:xpath, '//div[@id=\"result-cities\"]/p')\n #result.text\n hash_result = self.city_state_as_hash(code, result.text)\n \n # save to db.\n self.save_to_db(hash_result)\n \n hash_result\n end\n end",
"def search_zip_code\r\n @addresses = Address.find_by_zip_code(params[:address][:zip_code])\r\n end",
"def set_postal_address\n\n\tpostal_address = PostalAddress.find_by_postal_address_type_code_and_city_and_address1_and_address2(self.postal_address_type_code,self.city,self.address1,self.address2)\n\t if postal_address != nil \n\t\t self.postal_address = postal_address\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'postal_address_type_code' and 'city' and 'address1' and 'address2' is invalid- it must be unique\")\n\t\t return false\n\tend\nend",
"def cell_phone_with_country_code; end",
"def iso_code; end",
"def iso_code; end",
"def validate(address)\n if (address.country.present? && scotland_country_code_valid?(address.country) == false) ||\n (address.postcode.present? && scotland_postcode_format_valid?(address.postcode) == false)\n address.errors.add(:postcode, :postcode_format_invalid)\n end\n end",
"def country(code, name); end",
"def postal_code\n return @postal_code\n end",
"def postal_code_required_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.span.id(\"/valZip$/\"), format_method(__method__))\n end",
"def validate\r\n invalid_strings = [\r\n 'PO BOX', 'P.O. BOX', 'P.O BOX', 'PO. BOX', 'POBOX',\r\n 'P.OBOX', 'P.O.BOX', 'PO.BOX', 'P.BOX', 'PBOX', 'AFO',\r\n 'A.F.O.', 'APO', 'A.P.O.'\r\n ]\r\n cap_address = self.address.upcase()\r\n invalid_strings.each do |string|\r\n if cap_address.include?(string) then\r\n errors.add(:address, \"Sorry, we don't ship to P.O. boxes\")\r\n end\r\n end\r\n if self.country && self.country.name == \"United States of America\"\r\n unless zip.blank?\r\n unless zip =~ /^\\d{5}/\r\n errors.add(:zip, \"Please enter a valid zip.\")\r\n end\r\n end\r\n self.state = self.state.upcase\r\n errors.add(:state, \"Please use a US state abbreviation\") unless US_STATES.include?(self.state)\r\n end\r\n end",
"def filters_dutch_zipcode(*args)\n create_filtered_accessor(\"filter_dutch_zipcode\", args)\n end",
"def fix_up_zip_code(zip)\n return nil unless zip.present?\n return nil if (zip =~ /\\A(\\d{5})/).nil?\n $1\n end",
"def vat_number_expected?\n return false unless has_billing?\n billing_address.country != store.country\n end",
"def postal; end",
"def locality_region_and_postal_code(postal_code_type)\n country_is?(:canada) ?\n locality_region_and_postal_code_ca(postal_code_type) :\n locality_region_and_postal_code_us(postal_code_type)\n end",
"def check_billing_postcode?\n if billing_postcode != nil\n ukpc = UKPostcode.parse(billing_postcode)\n unless ukpc.full_valid?\n errors.add(:billing_postcode, \"not recognised as a UK postcode\")\n end\n end\n end",
"def iban_country_code; end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def country_code_long; end",
"def address_change\n @update_cart_invoice = zip_code_changed?\n true\n end",
"def zip_code=(zip_code)\n if zip_code.nil?\n fail ArgumentError, \"zip_code cannot be nil\"\n end\n\n if zip_code !~ Regexp.new(/^\\\\d{3}-?\\\\d{4}$/)\n fail ArgumentError, \"invalid value for 'zip_code', must conform to the pattern /^\\\\d{3}-?\\\\d{4}$/.\"\n end\n\n @zip_code = zip_code\n end",
"def set_zip_code_area_code\n @zip_code_area_code = ZipCodeAreaCode.find(params[:id])\n end",
"def country_code\n (self.country.nil? ? nil : self.country.code)\n end",
"def valid_address\n @address_string ||= [:street_address, :postal_code].map{|f| self.send(f)}.join(',')\n \n res=Geokit::Geocoders::GoogleGeocoder.geocode(@address_string)\n \n if res.success && res.precision.to_sym == :address\n\n self.street_address = res.street_address.upcase\n self.postal_code \t= res.zip.gsub(/\\s+/,'') \n self.lat = res.lat\n self.lng = res.lng\n \n country = Country.find_by_iso2(res.country_code)\n region = country.regions.find_or_create_by_code(res.state)\n city = region.cities.find_or_create_by_name_and_country_id(res.city, country.id) \n self.city = city\n\n elsif military_address?\n self.city = Country.find_by_iso2(res.country_code).regions.\n find_by_code(res.state).cities.find_by_name(res.city)\n return true \n else\n errors.add_to_base('Sorry the address is not valid')\n end \n end",
"def set_Zipcode(value)\n set_input(\"Zipcode\", value)\n end",
"def country; end",
"def country; end",
"def country; end",
"def define_postal_code\n @postal_code = Faker::Address.zip_code(state_abbreviation: @state)\n @postal_code = '' unless @set_blank == false\n end",
"def set_zip_code\n @zip_code = ZipCode.find(params[:id])\n end",
"def zip_postal_code_field\n $tracer.trace(__method__)\n #unit_test_no_generate: zip_postal_code_field, input.id(\"PostalCode\")\n return ToolTag.new(input.id(\"PostalCode\"), __method__, self)\n end",
"def country_code\n decode hash[\"CountryCode\"]\n end",
"def validate_country\n return unless country.present?\n return if country.valid?\n\n errors.add(:country, \"Is invalid: #{country.errors.full_messages}\")\n end",
"def set_admin_allowed_zip_code\n @admin_allowed_zip_code = AllowedZipCode.find(params[:id])\n end",
"def represented_country; end",
"def load_districts_zip(zip_code)\n params = {'zip' => zip_code}\n @districts = process('districts', 'districts/locate', params)\n end",
"def initialize(postcode)\n @country = 'BE'\n @postcode = clean(postcode)\n @postcode = @postcode.gsub(' ', '')\n @parts = [@postcode]\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end"
] |
[
"0.7138594",
"0.66672224",
"0.65053076",
"0.6392671",
"0.6359189",
"0.6359189",
"0.63049567",
"0.62893486",
"0.6233901",
"0.6233901",
"0.6233901",
"0.6233901",
"0.6233901",
"0.6233901",
"0.62141407",
"0.61871076",
"0.61671257",
"0.61671257",
"0.6137648",
"0.60821",
"0.6071982",
"0.60312563",
"0.600484",
"0.5969288",
"0.59506863",
"0.59407413",
"0.59322405",
"0.5930072",
"0.59057885",
"0.58975446",
"0.5897484",
"0.5897472",
"0.588842",
"0.5865544",
"0.5863933",
"0.58548117",
"0.584954",
"0.5846915",
"0.5827194",
"0.58234465",
"0.5810823",
"0.57990694",
"0.5792317",
"0.5773124",
"0.5768999",
"0.5766336",
"0.5747475",
"0.5746329",
"0.5737292",
"0.5717509",
"0.57003945",
"0.5694491",
"0.5679861",
"0.5678603",
"0.56679094",
"0.5661862",
"0.56596905",
"0.5652734",
"0.56518024",
"0.5648369",
"0.56361324",
"0.56361324",
"0.5628984",
"0.56190664",
"0.5604758",
"0.5603415",
"0.5585994",
"0.55826324",
"0.5573643",
"0.5572154",
"0.5565695",
"0.55632925",
"0.55562055",
"0.5555854",
"0.55558085",
"0.55558085",
"0.55558085",
"0.55558085",
"0.55481976",
"0.55436933",
"0.5525215",
"0.55211204",
"0.5520719",
"0.5520579",
"0.5517849",
"0.5507195",
"0.5507195",
"0.5507195",
"0.5505336",
"0.550149",
"0.5492811",
"0.54821825",
"0.54553354",
"0.54549664",
"0.5453254",
"0.54529995",
"0.5447112",
"0.54428625",
"0.54428625",
"0.54428625"
] |
0.8111252
|
0
|
If there's no country code at all, pretend us If there is a country code, the regex might still be nil....
|
def postal_code_regex(country_code)
return us_regex if country_code.nil?
Country.postal_code_regex(country_code)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def needs_country_code?\n country_code.nil?\n end",
"def drop_country(affi_string)\n found_ctry = get_country_any(affi_string)\n dropped_country = affi_string.gsub(found_ctry,\"\").strip\n return dropped_country\nend",
"def phone_number_with_country_code; end",
"def has_valid_postal_code_pattern\n return unless format.is_a?(LocalPostal::Format)\n\n matches = Regexp.new(format.postal_code_pattern).match(postal_code)\n\n errors.add(:postal_code, 'is invalid') unless matches.to_a.length > 0\n end",
"def get_iso_country(country)\n #Kinda redundant but downcasing first makes the hardcoding a bit more obvious\n country = country.downcase\n\n if country == \"bosnia-herzogovnia\"\n country = \"bosnia and herzogovnia\"\n elsif country == \"russia\"\n country = \"russian federation\"\n elsif country == \"laos\"\n country = \"lao peoples democratic republic\"\n elsif country == \"iran\"\n country = \"islamic republic of iran\"\n elsif country == \"taiwan\"\n country = \"province of china taiwan\"\n elsif country == \"north korea\"\n country = \"democratic people's republic of korea\"\n elsif country == \"south korea\"\n country = \"republic of korea\"\n elsif country == \"basque spain\"\n country = \"spain\"\n elsif country == \"macedonia\"\n country = \"the former yugoslav republic of macedonia\"\n elsif country == \"tanzania\"\n country = \"united republic of tanzania\"\n elsif country == \"vietnam\"\n country = \"viet nam\"\n elsif country == \"venezuela\"\n country = \"bolivarian republic of venezuela\"\n elsif country == \"syria\"\n country = \"syrian arab republic\"\n elsif country == \"rep.dem.congo\"\n country = \"congo\"\n elsif country == \"dagestan\"\n country = \"russian federation\"\n elsif country == \"adygea\"\n country = \"russian federation\"\n elsif country == \"karachaevo circassia\"\n country = \"russian federation\"\n elsif country == \"tartarstan\"\n country = \"russian federation\"\n #elsif country == \"ivory coast\"\n # This seems like the wrong way of doing this but not sure how else to guarentee the match\n #country = \"CÃTE D'IVOIRE\".downcase\n end\n\n country = normalize(country)\n \n @@iso_country_codes.xpath(\"//ISO_3166-1_Entry\").each do |code|\n n_country = normalize(code.xpath(\"ISO_3166-1_Country_name\")[0].content)\n\n if (country.upcase == n_country.upcase)\n return code.xpath(\"ISO_3166-1_Alpha-2_Code_element\")[0].content\n end\n end\n return \"ZZ\"\n end",
"def zipvalidate(postcode)\n !!postcode.match(/\\A[1-46][\\d]{5}\\z/)\nend",
"def strip_country_code(number)\n return nil unless number\n\n number = normalize_phone_number(number)\n if number.start_with?(\"+\")\n number = number[1..-1] \n\n # Put in a hack for numbers like 15102223333\n if number.length == 11 && number.start_with?(@@_default_country_code)\n return [@@_default_country_code,number[1..-1]]\n end\n\n # Now go through the countries until we match\n (1..5).each do |i|\n if COUNTRY_CODES[number[0...i]]\n return [number[0...i], number[i..-1]]\n end\n end\n else \n return [@@_default_country_code, number]\n end\n end",
"def match_postal_code(postal_code)\n /\\A\\s*(?<fsa>[a-zA-Z]\\d[a-zA-Z])\\s*(?<ldu>\\d[a-zA-Z]\\d)\\s*\\z/\n .match(postal_code)\n end",
"def validate_country(country)\n return false if country.to_s.length == 0\n return false if !validate_residency(country)\n if(PRgovCAPWebApp::App.settings.country_codes.has_key? country)\n return true\n else\n return false\n end\n end",
"def get_country(affi_string)\n cleared_affi_string = country_exclude(affi_string)\n $affi_countries.each do |country|\n if cleared_affi_string.include?(country)\n return country\n end\n end\n return nil\nend",
"def country_code\n Geocoder.search(hotel.city).first.country_code\n rescue Exception\n 'CZ'\n end",
"def normalize_country\n c = @data_object.add_country.strip\n\n c = c.downcase.gsub(/[\\. ]/, '').sub(/^the/, '')\n \n if US_MAP[c]\n @data_object.add_country = USA\n end\n\n end",
"def country_by_code(code: T.unsafe(nil)); end",
"def country_code_alpha2\n country_code == 'EL' ? 'GR' : country_code\n end",
"def zip_code\n @zip_code || (@address_line3 if @address_line3 =~ /(?i)^[a-z0-9][a-z0-9\\- ]{0,10}[a-z0-9]$/)\n end",
"def valid_birthdate(input)\n# if input.length == 8 && input.match(/^[0-9]+[0-9]$/) my code\n# SK code:\n if(input.length == 8 && !input.match(/^[0-9]+[0-9]$/).nil?)\n true\n else\n false\n end\nend",
"def country_code; end",
"def country_code; end",
"def country_exclude(affi_string)\n $country_exceptions.each do |not_a_country|\n if affi_string.include?(not_a_country)\n return affi_string.gsub(not_a_country, \"\")\n end\n end\n # if notting is removed\n return affi_string\nend",
"def validate_country\n return unless country.present?\n return if country.valid?\n\n errors.add(:country, \"Is invalid: #{country.errors.full_messages}\")\n end",
"def validate(country)\n raise UnknownCountry, \"Country not found.\" if country.empty?\n end",
"def get_sale_country(address)\n country = \"\"\n\n if address[\"c\"] != \"-\"\n country = address[\"c\"]\n elsif address[\"r\"] != \"-\"\n #if address[\"r\"] contains only numbers do not want\n country = get_country(address[\"r\"]) unless address[\"r\"] =~ /\\d+$/\n elsif address[\"l\"] != \"-\"\n country = get_country(address[\"l\"])\n end\n\n return country\n end",
"def reserved country_code\n # Does nothing, will just fail with an exception.\n end",
"def scotland_country_code_valid?(country)\n country == Rails.configuration.x.allowed_property_country_code\n end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes\n raise_invalid_data_source('country_codes')\n end",
"def country_code\n cc = carmen_country\n\n cc ? \"#{cc.code.upcase}\" : nil\n end",
"def get_country(str)\n data = check_local_db(str)\n\n if data.nil? \n data = Geocoder.search(str)\n\n #has to parse through geocode data to find correct result\n data.first.address_components.each do |obj|\n data = obj[\"short_name\"] if obj[\"types\"][0] == \"country\"\n end\n\n save_to_db(str, data)\n end\n\n return data\n end",
"def invalid_for_country?(country)\n !valid_for_country?(country)\n end",
"def test_iban_country_code\n assert_match(/^[A-Z]{2}$/, @tester.iban_country_code)\n end",
"def country(code, name); end",
"def get_clean_city_name(city_with_abbr)\n if city_with_abbr\n city_name_match = city_with_abbr.match(/([A-Za-zçã\\s]*).*/)\n city_name_match = city_name_match[1] if city_name_match\n end\n return city_name_match\n end",
"def require_country?\n true\n end",
"def virginia_borrower?\n # @profile !~ /^[a-z]{2,3}([0-9][a-z]{1,2})?$/i\n profile.match?(/Virginia Borrower|Other VA Faculty|Alum/i) ||\n profile.blank?\n end",
"def get_area_code(phone)\n country_code,number = strip_country_code(phone)\n if country_code == @@_default_country_code && number.length == 10\n number[0..2]\n else\n nil\n end\n end",
"def cell_phone_with_country_code; end",
"def country_code\n (self.country.nil? ? nil : self.country.code)\n end",
"def selected_country_code(address)\n address.country_code.blank? ? 'AU' : address.country_code\n end",
"def extract_postcode(address)\n postcode = \"\"\n if /[[:alpha:]]+\\d+\\s\\d+[[:alpha:]][[:alpha:]]/.match(address)\n postcode = /[[:alpha:]]+\\d+\\s\\d+[[:alpha:]][[:alpha:]]/.match(address)[0]\n end\nend",
"def valid_code?(some_code)\n country_codes.has_key?(some_code)\n end",
"def best_guess_at_country\n return self.country if !self.country.nil?\n\n extension_possibilities = []\n extension_possibilities << \".#{self.uri.to_s.gsub(/^.+organisations\\/.+\\-/, '')}\"\n extension_possibilities << self.uri.to_s.gsub(/^.+organisations\\/[A-z]+/, '').gsub(/\\-/, '.')\n extension_possibilities << self.uri.to_s.match(/\\-[A-z]+\\-[A-z]+$/)[0].gsub(/\\-/, '.') rescue ''\n mapping = ArtsAPI::COUNTRIES_MAPPING\n\n result = nil\n extension_possibilities.each { |ex| result = mapping[ex] if mapping.has_key?(ex) }\n\n if !result.nil?\n self.country = result\n self.save\n end\n\n result\n end",
"def process_country_names(country)\n # country.map do |c|\n country.gsub!('&', 'and')\n country.gsub /\\s+/, '-'\n # end\n end",
"def match_phone_number(number)\n /\\A\\s*\\(?\\s*?(?<area_code>\\d{3})\\s*\\)?[-.\\s]*(?<exchange>\\d{3})[-.\\s]*(?<number>\\d{4})([xX\\s]*(?<ext>\\d+))?\\s*\\z/\n .match(number)\n end",
"def country_name_to_code(name: T.unsafe(nil)); end",
"def check_billing_postcode?\n if billing_postcode != nil\n ukpc = UKPostcode.parse(billing_postcode)\n unless ukpc.full_valid?\n errors.add(:billing_postcode, \"not recognised as a UK postcode\")\n end\n end\n end",
"def strip_non_digits\n country_code.gsub!(/[^\\d]/, '') unless country_code.blank?\n local_number.gsub!(/[^\\d]/, '') unless local_number.blank?\n extension.gsub!(/[^\\d]/, '') unless extension.blank?\n end",
"def reserved_nets_regex; end",
"def country\n @country ||= IsoCountryCodes.find(alpha2)\n end",
"def matches_local_number_with_area_code?(string)\n string =~ area_code_number_regex && string =~ number_format_regex\n end",
"def restricted_country_code\n if obj.restricted_country_code.blank?\n nil\n else\n obj.restricted_country_code\n end\n end",
"def pattern(options_hash)\n settings[options_hash[:country]]['regexp']\n end",
"def validate_regex\n if !company.nil? && company.allow_email_regex == true\n # if email =~ /#{company.email_format}/i\n if email =~ /^([^@\\s]+)@((?:#{company.email_format}))$/i\n true\n else\n errors.add(:email, ' format not match')\n end\n else \n return true\n end\n end",
"def load_country_code(sections)\n # For now we assume all phone numbers are USA centric. If we wish to support other country\n # codes in the future we will need to enforce the presence of a country code when entering\n # a phone number\n return USA unless sections.first.length == 1\n\n raise \"Unsupported Country Code\" unless COUNTRY_CODES.include?(sections.first)\n\n sections.shift\n end",
"def address(input)\n\t(/[0-9]{4}(\\s|\\,){1}(.+?)(\\s|\\,){1}(?i)((str)|(street)|(ave)|(avenue)|(rd)|(road)|(blvd)|(boulevard))(\\.)?/i =~ input)? \"true\" : \"false\"\nend",
"def matches_local_number?(string, default_area_code)\n string =~ number_regex && default_area_code =~ area_code_regex\n end",
"def parse_number(some_number)\n some_number = clean(some_number)\n country_code = parse_code(some_number)\n some_number[country_code.length,some_number.length] unless country_code.nil?\n end",
"def get_country_name( code )\n # Strip and lowercase code\n new_code = code.strip.downcase\n # Find country by code. If not found, default to empty string.\n country = $COUNTRIES.find do |record|\n record[:code] == new_code.downcase\n end || ''\n\n return country.length > 0 ? \"The country you selected is #{country[:name]}.\" :\n 'That country code is not in our database.'\nend",
"def replace_country_code( value )\n $COUNTRIES.each do |record|\n # Replace country code with emoji using gsub\n # Use interpolation with regex then compare the variable with i option to ignore case sensitivity \n value = value.gsub(/#{record[:code]}/i, record[:code].flag_emoji+\" \") # I chose not to use gsub with ! because it was modifying the reference variable\n end\n return value\nend",
"def country_code\n if self.uk?\n UK_COUNTRY_CODE\n else\n IE_COUNTRY_CODE\n end\n end",
"def is_zipcode?(address_or_zipcode)\n\t\t/\\d{5}(-| )\\d{4}$|^\\d{5}$/.match(address_or_zipcode) != nil\n\tend",
"def scotland_postcode_format_valid?(postcode)\n postcode.match?(SCOTLAND_POSTCODE_REGEX)\n end",
"def valid_ISO?(str)\n # The iso_country_codes gem's ::for_select method provides all name and ISO pairs\n # in an array. Map the second el of each pair to create a list of just ISO codes.\n full_list = IsoCountryCodes.for_select.map { |pair| pair[1] }\n\n # Check to see if the two char str is in the ISO list\n full_list.include?(str.upcase)\nend",
"def iban(country_code: T.unsafe(nil)); end",
"def guess_country\n warnings = Array.new\n\n country_name = country\n residence_name = residence\n\n if country_name && country_name.length > 2\n self.country = lookup_isocode(country_name)\n warnings << \"Country of origin #{country_name} is not in ISO directory\" unless country\n end\n\n if residence_name && residence_name.length > 2\n self.residence = lookup_isocode(residence_name)\n warnings << \"Country of residence #{residence_name} is not in ISO directory\" unless residence\n end\n\n return warnings\n end",
"def exists_in_country_list\n country_code.upcase!\n if !Map.is_country_code?(country_code)\n errors.add(:country_code, \"is not in the list of allowed countries\")\n end\n end",
"def validLanguageISOid?(isoID)\n return /\\A[a-z]{3}\\z/.match? (isoID)\n end",
"def check_fr(word)\n /\\A(\\,|\\?|\\!|\\+)/.match(word) != nil\n end",
"def is_valid_location_id?(location_id)\n !/^[A-Z]+$/.match(location_id).nil?\nend",
"def can_encode?(str)\n str.nil? || !(GSM_REGEX =~ str).nil?\n end",
"def iban_country_code; end",
"def is_international?(phone)\n country_code,number = strip_country_code(phone)\n country_code != @@_default_country_code\n end",
"def validation_of_zip_code(code)\n\n # check type\n for str in code.chars\n if !/\\A\\d+\\z/.match(code)\n return false\n end \n end\n\n # check length\n if code.length == 5\n return true\n else\n return false\n end\nend",
"def country\n @country ||= begin\n valid_countries.find do |iso2|\n @data[iso2][Core::MAIN_COUNTRY_FOR_CODE] == 'true'\n end || valid_countries.first || countries.first\n end\n end",
"def is_regional?\n regional_code.present?\n end",
"def country_code_map\r\n {\r\n 'Ägypten' => 'eg',\r\n 'Albanien' => 'al',\r\n 'Algerien' => 'dz',\r\n 'Argentinien' => 'ar',\r\n 'Australien' => 'au',\r\n 'Belgien' => 'be',\r\n 'Bosnien-Herzegowina' => 'ba',\r\n 'Brasilien' => 'br',\r\n 'Chile' => 'cl',\r\n 'Costa Rica' => 'cr',\r\n 'Dänemark' => 'dk',\r\n 'Deutschland' => 'de',\r\n 'Ecuador' => 'ec',\r\n 'Elfenbeinküste' => 'ci',\r\n 'England' => '_England',\r\n 'Frankreich' => 'fr',\r\n 'Ghana' => 'gh',\r\n 'Griechenland' => 'gr',\r\n 'Honduras' => 'hn',\r\n 'Iran' => 'ir',\r\n 'Irland' => 'ie',\r\n 'Island' => 'is',\r\n 'Italien' => 'it',\r\n 'Japan' => 'jp',\r\n 'Kamerun' => 'cm',\r\n 'Kolumbien' => 'co',\r\n 'Kroatien' => 'hr',\r\n 'Marokko' => 'ma',\r\n 'Mexiko' => 'mx',\r\n 'Niederlande' => 'nl',\r\n 'Nigeria' => 'ng',\r\n 'Nordirland' => '_Northern_Ireland',\r\n 'Österreich' => 'at',\r\n 'Panama' => 'pa',\r\n 'Peru' => 'pe',\r\n 'Polen' => 'pl',\r\n 'Portugal' => 'pt',\r\n 'Rumänien' => 'ro',\r\n 'Russland' => 'ru',\r\n 'Saudi-Arabien' => 'sa',\r\n 'Schweden' => 'se',\r\n 'Schweiz' => 'ch',\r\n 'Senegal' => 'sn',\r\n 'Serbien' => 'rs',\r\n 'Slowakei' => 'sk',\r\n 'Spanien' => 'es',\r\n 'Südkorea' => 'kr',\r\n 'Tschechien' => 'cz',\r\n 'Tunesien' => 'tn',\r\n 'Türkei' => 'tr',\r\n 'Ukraine' => 'ua',\r\n 'Ungarn' => 'hu',\r\n 'USA' => 'us',\r\n 'Uruguay' => 'uy',\r\n 'Wales' => '_Wales'\r\n }\r\nend",
"def ensure_CountryName\n\t\tif self.CountryName == \"\"\n\t\t\tself.CountryName = \"United States\"\n\t\tend\n\t\tif [\"AB\", \"BC\", \"MB\", \"NB\"].include?(self.State)\n\t\t\tself.CountryName = \"Canada\"\n\t\tend\n\tend",
"def ensure_CountryName\n\t\tif self.CountryName == \"\"\n\t\t\tself.CountryName = \"United States\"\n\t\tend\n\t\tif [\"AB\", \"BC\", \"MB\", \"NB\"].include?(self.State)\n\t\t\tself.CountryName = \"Canada\"\n\t\tend\n\tend",
"def country_code_map\r\n {\r\n 'Ägypten' => 'eg',\r\n 'Albanien' => 'al',\r\n 'Algerien' => 'dz',\r\n 'Argentinien' => 'ar',\r\n 'Australien' => 'au',\r\n 'Belgien' => 'be',\r\n 'Bosnien-Herzegowina' => 'ba',\r\n 'Brasilien' => 'br',\r\n 'Chile' => 'cl',\r\n 'Costa Rica' => 'cr',\r\n 'Dänemark' => 'dk',\r\n 'Deutschland' => 'de',\r\n 'Ecuador' => 'ec',\r\n 'Elfenbeinküste' => 'ci',\r\n 'England' => '_England',\r\n 'Finnland' => 'fi',\r\n 'Frankreich' => 'fr',\r\n 'Ghana' => 'gh',\r\n 'Griechenland' => 'gr',\r\n 'Honduras' => 'hn',\r\n 'Iran' => 'ir',\r\n 'Irland' => 'ie',\r\n 'Island' => 'is',\r\n 'Italien' => 'it',\r\n 'Japan' => 'jp',\r\n 'Kamerun' => 'cm',\r\n 'Kanada' => 'ca',\r\n 'Katar' => 'kz',\r\n 'Kolumbien' => 'co',\r\n 'Kroatien' => 'hr',\r\n 'Marokko' => 'ma',\r\n 'Mexiko' => 'mx',\r\n 'Niederlande' => 'nl',\r\n 'Nigeria' => 'ng',\r\n 'Nordirland' => '_Northern_Ireland',\r\n 'Nordmazedonien' => 'mk',\r\n 'Österreich' => 'at',\r\n 'Panama' => 'pa',\r\n 'Peru' => 'pe',\r\n 'Polen' => 'pl',\r\n 'Portugal' => 'pt',\r\n 'Rumänien' => 'ro',\r\n 'Russland' => 'ru',\r\n 'Saudi-Arabien' => 'sa',\r\n 'Schottland' => '_Scotland',\r\n 'Schweden' => 'se',\r\n 'Schweiz' => 'ch',\r\n 'Senegal' => 'sn',\r\n 'Serbien' => 'rs',\r\n 'Slowakei' => 'sk',\r\n 'Spanien' => 'es',\r\n 'Südkorea' => 'kr',\r\n 'Tschechien' => 'cz',\r\n 'Tunesien' => 'tn',\r\n 'Türkei' => 'tr',\r\n 'Ukraine' => 'ua',\r\n 'Ungarn' => 'hu',\r\n 'USA' => 'us',\r\n 'Uruguay' => 'uy',\r\n 'Wales' => '_Wales'\r\n }\r\nend",
"def regexp; end",
"def regexp; end",
"def clean_for_comp( address = '' )\n address.upcase.gsub /[^0-9A-Z]/, ''\nend",
"def google_plus(word)\n if /\\Z+/.match(word) != nil && /google/i.match(word) != nil\n true\n else\n false\n end\n end",
"def country=(value)\n @country = value\n\n @format = case country_code\n when nil, '' then nil\n else LocalPostal::Format.from_country_code(country_code)\n end\n end",
"def valid_phone( phone )\r\n\tphone_regex = /^\\(?\\d{3}\\)?-?\\d{3}-?\\d{4}$/\r\n\tif phone =~ phone_regex\r\n\t\ttrue\r\n\telse\r\n\t\tfalse\r\n\tend\r\nend",
"def get_country_any(affi_string)\n cleared_affi_string = country_exclude(affi_string)\n $affi_countries.each do |country|\n if cleared_affi_string.include?(country)\n return country\n end\n end\n $country_synonyms.keys.each do |ctry_key|\n if cleared_affi_string.include?(ctry_key.to_s)\n return $country_synonyms[ctry_key]\n end\n end\n return nil\nend",
"def valid_phone(str)\n if str.length != 14\n return false\n elsif str[0] != \"(\" || str[4] != \")\" || str[5] != \" \" && str[-5] != \"-\"\n return false\n end\n true\nend",
"def valid_address\n @address_string ||= [:street_address, :postal_code].map{|f| self.send(f)}.join(',')\n \n res=Geokit::Geocoders::GoogleGeocoder.geocode(@address_string)\n \n if res.success && res.precision.to_sym == :address\n\n self.street_address = res.street_address.upcase\n self.postal_code \t= res.zip.gsub(/\\s+/,'') \n self.lat = res.lat\n self.lng = res.lng\n \n country = Country.find_by_iso2(res.country_code)\n region = country.regions.find_or_create_by_code(res.state)\n city = region.cities.find_or_create_by_name_and_country_id(res.city, country.id) \n self.city = city\n\n elsif military_address?\n self.city = Country.find_by_iso2(res.country_code).regions.\n find_by_code(res.state).cities.find_by_name(res.city)\n return true \n else\n errors.add_to_base('Sorry the address is not valid')\n end \n end",
"def has_valid_postal_code_prefix\n return unless format.is_a?(LocalPostal::Format)\n return if \"#{format.postal_code_prefix}\".empty?\n return if postal_code.start_with?(\"#{format.postal_code_prefix}\")\n\n errors.add(:postal_code, 'has an invalid prefix')\n end",
"def correct(country)\n MAPPING_FIX[country] || country\n end",
"def country_data?(row)\n !row[1].nil? && !row[3].nil? && row[3][0] == \".\"\n end",
"def valid_for_country?(country)\n country = country.to_s.upcase\n @data.select do |iso2, data|\n country == iso2 && data[:valid].any?\n end.any?\n end",
"def check_reject_regex(value, default_value, regex)\n if regex.match(value)\n default_value\n else\n value\n end\n end",
"def check_country_codes(countries, row)\n @known_codes ||= countries.reduce(Set.new) { |a,(_,v)| a.merge v; a }\n unless @known_codes.include?(row[2])\n puts \"#{row[2]}: #{row[0]}..#{row[1]}\"\n end\n end",
"def get_country_short_from_ip(remote_ip)\n begin\n geoip = GeoIP.new(\"#{Rails.root}/lib/GeoIP.dat\")\n country = geoip.country(remote_ip)\n\n if country != nil and country.country_code > 0\n short = translate_site(country.country_code2) # Se if we have a GB that should be UK\n return short\n end\n rescue\n return false\n end\n return false\n end",
"def test_gem_handles_weird_chars_without_exceptions\r\n assert_nothing_raised do\r\n assert_equal \"DE\", Autometal::Geoip.new('78.46.60.181').country\r\n assert_equal \"SE\", Autometal::Geoip.new('81.237.231.174').country\r\n end\r\n end"
] |
[
"0.6206724",
"0.6167595",
"0.6135322",
"0.61207247",
"0.61026204",
"0.608198",
"0.60280263",
"0.60259247",
"0.6023773",
"0.5996231",
"0.59501666",
"0.59468794",
"0.5934802",
"0.59014714",
"0.5863764",
"0.5859394",
"0.5856711",
"0.5856711",
"0.5839878",
"0.5838371",
"0.5837967",
"0.5822789",
"0.58202755",
"0.58092743",
"0.5806676",
"0.5806676",
"0.5806676",
"0.5806676",
"0.5806676",
"0.5806676",
"0.58028316",
"0.57963324",
"0.5760834",
"0.57450306",
"0.5722566",
"0.56982744",
"0.5696729",
"0.56928563",
"0.5684471",
"0.5681102",
"0.56805176",
"0.56682384",
"0.56556773",
"0.5638145",
"0.5626005",
"0.5612188",
"0.5607464",
"0.5590185",
"0.5583542",
"0.5571242",
"0.5565685",
"0.55413264",
"0.55335736",
"0.5528904",
"0.55250126",
"0.5521273",
"0.55205107",
"0.54885155",
"0.54841197",
"0.5477421",
"0.5470655",
"0.5464455",
"0.54627985",
"0.54575706",
"0.54569924",
"0.5435057",
"0.5433422",
"0.54217434",
"0.54190636",
"0.5416913",
"0.5414059",
"0.5394432",
"0.5385926",
"0.53731674",
"0.53642464",
"0.5343246",
"0.534076",
"0.53356385",
"0.5326067",
"0.532472",
"0.53221595",
"0.53221595",
"0.53101325",
"0.5305755",
"0.5305755",
"0.5303939",
"0.5294791",
"0.528934",
"0.5288066",
"0.528709",
"0.5278744",
"0.52763057",
"0.52650183",
"0.5264037",
"0.5260745",
"0.5258528",
"0.5247853",
"0.5245211",
"0.52420187",
"0.52407897"
] |
0.74367326
|
0
|
Uses the model''s country code to determine how to validate zip
|
def validates_zip_code(*config)
validates_each(:zip_code, *config) do |model, attr, zip|
if zip.present?
regex = postal_code_regex(model.country_code)
if regex.present?
unless regex =~ zip
model.errors.add(attr, I18n.t("activerecord.errors.messages.invalid"))
end
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validates_zip_code_according_to_publisher(*config)\n validates_each(:zip_code, *config) do |model, attr, zip|\n if zip.present?\n valid = false\n if model.publisher\n model.publisher.country_codes.each do |country_code|\n regex = postal_code_regex(country_code)\n if regex.present?\n valid = true if regex =~ zip\n else\n # valid if there's no validation regex\n valid = true\n end\n end\n else\n valid = true\n end\n unless valid\n model.errors.add(attr, I18n.t(\"activerecord.errors.messages.invalid\"))\n end\n end\n end\n end",
"def validate_zipcode(province_id, zipcode)\n zipcode = zipcode.to_i\n url = \"/provincia/#{province_id}/validar-codigo-postal\"\n query = \"codigo_postal=#{zipcode}\"\n get_response(url, query)\n end",
"def validate_zip_or_state\n # check format of zip and state\n enough = false\n if zip.present? && ::Geocode::ZipCode.is_valid_usa_zip_code?(zip)\n #\n enough = true\n elsif state.present?\n if ::Geocode::State::USA_STATE_CODES_TO_NAMES_MAP.include?(state.strip.upcase)\n enough = true\n else\n self.errors.add(:state, \"Invalid State\")\n end\n end\n unless enough\n self.errors.add(:zip, \"Required to set either State or Zip Code\")\n end\n end",
"def validate_zip(address)\n return SOAZipValidator(address.city, address.zipcode)\n end",
"def zip_code\n @zip_code || (@address_line3 if @address_line3 =~ /(?i)^[a-z0-9][a-z0-9\\- ]{0,10}[a-z0-9]$/)\n end",
"def zip_code\n Faker::Address.zip\n end",
"def zip_code\n Faker::Address.zip\n end",
"def aramex_address_validation\n zones = Spree::ShippingMethod.where(['LOWER(admin_name) like ?', '%aramex%']).map(&:zones).flatten\n if zones.map(&:countries).flatten.map(&:iso).include?(country.iso)\n response = JSON.parse(validate_address(city, zipcode, country.iso))\n if response['HasErrors'] == true && errors[:zipcode].blank?\n if response['SuggestedAddresses'].present?\n errors.add(:base, response['Notifications'].map { |data| data['Message'] }.join(', ') + ', Suggested city name is - ' + response['SuggestedAddresses'].map { |data| data['City'] }.join(', '))\n else\n cities_response = JSON.parse(fetch_cities(country.iso, city[0..1]))\n errors.add(:base, cities_response['Notifications'].map { |data| data['Message'] }.join(', ') + ', Suggested city name is - ' + cities_response['Cities'].join(' ,'))\n end\n end\n end\n rescue\n return true\n end",
"def postal_code\n self[:zip]\n end",
"def country_code; end",
"def country_code; end",
"def zipcode\n return poi.zip unless poi.nil?\n return place.zip unless place.nil?\n return get_zipcode\n end",
"def check_zipcode_validity\n\t\tif (zip_code =~ /\\d{5}/) == 0\n\t\t\t#zip_code.length == 5 and \n\t\t\t# !zip_code.include? \"abcdefghijklmnopqrstuvwxyz!@#$%^&*()\"\n\t\t\tputs 'Thanks for a valid zip code!'\n\t\t\tself.call_api\n\t\t\tself.parse_api\n\t\telse\n\t\t\tputs 'Sorry friend, that zipcode is not valid. Please try again!'\n\t\tend\n\tend",
"def valid_address\n @address_string ||= [:street_address, :postal_code].map{|f| self.send(f)}.join(',')\n \n res=Geokit::Geocoders::GoogleGeocoder.geocode(@address_string)\n \n if res.success && res.precision.to_sym == :address\n\n self.street_address = res.street_address.upcase\n self.postal_code \t= res.zip.gsub(/\\s+/,'') \n self.lat = res.lat\n self.lng = res.lng\n \n country = Country.find_by_iso2(res.country_code)\n region = country.regions.find_or_create_by_code(res.state)\n city = region.cities.find_or_create_by_name_and_country_id(res.city, country.id) \n self.city = city\n\n elsif military_address?\n self.city = Country.find_by_iso2(res.country_code).regions.\n find_by_code(res.state).cities.find_by_name(res.city)\n return true \n else\n errors.add_to_base('Sorry the address is not valid')\n end \n end",
"def find_and_save_zip(zip)\r\n # find url\r\n result = self.find_city_and_state(zip)\r\n \r\n # save result if its not nil\r\n unless result.nil?\r\n self.save_to_db(result)\r\n true\r\n else\r\n false\r\n end\r\n end",
"def get_zipcode\n return zip\n end",
"def country_code\n Geocoder.search(hotel.city).first.country_code\n rescue Exception\n 'CZ'\n end",
"def check_zip_code\n zip_string = @zipcode.to_s\n raise InvalidParameterException if zip_string.size != 5\n # raise InvalidParameterException if (@zipcode.to_s =~ pattern)\n check_patterns(zip_string)\n end",
"def zipvalidate(postcode)\n !!postcode.match(/\\A[1-46][\\d]{5}\\z/)\nend",
"def zip_code\n self[:zip]\n end",
"def zip_code(restrictions={state: [], zip_code: []})\n zip_code = nil\n state = restrictions[:state].is_a?(Array) and !restrictions[:state].blank? ? restrictions[:state] : []\n zip_codes = restrictions[:zip_code].is_a?(Array) and !restrictions[:zip_code].blank? ? restrictions[:zip_code] : []\n\n unless @config[:location_db][:adapter].eql?(:none)\n zip_code = find_location(state, zip_codes)[\"#{@config[:location_db][:column_mapping][:zip_code]}\"]\n end\n\n zip_code = Faker::Address.zip_code if zip_code.blank?\n\n zip_code\n end",
"def zip\n self[:address][:postalCode]\n end",
"def postal_code_search(_zip, _city, _country, or_search)\n unless or_search\n Rails.logger.debug \"\\t1) Determine longitude/latitude using exact search (AND)\" \n else\n Rails.logger.debug \"\\t\\t1.1) Determine longitude/latitude using matched search (OR)\"\n end\n \n geo_query = Geonames::PostalCodeSearchCriteria.new\n geo_query.place_name = [zip, city, correct(country)].compact.reject { |s| s.strip.empty? }.join(\" \")\n geo_query.max_rows = or_search ? '10' : '1'\n geo_query.is_or_operator = or_search\n \n results = Geonames::WebService.postal_code_search(geo_query)\n ensure_it_fits(results, _country)\n end",
"def check_values\n check_numericity\n check_zip_code\n end",
"def zipcode_matches_state?\n zipArray = Array.new\n zipArray[0] = /CT|MA|ME|NH|NJ|RI|VT/\n zipArray[1] = /DE|NY|PA/\n zipArray[2] = /DC|MD|NC|SC|VA|WV/\n zipArray[3] = /AL|FL|GA|MS|TN/\n zipArray[4] = /IN|KY|MI|OH/\n zipArray[5] = /IA|MN|MT|ND|SD|WI/\n zipArray[6] = /IL|KY|MO|NE/\n zipArray[7] = /AR|LA|OK|TX/\n zipArray[8] = /AZ|CO|ID|NM|NV|UT|WY/\n zipArray[9] = /AK|CA|HI|OR|WA/\n (zipArray[postalcode.chars.first.to_i] =~ province) != nil\n end",
"def force_address_zipcode_numeric\n before(:each) do\n Spree::Address.class_eval do\n validates_numericality_of :zipcode\n end\n end\n\n after(:each) do\n # http://stackoverflow.com/a/11268726/737303 was useful\n Spree::Address._validators[:zipcode].reject!{|z| z.is_a?(ActiveModel::Validations::NumericalityValidator) }\n cb = Spree::Address._validate_callbacks.find{|z|\n z.raw_filter.is_a?(ActiveModel::Validations::NumericalityValidator) && z.raw_filter.attributes.include?(:zipcode)\n }\n Spree::Address._validate_callbacks.delete(cb)\n end\n end",
"def zipcode_isValid?(zipcode)\n if(zipcode.length != 8 || !zipcode.numeric?)\n false\n else\n true\n end\nend",
"def is_zip_code?(user_zip)\n if user_zip.nil?\n false\n else\n user_zip.size == 5 && user_zip.to_i.to_s == user_zip && !user_zip.nil?\n end\n end",
"def search_zip_code\r\n @addresses = Address.find_by_zip_code(params[:address][:zip_code])\r\n end",
"def enter_zip_and_search(code)\n fill_in 'tZip', :with => code\n click_button 'Find'\n \n # checks if it found a valid zip code.\n # 2 conditions to fail a search.\n # 1. if zip is in a valid format and no city is found.\n # 2. if zip is not in a valid format.\n # pages contains those strings.\n strs = ['Sorry', 'You did not enter a valid ZIP Code']\n if ScrapeUtil.has_content_or?(page, strs)\n false\n else\n # found a valid zip.\n # the first p tag contains the city.\n result = first(:xpath, '//div[@id=\"result-cities\"]/p')\n #result.text\n hash_result = self.city_state_as_hash(code, result.text)\n \n # save to db.\n self.save_to_db(hash_result)\n \n hash_result\n end\n end",
"def set_zipcode\n @zipcode = Zipcode.find(params[:zipcode])\n end",
"def set_Zipcode(value)\n set_input(\"Zipcode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def validate\r\n invalid_strings = [\r\n 'PO BOX', 'P.O. BOX', 'P.O BOX', 'PO. BOX', 'POBOX',\r\n 'P.OBOX', 'P.O.BOX', 'PO.BOX', 'P.BOX', 'PBOX', 'AFO',\r\n 'A.F.O.', 'APO', 'A.P.O.'\r\n ]\r\n cap_address = self.address.upcase()\r\n invalid_strings.each do |string|\r\n if cap_address.include?(string) then\r\n errors.add(:address, \"Sorry, we don't ship to P.O. boxes\")\r\n end\r\n end\r\n if self.country && self.country.name == \"United States of America\"\r\n unless zip.blank?\r\n unless zip =~ /^\\d{5}/\r\n errors.add(:zip, \"Please enter a valid zip.\")\r\n end\r\n end\r\n self.state = self.state.upcase\r\n errors.add(:state, \"Please use a US state abbreviation\") unless US_STATES.include?(self.state)\r\n end\r\n end",
"def validation_of_zip_code(code)\n\n # check type\n for str in code.chars\n if !/\\A\\d+\\z/.match(code)\n return false\n end \n end\n\n # check length\n if code.length == 5\n return true\n else\n return false\n end\nend",
"def is_zipcode?(address_or_zipcode)\n\t\t/\\d{5}(-| )\\d{4}$|^\\d{5}$/.match(address_or_zipcode) != nil\n\tend",
"def cell_phone_with_country_code; end",
"def phone_number_with_country_code; end",
"def require_country?\n true\n end",
"def admin_allowed_zip_code_params\n params.require(:allowed_zip_code).permit(:zip)\n end",
"def set_zip_code\n @zip_code = ZipCode.find(params[:id])\n end",
"def geocode_postal_code\n return unless self.postal_code\n if self.postal_code && (!!self.geo_coded? || !!self.changes.symbolize_keys[:postal_code])\n res = GeoKit::Geocoders::MultiGeocoder.geocode(\"#{self.postal_code}, DE\")\n if res.success\n self.lat = res.lat\n self.lng = res.lng\n self.province_code = Project.province_name_to_code(res.state)\n end\n end\n rescue GeoKit::Geocoders::GeocodeError => ex\n logger.error \"Exception #{ex.message} caught when geocoding #{self.postal_code}, DE\"\n return\n end",
"def country_code\n end",
"def initialize(zip = DEFAULT_ZIP)\n address = (!Geocoder.search(zip).empty? ? Geocoder.search(zip) : Geocoder.search(DEFAULT_ZIP))\n\n\t\t@city = address[0].data[\"standard\"][\"city\"]\n\t\t@state = address[0].data[\"standard\"][\"prov\"]\n\t\t@zip = address[0].data[\"standard\"][\"postal\"]\n\t\t@confidence = address[0].data[\"standard\"][\"confidence\"]\n\t\t@longt = address[0].data[\"longt\"]\n\t\t@latt = address[0].data[\"latt\"]\n\tend",
"def country_code\n end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def set_location(civicrm_model)\n # Split in case suffix is in postal code\n if self.postal_code.present?\n zip = self.postal_code.split('-')[0]\n alf_zip = ALF::Zipcode.where('ZIP', zip).first\n end\n\n # Set country based on\n country = CIVICRM::Country.where(iso_code: self.country).take\n\n # If zip is found use to populate civicrm model\n if alf_zip.present?\n civicrm_model.city = alf_zip.City\n\n # Get the state from CIVICRM\n state = CIVICRM::StateProvince.where(abbreviation: alf_zip.State).take\n # IF state then add\n if state.present?\n civicrm_model.state_province_id = state.id\n # set country in case it is in F1 wrong\n country = CIVICRM::Country.where(id: state.country_id).take\n # Otherwise try to create a state\n else\n # Cannot create without a country\n if country.present?\n state = CIVICRM::StateProvince.new(name: alf_zip.State, abbreviation: alf_zip.State, country_id: country.id)\n # If this state is saved then set it to MODEL\n if state.valid? && state.save\n civicrm_model.state_province_id = state.id\n end\n end\n end\n\n # Get the county from CIVICRM (after state since we need state)\n county = CIVICRM::County.where('lower(name) = ?', alf_zip.County.downcase).take\n # If county then add\n if county.present?\n civicrm_model.county_id = county.id\n # Otherwise try to create the county\n else\n # Cannot create without a state\n if state.present?\n county = CIVICRM::County.new(name: alf_zip.County, state_province_id: state.id)\n if county.valid? && county.save\n civicrm_model.county_id = county.id\n end\n end\n end\n\n # Set country\n if country.present?\n civicrm_model.country_id = country.id\n end\n\n # IF an ALF zipcode model is not found\n else\n # check for state from f1 address model\n state = CIVICRM::StateProvince.where(abbreviation: self.st_province).take\n if state.present?\n civicrm_model.state_province_id = state.id\n end\n\n # check for county from f1 address model\n county = CIVICRM::StateProvince.where(abbreviation: self.county).take\n if county.present?\n civicrm_model.county_id = county.id\n end\n\n # Add country if found\n if country.present?\n civicrm_model.country_id = country.id\n end\n\n end\n\n # Set zip codes\n if self.postal_code.present?\n civicrm_model.postal_code = self.postal_code.split('-')[0]\n civicrm_model.postal_code_suffix = self.postal_code.split('-')[1]\n end\n\n civicrm_model\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def set_ZipCode(value)\n set_input(\"ZipCode\", value)\n end",
"def zip_code\n zip_codes = self.zip_codes.pluck(:zip)\n if self.zip_codes.count == 1 \n return self.zip.zip\n else \n return zip_codes.to_s\n end \n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def set_OriginZip(value)\n set_input(\"OriginZip\", value)\n end",
"def set_OriginZip(value)\n set_input(\"OriginZip\", value)\n end",
"def set_OriginZip(value)\n set_input(\"OriginZip\", value)\n end",
"def needs_country_code?\n country_code.nil?\n end",
"def set_postal_address\n\n\tpostal_address = PostalAddress.find_by_postal_address_type_code_and_city_and_address1_and_address2(self.postal_address_type_code,self.city,self.address1,self.address2)\n\t if postal_address != nil \n\t\t self.postal_address = postal_address\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'postal_address_type_code' and 'city' and 'address1' and 'address2' is invalid- it must be unique\")\n\t\t return false\n\tend\nend",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def validate(address)\n if (address.country.present? && scotland_country_code_valid?(address.country) == false) ||\n (address.postcode.present? && scotland_postcode_format_valid?(address.postcode) == false)\n address.errors.add(:postcode, :postcode_format_invalid)\n end\n end",
"def before_save\r\n=begin\r\n if self.country_region_id.nil? || self.country_region_id.empty?\r\n country = Country.find_by_name( self.country )\r\n self.country_region_id = country.fedex_code unless country.nil?\r\n end\r\n=end\r\n\r\n # Hash the address\r\n self.hash = MD5.md5(\"#{street}#{city}#{state}#{zip_code}#{county}#{country_region_id}\").to_s\r\n end",
"def update_address\n address_zip = ZipCodes.identify(zip_code) || {}\n self.city = address_zip[:city]\n self.state = address_zip[:state_name]\n self.state_code = address_zip[:state_code]\n end",
"def set_location(civicrm_model)\n # Split in case suffix is in postal code\n zip = self.postal_code.split('-')[0]\n alf_zip = ALF::Zipcode.where('ZIP', zip).first\n alf_country = ALF::Country.where('country_id', self.country)\n\n # Country\n if alf_country.present?\n country = CIVICRM::Country.where(iso_code: alf_country.country_code).take\n if country.present?\n civicrm_model.country_id = country.id\n end\n end\n\n if alf_zip.present?\n # City\n civicrm_model.city = alf_zip.City\n\n # State\n state = CIVICRM::StateProvice.where(abbreviation: alf_zip.State).take\n if state.present?\n civicrm_model.state_province_id = state.id\n end\n\n # County\n county = CIVICRM::County.where('lower(name) = ?', alf_zip.County.downcase).take\n if county.present?\n civicrm_model.county_id = county.id\n end\n end\n\n # Set zip codes\n civicrm_model.postal_code = self.postal_code.split('-')[0]\n civicrm_model.postal_code_suffix = self.postal_code.split('-')[1]\n\n civicrm_model\n end",
"def zipcode\n if params[:zipcode].present?\n @weather_output = WeatherQueryService.new(zipcode: params[:zipcode]).call\n @using_cached_forecast = Rails.cache.read(\"#{params[:zipcode]}\").present?\n @forecast_output = ForecastQueryService.new(zipcode: params[:zipcode]).call\n end\n end",
"def country_codes\n raise_invalid_data_source('country_codes')\n end",
"def check_aoa_zip\n @counseling = update_counseling(counseling_params)\n\n @states = CounselAssistance.states\n @ask_aoa = [\n EMP_TYPE[:company],\n EMP_TYPE[:railroad],\n EMP_TYPE[:religious],\n EMP_TYPE[:federal],\n EMP_TYPE[:military],\n EMP_TYPE[:unknown],\n EMP_TYPE[:farm_credit]\n ].include?(@counseling.employer_type_id)\n\n if !@counseling.valid?\n @show_aoa_expansion = false\n elsif @counseling.aoa_coverage.empty? && @ask_aoa &&\n (@counseling.hq_state_abbrev.blank? || @counseling.pension_state_abbrev.blank? || @counseling.work_state_abbrev.blank?)\n @aoa_states = @counseling.aoa_covered_states\n @show_aoa_expansion = true\n\n if @counseling.step == \"2a\"\n @counseling.errors.add(:work_state_abbrev, \"is required\") if @counseling.work_state_abbrev.blank?\n @counseling.errors.add(:hq_state_abbrev, \"is required\") if @counseling.hq_state_abbrev.blank?\n @counseling.errors.add(:pension_state_abbrev, \"is required\") if @counseling.pension_state_abbrev.blank?\n end\n\n @counseling.step = \"2a\"\n else # good zip with AoA coverage, or good zip but no need to ask AoA questions\n if @counseling.aoa_coverage.empty?\n # clear out extra state dropdowns, as we won't consider them in this case\n @counseling.hq_state_abbrev = @counseling.pension_state_abbrev = nil\n\n # but preserve work_state if user is state/county/local employee\n unless [EMP_TYPE[:state], EMP_TYPE[:county], EMP_TYPE[:city]].include?(@counseling.employer_type_id)\n @counseling.work_state_abbrev = nil\n end\n end\n @show_aoa_expansion = false\n update_session\n redirect_to(:action => :step_3) and return\n end\n\n @previous_to = \"/help/step_2\"\n update_session\n render :action => :step_2\n end",
"def zip_service_area\n errors.add(:base, \"Zip not in current PixiPost service area.\") if PixiPostZip.find_by_zip(zip.to_i) == nil\n end",
"def postal_code_required_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.span.id(\"/valZip$/\"), format_method(__method__))\n end",
"def scotland_country_code_valid?(country)\n country == Rails.configuration.x.allowed_property_country_code\n end",
"def country(code, name); end",
"def validate_country\n return unless country.present?\n return if country.valid?\n\n errors.add(:country, \"Is invalid: #{country.errors.full_messages}\")\n end",
"def country\n Faker::Address.country\n end",
"def country\n Faker::Address.country\n end",
"def define_postal_code\n @postal_code = Faker::Address.zip_code(state_abbreviation: @state)\n @postal_code = '' unless @set_blank == false\n end",
"def iban_country_code; end",
"def fix_up_zip_code(zip)\n return nil unless zip.present?\n return nil if (zip =~ /\\A(\\d{5})/).nil?\n $1\n end",
"def validate\n unless address =~ /^(\\d{1,3}\\.){3}\\d{1,3}$/\n raise ValidationError, \"Invalid address\"\n end\n end",
"def vat_number_expected?\n return false unless has_billing?\n billing_address.country != store.country\n end",
"def address_change\n @update_cart_invoice = zip_code_changed?\n true\n end",
"def test_rates_for_locations_with_only_zip_and_country \n setup_user\n response = @carrier.find_rates(\n @locations[:bare_beverly_hills],\n @locations[:bare_ottawa],\n @packages.values_at(:wii)\n )\n \n assert response.rates.size > 0\n end",
"def load_districts_zip(zip_code)\n params = {'zip' => zip_code}\n @districts = process('districts', 'districts/locate', params)\n end",
"def set_zip_code_area_code\n @zip_code_area_code = ZipCodeAreaCode.find(params[:id])\n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def set_Zip(value)\n set_input(\"Zip\", value)\n end",
"def valid?\n country_code && country_code.size == 2 && city_code && city_code.size == 3\n end"
] |
[
"0.72119874",
"0.6951393",
"0.6922878",
"0.68609256",
"0.6722515",
"0.66517246",
"0.66517246",
"0.64409167",
"0.6356393",
"0.6340032",
"0.6340032",
"0.6303804",
"0.626417",
"0.62593275",
"0.6254714",
"0.61897707",
"0.6180971",
"0.61758363",
"0.6165169",
"0.6156843",
"0.6154956",
"0.61462337",
"0.6145491",
"0.61175454",
"0.61094815",
"0.6101048",
"0.6092748",
"0.60855514",
"0.60479426",
"0.603466",
"0.6031042",
"0.6005929",
"0.60045457",
"0.60045457",
"0.60045457",
"0.60045457",
"0.5985354",
"0.59842557",
"0.59816223",
"0.59728736",
"0.59602904",
"0.59592646",
"0.5923763",
"0.59006053",
"0.58992636",
"0.58935493",
"0.5886326",
"0.5876471",
"0.5871426",
"0.5871426",
"0.5871426",
"0.5871426",
"0.5871426",
"0.5871426",
"0.5871329",
"0.5855522",
"0.5855522",
"0.5855522",
"0.5855522",
"0.5855522",
"0.58486134",
"0.583096",
"0.583096",
"0.58045703",
"0.58045703",
"0.58045703",
"0.5796295",
"0.57946056",
"0.57919323",
"0.57919323",
"0.57853115",
"0.57851064",
"0.5782534",
"0.57773995",
"0.57731736",
"0.5772487",
"0.5766108",
"0.57599384",
"0.57517624",
"0.57479215",
"0.57438034",
"0.5734124",
"0.5728675",
"0.5728675",
"0.571541",
"0.57152504",
"0.5709056",
"0.57086",
"0.57079375",
"0.5706012",
"0.56918424",
"0.56918365",
"0.5689832",
"0.56857616",
"0.56857616",
"0.56857616",
"0.56857616",
"0.56857616",
"0.56857616",
"0.5682765"
] |
0.74451184
|
0
|
PUT /cursuses/1 PUT /cursuses/1.xml
|
def update
respond_to do |format|
if @user.update_attributes(params[:user])
flash[:notice] = 'User was successfully updated.'
format.html { redirect_to(users_path) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update\n @curso = Curso.find(params[:id])\n\n respond_to do |format|\n if @curso.update_attributes(params[:curso])\n flash[:notice] = 'CURSO ATUALIZADO COM SUCESSO'\n format.html { redirect_to(@curso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @curso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @curta = Curta.find(params[:id])\n\n respond_to do |format|\n if @curta.update_attributes(params[:curta])\n flash[:notice] = 'Curta was successfully updated.'\n format.html { redirect_to(@curta) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @curta.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @curso = Curso.find(params[:id])\n\n respond_to do |format|\n if @curso.update_attributes(params[:curso])\n format.html { redirect_to(:back) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update\n @tipo_curso = TipoCurso.find(params[:id])\n\n respond_to do |format|\n if @tipo_curso.update_attributes(params[:tipo_curso])\n flash[:notice] = 'TipoCurso actualizado correctamente.'\n format.html { redirect_to(@tipo_curso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_curso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_occasion\n @occasion = Occasion.find(params[:id])\n end",
"def set_occasion\n @occasion = Occasion.find(params[:id])\n end",
"def set_occasion\n @occasion = Occasion.find(params[:id])\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def puts_to(path,params,opts={},&block) #:nodoc: \n crud_to(:put,path,params,opts,&block)\n end",
"def update\n @alumnos_x_curso = AlumnosXCurso.find(params[:id])\n\n respond_to do |format|\n if @alumnos_x_curso.update_attributes(params[:alumnos_x_curso])\n format.html { redirect_to @alumnos_x_curso, notice: 'Alumnos x curso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @alumnos_x_curso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def orchio_put(jdoc)\n response = client.send_request :put, inst_args(json: jdoc)\n if cache.enabled?\n simple_cache.save(\n Document.new(\n response.body.to_hash,\n Metadata.new(\n :collection => ocollection,\n :key => @id,\n :ref => response.header.etag\n )))\n end\n set_ref_value response\n orchio_status response, 201\n end",
"def put(uri, params = {})\n send_request(uri, :put, params)\n end",
"def update\n respond_to do |format|\n if @curso.update(curso_params)\n format.html { redirect_to @curso, notice: 'Curso was successfully updated.' }\n format.json { render :show, status: :ok, location: @curso }\n else\n format.html { render :edit }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_curation(engine_name, id, options)\n put(\"engines/#{engine_name}/curations/#{id}\", options)\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def update\n @curso = Curso.find(params[:curso_id])\n @seccion = Seccion.find(params[:id])\n respond_to do |format|\n if @seccion.update(seccion_params)\n format.html { redirect_to '/users/'+current_user.id.to_s+'/cursos/'+@curso.id.to_s+'/seccions/', notice: 'La sección ha sido actualizada satisfactoriamente' }\n \n else\n format.html { render :edit }\n \n end\n end\n end",
"def update\n @csosn = Csosn.find(params[:id])\n\n respond_to do |format|\n if @csosn.update_attributes(params[:csosn])\n format.html { redirect_to @csosn, notice: 'Csosn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @csosn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end",
"def test_put\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 contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend",
"def destroy\n @curso = Curso.find(params[:id])\n @curso.destroy\n\n respond_to do |format|\n format.html { redirect_to(cursos_url) }\n format.xml { head :ok }\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 post_to_solr(params,commit=true)\n url=\"#{Blacklight.default_index.connection.options[:url]}/update?commit=#{commit}\"\n RestClient.post url, params,:content_type => :json, :accept=>:json\n end",
"def update\n respond_to do |format|\n if @curso.update(curso_params)\n format.html { redirect_to cursos_path, notice: 'Curso atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @curso }\n else\n format.html { render :edit }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ontology = SYMPH::Ontology.find(params[:id])\n\n respond_to do |format|\n if @ontology.update_attributes(params[:ontology])\n flash[:notice] = 'Ontology was successfully updated.'\n format.html { redirect_to(ontologies_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ontology.errors, :status => :unprocessable_entity }\n end\n end\n\t\n end",
"def update\n @spouse = Spouse.find(params[:id])\n\n respond_to do |format|\n if @spouse.update_attributes(params[:spouse])\n flash[:notice] = 'Spouse was successfully updated.'\n format.html { redirect_to(@spouse) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spouse.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @curso.update(curso_params)\n format.json { render json: \"Curso Actualizado\", status: :ok, location: @curso }\n else\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\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",
"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",
"def put(*args)\n request :put, *args\n end",
"def put!\n request! :put\n end",
"def index_document( url_string = 'http://localhost:8983/solr/update' )\n index_doc = create_base_add_doc\n root = index_doc.root\n begin\n doc = to_solr_index_doc\n root << doc\n #set up basic connection\n @url = URI.parse( url_string )\n @http = Net::HTTP.new( @url.host, @url.port )\n \n response, body = @http.post( @url.path, index_doc.to_s, { 'Content-type'=>'text/xml; charset=utf-8' } )\n \n response, body = @http.post( @url.path, \"<commit/>\", { 'Content-type'=>'text/xml; charset=utf-8' } )\n\n rescue Exception => ex\n #puts \"Something went wrong with item: #{item.id}: #{item.title}\"\n puts ex.inspect\n puts ex.backtrace\n end\n end",
"def couchdb_put(urn, host = '127.0.0.1', options = @@default_options)\n query_couchdb(urn, 'PUT', host, options)\n end",
"def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def put(path, params)\n request(:put, path, params)\n end",
"def update\n replace_entry \"word/document.xml\", doc.serialize(:save_with => 0)\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end",
"def update\n respond_to do |format|\n if @curso.update(curso_params)\n format.html { redirect_to @curso, notice: 'Curso foi atualizado(a) com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @curso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_couch\n @couch = Couche.find(params[:id])\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 updateSeriesAcl(xml, roles)\n\n doc = Nokogiri::XML(xml)\n newNodeSet = Nokogiri::XML::NodeSet.new(doc)\n\n roles.each do |role|\n newNode = nokogiri_node_creator(doc, \"ace\", \"\")\n newNode << nokogiri_node_creator(doc, \"action\", role[:permission])\n newNode << nokogiri_node_creator(doc, \"allow\", 'true')\n newNode << nokogiri_node_creator(doc, \"role\", role[:user])\n\n # Avoid adding duplicate nodes\n nodeAlreadyExists = false\n doc.xpath(\"//x:ace\", \"x\" => \"http://org.opencastproject.security\").each do |oldNode|\n if sameNodes?(oldNode, newNode)\n nodeAlreadyExists = true\n break\n end\n end\n\n if (!nodeAlreadyExists)\n newNodeSet << newNode\n end\n end\n\n doc.root << newNodeSet\n\n return doc.to_xml\nend",
"def put(path, parameters = {})\n request(:put, path, parameters)\n end",
"def update\n @spot = Spot.find(params[:id])\n\n respond_to do |format|\n if @spot.update_attributes(params[:spot])\n format.html { redirect_to @spot, notice: t(:course_successfully_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:recursos][:status] == '1'\n @count = count_of_resource\n save_multiples_recursos\n end\n respond_to do |format|\n if @area.update(area_params)\n format.html { redirect_to @area, notice: 'El Área fue modificada éxitosamente.' }\n format.json { render :show, status: :ok, location: @area }\n else\n format.html { render :edit }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @omatsuri = Omatsuri.find(params[:id])\n\n respond_to do |format|\n if @omatsuri.update_attributes(params[:omatsuri])\n flash[:notice] = 'Omatsuri was successfully updated.'\n format.html { redirect_to(@omatsuri) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @omatsuri.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def update\n respond_to do |format|\n @sucursale.usuarios_id = current_usuario.id\n if @sucursale.update(sucursale_params)\n format.html { redirect_to @sucursale, notice: 'Sucursal actualizada con exito!' }\n format.json { render :show, status: :ok, location: @sucursale }\n else\n format.html { render :edit }\n format.json { render json: @sucursale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_stoc\n @stoc = Stoc.find(params[:id])\n end",
"def put( doc, opts = {} )\n response = http_action :put, doc, opts.merge( :doc => doc )\n doc['_id'], doc['_rev'] = response['id'], response['rev'] if doc.kind_of? Hash\n response\n end",
"def modify_securities(visited, account_id = nil)\n data = { visited: visited }\n if account_id\n query_api '/rest/accounts/' + account_id + '/securities', data, 'PUT'\n else\n query_api '/rest/securities', data, 'PUT'\n end\n end",
"def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename if document\n xml.summary document_type\n if document\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n end\n }\n end\n\n url = Document::PATH + \"cmis/i/#{document_id}?alf_ticket=\" + ticket\n\n begin\n RestClient.put url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error updating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def update\n Neo4j::Transaction.run do\n @q_resource = QResource.find(params[:id])\n @q_resource.update_attributes!(params[:q_resource])\n respond_to do |format|\n if @q_resource.update_attributes(params[:q_resource])\n format.html { redirect_to @q_resource, :notice => 'Q resource was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @q_resource.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def put(uri, parameters)\n response = Unirest.put uri, parameters: parameters\n response.body\n end",
"def update\n save_doc\n end",
"def update\n @seccion = Seccion.find(params[:id])\n\n respond_to do |format|\n if @seccion.update_attributes(params[:seccion])\n format.html { redirect_to(@seccion, :notice => 'Seccion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @seccion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_putpoi_update_valid\n nd = create(:node)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 1, result[4]\n\n # Now try to update again, with a different lat/lon, using the updated version number\n lat = nd.lat + 0.1\n lon = nd.lon - 0.1\n amf_content \"putpoi\", \"/2\", [\"#{user.email}:test\", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/2\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 2, result[4]\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n req.url \"categories\"\n req.body = options.to_json\n end\n\n resp.status \n end",
"def update\n @county = County.find(params[:id])\n\n respond_to do |format|\n if @county.update_attributes(params[:county])\n flash[:notice] = 'County was successfully updated.'\n format.html { redirect_to(@county) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @county.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @use = Use.find(params[:id])\n\n respond_to do |format|\n if @use.update_attributes(params[:use])\n format.html { redirect_to(@use, :notice => 'Use was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @use.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couche was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, opts = {})\n request(:put, path, opts).body\n end",
"def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end",
"def put(*args)\n request(:put, *args)\n end",
"def update\n @ccl = Ccl.find(params[:id])\n\n respond_to do |format|\n if @ccl.update_attributes(params[:ccl])\n format.html { redirect_to(@ccl, :notice => 'Ccl was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ccl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update \t\n\t @cinema = Cinema.find(params[:id])\n\t\t@cities = City.find(:all)\n\t\t\n\t respond_to do |format|\n\t if @cinema.update_attributes(params[:cinema])\n\t \n\t update_cinemas_xml()\n\t \n\t format.html { redirect_to(@cinema, :notice => 'Kino zostało pomyślnie zaktualizowane.') }\n\t format.xml { head :ok }\n\t else\n\t format.html { render :action => \"edit\" }\n\t format.xml { render :xml => @cinema.errors, :status => :unprocessable_entity }\n\t end\n\t end \n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def update\n if params[:commit] == 'Accept'\n params[:scoot][:state] = 'accepted'\n else\n params[:scoot][:state] = 'rejected'\n end\n respond_to do |format|\n if @scoot.update(scoot_params)\n format.html { redirect_to root_url, notice: 'Scoot was successfully updated.' }\n format.json { render :show, status: :ok, location: @scoot }\n else\n format.html { render :edit }\n format.json { render json: @scoot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @conseq = Conseq.find(params[:id])\n\n respond_to do |format|\n if @conseq.update_attributes(params[:conseq])\n format.html { redirect_to(@conseq, :notice => 'Conseq was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @conseq.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n update_resource @ride, ride_params\n end",
"def update\n @concept = Concept.find(params[:id])\n \n respond_to do |format|\n if @concept.update_attributes(params[:concept])\n flash[:notice] = 'Concept was successfully updated.'\n format.html { redirect_to(@concept) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @concept.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(name,&block)\n build_resource(name, :put, &block)\n end",
"def add_to_collection_solr_document_path (arg)\n \"/catalog/\" << arg.id << \"/add_to_collection\"\n end",
"def update\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couch was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @curso.update(curso_params)\n redirect_to @curso, notice: 'Curso se ha actualizado.'\n else\n render action: 'edit'\n end\n end",
"def set_cuota_curso\n @cuota_curso = CuotaCurso.find(params[:id])\n end",
"def update\n params[:resource][:term_ids] || []\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n if @tso.update_attributes(params[:tso])\n flash[:notice] = 'Tso was successfully updated.'\n format.html { redirect_to(@tso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, collection)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = @media_type\n\n response = case @media_type\n when 'application/occi+json'\n self.class.post(@endpoint + path,\n :body => collection.to_json,\n :headers => headers)\n when 'text/occi'\n self.class.post(@endpoint + path,\n :headers => collection.to_header.merge(headers))\n else\n self.class.post(@endpoint + path,\n :body => collection.to_text,\n :headers => headers)\n end\n\n response_msg = response_message response\n\n case response.code\n when 200, 201\n Occi::Parser.parse(response.header[\"content-type\"].split(\";\").first, response)\n else\n raise \"HTTP POST failed! #{response_msg}\"\n end\n end",
"def update\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n if @nossos_servico.update_attributes(params[:nossos_servico])\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @occasion.update(occasion_params)\n format.html { redirect_to [:admin, @occasion], notice: 'Occasion was successfully updated.' }\n format.json { render :show, status: :ok, location: @occasion }\n else\n format.html { render :edit }\n format.json { render json: @occasion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def command\n document = BSON::Document.new\n document.store('killCursors', collection)\n store_ids = cursor_ids.map do |cursor_id|\n BSON::Int64.new(cursor_id)\n end\n document.store('cursors', store_ids)\n document\n end",
"def update\n @setor = Setor.find(params[:id])\n\n respond_to do |format|\n if @setor.update_attributes(params[:setor])\n format.html { redirect_to(setors_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @setor.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.56058353",
"0.53983086",
"0.5222361",
"0.515674",
"0.5100553",
"0.5046217",
"0.5015402",
"0.5015402",
"0.5015402",
"0.5015208",
"0.49572614",
"0.49538562",
"0.49081543",
"0.49070477",
"0.49025142",
"0.48895276",
"0.48760718",
"0.48535058",
"0.4822368",
"0.48049316",
"0.47733042",
"0.47652015",
"0.47582313",
"0.47561967",
"0.47149664",
"0.47149664",
"0.47149664",
"0.46940887",
"0.4692136",
"0.4689508",
"0.46887627",
"0.46875957",
"0.4681268",
"0.46760437",
"0.46760437",
"0.46760437",
"0.46760437",
"0.46760437",
"0.46760437",
"0.46760437",
"0.46760437",
"0.4671442",
"0.4668665",
"0.46664214",
"0.4659952",
"0.46594912",
"0.46577996",
"0.4656616",
"0.46355963",
"0.46345082",
"0.46278566",
"0.46219265",
"0.46219265",
"0.4604976",
"0.45874512",
"0.4586426",
"0.45863366",
"0.45823872",
"0.45821145",
"0.45793113",
"0.45792452",
"0.45743242",
"0.45668358",
"0.45662224",
"0.4566077",
"0.45657063",
"0.45645198",
"0.45552528",
"0.45531568",
"0.45525724",
"0.45508832",
"0.45508066",
"0.45475405",
"0.45468155",
"0.45458892",
"0.45388657",
"0.4538706",
"0.45288756",
"0.4522874",
"0.4514373",
"0.45122522",
"0.45108336",
"0.4510029",
"0.4504928",
"0.4500231",
"0.44933087",
"0.4488356",
"0.4486806",
"0.44860184",
"0.44823027",
"0.44771984",
"0.44770423",
"0.4473405",
"0.4471758",
"0.44702122",
"0.44665152",
"0.44652617",
"0.44637012",
"0.44630376",
"0.44618964",
"0.44584703"
] |
0.0
|
-1
|
GET /projects/1 GET /projects/1.json
|
def show
@project = Project.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @project }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list\n get 'projects'\n end",
"def listprojects\n get('listprojects.json')['projects']\n end",
"def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def projects\n resource 'projects'\n end",
"def index\n @projects = Project.all\n render json: @projects, status: :ok\n end",
"def index\n @projects = Project.all\n render json: @projects\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @user = User.find_by(id: params[:user_id])\n @project = @user.projects\n if @project \n render :json => @project\n else\n render :json => 422\n end\n end",
"def projects\n request(method: 'getAllProjects')\n end",
"def project(project_id, params = {})\n make_get_request(\"/projects/#{project_id}\", params)\n end",
"def index\n @projects = Project.visible\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = Project.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @projects }\n end\n end",
"def show\n render json: Project.where(id: params.fetch(:id))\n end",
"def show \n project= Project.find(params[:id])\n\n render json: project\n end",
"def index\n @projects = Project.all_for_user(current_user.id)\n render json: @projects.to_json(include: :project_detail), status: 200\n end",
"def project(project_id, options={})\n response_body = nil\n begin\n response = connection.get do |req|\n req.url \"/api/v1/projects/#{project_id}\", options\n end\n response_body = response.body\n rescue MultiJson::DecodeError => e\n #p 'Unable to parse JSON.'\n end\n \n response_body\n end",
"def index\n @projects = current_user.projects\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def project(project_id, query_params = nil)\n get(\"/projects/#{project_id}\", query_params)\n end",
"def project(project_id)\n resource \"projects/#{project_id}\"\n end",
"def index\n @projects = Project.all\n render json: @projects, layout: false\n end",
"def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inertia-preview+json', :'Authorization' => 'token ' + CONFIG['OAUTH']\n result = JSON.parse(result) \n end",
"def show\n @project = Project.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def get\n CircleCi.request(conf, '/projects').get\n end",
"def index\n # @projects = @current_user.projects\n @projects = Project.all\n json_response(@projects)\n end",
"def projects\n records \"project\", \"/project/list\"\n end",
"def projects\n Sifter.\n get(\"/api/projects\").\n parsed_response[\"projects\"].\n map { |p| Sifter::Project.new(p) }\n end",
"def index \n\n @projects = Project.all\n respond_to do |format|\n format.html {render :template => \"projects/index\"}\n format.json { render json: @projects }\n end\n end",
"def index\n @projects = current_user.projects.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def index\n \n @workspaces = current_user.workspaces\n # debugger\n @projects = Project.where(:workspace_id => @workspace)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def show\n @project = Project.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @project }\n end\n end",
"def show\n render json: @project\n end",
"def show\n repo = ProjectRepo.new current_user\n @v_project = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_project }\n end\n end",
"def find_project(name)\n get(\"/projects/#{name}\")\n end",
"def find_project(name)\n get(\"/projects/#{name}\")\n end",
"def show\n @project = Project.find_by(id: params[:id])\n if @project\n render :json => @project\n else\n render :json => 422\n end\n end",
"def projects(params = {})\n make_get_request('/account/projects', params)\n end",
"def project\n request :project\n end",
"def project\n return forbidden unless current_account and params[:id] and (request.format.json? || request.format.js? || request.format.text?)\n project = Project.accessible(current_account).find(params[:id].to_i)\n return not_found unless project\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'project' => project.canonical(opts)}\n render_cross_origin_json\n end",
"def show \n render :json => Project.find_by_id(params[:id])\n end",
"def show\n @ourproject = Ourproject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ourproject }\n end\n end",
"def get_project(project_id)\n http = Net::HTTP.new(@city_db_url, @port)\n http.read_timeout = 1000\n if @city_db_is_https\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n request = Net::HTTP::Get.new(\"/projects/#{project_id}.json\")\n request.add_field('Content-Type', 'application/json')\n request.add_field('Accept', 'application/json')\n request.basic_auth(ENV['URBANOPT_USERNAME'], ENV['URBANOPT_PASSWORD'])\n\n response = http.request(request)\n if response.code != '200' # success\n @runner.registerError(\"Bad response #{response.code}\")\n @runner.registerError(response.body)\n @result = false\n return {}\n end\n\n result = JSON.parse(response.body, symbolize_names: true)\n return result\n end",
"def index\n @projects = Project.with_permissions_to(:read)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end",
"def show\n @projectresource = Projectresource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projectresource }\n end\n end",
"def index\n @projects = Project.where user: current_user\n render json: @projects, each_serializer: Projects::IndexSerializer\n end",
"def show \n respond_to do |format|\n format.json {\n\n @project = Project.find_by_id(params[:id])\n\n if @project\n render :json => @project\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def show\n @current_project = CurrentProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @current_project }\n end\n end",
"def show\n respond_with(@project) do |format|\n format.json { render json: @project.as_json }\n format.html\n end\n end",
"def show\n @show_project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @show_project }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def show\n respond_with @project do |format|\n format.json do\n render json: @project.as_json.merge(\n commits_url: project_commits_url(@project, format: 'json'),\n commits: @project.commits.order('committed_at DESC').limit(10).map { |commit|\n commit.as_json.merge(\n percent_done: commit.fraction_done.nan? ? 0.0 : commit.fraction_done*100,\n translations_done: commit.translations_done,\n translations_total: commit.translations_total,\n strings_total: commit.strings_total,\n import_url: import_project_commit_url(@project, commit, format: 'json'),\n sync_url: sync_project_commit_url(@project, commit, format: 'json'),\n url: project_commit_url(@project, commit),\n status_url: project_commit_url(@project, commit),\n )\n }\n )\n end\n end\n end",
"def show\n # turn ruby database into json\n # route to the project 3 page with this json\n # id = 1\n end",
"def show\n\n render json: Project.all\n\n end",
"def projects(params = {})\n fetch_all('projects', 'projects', params)\n end",
"def index\n @about_projects = AboutProject.last(1)\n\n respond_to do |format|\n format.json {render json: @about_projects[0], :only => [:description]}\n end\n end",
"def show\n set_surrogate_key_header \"api/platforms/#{@platform.id}/projects\"\n set_cache_control_headers 3600\n end",
"def show\n @projects = find_projects\n end",
"def get_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'GetProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def show_by_gitpath\n @project = Project.includes(:users).includes(:technos).find_by_gitpath(params[:gitpath])\n\n respond_to do |format|\n format.json { render json: @project, status: 200 }\n end\n end",
"def project\n @client.project(:id => project_id)\n end",
"def list_projects\n handle_action_exceptions(__method__) do\n cmd_line = ['listprojects']\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end",
"def index\n #@projects = []\n if current_user\n #@projects = current_user.projects.where(\"memberships.status >= ?\", 1)\n end\n\n if params[:id]\n @project = Project.find(params[:id])\n authorize! :read, @project\n else\n @project = @projects.first\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js { render :action => 'show'}\n format.json { render json: @projects }\n end\n end",
"def projects\n return forbidden unless current_account # already returns a 401 if credentials aren't supplied\n opts = { :include_document_ids => params[:include_document_ids] != 'false' }\n @response = {'projects' => Project.accessible(current_account).map {|p| p.canonical(opts) } }\n render_cross_origin_json\n end",
"def get_projects_of_user\n respond_to do |format|\n format.json {\n #param = params[:payload]\n #@user = User.find_by_id(param[:id])\n @projects = Project.where(:user_id => @current_user.id)\n if @projects\n render :json => @projects\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end",
"def get\n render json: Project.select(:id, \"name as label\")\n end",
"def index\n @projects = Project.includes(:user).all\n respond_with(@projects) do |format|\n format.json { render :json => {:list => @projects.as_json, :current_user => current_user.as_json} }\n format.html\n end\n end",
"def details\n get(\"project/details\")[\"project\"]\n end",
"def show\n @unfinished_project = UnfinishedProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unfinished_project }\n end\n end",
"def show\n @workspaces = current_user.workspaces\n @project = Project.find(params[:id])\n @workspace = Workspace.find(params[:workspace_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def index\n @user = User.find_by_id(session[:userid])\n @projects = current_user_projects\n respond_to do |format|\n format.html # index.html.erb\n format.json\n end\n end",
"def get(project_name)\n response = get_request(\"/projects/#{project_name}/\")\n TheShiningSource::Project.new(response)\n end",
"def show_project\r\n @project = Project.find(params[:id])\r\n @id = @project.id\r\n respond_to do |format|\r\n format.html { render 'project_control/view' }\r\n format.json { render json: @project }\r\n end\r\n end",
"def getProject(project)\r\n\t\t\t\tproject_json = JSON.parse project\r\n\t\t\t\tproject_array = project_json[\"projects\"]\r\n\t\t\t\treturn jsonToProject(project_array[0])\r\n\t\t\tend",
"def show\n @project = Project.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projects }\n #format.json { render json: @project.as_json(:include => [:client, :project_participants] ) }\n end\n end",
"def index\n if signed_in?\n @projects = current_user.projects\n respond_to do |format|\n format.html { render 'projects/index' }\n format.json { render template: 'projects/index.json.jbuilder' }\n end\n else\n redirect_to :projects\n end\n end",
"def index\n @projects = @projects.includes(:latest_iteration).where(:tenant_id => current_user.tenant).order(\"name\").page(params[:page]).per(DEFAULT_ROWS_PER_PAGE)\n\n respond_with @projects\n end",
"def show\n respond_to do |format|\n format.html {render :show}\n format.json {render json: @project}\n end\n end",
"def show\n @project = Project.find(params[:id])\n\t@user = User.find(@project.user_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def find(project_id)\n raw_response = get_request(\"projects/#{project_id}\")\n parse_response(raw_response, :project)\n end"
] |
[
"0.7868971",
"0.76979554",
"0.7680216",
"0.7611453",
"0.75334454",
"0.75258976",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74924207",
"0.7484109",
"0.7479275",
"0.7444873",
"0.74294627",
"0.74224764",
"0.7414947",
"0.7385035",
"0.7380203",
"0.7379937",
"0.7375317",
"0.73572785",
"0.7352506",
"0.73521084",
"0.73436445",
"0.73410857",
"0.73250616",
"0.7303016",
"0.72884965",
"0.72734356",
"0.72727096",
"0.72536707",
"0.7251402",
"0.72502863",
"0.72433484",
"0.7241812",
"0.7228012",
"0.7228012",
"0.7213682",
"0.7210143",
"0.72031206",
"0.71956533",
"0.7184686",
"0.71557546",
"0.71509594",
"0.71480834",
"0.7120158",
"0.71123755",
"0.7106823",
"0.70865124",
"0.7084294",
"0.7079523",
"0.705198",
"0.70506",
"0.7044681",
"0.70423746",
"0.70259416",
"0.70248544",
"0.70047486",
"0.70040953",
"0.70025414",
"0.7000689",
"0.6987457",
"0.6984701",
"0.69802356",
"0.6979858",
"0.69780463",
"0.69780076",
"0.6970507",
"0.6966368",
"0.69646454",
"0.69622666",
"0.6961776",
"0.6961545",
"0.69614834",
"0.69565344",
"0.6943089",
"0.6936655",
"0.69335127",
"0.69173217",
"0.69125015",
"0.6909762",
"0.69050795"
] |
0.7361155
|
37
|
GET /projects/new GET /projects/new.json
|
def new
@project = Project.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @project }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @project = current_user.projects.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.json { render json: @project }\n format.html # new.html.erb\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html\n format.json { render json: @project }\n end\n end",
"def new_link\n @project = Project.new(user_id: current_user.id)\n fetch_projects\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @project = Project.new\n @services = Service.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @projectresource = Projectresource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projectresource }\n end\n end",
"def new\n @project = Project.new(user_id: current_user.id)\n find_people_list\n fetch_clients\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n authorize! :create, Project\n \n @project = Project.new\n puts @project\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @current_project = CurrentProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @current_project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html { render layout: 'project'}\n format.json { render json: @project }\n end\n end",
"def new\n @ourproject = Ourproject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ourproject }\n end\n end",
"def new\n @project = Project.new :company_id => params[:company_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new_project\n if current_admin.present? || current_client.present?\n @project = Project.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n else\n redirect_to new_admin_session_path and return\n end\n end",
"def new\n @isgrey = true;\n @current_page = \"ADD PROJECT\"\n @project = Project.new\n @project_attachment = @project.project_attachments.build\n @slider_object = @project.slider_objects.build\n @project_field = @project.project_fields.build\n @project_other_field = @project.project_other_fields.build\n\n @types = Type.all\n @new_nav = true;\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @new_project = Project.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @new_project }\n end\n end",
"def new\n @project = Project.new\n \n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n \t@pagenav = Page.find_all_by_published('true')\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new_project\n @request = Request.new(data_type: :project)\n @request.build_contact\n @request.build_project\n @request.build_general_information\n\n render 'new'\n end",
"def new\n if signed_in?\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n else \n redirect_to \"/\"\n end\n end",
"def new\n @project = @client.projects.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @project }\n end\n end",
"def new\n authenticate_user!\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def create\n @urlroot = Designax::Application.config.urlroot\n if params[:pk] == \"new\" and params[:name] == \"project_name\"\n project_name = params[:value]\n @project = Project.new()\n @project.project_name = project_name\n else\n @project = Project.new(params[:project])\n end\n\n respond_to do |format|\n if @project.save\n redirect_url = @urlroot + \"/projects\"\n response_url = { \"url\" => redirect_url }\n format.json { render json: response_url, status: 200 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @file_project = FileProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_project }\n end\n end",
"def new\n @project_template = ProjectTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_template }\n end\n end",
"def new\n @projects_person = ProjectsPerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projects_person }\n end\n end",
"def new\n @project = Project.find(params[:project_id])\n @project_entry = ProjectEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_entry }\n end\n end",
"def new\n propose_nr = Integer(Project.order(\"nr desc\").first.nr) + 1\n @project = Project.new(:nr => propose_nr, :active => true)\n @project.tasks.new(:name => \"Project Mgmt\", :description => \"\")\n @project.tasks.new(:name => \"Pre-P\", :description => \"Moodboards | Examining project data, plans, briefing, etc.\")\n @project.tasks.new(:name => \"Web\", :description => \"Flatfinder/Boligvelger (eve-Estate) | CMS/Website (eve-Publisher) | Landingpage\")\n @project.tasks.new(:name => \"Undividable 3D work for exteriors\", :description => \"Modeling/texturing of buildings and their surroundings. Populating/detailing with plants, outdoor furniture, traffic, etc.\")\n @project.tasks.new(:name => \"Undividable 3D work for interiors\", :description => \"Modeling/texturing of X apartments. Setting up furniture, accessories, decoration according to moodboards.\")\n @project.tasks.new(:name => \"#{propose_nr}-01_e\", :description => \"Scene setup, lighting and detail adjustments, rendering with subsequent post-production/compositing.\")\n @project.tasks.order(:name)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.json { render json: @project }\n end\n end",
"def new\n @project =\n if params[:project]\n Project.where(name: params[:project][:name]).first || Project.new(project_params)\n else\n Project.new\n end\n\n respond_to do |format|\n format.html {\n redirect_to edit_embed_project_url(@project) if @project.persisted?\n }\n format.json { render json: @project }\n end\n end",
"def new\n session[:return_to] ||= request.referer\n @project = Project.new\n @project.user_id = current_user.id\n\n # we use list of projects and contexts on the view, need to prepare them\n @projects = Project.all_active_projects(params[:context_id],current_user.id )\n @contexts = Context.where(\"user_id = ?\",current_user.id)\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def project_new\n new_project.click\n end",
"def new\n @unfinished_project = UnfinishedProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unfinished_project }\n end\n end",
"def new\n @project = Project.create\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n # Agrega el breadcrumb de la pagina new de proyecto\n add_breadcrumb I18n.t('project.new'), :controller => \"projects\", :action => \"new\"\n @project = Project.new\n end",
"def new\n @campaign = Campaign.find(params[:campaign_id])\n @project = @campaign.projects.new(params[:project])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @project_detail = ProjectDetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_detail }\n end\n end",
"def new\n @past_project = PastProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @past_project }\n end\n end",
"def new\n\t\t@project = Project.new({:project_state_type_id => ProjectStateType.find_by_code('preparation').id})\n\t\tputs @project.inspect\n\t\tmake_breadcrumbs\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @project }\n\t\tend\n\tend",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n\n @project = Project.new\n @main_projects = Project.roots.where(creator_id: current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @project = Project.new\n end",
"def new\n @projecct = Projecct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projecct }\n end\n end",
"def new\n @project = Project.new\n #@project.build_ci\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @assigned_project = AssignedProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assigned_project }\n end\n end",
"def ajaxnew\n @project = Project.new\n\n respond_to do |format|\n format.html { render :layout => false } # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @project = Project.new(:user_id => current_user[:id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def new\n @task = Task.new(:project_id => params[:id])\n\t\t@projects = Project.sorted\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @project }\n end\n end",
"def new\n @user = User.find( params[:user_id] )\n @project = Project.new( :title => \"New Project\" )\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def create\n @project = Project.new(params[:project] || JSON.parse(request.body.read))\n\n if (params[:id])\n @project.id = params[:id]\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n format.json { render :json => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n format.json { render :text => \"error creating project via http/json\" }\n end\n end\n end"
] |
[
"0.81725097",
"0.81171846",
"0.80850273",
"0.80848",
"0.8061288",
"0.8030936",
"0.79504395",
"0.792672",
"0.79045373",
"0.7865987",
"0.7758509",
"0.7751187",
"0.77291125",
"0.7706384",
"0.7698888",
"0.7685731",
"0.7672869",
"0.7655707",
"0.76342",
"0.7632482",
"0.7619905",
"0.7612697",
"0.76019526",
"0.7579514",
"0.75643575",
"0.75576305",
"0.75530607",
"0.7552181",
"0.7532463",
"0.75238603",
"0.7521173",
"0.74954855",
"0.7472716",
"0.74714875",
"0.7468618",
"0.7468332",
"0.74637985",
"0.74482524",
"0.7444269",
"0.7438458",
"0.74200654",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.73890764",
"0.7388426",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.73828655",
"0.7367906",
"0.7361138",
"0.73421776",
"0.73386914",
"0.7318866",
"0.7279783",
"0.72779024",
"0.72771907",
"0.72716326"
] |
0.8165836
|
22
|
POST /projects POST /projects.json
|
def create
@project = Project.new(params[:project])
@project.user_id =current_user.id
respond_to do |format|
if @project.save
format.html { redirect_to @project, notice: 'Project was successfully created.' }
format.json { render json: @project, status: :created, location: @project }
else
format.html { render action: "new" }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_project(name)\n post('projects', {:name => name})[\"project\"]\n end",
"def create\n @project = Project.new(project_params)\n\n if @project.save\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end",
"def create\n @project = Project.new(project_params)\n\n if @project.save\n render json: @project, status: :created\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end",
"def create\n @urlroot = Designax::Application.config.urlroot\n if params[:pk] == \"new\" and params[:name] == \"project_name\"\n project_name = params[:value]\n @project = Project.new()\n @project.project_name = project_name\n else\n @project = Project.new(params[:project])\n end\n\n respond_to do |format|\n if @project.save\n redirect_url = @urlroot + \"/projects\"\n response_url = { \"url\" => redirect_url }\n format.json { render json: response_url, status: 200 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project] || JSON.parse(request.body.read))\n\n if (params[:id])\n @project.id = params[:id]\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n format.json { render :json => @project }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n format.json { render :text => \"error creating project via http/json\" }\n end\n end\n end",
"def test_should_create_project_via_API_JSON\r\n get \"/logout\"\r\n post \"/projects.json\", :api_key => 'testapikey',\r\n :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response :created\r\n project = JSON.parse(response.body)\r\n check_new_project(project) \r\n end",
"def create\n\t\t@project = current_user.projects.new(project_params)\n\n\t\trespond_to do |format|\n\t\t\tif @project.save\n\t\t\t\tformat.json { render :show, status: :created }\n\t\t\telse\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @projects = current_user.projects\n @project = current_user.projects.new(project_params)\n\n respond_to do |format|\n if @projects << @project\n format.html { redirect_to user_projects_path(current_user), notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render json: @project, status: :created, location: @project }\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n format.html { render action: \"new\" }\n end\n end\n end",
"def create\n @project = current_user.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(attributes={})\n raw_response = post_request('projects', project: attributes)\n parse_response(raw_response, :project)\n end",
"def create\n #byebug\n @project = Project.new(create_params)\n @project.user_id = @current_user.id\n @project.save\n #@project = Project.create(name_project: \"prueba\", subsidy: true, parking: true, user_id: @current_user.id)\n #byebug\n render json: @project, status: :created\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.json { render :json => @project, :status => :created, :location => @project }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n if @project.save\n render json: @project, status: :ok\n else\n render json: {error: @project.errors.full_messages.to_sentence } , status: :unprocessable_entity\n end\n end",
"def create\n @user = current_user\n @project = @user.projects.build(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = current_user.projects.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html {redirect_to \"/projects\", notice: \"Project was successfully created.\"}\n format.json {render :show, status: :created, location: @project}\n else\n format.html {render :new, status: :unprocessable_entity}\n format.json {render json: @project.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: \"Project was successfully created.\" }\n User.find(current_user.id).projects << Project.find(@project.id)\n @projects_user = ProjectsUser.find_by(user_id: current_user.id, project_id: @project.id)\n format.json { render :show, status: :created, location: @project }\n\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: t('models.project.create') }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_project = Project.new(api_project_params)\n\n respond_to do |format|\n if @api_project.save\n format.html { redirect_to @api_project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @api_project }\n else\n format.html { render :new }\n format.json { render json: @api_project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: \"Project was successfully created.\" }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = @client.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @client, notice: 'Project was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.json { render json: @project, status: 200 }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n @project.user_id = @user.id\n if @project.save\n render json: {status: :success, project: @project}\n else\n render json: {status: :failed, project: @project}\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Project was successfully created.' }\n format.json { render action: 'show', status: :created, location: @project }\n else\n format.html { render action: 'new' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if project.save\n format.html { redirect_to project, notice: 'Project was successfully created.' }\n format.json { render json: project, status: ':created', location: project }\n else\n format.html { render action: 'new' }\n format.json { render json: project.errors, status: ':unprocessable_entity' }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: 'new' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = current_user.projects.new(project_params)\n if @project.save\n render :show\n else\n render json: { errors: @project.errors }\n end\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to admin_projects_url, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, flash: {success: 'Project was successfully created.'} }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # authenticate_user!\n @project = Project.new\n @project[:category] = params[:category]\n @project[:title] = params[:title]\n @project[:body] = params[:body]\n @project[:location] = params[:location]\n @project[:image_link] = params[:image_link]\n @project[:project_url] = params[:project_url]\n @project[:year] = params[:year]\n @project[:likes] = params[:likes]\n @project.save\n\n render json: @project\n end",
"def create\n @project = Project.new(project_params.merge(user_id: current_user.id))\n\n respond_to do |format|\n if @project.save\n format.json { render :show, status: :created, location: @project }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n \n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.find(params[:client_id])\n @project = @client.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to client_projects_path(@client), notice: 'Project was successfully created.' }\n format.json { render json: client_projects_path(@client), status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: client_projects_path(@client).errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = current_user.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to root_path, notice: 'Enhorabuena! Tienes un nuevo proyecto. A trabajar!' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.create project_params\n current_user.memberships.create(\n project_id: @project.id,\n owner_at: Time.now\n )\n\n if @project.save\n render 'projects/create', status: 201\n else\n render 'projects/error', status: 422\n end\n end",
"def create\n @project = @client.projects.build(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(client_projects_url(@client), notice: 'Project was successfully created.') }\n format.xml { render xml: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @create_project = current_user.projects.build(params[:project])\n flash[:notice] = \"Project #{@create_project.description} successfully created\" if @create_project.save\n respond_with(@create_project, layout: !request.xhr?)\n end",
"def new_project\n @request = Request.new(data_type: :project)\n @request.build_contact\n @request.build_project\n @request.build_general_information\n\n render 'new'\n end",
"def create\t\t\t\t\t\t\t\t\t# Creates record in db and redirects (porbably to index)\n\t\t@project = Project.new(projects_params)\t# Passes only title and desc.\n\n \trespond_to do |format|\t\t\t\t\t# All this is doing is rendering stuff in case of json\n \t\tif @project.save\n \t\tformat.html { redirect_to @project, notice: 'Created a new project!' }\n \t\tformat.json { render :show, status: :created, location: @project }\n \t\telse\n \t\tformat.html { render :new }\n \t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n\tend",
"def create\n if params[:project_id]\n cloned_from = Project.find(params[:project_id])\n @project = cloned_from.clone(params, @cur_user.id)\n else\n @cloned_project = nil\n @project = Project.new project_params\n @project.user_id = @cur_user.id\n end\n\n respond_to do |format|\n if @project.save\n format.html do\n redirect_to @project, notice: 'Project was successfully created.'\n end\n format.json do\n render json: @project.to_hash(false),\n status: :created, location: @project\n end\n else\n flash[:error] = @project.errors.full_messages\n format.html { redirect_to projects_path }\n format.json do\n render json: @project.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def create_project(key, name, params = {})\n params[:key] = key\n params[:name] = name\n post('projects', params)\n end",
"def create\n @project = Project.new(project_params)\n @project.owner = current_user unless @project.owner\n if @project.save\n render :show, status: :created, location: @project\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end",
"def create_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'POST'\n\t\targs[:pattern] = '/projects'\n\t\targs[:query]['Action'] = 'CreateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tself.run(args)\n\tend",
"def projects\n resource 'projects'\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n build_projects_user\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n project_attrs = params[:project].merge(validate_repo_connectivity: true)\n @project = current_user.owned_projects.create(project_attrs, as: :owner)\n respond_with @project do |format|\n format.json do\n if @project.valid?\n render json: decorate(@project).to_json, status: :created\n else\n render json: {project: @project.errors.as_json}.to_json, status: :unprocessable_entity\n end\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n @project.skills = params[:skills]\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.create(project_params)\n if @project.errors.blank?\n flash[:success] = t('controllers.projects.create.success', project: @project.name)\n else\n flash.now[:alert] = @project.errors.full_messages.unshift(t('controllers.projects.create.failure'))\n end\n respond_with @project, location: projects_url\n end",
"def create\n @new_nav = true;\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n if params[:project_attachments]\n create_attachments\n end\n\n if params[:project_fields]\n create_fields\n end\n\n if params[:slider_objects]\n create_slider_objects\n end\n\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n @project.user = current_user\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n begin\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors.full_messages, status: :unprocessable_entity }\n end\n end\n rescue Exception => e\n @project.destroy\n respond_to do |format|\n format.html { render :new }\n format.json { render json: e.as_json, status: :service_unavailable }\n end\n end\n end",
"def project_create(global_options, options)\n result = Excon.post(\n \"#{global_options[:fenton_server_url]}/projects.json\",\n body: project_json(options),\n headers: { 'Content-Type' => 'application/json' }\n )\n\n [result.status, JSON.parse(result.body)]\n end",
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n @project.user_projects.create(:user_id => current_user.id, :status => true, :role => 1)\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n respond_to do |format|\n if @project.save\n flash[:alert] = \"Project created successfully.\"\n format.html { redirect_back(fallback_location: root_path) }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n if is_organization_admin? and @project.save\n @project.team_members.create(user_id: @project.organization.owner_id)\n render json: {\n name: @project.name,\n organization: @project.organization.name,\n url: project_dashboard_path(@project.id)\n }\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end",
"def create\n @project = Project.new(project_params)\n\n if params[\"project\"][\"client_id\"] != \"\"\n @project.client = Client.find params[\"project\"][\"client_id\"]\n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Novo projeto cadastrado com sucesso.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = current_user.projects.create(params[:project])\n \n if @project.save\n record_activity(\"created new project: \" + @project.id.to_s)\n redirect_to root_path, :notice => \"Project created successfully\"\n else\n render 'new'\n end\n end",
"def create\n find_projects(params[:api_key])\n end",
"def create\n\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n\n respond_to do |format|\n if @project.save\n\n format.html { redirect_to @project, success: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(:project_title => params[:project_title], :start_date => params[:startDate], :end_date => params[:endDate],\n :status => params[:project_status])\n\n @project.user_id = current_user.id\n\n\n respond_to do |format|\n if @project.save\n p \"pass on projects controller\"\n format.html { redirect_to @project}\n format.json { render json: \"ok\" }\n else\n p \"fail on projects controller\"\n end\n end\n\n\n end",
"def create_project_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.create_project ...'\n end\n # resource path\n local_var_path = '/projects'\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 content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'create_project_body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'Project'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oryAccessToken']\n\n new_options = opts.merge(\n :operation => :\"ProjectApi.create_project\",\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: ProjectApi#create_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to :projects, notice: \"Project was successfully created.\" }\n format.json { render :show, status: :created, location: @project }\n else\n format.html do\n @teams = Team.order(:name)\n render :new\n end\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n @project.team.touch\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n render_errors(format, @project.errors, :new)\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to [:user, @project], notice: 'Project temp was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n\n render text: params[:project].inspect\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to projects_path, notice: 'Proyecto creado sastifactoriamente' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(params[:project])\n @project.status = \"Etat zero\"\n creator = current_user\n ProjectUser.create(:project => @project, :user => creator, :admin => true)\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project = @projectable.projects.new(params[:project])\n\n respond_to do |format|\n if @project.save\n track_activity @project\n format.html { redirect_to [@projectable, @project], notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render layout: 'form', action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n #Acá se retorna de la vista New (o de cualquier lugar que llame a create con POST). Le llega el hash project_params con \n # los datos que retornó la vista.\n\n #Crea el nuevo usuario.\n @project = Project.new(project_params)\n\n respond_to do |format| #Esta linea es curiosa. Si el request le llegó por HTML, entonces fue un navegador. Si le llego\n #por JSON, entonces probablemente fue otra cosa, un app movil por ejemplo.\n if @project.save #Esto guarda el proyecto nuevo en la base de datos y retorna True si no hubo problema, y False si hubo un error.\n # Es importante notar que al llamar .save, primero pasa por el modelo, el cual revisa que no falte ningún dato.\n # Por ejemplo, si el modelo necesita que se incluya el nombre del proyecto, si o si, y no se le pasó el nombre,\n # Entonces el modelo va a guardar ese error en un hash llamado errors, dentro de el mismo (@projects.errors)\n # y va a hacer que .save retorne False.\n\n\n format.html { redirect_to :controller => \"misc\", :action =>\"about\", notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7338948",
"0.73139244",
"0.7308003",
"0.7299582",
"0.7227503",
"0.7225945",
"0.71982473",
"0.71170384",
"0.7104803",
"0.7095263",
"0.7070636",
"0.70408624",
"0.70358187",
"0.7024969",
"0.70191896",
"0.7009597",
"0.698481",
"0.697517",
"0.6963753",
"0.6963096",
"0.6948756",
"0.6948756",
"0.6948756",
"0.6948756",
"0.6948756",
"0.6948756",
"0.6948756",
"0.6948756",
"0.6948756",
"0.6944626",
"0.69397265",
"0.6938008",
"0.69204897",
"0.6911497",
"0.6908809",
"0.6907813",
"0.6894293",
"0.689054",
"0.68847734",
"0.6879909",
"0.68794346",
"0.6879012",
"0.68784195",
"0.6868972",
"0.68664163",
"0.68660194",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.68657774",
"0.6865554",
"0.68598175",
"0.6858278",
"0.6846567",
"0.6828604",
"0.68193066",
"0.6806436",
"0.678643",
"0.6784763",
"0.6773288",
"0.675545",
"0.6750235",
"0.67379624",
"0.6718913",
"0.6716745",
"0.67009157",
"0.6686259",
"0.668621",
"0.66856426",
"0.66838706",
"0.6680505",
"0.66770595",
"0.6670888",
"0.6668133",
"0.66572726",
"0.66528344",
"0.66518456",
"0.66511416",
"0.6649628",
"0.6649045",
"0.6642436",
"0.6638429",
"0.6634081",
"0.66324985",
"0.6629944",
"0.6628171",
"0.66263485",
"0.66259176",
"0.66255814"
] |
0.66877806
|
77
|
PUT /projects/1 PUT /projects/1.json
|
def update
@project = Project.find(params[:id])
respond_to do |format|
if @project.update_attributes(params[:project])
format.html { redirect_to @project, notice: 'Project was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def project_update(project)\n raise Client::FileboundClientException.new('Id is required', 0) unless project[:projectId].greater_than_zero?\n put('/projects', nil, project)\n end",
"def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end",
"def update\n authorize! :update, @project\n\n if @project.update(project_params)\n head :no_content\n else\n render 'projects/error', status: 422\n end\n end",
"def update_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'UpdateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def update\n if @project.update(project_params)\n render :show, status: :ok, location: api_v1_project_url(@project)\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @project.update(project_params)\n render json: {status: :success, project: @project}\n else\n render json: {status: :failed, project: @project}\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n if params[:name] == \"project_name\"\n project_name = params[:value]\n @project.project_name = project_name\n end\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n\n @projects = Project.all\n format.html {\n render :action => \"index\"\n }\n format.json { render json: @project }\n else\n logMessage = self.class.to_s + \"#\" + __method__.to_s + \" \" + current_user.username + \" errors:\" + @project.errors.full_messages.to_s\n logger.info logMessage\n\n format.html {\n flash[:error] = 'Project was not successfully updated.'\n redirect_to action: \"index\"\n }\n errorMsg = @project.errors.full_messages.to_s.split(\"\\\"\")\n format.json { render json: errorMsg[1], status: 500 }\n end\n end\n end",
"def update\n respond_to do |format|\n if @project.update(project_params)\n format.json { render :show, status: :ok, location: @project }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @project.update(project_params)\n\t\t\t\tformat.json { render :show, status: :ok }\n\t\t\telse\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, :notice => 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @project.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = @client.projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to([@client, @project], notice: 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"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 @project.update(project_params)\n format.json { render json: @project, status: 200 }\n else\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @project.update(project_params)\n render :show, status: :ok\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @project.update(project_params)\n render :show, status: :ok\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @project\n if @project.update(project_params)\n render json: @project, status: :ok\n else\n render json: {error: @project.errors.full_messages.to_sentence } , status: :unprocessable_entity\n end\n else\n render json: {error: \"Project does not exist\"} , status: :unprocessable_entity\n end\n end",
"def update\n if @project.update(project_params)\n render :show, status: :ok, location: @project\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @project.update(project_params)\n render :show, status: :ok, location: @project\n else\n render json: @project.errors, status: :unprocessable_entity\n end\n end",
"def update\n @project = current_user.projects.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"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 @project.update(project_params)\n format.html { redirect_to add_path(@project), notice: 'Project was successfully updated.' }\n format.json { render :add, 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\t\t\t\t\t\t\t\t\t# Actually modifies the data and redirects (probably to index or show? depends)\n\t\t#@project = Project.find(params[:id])\t# Taken out because of the before action GENIUS!\n\n\t\trespond_to do |format|\n \t\t if @project.update(projects_params)\n \t\tformat.html { redirect_to @project, notice: 'Project was successfully updated.' }\n \t\tformat.json { render :show, status: :ok, location: @project }\n \t\telse\n \t\tformat.html { render :edit }\n \t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n\tend",
"def update\n project = Project.find(params[:id])\n\n respond_to do |format|\n if project and project.update_attributes(params[:project])\n format.html { redirect_to project }\n else\n format.html { redirect_to projects_path }\n end\n end\n end",
"def update\n\t\t@project = Project.find(params[:id])\n\t\tmake_breadcrumbs\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @project.update_attributes(params[:project])\n\t\t\t\tformat.html { redirect_to @project, notice: t('app.projects.updated') }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def project_updates\n @project = Project.find(params[:id])\n end",
"def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Projeto atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @edit_project = Project.find(params[:id])\n\n respond_to do |format|\n if @edit_project.update_attributes(params[:project])\n format.html { redirect_to @edit_project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @edit_project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project = Project.find_by_slug(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @workspaces = current_user.workspaces\n @project = Project.find(params[:id])\n @workspace = Workspace.find(params[:workspace_id])\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to workspace_project_tasks_path(@workspace , @project), notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:client_id])\n @project = Project.find(params[:id])\n \n respond_to do |format|\n if @project.update_attributes(project_params)\n format.html { redirect_to client_projects_path(@client), notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: client_projects_path(@client).errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\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 { head :no_content }\n else\n format.html { render action: '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 @api_project.update(api_project_params)\n format.html { redirect_to @api_project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_project }\n else\n format.html { render :edit }\n format.json { render json: @api_project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @project.update(project_params)\n \t\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 @project.update(project_params)\n format.html { redirect_to @project, notice: \"#{I18n.t 'project.project_updated'}\"}\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :edit, @project\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 @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: '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 @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: '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 @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authenticate_user!\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(params[:project])\n format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'UpdateProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :project\n\t\t\targs[:body]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:query]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def update\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.full_messages, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: projects_path }\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 @project.update(project_params)\n format.html { redirect_to @project, info: '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 @project.update(project_params)\n format.html { redirect_to projects_path, notice: \"Project was successfully updated.\" }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit, status: :unprocessable_entity }\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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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"
] |
[
"0.7379903",
"0.730825",
"0.7180619",
"0.71665376",
"0.71320134",
"0.71245116",
"0.7082403",
"0.70080924",
"0.70050913",
"0.69997466",
"0.6990245",
"0.6988755",
"0.6988755",
"0.6988755",
"0.6988755",
"0.6983069",
"0.69799423",
"0.69799423",
"0.6976596",
"0.6962526",
"0.69554496",
"0.69554496",
"0.6930991",
"0.6930991",
"0.6911746",
"0.6909087",
"0.6909087",
"0.6907269",
"0.6899338",
"0.6882839",
"0.68724597",
"0.68705934",
"0.6851139",
"0.682724",
"0.68240094",
"0.6815114",
"0.6811716",
"0.6806811",
"0.67920184",
"0.67625225",
"0.6755208",
"0.6751892",
"0.67327434",
"0.67309535",
"0.6723257",
"0.6723257",
"0.67218864",
"0.6715651",
"0.6709046",
"0.670732",
"0.67073023",
"0.6706559",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766",
"0.67049766"
] |
0.6969676
|
28
|
DELETE /projects/1 DELETE /projects/1.json
|
def destroy
@project = Project.find(params[:id])
@project.destroy
respond_to do |format|
format.html { redirect_to projects_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.delete\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.status = 'deleted'\n @project.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end",
"def delete\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n project = Project.find(params[:id])\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n name = @project.name\n @project.destroy\n render json: [\"You have successfullly deleted '#{name}''\"], status: 200\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @project.destroy\r\n respond_to do |format|\r\n format.html { redirect_to projects_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def delete(projects)\n project_ids = projects.collect { |project| project.id } \n args = {ids: project_ids.to_json}\n return @client.api_helper.command(args, \"project_delete\")\n end",
"def delete\r\n\t\t\trender json: Project.delete_by_id(params[:id])\r\n\t\tend",
"def destroy\n\t\t@project.destroy\n\t\trespond_to do |format|\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to administration_projects_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = current_user.projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { render :json => {:message=>\"OK\",:id=>@project.id}, :staus=>:ok}\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n head :no_content\n end",
"def destroy\t\t\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Successfully deleted project.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: t('models.project.destroy') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = @client.projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to @client }\n end\n end",
"def destroy\n @project.destroy\n\n head :no_content\n end",
"def destroy\n @ourproject = Ourproject.find(params[:id])\n @ourproject.destroy\n\n respond_to do |format|\n format.html { redirect_to ourprojects_url }\n format.json { head :ok }\n end\n end",
"def destroy\n authorize @project\n @project.destroy\n render json: [\"Deleted successfully.\"], status: :ok\n end",
"def destroy\n @project.destroy_all\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'The project was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def delete_project(project)\n handle_action_exceptions(__method__) do\n cmd_line = [\"deleteproject '#{project}'\"]\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { render :json => {:valid => true} }\n end\n end",
"def destroy\n @api_project.destroy\n respond_to do |format|\n format.html { redirect_to api_projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_path, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = Project.find_by_permalink(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def delproject(project)\n post('delproject.json', project: project)\n end",
"def destroy\n authorize! :destroy, @project\n @project.destroy\n\n head :no_content\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n\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 Rails.logger.info \"We are deleting project\"\n @todo_project.destroy\n respond_to do |format|\n format.html { redirect_to todo_projects_url, notice: 'Project was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = @projectable.projects.find(params[:id])\n @project.destroy\n track_activity @project\n\n respond_to do |format|\n format.html { redirect_to [@projectable, :projects] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = Project.find(params[:id])\n @project.destroy\n @project.users.delete_all\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t@project = Project.find(params[:id])\n \t#ap @project\n \t#abort\n \n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n authenticate_user!\n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(projects_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @project.destroy\n render json: {message: 'Projeto Excluido'}, status: :ok\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = Project.find_by_slug(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :ok }\n end\n end",
"def destroy\n\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"#{I18n.t 'project.project_destoy'}\"}\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = Admin::Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_projects_url) }\n format.xml { head :ok }\n end\n end",
"def delete_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'DELETE'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'DeleteProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def destroy\n @project = current_user.active_projects.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n standard_destroy(Project, params[:id])\n end",
"def destroy\n authorize! :delete, @project\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: \"Project was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'Project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.78951",
"0.78593713",
"0.7778056",
"0.7771693",
"0.77585995",
"0.7730887",
"0.77305084",
"0.77305084",
"0.77305084",
"0.77305084",
"0.77305084",
"0.77244985",
"0.7718401",
"0.7718401",
"0.7718401",
"0.7718401",
"0.7700103",
"0.76993084",
"0.7682566",
"0.7669082",
"0.7659675",
"0.764973",
"0.76495475",
"0.7641442",
"0.763269",
"0.761519",
"0.76147044",
"0.7611191",
"0.76066136",
"0.7605034",
"0.7598783",
"0.75986093",
"0.7593673",
"0.7591231",
"0.75896156",
"0.7571706",
"0.7571697",
"0.7561333",
"0.7543007",
"0.7537952",
"0.75324875",
"0.75302756",
"0.75237787",
"0.75237787",
"0.75189",
"0.75063527",
"0.7504202",
"0.7499374",
"0.7494583",
"0.7487019",
"0.74810386",
"0.74776345",
"0.7469382",
"0.74652857",
"0.7460907",
"0.7460907",
"0.74520767",
"0.7448516",
"0.744649",
"0.74448746",
"0.74421936",
"0.7441719",
"0.74374086",
"0.7437005",
"0.74365294",
"0.74365294",
"0.74365294",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244",
"0.7436244"
] |
0.7704753
|
32
|
plex last episode of a show
|
def thetvdb_missing_plex_last_ep(show)
log_debug
last_ep = '0;0'
$plex.episodes[show].keys.each do |season|
$plex.episodes[show][season].keys.each do |episode|
last_ep = "#{season};#{episode}"
end
end
return last_ep.split(';')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def latest_episode(index=0)\n latest_ep = nil\n\n\n# self.live_episodes.each do |ep|\n## puts \"#{__FILE__}:#{__LINE__} #{__method__} #{ep.release_date_unix} - #{ep.name}\"\n# latest_ep = ep if latest_ep == nil\n# latest_ep = ep if latest_ep.release_date_unix.to_i < ep.release_date_unix.to_i\n# end\n self.released_episodes.each_with_index do |ep, idx|\n latest_ep = ep if idx == index\n end\n\n sd = ShowDate.new(latest_ep.release_date_unix.to_i) if latest_ep\n sd = ShowDate.new(Time.new.to_i) unless latest_ep\n\n# puts \"#{__FILE__}:#{__LINE__} #{__method__} SD: #{sd.timestamp} - #{self.name} - #{sd.inspect} - #{sd.month_str}, #{sd.day_of_month} ,#{sd.year}\"\n\n sd\n end",
"def final_ep\n @episodes.last.number\n end",
"def next_episodes(show, name, id)\n db_show = TvShows.where(:user => session[:username]).where(:name => name).first\n\n if !db_show.nil?\n last_season = TvShows.where(:user => session[:username]).where(:name => name).first.season\n last_episode = TvShows.where(:user => session[:username]).where(:name => name).first.episode\n else\n last_season = 1\n last_episode = 1\n end\n\n current_season = Tmdb::Season.detail(id, last_season)\n if !current_season['episodes'].nil?\n episodes = current_season['episodes'][last_episode.to_i, current_season['episodes'].length]\n\n number_of_seasons = show['number_of_seasons']\n ((last_season.to_i + 1)..number_of_seasons.to_i).each do |season_number|\n season = Tmdb::Season.detail(id, season_number)\n new_episodes = season['episodes'][0, season['episodes'].length]\n episodes.concat(new_episodes)\n end\n episodes\n else\n nil\n end\n end",
"def get \n log_debug\n $plex.episodes.keys.each do |show|\n thetvdb_missing_last_process(show)\n end\nend",
"def episode; end",
"def episode; end",
"def episode; end",
"def episode; end",
"def first_episode_number\n @first_episode_number || 1\n end",
"def next_episode\n # Not ep(@current_ep + 1) because episodes are not guaranteed to be in\n # sequence (i.e. we could have episodes 1, 2, 4, 5 etc.)\n idx = @episodes.map(&:number).index(@current_ep)\n if idx + 1 < @episodes.size\n @episodes[idx + 1]\n else\n ep(@current_ep)\n end\n end",
"def episode\n fetch('cowboy_bebop.episode')\n end",
"def prev_video\n if episode?\n episode = content.prev_ep\n unless episode.nil?\n episode.video\n end\n end\n end",
"def finished_at\n @episodes.last.first_watched\n end",
"def thetvdb_missing_plex_first_ep(show)\n log_debug\n first_ep = '0;0'\n \n $plex.episodes[show].keys.each do |season|\n $plex.episodes[show][season].keys.each do |episode|\n if first_ep == '0;0' \n first_ep = \"#{season};#{episode}\"\n end\n end\n end\n \n return first_ep.split(';')\nend",
"def thetvdb_missing_last_process(show)\n log_debug\n \n $thetvdb.show(show)\n\n season_last, episode_last = thetvdb_missing_plex_last_ep(show)\n season_first, episode_first = thetvdb_missing_plex_first_ep(show)\n log_debug(\"#{show} start s#{season_first}e#{episode_first} : last s#{season_last}e#{episode_last}\")\n\n if $thetvdb.episodes.has_key?(show)\n $thetvdb.episodes[show]['episodes'].keys.each do |season|\n next if season == \"0\"\n \n $thetvdb.episodes[show]['episodes'][season].keys.each do |episode|\n first_aired = $thetvdb.episodes[show]['episodes'][season][episode]['first_aired']\n show_index = show_index(season, episode)\n plex_has = thetvdb_missing_plex_found(show,season,episode)\n missing = thetvdb_missing_range(season, season_first, episode, episode_first)\n missing = false if plex_has\n \n if first_aired =~ /\\w/\n date_available = Date.today\n date_aired = Date.parse first_aired\n if ( date_available > (date_aired + 1) ) and missing\n missing_process show, show_index,\"aired: #{first_aired}\"\n end\n end\n end\n end\n end\nend",
"def episode_number\n return 0 if link_url == 'https://shows.acast.com/easyeaspanish/episodes/trailer'\n if podcast.code == 'easygreek'\n link_url[%r{/episodes/(\\d+)}, 1]&.to_i\n else\n slug[/^\\d+/]&.to_i\n end\n end",
"def episode_number\n @ole.EpisodeNumber\n end",
"def episode_number\n filename = @resource.path.split('/').last\n filename.split('-').first.to_i\n end",
"def show\n @trabajador = Trabajador.find(@episode.trabajador_id)\n @sintoma = @episode.sintoma\n @contactos = @episode.contactos\n @Useguimiento = @episode.seguimientos.last\n\n end",
"def index\n @last_episodes = current_user.last_episodes\n end",
"def next_video\n if episode?\n episode = content.next_ep\n unless episode.nil?\n return episode.video\n end\n end\n end",
"def previous\n self.new_record? ? nil : Slide.where(:lesson_id => self.lesson_id, :position => (self.position - 1)).first\n end",
"def add_episode_name(show_hash)\n \t@latest_episode_name = show_hash[:latest_episode_name]\n end",
"def ep(ep_num)\n idx = @episodes.map(&:number).index(ep_num.to_i)\n return nil if idx.nil?\n @episodes[idx]\n end",
"def episode_title\n fetch('simpsons.episode_titles')\n end",
"def episode_title; end",
"def next_video_or_show\n ep = next_video\n if ep.nil?\n return content.show\n else\n return ep\n end\n end",
"def played\n # @@played.inspect\n index = @@played.length \n puts @@played[index-1].show \n end",
"def last_movie\n doc.search(\"a[title='Последний фильм']\").text\n end",
"def last() end",
"def build_external_episode(show)\n @external_program.external_episodes.build(\n :title => \"#{@external_program.title} for \" +\n show.showDate.strftime(\"%A, %B %e, %Y\"),\n :air_date => show.showDate\n )\n end",
"def following\n self.new_record? ? nil : Slide.where(:lesson_id => self.lesson_id, :position => (self.position + 1)).first\n end",
"def last\n @listen_event = @recording.listen_events.last\n render :show\n end",
"def episode(*args)\n if args.first.is_a? String\n episode_by_title *args\n else\n episode_by_numbers *args\n end\n end",
"def thetvdb_missing_plex_found(show,season,episode)\n plex_has = false\n \n # remove shows that we have\n if $plex.episodes.has_key? show \n if $plex.episodes[show].has_key?(season.to_i)\n if $plex.episodes[show][season.to_i].has_key?(episode.to_i)\n plex_has = true \n end\n end\n end\n plex_has\nend",
"def getNextShow()\n #todo: implement priority checking\n #this query only grabs shows that should currently be recording\n #assume shows do not overlap, just the padded times overlap\n shows = Array.new\n now_showing = \"SELECT DATE_FORMAT(start, '#{DATE_TIME_FORMAT_XML}') as start, \n DATE_FORMAT(p.stop, '#{DATE_TIME_FORMAT_XML}') as stop, \n number, filename, p.xmlNode as xmlNode, channelID, priority\n FROM Scheduled s JOIN Channel USING (channelID)\n JOIN Programme p USING(channelID, start)\n WHERE start <= '#{PaddedTime.strstart}'\n AND p.stop > '#{PaddedTime.strstop}'\"\n \n databasequery(\"SELECT * FROM (#{now_showing}) as sub1\n WHERE priority = (SELECT max(priority) FROM (#{now_showing}) as sub2 )\").each_hash { |show_hash| \n shows << Show.new(show_hash['start'], \n show_hash['stop'], \n show_hash['number'], \n show_hash['xmlNode'], \n show_hash['filename'], \n show_hash['channelID'])\n }\n return nil if shows.length == 0\n if shows.length > 1\n #we have adjacent shows, or at least close enough so they overlap when padded\n shows.sort! {|a,b| a.starts_in <=> b.starts_in }\n (1...shows.length).each {|pos|\n shows[pos-1].unpad(shows[pos])\n }\n shows.delete_if { |show| show.notShowing }\n end\n #LOG.debug(\"The next show to record is #{shows[0].filename}\")\n shows[0]\nend",
"def set_episode\n @episode = @season.episodes.find_by(number: params[:id])\n end",
"def set_episode\n @episode = @season.episodes.find_by(number: params[:id])\n end",
"def current_season\n self.seasons.find(:first,\n :conditions => {:date => Season.maximum('date')})\n end",
"def last; end",
"def last; end",
"def last; end",
"def show\n session[:recent_shows] ||= []\n post_hash = {:title => @post.title, :id => @post.id.to_s}\n\n unless session[:recent_shows].include?(post_hash)\n session[:recent_shows].push(post_hash)\n end\n\n if session[:recent_shows].length > 3\n # 末尾3つを残す\n length = session[:recent_shows].length\n session[:recent_shows] = session[:recent_shows][length-3..-1]\n end\n end",
"def show\n @events = Event.last(4).reverse \n end",
"def tv_last_channel \n send_cmd(\"tv_last_channel\")\n end",
"def target_path(ep, ext)\n show_dir = @dest_dir + ep.show_name\n season_dirname = \"Season #{ep.season}\"\n epNum = ep.episodes.map { |e| ep.season.to_s + 'x' + e.to_s.rjust(2,'0') }.join('+')\n epTitle = ep.titles.join(' + ')\n \n # Special case if the episode is in 2 parts and the two parts have the same title\n # Like \"XXX (Part 1)\" and \"XXX (Part 2)\", then be a bit more clever for the ep title\n if ep.titles.count == 2 && ep.titles[0].length == ep.titles[1].length\n (t1,t2) = ep.titles\n pos = (0..t1.length-1).find { |i| t1[i] != t2[i] } # Find first differing char\n if t1[pos].chr == '1' && t2[pos].chr == '2' && t1[pos+1..-1] == t2[pos+1..-1]\n # If only differing char is '1' vs '2' (and is the only difference)\n t1[pos] = '1+2' # then use the one of the two titles and replace with '1+2'\n epTitle = t1 # and use as the episode title instead.\n end\n end\n \n target_basename = sanitize(\"#{ep.show_name} - #{epNum} - #{epTitle}\")\n show_dir + season_dirname + (target_basename + ext)\n end",
"def episode_id\n @ole.EpisodeID\n end",
"def episode_show_pagination\n\t\tself.class.episode_show_pagination( self, @show )\n\tend",
"def show\n puts \"++++++++ star#show\"\n @star = Star.find(params[:id])\n @episodes = @star.episodes\n #@episode = Episode.new\n #@podcasts = Podcast.all #we don't need all the podcasts.\n\n star_query = @star.name.strip.gsub(/\\s+/, \"+\")\n\n #this works, but super innefficient. \n def all_eps(query, offset)\n episodes_arr = []\n results = 10\n num = offset\n\n while results == 10\n\n response = HTTParty.get \"https://listennotes.p.mashape.com/api/v1/search?len_min=10&offset=#{num}&only_in=title&published_after=0&q=#{query}&sort_by_date=0&type=episode\",\n headers:{\n 'X-Mashape-Key' => ENV['MASHAPE_KEY'],\n \"Accept\" => \"application/json\"\n }\n #episodes_arr << response[\"results\"] #adds the current results to the array. Nope..\n response[\"results\"].each { |r| episodes_arr << r}\n num += response[\"count\"].to_i #increases the offset by the number of results that we just found\n \n count = episodes_arr.count\n puts \"There are now #{count} in the array\"\n results = response[\"count\"]\n puts \"The latest lookup has #{results} results in there. \"\n\n end\n return episodes_arr\n end\n\n if @star.last_search == nil\n s = @star\n s.last_search = Date.today - 10.days\n puts s.last_search\n s.save\n end\n\n l = @star.last_search < (Date.today - 2.days)\n puts l \n #works\n\n if l == true \n many_episodes = all_eps(star_query, 0)\n many_episodes.select! do |e| \n limit = Date.today - 3.years\n def comparable_date(f)\n sec = (f[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n end\n comparable_date(e) > limit\n end #holy shit this works! Needs cleanup\n\n #save each episode - works\n many_episodes.each do |ep|\n new_ep = Episode.new\n pod_name = ep[\"podcast_title_original\"]\n pod = Podcast.find_or_create_by(name: pod_name)\n new_ep.star_id = @star.id\n new_ep.podcast_id = pod.id\n new_ep.title = ep[\"title_original\"]\n new_ep.description = ep[\"description_original\"]\n new_ep.api_id = ep[\"id\"]\n sec = (ep[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n new_ep.release_date = dform\n new_ep.save\n end\n\n @episodes_arr = many_episodes.sort_by { |e| e[\"pub_date_ms\"]}.reverse\n @star.last_search = Date.today\n @star.save\n else\n puts \"WE DIDN RUN THE SEARCH\"\n end\n @display_episodes = @episodes.where(display: true)\n end",
"def last\n end",
"def last(n = 1)\n return @history[-n] ;\n end",
"def previous_player\n players.last\n end",
"def play\r\n puts @recordings.last\r\n end",
"def set_episode\n @episode = Episode.find_by(human_id: params[:id])\n end",
"def finished?\n @episodes.last.watched?\n end",
"def show\n acts = @act.play.acts\n acts = acts.sort { |a, b| a.act_number <=> b.act_number }\n index = acts.index { |a| a.id == @act.id }\n \n @next = acts[index + 1]\n if index > 0\n @previous = acts[index-1]\n end\n end",
"def new\n season = Season.find(params.require(:season_id))\n episode = Episode.new\n episode.season_id = season.id\n episode.number = season.episodes_count + 1\n episode.save\n redirect_to :back, notice: \"Episode #{episode.number} successfully created\"\n end",
"def current_show\n shows.order('created_at DESC').first\n end",
"def view_last\n return @vassals[-1].view_last\n end",
"def set_episode\n @series = Series.find(params[:series_id].to_i)\n @episode = @series.episodes.find(params[:id].to_i)\n end",
"def recent_videos\n videos.first(6)\n end",
"def command_next(m, show_keyword)\n show = @shows.find_show(show_keyword) if show_keyword and !show_keyword.strip.empty?\n\n if show\n next_event = @calendar.next_event(show.title)\n else\n next_event = @calendar.next_event\n end\n\n if next_event\n date_string = next_event.start_time.strftime(\"%-m/%-d/%Y\")\n time_string = next_event.start_time.strftime(\"%-I:%M%P\")\n nearest_seconds_until = ((next_event.start_time - DateTime.now) * 24 * 60 * 60).to_i\n if show\n m.user.send \"The next #{next_event.summary} is in #{ChronicDuration.output(nearest_seconds_until, :format => :long)} (#{time_string} on #{date_string})\"\n else \n m.user.send \"Next show is #{next_event.summary} in #{ChronicDuration.output(nearest_seconds_until, :format => :long)} (#{time_string} on #{date_string})\"\n end\n else\n m.user.send \"No upcoming show found for #{show.title}\"\n end\n\n end",
"def last(n = 1)\n if n > 1\n (ds = Array(max)).empty? ? ds : ds.concat(ds[0].prev(n - 1))\n else\n max\n end\n end",
"def episodes\n Episode.all.select{ |episode| episode.show == self }\n end",
"def last?; end",
"def index\n @series = Series.find(params[:series_id].to_i)\n @new_episodes = @series.episodes.where(:seen => false).order(\"season desc, episode desc\")\n @seen_episodes = @series.episodes.where(:seen => true).order(\"season desc, episode desc\")\n end",
"def show\n \t@season_list = @title.season_list\n \t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n \tif @episode_list.count == 0\n \t\tparams[:season_choice] = \"All\"\n\t\t\t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n\t\tend\n \tlogger.debug @episode_list\n end",
"def url_to_episode( show_version, episode_version )\n\t\t{ :controller => '/watch', :action => episode_version.version_stub_id, :id => \"#{show_version.url_title}-#{episode_version.url_title}\" }\n\tend",
"def prev_in_playlist\n self.new_record? ? nil : (self.in_playlist? ? VirtualClassroomLesson.where(:user_id => self.user_id, :position => (self.position - 1)).first : nil)\n end",
"def show\n @scores = @music.machine.get_top_scores(@music.season, num: nil)[@music]\n end",
"def watching_episodes\n shows = ::TvShow.watching\n @episodes = episodes.each_with_object([]) do |episode, object|\n show = shows.find{|sh| sh.imdb_id == episode.show.ids.imdb}\n next if show.blank?\n object << episode\n end.uniq{|episode| episode.show.title}\n self\n end",
"def episodes( season )\n return @seasons[season].first.flatten\n end",
"def watch_current!\n ep = ep(@current_ep).watch!\n @current_ep = next_episode.number\n ep\n end",
"def next\n Post.posted.where('publish_at > ?', publish_at).last\n end",
"def set_episode\n @episode = Episode.includes(:season).find(params[:id])\n end",
"def previous_track()\n @ole.PreviousTrack()\n end",
"def show\n @lastest_news = Publication.latest_news\n end",
"def last_match\n self.current_season.round_actual.get_match(self)\n end",
"def get_episode_info\n\n\t\tbegin\n\t\t\turl = source_url\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/miss-undercover,5cd28786818965652bf912ab.html\"\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/monitor,5cda852e81896518171f509c.html\"\n\t\t\tdoc \t\t\t= send_request(url)\n\t\t\tdata \t\t\t= doc.css(\"article.broadcast-detail\")\n\t\t\t# header \t\t= doc.css(\"header.broadcast-detail__header\")\n\t\t\t# duration \t\t= header.css(\"div.text-wrapper span.text-row\")[1].text[-7..-2] rescue nil\n\t\t\tchannel \t\t= doc.css(\"span.tv-show-label__channel\").text\n\t\t\tvideo \t\t\t= get_video_url(doc)\n\t\t\tdescription = doc.css(\"section.broadcast-detail__description p\").text.delete(\"\\\"\").delete(\"\\r\").delete(\"\\n\")\n\t\t\tcast \t\t\t= doc.css(\"section.cast dl\")\n\t\t\tcasts \t\t\t= get_cast(cast[0])\n\t\t\tactors \t\t\t= get_cast(cast[1])\n\t\t\tthumb = doc.css('div.editorial-rating')[0].values[0].split(\" \")[1] rescue nil\n\t\t\t# transmitter_valid(channel)\n\t\t\timage = doc.css(\".broadcast-detail__stage img\").first.attributes[\"src\"].value rescue []\n\t self.program.update(genre: casts[\"Genre\"]) if (casts[\"Genre\"].present? && program.genre.nil?)\n\t\t\t\n\t\t\tparam = {is_scraped: true} \n\t\t\tparam.merge!(preview_video_url: video) if video.present?\n\t\t\tself.update(param)\n\n\t self.episode_infos.create(description: description, country: casts[\"Land\"], year: casts[\"Jahr\"],age_rating: casts[\"Altersfreigabe\"], director: casts[\"Regie\"], producer: casts[\"Produzent\"], script: casts[\"Drehbuch\"], camera: casts[\"Kamera\"], music: casts[\"Musik\"], original_title: casts[\"Originaltitel\"], actors: actors ,thumb: thumb, image_urls: image)\n\t get_rating(doc)\n\t rescue StandardError => e\n\t \tRails.logger.info \"================================================\"\n\t \tRails.logger.info \"Having some issues during storing episode info.\"\n\t \tRails.logger.info \"#{e}\"\n\t end\n\tend",
"def show\n french_scenes = @french_scene.scene.act.play.french_scenes\n french_scenes = french_scenes.sort { |a, b| a.pretty_name <=> b.pretty_name }\n index = french_scenes.index { |fs| fs.id == @french_scene.id }\n\n @next = french_scenes[index + 1]\n if index > 0\n @previous = french_scenes[index-1]\n end\n end",
"def last\n at(-1)\n end",
"def current_season\n curr_season = seasons.where(\"current_season = ?\", true).first\n\n if curr_season == nil\n curr_season = seasons.last\n end\n\n curr_season\n end",
"def find_last_note(nb_notes)\n note = self\n (nb_notes.to_i - 1).times do\n note = note.succ\n end\n note\n end",
"def last_transition\n StateTransition.where(record_id: id, record_type: self.class.to_s).order(id: :desc).limit(1).first\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def last_event\n history.last\n end",
"def last_event\n history.last\n end",
"def previous\n @news_item = @news_item.previous_version\n show\n end",
"def lastn_arel(limit = AppConstants.number_of_shows_for_trending)\n s = Show.arel_table\n s.project(s[:id]).\n order(s[:number].desc).take(limit)\n end"
] |
[
"0.7042593",
"0.70366925",
"0.6770952",
"0.66725326",
"0.65757227",
"0.65757227",
"0.65757227",
"0.65757227",
"0.6516167",
"0.647702",
"0.63450396",
"0.6166348",
"0.61621815",
"0.6115442",
"0.6099597",
"0.60675365",
"0.6003067",
"0.5946553",
"0.5941841",
"0.59389234",
"0.58761954",
"0.5823895",
"0.5749637",
"0.5719891",
"0.5696129",
"0.5693239",
"0.5683193",
"0.56822366",
"0.56664485",
"0.5600373",
"0.55986303",
"0.5579047",
"0.5545097",
"0.55110234",
"0.55093616",
"0.55016756",
"0.5435291",
"0.5432438",
"0.542941",
"0.5428646",
"0.5428646",
"0.5428646",
"0.5404899",
"0.53993404",
"0.53909856",
"0.5389327",
"0.5388998",
"0.5377778",
"0.5359651",
"0.53366476",
"0.5329561",
"0.5304654",
"0.5302114",
"0.5294775",
"0.52926105",
"0.52880853",
"0.5278355",
"0.5271451",
"0.5260545",
"0.5226742",
"0.5226505",
"0.5225173",
"0.52028984",
"0.5201279",
"0.5197483",
"0.51940036",
"0.51936597",
"0.5170806",
"0.51662517",
"0.5163565",
"0.51584345",
"0.51568264",
"0.5148782",
"0.51432073",
"0.51421785",
"0.51405966",
"0.513164",
"0.5131624",
"0.5131015",
"0.5125644",
"0.51252747",
"0.5117033",
"0.5115457",
"0.51105165",
"0.51094365",
"0.51094365",
"0.51094365",
"0.51094365",
"0.51094365",
"0.51094365",
"0.51094365",
"0.51094365",
"0.51094365",
"0.51094365",
"0.5107415",
"0.5107415",
"0.51065046",
"0.51065046",
"0.5105974",
"0.50986046"
] |
0.69161004
|
2
|
plex first episode of a show
|
def thetvdb_missing_plex_first_ep(show)
log_debug
first_ep = '0;0'
$plex.episodes[show].keys.each do |season|
$plex.episodes[show][season].keys.each do |episode|
if first_ep == '0;0'
first_ep = "#{season};#{episode}"
end
end
end
return first_ep.split(';')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def first_episode_number\n @first_episode_number || 1\n end",
"def next_episodes(show, name, id)\n db_show = TvShows.where(:user => session[:username]).where(:name => name).first\n\n if !db_show.nil?\n last_season = TvShows.where(:user => session[:username]).where(:name => name).first.season\n last_episode = TvShows.where(:user => session[:username]).where(:name => name).first.episode\n else\n last_season = 1\n last_episode = 1\n end\n\n current_season = Tmdb::Season.detail(id, last_season)\n if !current_season['episodes'].nil?\n episodes = current_season['episodes'][last_episode.to_i, current_season['episodes'].length]\n\n number_of_seasons = show['number_of_seasons']\n ((last_season.to_i + 1)..number_of_seasons.to_i).each do |season_number|\n season = Tmdb::Season.detail(id, season_number)\n new_episodes = season['episodes'][0, season['episodes'].length]\n episodes.concat(new_episodes)\n end\n episodes\n else\n nil\n end\n end",
"def next_episode\n # Not ep(@current_ep + 1) because episodes are not guaranteed to be in\n # sequence (i.e. we could have episodes 1, 2, 4, 5 etc.)\n idx = @episodes.map(&:number).index(@current_ep)\n if idx + 1 < @episodes.size\n @episodes[idx + 1]\n else\n ep(@current_ep)\n end\n end",
"def episode; end",
"def episode; end",
"def episode; end",
"def episode; end",
"def latest_episode(index=0)\n latest_ep = nil\n\n\n# self.live_episodes.each do |ep|\n## puts \"#{__FILE__}:#{__LINE__} #{__method__} #{ep.release_date_unix} - #{ep.name}\"\n# latest_ep = ep if latest_ep == nil\n# latest_ep = ep if latest_ep.release_date_unix.to_i < ep.release_date_unix.to_i\n# end\n self.released_episodes.each_with_index do |ep, idx|\n latest_ep = ep if idx == index\n end\n\n sd = ShowDate.new(latest_ep.release_date_unix.to_i) if latest_ep\n sd = ShowDate.new(Time.new.to_i) unless latest_ep\n\n# puts \"#{__FILE__}:#{__LINE__} #{__method__} SD: #{sd.timestamp} - #{self.name} - #{sd.inspect} - #{sd.month_str}, #{sd.day_of_month} ,#{sd.year}\"\n\n sd\n end",
"def get \n log_debug\n $plex.episodes.keys.each do |show|\n thetvdb_missing_last_process(show)\n end\nend",
"def episode_title\n fetch('simpsons.episode_titles')\n end",
"def show\n \t@season_list = @title.season_list\n \t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n \tif @episode_list.count == 0\n \t\tparams[:season_choice] = \"All\"\n\t\t\t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n\t\tend\n \tlogger.debug @episode_list\n end",
"def episode(*args)\n if args.first.is_a? String\n episode_by_title *args\n else\n episode_by_numbers *args\n end\n end",
"def thetvdb_missing_plex_last_ep(show)\n log_debug\n last_ep = '0;0'\n $plex.episodes[show].keys.each do |season|\n $plex.episodes[show][season].keys.each do |episode|\n last_ep = \"#{season};#{episode}\"\n end\n end\n \n return last_ep.split(';')\nend",
"def episode\n fetch('cowboy_bebop.episode')\n end",
"def set_episode\n @episode = @season.episodes.find_by(number: params[:id])\n end",
"def set_episode\n @episode = @season.episodes.find_by(number: params[:id])\n end",
"def thetvdb_missing_plex_found(show,season,episode)\n plex_has = false\n \n # remove shows that we have\n if $plex.episodes.has_key? show \n if $plex.episodes[show].has_key?(season.to_i)\n if $plex.episodes[show][season.to_i].has_key?(episode.to_i)\n plex_has = true \n end\n end\n end\n plex_has\nend",
"def episode_number\n return 0 if link_url == 'https://shows.acast.com/easyeaspanish/episodes/trailer'\n if podcast.code == 'easygreek'\n link_url[%r{/episodes/(\\d+)}, 1]&.to_i\n else\n slug[/^\\d+/]&.to_i\n end\n end",
"def next_video_or_show\n ep = next_video\n if ep.nil?\n return content.show\n else\n return ep\n end\n end",
"def set_show\n # @show = Show.find(params[:id])\n # @show = Show.friendly.find(params[:id])\n #@show = Show.includes(:episodes).where(\"episodes.approved\" => true).friendly.find(params[:id])\n @show = Show.includes(:episodes).where(\"episodes.approved\" => true).order('episodes.episode').friendly.find(params[:id])\n end",
"def ep(ep_num)\n idx = @episodes.map(&:number).index(ep_num.to_i)\n return nil if idx.nil?\n @episodes[idx]\n end",
"def episode_title; end",
"def next_video\n if episode?\n episode = content.next_ep\n unless episode.nil?\n return episode.video\n end\n end\n end",
"def started_at\n @episodes.first.first_watched\n end",
"def build_external_episode(show)\n @external_program.external_episodes.build(\n :title => \"#{@external_program.title} for \" +\n show.showDate.strftime(\"%A, %B %e, %Y\"),\n :air_date => show.showDate\n )\n end",
"def set_episode\n @episode = Episode.find_by(human_id: params[:id])\n end",
"def show\n acts = @act.play.acts\n acts = acts.sort { |a, b| a.act_number <=> b.act_number }\n index = acts.index { |a| a.id == @act.id }\n \n @next = acts[index + 1]\n if index > 0\n @previous = acts[index-1]\n end\n end",
"def prev_video\n if episode?\n episode = content.prev_ep\n unless episode.nil?\n episode.video\n end\n end\n end",
"def set_episode\n @episode = Episode.includes(:season).find(params[:id])\n end",
"def final_ep\n @episodes.last.number\n end",
"def set_episode\n @series = Series.find(params[:series_id].to_i)\n @episode = @series.episodes.find(params[:id].to_i)\n end",
"def show\n @trabajador = Trabajador.find(@episode.trabajador_id)\n @sintoma = @episode.sintoma\n @contactos = @episode.contactos\n @Useguimiento = @episode.seguimientos.last\n\n end",
"def show\n @scores = @music.machine.get_top_scores(@music.season, num: nil)[@music]\n end",
"def getNextShow()\n #todo: implement priority checking\n #this query only grabs shows that should currently be recording\n #assume shows do not overlap, just the padded times overlap\n shows = Array.new\n now_showing = \"SELECT DATE_FORMAT(start, '#{DATE_TIME_FORMAT_XML}') as start, \n DATE_FORMAT(p.stop, '#{DATE_TIME_FORMAT_XML}') as stop, \n number, filename, p.xmlNode as xmlNode, channelID, priority\n FROM Scheduled s JOIN Channel USING (channelID)\n JOIN Programme p USING(channelID, start)\n WHERE start <= '#{PaddedTime.strstart}'\n AND p.stop > '#{PaddedTime.strstop}'\"\n \n databasequery(\"SELECT * FROM (#{now_showing}) as sub1\n WHERE priority = (SELECT max(priority) FROM (#{now_showing}) as sub2 )\").each_hash { |show_hash| \n shows << Show.new(show_hash['start'], \n show_hash['stop'], \n show_hash['number'], \n show_hash['xmlNode'], \n show_hash['filename'], \n show_hash['channelID'])\n }\n return nil if shows.length == 0\n if shows.length > 1\n #we have adjacent shows, or at least close enough so they overlap when padded\n shows.sort! {|a,b| a.starts_in <=> b.starts_in }\n (1...shows.length).each {|pos|\n shows[pos-1].unpad(shows[pos])\n }\n shows.delete_if { |show| show.notShowing }\n end\n #LOG.debug(\"The next show to record is #{shows[0].filename}\")\n shows[0]\nend",
"def episode_number\n @ole.EpisodeNumber\n end",
"def show\n @query = Episode.where(podcast_id: @podcast.id).search(params[:q])\n if params[:q]\n @query.sorts = 'pub_date desc' if @query.sorts.empty?\n @episodes = @query.result.paginate(:page => params[:page], :per_page => 15)\n else\n @episodes = @podcast.episodes.order(pub_date: :desc).paginate(:page => params[:page], :per_page => 15)\n end\n end",
"def episode_number\n filename = @resource.path.split('/').last\n filename.split('-').first.to_i\n end",
"def show\n french_scenes = @french_scene.scene.act.play.french_scenes\n french_scenes = french_scenes.sort { |a, b| a.pretty_name <=> b.pretty_name }\n index = french_scenes.index { |fs| fs.id == @french_scene.id }\n\n @next = french_scenes[index + 1]\n if index > 0\n @previous = french_scenes[index-1]\n end\n end",
"def command_next(m, show_keyword)\n show = @shows.find_show(show_keyword) if show_keyword and !show_keyword.strip.empty?\n\n if show\n next_event = @calendar.next_event(show.title)\n else\n next_event = @calendar.next_event\n end\n\n if next_event\n date_string = next_event.start_time.strftime(\"%-m/%-d/%Y\")\n time_string = next_event.start_time.strftime(\"%-I:%M%P\")\n nearest_seconds_until = ((next_event.start_time - DateTime.now) * 24 * 60 * 60).to_i\n if show\n m.user.send \"The next #{next_event.summary} is in #{ChronicDuration.output(nearest_seconds_until, :format => :long)} (#{time_string} on #{date_string})\"\n else \n m.user.send \"Next show is #{next_event.summary} in #{ChronicDuration.output(nearest_seconds_until, :format => :long)} (#{time_string} on #{date_string})\"\n end\n else\n m.user.send \"No upcoming show found for #{show.title}\"\n end\n\n end",
"def index\n @episodes = @season.episodes\n end",
"def show\n @hambrief = Hambrief.find(:first, :conditions => ['episode = ?', params[:id]])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hambrief }\n end\n end",
"def episodes( season )\n return @seasons[season].first.flatten\n end",
"def getEpisodeToPlay(client)\n\n\t\tbegin\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='海外ドラマ' and @id='textView']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='見放題で楽しめる厳選良作!海外ドラマ編']\")\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recyclerView' and ./preceding-sibling::*[./*[@text='見放題で楽しめる厳選良作!海外ドラマ編']]]/*/*/*[@id='imageView' and ./parent::*[@id='maskLayout']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@id='searchButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=国内ドラマ一覧\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=すべての作品\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=見放題\", 0, 1)\n\t\t\t\tclient.sleep(3000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*[@id='thumbnail'])\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\tend\n\t\t\tclient.swipe2(\"Down\", 250, 2000)\n\t\t\tclient.sleep(3000)\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='エピソードを選択']\")\n\t\t\t\tclient.click(\"NATIVE\", \"text=エピソードを選択\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*/*[@id='download_indicator' and ./parent::*[@id='image_container']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(10000)\n\t\t\t\tHistoryPlay.new.playbackCheck(client)\n\t\t\t\tHistoryPlay.new.leavingPlayer(client)\n\t\t\telse\n\t\t\t\tputs \"::MSG:: This contents does not have episode list!!!\"\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Error occurred while episode playing..\" + e.message\n\t\t\t$obj_rtnrs.returnNG\n\t\tend\t\t\n\t\tclient.sleep(2000)\n\tend",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.friendly.find(params[:id])\n end",
"def set_episode\n @episode = Episode.friendly.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n end",
"def set_series\n @episode = Episode.find(params[:id])\n end",
"def init\n update_episodes\n end",
"def show\n @episode = @trabajador.episodes.reload.find_by abierto: true\n @tests = @trabajador.tests\n render layout: \"ficha_trabajador\"\n end",
"def finished_at\n @episodes.last.first_watched\n end",
"def show\n @episode = @series.episodes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @episode }\n end\n end",
"def set_episode\n @episode = Episode.find(params[:id])\n @epis = Episode.find(params[:id])\n end",
"def episode_show_pagination\n\t\tself.class.episode_show_pagination( self, @show )\n\tend",
"def show\n q = params[:q]\n if q.blank?\n @q = Episode.includes(:tags).find(params[:id]).name\n elsif q.match(/^#[0-9]+/)\n @q = q\n @episode = Episode.includes(:tags).order(:release_date).where(\"MATCH (name, description) AGAINST ('#{q}' IN NATURAL LANGUAGE MODE)\")[0]\n \n if @episode.blank?\n render file: \"#{Rails.root}/public/404\", status: :not_found \n else\n redirect_to \"/episodes/#{@episode.id}\"\n end\n else\n @q = q\n redirect_to \"/?q=#{@q}\"\n end\n respond_to do |format|\n format.html {}\n format.json { render json: @episode}\n end\n end",
"def episodes\n Episode.all.select{ |episode| episode.show == self }\n end",
"def show\n if params[:show_id] \n @show = Show.find_by(id: params[:show_id]) || Show.find_by(slug: params[:show_id])\n end\n \n @product = Product.find_by(id: params[:id])\n if (@product.outfits.any?) && (@product.outfits.first.episodes.any?)\n @episode = @product.outfits.first.episodes.first\n @episodenumber = @episode.episode_number\n end\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def watching_episodes\n shows = ::TvShow.watching\n @episodes = episodes.each_with_object([]) do |episode, object|\n show = shows.find{|sh| sh.imdb_id == episode.show.ids.imdb}\n next if show.blank?\n object << episode\n end.uniq{|episode| episode.show.title}\n self\n end",
"def show\n @episode = set_episode\n authorize @episode, :show?\n end",
"def first_movie(films)\n \n return films[0]\nend",
"def load_series! api\n @seasons = 1 # determined later\n @episodes = []\n current_season = 1\n begin\n season_url = url + '/episodes?season=%d' % current_season\n load_season!(api, season_url, current_season)\n current_season+=1\n end until current_season > @seasons\n\n # number all episodes\n num = 1\n @seasons.times do |season|\n sorted_episodes = get_season(season+1).sort_by {|epi| epi.episode}\n sorted_episodes.each do |epi|\n epi.number = num\n num += 1\n #debug '%s S%02dE%02d [%d] -- %s' % [title, epi.season, epi.episode, epi.number, epi.airdate]\n end\n end\n\n # remove pages:\n @episodes.each do |episode|\n episode.page = nil\n end\n\n @series_loaded = true\n end",
"def show\n @episodes = Episode.where(:series_id => @series).order(\"created_at DESC\")\n \n add_breadcrumb \"Mecha Anime\", :series_index_path\n add_breadcrumb \"#{@series.name}\", :series_path\n end",
"def find_shows(page)\n # Looks like it is consistent in the classes it uses\n # so grab what we need\n page.search(\".entry-content-live\").map do |elem|\n dateNode = elem.at(\".artist_date\")\n # convert the date so we can see the year\n date = Date.today\n unless dateNode.nil?\n # it is delimited by '|' and the date is on the first index\n date = Date.parse(dateNode.text.strip.split(\"|\")[0])\n # if its parsed to be before today then in actual the following year\n if date < Date.today\n date = date.next_year()\n end\n end\n # openers are delimited by '|'\n supports = []\n supportsNode = elem.at(\".openers\")\n unless supportsNode.nil?\n supports = supportsNode.text.strip.split(\"|\").map do |support|\n support.strip\n end\n end\n # create the show object\n {\n venue: \"Rock & Roll Hotel\",\n date: date,\n headliner: grab_text(elem, \".artist_title a\", \"\"),\n support: supports\n }\n end\n end",
"def following\n self.new_record? ? nil : Slide.where(:lesson_id => self.lesson_id, :position => (self.position + 1)).first\n end",
"def find_shows(page)\n # Looks like it is consistent in the classes it uses\n # so grab what we need\n page.search(\".show-details\").map do |elem|\n headliners = elem.search(\".headline a\").map do |headliner|\n headliner.text.strip\n end\n # if its empty then its at the Upcoming which we can skip\n next if headliners.empty?\n\n dateNode = elem.at(\".date\")\n # convert the date so we can see the year\n date = Date.today\n if not dateNode.nil? and not dateNode.text.empty?\n date = convert_date(dateNode.text)\n end\n # the supports are in their own nodes!\n support = elem.search(\".support\").map do |sup|\n sup.text.strip\n end\n # create the show object\n {\n venue: \"Black Cat\",\n date: date,\n headliner: headliners.first,\n support: headliners.drop(1) + support\n }\n end\n end",
"def show\n @event = Event.find params[:id]\n @slides = @event.slides.page(params[:page]).per(10)\n end",
"def next\n week = Week.where('number > ? AND setup_id = ?', self.number, self.setup_id).order(number: :asc).first\n week && week.is_visible? ? week : nil\n end",
"def index\n @series = Series.find(params[:series_id].to_i)\n @new_episodes = @series.episodes.where(:seen => false).order(\"season desc, episode desc\")\n @seen_episodes = @series.episodes.where(:seen => true).order(\"season desc, episode desc\")\n end",
"def start_of_first_scene(script)\n script = script.split(\"\\n\") if script.is_a?(String)\n line_index = 0\n loop do\n line = script[line_index]\n break unless line\n break if line =~ /[A-Za-z]/\n line_index += 1\n end\n line_index += 1 if line_index < script.size # And ignore the name of the play\n line_index\n end",
"def show\n session[:slideshow] = @slideshow\n session[:slide_index] = 0\n @slide = @slideshow.slides[0]\n end",
"def show\n @page_title = @recommendation.movie.title\n end",
"def create_episode(title)\n Episode.new(title, self)\n end",
"def show\n puts \"++++++++ star#show\"\n @star = Star.find(params[:id])\n @episodes = @star.episodes\n #@episode = Episode.new\n #@podcasts = Podcast.all #we don't need all the podcasts.\n\n star_query = @star.name.strip.gsub(/\\s+/, \"+\")\n\n #this works, but super innefficient. \n def all_eps(query, offset)\n episodes_arr = []\n results = 10\n num = offset\n\n while results == 10\n\n response = HTTParty.get \"https://listennotes.p.mashape.com/api/v1/search?len_min=10&offset=#{num}&only_in=title&published_after=0&q=#{query}&sort_by_date=0&type=episode\",\n headers:{\n 'X-Mashape-Key' => ENV['MASHAPE_KEY'],\n \"Accept\" => \"application/json\"\n }\n #episodes_arr << response[\"results\"] #adds the current results to the array. Nope..\n response[\"results\"].each { |r| episodes_arr << r}\n num += response[\"count\"].to_i #increases the offset by the number of results that we just found\n \n count = episodes_arr.count\n puts \"There are now #{count} in the array\"\n results = response[\"count\"]\n puts \"The latest lookup has #{results} results in there. \"\n\n end\n return episodes_arr\n end\n\n if @star.last_search == nil\n s = @star\n s.last_search = Date.today - 10.days\n puts s.last_search\n s.save\n end\n\n l = @star.last_search < (Date.today - 2.days)\n puts l \n #works\n\n if l == true \n many_episodes = all_eps(star_query, 0)\n many_episodes.select! do |e| \n limit = Date.today - 3.years\n def comparable_date(f)\n sec = (f[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n end\n comparable_date(e) > limit\n end #holy shit this works! Needs cleanup\n\n #save each episode - works\n many_episodes.each do |ep|\n new_ep = Episode.new\n pod_name = ep[\"podcast_title_original\"]\n pod = Podcast.find_or_create_by(name: pod_name)\n new_ep.star_id = @star.id\n new_ep.podcast_id = pod.id\n new_ep.title = ep[\"title_original\"]\n new_ep.description = ep[\"description_original\"]\n new_ep.api_id = ep[\"id\"]\n sec = (ep[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n new_ep.release_date = dform\n new_ep.save\n end\n\n @episodes_arr = many_episodes.sort_by { |e| e[\"pub_date_ms\"]}.reverse\n @star.last_search = Date.today\n @star.save\n else\n puts \"WE DIDN RUN THE SEARCH\"\n end\n @display_episodes = @episodes.where(display: true)\n end",
"def show\n @episode = Episode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @episode }\n end\n end",
"def show\n @episode = Episode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @episode }\n end\n end",
"def show\n @episode = Episode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @episode }\n end\n end",
"def show\n @story = Story.includes(:comments).find(params[:id])\n @next = ((@story == Story.last) ? Story : Story.where(['id > ?', params[:id]])).where(:aprooved => true).first.id\n @prev = ((@story == Story.first) ? Story : Story.where(['id < ?', params[:id]])).where(:aprooved => true).last.id\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def add_episode_name(show_hash)\n \t@latest_episode_name = show_hash[:latest_episode_name]\n end",
"def thetvdb_missing_last_process(show)\n log_debug\n \n $thetvdb.show(show)\n\n season_last, episode_last = thetvdb_missing_plex_last_ep(show)\n season_first, episode_first = thetvdb_missing_plex_first_ep(show)\n log_debug(\"#{show} start s#{season_first}e#{episode_first} : last s#{season_last}e#{episode_last}\")\n\n if $thetvdb.episodes.has_key?(show)\n $thetvdb.episodes[show]['episodes'].keys.each do |season|\n next if season == \"0\"\n \n $thetvdb.episodes[show]['episodes'][season].keys.each do |episode|\n first_aired = $thetvdb.episodes[show]['episodes'][season][episode]['first_aired']\n show_index = show_index(season, episode)\n plex_has = thetvdb_missing_plex_found(show,season,episode)\n missing = thetvdb_missing_range(season, season_first, episode, episode_first)\n missing = false if plex_has\n \n if first_aired =~ /\\w/\n date_available = Date.today\n date_aired = Date.parse first_aired\n if ( date_available > (date_aired + 1) ) and missing\n missing_process show, show_index,\"aired: #{first_aired}\"\n end\n end\n end\n end\n end\nend",
"def show\n if current_user.has_role? :admin\n else\n session[:paperitem_id] = @paperitem.id\n @paper = @paperitem.paper\n @papertest_ids = @paper.papertests.map{|p|p.id}\n @evaluations = Evaluation.where(practice_id: @paperitem.practice_id, papertest: @papertest_ids).order(id: :desc)\n # 下面生成“上一题”和“下一题”\n all_paperitem_ids = Paperitem.where(paper_id: @paper.id).order(:serial).pluck(:id)\n index = all_paperitem_ids.find_index(@paperitem.id)\n if index - 1 < 0\n\t @previous_paperitem = nil \n\t else\n\t previous_paperitem = all_paperitem_ids[index - 1]\n\t @previous_paperitem = Paperitem.find(previous_paperitem)\n\t end\n\t if index + 1 == all_paperitem_ids.length\n\t @next_paperitem = nil\n\t else\n\t next_paperitem = all_paperitem_ids[index + 1]\n\t @next_paperitem = Paperitem.find(next_paperitem)\n\t end\n end\n end",
"def add_episode_to_podcasts\n \tPodcast.all.each do |podcast|\n show_hash = Scraper.scrape_show_page(podcast.show_page_url)\n \t podcast.add_episode_name(show_hash)\n \tend\n end",
"def show\n if @scene.position > 0\n @previous = Scene.find_by(story_id: @scene.story_id, position: (@scene.position - 1))\n end\n if @scene.position < @scene.story.scenes.length\n @next = Scene.find_by(story_id: @scene.story_id, position: (@scene.position + 1))\n end\n @notable = @scene\n @notes = @notable.notes\n @note = Note.new\n end",
"def watch_current!\n ep = ep(@current_ep).watch!\n @current_ep = next_episode.number\n ep\n end",
"def slide\n slides.first rescue nil\n end",
"def succ\n s = dup\n s.season = next_season_code\n s.year = year + 1 if s.first?\n s\n end",
"def show\n extract_nxt_prv(@article)\n end",
"def show\n @initialPremise = Premise.find(params[:id])\n @nextPremise = @initialPremise.next\n @previousPremise = @initialPremise.previous\n end",
"def description(show_number)\n if valid_show?(show_number)\n doc = Nokogiri::HTML(open(\"#{DOMAIN}/#{@url}/#{show_number}\"))\n\n description = doc.css('div.episode_notes/p').first.text.strip\n return description\n else\n return \"Show #{show_number} not found for #{@title}. Jackals.\"\n end\n end",
"def show\n render json: {episode: @episode, season: @season}\n end",
"def target_path(ep, ext)\n show_dir = @dest_dir + ep.show_name\n season_dirname = \"Season #{ep.season}\"\n epNum = ep.episodes.map { |e| ep.season.to_s + 'x' + e.to_s.rjust(2,'0') }.join('+')\n epTitle = ep.titles.join(' + ')\n \n # Special case if the episode is in 2 parts and the two parts have the same title\n # Like \"XXX (Part 1)\" and \"XXX (Part 2)\", then be a bit more clever for the ep title\n if ep.titles.count == 2 && ep.titles[0].length == ep.titles[1].length\n (t1,t2) = ep.titles\n pos = (0..t1.length-1).find { |i| t1[i] != t2[i] } # Find first differing char\n if t1[pos].chr == '1' && t2[pos].chr == '2' && t1[pos+1..-1] == t2[pos+1..-1]\n # If only differing char is '1' vs '2' (and is the only difference)\n t1[pos] = '1+2' # then use the one of the two titles and replace with '1+2'\n epTitle = t1 # and use as the episode title instead.\n end\n end\n \n target_basename = sanitize(\"#{ep.show_name} - #{epNum} - #{epTitle}\")\n show_dir + season_dirname + (target_basename + ext)\n end"
] |
[
"0.7179375",
"0.68348485",
"0.6698081",
"0.6390671",
"0.6390671",
"0.6390671",
"0.6390671",
"0.6311379",
"0.6061875",
"0.6050348",
"0.6022803",
"0.59962916",
"0.5989896",
"0.5973696",
"0.5932805",
"0.5904213",
"0.57907444",
"0.57901776",
"0.57812834",
"0.57653815",
"0.57273656",
"0.57130146",
"0.57111526",
"0.5675981",
"0.5657142",
"0.56219226",
"0.55991644",
"0.5587011",
"0.55853355",
"0.5574395",
"0.55562586",
"0.5554152",
"0.55503243",
"0.5548149",
"0.55464923",
"0.5545882",
"0.5524382",
"0.5516983",
"0.547301",
"0.5465933",
"0.53909",
"0.53877074",
"0.5387229",
"0.5383086",
"0.5383086",
"0.5383086",
"0.5383086",
"0.5383086",
"0.5383086",
"0.5383086",
"0.5383086",
"0.5383086",
"0.5383086",
"0.53755236",
"0.53755236",
"0.5368202",
"0.5368202",
"0.5366262",
"0.5357678",
"0.53516823",
"0.5336613",
"0.53349006",
"0.53244126",
"0.53202605",
"0.53162724",
"0.529441",
"0.52899563",
"0.5284618",
"0.52700347",
"0.526187",
"0.5237822",
"0.5233725",
"0.52307725",
"0.518652",
"0.51765114",
"0.51763105",
"0.5170443",
"0.51662415",
"0.5149204",
"0.5146588",
"0.51377535",
"0.51313925",
"0.5129193",
"0.51278496",
"0.51278496",
"0.51278496",
"0.5122551",
"0.51175773",
"0.510868",
"0.5108008",
"0.51034343",
"0.50990415",
"0.509617",
"0.5095486",
"0.5093019",
"0.5083612",
"0.506363",
"0.5058343",
"0.505725",
"0.5041275"
] |
0.6759812
|
2
|
remove episodes that are found in plex
|
def thetvdb_missing_plex_found(show,season,episode)
plex_has = false
# remove shows that we have
if $plex.episodes.has_key? show
if $plex.episodes[show].has_key?(season.to_i)
if $plex.episodes[show][season.to_i].has_key?(episode.to_i)
plex_has = true
end
end
end
plex_has
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prune\n @set.clear\n end",
"def summon_removal\n # remove all expired pets\n @pets.clone.each {|p| @pets.delete(p) if p.terminate}\n # remove all expired monsters\n @monsters.clone.each {|m| @monsters.delete(m) if m.terminate}\n end",
"def remove_idea_events(events)\n events.delete_if(&:idea?)\nend",
"def one_week_wonders(songs)\n songs.each_with_index do |el, index|\n if el == songs[index + 1]\n songs.delete(el)\n end\n end\n songs.uniq\nend",
"def rem_dead_tracks playlist\n begin\n\t playlist.fileTracks.each do |track|\n\t #puts \"#{track.index}: #{track.location}\"\n\t next unless track.location == nil \n\t puts \"Deleting dead track: #{track.artist} - #{track.album} - #{track.name}\"\n\t @logger.info \"Deleting dead track: #{track.artist} - #{track.album} - #{track.name}\"\n\t track.delete\n\t end\n\t rescue Exception => e\n puts e.message\n end\n end",
"def delete_orphan_spektrix_events\n @spektrix_event_ids = @spektrix_events.collect {|e| e.id.to_i}\n @rooftop_event_ids = @rooftop_events.inject({}) do |hash, e|\n hash[e.id] = e.meta_attributes[:spektrix_id].to_i\n hash\n end\n @rooftop_event_ids.reject! {|k,v| v == 0} #remove events with no spektrix ID; we don't want to remove them.\n spektrix_ids_to_delete = (@rooftop_event_ids.values - (@rooftop_event_ids.values & @spektrix_event_ids))\n rooftop_ids_to_delete = @rooftop_event_ids.select {|k,v| spektrix_ids_to_delete.include?(v)}.keys\n Rooftop::Events::Event.where(post__in: rooftop_ids_to_delete).each do |rooftop_event|\n title = rooftop_event.title\n if rooftop_event.destroy\n @logger.info(\"[spektrix] Removed Rooftop event #{title} which doesn't exist in Spektrix\")\n end\n end\n end",
"def watching_episodes\n shows = ::TvShow.watching\n @episodes = episodes.each_with_object([]) do |episode, object|\n show = shows.find{|sh| sh.imdb_id == episode.show.ids.imdb}\n next if show.blank?\n object << episode\n end.uniq{|episode| episode.show.title}\n self\n end",
"def prune_question_set(round_id)\n puts 'Entering prune_question_set()'\n round = Round.find(round_id)\n QuestionOccurrence.where(round_id: round_id).where(\"index_in_round > ?\", round.max_qo_index).each{ |qo| qo.destroy; }\n puts 'Exiting prune_question_set()'\n end",
"def destroy\n @episode.destroy\n end",
"def remove_all\n @peer.remove_all\n# @children.each { |child| scene.unindex_prop(child) } if scene\n# @children = []\n end",
"def pbRemovePokemonAt(index)\n return false if index<0 || !$Trainer || index>=$Trainer.party.length\n haveAble = false\n for i in 0...$Trainer.party.length\n next if i==index\n haveAble = true if $Trainer.party[i].hp>0 && !$Trainer.party[i].egg?\n end\n return false if !haveAble\n $Trainer.party.delete_at(index)\n return true\nend",
"def unprepare_mega_evolve(pokemon)\n @mega_evolved_trainer_ids.delete(pokemon.trainer_id)\n @prepared_mega_evolve.delete_if { |cell| cell.first == pokemon }\n end",
"def remove_p_bubbles\n visited = Set.new\n segment_names.each do |sn|\n next if visited.include?(sn)\n if connectivity(sn) == [1,1]\n s1 = neighbours([sn, :B])[0]\n s2 = neighbours([sn, :E])[0]\n n1 = neighbours(s1).sort\n n2 = neighbours(s2).sort\n n1.each {|se| visited << se[0].name}\n if n1 == n2.map{|se| se.invert_end_type}\n remove_proven_p_bubble(s1, s2, n1)\n end\n end\n end\n return self\n end",
"def remove_sport\n 'basketball|baseball|softball|football|womens basketball'\n end",
"def remove(title)\n \t\tfounds = []\n\t\t(@titles.length-1).downto(0).each { |i|\n \t\t\tif @titles[i] == title\n \t\t\t\tfounds.push(i)\n\t\t\tend\n\t\t}\n\n\t\tif founds.length > 0\n\t\t\tfor i in founds\n \t\t\t\t@titleCount -= 1\n\t\t\t\t@titles.delete_at(i)\n\t\t\tend\n\t\tend\n\tend",
"def remove(movie)\n @items.select! do |m| \n m.title != movie.title && \n m.year != movie.year\n end\n\n self.save_to_file()\n puts \"#{movie.title} has been removed from your watchlist.\\n\".green\n end",
"def find_remove(preposistion)\n\t\tremove(find(preposition))\n\tend",
"def remove\n @instantiations.dup.each(&:remove)\n @instantiations[0..-1] = []\n true\n end",
"def remove_except_follower\n events=$PokemonGlobal.dependentEvents\n $PokemonGlobal.dependentEvents.each_with_index do |event,i|\n next if event[8][/FollowerPkmn/]\n events[i] = nil\n @realEvents[i] = nil\n @lastUpdate += 1\n end\n events.compact!\n @realEvents.compact!\n end",
"def delete_pose_index\n self.pose_words.clear if Pose.perform_search?\n end",
"def remove_all_participants\n Hyrax::CollectionTypeParticipant.where(hyrax_collection_type_id: id).all.find_each(&:destroy!)\n end",
"def remove_all_participants\n Hyrax::CollectionTypeParticipant.where(hyrax_collection_type_id: id).all.find_each(&:destroy!)\n end",
"def remove( *ruleses )\n self.dup.remove!( *ruleses )\n end",
"def remove_assignments\n # tas = TagAssignment.find_all_by_source_and_source_info(2, self.id)\n # tas.each do |ta|\n # ta.destroy\n # end\n # tas.count\n\n # this does the same as above with less queries, but doesn't apply\n # any callbacks (none needed in this case)\n TagAssignment.destroy_all(:source => 2, \n :source_info => self.id) if self.has_attribute?('id') \n end",
"def phase1_reduce\n removed_all = []\n\n # 1.3i - remove any that match 1.3i\n @best_proposals.each_with_index do |p,i|\n slice_point = @people_prefs[i].index(p) + 1\n removed_from_i = @people_prefs[i].slice!(slice_point, @people_prefs[i].count)\n removed_all << removed_from_i\n end\n\n # 1.3ii - remove user i from the list of those he had removed above\n removed_all.each_with_index do |list,i|\n list.each do |ignored_user|\n @people_prefs[ignored_user].delete(i)\n end\n end\n\n @people_prefs\n end",
"def free!\n return false if matches.empty?\n match_preference_indexes = matches.map { | match | preferences.index match }\n max = match_preference_indexes.max # The index of the match with the lowest preference\n candidate_to_reject = preferences[ max ]\n\n # Delete from both sides\n candidate_to_reject.matches.delete self\n self.matches.delete candidate_to_reject\n end",
"def cleanup()\n Track.where(scanned: false).delete_all()\n Disc.delete_all(\"id NOT IN (SELECT DISTINCT(disc_id) FROM tracks)\")\n Album.delete_all(\"id NOT IN (SELECT DISTINCT(album_id) FROM tracks)\")\n Artist.delete_all(\"id NOT IN (SELECT DISTINCT(artist_id) FROM tracks)\")\n end",
"def delete_state(state)\n @states.reject! { |_,v| v == state }\n#$stderr.print \"States: #{@states.length} \"\n end",
"def remove_evens!(arr)\n arr.each do |num|\n if num % 2 == 0\n arr.delete(num)\n end\n end\n arr\nend",
"def remove_topping(x)\n @toppings.delete_at(x)\n end",
"def remove_depricated\n self.articles.each do |a|\n unless ((a.created_at + 3.days) > Date.today) \n self.articles.delete(a)\n end\n end\n\tend",
"def remove_orphaned\n\t\tTaskTag.where([\n\t\t\t\"task_id NOT IN (?) OR task_id NOT IN (?)\",\n\t\t\tTask.pluck(\"id\"),\n\t\t\tTag.pluck(\"id\")\n\t\t]).destroy_all\n\tend",
"def prune(items)\n wants = []\n # owners = []\n items.each do |item|\n # owners << item.user\n item.user.wants.each do |want|\n if want.possession.trade_id == self.id\n wants << want.possession\n end\n end\n end\n # wants = []\n # owners.each do |owner|\n # owner.wants.each do |want|\n # if want.possession.trade_id == self.id\n # wants << want.possession\n # end\n # end\n # end\n items.each do |item|\n if !wants.include?(item)\n items.delete(item)\n end\n end\n items\n end",
"def remove_intermediate(station_name)\n self.stations.delete_if { |s| s.name == station_name && stations.index(s) != 0 && stations.index(s) != stations.size - 1 }\n end",
"def prune_subjects(subject_id_array)\n subject_id_array.each do |subject_id|\n found_subject = Subject.find(subject_id)\n if (found_subject and SubjectTeacherSet.where(subject_id: subject_id).empty?)\n found_subject.destroy\n end\n end\n end",
"def clear\n @excluded = Set.new\n end",
"def prune_duplicate_patterns(song)\n pattern_replacements = determine_pattern_replacements(song.patterns)\n\n # Update flow to remove references to duplicates\n new_flow = song.flow\n pattern_replacements.each do |duplicate, replacement|\n new_flow = new_flow.map do |pattern_name|\n (pattern_name == duplicate) ? replacement : pattern_name\n end\n end\n song.flow = new_flow\n\n # This isn't strictly necessary, but makes resulting songs easier to read for debugging purposes.\n song.remove_unused_patterns\n\n song\n end",
"def remove_from_all_dil_collections\r\n self.collections.each do |collection|\r\n collection.members.remove_member_by_pid( self.pid )\r\n collection.save\r\n self.collections.delete(collection)\r\n end\r\n end",
"def delete_appointments\n @appointments = Appointment.my_appointment.where(self.pupil_id)\n @appointments.destroy_all\n end",
"def remove!\n self.results.each{ |r| r.remove! }\n self.metadata.remove!\n end",
"def remove_all\n @sequence.remove_all\n end",
"def prune_unwatched_repos\n gitchen_ids, github_ids = watchings.map(&:id), github_watched.map(&:id)\n\n sidekiq_logger.info { \"[#{username}] Pruning watched repos...\" }\n\n (pruned = watchings.find(gitchen_ids - github_ids)).each do |repo|\n sidekiq_logger.info { \"[#{username}] stopped watching #{repo}\" }\n end\n\n watchings.delete pruned\n\n sidekiq_logger.info { \"[#{username}] Completed pruning watched repos\" }\n end",
"def strip_excess_words(content_player_id)\n\t\tself.played_words.each do |value|\n\t\t\tif value.t != self.t - 1 \n\t\t\t\tvalue.t_l.clear \n\t\t\tend\n\t\tend\t\n\tend",
"def remove_weekly_alerts_if_genre_all_edit \n WeeklyAlert.destroy_all([\"id != ? AND user_id = ?\" , id, user_id]) if Genre.find(genre_id).name == \"all\"\n end",
"def remove_duplicates(movies)\n # Iterate through the list and remove any duplicates -- they should be right next to each other\n i = 0\n while i < (movies.length - 1)\n if compare_movies(movies[i], movies[i+1]) == 0\n movies.delete_at i\n else\n i += 1\n end\n end\n\n # Lastly, return the subset of movies\n movies\nend",
"def remove_pet_by_name(animal, past_animal)\n for pet in animal[:pets]\n if pet[:name] == past_animal\n return animal[:pets].delete(pet)\n end\n end\nend",
"def destroy\n @episode.destroy\n\n head :no_content\n end",
"def one_week_wonders(songs)\n one_week_wonders = songs.select {|el| no_repeats?(el, songs)}\n one_week_wonders.uniq\nend",
"def remove_odd list\n # list.delete_if &:odd?\n list.delete_if {|x| x.odd?}\nend",
"def destroy\n @trabajador = Trabajador.find(params[:trabajador_id])\n @episode = @trabajador.episodes.find(params[:id])\n @episode.destroy\n redirect_to trabajador_path(@trabajador)\n\n\n end",
"def eraseOldTopStoryEntries\n for i in 0...TopStory.count-1\n TopStory.first.destroy\n end\n end",
"def episodes\n Episode.all.select{ |episode| episode.show == self }\n end",
"def remove_illegitimate_children\n puts \"Destroying illegitimate children of response #{id}: #{text}\" if illegitimate_children.length > 1\n illegitimate_children.select {|q| q != child_question }.each do |q|\n puts \" Destroying illegitimate child question #{q.id}: #{q.text}\"\n q.destroy\n end\n end",
"def poolplay_team_objects\n self.teams.select { |team| !team.playoffs }\n end",
"def remove_evens!(arr)\n cloned_arr = arr.dup\n cloned_arr.each do |num|\n if num % 2 == 0\n arr.delete(num)\n end\n end\n arr\nend",
"def remove_existing_questionnaire(rubrics_list, aq)\n return if aq.questionnaire_id.nil?\n\n rubrics_list.reject! do |rubric|\n rubric == Questionnaire.where(id: aq.questionnaire_id).first.type.to_s\n end\n end",
"def prune(sexp)\n if sexp.nil?\n nil\n elsif !list?(sexp)\n sexp\n elsif sexp.empty?\n []\n elsif sexp.first == :iter && (sexp[2].nil? || sexp[2] && ANAPHOR_PARAMETERS[sexp[2].to_a])\n r = sexp[0..-2].map { |inner| prune(inner) }\n else\n sexp.map { |inner| prune(inner) }\n end\n end",
"def remove_player p\n (@players ||= []).delete p.sym\n end",
"def remove_unwanted_duplicates word_pairs\n all_sequences = word_pairs.map{ |pair| pair.first }\n\n duplicate_seqs = identify_duplicate_sequences all_sequences\n\n word_pairs.reject do |seq, original|\n duplicate_seqs.include? seq\n end\n end",
"def destroy\n @episode = Episode.find(params[:id])\n movie = @episode.movie\n flash[:notice] = \"剧集#{@episode.title} 已经被删除\"\n \n @episode.destroy\n\n respond_to do |format|\n format.html { redirect_to movie_url(movie) }\n format.json { head :no_content }\n end\n end",
"def clean_temp_evs_helper\n @spawned_event_ids.each{|id| @events.delete(id) unless @events[id].persistent}\n @spawned_event_ids = []\n end",
"def remove_old_answers\n if self.valid?\n self.choice_questions.includes(:choice_answers).each {|x| x.choice_answers.each(&:destroy)}\n end\n end",
"def remove_pet_by_name (pet_shop, pet_name)\n for pet in pet_shop[:pets]\n if pet_name == pet[:name]\n pet[:name].delete!(pet_name)\n end\n end\nend",
"def sell_pets \n self.dogs.each do |dog|\n dog.owner = nil\n dog.mood = \"nervous\"\n self.dogs.delete(dog)\n end \n self.cats.each do |cat|\n cat.owner = nil\n cat.mood = \"nervous\"\n self.cats.delete(cat)\n end\n end",
"def my_array_deletion_method!(source, thing_to_delete)\r\n words_to_delete = source.find_all { |f| f.to_s.include?(thing_to_delete)}\r\n words_to_delete.each do |word|\r\n source.delete(word)\r\n end\r\n p source\r\nend",
"def find_dead_tracks playlist\n playlist.fileTracks.each do |track|\n next unless track.location == nil\n puts \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n @logger.info \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n #@dead_track_list << track\n end\n \n #return @dead_track_list\n end",
"def wipe_leading_adjective\n @leading_adjective = nil\n end",
"def remove_future_registrations\n self.registrations.select{|r| r.camp.start_date >= Date.current}.each{|r| r.destroy}\n end",
"def one_week_wonders(songs)\n songs.select{ |song| no_repeats?(song, songs)}.uniq\nend",
"def prune_ignored!\n ignored = []\n\n results.each do |result|\n if Config.ignore?(result.name) && !prompt(\"#{result.name} is ignored. Process anyway\")\n warn(\"skipping #{result.name}...\")\n ignored << result\n end\n end\n\n ignored.each { |i| results.delete(i) }\n end",
"def tags_to_remove\n aws_tags.reject { |t, v| local_tags.include?(t) and local_tags[t] == v }\n end",
"def remove_evens!(arr)\n cloned_arr = arr.dup\n arr.each do |num|\n if num % 2 == 0\n cloned_arr.delete(num)\n end\n end\n cloned_arr\nend",
"def remove_all_vlans\n remove_all_bridge_domains\n remove_all_svis\n Vlan.vlans.each do |vlan, obj|\n # skip reserved vlan\n next if vlan == '1'\n next if node.product_id[/N5K|N6K|N7K/] && (1002..1005).include?(vlan.to_i)\n obj.destroy\n end\n end",
"def remove_pet(pet_name)\n index_position = 0\n @pet_arr.each do |animal|\n if pet_name == animal.name_str\n index_position = @pet_arr.index(animal)\n end\n end\n @pet_arr.delete_at(index_position)\n end",
"def find_unseen\n unseen.replace(full_deck)\n (my_hand + op_hand + my_lands.values +\n op_lands.values + discards.values).flatten.each do |c|\n i = unseen.index(c) or next\n unseen.delete_at(i)\n end\n end",
"def remove(*song)\n\t\tsong.each do |num|\n\t\t\tif @contents.include?(num) == false #order matters here or else you get statement due to delete destructiveness\n\t\t\t\tputs \"You don't have this song in your playlist to delete.\"\n\t\t\tend\n\t\t\tif @contents.include?(num)\n\t\t\t\t@num_of_tracks -= 1\n\t\t\t\t@contents.delete(num)\n\t\t\tend\n\t\tend\n\tend",
"def prune\r\n NavContentsLens.new @nav, @objs.uniq\r\n end",
"def remove_to_the_fleet(a_ship)\n \tships.reject! { |ship| ship == a_ship }\n end",
"def trim(leaderboard, spectrum, n)\n lb_map = {}\n leaderboard.each do |peptide|\n linear_score = cyclopeptide_scoring_linear(peptide, spectrum)\n lb_map[peptide] = linear_score\n end\n sorted = lb_map.sort_by {|k,v| v}.reverse\n #puts sorted.join(\" \")\n for j in n..leaderboard.size-1\n if sorted[j][1] < sorted[n-1][1]\n #puts \"deleting #{sorted[j][0]}\"\n leaderboard.delete(sorted[j][0])\n end \n end\n leaderboard\nend",
"def removeSuccesses!\n @pages.reject! { |page, entries| entries.length == 0 }\n end",
"def unlinked\n reject(&:linked?)\n end",
"def remove(x)\n if include?(x)\n ind = @indices[x]\n ind2 = @content.size - 1\n swap(ind,ind2) # do this to ensure constant time\n removeEnd\n end\n end",
"def mark_progresses_for_removal\n self.progresses.each do |p|\n if p.due_date.blank? && p.accuracy.to_i <= 0\n p.mark_for_destruction\n end\n end\n end",
"def alive_players\n @players.reject{|p| p.dead? }\n end",
"def spots_to_remove\n Spot.outdated\n end",
"def remove_pet_by_name(pet_shop, pet_name)\n\n pet_array = pet_shop[:pets]\n pet_to_delete = find_pet_by_name(pet_shop, pet_name)\n pet_array.delete(pet_to_delete)\n\nend",
"def remove_genomes_by_prot_id!(prot_ids)\n prot_ids.map{ |i| @genomes.delete(i) }.flatten.compact\n end",
"def get_all_free_episode_links_for_each_show_on_vland\n \t\tShow.all.each do |show|\n \t\t\tputs \"getting epsides for #{show.url}\"\n \t\t\t# sometimes its nice to take a 2-3 sec nap\n \t\t\tsleep(rand(2..3))\n \t\t\tresp = get_resp(show.url)\n \t\t\t# this is the point where I got tired of heavy lifting\n \t\t\thtml_result = Nokogiri::HTML.parse(resp.body)\n \t\t\thtml_result.css(\".entry-card\").each do |clip|\n \t\t\t\t# skip episdes / clips that are not free to watch, may also one day limit it to just episodes.\n \t\t\t\tnext if clip.css(\".unlockable\").first.to_s.include? \"icon-locked\"\n \t\t\t\t# grabs sub link to epsides or clip\n \t\t\t\tepisode_or_clip_url = clip.css(\".cta\").attr(\"href\").to_s\n \t\t\t\t#getting rid of a \"/\" at the start\n \t\t\t\tepisode_or_clip_url[0] = \"\"\n\n \t\t\t\t# lets create some links pertaining to shows and clips from shows\n \t\t\t\tep = Episode.find_or_initialize_by(url: self.url + episode_or_clip_url)\n \t\t\t\tif ep.new_record?\n \t\t\t\t\tep.show_id=show.id\n \t\t\t\t\t#can do fancy stuff here like grab all show episode / clip fields \n \t\t\t\t\tep.save!\n \t\t\t\tend\n \t\t\tend\n \t\tend\n \tend",
"def watch_movie (array)\n array.delete(\"Minions\")\n array\nend",
"def clean()\n rels = releases()\n rels.pop()\n\n unless rels.empty?\n rm = ['rm', '-rf'].concat(rels.map {|r| release_dir(r)})\n rm << release_dir('skip-*')\n cmd.ssh(rm)\n end\n end",
"def ditch_crap(clean_items)\n clean_items.delete_if do |item|\n if !!(item[\"title\"].match(/proxy/i)) || !!(item[\"title\"].match(/altered/i))\n true\n end\n end\n clean_items\n end",
"def sell_pets\n#this makes them all nervous\n pets.each do |species, animals|\n animals.each do |animal|\n animal.mood = \"nervous\"\n end\n animals.clear\n end\n end",
"def remove_pet_by_name(pet_shop, pet_name)\n for pet in pet_shop[:pets]\n pet_shop[:pets].delete(pet) if pet[:name] == pet_name\n end\nend",
"def remove_pet_by_name(pet_shop, name)\n for pet in pet_shop[:pets]\n if pet[:name] == name\n p pet_shop[:pets].delete(pet)\n end\n end\nend",
"def remove_errant_matches_from(pot_ex_array)\n correct_match_arr = []\n pot_ex_array.each do |example|\n constituents = example.construct_constituents_array\n constituents.each do |const_array|\n if const_array[0] == self.word && const_array[1] == self.hiragana && const_array[3] == self.reading # For this to work, the constituents have to be normalized to dictionary_forms.\n correct_match_arr << example\n end\n end\n end\n return correct_match_arr\n end",
"def orphaned_design_checks\n \n log = []\n \n total_design_checks = self.design_checks.size\n self.trim_checklist_for_design_type\n self.get_design_checks\n \n completed_check_counts = self.completed_check_count\n \n attached_design_checks = []\n self.checklist.each_check { |ch| attached_design_checks << ch.design_check }\n\n directory_name = self.design.directory_name\n \n orphaned_design_checks = self.design_checks - attached_design_checks\n \n if orphaned_design_checks.size > 0\n \n self.designer_completed_checks = completed_check_counts[:self]\n self.auditor_completed_checks = completed_check_counts[:peer]\n self.save\n \n log << \" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\"\n log << \" REMOVING INAPPROPRIATE DESIGN CHECKS\"\n log << \" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\"\n\n orphaned_design_checks.each do |dc|\n check = Check.find(dc.check_id)\n \n log << \"\"\n log << \" DESIGN CHECK ID: \" + dc.id.to_s\n log << \" CHECK ID: \" + dc.check_id.to_s\n log << \" SELF CHECKED: \" + dc.self_auditor_checked?.to_s\n log << \" PEER CHECKED: \" + dc.peer_auditor_checked?.to_s\n log << \" NEW REVIEW: \" + check.full_review?.to_s\n log << \" BB REVIEW: \" + check.dot_rev_check?.to_s\n \n dc.destroy \n \n design_check_list = DesignCheck.find(:all, :conditions => \"audit_id=#{self.id} AND check_id=#{dc.check_id}\")\n if design_check_list.size > 1\n log << \"\"\n log << \" **********************************************\"\n log << \" **********************************************\"\n log << \" ***** WARNING: FOUND MULTIPLE DESIGN CHECKS!!!\"\n log << \" **********************************************\"\n log << \" **********************************************\"\n log << \"\"\n end\n end\n end\n \n log\n \n end",
"def remove_duplicates()\n self.duplicate_transactions_by_actor().each do |a, txns|\n # Spaceship operator, if my actor is of greater value than theirs, skip because they should remove the dupe\n next if (self.actor <=> a) == 1\n txns.each do |txn|\n self.counts[self.actor][\"txns\"].delete(txn)\n end\n end\n end",
"def parts_with_order_remove part\n self.parts_with_order = self.parts_with_order.reject{|master_file| master_file.pid == part.pid }\n end",
"def fix_names(shows)\n\t\t\t# Ignored shows\n\t\t\ts = shows.reject do |i|\n\t\t\t\t# Remove season+episode\n\t\t\t\t@config[:ignored].include?(i.split(\" \")[0..-2].join(\" \").downcase)\n\t\t\tend\n\n\t\t\ts.map { |i| i.gsub(/ \\(.+\\)|[':]/, \"\") }\n\t\tend",
"def orphan_tasks\n each_task.reject do |task|\n task.dependency_backward_any? or task.dependency_forward_any?\n end\n end"
] |
[
"0.5777581",
"0.57602966",
"0.5732618",
"0.5636568",
"0.55728316",
"0.549267",
"0.54691",
"0.5452294",
"0.54078877",
"0.5385365",
"0.53606415",
"0.5344986",
"0.53356004",
"0.5295978",
"0.5294535",
"0.5268267",
"0.5239667",
"0.52054423",
"0.5203759",
"0.52014816",
"0.52011436",
"0.52011436",
"0.5195696",
"0.51650196",
"0.5142871",
"0.51127416",
"0.51103824",
"0.5097239",
"0.5056726",
"0.50563407",
"0.5050421",
"0.50446796",
"0.5042497",
"0.5030477",
"0.50282484",
"0.50256383",
"0.5020015",
"0.50182223",
"0.50172216",
"0.50160474",
"0.49873495",
"0.49852797",
"0.49640086",
"0.4961215",
"0.49403444",
"0.4940177",
"0.49252182",
"0.48995262",
"0.48908797",
"0.48871884",
"0.4878445",
"0.48777753",
"0.48770067",
"0.48723528",
"0.48701572",
"0.4868714",
"0.4868399",
"0.48637605",
"0.48607025",
"0.48592147",
"0.48586243",
"0.4855179",
"0.4854962",
"0.48535335",
"0.48528138",
"0.48525658",
"0.4850315",
"0.4850189",
"0.48384687",
"0.4835016",
"0.4834468",
"0.48296618",
"0.4818333",
"0.48169455",
"0.481622",
"0.48150992",
"0.48142254",
"0.48114967",
"0.47966883",
"0.4793774",
"0.4790355",
"0.47812206",
"0.4780932",
"0.47797218",
"0.47788864",
"0.4775494",
"0.4775386",
"0.47671357",
"0.47667694",
"0.47663411",
"0.4761274",
"0.47610837",
"0.4760257",
"0.4759792",
"0.4759593",
"0.47595266",
"0.4756731",
"0.47531563",
"0.4749563",
"0.47488737"
] |
0.5839707
|
0
|
handle the range of where we loop up to for episodes
|
def thetvdb_missing_range(season, season_first, episode, episode_first)
missing = true
# for now we are only interested in episodes greater than our first one and
# inclusive of the whole season
if season.to_i < season_first.to_i
missing = false
end
if $config["missing"]["start_at_first_found"]
if episode_first.to_i > episode.to_i
missing = false
end
end
missing
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def episode; end",
"def episode; end",
"def episode; end",
"def episode; end",
"def next_episodes(show, name, id)\n db_show = TvShows.where(:user => session[:username]).where(:name => name).first\n\n if !db_show.nil?\n last_season = TvShows.where(:user => session[:username]).where(:name => name).first.season\n last_episode = TvShows.where(:user => session[:username]).where(:name => name).first.episode\n else\n last_season = 1\n last_episode = 1\n end\n\n current_season = Tmdb::Season.detail(id, last_season)\n if !current_season['episodes'].nil?\n episodes = current_season['episodes'][last_episode.to_i, current_season['episodes'].length]\n\n number_of_seasons = show['number_of_seasons']\n ((last_season.to_i + 1)..number_of_seasons.to_i).each do |season_number|\n season = Tmdb::Season.detail(id, season_number)\n new_episodes = season['episodes'][0, season['episodes'].length]\n episodes.concat(new_episodes)\n end\n episodes\n else\n nil\n end\n end",
"def backtrack(input_elist)\n\n\t\telist = Marshal.load(Marshal.dump(input_elist))\n\n\t\t# sort events based on slack\n\t\telist.sort! do |event1, event2|\n\t\t\tget_slack(event1) <=> get_slack(event2)\n\t\tend\n\t\t\n\t\t# find next event to assign (the one with the least slack) and remove from event list\n\t\tcurr_event = elist.delete_at(0)\n\n\t\t# make array of all possible start times for current event\n\t\tstart_vals = []\n\t\tcurr_event.times.each do |t|\n\t\t\tfor i in t[0]..(t[1]-curr_event.length)\n\t\t\t\tstart_vals.push(i)\n\t\t\tend\n\t\tend\n\t\tputs \"starting #{curr_event.name}, all times: #{curr_event.times}\"\n\t\t# try each assigning each possible value until one works\n\t\tstart_vals.each do |v1|\n\t\t\tv2 = v1+curr_event.length\n\t\t\tcurr_event.times=([[v1,v2]])\n\n\t\t\t# uses 1 room for the chosen time value\n\t\t\t# make an array containing every room that is available for the entire chosen time bracket\n\t\t\tintersect = @availability[v1]\n\t\t\tfor i in (v1+1)...v2\n\t\t\t\tintersect = intersect & @availability[i]\n\t\t\tend\n\t\t\tputs \"looking for room for #{curr_event.name} from #{v1} to #{v2}. Available: #{intersect}\"\n\t\t\t#puts \"available times for next event: #{elist[0].times}\"\n\t\t\t# assign curr_event to the first room in the array of available rooms\n\t\t\tunless intersect.empty?\n\t\t\t\t# variable to store name of room; used later if chosen time value fails\n\t\t\t\tcurr_room = intersect[0]\n\n\t\t\t\t@roomhash[curr_room].push(curr_event)\n\n\t\t\t\t# this room becomes unavailable for every hour in the chosen time bracket\n\t\t\t\tfor i in v1...v2\n\t\t\t\t\t@availability[i].delete(curr_room)\n\t\t\t\tend\n\n\t\t\t\tputs \"trying #{curr_event.name} from #{v1} to #{v2} in #{curr_room}\"\n\t\t\telse\n\t\t\t\t# no available room; skip the rest of this iteration of the loop\n\t\t\t\tnext\n\t\t\tend\n\t\t\t\n\t\t\t# base case - have assigned values to every event from original list\n\t\t\tif elist.empty?\n\t\t\t\treturn [curr_event]\n\t\t\tend\n\t\t\t\n\t\t\t# store current state of events list, to revert back to later if this path fails\n\t\t\ttemp_elist = Marshal.load(Marshal.dump(elist))\n\n\t\t\t# check for host conflicts - a host can't be at 2 events at the same time\n\t\t\telist.each do |e|\n\t\t\t\tcurr_event.hosts.each do |h|\n\t\t\t\t\t# for each event, if it shares a host with curr_event\n\t\t\t\t\tif e.hosts.include?(h)\n\t\t\t\t\t\ttrim_times(e,v1,v2)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\t# re-sort & check slack; if any events have a negative amount of slack, this time assignment doesn't work\n\t\t\telist.sort! do |event1, event2|\n\t\t\t\tget_slack(event1) <=> get_slack(event2)\n\t\t\tend\n\t\t\t\n\t\t\tif get_slack(elist[0]) >= 0\n\n\t\t\t\t# this time assignment works; recursively call backtrack algorithm to assign a time to the next event in the list\n\t\t\t\tresult = backtrack(elist)\n\t\t\t\treturn result + [curr_event] unless result==\"fail\"\n\t\t\tend\n\t\t\t\n\t\t\t# didn't return success in if statements; remove v from potential start times,\n\t\t\t# remove curr_event from room hash, reset room availability, un-trim altered times\n\t\t\t# for i in v1..v2\n\t\t\t# \t@availability[i] += 1\n\t\t\t# end\n\t\t\tfor i in v1...v2\n\t\t\t\t@availability[i].push(curr_room)\n\t\t\tend\n\t\t\troomhash[curr_room].delete(curr_event)\n\t\t\telist = Marshal.load(Marshal.dump(temp_elist))\n\t\tend\n\n\t\t# went through all recursive calls without returning a success\n\t\tputs \"returning fail on #{curr_event.name}\"\n\t\treturn \"fail\"\n\tend",
"def next_episode\n # Not ep(@current_ep + 1) because episodes are not guaranteed to be in\n # sequence (i.e. we could have episodes 1, 2, 4, 5 etc.)\n idx = @episodes.map(&:number).index(@current_ep)\n if idx + 1 < @episodes.size\n @episodes[idx + 1]\n else\n ep(@current_ep)\n end\n end",
"def get_all_free_episode_links_for_each_show_on_vland\n \t\tShow.all.each do |show|\n \t\t\tputs \"getting epsides for #{show.url}\"\n \t\t\t# sometimes its nice to take a 2-3 sec nap\n \t\t\tsleep(rand(2..3))\n \t\t\tresp = get_resp(show.url)\n \t\t\t# this is the point where I got tired of heavy lifting\n \t\t\thtml_result = Nokogiri::HTML.parse(resp.body)\n \t\t\thtml_result.css(\".entry-card\").each do |clip|\n \t\t\t\t# skip episdes / clips that are not free to watch, may also one day limit it to just episodes.\n \t\t\t\tnext if clip.css(\".unlockable\").first.to_s.include? \"icon-locked\"\n \t\t\t\t# grabs sub link to epsides or clip\n \t\t\t\tepisode_or_clip_url = clip.css(\".cta\").attr(\"href\").to_s\n \t\t\t\t#getting rid of a \"/\" at the start\n \t\t\t\tepisode_or_clip_url[0] = \"\"\n\n \t\t\t\t# lets create some links pertaining to shows and clips from shows\n \t\t\t\tep = Episode.find_or_initialize_by(url: self.url + episode_or_clip_url)\n \t\t\t\tif ep.new_record?\n \t\t\t\t\tep.show_id=show.id\n \t\t\t\t\t#can do fancy stuff here like grab all show episode / clip fields \n \t\t\t\t\tep.save!\n \t\t\t\tend\n \t\t\tend\n \t\tend\n \tend",
"def all_eps(query, offset)\n episodes_arr = []\n results = 10\n num = offset\n\n while results == 10\n\n response = HTTParty.get \"https://listennotes.p.mashape.com/api/v1/search?len_min=10&offset=#{num}&only_in=title&published_after=0&q=#{query}&sort_by_date=0&type=episode\",\n headers:{\n 'X-Mashape-Key' => ENV['MASHAPE_KEY'],\n \"Accept\" => \"application/json\"\n }\n #episodes_arr << response[\"results\"] #adds the current results to the array. Nope..\n response[\"results\"].each { |r| episodes_arr << r}\n num += response[\"count\"].to_i #increases the offset by the number of results that we just found\n \n count = episodes_arr.count\n puts \"There are now #{count} in the array\"\n results = response[\"count\"]\n puts \"The latest lookup has #{results} results in there. \"\n\n end\n return episodes_arr\n end",
"def latest_episode(index=0)\n latest_ep = nil\n\n\n# self.live_episodes.each do |ep|\n## puts \"#{__FILE__}:#{__LINE__} #{__method__} #{ep.release_date_unix} - #{ep.name}\"\n# latest_ep = ep if latest_ep == nil\n# latest_ep = ep if latest_ep.release_date_unix.to_i < ep.release_date_unix.to_i\n# end\n self.released_episodes.each_with_index do |ep, idx|\n latest_ep = ep if idx == index\n end\n\n sd = ShowDate.new(latest_ep.release_date_unix.to_i) if latest_ep\n sd = ShowDate.new(Time.new.to_i) unless latest_ep\n\n# puts \"#{__FILE__}:#{__LINE__} #{__method__} SD: #{sd.timestamp} - #{self.name} - #{sd.inspect} - #{sd.month_str}, #{sd.day_of_month} ,#{sd.year}\"\n\n sd\n end",
"def thetvdb_missing_last_process(show)\n log_debug\n \n $thetvdb.show(show)\n\n season_last, episode_last = thetvdb_missing_plex_last_ep(show)\n season_first, episode_first = thetvdb_missing_plex_first_ep(show)\n log_debug(\"#{show} start s#{season_first}e#{episode_first} : last s#{season_last}e#{episode_last}\")\n\n if $thetvdb.episodes.has_key?(show)\n $thetvdb.episodes[show]['episodes'].keys.each do |season|\n next if season == \"0\"\n \n $thetvdb.episodes[show]['episodes'][season].keys.each do |episode|\n first_aired = $thetvdb.episodes[show]['episodes'][season][episode]['first_aired']\n show_index = show_index(season, episode)\n plex_has = thetvdb_missing_plex_found(show,season,episode)\n missing = thetvdb_missing_range(season, season_first, episode, episode_first)\n missing = false if plex_has\n \n if first_aired =~ /\\w/\n date_available = Date.today\n date_aired = Date.parse first_aired\n if ( date_available > (date_aired + 1) ) and missing\n missing_process show, show_index,\"aired: #{first_aired}\"\n end\n end\n end\n end\n end\nend",
"def each(&block)\n @episodes.each(&block)\n end",
"def handle_series(episode)\n tvdb_result = series_lookup(episode) if ($opt[\"tvdb\"]) && (! @tvdb_episodes.has_key?(episode.show))\n if tvdb_result == false\n handle_error(\"failed to find tvshow \\'#{episode.show}\\' from tvdb, skipping..\") if $opt[\"debug\"]\n return false\n end\n re_cache = episode.fix_via_tvdb @tvdb_episodes if $opt[\"tvdb\"] and @tvdb_episodes.has_key?(episode.show)\n\n # we do one round of re-caching only if the episode name is not found\n if re_cache\n log(\"re-caching from tvdb\")\n $opt[\"tvdb-refresh\"] = true\n @tvdb_episodes = {}\n tvdb_result = series_lookup(episode) if ($opt[\"tvdb\"]) && (! @tvdb_episodes.has_key?(episode.show))\n if tvdb_result == false\n handle_error(\"failed to find tvshow \\'#{episode.show}\\' from tvdb, skipping..\")\n return false\n end\n episode.fix_via_tvdb @tvdb_episodes if $opt[\"tvdb\"] and @tvdb_episodes.has_key?(episode.show)\n end\n \n # FIXME: temporay way to handle new destination folder\n target_directory_original = @tvdir\n if $show_storage.has_key? episode.show\n @tvdir = $show_storage[episode.show]\n end\n \n season_pre = \"season.\"\n season_pre = $config[\"settings\"][\"season_dir_prepend\"] if $config[\"settings\"].has_key? \"season_dir_prepend\"\n season = \"#{season_pre}#{episode.season}\"\n season = \"specials\" if episode.season == \"0\"\n target = \"#{@tvdir}/#{episode.show_on_fs}/#{season}\" \n target = \"#{@tvdir}\" if $opt[\"dst_no_hierarchy\"]\n\n move_file(episode.original_file,target)\n @tvdir = target_directory_original\nend",
"def loop; end",
"def loop\n end",
"def loop\n end",
"def play\n t0_setup\n row_to_find\n\n for @it in 1..12\n unless @over == true\n iterate_and_check\n big_input_array\n big_result_array\n plot_game\n defeat\n end\n end\n\n end",
"def sheetlisten()\n n=0.5\n i=0\n while i<@songstr.length-1\n case @songstr[i]\n when 'a' \n play :a\n when 'b' \n play :b\n when 'c' \n play :c\n when 'd' \n play :d\n when 'e' \n play :e\n when 'f' \n play :f\n when 'g' \n play :g\n else\n if(!is_numeric?(@songstr[i]))\n puts(\"invalid char\")\n end\n end\n if(!is_numeric?(@songstr[i+1]))\n sleep 0.5\n else\n case @songstr[i+1]\n when '2' \n #for halfnote at regular speed: sleep 1\n n=1\n when '8' \n #for eighth\n n=0.25\n when '6' \n #for sixteenth note\n n=0.125\n end\n sleep n\n i+=1\n end\n i+=1\n end\n end",
"def getEpisodeToPlay(client)\n\n\t\tbegin\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='海外ドラマ' and @id='textView']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='見放題で楽しめる厳選良作!海外ドラマ編']\")\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recyclerView' and ./preceding-sibling::*[./*[@text='見放題で楽しめる厳選良作!海外ドラマ編']]]/*/*/*[@id='imageView' and ./parent::*[@id='maskLayout']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@id='searchButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=国内ドラマ一覧\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=すべての作品\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=見放題\", 0, 1)\n\t\t\t\tclient.sleep(3000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*[@id='thumbnail'])\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\tend\n\t\t\tclient.swipe2(\"Down\", 250, 2000)\n\t\t\tclient.sleep(3000)\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='エピソードを選択']\")\n\t\t\t\tclient.click(\"NATIVE\", \"text=エピソードを選択\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*/*[@id='download_indicator' and ./parent::*[@id='image_container']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(10000)\n\t\t\t\tHistoryPlay.new.playbackCheck(client)\n\t\t\t\tHistoryPlay.new.leavingPlayer(client)\n\t\t\telse\n\t\t\t\tputs \"::MSG:: This contents does not have episode list!!!\"\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Error occurred while episode playing..\" + e.message\n\t\t\t$obj_rtnrs.returnNG\n\t\tend\t\t\n\t\tclient.sleep(2000)\n\tend",
"def process_paused_offers\n asana = AsanaCommunicator.new\n Offer.where(aasm_state: 'paused').find_each do |paused_offer|\n if (Time.zone.now + 30.days).to_date == paused_offer.starts_at.to_date\n asana.create_seasonal_offer_ready_for_checkup_task paused_offer\n end\n end\n end",
"def loop\n end",
"def dynamic_range \n\t\tpage\n\t\tframes\n\t\tnum = 0\n\t\twhile num < 4 \n\t\t\tif page == frames[num] \n\t\t\t\t@destination = frames[num] \n\t\t\tend \n\t\t\tnum += 1 \n\t\tend\n\tend",
"def maybe_pause_evolution\n\n end",
"def post_loop; end",
"def episode(*args)\n if args.first.is_a? String\n episode_by_title *args\n else\n episode_by_numbers *args\n end\n end",
"def do_event\n=begin\n\n event = Events.new(@resources[:luck])\n # starts an event\n event.start\n decision = gets.chomp\n\n until event.accepts? decision # Requires valid input\n UiHandler.print_error(event.valid_range)\n decision = gets.chomp\n end\n\n # event.dispatch accepts player decision and affects the world\n # returning new number of resources\n @resources = event.dispatch(decision)\n\n=end\n end",
"def pre_loop; end",
"def set_episode\n @episode = @season.episodes.find_by(number: params[:id])\n end",
"def index\n @series = Series.find(params[:series_id].to_i)\n @new_episodes = @series.episodes.where(:seen => false).order(\"season desc, episode desc\")\n @seen_episodes = @series.episodes.where(:seen => true).order(\"season desc, episode desc\")\n end",
"def schedule_talks\n until available_talks.empty?\n Track.all.each do |track|\n schedule_talks_for_track(track)\n\n # When a track didn't fill exactly\n # Removing already scheduled last element from track and\n # Again trying for a exact match on available talks\n # Not a perfect solution, But, It produces better result\n # Kind of backtracking\n backtrack_and_schedule_talks_for_track(track)\n end\n end\n end",
"def watching_episodes\n shows = ::TvShow.watching\n @episodes = episodes.each_with_object([]) do |episode, object|\n show = shows.find{|sh| sh.imdb_id == episode.show.ids.imdb}\n next if show.blank?\n object << episode\n end.uniq{|episode| episode.show.title}\n self\n end",
"def add_episode_to_podcasts\n \tPodcast.all.each do |podcast|\n show_hash = Scraper.scrape_show_page(podcast.show_page_url)\n \t podcast.add_episode_name(show_hash)\n \tend\n end",
"def init\n update_episodes\n end",
"def watch_current!\n ep = ep(@current_ep).watch!\n @current_ep = next_episode.number\n ep\n end",
"def set_episode\n @episode = @season.episodes.find_by(number: params[:id])\n end",
"def start_falling(event)\n event.obfalling = 1\n event.move_speed = 4.5\n event.through = true\n event.fallbyjump.nil? ? event.move_away_from_player : event.fallbyjump = nil\n RPG::SE.new(FallSe,80).play \n @eve_fall.push(event) unless @eve_fall.include?(event)\n @eve_fall = @eve_fall.uniq \n @player_busy = event.picked = false if event.picked\n end",
"def speak(number_of_times)\n\t\tindex = 0\n\t\tuntil number_of_times == index \n\t\t\tputs \"Ho, ho, ho!, Haaaappy holidays!\"\n\t\t\tindex +=1\n\t\tend \n\tend",
"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 episodes_get\n log_debug\n\n # build syntax if we looking for a specific show\n show_wanted = ''\n \n if self.show\n show_wanted = \"and title = '#{self.show}'\"\n end\n \n sql_shows = \"select id,title,guid from metadata_items where metadata_type=2 and library_section_id in (select id from library_sections where section_type = 2) #{show_wanted} order by title\" \n \n sql_select(sql_shows).each do |row_shows|\n\n sql_seasons = \"select id,\\\"index\\\" from metadata_items where metadata_type=3 and parent_id=#{row_shows[0]} order by \\\"index\\\"\"\n sql_select(sql_seasons).each do |row_seasons|\n show = row_shows[1]\n season = row_seasons[1]\n guid = row_shows[2] \n \n sql_episodes = \"select \\\"index\\\",title, id from metadata_items where metadata_type=4 and parent_id=#{row_seasons[0]} order by \\\"index\\\"\"\n sql_select(sql_episodes).each do |row_episodes|\n episode = row_episodes[0]\n name = row_episodes[1]\n metadata_item_id = row_episodes[2]\n \n #puts \"metadata_item_id : #{metadata_item_id}\"\n episodes_track show, season, episode, name\n found_debug show, season, episode, name \n \n sql_items = \"select id from media_items where metadata_item_id = #{metadata_item_id}\"\n sql_select(sql_items).each do |row_items|\n media_items_id = row_items[0]\n # puts \"media_items_id : #{media_items_id}\"\n \n sql_parts = \"select file from media_parts where media_item_id = #{media_items_id}\"\n sql_select(sql_parts).each do |row_parts|\n file = row_parts[0]\n # puts \"file : #{file}\"\n shows_track show, guid, season, file\n \n end\n \n end\n\n \n end\n end\n end\n\n end",
"def show\n \t@season_list = @title.season_list\n \t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n \tif @episode_list.count == 0\n \t\tparams[:season_choice] = \"All\"\n\t\t\t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n\t\tend\n \tlogger.debug @episode_list\n end",
"def show\n puts \"++++++++ star#show\"\n @star = Star.find(params[:id])\n @episodes = @star.episodes\n #@episode = Episode.new\n #@podcasts = Podcast.all #we don't need all the podcasts.\n\n star_query = @star.name.strip.gsub(/\\s+/, \"+\")\n\n #this works, but super innefficient. \n def all_eps(query, offset)\n episodes_arr = []\n results = 10\n num = offset\n\n while results == 10\n\n response = HTTParty.get \"https://listennotes.p.mashape.com/api/v1/search?len_min=10&offset=#{num}&only_in=title&published_after=0&q=#{query}&sort_by_date=0&type=episode\",\n headers:{\n 'X-Mashape-Key' => ENV['MASHAPE_KEY'],\n \"Accept\" => \"application/json\"\n }\n #episodes_arr << response[\"results\"] #adds the current results to the array. Nope..\n response[\"results\"].each { |r| episodes_arr << r}\n num += response[\"count\"].to_i #increases the offset by the number of results that we just found\n \n count = episodes_arr.count\n puts \"There are now #{count} in the array\"\n results = response[\"count\"]\n puts \"The latest lookup has #{results} results in there. \"\n\n end\n return episodes_arr\n end\n\n if @star.last_search == nil\n s = @star\n s.last_search = Date.today - 10.days\n puts s.last_search\n s.save\n end\n\n l = @star.last_search < (Date.today - 2.days)\n puts l \n #works\n\n if l == true \n many_episodes = all_eps(star_query, 0)\n many_episodes.select! do |e| \n limit = Date.today - 3.years\n def comparable_date(f)\n sec = (f[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n end\n comparable_date(e) > limit\n end #holy shit this works! Needs cleanup\n\n #save each episode - works\n many_episodes.each do |ep|\n new_ep = Episode.new\n pod_name = ep[\"podcast_title_original\"]\n pod = Podcast.find_or_create_by(name: pod_name)\n new_ep.star_id = @star.id\n new_ep.podcast_id = pod.id\n new_ep.title = ep[\"title_original\"]\n new_ep.description = ep[\"description_original\"]\n new_ep.api_id = ep[\"id\"]\n sec = (ep[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n new_ep.release_date = dform\n new_ep.save\n end\n\n @episodes_arr = many_episodes.sort_by { |e| e[\"pub_date_ms\"]}.reverse\n @star.last_search = Date.today\n @star.save\n else\n puts \"WE DIDN RUN THE SEARCH\"\n end\n @display_episodes = @episodes.where(display: true)\n end",
"def part1\n 2.times do\n \n 6.times do\n play :G4\n play :E4\n play :E2\n sleep 0.5\n end\n \n 2.times do\n play :A4\n play :E4\n play :E2\n sleep 0.5\n end\n end\nend",
"def stopped_at; end",
"def stopped_at; end",
"def stopped_at; end",
"def tick events\n @outerlimit = (battlefield_width + battlefield_height) * 3\n #print \"mode=#{@mode},stage=#{@stage},dir=#{@dir},walldir=#{@walldir}\\n\"\n #print \"at (#{x},#{y}) at time #{time},res=#{@trk_res}\\n\"\n #mode nil is startup and initialize variables\n #STDOUT.flush\n # ###########\n # # Sensors\n # ###########\n @since_evade += 1\n @sincehit += 1\n @sincehit = 0 if not events['got_hit'].empty?\n events['got_hit'].each{|e| @hit_filter += e.first}\n @hit_filter *= 0.99\n if events['robot_scanned'].empty?\n @sinceblip += 1\n @closest = @outerlimit\n #print\"\\n\" \n else\n @closest = events['robot_scanned'].collect{|e| e.first}.sort.first\n @sinceblip = 0\n #print \",blip=#{@closest}\\n\"\n end\n # ###########\n # # High level logic - state machine\n # ###########\n #print \"sincehit=#{@sincehit},closest=#{@closest},range=#{@range}\\n\"\n #mode 0 is orient tank\n if @mode == 0\n @stage = 0\n @range = @outerlimit\n @mode = 1 if aimrad(@dir*90)\n #mode 1 find range of nearest target\n elsif @mode == 1\n #setup radar for a scan\n if @stage==0\n aimrad(@dir*90 + 180,60,1)\n @range = min(@range,@closest)\n @stage +=1\n #continue around for full circle\n elsif @stage == 1\n @range = min(@range,@closest)\n if aimrad(@dir*90,60,1)\n #did we see a bot?\n if @range == @outerlimit\n @stage = 0 \n else\n @mode = 2\n @stage = 0\n end\n end\n end\n #mode 2: find the nearestbot\n elsif @mode == 2\n #start next circle to re find the closest bot\n if @stage == 0\n #print \"range is #{@range}\\n\"\n aimrad(@dir*90 + 180,60,1)\n @stage +=1\n #continue scan for the closest bot\n elsif @stage == 1\n #print \"dir=#{@dir},angle=#{radar_heading}, closest=#{@closest}\\n\"\n if @closest < @range * 1.25\n @range = @closest\n @mode = 3\n @stage = 0\n @tangle = radar_heading\n #print \"found target at angle #{@tangle}\\n\"\n #if we finished the scan, and didn't find close target, recompute range\n elsif aimrad(@dir*90,60,1)\n @mode = 0\n @stage =0\n end\n end\n #mode 3 is tracking bot\n elsif @mode == 3\n #entry from previous mode, determine whether to scan ccw or cw\n if @stage == 0\n @trk_dir,@trk_res,@stage = -1,4,2\n #first scan in this direction\n elsif @stage == 1\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n else\n @stage = 2\n end\n #second scan in this direction\n elsif @stage == 2\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n else\n @trk_dir = -@trk_dir\n @trk_res = min(@trk_res + 2,4)\n @stage = 3\n end\n #the target bot has moved out of our window, expand the window\n elsif @stage == 3\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = - @trk_dir\n @trk_res = max(@trk_res - 2,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n elsif @trk_res < 6\n @trk_dir = - @trk_dir\n @trk_res = @trk_res +1\n else\n #we lost our target, reaquire from scratch\n @mode = 0\n @stage = 0\n end\n end\n @tangle += @@ScanRes[@trk_res] * @trk_dir\n aimrad(@tangle)\n #print\"tangle=#{@tangle}, res=#{@@ScanRes[@trk_res]}, rot=#{@trk_dir}\\n\"\n elsif @mode == 4\n #determine which corner to go to from a corner\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 + 95*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 60*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @prevCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n elsif @stage == 3\n aimrad(@dir*90 -5*@walldir)\n @stage += 1\n elsif @stage == 4\n @nextCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + @walldir)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n elsif @mode == 5\n #determine which corner to go to from middle of wall\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 - 5*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @nextCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 150*@walldir)\n @stage += 1\n elsif @stage == 3\n @stage += 1 \n aimrad(@dir*90 -150*@walldir)\n elsif @stage == 4\n aimrad(@dir*90 -185*@walldir)\n @stage += 1\n elsif @stage == 5 \n @prevCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + 2)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n end\n #compute the distances to the four walls\n walls = [battlefield_width - x,y,x,battlefield_height - y]\n #hug the wall, if we are slightly off the wall, than move back to the wall\n toleftwall,torightwall = walls[(@dir+1)%4],walls[(@dir-1)%4]\n #print \"wallroom left=#{toleftwall}, right=#{torightwall}\\n\"\n if toleftwall > 80 and toleftwall < 200\n aimtank(@dir * 90 + 20)\n elsif torightwall > 80 and torightwall < 200\n aimtank(@dir * 90 - 20)\n else\n aimtank(@dir * 90)\n end\n #If we reach a corner or wall, turn towards farthest corner on this wall\n if walls[@dir] < 100\n if toleftwall > torightwall\n @walldir = 1 #we are now going ccw\n @dir = (@dir+1)%4 # turn ccw\n #print \"turn left\\n\" \n else\n @walldir = -1 #we are now going cw\n @dir = (@dir-1)%4 #turn cw\n #print \"turn right\\n\" \n end\n #don't check corners at T junction\n if toleftwall > 100 and torightwall > 100\n @mode = 5 # determin weather it is safer ahead or behind\n @stage = 0\n else\n @mode = 4 # determin if previous corner was safer\n @stage = 0\n end\n #If we are getting hammered, turn now to evade damage\n # once we evade, avoid making another evasive manuver or we will turn in circles\n elsif @hit_filter > 400 and @since_evade > 100\n @dir = (@dir+@walldir)%4\n @hit_filter = 0\n @since_evade = 0\n end\n accelerate 1\n aim = @mytrack.predict(x,y,time) || (@dir * 90)%360\n aimgun(aim)\n fire 0.1\n doturns #we already computed our turns, now execute them\n STDOUT.flush\n end",
"def advance\n if @days_until_next <= 0\n @state = :shock\n @days_until_next = @rng.call\n else\n @state = :normal\n @days_until_next -= 1\n end\n end",
"def remaining_events_slots\n #num de eventos dos pacotes - num de eventos que possui\n self.max_events - self.active_events_count\n end",
"def after_cycle; end",
"def ios_getEpisodeToPlay(client)\n\t\tbegin\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.HamburgerButton']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='洋画' and ./parent::*[@class='UITableViewCellContentView']]\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UIImageView' and @height>0 and ./parent::*[@accessibilityLabel='button search']]\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='タイトルとの一致']\") == true || client.isElementFound(\"NATIVE\", \"xpath=//*[@accessibilityLabel='戻る' and ./preceding-sibling::*[@accessibilityLabel='']]\") == true\n\t\t\t\t$obj_gener.icheckSearchField(client)\n\t\t\tend\n\t\t\tclient.click(\"NATIVE\", \"text=海外ドラマ一覧\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"text=すべての作品\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"text=見放題\", 0, 1)\n\t\t\tclient.sleep(3000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UIView' and @height>0 and ./parent::*[@class='UNextMobile_Protected.ThumbPlayButton']]\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.swipe2(\"Down\", 500, 2000)\n\t\t\tclient.sleep(3000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='エピソードを選択']\")\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='エピソードを選択']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UNextMobile_Protected.PlayingStateView' and @width>0 and ./parent::*[./parent::*[@class='UNextMobile_Protected.ThumbPlayButton']]]\", 0, 1)\n\t\t\t\tclient.sleep(10000)\n\t\t\t\tHistoryPlay.new.ios_playbackCheckFromList(client)\n\t\t\t\tHistoryPlay.new.ios_leavingPlayer(client)\n\t\t\telse\n\t\t\t\tputs \"::MSG:: This contents does not have episode list!!!\"\n\t\t\tend\t\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@accessibilityLabel='戻る' and ./preceding-sibling::*[@accessibilityLabel='エピソード']]\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UIImageView' and @height>0 and ./parent::*[@accessibilityLabel='main nav close']]\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@accessibilityLabel='戻る' and ./preceding-sibling::*[@class='UNextMobile_Protected.UNTitleListHeaderView']]\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@accessibilityLabel='戻る' and ./preceding-sibling::*[@accessibilityLabel='']]\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@class='UIControl']\", 0, 1)\t\t\n\t\trescue Exception => e\n\t\t\t$errMsgTanwa = \"::MSG:: Exception occurrred while finding ELEMENT\" + e.message\n\t\tend\t\t\n\tend",
"def set_episode\n @episode = Episode.find(params[:id])\n @epis = Episode.find(params[:id])\n end",
"def set_episode\n @series = Series.find(params[:series_id].to_i)\n @episode = @series.episodes.find(params[:id].to_i)\n end",
"def playlist_end playlist\n end",
"def load_series! api\n @seasons = 1 # determined later\n @episodes = []\n current_season = 1\n begin\n season_url = url + '/episodes?season=%d' % current_season\n load_season!(api, season_url, current_season)\n current_season+=1\n end until current_season > @seasons\n\n # number all episodes\n num = 1\n @seasons.times do |season|\n sorted_episodes = get_season(season+1).sort_by {|epi| epi.episode}\n sorted_episodes.each do |epi|\n epi.number = num\n num += 1\n #debug '%s S%02dE%02d [%d] -- %s' % [title, epi.season, epi.episode, epi.number, epi.airdate]\n end\n end\n\n # remove pages:\n @episodes.each do |episode|\n episode.page = nil\n end\n\n @series_loaded = true\n end",
"def set_episode\n @episode = Episode.includes(:season).find(params[:id])\n end",
"def retirement_range\n #large simulation\n (1..30)\n end",
"def can_watch_episode?( episode, t = Time.now.utc )\n\t\tepisode.available?( t )\n\tend",
"def endless_loop?; end",
"def run\n if ARGV.empty? && @alive\n scrape_today \n scrape_weekend\n process_today_activities\n process_weekend_activities\n run_normal\n elsif !ARGV.empty? && @alive \n scrape_today \n scrape_weekend\n process_today_activities\n process_weekend_activities\n run_argv\n elsif !ARGV.empty? && !@alive\n run_argv\n else \n run_offline\n 30.times do\n sleep(0.1)\n @bar.advance\n end \n display_favorites\n end \n end",
"def extract_video_page_urls(webpage,options)\r\n puts \"Extracting data from html5 data\"\r\n webpage.css('li.regularitem').each do |post|\r\n link = post.css('h4.itemtitle').css('a').first\r\n description = post.css('div.itemcontent').first.text\r\n download_episode(link.child.text,link['href'],description, options)\r\n end\r\nend",
"def setup_loop\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n count = @acts[1]\n action_key = @acts[2]\n is_string = action_key.is_a?(String)\n count.times do\n if is_string\n @acts = [:action, action_key]\n execute_sequence\n break if @break_action\n else\n begin\n action_key.each do |action|\n @acts = action\n execute_sequence\n break if @break_action\n end\n rescue\n ErrorSound.play\n text = \"Wrong [:loop] parameter!\"\n msgbox text\n exit\n end\n end\n break if @break_action\n end\n end",
"def get_episode_info\n\n\t\tbegin\n\t\t\turl = source_url\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/miss-undercover,5cd28786818965652bf912ab.html\"\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/monitor,5cda852e81896518171f509c.html\"\n\t\t\tdoc \t\t\t= send_request(url)\n\t\t\tdata \t\t\t= doc.css(\"article.broadcast-detail\")\n\t\t\t# header \t\t= doc.css(\"header.broadcast-detail__header\")\n\t\t\t# duration \t\t= header.css(\"div.text-wrapper span.text-row\")[1].text[-7..-2] rescue nil\n\t\t\tchannel \t\t= doc.css(\"span.tv-show-label__channel\").text\n\t\t\tvideo \t\t\t= get_video_url(doc)\n\t\t\tdescription = doc.css(\"section.broadcast-detail__description p\").text.delete(\"\\\"\").delete(\"\\r\").delete(\"\\n\")\n\t\t\tcast \t\t\t= doc.css(\"section.cast dl\")\n\t\t\tcasts \t\t\t= get_cast(cast[0])\n\t\t\tactors \t\t\t= get_cast(cast[1])\n\t\t\tthumb = doc.css('div.editorial-rating')[0].values[0].split(\" \")[1] rescue nil\n\t\t\t# transmitter_valid(channel)\n\t\t\timage = doc.css(\".broadcast-detail__stage img\").first.attributes[\"src\"].value rescue []\n\t self.program.update(genre: casts[\"Genre\"]) if (casts[\"Genre\"].present? && program.genre.nil?)\n\t\t\t\n\t\t\tparam = {is_scraped: true} \n\t\t\tparam.merge!(preview_video_url: video) if video.present?\n\t\t\tself.update(param)\n\n\t self.episode_infos.create(description: description, country: casts[\"Land\"], year: casts[\"Jahr\"],age_rating: casts[\"Altersfreigabe\"], director: casts[\"Regie\"], producer: casts[\"Produzent\"], script: casts[\"Drehbuch\"], camera: casts[\"Kamera\"], music: casts[\"Musik\"], original_title: casts[\"Originaltitel\"], actors: actors ,thumb: thumb, image_urls: image)\n\t get_rating(doc)\n\t rescue StandardError => e\n\t \tRails.logger.info \"================================================\"\n\t \tRails.logger.info \"Having some issues during storing episode info.\"\n\t \tRails.logger.info \"#{e}\"\n\t end\n\tend",
"def check_for_infinite_loop(processed_source, offenses_by_iteration); end",
"def play_cycle\n play\n earn_achievements\n end_game\n end",
"def find_and_set_season_episode_fields\n @season_ep_field_pos = nil\n SeasonEp_Regexps.each do |re|\n @filename_fields.each_with_index do |fn_field, idx|\n if fn_field =~ re\n @season_ep_field_pos = idx\n @result[:season] = $1.to_i\n @result[:episode] = $2.to_i\n break\n end\n end\n break unless @season_ep_field_pos.nil?\n end\n @season_ep_field_pos\n end",
"def runs; end",
"def play\n\t# while $game_end == false\n\t\t9.times { \n\t\t\tif $game_end == false\n\t\t\t\tturns\n\t\t\tend\n\t\t}\nend",
"def stopsig(*) end",
"def run\n loop { sleep 5 while @feeds.alive? }\n end",
"def advance_players!\n until finished? != nil\n @players.times do |current_player|\n new_location = @current_location[current_player] + @dice.roll\n unless new_location > @length-1 || finished? != nil\n @track[current_player][@current_location[current_player]] = \".\"\n @current_location[current_player] = new_location\n @track[current_player][new_location] = \">\"\n end\n end\n print_track\n sleep 1\n end\n end",
"def pushSeason (index, reviews, grades, validSeasons, episodesPerSeason)\n \tputs \"season \" + validSeasons[index].inner_html\n \tif index != 0 then\n \t\tseason = reviews.link_with(class: \"badge season-\" + validSeasons[index].inner_html).click.search('.grade.letter.tv').reverse\n \telse\n \t\tseason = reviews.search('.grade.letter.tv').reverse\n \tend\n\n \ttopJunk = season[season.size - 1] # grabs top element from array\n\n \twhile season[season.size - 1] == topJunk\n \t\tseason.pop\n \tend\n\n \t#season.pop\n\n \t#season.delete(topJunk)\n\t #season.pop # the latest episode is at the top of every page, remove it from the list\n\n\t # for some reason, every couple of days I will test this program and this section messes me up.\n\t # Some days it needs 3 pops to get the right number of episodes, other days it needs 1 pop.\n\t # There's probably a better way of removing duplicates, but I have yet to implement that. Definitely on the to-do list.\n\n\t #season.pop # maybe implement something where you fetch the top episode's ID and make sure the last one isn't that,\n\t #season.pop # except in the caes of the final season/latest season of the show where it is.\n\t season = season.reverse\n\t puts season.length.to_s + \" episodes\"\n\t episodesPerSeason.push(season.length.to_i)\n\t while season.length > 0 do\n\t \tgrades.push(season.pop.inner_text())\n\t end\n\tend",
"def episode_show_pagination\n\t\tself.class.episode_show_pagination( self, @show )\n\tend",
"def movement_process_end(no_follower_move = false)\n follower_move unless no_follower_move\n particle_push\n if SlideTags.include?(sys_tag = system_tag) ||\n (sys_tag == MachBike && !($game_switches[::Yuki::Sw::EV_Bicycle] && @lastdir4 == 8))\n @sliding = true\n @sliding_parameter = sys_tag\n Scheduler::EventTasks.trigger(:begin_slide, self)\n end\n z_bridge_check(sys_tag)\n detect_swamp\n if jumping?\n Scheduler::EventTasks.trigger(:begin_jump, self)\n elsif moving?\n Scheduler::EventTasks.trigger(:begin_step, self)\n end\n end",
"def trip(url, steps=10)\n so_far = [] # (3) \n\n steps.times do \n page = fetch(url)\n book_info = scrape_book_info(page)\n so_far << book_info[:title]\n puts format_output(book_info)\n \n next_book = scrape_affinity_list(page).find do | possible | # (4) \n not so_far.include?(possible[:title])\n end\n\n url = next_book[:url]\n end\nend",
"def next_life_span!\n next_round_dead_cells = []\n next_round_live_cells = []\n\n world.cells.each do |cell|\n #under population rule\n # puts cell.inspect\n # puts world.live_neighbours_around_cell(cell).count\n if cell.alive? and world.live_neighbours_around_cell(cell).count < 2\n next_round_dead_cells << cell\n end\n #cell to next gen\n if cell.alive? and ([2,3].include? world.live_neighbours_around_cell(cell).count)\n next_round_live_cells << cell\n end\n #over population\n if cell.alive? and world.live_neighbours_around_cell(cell).count > 3\n next_round_dead_cells << cell\n end\n #reproduction\n if cell.dead? and world.live_neighbours_around_cell(cell).count == 3\n next_round_live_cells << cell\n end\n end\n #revive cells for next span\n next_round_live_cells.each do |cell|\n cell.revive!\n end\n #kill cells\n next_round_dead_cells.each do |cell|\n cell.die!\n end\n end",
"def index\n @episodes = @season.episodes\n end",
"def evaulate_schedule\n 5\n end",
"def loop_forever; end",
"def do_turn_end_evs\n @wait_on_turn_end_evs = true\n ev_ids = TM.ev_turn_start[TM.turn_no]\n print \"do_turn_end_evs, ev_ids = #{ev_ids} turn_no = #{TM.turn_no}\\n\"\n if ev_ids\n ev_ids.each{|id| Era::AI.start_event(id)}\n end\n end",
"def prospector_journey(num_turns)\r\n i = 0\r\n while i < @prospectors.count\r\n @prospectors[i].print_start\r\n\r\n while @prospectors[i].visits < num_turns\r\n found_anything = @prospectors[i].look_for_rubies\r\n @prospectors[i].print_findings\r\n # Has more visits they can make\r\n if @prospectors[i].visits < num_turns - 1 && !found_anything\r\n @prospectors[i].move\r\n # No more visits to make, don't move again before returning\r\n elsif @prospectors[i].visits == num_turns - 1 && !found_anything\r\n break\r\n end\r\n end\r\n\r\n @prospectors[i].print_total_findings\r\n @prospectors[i].going_home\r\n\r\n i += 1\r\n end\r\nend",
"def fetch_episodes_for_playlist(user)\n all_episodes_array = []\n favorites_on_array = Favorite.where(user_id: user.id, playlist_on_off: \"on\")\n favorites_on_array.each do |favorite_instance|\n all_episodes_array += fetch_episodes_by_id(favorite_instance.show_id)\n end\n add_playlist_to_table(all_episodes_array, user)\nend",
"def essence_to_life\n if not r_pause\n if essence >= new_life\n @essence -= new_life\n @life += 1\n $hud.set_lives(life)\n $sm.play_sound(\"regain1\",1.0,1.0,false)\n @r_pause = true\n else\n $sm.play_sound(\"error\",0.5,1.0,false)\n @r_pause = true\n end\n end\n end",
"def perform \n application = Application.new\n while application.decide == \"Y\"\n application.ongoing_game\n application.ending_game \n end\nend",
"def episode\n\t\tlimit = params[:limit] || Setting['vms-protected-visible-episode-comment-count'].value_typed\n\t\tstart_at_id = params[:start_at_id]\n\n\t\t# ensure no one abuses the system\n\t\tlimit = Setting['vms-protected-visible-episode-comment-count'].value_typed if limit > Setting['vms-protected-visible-episode-comment-count'].value_typed\n\t\t@episode = Episode.find( params[:id], :readonly => true )\n\t\tif !@episode.available? or !@episode.show.available?\n\t\t\tredirect_to home_url and return\n\t\tend\n\t\topts = {:limit => limit, :order => 'id DESC', :readonly => true}\n\t\topts[:conditions] = ['id < ?',start_at_id] unless start_at_id.nil?\n\t\t@comments = @episode.episode_comments.find( :all, opts )\n\t\tuser_ids = @comments.collect{|c| c.user_id }.uniq\n\t\t@users = User.all( :conditions => { :id => user_ids }, :readonly => true )\n\t\trespond_to do |format|\n\t\t\tformat.json do\n\t\t\t\trender( :json => '{ comments: {' + @comments.collect{|x| x.to_json}.join(',') + '}, users: {' + @users.collect{|x| x.to_public_json}.join(',') + '} }' ) and return\n\t\t\tend\n\t\tend\n\tend",
"def run_loop\n end",
"def cycle?\n #...\n end",
"def episode_number\n return 0 if link_url == 'https://shows.acast.com/easyeaspanish/episodes/trailer'\n if podcast.code == 'easygreek'\n link_url[%r{/episodes/(\\d+)}, 1]&.to_i\n else\n slug[/^\\d+/]&.to_i\n end\n end",
"def show\n @banner_ad = \"/31902320/Shows_Leaderboard\"\n @banner_id = 'div-gpt-ad-1411894829676-0'\n @dfp_header = \"shows\"\n @active=\"shows\"\n @show_follow_status = ''\n # @f = @show.user_followers.random(5)\n # @followers = (@f.compact!).nil? ? @f : @f.compact!\n\n @followers = @show.user_followers.offset(rand(@show.user_followers.count)).limit(5)\n \n if(@episode.nil?) \n @episode = @show.episodes.first\n end\n\n\n @ga_page_params = \", {'dimension1': '#{@episode.creator.id}', 'dimension2': '#{@episode.id}'}\"\n\n #we want to have different items based on single or episodic info\n @description = @show.single? ? @show.description : @episode.description\n @title = @show.single? ? @show.title : \"#{@show.title} : #{@episode.title}\"\n\n \n\n#meta fun\n\n # @meta_description = @show.single? ? \"#{@show.title} : #{@episode.description}\" : \"#{@show.title} : #{@episode.title} - #{@episode.description}\"\n @meta_description = \"#{@title} - #{@episode.description}\"\n if(!@episode.tag_list.empty?)\n @page_keywords = @episode.tag_list.to_s\n end\n if(!@episode.keyword_list.empty?)\n @page_keywords = @episode.keyword_list.to_s\n end\n # if current user following\n if !current_user.nil? && current_user.following?(@show)\n @show_follow_status = \"You are following\"\n else\n @show_follow_status = \"status\"\n end\n \n @likers = @episode.votes.up.by_type(User).voters.compact\n # @voters = Votes.where(votable: @episode).random(3).map(&:voter)\n end",
"def week_3\n wait(0)\n say \"Start your first short run.\"\n count_down(90, 'running')\n say \"Stop running now. You have 1 long run and two short ones left.\"\n count_down(90, 'walking')\n\n say \"Start the first long run now.\"\n count_down(3*60, 'running')\n say \"Stop running now. You have a short run and a long run left.\"\n count_down(3*60, 'walking')\n\n say \"Start your second short run.\"\n count_down(90, 'running')\n say \"Stop running. You have 1 more long run left.\"\n count_down(90, 'walking')\n\n say \"Start your last run now.\"\n count_down(3*60, 'running')\n say \"Stop running. After this walk, you will have finished.\"\n count_down(3*60, 'walking')\n\n say \"Great! You've finished for today.\"\nend",
"def cycle_video\n video_polls.reload\n # 'poll id: ' + current_video_poll.id.to_s\n if video_polls.length >= 1\n current_poll = Room.find(id).video_polls.last\n puts 'WINNER: ' + current_poll.select_winner.title\n current_poll.played_video.title\n end\n puts \"count before\" + video_polls.count.to_s\n new_poll = self.generate_video_poll\n if new_poll.candidate_videos.length == 0\n throw 'generated empty poll!'\n end\n puts \"count after\" + video_polls.count.to_s\n\n RoomsChannel.broadcast_state self\n end",
"def stopped_at=(_arg0); end",
"def stopped_at=(_arg0); end",
"def stopped_at=(_arg0); end",
"def process_one_cycle(data)\n data.each_slice(4) do |m, sec, usec, args|\n process_one_event(m, sec, usec, args)\n end\n end",
"def runner\n welcome\n total = initial_round\n\n until total >= 21 do\n total = hit?(total)\n end\n end_game(total)\n \n \n \nend",
"def run\n while 1\n if step == 1 then break end\n end\n end",
"def import!\n each_mapping do |anime, series_id, season_number|\n begin\n series = get_series(series_id)\n episodes = get_episodes(series_id, season_number)\n rescue NotFound\n anime.mappings.where(external_id: tvdb_id).first.destroy!\n next\n end\n\n next unless episodes\n\n next if anime.episode_count && (anime.episode_count - episodes.count).abs > 2\n if anime.episode_count\n episodes = episodes[0..anime.episode_count - 1] if anime.episode_count\n else\n anime.update_unit_count_guess(episodes.count)\n end\n\n # creating/updating the episode\n process_series_data(series, anime)\n process_episode_data(episodes, anime, series_id)\n end\n end",
"def getNextShow()\n #todo: implement priority checking\n #this query only grabs shows that should currently be recording\n #assume shows do not overlap, just the padded times overlap\n shows = Array.new\n now_showing = \"SELECT DATE_FORMAT(start, '#{DATE_TIME_FORMAT_XML}') as start, \n DATE_FORMAT(p.stop, '#{DATE_TIME_FORMAT_XML}') as stop, \n number, filename, p.xmlNode as xmlNode, channelID, priority\n FROM Scheduled s JOIN Channel USING (channelID)\n JOIN Programme p USING(channelID, start)\n WHERE start <= '#{PaddedTime.strstart}'\n AND p.stop > '#{PaddedTime.strstop}'\"\n \n databasequery(\"SELECT * FROM (#{now_showing}) as sub1\n WHERE priority = (SELECT max(priority) FROM (#{now_showing}) as sub2 )\").each_hash { |show_hash| \n shows << Show.new(show_hash['start'], \n show_hash['stop'], \n show_hash['number'], \n show_hash['xmlNode'], \n show_hash['filename'], \n show_hash['channelID'])\n }\n return nil if shows.length == 0\n if shows.length > 1\n #we have adjacent shows, or at least close enough so they overlap when padded\n shows.sort! {|a,b| a.starts_in <=> b.starts_in }\n (1...shows.length).each {|pos|\n shows[pos-1].unpad(shows[pos])\n }\n shows.delete_if { |show| show.notShowing }\n end\n #LOG.debug(\"The next show to record is #{shows[0].filename}\")\n shows[0]\nend",
"def each_tuesday( n=1, offset=0, dur=1); each_wdays(self.Tue,n,offset,dur); end",
"def new_episodes( season )\n return @seasons[season][1].flatten\n end"
] |
[
"0.64978206",
"0.64978206",
"0.64978206",
"0.64978206",
"0.5998188",
"0.5801927",
"0.5790353",
"0.5756773",
"0.5714188",
"0.55238515",
"0.5520462",
"0.54880637",
"0.54632616",
"0.53707284",
"0.53678775",
"0.53678775",
"0.53495806",
"0.5339623",
"0.53347844",
"0.5318255",
"0.5305853",
"0.53048486",
"0.52992105",
"0.5271848",
"0.52692235",
"0.526588",
"0.52494305",
"0.5235146",
"0.5229634",
"0.5208668",
"0.5208399",
"0.52026844",
"0.51990527",
"0.518264",
"0.51792705",
"0.5176029",
"0.51601017",
"0.51535255",
"0.5149015",
"0.5127139",
"0.5122289",
"0.51192975",
"0.5116014",
"0.5116014",
"0.5116014",
"0.51157254",
"0.511053",
"0.50873554",
"0.50831217",
"0.5075679",
"0.5067468",
"0.50665194",
"0.5056009",
"0.5055528",
"0.50408834",
"0.50387484",
"0.5030192",
"0.5025115",
"0.50180197",
"0.50018805",
"0.50008667",
"0.4994882",
"0.49854502",
"0.49827293",
"0.49791253",
"0.4974877",
"0.49647027",
"0.4954578",
"0.4953643",
"0.4953012",
"0.49486682",
"0.49443856",
"0.49418238",
"0.4941029",
"0.49376437",
"0.49373123",
"0.49299946",
"0.49225116",
"0.49150372",
"0.49065587",
"0.49051479",
"0.48996142",
"0.4899159",
"0.48936448",
"0.4893023",
"0.48891345",
"0.4880312",
"0.48727325",
"0.48691416",
"0.48681164",
"0.4866734",
"0.4866734",
"0.4866734",
"0.4865715",
"0.48653153",
"0.4864641",
"0.48640046",
"0.4860586",
"0.48591813",
"0.48576093"
] |
0.5805307
|
5
|
loop through all the episodes found in thetvdb for a show remove those that exists in plex ignore specials for now TODO: terrible method name
|
def thetvdb_missing_last_process(show)
log_debug
$thetvdb.show(show)
season_last, episode_last = thetvdb_missing_plex_last_ep(show)
season_first, episode_first = thetvdb_missing_plex_first_ep(show)
log_debug("#{show} start s#{season_first}e#{episode_first} : last s#{season_last}e#{episode_last}")
if $thetvdb.episodes.has_key?(show)
$thetvdb.episodes[show]['episodes'].keys.each do |season|
next if season == "0"
$thetvdb.episodes[show]['episodes'][season].keys.each do |episode|
first_aired = $thetvdb.episodes[show]['episodes'][season][episode]['first_aired']
show_index = show_index(season, episode)
plex_has = thetvdb_missing_plex_found(show,season,episode)
missing = thetvdb_missing_range(season, season_first, episode, episode_first)
missing = false if plex_has
if first_aired =~ /\w/
date_available = Date.today
date_aired = Date.parse first_aired
if ( date_available > (date_aired + 1) ) and missing
missing_process show, show_index,"aired: #{first_aired}"
end
end
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def thetvdb_missing_plex_found(show,season,episode)\n plex_has = false\n \n # remove shows that we have\n if $plex.episodes.has_key? show \n if $plex.episodes[show].has_key?(season.to_i)\n if $plex.episodes[show][season.to_i].has_key?(episode.to_i)\n plex_has = true \n end\n end\n end\n plex_has\nend",
"def watching_episodes\n shows = ::TvShow.watching\n @episodes = episodes.each_with_object([]) do |episode, object|\n show = shows.find{|sh| sh.imdb_id == episode.show.ids.imdb}\n next if show.blank?\n object << episode\n end.uniq{|episode| episode.show.title}\n self\n end",
"def get_all_free_episode_links_for_each_show_on_vland\n \t\tShow.all.each do |show|\n \t\t\tputs \"getting epsides for #{show.url}\"\n \t\t\t# sometimes its nice to take a 2-3 sec nap\n \t\t\tsleep(rand(2..3))\n \t\t\tresp = get_resp(show.url)\n \t\t\t# this is the point where I got tired of heavy lifting\n \t\t\thtml_result = Nokogiri::HTML.parse(resp.body)\n \t\t\thtml_result.css(\".entry-card\").each do |clip|\n \t\t\t\t# skip episdes / clips that are not free to watch, may also one day limit it to just episodes.\n \t\t\t\tnext if clip.css(\".unlockable\").first.to_s.include? \"icon-locked\"\n \t\t\t\t# grabs sub link to epsides or clip\n \t\t\t\tepisode_or_clip_url = clip.css(\".cta\").attr(\"href\").to_s\n \t\t\t\t#getting rid of a \"/\" at the start\n \t\t\t\tepisode_or_clip_url[0] = \"\"\n\n \t\t\t\t# lets create some links pertaining to shows and clips from shows\n \t\t\t\tep = Episode.find_or_initialize_by(url: self.url + episode_or_clip_url)\n \t\t\t\tif ep.new_record?\n \t\t\t\t\tep.show_id=show.id\n \t\t\t\t\t#can do fancy stuff here like grab all show episode / clip fields \n \t\t\t\t\tep.save!\n \t\t\t\tend\n \t\t\tend\n \t\tend\n \tend",
"def fix_names(shows)\n\t\t\t# Ignored shows\n\t\t\ts = shows.reject do |i|\n\t\t\t\t# Remove season+episode\n\t\t\t\t@config[:ignored].include?(i.split(\" \")[0..-2].join(\" \").downcase)\n\t\t\tend\n\n\t\t\ts.map { |i| i.gsub(/ \\(.+\\)|[':]/, \"\") }\n\t\tend",
"def episodes\n Episode.all.select{ |episode| episode.show == self }\n end",
"def episodes_get\n log_debug\n\n # build syntax if we looking for a specific show\n show_wanted = ''\n \n if self.show\n show_wanted = \"and title = '#{self.show}'\"\n end\n \n sql_shows = \"select id,title,guid from metadata_items where metadata_type=2 and library_section_id in (select id from library_sections where section_type = 2) #{show_wanted} order by title\" \n \n sql_select(sql_shows).each do |row_shows|\n\n sql_seasons = \"select id,\\\"index\\\" from metadata_items where metadata_type=3 and parent_id=#{row_shows[0]} order by \\\"index\\\"\"\n sql_select(sql_seasons).each do |row_seasons|\n show = row_shows[1]\n season = row_seasons[1]\n guid = row_shows[2] \n \n sql_episodes = \"select \\\"index\\\",title, id from metadata_items where metadata_type=4 and parent_id=#{row_seasons[0]} order by \\\"index\\\"\"\n sql_select(sql_episodes).each do |row_episodes|\n episode = row_episodes[0]\n name = row_episodes[1]\n metadata_item_id = row_episodes[2]\n \n #puts \"metadata_item_id : #{metadata_item_id}\"\n episodes_track show, season, episode, name\n found_debug show, season, episode, name \n \n sql_items = \"select id from media_items where metadata_item_id = #{metadata_item_id}\"\n sql_select(sql_items).each do |row_items|\n media_items_id = row_items[0]\n # puts \"media_items_id : #{media_items_id}\"\n \n sql_parts = \"select file from media_parts where media_item_id = #{media_items_id}\"\n sql_select(sql_parts).each do |row_parts|\n file = row_parts[0]\n # puts \"file : #{file}\"\n shows_track show, guid, season, file\n \n end\n \n end\n\n \n end\n end\n end\n\n end",
"def episodes_missing_track ( show, season, episode,extra=nil)\n @episodes_missing[show] = {} if @episodes_missing[show].class.to_s != 'Hash'\n @episodes_missing[show][season] = {} if @episodes_missing[show][season].class.to_s != 'Hash'\n @episodes_missing[show][season][episode] = 'missing do something'\n end",
"def thetvdb_get_show_episodes(show_id,show)\n episodes = {}\n local_file = show.gsub(/\\*/,'_')\n cache_dir = $script_dir + \"/var/tvdb/\" + local_file\n cache_dir = $config[\"tvdb\"][\"cache_directory\"] + \"/\" + local_file if $config[\"tvdb\"].has_key? \"cache_directory\"\n cache = cache_dir + \"/\" + show_id + \".xml\"\n \n if File.exists? cache and not $opt[\"tvdb-refresh\"]\n log(\"tvdb retrieving show episodes via cache: #{show} (#{show_id})\") if $config[\"settings\"][\"log_level\"] > 1\n parser = XML::Parser.file cache\n doc = parser.parse\n else\n log(\"tvdb retrieving show episodes via www: #{show} (#{show_id})\") if $config[\"settings\"][\"log_level\"] > 1\n url = $config[\"tvdb\"][\"mirror\"] + '/api/' + $config[\"tvdb\"][\"api_key\"] + '/series/' + show_id + '/all/en.xml'\n xml_data = http_get(url)\n \n parser = XML::Parser.string xml_data\n doc = parser.parse\n \n File.open(cache, 'w') do |file|\n # TODO: odd no idea whats changed here or why\n file.puts xml_data\n #xml_data.split(/\\n/).each {|x| file.puts x}\n end\n end\n\n doc.find('//Data/Episode').each do |item| \n season = item.find('SeasonNumber')[0].child.to_s\n episode = item.find('EpisodeNumber')[0].child.to_s\n name = item.find('EpisodeName')[0].child.to_s\n episodes[show] = Hash.new unless episodes[show].class == Hash\n #episodes[show][\"series name\"] = series_name\n episodes[show][season] = Hash.new unless episodes[show][season].class == Hash\n episodes[show][season][episode] = name\n end\n episodes\nend",
"def larry_all_episodes (larry_david)\n all_shows = []\n Episode.all.map do |episode|\n show = { character_id: larry_david.id, episode_id: episode.id}\n all_shows.push(show)\n end\n Show.create(all_shows)\nend",
"def next_episodes(show, name, id)\n db_show = TvShows.where(:user => session[:username]).where(:name => name).first\n\n if !db_show.nil?\n last_season = TvShows.where(:user => session[:username]).where(:name => name).first.season\n last_episode = TvShows.where(:user => session[:username]).where(:name => name).first.episode\n else\n last_season = 1\n last_episode = 1\n end\n\n current_season = Tmdb::Season.detail(id, last_season)\n if !current_season['episodes'].nil?\n episodes = current_season['episodes'][last_episode.to_i, current_season['episodes'].length]\n\n number_of_seasons = show['number_of_seasons']\n ((last_season.to_i + 1)..number_of_seasons.to_i).each do |season_number|\n season = Tmdb::Season.detail(id, season_number)\n new_episodes = season['episodes'][0, season['episodes'].length]\n episodes.concat(new_episodes)\n end\n episodes\n else\n nil\n end\n end",
"def get \n log_debug\n $plex.episodes.keys.each do |show|\n thetvdb_missing_last_process(show)\n end\nend",
"def add_episode_to_podcasts\n \tPodcast.all.each do |podcast|\n show_hash = Scraper.scrape_show_page(podcast.show_page_url)\n \t podcast.add_episode_name(show_hash)\n \tend\n end",
"def cleanup()\n Track.where(scanned: false).delete_all()\n Disc.delete_all(\"id NOT IN (SELECT DISTINCT(disc_id) FROM tracks)\")\n Album.delete_all(\"id NOT IN (SELECT DISTINCT(album_id) FROM tracks)\")\n Artist.delete_all(\"id NOT IN (SELECT DISTINCT(artist_id) FROM tracks)\")\n end",
"def handle_series(episode)\n tvdb_result = series_lookup(episode) if ($opt[\"tvdb\"]) && (! @tvdb_episodes.has_key?(episode.show))\n if tvdb_result == false\n handle_error(\"failed to find tvshow \\'#{episode.show}\\' from tvdb, skipping..\") if $opt[\"debug\"]\n return false\n end\n re_cache = episode.fix_via_tvdb @tvdb_episodes if $opt[\"tvdb\"] and @tvdb_episodes.has_key?(episode.show)\n\n # we do one round of re-caching only if the episode name is not found\n if re_cache\n log(\"re-caching from tvdb\")\n $opt[\"tvdb-refresh\"] = true\n @tvdb_episodes = {}\n tvdb_result = series_lookup(episode) if ($opt[\"tvdb\"]) && (! @tvdb_episodes.has_key?(episode.show))\n if tvdb_result == false\n handle_error(\"failed to find tvshow \\'#{episode.show}\\' from tvdb, skipping..\")\n return false\n end\n episode.fix_via_tvdb @tvdb_episodes if $opt[\"tvdb\"] and @tvdb_episodes.has_key?(episode.show)\n end\n \n # FIXME: temporay way to handle new destination folder\n target_directory_original = @tvdir\n if $show_storage.has_key? episode.show\n @tvdir = $show_storage[episode.show]\n end\n \n season_pre = \"season.\"\n season_pre = $config[\"settings\"][\"season_dir_prepend\"] if $config[\"settings\"].has_key? \"season_dir_prepend\"\n season = \"#{season_pre}#{episode.season}\"\n season = \"specials\" if episode.season == \"0\"\n target = \"#{@tvdir}/#{episode.show_on_fs}/#{season}\" \n target = \"#{@tvdir}\" if $opt[\"dst_no_hierarchy\"]\n\n move_file(episode.original_file,target)\n @tvdir = target_directory_original\nend",
"def remove_tvshow\n @watch = Watchlist.find_by(show_watched: false, user_id: params[:user_id], tv_show_id: params[:tv_show_id])\n\n if @watch\n @watch.destroy\n render json: @watch\n else\n render json: {\n error: \"Something went wrong\"\n }\n end\n end",
"def shows_track ( show, guid, season, file )\n @shows[show] = {} if @shows[show].class.to_s != 'Hash'\n @shows[show]['guid'] = guid\n @shows[show]['seasons'] = [] if @shows[show]['seasons'].class.to_s != 'Array'\n \n @shows[show]['seasons'].push(season).uniq!\n @shows[show]['path'] = file\n #@shows[show]['path'].gsub!(/\\/share\\/CACHEDEV1_DATA/,'/Volumes')\n @shows[show]['path'].gsub!(/\\/Season\\s.*/,'')\n \n if ( guid =~ /com.plexapp.agents.thetvdb:\\/\\/(\\d+)\\?/ ) \n @shows[show]['tvdb_id'] = $1\n end\n\n end",
"def find_shows(page)\n # Looks like it is consistent in the classes it uses\n # so grab what we need\n page.search(\".entry-content-live\").map do |elem|\n dateNode = elem.at(\".artist_date\")\n # convert the date so we can see the year\n date = Date.today\n unless dateNode.nil?\n # it is delimited by '|' and the date is on the first index\n date = Date.parse(dateNode.text.strip.split(\"|\")[0])\n # if its parsed to be before today then in actual the following year\n if date < Date.today\n date = date.next_year()\n end\n end\n # openers are delimited by '|'\n supports = []\n supportsNode = elem.at(\".openers\")\n unless supportsNode.nil?\n supports = supportsNode.text.strip.split(\"|\").map do |support|\n support.strip\n end\n end\n # create the show object\n {\n venue: \"Rock & Roll Hotel\",\n date: date,\n headliner: grab_text(elem, \".artist_title a\", \"\"),\n support: supports\n }\n end\n end",
"def myitasa_remove_show(show_id, version)\n raise APIError, 'not logged in' if @authcode.nil?\n res = call(\n 'myitasa/removeShowFromPref',\n 'authcode' => @authcode,\n 'show_id' => show_id,\n 'version' => version\n )\n\n res.body['Itasa_Rest2_Server_Myitasa']['removeShowFromPref']['shows'].values\n end",
"def unfavorite_a_show(show_id)\n previous_clicks = Interest.where('user_id' => self.id,\n 'show_id' => show_id).all\n for elt in previous_clicks\n elt.destroy\n end\n end",
"def thetvdb_missing_plex_last_ep(show)\n log_debug\n last_ep = '0;0'\n $plex.episodes[show].keys.each do |season|\n $plex.episodes[show][season].keys.each do |episode|\n last_ep = \"#{season};#{episode}\"\n end\n end\n \n return last_ep.split(';')\nend",
"def set_show\n # @show = Show.find(params[:id])\n # @show = Show.friendly.find(params[:id])\n #@show = Show.includes(:episodes).where(\"episodes.approved\" => true).friendly.find(params[:id])\n @show = Show.includes(:episodes).where(\"episodes.approved\" => true).order('episodes.episode').friendly.find(params[:id])\n end",
"def thetvdb_missing_plex_first_ep(show)\n log_debug\n first_ep = '0;0'\n \n $plex.episodes[show].keys.each do |season|\n $plex.episodes[show][season].keys.each do |episode|\n if first_ep == '0;0' \n first_ep = \"#{season};#{episode}\"\n end\n end\n end\n \n return first_ep.split(';')\nend",
"def remove_show_hls\n @spriteset.remove_group(DISPLAY_TB)\n @spriteset.remove_group(TB_AOE)\n end",
"def find_shows(page)\n # Looks like it is consistent in the classes it uses\n # so grab what we need\n page.search(\".show-details\").map do |elem|\n headliners = elem.search(\".headline a\").map do |headliner|\n headliner.text.strip\n end\n # if its empty then its at the Upcoming which we can skip\n next if headliners.empty?\n\n dateNode = elem.at(\".date\")\n # convert the date so we can see the year\n date = Date.today\n if not dateNode.nil? and not dateNode.text.empty?\n date = convert_date(dateNode.text)\n end\n # the supports are in their own nodes!\n support = elem.search(\".support\").map do |sup|\n sup.text.strip\n end\n # create the show object\n {\n venue: \"Black Cat\",\n date: date,\n headliner: headliners.first,\n support: headliners.drop(1) + support\n }\n end\n end",
"def episodes_track ( show, season, episode, name)\n @episodes[show] = {} if @episodes[show].class.to_s != 'Hash'\n @episodes[show][season] = {} if @episodes[show][season].class.to_s != 'Hash'\n @episodes[show][season][episode] = name\n end",
"def filter_shows(links)\n\t\t\t@filters.each do |f| # Apply each filter\n\t\t\t\tnew_links = links.reject { |name, _link| f.(name) }\n\t\t\t\t# Stop if the filter removes every release\n\t\t\t\tbreak if new_links.size == 0\n\n\t\t\t\tlinks = new_links\n\t\t\tend\n\n\t\t\tlinks\n\t\tend",
"def discardAllTreasures\n vT = Array.new(@visibleTreasures)\n vT.each {|treasure| discardVisibleTreasure(treasure)}\n hT = Array.new(@hiddenTreasures)\n hT.each {|treasure| discardHiddenTreasure(treasure)}\n \n end",
"def fetch_episodes_for_playlist(user)\n all_episodes_array = []\n favorites_on_array = Favorite.where(user_id: user.id, playlist_on_off: \"on\")\n favorites_on_array.each do |favorite_instance|\n all_episodes_array += fetch_episodes_by_id(favorite_instance.show_id)\n end\n add_playlist_to_table(all_episodes_array, user)\nend",
"def destroy\n @trabajador = Trabajador.find(params[:trabajador_id])\n @episode = @trabajador.episodes.find(params[:id])\n @episode.destroy\n redirect_to trabajador_path(@trabajador)\n\n\n end",
"def destroy\n @episode.destroy\n end",
"def episodes \n object.episodes.collect do |episode|\n { \n :episode_code => episode.episode_code, \n :episode_name => episode.episode_name\n }\n end \n end",
"def rem_dead_tracks playlist\n begin\n\t playlist.fileTracks.each do |track|\n\t #puts \"#{track.index}: #{track.location}\"\n\t next unless track.location == nil \n\t puts \"Deleting dead track: #{track.artist} - #{track.album} - #{track.name}\"\n\t @logger.info \"Deleting dead track: #{track.artist} - #{track.album} - #{track.name}\"\n\t track.delete\n\t end\n\t rescue Exception => e\n puts e.message\n end\n end",
"def discardHiddenTreasures(t)\n \n t.each do |x|\n @currentPlayer.discardHiddenTreasure(x)\n @dealer.giveTreasureBack(x)\n \n end\n \n end",
"def getEpisodeToPlay(client)\n\n\t\tbegin\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='海外ドラマ' and @id='textView']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='見放題で楽しめる厳選良作!海外ドラマ編']\")\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recyclerView' and ./preceding-sibling::*[./*[@text='見放題で楽しめる厳選良作!海外ドラマ編']]]/*/*/*[@id='imageView' and ./parent::*[@id='maskLayout']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@id='searchButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=国内ドラマ一覧\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=すべての作品\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=見放題\", 0, 1)\n\t\t\t\tclient.sleep(3000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*[@id='thumbnail'])\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\tend\n\t\t\tclient.swipe2(\"Down\", 250, 2000)\n\t\t\tclient.sleep(3000)\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='エピソードを選択']\")\n\t\t\t\tclient.click(\"NATIVE\", \"text=エピソードを選択\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*/*[@id='download_indicator' and ./parent::*[@id='image_container']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(10000)\n\t\t\t\tHistoryPlay.new.playbackCheck(client)\n\t\t\t\tHistoryPlay.new.leavingPlayer(client)\n\t\t\telse\n\t\t\t\tputs \"::MSG:: This contents does not have episode list!!!\"\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Error occurred while episode playing..\" + e.message\n\t\t\t$obj_rtnrs.returnNG\n\t\tend\t\t\n\t\tclient.sleep(2000)\n\tend",
"def movies\n # .each - visit everything once\n # .select - select only some whole things\n # .filter - synonym for select\n # .reject - opposite of select/filter\n # .map - 1:1 transformation of array\n # turns each one thing into something\n # given: [1, 2, 3].map {|n| n*n} \n # get: [1, 4, 9]\n self.showings.map do |showing|\n showing.movie\n end.uniq\n end",
"def import!\n each_mapping do |anime, series_id, season_number|\n begin\n series = get_series(series_id)\n episodes = get_episodes(series_id, season_number)\n rescue NotFound\n anime.mappings.where(external_id: tvdb_id).first.destroy!\n next\n end\n\n next unless episodes\n\n next if anime.episode_count && (anime.episode_count - episodes.count).abs > 2\n if anime.episode_count\n episodes = episodes[0..anime.episode_count - 1] if anime.episode_count\n else\n anime.update_unit_count_guess(episodes.count)\n end\n\n # creating/updating the episode\n process_series_data(series, anime)\n process_episode_data(episodes, anime, series_id)\n end\n end",
"def remove_weekly_alerts_if_genre_all_edit \n WeeklyAlert.destroy_all([\"id != ? AND user_id = ?\" , id, user_id]) if Genre.find(genre_id).name == \"all\"\n end",
"def index\n @series = Series.find(params[:series_id].to_i)\n @new_episodes = @series.episodes.where(:seen => false).order(\"season desc, episode desc\")\n @seen_episodes = @series.episodes.where(:seen => true).order(\"season desc, episode desc\")\n end",
"def remove_preview_events(events, eventType)\n results = []\n prev = nil\n\n events.each do |r|\n\n if (!prev.nil? and r.event_type == eventType and\n DateTime.strptime(r.created_at).strftime(\"%M\").to_i - DateTime.strptime(prev.created_at).strftime(\"%M\").to_i <= 0)\n # repeat, do nothing\n else\n prev = r\n results << r\n end\n end\n results\n end",
"def no_casting_info\n MovieDatabase.execute(<<-SQL)\n SELECT\n movies.title\n FROM\n movies\n LEFT JOIN \n castings ON castings.movie_id = movies.id\n WHERE\n castings.actor_id IS NULL\n AND movies.yr = 1920\n GROUP BY\n movies.title\n SQL\nend",
"def fix_via_tvdb(episodes)\n re_cache = true\n log(\"attempting to fix name based on tvdb\") if $config[\"settings\"][\"log_level\"] > 4\n @name = episodes[@show][@season][@number] if episodes[@show][@season]\n ap episodes[@show] if $config[\"settings\"][\"log_level\"] > 3 \n\n if not @name.nil? and @name != \"\"\n re_cache = false\n @name = CGI.unescapeHTML(@name)\n @name.gsub!(/\\//,'-')\n @name.gsub!(/\\?/,'')\n @name.gsub!(/\\:/,' ')\n @name.gsub!(/\\s+$/,'') \n @show.gsub!(/\\:/,'')\n @number.gsub!(/^/,'0') if @number.to_i < 10 and @number.to_i != 0\n\n @name = \"#{@show_on_fs} [#{@season}x#{@number}] #{@name}\" \n @name.gsub!(/\\s\\s/,' ') \n orig = @original_file\n @file = File.dirname(orig) + \"/\" + @name + File.extname(File.basename(orig))\n\n #FileUtils.mv(orig,@file,$options) if orig.downcase != @file.downcase\n if orig != @file and $config[\"settings\"][\"fs_case_sensitive\"] == true\n log \"fix_via_tvdb: #{orig} to #{@file}\" if $config[\"settings\"][\"log_level\"] > 1 \n FileUtils.mv(orig,@file,$options) \n @original_file = @file\n elsif orig.downcase != @file.downcase\n log \"fix_via_tvdb: #{orig} to #{@file}\" if $config[\"settings\"][\"log_level\"] > 1\n begin\n FileUtils.mv(orig,@file,$options) if not File.exist? @file \n rescue => e\n log(\"error: problem with target, reason #{e.to_s}\")\n exit 1\n end\n @original_file = @file\n end\n end\n re_cache\n end",
"def index\n @tv_shows = TvShow.all\n end",
"def unprepare_mega_evolve(pokemon)\n @mega_evolved_trainer_ids.delete(pokemon.trainer_id)\n @prepared_mega_evolve.delete_if { |cell| cell.first == pokemon }\n end",
"def clean_recommendations(selections)\n selections.each do |track|\n details = track.split(' by ')\n song = RSpotify::Track.search(\"#{details[0]} #{details[1]}\", limit: 1).first\n song_details(song)\n end\n update_file\n end",
"def destroy\n @tv_episode = TvEpisode.find(params[:id])\n @tv_episode.destroy\n\n respond_to do |format|\n format.html { redirect_to tv_episodes_url }\n format.json { head :no_content }\n end\n end",
"def index\n @admin_posts = Post.where(\"type <> 'VideoPost'\")\n end",
"def unknown_actors_2012\n MovieDatabase.execute(<<-SQL)\n SELECT movies.id, movies.title\n FROM movies\n LEFT OUTER JOIN castings on movies.id = castings.movie_id\n WHERE castings.actor_id IS NULL\n GROUP BY movies.id\n\nSQL\nend",
"def remove_idea_events(events)\n events.delete_if(&:idea?)\nend",
"def discardVisibleTreasures(t)\n \n t.each do |x|\n @currentPlayer.discardVisibleTreasure(x)\n @dealer.giveTreasureBack(x)\n end\n \n end",
"def get_shows_by_name(showname)\n videos = get_listings.videos.select do |s|\n !s.copy_protected? && s.title =~ /#{showname}/\n end\n videos.sort_by(&:time_captured)\n end",
"def discardAllTreasures\n \n end",
"def latest_episode(index=0)\n latest_ep = nil\n\n\n# self.live_episodes.each do |ep|\n## puts \"#{__FILE__}:#{__LINE__} #{__method__} #{ep.release_date_unix} - #{ep.name}\"\n# latest_ep = ep if latest_ep == nil\n# latest_ep = ep if latest_ep.release_date_unix.to_i < ep.release_date_unix.to_i\n# end\n self.released_episodes.each_with_index do |ep, idx|\n latest_ep = ep if idx == index\n end\n\n sd = ShowDate.new(latest_ep.release_date_unix.to_i) if latest_ep\n sd = ShowDate.new(Time.new.to_i) unless latest_ep\n\n# puts \"#{__FILE__}:#{__LINE__} #{__method__} SD: #{sd.timestamp} - #{self.name} - #{sd.inspect} - #{sd.month_str}, #{sd.day_of_month} ,#{sd.year}\"\n\n sd\n end",
"def remove_all_vlans\n remove_all_bridge_domains\n remove_all_svis\n Vlan.vlans.each do |vlan, obj|\n # skip reserved vlan\n next if vlan == '1'\n next if node.product_id[/N5K|N6K|N7K/] && (1002..1005).include?(vlan.to_i)\n obj.destroy\n end\n end",
"def show\n @query = Episode.where(podcast_id: @podcast.id).search(params[:q])\n if params[:q]\n @query.sorts = 'pub_date desc' if @query.sorts.empty?\n @episodes = @query.result.paginate(:page => params[:page], :per_page => 15)\n else\n @episodes = @podcast.episodes.order(pub_date: :desc).paginate(:page => params[:page], :per_page => 15)\n end\n end",
"def remove_from_list *list\n @show = @show - TinyPng::Path.get_all(list)\n end",
"def shows_at_venue_per_day(week_day)\n festival_start = find_days_start_time(week_day)\n shows_at_venue = Event.where(\"venue_id\" => @venue.id)\n @shows_at_venue_per_day = []\n shows_at_venue.each do |show|\n if show.weekday == week_day\n @shows_at_venue_per_day << show\n end\n end\n if @shows_at_venue_per_day != []\n @shows_at_venue_per_day.sort_by! { |obj| obj.start_date_time}\n shows_with_blanks(festival_start)\n fill_out_final_blanks(festival_start)\n end\n return @shows_with_blanks\n end",
"def index\n @shows = Show.all\n response = HTTParty.get('https://api.setlist.fm/rest/1.0/artist/94f8947c-2d9c-4519-bcf9-6d11a24ad006/setlists?p=1', headers: {\"Accept\" => \"application/json\", \"x-api-key\": \"X5zdk_R9xhoRkSxvDUDSV1n_1hlGGSRPwaDq\"})\n results = JSON.parse(response.body)\n results[\"setlist\"].each do |show|\n if Venue.find_by(mbid: show[\"venue\"][\"id\"])\n # do nothing\n else\n @venue = Venue.create(mbid: show[\"venue\"][\"id\"], \n name: show[\"venue\"][\"name\"], \n city: show[\"venue\"][\"city\"][\"name\"],\n state: show[\"venue\"][\"city\"][\"state\"],\n country: show[\"venue\"][\"city\"][\"country\"][\"code\"])\n end\n # do some not have venues? check for this\n if @venue\n @show = Show.create(name: show[\"venue\"][\"name\"], event_date: show[\"eventDate\"], venue_id: @venue.id)\n else\n @show = Show.create(name: show[\"venue\"][\"name\"], event_date: show[\"eventDate\"])\n end\n # FIXME - hardcoded for dead & co with 3\n ArtistShow.create(artist_id: 3, show_id: @show.id)\n show[\"sets\"][\"set\"].each do |set|\n # increment sets by 1 for ordering later\n encore = set[\"encore\"] if set[\"encore\"]\n set_num = 1\n @setlist = Setlist.create(number: set_num, encore: encore, show_id: @show.id)\n set[\"song\"].each do |song|\n if song[\"cover\"]\n if Artist.find_by(mbid: song[\"cover\"][\"mbid\"])\n # do nothing\n else\n @artist = Artist.create(name: song[\"cover\"][\"name\"], sort_name: song[\"cover\"][\"sortName\"], mbid: song[\"cover\"][\"mbid\"])\n end\n end\n if @artist\n @song = Song.create(name: song[\"name\"], artist_id: @artist.id) \n else\n @song = Song.create(name: song[\"name\"])\n end\n SetlistSong.create(song_id: @song.id, setlist_id: @setlist.id, position: 1 )\n end\n end\n end\n end",
"def show\n @video = Video.find(params[:id])\n @relateds = []\n @video.relateds.each do |item|\n unless item.wistia.blank?\n @relateds << Video.where(wistia: item.wistia).first\n end\n end\n end",
"def series_lookup(episode)\n if $config.has_key? \"tvdb\" and $config[\"tvdb\"].has_key? \"api_key\" and $config[\"tvdb\"].has_key? \"mirror\"\n #log(\"series_lookup tvdb: #{episode.show}\")\n thetvdb_lookup(episode.show)\n end\nend",
"def shows_with_blanks(festival_start)\n @shows_with_blanks = []\n @current_time_check = festival_start\n i = 0\n until i >= @shows_at_venue_per_day.length\n start_of_show = @shows_at_venue_per_day[i].start_date_time\n find_show_start_time(start_of_show)\n @shows_with_blanks << @shows_at_venue_per_day[i]\n @current_time_check = @shows_with_blanks.last.end_date_time\n check_previous_end_time(start_of_show, end_time_of_previous_show)\n i += 1\n end\n return @shows_with_blanks\n end",
"def destroy\n @episode.destroy\n\n head :no_content\n end",
"def remove_depricated\n self.articles.each do |a|\n unless ((a.created_at + 3.days) > Date.today) \n self.articles.delete(a)\n end\n end\n\tend",
"def remove(movie)\n @items.select! do |m| \n m.title != movie.title && \n m.year != movie.year\n end\n\n self.save_to_file()\n puts \"#{movie.title} has been removed from your watchlist.\\n\".green\n end",
"def show\n \t@season_list = @title.season_list\n \t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n \tif @episode_list.count == 0\n \t\tparams[:season_choice] = \"All\"\n\t\t\t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n\t\tend\n \tlogger.debug @episode_list\n end",
"def index\n # @episodes = Episode.all\n @trabajador = Trabajador.find(params[:trabajador_id])\n @episodes = @trabajador.episodes\n\n end",
"def index\n @articles = Article.visible.where(press_release: 0).sorted.limit(5)\n if I18n.locale == :en\n @articles.reject!{|x| x.title_en.to_s.strip.length == 0 }\n else\n @articles.reject!{|x| x.title_no.to_s.strip.length == 0 }\n end\n end",
"def char_episode\n Char_Episode.all.select{ |char_episode| char_episode.episode == self }\n end",
"def remove_except_follower\n events=$PokemonGlobal.dependentEvents\n $PokemonGlobal.dependentEvents.each_with_index do |event,i|\n next if event[8][/FollowerPkmn/]\n events[i] = nil\n @realEvents[i] = nil\n @lastUpdate += 1\n end\n events.compact!\n @realEvents.compact!\n end",
"def find_dead_tracks playlist\n playlist.fileTracks.each do |track|\n next unless track.location == nil\n puts \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n @logger.info \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n #@dead_track_list << track\n end\n \n #return @dead_track_list\n end",
"def show\n @episode = @trabajador.episodes.reload.find_by abierto: true\n @tests = @trabajador.tests\n render layout: \"ficha_trabajador\"\n end",
"def show\n @article = Article.find(params[:id])\n\n @related = Article.visible.where(press_release: 0).sorted.limit(5)\n @related.reject!{|x| x == @article }\n\n if I18n.locale == :en\n @related.reject!{|x| x.title_en.to_s.strip.length == 0 }\n else\n @related.reject!{|x| x.title_no.to_s.strip.length == 0 }\n end\n end",
"def unknown_actors_2012\n MovieDatabase.execute(<<-SQL)\n SELECT\n movies.id, movies.title\n FROM\n movies\n LEFT JOIN castings ON castings.movie_id = movies.id\n WHERE\n castings.actor_id IS NULL\n AND\n movies.yr = 2012\nSQL\nend",
"def thetvdb_get_show_id(show)\n # so confused why this is here suddenly!\n show.gsub!(/:/,'')\n local_file = show.gsub(/\\*/,'_')\n \n show_id = \"\"\n cache_dir = $script_dir + \"/var/tvdb/\" + local_file\n cache_dir = $config[\"tvdb\"][\"cache_directory\"] + \"/\" + local_file if $config[\"tvdb\"].has_key? \"cache_directory\"\n\n \n FileUtils.mkdir_p(cache_dir) if not File.directory? cache_dir\n cache = cache_dir + \"/\" + show + \".xml\"\n if File.exists? cache and not $opt[\"tvdb-refresh\"]\n parser = XML::Parser.file cache\n begin\n doc = parser.parse\n rescue => err\n log(\"tvdb error: #{err} when retrieving \\'#{show}\\'\")\n return \n end\n else\n log(\"tvdb retrieving show id via www: #{show}\") if $config[\"settings\"][\"log_level\"] > 1\n show_escaped = CGI.escape(show)\n url = $config[\"tvdb\"][\"mirror\"] + '/api/GetSeries.php?&language=en&seriesname=' + show_escaped\n xml_data = http_get(url)\n parser = XML::Parser.string xml_data\n begin\n doc = parser.parse\n rescue => err\n log(\"tvdb error: #{err} when retrieving \\'#{show}\\'\")\n return \n end\n File.open(cache, 'w') do |file| \n file.puts xml_data\n #xml_data.each {|x| file.puts x}\n end\n end\n showIncorrectStatus = false\n \n doc.find('//Data/Series').each do |item|\n find = show\n find = Regexp.escape(show) if show =~ /\\'|\\(|\\&|\\*|\\?/\n \n series_name = item.find('SeriesName')[0].child.to_s\n series_name = CGI.unescapeHTML(series_name)\n pre_regex = '^'\n \n # having a problem matching some shows due to the colon issue above not being able to be used in a filename on fat32\n # this si being commented out as its not working\n #pre_regex = '' if series_name =~ /:/\n # file names can not contain ':' so we need to remove them from possible show names\n series_name.gsub!(/:/,'')\n find.gsub!(/:/,'')\n\n log \"show -> #{show} : looking at show of -> #{series_name}\" if $config[\"settings\"][\"log_level\"] > 1\n\n if series_name =~ /#{pre_regex}#{find}$/i \n show_id = item.find('id')[0].child.to_s\n showIncorrectStatus = false \n end\n\n if show_id == \"\"\n showIncorrectStatus = true\n end\n\n if showIncorrectStatus == true\n newShow = \"#{find}\"\n newShow.gsub!(/(\\s|\\.)(us)$/i,' (us)')\n newShow.gsub!(/(\\s|\\.)(uk)$/i,' (uk)')\n handle_error(\"tvdb error: show \\'#{show}\\' is actually \\'#{newShow}\\' update tv-name-mapping.yaml\") if show != newShow\n end\n end\n if show_id == \"\"\n handle_error(\"tvdb error: can not find id for show \\'#{show}\\'\")\n show_id = false\n end\n show_id\nend",
"def episode; end",
"def episode; end",
"def episode; end",
"def episode; end",
"def update_audi_seats\n @seat_numbers.each do |seat_number|\n eval(\"$AUDI_#{@show_no}_SEATS\").delete_at(eval(\"$AUDI_#{@show_no}_SEATS\").index(seat_number))\n end\n end",
"def get_all_index_links_to_each_vland_show\n \t\t# index link for shows\n \t\tresp = get_resp(self.url)\n \t\tshow_index_link = self.url + resp.match(/\"\\/([^\"]*\\/shows)/)[1]\n \t\t#should probbly store this on something but yolo\n \t\tresp_shows = get_resp(show_index_link)\n \t\t# create shows by urls\n \t\tresp_shows.scan(/href=\"([^\"]*show\\/[^\"]*)/).uniq.each do |show_url|\n \t\t\tshow=Show.find_or_initialize_by(url: \"https:\" + show_url.to_s.gsub(/[\"\\[\\]]/,\"\"))\n \t\t\tif show.new_record?\n \t\t\t\tshow.content_provider_id = self.id\n \t\t\t\tshow.save!\n \t\t\tend\n \t\tend\n \tend",
"def get_episode_info\n\n\t\tbegin\n\t\t\turl = source_url\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/miss-undercover,5cd28786818965652bf912ab.html\"\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/monitor,5cda852e81896518171f509c.html\"\n\t\t\tdoc \t\t\t= send_request(url)\n\t\t\tdata \t\t\t= doc.css(\"article.broadcast-detail\")\n\t\t\t# header \t\t= doc.css(\"header.broadcast-detail__header\")\n\t\t\t# duration \t\t= header.css(\"div.text-wrapper span.text-row\")[1].text[-7..-2] rescue nil\n\t\t\tchannel \t\t= doc.css(\"span.tv-show-label__channel\").text\n\t\t\tvideo \t\t\t= get_video_url(doc)\n\t\t\tdescription = doc.css(\"section.broadcast-detail__description p\").text.delete(\"\\\"\").delete(\"\\r\").delete(\"\\n\")\n\t\t\tcast \t\t\t= doc.css(\"section.cast dl\")\n\t\t\tcasts \t\t\t= get_cast(cast[0])\n\t\t\tactors \t\t\t= get_cast(cast[1])\n\t\t\tthumb = doc.css('div.editorial-rating')[0].values[0].split(\" \")[1] rescue nil\n\t\t\t# transmitter_valid(channel)\n\t\t\timage = doc.css(\".broadcast-detail__stage img\").first.attributes[\"src\"].value rescue []\n\t self.program.update(genre: casts[\"Genre\"]) if (casts[\"Genre\"].present? && program.genre.nil?)\n\t\t\t\n\t\t\tparam = {is_scraped: true} \n\t\t\tparam.merge!(preview_video_url: video) if video.present?\n\t\t\tself.update(param)\n\n\t self.episode_infos.create(description: description, country: casts[\"Land\"], year: casts[\"Jahr\"],age_rating: casts[\"Altersfreigabe\"], director: casts[\"Regie\"], producer: casts[\"Produzent\"], script: casts[\"Drehbuch\"], camera: casts[\"Kamera\"], music: casts[\"Musik\"], original_title: casts[\"Originaltitel\"], actors: actors ,thumb: thumb, image_urls: image)\n\t get_rating(doc)\n\t rescue StandardError => e\n\t \tRails.logger.info \"================================================\"\n\t \tRails.logger.info \"Having some issues during storing episode info.\"\n\t \tRails.logger.info \"#{e}\"\n\t end\n\tend",
"def episode_list(sid)\n xml = get('/feeds/episode_list.php', :query => {:sid => sid})\n xml[\"Show\"]\n end",
"def ditch_crap(clean_items)\n clean_items.delete_if do |item|\n if !!(item[\"title\"].match(/proxy/i)) || !!(item[\"title\"].match(/altered/i))\n true\n end\n end\n clean_items\n end",
"def clean_test\n video=Video.find(self.id)\n video.attach_file_name = nil\n video.attach_content_type = nil\n video.attach_file_size = nil\n video.attach_updated_at = nil\n video.video_estado_id = nil\n video.transcoder_job_id = nil\n video.conversion_status = nil\n video.revisado = false\n video.identidad_verificada = nil\n video.intentos = 0\n video.save(validate:false)\n ##self.save(validate:false)\n Evaluacion.where(video_id: self.id).map{|x|x.delete}\n Reporte.where(video_id: self.id).map{|x|x.delete}\n end",
"def prominence!\n @filters[:prominent].each do |filter|\n @query = Ydl::Videos.where(filter => @options[filter])\n return @query if @query.any?\n end\n end",
"def show_all_notes_db(db)\n db.all_notes.select { |note| !note[\"deleted\"] }\n .each { |note| show_note(note) }\nend",
"def destroy\n @tv_show = TvShow.find(params[:id])\n @tv_show.destroy\n\n respond_to do |format|\n format.html { redirect_to tv_shows_url }\n format.json { head :no_content }\n end\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def summon_removal\n # remove all expired pets\n @pets.clone.each {|p| @pets.delete(p) if p.terminate}\n # remove all expired monsters\n @monsters.clone.each {|m| @monsters.delete(m) if m.terminate}\n end",
"def discardNecklaceIfVisible\n @visibleTreasures.each do |vt|\n if vt.kind == TreasureKind::NECKLACE\n CardDealer.instance.giveTreasureBack(vt)\n @visibleTreasures.delete(vt)\n break\n end\n end\n end",
"def denzel_washington_non_starring_films\n MovieDatabase.execute(<<-SQL)\n SELECT movies.title\n FROM movies\n JOIN castings on movies.id = castings.movie_id\n JOIN actors on actors.id = castings.actor_id\n WHERE actors.name = 'Denzel Washington' AND castings.ord != 1\n ORDER BY movies.title\nSQL\nend",
"def cleanup\n show do\n title \"Discard stripwells\"\n note \"Please discard all stripwells.\"\n operations.each do |op|\n op.input(\"PCR\").collection.mark_as_deleted\n end\n end\n \n show do\n title \"Make sure machine in parked position\"\n check \"Click \\\"Processes\\\" -> \\\"Parked\\\" icon.\"\n image \"Actions/Fragment Analyzer/frag_an_parked.JPG\"\n end\n end",
"def index\n @showtimes = Showtime.all.sort_by(&:start_time).group_by{ |showtime| showtime.start_time.to_date}.transform_values do |shows|\n shows.group_by{ |showtime| showtime.movie.title }\n end\n end",
"def get_upcoming_episodes(seriesid)\n # See if we already have both a name for the series, if there exists a name episodes should be updated\n seriesInformation = SeriesInformation.find_by seriesid: seriesid\n upcomingEpisodes = EpisodeInformation.where(seriesid: seriesid)\n if seriesInformation.nil?\n seriesInformation,upcomingEpisodes = initialize_cache_and_return_data(seriesid)\n end\n # If, for some reason, neither database lookup or cache updating didn't return an array, create one.\n if upcomingEpisodes.nil?\n upcomingEpisodes = Array.new\n end\n upcoming_episodes_for_return = Array.new\n # Go through list of episodes found\n for j in 0..(upcomingEpisodes.length-1)\n # Check if episode is still in the future\n if(upcomingEpisodes[j].firstaired > Date.today.prev_day)\n upcoming_episodes_for_return.push(upcomingEpisodes[j])\n else\n # If not, delete it (should be safe to do here as the data is only removed from database, not from array)\n # NOTE: This is the only place old episodes are pruned out when updates are not occurring. This should probably also be in a cleanup function. \n upcomingEpisodes[j].delete\n end\n end\n return upcoming_episodes_for_return\n end",
"def destroy\n @episode = Episode.find(params[:id])\n movie = @episode.movie\n flash[:notice] = \"剧集#{@episode.title} 已经被删除\"\n \n @episode.destroy\n\n respond_to do |format|\n format.html { redirect_to movie_url(movie) }\n format.json { head :no_content }\n end\n end",
"def episodes(options)\n # Set default options unless defined in the options hash\n options[:content_type] = 'episode'\n options[:include] = 2 unless options.key?(:include)\n options[:order] = '-fields.releaseDate' unless options.key?(:order)\n\n objects('Episode', options)\n end"
] |
[
"0.65190876",
"0.6492478",
"0.6420633",
"0.62164086",
"0.5919018",
"0.5781975",
"0.5666205",
"0.5646294",
"0.5546408",
"0.55212903",
"0.55133045",
"0.55097985",
"0.55067444",
"0.54902107",
"0.5479884",
"0.54502773",
"0.53975314",
"0.5380555",
"0.5366146",
"0.5346242",
"0.5327314",
"0.5327177",
"0.5318655",
"0.5288471",
"0.52625805",
"0.5260116",
"0.51918393",
"0.51697433",
"0.5168675",
"0.5166291",
"0.51610017",
"0.51253873",
"0.5122708",
"0.51122457",
"0.5104603",
"0.5096264",
"0.5092284",
"0.5085231",
"0.5060241",
"0.50479704",
"0.5046886",
"0.5040829",
"0.5040091",
"0.50365025",
"0.5032721",
"0.5031274",
"0.50280446",
"0.50244594",
"0.50200933",
"0.5016967",
"0.5003337",
"0.49990946",
"0.49765092",
"0.4971163",
"0.49629408",
"0.4959398",
"0.4949219",
"0.49460346",
"0.4941955",
"0.49413255",
"0.49124408",
"0.4912383",
"0.49100485",
"0.49078047",
"0.48998302",
"0.4895516",
"0.48936602",
"0.48881224",
"0.4887702",
"0.48840234",
"0.48838294",
"0.48833215",
"0.48805836",
"0.48703116",
"0.48703116",
"0.48703116",
"0.48703116",
"0.4868058",
"0.48586443",
"0.48559266",
"0.48532286",
"0.48457485",
"0.48380226",
"0.48375887",
"0.48355916",
"0.48355716",
"0.4835297",
"0.4835297",
"0.4835297",
"0.4835297",
"0.4835297",
"0.4835297",
"0.48306066",
"0.48206046",
"0.48171377",
"0.48168892",
"0.48102993",
"0.47864008",
"0.47863817",
"0.4785051"
] |
0.59198904
|
4
|
get the missing episodes based on thetvdb
|
def get
log_debug
$plex.episodes.keys.each do |show|
thetvdb_missing_last_process(show)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def thetvdb_missing_plex_found(show,season,episode)\n plex_has = false\n \n # remove shows that we have\n if $plex.episodes.has_key? show \n if $plex.episodes[show].has_key?(season.to_i)\n if $plex.episodes[show][season.to_i].has_key?(episode.to_i)\n plex_has = true \n end\n end\n end\n plex_has\nend",
"def thetvdb_missing_range(season, season_first, episode, episode_first)\n missing = true\n \n # for now we are only interested in episodes greater than our first one and \n # inclusive of the whole season\n if season.to_i < season_first.to_i \n missing = false\n end\n \n if $config[\"missing\"][\"start_at_first_found\"]\n if episode_first.to_i > episode.to_i \n missing = false \n end\n end\n \n missing\nend",
"def thetvdb_missing_last_process(show)\n log_debug\n \n $thetvdb.show(show)\n\n season_last, episode_last = thetvdb_missing_plex_last_ep(show)\n season_first, episode_first = thetvdb_missing_plex_first_ep(show)\n log_debug(\"#{show} start s#{season_first}e#{episode_first} : last s#{season_last}e#{episode_last}\")\n\n if $thetvdb.episodes.has_key?(show)\n $thetvdb.episodes[show]['episodes'].keys.each do |season|\n next if season == \"0\"\n \n $thetvdb.episodes[show]['episodes'][season].keys.each do |episode|\n first_aired = $thetvdb.episodes[show]['episodes'][season][episode]['first_aired']\n show_index = show_index(season, episode)\n plex_has = thetvdb_missing_plex_found(show,season,episode)\n missing = thetvdb_missing_range(season, season_first, episode, episode_first)\n missing = false if plex_has\n \n if first_aired =~ /\\w/\n date_available = Date.today\n date_aired = Date.parse first_aired\n if ( date_available > (date_aired + 1) ) and missing\n missing_process show, show_index,\"aired: #{first_aired}\"\n end\n end\n end\n end\n end\nend",
"def episodes_missing_track ( show, season, episode,extra=nil)\n @episodes_missing[show] = {} if @episodes_missing[show].class.to_s != 'Hash'\n @episodes_missing[show][season] = {} if @episodes_missing[show][season].class.to_s != 'Hash'\n @episodes_missing[show][season][episode] = 'missing do something'\n end",
"def watching_episodes\n shows = ::TvShow.watching\n @episodes = episodes.each_with_object([]) do |episode, object|\n show = shows.find{|sh| sh.imdb_id == episode.show.ids.imdb}\n next if show.blank?\n object << episode\n end.uniq{|episode| episode.show.title}\n self\n end",
"def thetvdb_missing_plex_last_ep(show)\n log_debug\n last_ep = '0;0'\n $plex.episodes[show].keys.each do |season|\n $plex.episodes[show][season].keys.each do |episode|\n last_ep = \"#{season};#{episode}\"\n end\n end\n \n return last_ep.split(';')\nend",
"def find_dead_tracks playlist\n playlist.fileTracks.each do |track|\n next unless track.location == nil\n puts \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n @logger.info \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n #@dead_track_list << track\n end\n \n #return @dead_track_list\n end",
"def get_upcoming_episodes(seriesid)\n # See if we already have both a name for the series, if there exists a name episodes should be updated\n seriesInformation = SeriesInformation.find_by seriesid: seriesid\n upcomingEpisodes = EpisodeInformation.where(seriesid: seriesid)\n if seriesInformation.nil?\n seriesInformation,upcomingEpisodes = initialize_cache_and_return_data(seriesid)\n end\n # If, for some reason, neither database lookup or cache updating didn't return an array, create one.\n if upcomingEpisodes.nil?\n upcomingEpisodes = Array.new\n end\n upcoming_episodes_for_return = Array.new\n # Go through list of episodes found\n for j in 0..(upcomingEpisodes.length-1)\n # Check if episode is still in the future\n if(upcomingEpisodes[j].firstaired > Date.today.prev_day)\n upcoming_episodes_for_return.push(upcomingEpisodes[j])\n else\n # If not, delete it (should be safe to do here as the data is only removed from database, not from array)\n # NOTE: This is the only place old episodes are pruned out when updates are not occurring. This should probably also be in a cleanup function. \n upcomingEpisodes[j].delete\n end\n end\n return upcoming_episodes_for_return\n end",
"def get_all_free_episode_links_for_each_show_on_vland\n \t\tShow.all.each do |show|\n \t\t\tputs \"getting epsides for #{show.url}\"\n \t\t\t# sometimes its nice to take a 2-3 sec nap\n \t\t\tsleep(rand(2..3))\n \t\t\tresp = get_resp(show.url)\n \t\t\t# this is the point where I got tired of heavy lifting\n \t\t\thtml_result = Nokogiri::HTML.parse(resp.body)\n \t\t\thtml_result.css(\".entry-card\").each do |clip|\n \t\t\t\t# skip episdes / clips that are not free to watch, may also one day limit it to just episodes.\n \t\t\t\tnext if clip.css(\".unlockable\").first.to_s.include? \"icon-locked\"\n \t\t\t\t# grabs sub link to epsides or clip\n \t\t\t\tepisode_or_clip_url = clip.css(\".cta\").attr(\"href\").to_s\n \t\t\t\t#getting rid of a \"/\" at the start\n \t\t\t\tepisode_or_clip_url[0] = \"\"\n\n \t\t\t\t# lets create some links pertaining to shows and clips from shows\n \t\t\t\tep = Episode.find_or_initialize_by(url: self.url + episode_or_clip_url)\n \t\t\t\tif ep.new_record?\n \t\t\t\t\tep.show_id=show.id\n \t\t\t\t\t#can do fancy stuff here like grab all show episode / clip fields \n \t\t\t\t\tep.save!\n \t\t\t\tend\n \t\t\tend\n \t\tend\n \tend",
"def thetvdb_missing_plex_first_ep(show)\n log_debug\n first_ep = '0;0'\n \n $plex.episodes[show].keys.each do |season|\n $plex.episodes[show][season].keys.each do |episode|\n if first_ep == '0;0' \n first_ep = \"#{season};#{episode}\"\n end\n end\n end\n \n return first_ep.split(';')\nend",
"def thetvdb_get_show_episodes(show_id,show)\n episodes = {}\n local_file = show.gsub(/\\*/,'_')\n cache_dir = $script_dir + \"/var/tvdb/\" + local_file\n cache_dir = $config[\"tvdb\"][\"cache_directory\"] + \"/\" + local_file if $config[\"tvdb\"].has_key? \"cache_directory\"\n cache = cache_dir + \"/\" + show_id + \".xml\"\n \n if File.exists? cache and not $opt[\"tvdb-refresh\"]\n log(\"tvdb retrieving show episodes via cache: #{show} (#{show_id})\") if $config[\"settings\"][\"log_level\"] > 1\n parser = XML::Parser.file cache\n doc = parser.parse\n else\n log(\"tvdb retrieving show episodes via www: #{show} (#{show_id})\") if $config[\"settings\"][\"log_level\"] > 1\n url = $config[\"tvdb\"][\"mirror\"] + '/api/' + $config[\"tvdb\"][\"api_key\"] + '/series/' + show_id + '/all/en.xml'\n xml_data = http_get(url)\n \n parser = XML::Parser.string xml_data\n doc = parser.parse\n \n File.open(cache, 'w') do |file|\n # TODO: odd no idea whats changed here or why\n file.puts xml_data\n #xml_data.split(/\\n/).each {|x| file.puts x}\n end\n end\n\n doc.find('//Data/Episode').each do |item| \n season = item.find('SeasonNumber')[0].child.to_s\n episode = item.find('EpisodeNumber')[0].child.to_s\n name = item.find('EpisodeName')[0].child.to_s\n episodes[show] = Hash.new unless episodes[show].class == Hash\n #episodes[show][\"series name\"] = series_name\n episodes[show][season] = Hash.new unless episodes[show][season].class == Hash\n episodes[show][season][episode] = name\n end\n episodes\nend",
"def no_casting_info\n MovieDatabase.execute(<<-SQL)\n SELECT\n movies.title\n FROM\n movies\n LEFT JOIN \n castings ON castings.movie_id = movies.id\n WHERE\n castings.actor_id IS NULL\n AND movies.yr = 1920\n GROUP BY\n movies.title\n SQL\nend",
"def unknown_actors_2012\n MovieDatabase.execute(<<-SQL)\n SELECT\n movies.id, movies.title\n FROM\n movies\n LEFT JOIN castings ON castings.movie_id = movies.id\n WHERE\n castings.actor_id IS NULL\n AND\n movies.yr = 2012\nSQL\nend",
"def unknown_actors_2012\n MovieDatabase.execute(<<-SQL)\n SELECT movies.id, movies.title\n FROM movies\n LEFT OUTER JOIN castings on movies.id = castings.movie_id\n WHERE castings.actor_id IS NULL\n GROUP BY movies.id\n\nSQL\nend",
"def episodes\n Episode.all.select{ |episode| episode.show == self }\n end",
"def latest_episode(index=0)\n latest_ep = nil\n\n\n# self.live_episodes.each do |ep|\n## puts \"#{__FILE__}:#{__LINE__} #{__method__} #{ep.release_date_unix} - #{ep.name}\"\n# latest_ep = ep if latest_ep == nil\n# latest_ep = ep if latest_ep.release_date_unix.to_i < ep.release_date_unix.to_i\n# end\n self.released_episodes.each_with_index do |ep, idx|\n latest_ep = ep if idx == index\n end\n\n sd = ShowDate.new(latest_ep.release_date_unix.to_i) if latest_ep\n sd = ShowDate.new(Time.new.to_i) unless latest_ep\n\n# puts \"#{__FILE__}:#{__LINE__} #{__method__} SD: #{sd.timestamp} - #{self.name} - #{sd.inspect} - #{sd.month_str}, #{sd.day_of_month} ,#{sd.year}\"\n\n sd\n end",
"def enumerate_missing\n account_snapshots = account.snapshots\n backed_up_snapshots = self.snapshots\n backed_up_snapshot_descriptions = backed_up_snapshots.collect { |bus| bus.description }\n missing = []\n account_snapshots.each do |snapshot|\n new_desc = \"#{account.name} #{snapshot.description}\"\n missing << snapshot if !backed_up_snapshot_descriptions.include?(new_desc) && (VfSnapshots::DESC_REGEX =~ snapshot.description) && snapshot.start_time.to_date > Date.today-( Config.accounts[account.name][:backup][:days] || VfSnapshots::DEFAULT_BACKUP_DAYS )\n end\n missing\n end",
"def fetch_missing\n all_tasks = SlimtimerTask.all\n missing_ids = TimeEntry.all(\n :slimtimer_task_id.not => all_tasks.map(&:id)\n ).map(&:slimtimer_task_id).uniq\n\n log.info \"Trying to get info on #{missing_ids.length} missing tasks\" if missing_ids.length > 0\n missing_ids.each do |task_id|\n task = handle_timeouts(MAX_CONSECUTIVE_TIMEOUTS, \"Loading specific task : #{task_id}\") do\n @st_api.find_task task_id\n end\n\n if task\n SlimtimerTask.update [task]\n else\n log.warn \"Unable to find task id : #{task_id}. Creating an artificial one...\"\n SlimtimerTask.update([\n 'id' => task_id,\n 'name' => \"Missing (#{task_id})\",\n 'hours' => 0,\n 'completed' => false\n ])\n end\n end\n end",
"def display_no_data\n if Movie.find_all.count == 0 and Episode.find_all.count == 0\n log(\"no new media found\")\n end\nend",
"def next_episodes(show, name, id)\n db_show = TvShows.where(:user => session[:username]).where(:name => name).first\n\n if !db_show.nil?\n last_season = TvShows.where(:user => session[:username]).where(:name => name).first.season\n last_episode = TvShows.where(:user => session[:username]).where(:name => name).first.episode\n else\n last_season = 1\n last_episode = 1\n end\n\n current_season = Tmdb::Season.detail(id, last_season)\n if !current_season['episodes'].nil?\n episodes = current_season['episodes'][last_episode.to_i, current_season['episodes'].length]\n\n number_of_seasons = show['number_of_seasons']\n ((last_season.to_i + 1)..number_of_seasons.to_i).each do |season_number|\n season = Tmdb::Season.detail(id, season_number)\n new_episodes = season['episodes'][0, season['episodes'].length]\n episodes.concat(new_episodes)\n end\n episodes\n else\n nil\n end\n end",
"def songs_never_played\n return @tracks.find_all {|s| s.play_count == 0}\n end",
"def episodes_get\n log_debug\n\n # build syntax if we looking for a specific show\n show_wanted = ''\n \n if self.show\n show_wanted = \"and title = '#{self.show}'\"\n end\n \n sql_shows = \"select id,title,guid from metadata_items where metadata_type=2 and library_section_id in (select id from library_sections where section_type = 2) #{show_wanted} order by title\" \n \n sql_select(sql_shows).each do |row_shows|\n\n sql_seasons = \"select id,\\\"index\\\" from metadata_items where metadata_type=3 and parent_id=#{row_shows[0]} order by \\\"index\\\"\"\n sql_select(sql_seasons).each do |row_seasons|\n show = row_shows[1]\n season = row_seasons[1]\n guid = row_shows[2] \n \n sql_episodes = \"select \\\"index\\\",title, id from metadata_items where metadata_type=4 and parent_id=#{row_seasons[0]} order by \\\"index\\\"\"\n sql_select(sql_episodes).each do |row_episodes|\n episode = row_episodes[0]\n name = row_episodes[1]\n metadata_item_id = row_episodes[2]\n \n #puts \"metadata_item_id : #{metadata_item_id}\"\n episodes_track show, season, episode, name\n found_debug show, season, episode, name \n \n sql_items = \"select id from media_items where metadata_item_id = #{metadata_item_id}\"\n sql_select(sql_items).each do |row_items|\n media_items_id = row_items[0]\n # puts \"media_items_id : #{media_items_id}\"\n \n sql_parts = \"select file from media_parts where media_item_id = #{media_items_id}\"\n sql_select(sql_parts).each do |row_parts|\n file = row_parts[0]\n # puts \"file : #{file}\"\n shows_track show, guid, season, file\n \n end\n \n end\n\n \n end\n end\n end\n\n end",
"def print_unused(db)\n\tact_list = db.execute(\"SELECT * FROM activities\")\n\ttodo_list = db.execute(\"SELECT activity_id FROM todo\")\n\tputs \"\\nActivities Available (i.e. Not Being Used):\"\n\tputs '*~'*20+'*'\n\tact_list.each { |act| \n\t\texists = false\n\t\ttodo_list.each{ |todo_act| \n\t\t\texists = true if act[\"id\"] == todo_act[\"activity_id\"]\n\t\t}\n\t\tputs \"#{act['id']} - #{act['name']}\" if !exists \n\t}\nend",
"def shows_with_blanks(festival_start)\n @shows_with_blanks = []\n @current_time_check = festival_start\n i = 0\n until i >= @shows_at_venue_per_day.length\n start_of_show = @shows_at_venue_per_day[i].start_date_time\n find_show_start_time(start_of_show)\n @shows_with_blanks << @shows_at_venue_per_day[i]\n @current_time_check = @shows_with_blanks.last.end_date_time\n check_previous_end_time(start_of_show, end_time_of_previous_show)\n i += 1\n end\n return @shows_with_blanks\n end",
"def get_unseen_atoms(opts = {})\n @hive_party.post('/atom_search', opts) unless opts[:application].nil?\n end",
"def unknown_urls\n\t\tr = Array.new\n\t\tself.latest( @conf.latest_limit ) do |diary|\n\t\t\trefs = DispRef2Refs.new( diary, @setup )\n\t\t\th = refs.urls( DispRef2URL::Antenna )\n\t\t\th.each_key do |url|\n\t\t\t\tnext unless @setup['normal-unknown.title.regexp'] =~ h[url][2]\n\t\t\t\tnext if DispRef2String::url_match?( url, @setup.no_referer )\n\t\t\t\tnext if DispRef2String::url_match?( url, @setup['reflist.ignore_urls'] )\n\t\t\t\tr << url\n\t\t\tend\n\t\t\th = nil\n\t\t\trefs.urls( DispRef2URL::Unknown ).each_key do |url|\n\t\t\t\tnext if DispRef2String::url_match?( url, @setup.no_referer )\n\t\t\t\tnext if DispRef2String::url_match?( url, @setup['reflist.ignore_urls'] )\n\t\t\t\tr << url\n\t\t\tend\n\t\tend\n\t\tr.uniq\n\tend",
"def missed_appointments\n appointments = Observation.joins(:encounter)\n .merge(appointment_encounters)\n .where.not(person_id: referral_patients.select(:person_id))\n .where(concept: ConceptName.where(name: 'Appointment date').select(:concept_id))\n .where('value_datetime BETWEEN ? AND ? AND encounter.program_id = ?',\n @start_date.strftime('%Y-%m-%d 00:00:00'),\n @end_date.strftime('%Y-%m-%d 23:59:59'), 1)\n .group(:person_id)\n\n appointments.each_with_object([]) do |appointment, patients|\n patient = missed_appointment?(appointment)\n\n patients << patient unless patient.blank?\n end\n end",
"def fetch_episodes_for_playlist(user)\n all_episodes_array = []\n favorites_on_array = Favorite.where(user_id: user.id, playlist_on_off: \"on\")\n favorites_on_array.each do |favorite_instance|\n all_episodes_array += fetch_episodes_by_id(favorite_instance.show_id)\n end\n add_playlist_to_table(all_episodes_array, user)\nend",
"def all_eps(query, offset)\n episodes_arr = []\n results = 10\n num = offset\n\n while results == 10\n\n response = HTTParty.get \"https://listennotes.p.mashape.com/api/v1/search?len_min=10&offset=#{num}&only_in=title&published_after=0&q=#{query}&sort_by_date=0&type=episode\",\n headers:{\n 'X-Mashape-Key' => ENV['MASHAPE_KEY'],\n \"Accept\" => \"application/json\"\n }\n #episodes_arr << response[\"results\"] #adds the current results to the array. Nope..\n response[\"results\"].each { |r| episodes_arr << r}\n num += response[\"count\"].to_i #increases the offset by the number of results that we just found\n \n count = episodes_arr.count\n puts \"There are now #{count} in the array\"\n results = response[\"count\"]\n puts \"The latest lookup has #{results} results in there. \"\n\n end\n return episodes_arr\n end",
"def import!\n each_mapping do |anime, series_id, season_number|\n begin\n series = get_series(series_id)\n episodes = get_episodes(series_id, season_number)\n rescue NotFound\n anime.mappings.where(external_id: tvdb_id).first.destroy!\n next\n end\n\n next unless episodes\n\n next if anime.episode_count && (anime.episode_count - episodes.count).abs > 2\n if anime.episode_count\n episodes = episodes[0..anime.episode_count - 1] if anime.episode_count\n else\n anime.update_unit_count_guess(episodes.count)\n end\n\n # creating/updating the episode\n process_series_data(series, anime)\n process_episode_data(episodes, anime, series_id)\n end\n end",
"def index\n @series = Series.find(params[:series_id].to_i)\n @new_episodes = @series.episodes.where(:seen => false).order(\"season desc, episode desc\")\n @seen_episodes = @series.episodes.where(:seen => true).order(\"season desc, episode desc\")\n end",
"def all_movies_not_on_a_list\n movie_listing_ids = listings.pluck(:movie_id).uniq\n all_movies.where.not(id: movie_listing_ids)\n end",
"def missing_list\n list = []\n active_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n end",
"def add_episode_to_podcasts\n \tPodcast.all.each do |podcast|\n show_hash = Scraper.scrape_show_page(podcast.show_page_url)\n \t podcast.add_episode_name(show_hash)\n \tend\n end",
"def get_predictable_items_for_invalidated_predictions\n items = []\n stages = get_stages_to_delete_predictions_for\n return items if stages.empty?\n\n stages.each do |stage|\n set = @contest.set(\"Teams through to #{stage.description}\")\n set.predictable_items.each {|item| items << item.id} if set\n end\n set = @contest.set(\"Third Place Team\")\n items << set.predictable_items.first.id if set\n set = @contest.set(\"Winner Team\")\n items << set.predictable_items.first.id\n items.uniq\n end",
"def not_delivered\n PeriodDocument.scanned.where(\"scanned_at >= ?\", 30.days.ago).select do |scan|\n result = false\n\n temp_pack = TempPack.where(name: scan.name).first\n\n if temp_pack\n # NOTE minus 10 days because PPP delivers a few days before entering the information inside iDocus\n result = temp_pack.temp_documents.scan.where(\"created_at >= ?\", scan.scanned_at-10.days).empty?\n else\n result = true\n end\n\n print (result ? '!' : '.')\n\n result\n end.map(&:name)\n end",
"def retrieve_unused_artifacts_by_age_test\n return [JSON.parse('{\"uri\": \"keeper2\"}'), JSON.parse('{\"uri\": \"a1\"}'), JSON.parse('{\"uri\": \"keeper3\"}'), JSON.parse('{\"uri\": \"a2\"}'), JSON.parse('{\"uri\": \"a3\"}'), JSON.parse('{\"uri\": \"keeper1\"}')]\nend",
"def series_lookup(episode)\n if $config.has_key? \"tvdb\" and $config[\"tvdb\"].has_key? \"api_key\" and $config[\"tvdb\"].has_key? \"mirror\"\n #log(\"series_lookup tvdb: #{episode.show}\")\n thetvdb_lookup(episode.show)\n end\nend",
"def show\n puts \"++++++++ star#show\"\n @star = Star.find(params[:id])\n @episodes = @star.episodes\n #@episode = Episode.new\n #@podcasts = Podcast.all #we don't need all the podcasts.\n\n star_query = @star.name.strip.gsub(/\\s+/, \"+\")\n\n #this works, but super innefficient. \n def all_eps(query, offset)\n episodes_arr = []\n results = 10\n num = offset\n\n while results == 10\n\n response = HTTParty.get \"https://listennotes.p.mashape.com/api/v1/search?len_min=10&offset=#{num}&only_in=title&published_after=0&q=#{query}&sort_by_date=0&type=episode\",\n headers:{\n 'X-Mashape-Key' => ENV['MASHAPE_KEY'],\n \"Accept\" => \"application/json\"\n }\n #episodes_arr << response[\"results\"] #adds the current results to the array. Nope..\n response[\"results\"].each { |r| episodes_arr << r}\n num += response[\"count\"].to_i #increases the offset by the number of results that we just found\n \n count = episodes_arr.count\n puts \"There are now #{count} in the array\"\n results = response[\"count\"]\n puts \"The latest lookup has #{results} results in there. \"\n\n end\n return episodes_arr\n end\n\n if @star.last_search == nil\n s = @star\n s.last_search = Date.today - 10.days\n puts s.last_search\n s.save\n end\n\n l = @star.last_search < (Date.today - 2.days)\n puts l \n #works\n\n if l == true \n many_episodes = all_eps(star_query, 0)\n many_episodes.select! do |e| \n limit = Date.today - 3.years\n def comparable_date(f)\n sec = (f[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n end\n comparable_date(e) > limit\n end #holy shit this works! Needs cleanup\n\n #save each episode - works\n many_episodes.each do |ep|\n new_ep = Episode.new\n pod_name = ep[\"podcast_title_original\"]\n pod = Podcast.find_or_create_by(name: pod_name)\n new_ep.star_id = @star.id\n new_ep.podcast_id = pod.id\n new_ep.title = ep[\"title_original\"]\n new_ep.description = ep[\"description_original\"]\n new_ep.api_id = ep[\"id\"]\n sec = (ep[\"pub_date_ms\"].to_f / 1000).to_s\n dform = Date.strptime(sec, '%s')\n new_ep.release_date = dform\n new_ep.save\n end\n\n @episodes_arr = many_episodes.sort_by { |e| e[\"pub_date_ms\"]}.reverse\n @star.last_search = Date.today\n @star.save\n else\n puts \"WE DIDN RUN THE SEARCH\"\n end\n @display_episodes = @episodes.where(display: true)\n end",
"def new_episodes( season )\n return @seasons[season][1].flatten\n end",
"def episodes \n object.episodes.collect do |episode|\n { \n :episode_code => episode.episode_code, \n :episode_name => episode.episode_name\n }\n end \n end",
"def upcoming_dvd_releases\n return @badfruit.parse_movies_array(JSON.parse(@badfruit.get_lists_action(\"upcoming_dvds\")))\n end",
"def larry_all_episodes (larry_david)\n all_shows = []\n Episode.all.map do |episode|\n show = { character_id: larry_david.id, episode_id: episode.id}\n all_shows.push(show)\n end\n Show.create(all_shows)\nend",
"def unregistered_events\n tournament\n .schedules\n .keep_if { |s| s.is_scheduled_online? && s.division == division } -\n sign_ups.map{|x| x.try(:timeslot).try(:schedule) }\n end",
"def not_in_season\n OfferSeason.find(:all) - OfferSeason.find_by_id(1)\n end",
"def missing_list\n list = []\n regular_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n end",
"def get_episode_info\n\n\t\tbegin\n\t\t\turl = source_url\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/miss-undercover,5cd28786818965652bf912ab.html\"\n\t\t\t# url = \"https://www.tvspielfilm.de/tv-programm/sendung/monitor,5cda852e81896518171f509c.html\"\n\t\t\tdoc \t\t\t= send_request(url)\n\t\t\tdata \t\t\t= doc.css(\"article.broadcast-detail\")\n\t\t\t# header \t\t= doc.css(\"header.broadcast-detail__header\")\n\t\t\t# duration \t\t= header.css(\"div.text-wrapper span.text-row\")[1].text[-7..-2] rescue nil\n\t\t\tchannel \t\t= doc.css(\"span.tv-show-label__channel\").text\n\t\t\tvideo \t\t\t= get_video_url(doc)\n\t\t\tdescription = doc.css(\"section.broadcast-detail__description p\").text.delete(\"\\\"\").delete(\"\\r\").delete(\"\\n\")\n\t\t\tcast \t\t\t= doc.css(\"section.cast dl\")\n\t\t\tcasts \t\t\t= get_cast(cast[0])\n\t\t\tactors \t\t\t= get_cast(cast[1])\n\t\t\tthumb = doc.css('div.editorial-rating')[0].values[0].split(\" \")[1] rescue nil\n\t\t\t# transmitter_valid(channel)\n\t\t\timage = doc.css(\".broadcast-detail__stage img\").first.attributes[\"src\"].value rescue []\n\t self.program.update(genre: casts[\"Genre\"]) if (casts[\"Genre\"].present? && program.genre.nil?)\n\t\t\t\n\t\t\tparam = {is_scraped: true} \n\t\t\tparam.merge!(preview_video_url: video) if video.present?\n\t\t\tself.update(param)\n\n\t self.episode_infos.create(description: description, country: casts[\"Land\"], year: casts[\"Jahr\"],age_rating: casts[\"Altersfreigabe\"], director: casts[\"Regie\"], producer: casts[\"Produzent\"], script: casts[\"Drehbuch\"], camera: casts[\"Kamera\"], music: casts[\"Musik\"], original_title: casts[\"Originaltitel\"], actors: actors ,thumb: thumb, image_urls: image)\n\t get_rating(doc)\n\t rescue StandardError => e\n\t \tRails.logger.info \"================================================\"\n\t \tRails.logger.info \"Having some issues during storing episode info.\"\n\t \tRails.logger.info \"#{e}\"\n\t end\n\tend",
"def missing_children\n return [] unless name && date\n\n @missing_children ||= SingleDayEvent.where(parent_id: nil).where(name: name).year(date.year)\n end",
"def missing_data\n only_missing.to_a\n end",
"def not_scheduled_applications\n accepted_applications.select do |a|\n been_in_stage_for(a, 7.days.ago)\n end\n end",
"def obsolete_data_sets\n data_sets.take_while { |ds| ds != active_data_set }.slice(0...-1)\n end",
"def obsolete_data_sets\n data_sets.take_while { |ds| ds != active_data_set }.slice(0...-1)\n end",
"def step_videos_without_uuid\n StepVideo.where(uuid: nil)\n end",
"def index\n @episodes = Episode.all\n @views_chart = get_all_views(@episodes)\n @change_chart = get_all_differences(@episodes)\n end",
"def active_exchanges_without_gifts\n Exchange.find_by_sql([\"SELECT exchanges.* FROM exchanges \n JOIN matches ON exchanges.id = matches.exchange_id \n JOIN users ON matches.santa_id = users.id\n WHERE exchanges.match_date < :todays_date \n AND exchanges.exchange_date > :todays_date \n AND users.id = :user_id \n AND users.id = matches.santa_id\n AND matches.gift_id is NULL\", \n :todays_date => Date.today, \n :user_id => self.id])\n end",
"def missing_dp_lpi_records(cadid=false)\n # FIXME - The CONCAT() functions in this query are to ensure that NULL\n # values get coerced into empty strings. In the import CSV, the value\n # |\"\"| is recorded as \"\", whereas || is recorded as NULL, and sometimes\n # one is present in the LGA import and another in the LPI import.\n connection.query(%{\n SELECT title_reference } + (cadid ? \", cadastre_id\" : \"\") + %{\n FROM land_and_property_information_records AS lpi_records\n LEFT JOIN local_government_area_records AS lga_records\n ON lga_records.local_government_area_id = lpi_records.local_government_area_id\n AND lga_records.dp_plan_number = lpi_records.plan_label\n AND CONCAT('', lga_records.dp_section_number) = CONCAT('', lpi_records.section_number)\n AND CONCAT('', lga_records.dp_lot_number) = CONCAT('', lpi_records.lot_number)\n WHERE lpi_records.plan_label LIKE 'DP%%'\n AND lga_records.dp_plan_number IS NULL\n AND lpi_records.local_government_area_id = %d\n AND lpi_records.retired = FALSE\n } % [id])\n end",
"def test_emailer_get_unopened\n\t\tres = DB.exec(\"SELECT id FROM emailer_get_unopened(1)\")\n\t\tassert_equal %w(7 8 9), res.map {|x| x['id']}\n\t\tres = DB.exec(\"SELECT id FROM emailer_get_unopened(3)\")\n\t\tassert_equal 0, res.ntuples\n\t\tres = DB.exec(\"SELECT id FROM emailer_get_unopened(4)\")\n\t\tassert_equal %w(7 8), res.map {|x| x['id']}\n\tend",
"def index\n query = \"https://itunes.apple.com/lookup?id=#{params[:podcast_id]}\"\n feed_url = params[:feedUrl] || itunes_query_results(query)[0]['feedUrl']\n hashed_xml = Crack::XML.parse(open(feed_url).read)['rss']['channel']\n parsed_episodes = parse_episodes(hashed_xml)\n # parsed_episodes = EpisodeLoader.find(feed_url)\n # for DB saving, changing from JSON camelCase to Rails snake_case\n snaked_episodes = parsed_episodes.map(&:to_snake_keys).take(100)\n current_guids = Episode.where(collection_id: params[:podcast_id]).map(&:guid)\n snaked_episodes.each do |episode|\n new_episode(episode) unless current_guids.include?(episode[:guid])\n # new_episode_with_status(episode) unless Episode.find_by_guid(episode[:guid])\n end\n render json: Podcast.find(params[:podcast_id]).episodes\n # render json: parsed_episodes\n end",
"def get_unpublished_books\n @grid_title = \"Not Published\"\n\n # get task 'Production Complete' which is a published book\n published_task = Task.find_by_name(\"Production Complete\")\n workflow_task = published_task.workflow.root\n\n # get all tasks in the workflow that occur before production compelete.\n not_published_tasks = []\n while next_task = workflow_task.next_task\n\n # we don't want to include published_task\n break if next_task.id == published_task.id\n\n not_published_tasks.push next_task.name\n workflow_task = next_task\n end\n @projects = ProjectGridTableRow.includes(project: [:cover_template])\n .where(\"production_task_name in (?)\", not_published_tasks)\n .not_archived\n end",
"def unavailable_players\n players = []\n self.cached_teamsheet_entries.each do |teamsheet_entry|\n if teamsheet_entry.response_status == InviteResponseEnum::UNAVAILABLE\n players << teamsheet_entry.user\n end\n end\n players\n end",
"def show\n @entries = @slideshow.entries.recent.limit(12)\n\n @active_feeds = @slideshow.feeds.order(title: :asc)\n @available_feeds = Feed.where.not(id: @slideshow.feed_ids).order(title: :asc)\n end",
"def missing_player_box_scores\n nba_matchups - player_box_scores.map(&:nba_matchup)\n end",
"def collect_deletable_meetings( season_id )\n # Build up a list of meeting codes for the specified season:\n codes = FinCalendar.where( season_id: season_id ).map{|row| row.goggles_meeting_code }\n # Filter-out the meetings: we need the ones that do not have the results flag\n # triggered and are not enlisted in the calendar:\n deletable_meetings = Meeting.where(\n \"(season_id = ?) AND (code NOT IN (?)) AND (are_results_acquired = 0) AND (is_cancelled = 0)\",\n season_id, codes\n ).to_a\n\n # Discard from the filtered meetings any which have some associated results\n # anyhow:\n deletable_meetings.reject! do |meeting|\n (meeting.meeting_individual_results.count > 0) ||\n (meeting.meeting_relay_results.count > 0)\n end\n\n # Return the list of deletable meetings:\n deletable_meetings\n end",
"def missing_answers\n return @missing_answers if @missing_answers\n answer_for_qing(:rebuild => true)\n @missing_answers = visible_questionings.collect do |qing|\n (answer_for(qing).nil? && qing.required?) ? qing : nil\n end.compact\n end",
"def get_unqual_records\n records = storage_engine.get_all\n qual_records = []\n records.each do |record|\n qual_records << record unless record.qualified?\n end\n qual_records\n end",
"def getEpisodeToPlay(client)\n\n\t\tbegin\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@contentDescription='上へ移動']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@text='海外ドラマ' and @id='textView']\", 0, 1)\n\t\t\tclient.sleep(2000)\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='見放題で楽しめる厳選良作!海外ドラマ編']\")\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recyclerView' and ./preceding-sibling::*[./*[@text='見放題で楽しめる厳選良作!海外ドラマ編']]]/*/*/*[@id='imageView' and ./parent::*[@id='maskLayout']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\telse\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=//*[@id='searchButton']\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=国内ドラマ一覧\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=すべての作品\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"text=見放題\", 0, 1)\n\t\t\t\tclient.sleep(3000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*[@id='thumbnail'])\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\tend\n\t\t\tclient.swipe2(\"Down\", 250, 2000)\n\t\t\tclient.sleep(3000)\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Exception occurrred while finding ELEMENT \" + e.message\n\t\tend\t\t\n\t\tbegin\n\t\t\tif client.isElementFound(\"NATIVE\", \"xpath=//*[@text='エピソードを選択']\")\n\t\t\t\tclient.click(\"NATIVE\", \"text=エピソードを選択\", 0, 1)\n\t\t\t\tclient.sleep(2000)\n\t\t\t\tclient.click(\"NATIVE\", \"xpath=(//*[@id='recycler_view']/*/*/*/*[@id='download_indicator' and ./parent::*[@id='image_container']])[1]\", 0, 1)\n\t\t\t\tclient.sleep(10000)\n\t\t\t\tHistoryPlay.new.playbackCheck(client)\n\t\t\t\tHistoryPlay.new.leavingPlayer(client)\n\t\t\telse\n\t\t\t\tputs \"::MSG:: This contents does not have episode list!!!\"\n\t\t\tend\n\t\trescue Exception => e\n\t\t\t$errMsgEpsdp = \"::MSG:: Error occurred while episode playing..\" + e.message\n\t\t\t$obj_rtnrs.returnNG\n\t\tend\t\t\n\t\tclient.sleep(2000)\n\tend",
"def episodes( season )\n return @seasons[season].first.flatten\n end",
"def unseen\n table.reject do |k, v|\n v[2]\n end\n end",
"def where_no_developers\n [[:educator_id, '!=', 12],\n [:educator_id, '!=', 509]]\n end",
"def availiable_employees\n Employee.where.not(id: User.where.not(id: id).map(&:employee_id)).order('number asc')\n end",
"def missing_chapters\n traces = @db.get_trace(@manga_data)\n if @todo.size != 0\n @todo = @todo.reject{|e| e[:page] != -1}\n end\n i = 0\n all_data = []\n @links.each do |link|\n all_data << Struct::Data.new(*@manga_data.extract_values_from_link(link), link)\n end\n Utils_misc::sort_chapter_list(all_data).each do |data|\n if traces.count{|_id, _manga_name, vol_value, chap_value| vol_value == data[:volume] && chap_value == data[:chapter]} == 0 &&\n @todo.count{|e| e[:chapter] == data[:chapter]} == 0\n prep_display = \" ( link #{i + 1} / #{@links.size} )\"\n chapter_link(data[:link], prep_display)\n end\n i += 1\n end\n @aff.dump\n end",
"def not_created_instances\n pending_instances_count = wanted_instances - filtered_pods_by_track.count\n\n return [] if pending_instances_count <= 0\n\n Array.new(pending_instances_count, deployment_instance(pod_name: 'Not provided', pod_status: 'Pending'))\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def index\n @episodes = Episode.all\n end",
"def episode\n fetch('cowboy_bebop.episode')\n end",
"def episode; end",
"def episode; end",
"def episode; end",
"def episode; end",
"def episodes_track ( show, season, episode, name)\n @episodes[show] = {} if @episodes[show].class.to_s != 'Hash'\n @episodes[show][season] = {} if @episodes[show][season].class.to_s != 'Hash'\n @episodes[show][season][episode] = name\n end",
"def get_playlists(days = 0)\n result = []\n tday = Time.now\n begin\n days -= 1\n days = 0 if days > LIST_NUM || days.negative?\n days.downto(0).each { |day| result << playlist_item(tday, day) }\n rescue StandardError => e\n push_error(e)\n end\n result\n end",
"def non_baculized_hosts\n hosts.not_baculized.pluck(:name)\n end",
"def index\n # @episodes = Episode.all\n @trabajador = Trabajador.find(params[:trabajador_id])\n @episodes = @trabajador.episodes\n\n end",
"def printNotFoundIMDBIDs(list)\n\tcounter = 0\n\tputs \"List of movies whose IMDB ID was NOT found\\n\"\n\tlist.each do |key,elem|\n\t\timdbid = elem['imdb_id']\n\t\tif imdbid == \"\" or imdbid == nil\n\t\t\tputs \"\\t\" + key \n\t\t\tcounter += 1;\n\t\tend\n\tend\n\tputs \"\\nIMDB ID not found for \" + counter.to_s + \" movies out of \" + list.length.to_s + \"!\"\nend",
"def fetch_non_favorite_bar_events()\n events = Hash.new\n temp = Bar.find(:all, :select => 'bars.name, bar_events.detail', :joins => :bar_event, :conditions => ['bars.id not in (select bar_id from favorites where user_id = ?) and verified = 1', [self.id] ])\n for t in temp do\n\t if events.key?(t.name)\n\t events[t.name] << t.detail\n\t else\n\t events[t.name] = [t.detail]\n\t end\n\tend\n\t\n\tevents\n end",
"def proper_items\n items.where.not(sort: ['self', 'pdf_destination'])\n .where.not(start_time: nil)\n end",
"def episodes(options)\n # Set default options unless defined in the options hash\n options[:content_type] = 'episode'\n options[:include] = 2 unless options.key?(:include)\n options[:order] = '-fields.releaseDate' unless options.key?(:order)\n\n objects('Episode', options)\n end",
"def fill_out_final_blanks(festival_start)\n @current_time_check = end_time_of_previous_show\n festival_end = festival_start + 9.hours\n remaining_hours = TimeDifference.between(end_time_of_previous_show, festival_end).in_hours.to_i\n remaining_hours.times do\n @current_time_check += 1.hour\n @shows_with_blanks << Event.new(start_date_time: @current_time_check-1.hour, end_date_time: @current_time_check)\n end\n return @shows_with_blanks\n end",
"def episode_list(sid)\n xml = get('/feeds/episode_list.php', :query => {:sid => sid})\n xml[\"Show\"]\n end",
"def initialize_cache_and_return_data(seriesid)\n begin\n # Create a TvDBParty client and fetch the episode record\n client = TheTvDbParty::Client.new(ENV['TVDB_API_KEY'])\n full_record = client.get_series_all(seriesid).full_series_record\n\n #Methods using the cache must handle the exception, creates a double render error when handled in this method\n if full_record.nil?\n raise ActionController::RoutingError.new('Internal Server Error')\n end\n\n seriesInformation = new_series_information_from_series_record(full_record)\n upcomingEpisodes = Array.new\n # Look through the episode record and see if we have any records that are not added\n for j in 1..(full_record.episodes.length)\n if(full_record.episodes[full_record.episodes.length-j].firstaired)\n if(full_record.episodes[full_record.episodes.length-j].firstaired > Date.today.prev_day)\n # If we find an episode which hasn't aired yet, or airs today, add it to the list.\n upcomingEpisodes.push(new_episode_information_from_episode_record(full_record.episodes[full_record.episodes.length-j]))\n else\n break\n end\n end\n end\n return seriesInformation,upcomingEpisodes\n end\n end",
"def getFailedQuests\n failed = []\n $PokemonGlobal.quests.failed_quests.each do |s|\n failed.push(s.id)\n end\n return failed\nend",
"def add_exceptions_for_missing_dp_lpi_records\n missing_dp_lpi_records.each do |lpi_record|\n add_exception_to_base(\n NotInLgaError.new(\n \"'%s' is present in LPI database but not in this LGA\" % [lpi_record]\n )\n )\n end\n end",
"def unfollowed_events\n events.where(visited: false).select do |event|\n !(event.next_event? || event.choices?)\n end\n end",
"def get_epg\n require 'json'\n require 'net/http'\n require 'time'\n epg = Net::HTTP.get('130.236.248.226', '/mdio/epg')\n epg = JSON.parse(epg)\n\n for channel in epg\n ch = Channel.new\n ch.name = channel['name']\n ch.channelURL = channel['url']\n # iconURL needs the adress to a STB that the server don't know.\n # ch.iconURL = '/mdio/channelicon?onid=' + channel['onid'].to_s() + '&tsid='+ channel['tsid'].to_s() + '&sid=' + channel['sid'].to_s()\n ch.iconURL = 'hej'\n ch.save\n ch = Channel.where(:name => channel['name'])\n #break\n for program in channel['programs']\n prog = Program.new\n duration = program['duration']\n intDuration = duration.split(\".\").map(&:to_i)\n minutes = intDuration[0] * 60 + intDuration[1];\n prog.duration = minutes\n prog.name = program['name']\n prog.starttime = DateTime.parse(program['start'])\n prog.description = program['exttext']\n prog.shortdescription = program['shorttext']\n prog.channel_id = ch[0]\n prog.save\n end\n end\n end",
"def unconnected_venues\n unconnected = []\n Venue.all.each do |venue|\n unconnected << venue if venues.exclude? venue\n end\n return unconnected\n end",
"def create_hidden_plannings\n if on_appointment_changed? or audience_ids_changed?\n self.plannings.map(&:destroy)\n if self.on_appointment\n (0..6).each do |week_day|\n self.plannings.create(\n week_day: week_day,\n visible: false,\n start_time: Time.parse('2000-01-01 06:00:00 UTC'),\n start_date: Date.yesterday,\n end_time: Time.parse('2000-01-01 23:00:00 UTC'),\n end_date: Date.today + 100.years,\n audience_ids: self.audience_ids\n )\n end\n end\n end\n nil\n end"
] |
[
"0.68971413",
"0.6663914",
"0.6521342",
"0.62834275",
"0.62667704",
"0.60120064",
"0.6007832",
"0.5991673",
"0.58730125",
"0.5805428",
"0.5799184",
"0.57035935",
"0.5676409",
"0.56607056",
"0.5649644",
"0.56205535",
"0.5614181",
"0.5613577",
"0.5554761",
"0.55046594",
"0.54992265",
"0.5495735",
"0.54944867",
"0.54933375",
"0.5491869",
"0.5460235",
"0.5444616",
"0.54388857",
"0.53970677",
"0.5386881",
"0.53074706",
"0.5299195",
"0.528989",
"0.5259818",
"0.5250035",
"0.52448523",
"0.5221063",
"0.52159756",
"0.5205864",
"0.51829875",
"0.5176214",
"0.517061",
"0.51695967",
"0.5163293",
"0.5149213",
"0.51245606",
"0.51064277",
"0.5102106",
"0.509546",
"0.50780165",
"0.50637233",
"0.50637233",
"0.50266564",
"0.49919027",
"0.4983399",
"0.49830225",
"0.49794897",
"0.49759814",
"0.4969836",
"0.49690118",
"0.49671108",
"0.4966794",
"0.496323",
"0.4949752",
"0.49376097",
"0.49315208",
"0.49313214",
"0.49055296",
"0.4902496",
"0.49021643",
"0.48993373",
"0.48985374",
"0.48944327",
"0.48944327",
"0.48944327",
"0.48944327",
"0.48944327",
"0.48944327",
"0.4882225",
"0.4879133",
"0.4879133",
"0.4879133",
"0.4879133",
"0.48764637",
"0.48702914",
"0.48688558",
"0.4863893",
"0.4853288",
"0.4843301",
"0.48398927",
"0.48385864",
"0.4837727",
"0.48362628",
"0.4830698",
"0.48286",
"0.48265803",
"0.48232162",
"0.48087418",
"0.4807693",
"0.4806443"
] |
0.6176883
|
5
|
Eigenclass Returns a new instance of Vedeu::Editor::Line.
|
def initialize(collection = nil)
@collection = collection || ''
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deputy(client = nil)\n Vedeu::DSL::Line.new(self, client)\n end",
"def eigen_vertical_line(size, color)\n {\n type: \"VerticalLine\",\n size: size,\n color: color\n }\n end",
"def create_line(instance_name, class_name, which=0)\n raise StandardError, \"Line object already exists. (#{instance_name})\" if self.instance_variables.include?(\"@#{instance_name}\".to_sym)\n new_line_name = instance_name\n make_accessor(:\"#{instance_name}\")\n klas = OLE_QA::Framework::OLEFS.const_get(:\"#{class_name}\")\n instance_variable_set(:\"@#{new_line_name}\", klas.new(@ole, which))\n end",
"def eulerline\n return self.orthocenter if self.is_equilateral?\n Line.new(self.orthocenter, self.circumcenter)\n end",
"def line(&block)\n attributes[:lines] << Line.build(&block)\n end",
"def line\n @line ||= Line.get(@attrs['Line'])\n end",
"def initialize(line)\n @line = line\n end",
"def line\n @line ||= Line.get(@attrs['LineCode'])\n end",
"def vertical_line_row(border_options=RGhost::Border::DEFAULT_OPTIONS)\n set RGhost::VerticalLine.row(border_options)\n end",
"def lines\n @lines ||= Vedeu::Editor::Lines.coerce(data)\n end",
"def initialize(line_id)\n super()\n @line_id = line_id\n end",
"def to_line(*args)\n raise NotImplementedError.new 'No line conversion method defined!'\n end",
"def initialize(vertical_line, horizontal_line)\n raise WrongFieldException.new unless (1..8).include?(vertical_line) && (1..8).include?(horizontal_line)\n @vertical_line = vertical_line\n @horizontal_line = horizontal_line\n end",
"def linechart(*args)\n Line.new(self, *args)\n end",
"def original_line; end",
"def vline x, c, y1 = 0, y2 = w\n line x, y1, x, y2, c\n end",
"def vline x, c, y1 = 0, y2 = w\n line x, y1, x, y2, c\n end",
"def vline(x, y, height, options = {})\n options = LINE_OPTIONS.merge(options)\n\n \"<line x1=\\\"#{x}\\\" y1=\\\"#{y}\\\" x2=\\\"#{x}\\\" y2=\\\"#{y+height}\\\" \n style=\\\"stroke:#{options[:stroke]};\n stroke-width:#{options[:stroke_width]};\n stroke-linecap:#{options[:stroke_linecap]};\n stroke-opacity:#{options[:stroke_opacity]};\n stroke-dasharray:#{options[:dasharray]}\\\"/>\"\n end",
"def vertical_line(options={:start_in => :limit_left, :size => :area_y})\n set RGhost::VerticalLine.new(options)\n end",
"def set_lines\n set_line(:line_item, OLE_QA::Framework::OLEFS::Line_Item)\n end",
"def line_template(ul = 'unmarked', ur = 'unmarked', ll = 'unmarked', lr = 'unmarked')\n html = <<-eol\n <div class=\"fam-tree-line-container\">\n <div class=\"fam-tree-line-level\">\n <div class=\"fam-tree-#{ul}\"></div>\n <div class=\"fam-tree-#{ur}\"></div>\n #{clear}\n </div>\n <div class=\"fam-tree-line-level\">\n <div class=\"fam-tree-#{ll}\"></div>\n <div class=\"fam-tree-#{lr}\"></div>\n #{clear}\n </div>\n </div>\n eol\n html.html_safe\n end",
"def horizontal_line(valign=:middle,options={})\n hl(valign,options)\n end",
"def geometry\n linestring\n end",
"def rb_mvwvline row, col, char, width\n super(row-@top, col-@left, char, width)\n end",
"def from_line\n position.new_line\n end",
"def vertical_line x\n line = { x: x, y: 0, w: 0, h: grid.height }\n line.transform_values { |v| v * grid.cell_size }\n end",
"def vertical_line x\n line = { x: x, y: 0, w: 0, h: grid.height }\n line.transform_values { |v| v * grid.cell_size }\n end",
"def initialize(*lines)\n @lines = normalised_lines(lines)\n end",
"def initialize(lines)\n @lines = lines\n end",
"def lines\n @lines ||= build_lines\n end",
"def insert_line\n down\n\n @lines = lines.insert_line(Vedeu::Editor::Line.new, y)\n\n bol\n\n refresh\n end",
"def initialize(line, parent)\n @line = line\n @parent = parent\n @cmds = []\n @children = []\n end",
"def vertical_line (board)\n transposed_board = board.transpose\n return horizontal_line (transposed_board)\n end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def draw_line_preview(view)\n plane = [@compass_position, Z_AXIS]\n projected = @input_point.position.project_to_plane(plane)\n\n # Copying visual style from Rotate tool.\n view.set_color_from_line(projected, @compass_position)\n view.line_stipple = \"_\"\n view.draw(GL_LINES, [@compass_position, projected])\n\n view.line_stipple = \"-\"\n view.drawing_color = \"gray\"\n view.draw(GL_LINES, [@input_point.position, projected])\n end",
"def line\n\t\t\t@line.set(buffer.line.start, buffer.line.end)\n\t\tend",
"def line\n lines.line(y)\n end",
"def diff_line_class(line)\n case line[0, 1]\n when '+' then 'added'\n when '-' then 'deleted'\n end\n end",
"def add_line\n @layout.add_widget(HLine.new)\n end",
"def eigenclass\n class << self\n return self\n end\n end",
"def line\n end",
"def line\n end",
"def create_line(frag)\n who = fragments.find_by order: frag.order - 1, f_type: 24\n Line.create! fragment_id: frag.id, who: (who.nil? ? nil : who.orig_text), content: frag.orig_text\n 1\n end",
"def eigen\n class << self; self; end\n end",
"def setLine (line)\n @line = line\n end",
"def initialize(path, line_number, line)\r\n @path = path\r\n @line_number = line_number\r\n @line = line\r\n @colorize_line = @line.gsub('<', '<')\r\n @colorize_line = @colorize_line.gsub('>', '>')\r\n end",
"def normal_line(text)\n end",
"def new_line(command)\n if command[1] == command[3]\n if command[2].to_i > @canvas.width - 2 || command[4].to_i > @canvas.width - 2\n puts 'you can not create the line because it is larger than the canvas'\n return\n else\n line_shape = :horizontal\n end\n elsif command [2] == command[4]\n if command[1].to_i > @canvas.height - 2 || command[3].to_i > @canvas.height - 2\n puts 'you can not create the line because it is larger than the canvas'\n return\n else\n line_shape = :vertical\n end\n else\n puts 'The line you are trying to create is not horizontal or vertical'\n return\n end\n @canvas.commands.new_line(command[1], command[2], command[3], command[4], line_shape)\n end",
"def rb_mvwhline row, col, char, width\n super(row-@top, col-@left, char, width)\n end",
"def editor_delete_line!\n Vedeu.bind(:_editor_delete_line_) do |name|\n Vedeu.documents.by_name(name).delete_line\n end\n end",
"def eigenclass\n class << self\n self\n end\n end",
"def line=(_); end",
"def line=(_); end",
"def initialize(lines=[], start_line=1, code_type=:ruby)\n if lines.is_a? String\n lines = lines.lines\n end\n\n @lines = lines.each_with_index.map { |l, i| [l.chomp, i + start_line.to_i] }\n @code_type = code_type\n end",
"def line\n @line ||= Line::Bot::Client.new {\n |config|\n config.channel_secret = '168b8406f6a932635df7f567e407929c'\n config.channel_token = 'fUXC56EsDT0OXh9rxhPbSxwq3Ap+pKaJgDFuO8FIrx2G7GK40glmBiqzGGALnz+kkNvFyqheKfBoeMl2BCsiHRT48zFJY1pTnuW2KuaPZsWbKBbnqMXncdGvB+hoWOdPloQRA5/4CMUgh47uPZyD4wdB04t89/1O/w1cDnyilFU='\n }\n end",
"def load_node(line)\n name, klass, parent = line.split(field_sep)\n [klass.constantize.new(name, nil), parent]\n end",
"def straight\n @line_type = '--'\n self\n end",
"def as_line_string\n GeoRuby::SimpleFeatures::LineString.from_points(@points)\n end",
"def initialize(line = nil)\n @line = line || ''\n end",
"def transform_in_line(linha_strans)\n line_hash = {}\n linha_strans.instance_variables.each do |var|\n attr_name = var.to_s.delete('@')\n attr_name = @@line_attrs[attr_name]\n line_hash[attr_name] = linha_strans.instance_variable_get(var) if attr_name\n end\n line_hash = line_hash.except('veiculos')\n line_hash = line_hash.except('paradas')\n Line.new(line_hash)\n end",
"def rb_mvwvline row, col, char, width\n mvwvline row, col, char, width\n end",
"def element_line(element); end",
"def eigenclass\n class << self; self; end\n end",
"def line=(line)\r\n members.each {|m| m.line = line}\r\n @line = line\r\n end",
"def set_line\n @line = Line.find(params[:id])\n end",
"def set_line\n @line = Line.find(params[:id])\n end",
"def set_line\n @line = Line.find(params[:id])\n end",
"def initialize( body, linenum=nil, colnum=nil )\n\t\t@inverted = false\n\t\tsuper\n\tend",
"def initialize( body, linenum=nil, colnum=nil )\n\t\t@inverted = false\n\t\tsuper\n\tend",
"def initialize( body, linenum=nil, colnum=nil )\n\t\t@inverted = false\n\t\tsuper\n\tend",
"def line_one=(line_one)\n @line_one = line_one\n end",
"def recordize line\n vals = line.split(\"\\t\")\n [@model_klass.from_tuple(*vals)]\n end",
"def get_line\n raise NotImplementedError\n end",
"def init_line_structures(minsize)\r\n if @invisible_line.nil? # initialize it\r\n if (@line_size < minsize)\r\n @line_size = minsize\r\n end\r\n @visible_line = 0.chr * @line_size\r\n @invisible_line = 0.chr * @line_size # 1.chr\r\n elsif (@line_size < minsize) # ensure it can hold MINSIZE chars\r\n @line_size *= 2\r\n if (@line_size < minsize)\r\n @line_size = minsize\r\n end\r\n @visible_line << 0.chr * (@line_size - @visible_line.length)\r\n @invisible_line << 1.chr * (@line_size - @invisible_line.length)\r\n end\r\n @visible_line[minsize,@line_size-minsize] = 0.chr * (@line_size-minsize)\r\n @invisible_line[minsize,@line_size-minsize] = 1.chr * (@line_size-minsize)\r\n\r\n if @vis_lbreaks.nil?\r\n @inv_lbreaks = []\r\n @vis_lbreaks = []\r\n @_rl_wrapped_line = []\r\n @inv_lbreaks[0] = @vis_lbreaks[0] = 0\r\n end\r\n end",
"def hline y, c, x1 = 0, x2 = h\n line x1, y, x2, y, c\n end",
"def hline y, c, x1 = 0, x2 = h\n line x1, y, x2, y, c\n end",
"def render_line(line)\n raise NotImplementedError\n end",
"def get_type\n \"line\"\n end",
"def line_one\n @line_one\n end",
"def draw_line; draw_horizontal_line(@draw_y + (line_height / 2) - 1, 2); end",
"def editor_insert_line!\n Vedeu.bind(:_editor_insert_line_) do |name|\n Vedeu.documents.by_name(name).insert_line\n end\n end",
"def original_text\n @line\n end",
"def linetool\n Sketchup.active_model.select_tool LineTool.new\nend",
"def set_line_property\n @line_property = LineProperty.find(params[:id])\n end",
"def initialize(line_items)\n @line_items = line_items\n end",
"def setlinetype(*)\n super\n end",
"def initialize(line: nil)\n @line = line\n @current_command_type = EXPORT_COMMAND if export?\n @current_command_type = ALIAS_COMMAND if alias?\n process_attributes! unless line?\n end"
] |
[
"0.62600344",
"0.61780834",
"0.60357076",
"0.59837794",
"0.59187675",
"0.57833785",
"0.5782081",
"0.57682216",
"0.573901",
"0.5726313",
"0.5709869",
"0.5599225",
"0.5581626",
"0.55598307",
"0.55406785",
"0.5509585",
"0.5509585",
"0.54836595",
"0.54709804",
"0.5400316",
"0.5384365",
"0.53803927",
"0.5370178",
"0.5339008",
"0.533608",
"0.5317555",
"0.5317555",
"0.53013253",
"0.5282839",
"0.5282203",
"0.5262973",
"0.5227062",
"0.5220209",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5214962",
"0.5208555",
"0.5183909",
"0.517059",
"0.51636827",
"0.5154068",
"0.5152484",
"0.5140224",
"0.5140224",
"0.5135298",
"0.5127741",
"0.5126689",
"0.5115886",
"0.51153123",
"0.51078314",
"0.5094206",
"0.50900185",
"0.5088749",
"0.5087078",
"0.5087078",
"0.5081835",
"0.5081314",
"0.5072918",
"0.50717026",
"0.5068987",
"0.5065465",
"0.5044682",
"0.5037509",
"0.5035745",
"0.5016584",
"0.5007358",
"0.49916992",
"0.49916992",
"0.49916992",
"0.49878252",
"0.49878252",
"0.49878252",
"0.4976917",
"0.4973529",
"0.49609667",
"0.49540654",
"0.49402347",
"0.49402347",
"0.4931444",
"0.49289054",
"0.4923029",
"0.49134126",
"0.49104834",
"0.49097472",
"0.4905943",
"0.4905462",
"0.49023262",
"0.48984534",
"0.48925483"
] |
0.0
|
-1
|
Return the character at the given index.
|
def character(index = nil)
return '' if collection && collection.empty?
return collection[-1] unless index
by_index(index)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_character(full_string, index)\n full_string[index]\nend",
"def get_char at\n index = range_correct_index(at)\n return internal_object_get(index + 1)\n end",
"def char_at(index)\n self.to_array[index.to_i]\n end",
"def character(index = nil)\n return '' if line && line.empty?\n return line[-1] unless index\n\n Vedeu::Editor::Item.by_index(line, index)\n end",
"def char_at(index)\n\tself.to_array[index.to_i]\n end",
"def char_at(index)\n\tself.to_array[index.to_i]\nend",
"def getChar\n if @index <= @code.size - 1\n return @code[@index] if !@code[@index].nil?\n end\n # If nil return empty string.\n return nil\n end",
"def char_at(index)\n self.to_array[index.to_i]\n #@word = TILE_VALUES[index]\n end",
"def get_character(full_string, index) # defines a method get_character with two parameters full_string and index\n full_string[index] # looks for index within the variable full_string ????\nend",
"def index_to_letter(index)\n alphabet_array[index]\n end",
"def index_to_letter(index)\n ALPHA26[index]\n end",
"def char_at(column)\n line[column, 1]\n end",
"def get_letter(word, index)\n if word[index] == 'Q' && index+1 < word.length && word[index+1] == 'U'\n return 'Qu'\n end\n\n return word[index]\n end",
"def [](n)\n @chars[n]\n end",
"def char(index)\n s = case @raw_text[index + 1].ord\n when 0x4f, 0x0b, 0x32; :normal_protected\n when 0x6e, 0x22; :normal_unprotected\n when 0x50, 0x3a; :intensified_protected\n when 0x4e, 0x2a; :intensified_unprotected\n else @raw_text[index + 1,1].retain_to_user\n end\n s\n end",
"def index_to_letter(idx)\n letter = \"\"\n while true\n idx -= 1\n r = idx % 26\n idx /= 26\n letter = (r + 97).chr + letter\n break if idx <= 0\n end\n letter\n end",
"def uindex_to_index(char_index)\n return nil if char_index.nil?\n if char_index < 0 || char_index > jlength\n raise RangeError, 'index out of range'\n end\n \n chars = split('')\n byte_index = 0\n char_index.times do |i|\n byte_index += chars[i].length\n end\n byte_index\n end",
"def nextchar\n c = self.more?() ? @source[@index,1] : \"\\0\"\n @index += 1\n return(c)\n end",
"def get index\n @letters[index]\n end",
"def [](index)\n to_s[index]\n end",
"def char_at(off)\n if off.abs >= @length\n return \"\"\n end\n off = (off + @length) % @length\n if isleaf(self)\n return str.slice(off,1)\n elsif off < left.length\n return @left.char_at(off)\n else \n return @right.char_at(off-@left.length)\n end\n end",
"def line_from_char(index = -1)\n send_message(:LINEFROMCHAR, index.to_i)\n end",
"def firstChar(str, f_index)\n if alpha(str[f_index])\n return str[f_index], f_index\n end\n firstChar(str, f_index += 1) \n end",
"def shift_character_by(char, index)\n new_ord = (char.ord + index)\n if new_ord > LAST_CHARACTER_ORD\n new_ord -= ALPHABET_SIZE\n elsif new_ord < FIRST_CHARACTER_ORD\n new_ord += ALPHABET_SIZE\n end\n new_ord.chr\n end",
"def getChar(c)\n c.chr\nend",
"def getChar(c)\n c.chr\nend",
"def next_char(options = {})\n ix = column\n ix = skip_space(ix, :right) if options[:skip_space]\n char_at(ix) || ''\n end",
"def nextchars(n)\n raise \"substring bounds error\" if (@index + n > @source.length)\n i = @index\n @index += n\n return(@source[i,n])\n end",
"def getCharByOffset(char, offset=0)\n # Chars could be in the upper alphabet, the lower alphabet, or neither.\n indexUpper = $ALPHABET.index(char)\n indexLower = $alphabet.index(char)\n if indexUpper\n i = calculateOffset(indexUpper, offset)\n char = $ALPHABET[i] # Get the char at that index\n elsif indexLower\n i = calculateOffset(indexLower, offset)\n char = $alphabet[i]\n end\n char\n end",
"def next_char\n @current_char_pos += 1\n @current_char = @string[@current_char_pos, 1]\n end",
"def nth_char(arr)\n str = ''\n 0.upto(arr.size - 1) do |idx|\n str += arr[idx][idx]\n end\n str\nend",
"def get_char\n @look = @expression[@number]\n @number +=1\nend",
"def charChange(char)\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n charPosition = alpha.index(char)\n newChar = alpha[charPosition - 1]\n return newChar\nend",
"def get_rowcol_from_index(index)\n letter = get_col_from_index(index)\n number = get_row_from_index(index)\n \"#{letter}#{number}\"\n end",
"def get_char_summery(string, count)\n string[0..count]\n end",
"def char\n self[@char]\n end",
"def lastChar(str, l_index)\n if alpha(str[l_index])\n return str[l_index], l_index\n end\n lastChar(str, l_index -= 1)\n end",
"def get_char\n\t\tc = read_char\n\n\t\tcase c\n\t\twhen \"\\e[A\"\n\t\t\treturn :up\n\t\twhen \"\\e[B\"\n\t\t\treturn :down\n\t\twhen \"\\e[C\"\n\t\t\treturn :right\n\t\twhen \"\\e[D\"\n\t\t\treturn :left\n\t\twhen \"\\177\"\n\t\t\treturn :backspace\n\t\twhen \"\\004\"\n\t\t\treturn :delete\n\t\twhen \"\\e[3~\"\n\t\t\treturn :altdelete\n\t\twhen \"\\u0003\" # Ctrl C\n\t\t\texit 0\n\t\twhen /^.$/ # Only one char\n\t\t\treturn c\n\t\telse\n\t\t\tSTDERR.puts \"strange char: #{c.inspect}\"\n\t\tend\n\tend",
"def current()\n @string[@index...(@index+1)]\n end",
"def at(index)\n self[index]\n end",
"def nth_char(arr)\n arr.map.with_index { |word, idx| word[idx] }.join\nend",
"def rl_get_char()\r\n if (@push_index == @pop_index)\r\n return nil\r\n end\r\n key = @ibuffer[@pop_index]\r\n @pop_index += 1\r\n\r\n if (@pop_index >= @ibuffer_len)\r\n @pop_index = 0\r\n end\r\n\r\n return key\r\n end",
"def index_letter\n last_name[0..0]\n end",
"def index_of_char(string, character)\n i = 0\n position = nil\n while i < string.length\n if string[i] == character\n position = i\n break\n else\n i += 1\n end\n end\n return position\nend",
"def at(index)\n each.with_index { |v, i| return v if i == index }\n return nil\n end",
"def read_character\n unless @input.empty?\n result(@input.at(0), advance(1))\n else\n failure(\"less than one character available\")\n end\n end",
"def character_for(unicode_codepoint)\n if unicode_codepoint < FIRST_UNICODE_CODEPOINT\n unicode_codepoint = LAST_UNICODE_CODEPOINT - (FIRST_UNICODE_CODEPOINT - unicode_codepoint)\n elsif unicode_codepoint >= LAST_UNICODE_CODEPOINT\n unicode_codepoint = FIRST_UNICODE_CODEPOINT + (unicode_codepoint - LAST_UNICODE_CODEPOINT)\n end\n unicode_codepoint.chr\n end",
"def get_index(index)\n return self.at(index)\n end",
"def letter_for(n)\n offset = n < 26 ? 'A'.ord : 'a'.ord\n ascii = offset + (n % 26)\n ascii.chr\n end",
"def [](index)\r\n words[index]\r\n end",
"def index_of_char(string, letter)\n i = 0\n while i < string.length\n if string[i] == letter\n return i\n end\n i += 1\n end\n return nil\nend",
"def substring_at(index, length: length)\n bytes.to_a[index, length].map(&:chr).join\n end",
"def delete_character(index = nil)\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete\n .from(line, index, size))\n end",
"def delete_character(index = nil)\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete\n .from(line, index, size))\n end",
"def closest_character_index(position)\n\t\t\t# Move caret into position\n\t\t\t# Try to get as close to the position of the cursor as possible\n\t\t\twidth = @font.width(@string, @height)\n\t\t\tx = @position.x\n\t\t\tmouse_x = $window.mouse.position_in_world.x\n\t\t\t\n\t\t\t# Figure out where mouse_x is along the continuum from x to x+width\n\t\t\t# Use that to guess what the closest letter is\n\t\t\t# * basically, this algorithm is assuming fixed width, but it works pretty well\n\t\t\tpercent = (mouse_x - x)/width.to_f\n\t\t\ti = (percent * (@string.length)).to_i\n\t\t\t\n\t\t\ti = 0 if i < 0\n\t\t\ti = @string.length if i > @string.length\n\t\t\t\n\t\t\treturn i\n\t\tend",
"def index_of_char(str, char)\n i = 0\n while i < str.length\n if str[i] == char\n return i\n end\n\n i += 1\n end\n\n return nil\nend",
"def peek_char(lookahead = 1)\n @string[@current_char_pos + lookahead, 1]\n end",
"def nth_char(words)\n final_word = []\n words.each_with_index { |word, index| \n final_word << word[index]\n }\n return final_word.join('')\nend",
"def column(index)\n @columns[index]\n end",
"def current_char\n @current_char\n end",
"def char(char, other_alphabet)\n self[other_alphabet.index(char)]\n end",
"def shift_char(current_char)\r\n vowels = 'aeiou'\r\n consonants = 'bcdfghjklmnpqrstvwxyz'\r\n comp_string = vowels.index(current_char) ? vowels : consonants\r\n char_index = (comp_string.index(current_char) + 1) % comp_string.length\r\n return comp_string[char_index]\r\nend",
"def char\n self.class.codepoint2char(@codepoint)\n end",
"def nextChar(n, char)\n\tif n > 0\n\t\treturn nextChar(n-1, char.next)\n\telse\n\t\treturn char\n\tend\nend",
"def get_card_at_index(index)\n x = @cardList[index]\n end",
"def [](index, second_arg = -1)\n return super if second_arg != -1\n if index.is_a?(String)\n index = @grid.index_for_column_name(index)\n return '' if index.blank?\n end\n\n return '' if index >= size\n return slice(index) || ''\n end",
"def char\n raise MathError, \"Non-integer for char\" unless int?\n raise MathError, \"Out of range for char\" unless between?(0, 255)\n if zero?\n \"\"\n else\n to_i.chr\n end\n end",
"def read_character\n lit = read_literal\n\n return \" \" if lit.empty? && peek_char == \" \"\n CHARACTERS.fetch(lit.downcase) do\n # Return just the first character\n unread(lit[1..-1])\n lit[0,1]\n end\n end",
"def [](index)\n i = 0\n each { |x| return x if i == index; i += 1 }\n nil # out of index\n end",
"def get_character(input = T.unsafe(nil)); end",
"def get_swapped_char (letter)\n\tif is_vowel(letter)\n\t\tget_next_vowel(letter)\n\telse\n\t\tget_next_consonant(letter)\n\tend\nend",
"def get_swapped_char (letter)\n\tif is_vowel(letter)\n\t\tget_next_vowel(letter)\n\telse\n\t\tget_next_consonant(letter)\n\tend\nend",
"def first_char_idx\n dewey? ? 3 : 0\n end",
"def rand_char\n self[Kernel.rand(length), 1]\n end",
"def get_at_index(index)\n return nil if index > length\n return get_at_index_helper(index, 0, @head)\n end",
"def NextChar\r\n\t\t@Line.slice!(0, 1)\r\n\tend",
"def peekChar\r\n\t\tcheckLine\r\n\t\tcheckSpace\r\n\t\treturn @Line[0]\r\n\tend",
"def get_char\n c = Curses.getch\n c if (0..255) === c.ord\n end",
"def at_index(index)\n find_by_index(index)\n current\n end",
"def subject_string_by_index(index)\n\t\tcase index\n\t\t\twhen 0\n\t\t\t\treturn \"ma\"\n\t\t\twhen 1\n\t\t\t\treturn \"sc\"\n\t\t\twhen 2\n\t\t\t\treturn \"ss\"\n\t\t\twhen 3\n\t\t\t\treturn \"la\"\n\t\t\twhen 4\n\t\t\t\treturn \"fl\"\n\t\t\twhen 5\n\t\t\t\treturn \"mu\"\n\t\t\twhen 6\n\t\t\t\treturn \"pe\"\n\t\t\twhen 7\n\t\t\t\treturn \"he\"\n\t\t\twhen 8\n\t\t\t\treturn \"da\"\n\t\t\twhen 9\n\t\t\t\treturn \"va\"\n\t\t\twhen 10\n\t\t\t\treturn \"se\"\n\t\t\twhen 11\n\t\t\t\treturn \"te\"\n\t\tend\n\t\t#otherwise\n\t\treturn \"Invalid subject index!\"\n\tend",
"def char\n\t\t\t\t@char\n\t\t\tend",
"def get_at_index(index)\n raise NotImplementedError, \"Please implement get_at_index\"\n end",
"def [](index, second_arg = -1)\n return super if second_arg != -1\n if index.is_a?(String)\n index = @grid.index_for_column_name(index)\n return '' if index.blank?\n end\n\n return '' if index >= size\n return slice(index) || ''\n end",
"def show_char(c)\n chars = %w( nul sch stx etx eot enq ack bel bs tab nl vtab\n ff cr so si dle dcl dc2 dc3 dc4 nak syn etb\n can em sub esc fs gs rs us sp\n )\n return(chars[c.ord])\nend",
"def [](x, y)\n @chars[y][x]\n end",
"def prev_char(single_letter)\n (single_letter.ord - 1).chr\nend",
"def prev_char(single_letter)\n (single_letter.ord - 1).chr\nend",
"def index_to_input(index)\n (index + 1).to_s\n end",
"def column(index)\n columns[index]\n end",
"def get_col_from_index(index)\n if index % 8 == 0\n return 8\n else\n return index % 8\n end\n end",
"def get_char\n\tbegin\n\t\tsystem(\"stty raw -echo\")\n\t\tchar = STDIN.getc\n\tensure\n\t\tsystem(\"stty -raw echo\")\n\tend\n\treturn char\nend",
"def caesar_cipher(str, num)\n\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n alphabet.each_char.with_index do |char, idx|\n puts char\n puts idx\n puts \"---\"\n end \n\nend",
"def index_of_char(string, character)\n i = 0\n output = []\n while i < string.length\n if character == string[i]\n output << i\n end\n i += 1\n end\n if output == []\n output = nil\n end\n return output\nend",
"def next_consonant(letter)\n\tc_alphabet = \"bcdfghjklmnpqrstvqwxyzb\"\n \tx = c_alphabet.index(letter)\n \tx += 1\n\t c_alphabet[x]\n\nend",
"def current_letter\n @letters[self.position]\n end",
"def index_to_uindex(byte_index)\n return nil if byte_index.nil?\n if byte_index < 0 || byte_index > length\n raise RangeError, 'index out of range'\n end\n \n chars = split('')\n char_index = 0\n chars.each do |ch|\n break if byte_index == 0\n byte_index -= ch.length\n return nil if byte_index < 0\n char_index += 1\n end\n char_index\n end",
"def print_index\n\t\t#zet de index nr in text_index\n\t\ttext_index = \"Hello, Ruby.\".index /Ruby/\n\t\t#print text_index\n\t\tputs text_index\n\tend",
"def get_codepoint(character)\n \"%04x\" % character.unpack(\"U\")[0]\n end",
"def get_code_for(i)\n if i.is_a?(String)\n c = i[0]\n else\n c = i\n end\n\n return @remap_chars[c.chr] || c.chr\n end",
"def [](index)\n line[index]\n end"
] |
[
"0.81421363",
"0.8107879",
"0.8053279",
"0.7949277",
"0.78538704",
"0.76641023",
"0.7345691",
"0.73228943",
"0.7106117",
"0.70170766",
"0.700419",
"0.6880574",
"0.6804608",
"0.67518866",
"0.6677644",
"0.664349",
"0.6637772",
"0.65750843",
"0.65320283",
"0.65018886",
"0.64844394",
"0.64055127",
"0.6381397",
"0.63715184",
"0.63286877",
"0.63286877",
"0.63130337",
"0.627822",
"0.62180823",
"0.6162035",
"0.6155157",
"0.6150543",
"0.6105469",
"0.6084785",
"0.6061852",
"0.60599613",
"0.6058913",
"0.60172504",
"0.5993664",
"0.5993469",
"0.5991865",
"0.59839636",
"0.5981605",
"0.5981331",
"0.5966181",
"0.59337837",
"0.5906377",
"0.59058636",
"0.5901015",
"0.5892704",
"0.58888423",
"0.5864749",
"0.58592695",
"0.58592695",
"0.58572686",
"0.58543766",
"0.5790659",
"0.57755077",
"0.5771532",
"0.5762751",
"0.57492584",
"0.5743411",
"0.57415897",
"0.5738888",
"0.5706203",
"0.5692995",
"0.5692469",
"0.56916356",
"0.5690913",
"0.56903195",
"0.5681739",
"0.5681739",
"0.56669533",
"0.5658318",
"0.56578773",
"0.5647096",
"0.56457275",
"0.56449604",
"0.5640074",
"0.5636589",
"0.56237674",
"0.5623611",
"0.5615488",
"0.5613152",
"0.5608051",
"0.5597366",
"0.5597366",
"0.55903685",
"0.5586249",
"0.5583904",
"0.5557847",
"0.55468345",
"0.55381787",
"0.5527366",
"0.55245936",
"0.55227077",
"0.55202246",
"0.5517921",
"0.5515625",
"0.5497305"
] |
0.80683035
|
2
|
Delete the character from the line positioned at the given index.
|
def delete_character(index = nil)
Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete
.from(line, index, size))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_character\n @lines = lines.delete_character(y, x - 1)\n\n left\n\n refresh\n end",
"def delete_at index=@curpos\n return -1 if !@editable \n char = @buffer.slice!(index,1)\n #$log.debug \" delete at #{index}: #{@buffer.length}: #{@buffer}\"\n @modified = true\n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :DELETE, 0, char) # 2010-09-11 13:01 \n end",
"def character(index = nil)\n return '' if line && line.empty?\n return line[-1] unless index\n\n Vedeu::Editor::Item.by_index(line, index)\n end",
"def delete(n = 1)\n @text.slice!(@cursor, n)\n end",
"def delete\n @text.slice!(@cursor, 1)\n end",
"def remove_line(line_num)\n\t\tif @line_indices == []\n\t\t\t@text = \"\"\n\t\telse\n\t\t\tlength = line_index(line_num + 1) - line_index(line_num)\n\t\t\t@text[line_index(line_num) + 1 .. line_index(line_num + 1)] = \"\"\n\t\t\t@line_indices.delete_at(line_num)\n\t\t\t(line_num...@line_indices.length).each { |i| @line_indices[i] -= length }\n\t\tend\n\tend",
"def delete_at(index)\n # raises IndexOutOfBoundsException if index is out of bounds [0, @length)\n # TODO\n end",
"def delete_at_index(index)\n \n end",
"def delete_current_character() \n\t\tif @selection_start != -1\n\t\t\tl1, i1 = index_line_and_col(@selection_start)\n\t\t\tl2, i2 = index_line_and_col(@selection_end)\n\t\t\tremove_range(l1, i1, l2, i2)\n\t\t\tclear_selection\n\t\t\temit_changed((l1...num_lines)) #todo\n\t\telse\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col.. @cursor_col] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def delete_at(line_number)\n self[line_number].delete\n super(line_number)\n update_line_numbers!\n end",
"def line_from_char(index = -1)\n send_message(:LINEFROMCHAR, index.to_i)\n end",
"def erase!(chars)\n return if chars == 0\n str = @result.slice!(-chars..-1)\n newlines = str.count(\"\\n\")\n if newlines > 0\n @line -= newlines\n @offset = @result[@result.rindex(\"\\n\") || 0..-1].size\n else\n @offset -= chars\n end\n end",
"def delchar(row,col)\n\t\tif col == @text[row].length\n\t\t\tmergerows(row,row+1)\n\t\telse\n\t\t\t@text[row] = @text[row].dup\n\t\t\t@text[row][col] = \"\"\n\t\tend\n\tend",
"def remove(n = 1)\n left(n)\n @text.slice!(@cursor, n)\n end",
"def clear_line\n CSI + '2K' + column(1)\n end",
"def undoMove(index)\n @board[index] = \" \"\n end",
"def clear(line, c=\".\")\n\tline.each_index do |i|\n\t\tline[i] = c\n\tend\nend",
"def rl_delete(count, key)\r\n if (count < 0)\r\n return (_rl_rubout_char(-count, key))\r\n end\r\n if (@rl_point == @rl_end)\r\n rl_ding()\r\n return -1\r\n end\r\n\r\n if (count > 1 || @rl_explicit_arg)\r\n xpoint = @rl_point\r\n rl_forward_byte(count, key)\r\n\r\n rl_kill_text(xpoint, @rl_point)\r\n @rl_point = xpoint\r\n else\r\n if !@rl_byte_oriented\r\n xpoint =_rl_find_next_mbchar(@rl_line_buffer, @rl_point, 1, MB_FIND_NONZERO)\r\n else\r\n xpoint = @rl_point + 1\r\n end\r\n\r\n rl_delete_text(@rl_point, xpoint)\r\n end\r\n 0\r\n end",
"def remove_node(index)\n @strat.remove_node(index)\n @ize -= 1\n end",
"def delete_at(idx)\n idx = Maglev::Type.coerce_to(idx, Fixnum, :to_int)\n sz = self.__size\n if idx < 0\n idx = sz + idx\n if idx < 0\n return nil\n end\n end\n if idx >= sz\n return nil\n end\n elem = self.__at(idx)\n oidx = idx + 1\n self.__remove_from_to_(oidx, oidx)\n return elem\n end",
"def remove_at(idx)\n @todos.delete(item_at(idx))\n end",
"def delete(index)\n Entity.remove_item(index)\n end",
"def delete_at(index)\n @fields.delete_at(index)\n self\n end",
"def delete_at index\n idx = named_index_for index\n @data.delete_at @index[idx]\n\n if @index.index_class == Integer\n @index = Daru::Index.new @size-1\n else\n @index = Daru::Index.new (@index.to_a - [idx])\n end\n\n set_size\n set_nil_positions\n end",
"def remove(word, idx)\n word[0...idx] + word[idx+1..-1]\n end",
"def delete_prev_char\n return -1 if !@editable \n return if @curpos <= 0\n # if we've panned, then unpan, and don't move cursor back\n # Otherwise, adjust cursor (move cursor back as we delete)\n adjust = true\n if @pcol > 0\n @pcol -= 1\n adjust = false\n end\n @curpos -= 1 if @curpos > 0\n delete_at\n addcol -1 if adjust # move visual cursor back\n @modified = true\n end",
"def using_delete_at(arr, index)\n arr.delete_at(index)\nend",
"def delete_at_index(index)\n @list.delete_at(index)\n end",
"def delete\n \ttemp = @cbuf.delete_at(@s)\n \t@s += 1\n \ttemp\n end",
"def clear_char(n = nil)\n CSI + \"#{n}X\"\n end",
"def delete_at(p0) end",
"def delete_at(index)\n @driver_instance.delete_list_value_at(@key, index)\n end",
"def delete_at ix\n return unless @list\n raise ArgumentError, \"Argument must be within 0 and #{@list.length}\" if ix < 0 or ix >= @list.length \n fire_dimension_changed\n #@list.delete_at(ix + @_header_adjustment)\n _ret = @list.delete_at(ix)\n @native_text = @list # 2014-05-27 - 16:34 \n return _ret\n end",
"def line_space(index=@buffer.line.end)\n\t\t\ts = 0\n\t\t\t@buffer[@buffer.line.start ... index].each_char do |k|\n\t\t\t\ts += char_space(k, s)\n\t\t\tend\n\t\t\t\n\t\t\ts\n\t\tend",
"def remove_at(index)\n raise(StandardError, 'IndexError') if invalid_index?(index)\n return remove_uniq_element if size == 1\n\n index = normalize_index(index)\n\n if index.zero?\n remove_header\n elsif (index + 1) == size\n remove_trailer\n else\n remove_node(find_node_by_index(index))\n end\n end",
"def char_at(column)\n line[column, 1]\n end",
"def NextChar\r\n\t\t@Line.slice!(0, 1)\r\n\tend",
"def delete_at(index)\n delete_idx = @indexes.each_index.find { |i| index == @indexes[i] }\n return nil unless delete_idx\n\n @indexes.delete_at(delete_idx)\n choice = @selected.delete_at(delete_idx)\n @size -= 1\n choice\n end",
"def remove\n\t\t\tback if (@buffer.at_end?)\n\t\t\tch = @buffer.char\n\t\t\t@buffer.remove\n\t\t\tredraw_line((ch == Ruvim::API::CR) ? (@cursor.y ... @height) : @cursor.y) \n\t\t\tself\n\t\tend",
"def using_delete_at(array, index)\n array.delete_at(index)\nend",
"def delete_ace(index=MAXDWORD)\n unless DeleteAce(@ace, index)\n raise Error, get_last_error\n end\n\n index\n end",
"def noteboard_delete(line_number)\n \n\n end",
"def using_delete_at(array, index)\n array.delete_at(index)\nend",
"def [](index)\n line[index]\n end",
"def remove_at(index)\n node = get_node index\n remove_node node\n node.element\n end",
"def erase_line_to_beginning\n ConsoleGlitter.escape('1K')\n end",
"def remove\n left\n @text.slice!(@cursor, 1)\n end",
"def erase_line_to_end\n ConsoleGlitter.escape('0K')\n end",
"def remove_line(line)\n\t\t@lines.delete(line)\n\tend",
"def remove_item_at(index)\n @list.slice!(index)\n end",
"def delete_at n\n self.slice! n\n end",
"def deleteTextDelete c, nbToDelete = 1\n nbToDelete = deleteTextDeleteTooBig c, nbToDelete\n while @fileContent[c.line].size - c.column < nbToDelete\n nbToDelete = deleteTextDeleteConcatLine c, nbToDelete\n end\n deleteTextDeleteSameLine c, nbToDelete\n nil\n end",
"def draw_line(index)\n rect = Rect.new(0, 0, 0, 0)\n rect.x += 4\n rect.y += index * WLH\n rect.width = contents.width - 8\n rect.height = WLH\n self.contents.clear_rect(rect)\n self.contents.font.color = normal_color\n self.contents.draw_text(rect, @lines[index])\n end",
"def _rl_erase_at_end_of_line(l)\r\n _rl_backspace(l)\r\n @rl_outstream.write(' '*l)\r\n _rl_backspace(l)\r\n @_rl_last_c_pos -= l\r\n @visible_line[@_rl_last_c_pos,l] = 0.chr * l\r\n @rl_display_fixed = true if !@rl_display_fixed\r\n end",
"def delete_at(index)\n return nil if index >= @size || index < 0\n element = self[index]\n if direct_index = @map[index]\n @added.delete_at(direct_index)\n @map.delete(index)\n @map.keys.sort.each do |key|\n if key > index\n value = @map.delete(key)\n value -= 1 if value > direct_index\n @map[key-1] = value\n else\n if (value = @map[key]) > direct_index\n @map[key] -= 1\n end\n end\n end\n else\n lazy_index = lazy_index(index)\n position = @deleted.bsearch_upper_boundary{|e| e <=> lazy_index }\n @deleted.insert(position,lazy_index)\n @map.keys.sort.each do |key|\n if key > index\n @map[key-1] = @map.delete(key)\n end\n end\n end\n #@commands << [:delete,[index]]\n @size -= 1\n element\n end",
"def using_delete_at(arr, i)\n arr.delete_at(i)\nend",
"def delete_line(line)\n raise \"Can't find line item to delete\" unless @lines.delete(line)\n @deleted_lines << line\n end",
"def delete_at (i)\n\n outlen_op(:tclistremove, i)\n end",
"def delete_at index\n idx = named_index_for index\n @vector.delete_at @index[idx]\n\n if @index.index_class == Integer\n @index = Daru::Index.new @size-1\n else\n @index = Daru::Index.new (@index.to_a - [idx])\n end\n\n set_size\n end",
"def delete(from: 0, to: length)\n editable? and @native.delete_text(from.to_i, to.to_i)\n end",
"def remove_by_index(index)\n @items.delete_at(index-1)\n end",
"def remove_nth_letter(string, n)\n string.delete!(string[n])\nend",
"def wdelch\n Ncurses.wdelch(pointer)\n end",
"def delete(key)\n key = key.key if key.respond_to?(:key)\n\n unless (idx = @indicies[key]).nil?\n @indicies.delete(key)\n @indicies.each { |k,v| @indicies[k] = v -= 1 if v > idx }\n @lines.delete_at(idx)\n end\n end",
"def clear_line_after\n CSI + '0K'\n end",
"def delete_col(idx)\n @header.delete_at(idx)\n @order -= 1\n each { |row| row.delete_at(idx) }\n end",
"def remove_at(index)\n at(index+1)\n temp = @current_node\n at(index-1)\n @current_node.next = temp\n end",
"def delete_at(index)\t\n\t\tif index==1\n\t\t\t@first = tmp.front\n\t\t\t@first.back = nil\n\t\telsif @length==index\n\t\t\tpop;\n\t\telse\n\t\t\ttmp = get(index)\n\t\t\ttmp.back.front = tmp.front \n\t\t\ttmp.front.back = tmp.back\n\t\tend\n\t\t@length-=1\n\tend",
"def ti_delete_line\n\ttictl(\"dl\")\n end",
"def replace(line)\n # get the actual offset\n start = @buffer.get_iter_at_offset(@@offset)\n\n # Delete all\n @buffer.delete(start, @buffer.end_iter)\n\n # Save the new offset\n @@offset = @buffer.end_iter.offset\n\n # insert the old command\n @buffer.insert(@buffer.end_iter, line)\n end",
"def delete_child_at(index)\n # NOTE: All deleting uses this method so that subclasses can override default behaviour when deleting a child\n @children.delete_at(index)\n end",
"def removeLine(lineNumber)\n \n\n\tlineNumber = lineNumber - 1\n\tnewQuestions = \"\"\n\n\tquestions = File.open(\"/Users/Wipf/questions.txt\", \"r+\")\n\n\t\tquestions.readlines.each_with_index do |eachLine, idx|\n\n\t\t\tif idx != lineNumber && eachLine.delete(\"#{idx}\\n\") != \"\" #each line has an index and /n ; .delete(\"#{idx}\\n\")removes it\n\t\t\t\t\t\t\t\t\t\t\t\t \t\t \n\t\t\t \tnewQuestions += eachLine\n\n\t\t\tend\n \t end\n\n questions.close\n\n \tquestions = File.open(\"/Users/Wipf/questions.txt\", \"w\")\n \tquestions.puts newQuestions\n\n\tquestions.close\n\n\tprint \"Question #{lineNumber + 1} has been removed\"\n\n\tputs \n\tputs\n\tputs \"Updated questions are:\"\n\tprint_questions\n\nend",
"def using_delete_at(array,integer)\n array.delete_at(integer)\n end",
"def remove(index)\n end",
"def clear_line_before\n CSI + '1K'\n end",
"def using_delete_at(array, int)\n array.delete_at(int)\nend",
"def using_delete_at(array, int)\n array.delete_at(int)\nend",
"def delete_at(index)\n @store.delete_at(index)\n end",
"def erase_line\n # highline does not expose the output stream\n HighLine.default_instance.instance_variable_get('@output').print \"\\r\\e[K\"\n end",
"def remove_point(index)\n MSPhysics::Newton::CurvySlider.remove_point(@address, index)\n end",
"def remove_point(index)\n MSPhysics::Newton::CurvySlider.remove_point(@address, index)\n end",
"def character(index = nil)\n return '' if collection && collection.empty?\n return collection[-1] unless index\n\n by_index(index)\n end",
"def undo_move(move)\n self.cells[move.to_i - 1] = \" \"\n end",
"def using_delete_at(array, integer)\n \n array.delete_at(integer)\n \nend",
"def backspace() \n\t\t#todo\n\t\tif @cursor_col > 0\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col - 1.. @cursor_col - 1] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\t@cursor_col -= 1\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def using_delete_at(array, num)\n array.delete_at(num)\nend",
"def using_delete_at(array, num)\n array.delete_at(num)\nend",
"def delete(index_value)\n index.delete(index_value)\n end",
"def delete_at_arr(arr, index)\n # delete the element at the position #index\n return arr.delete_at(index)\nend",
"def strip_index(input); end",
"def remove_at(index)\n @childs.delete_at(index)\n end",
"def using_delete_at (array,integer)\n array.delete_at(integer)\nend",
"def delete_at_index(index)\n if index.zero?\n self.first_node = first_node.next_node\n else\n current_node = first_node\n current_index = 0\n while current_index < (index - 1)\n current_node = current_node.next_node\n current_index += 1\n end\n node_after_deleted_node = current_node.next_node.next_node\n current_node.next_node = node_after_deleted_node\n end\n end",
"def delete element\n self.delete_at index_of(element) \n end",
"def delete element\n self.delete_at index_of(element) \n end",
"def using_delete_at(array, integer)\n array.delete_at(integer)\nend",
"def using_delete_at(array, integer)\n array.delete_at(integer)\nend",
"def using_delete_at (array, integer)\n return array.delete_at(integer)\nend",
"def delete_chars(count)\r\n return if (count > @_rl_screenwidth) # XXX\r\n\r\n if @hConsoleHandle.nil?\r\n #if (@_rl_term_DC)\r\n # buffer = tgoto(_rl_term_DC, count, count);\r\n # @_rl_out_stream.write(buffer * count)\r\n #else\r\n if (@_rl_term_dc)\r\n @_rl_out_stream.write(@_rl_term_dc * count)\r\n end\r\n #end\r\n end\r\n end"
] |
[
"0.7387134",
"0.727514",
"0.68795305",
"0.67943084",
"0.67259914",
"0.66502255",
"0.6592625",
"0.65758944",
"0.6533846",
"0.64526546",
"0.63957214",
"0.6304025",
"0.62773126",
"0.6252403",
"0.61952895",
"0.6143449",
"0.6099605",
"0.6082346",
"0.60375226",
"0.5959847",
"0.595894",
"0.5952612",
"0.5944234",
"0.59326535",
"0.591553",
"0.5907399",
"0.58981985",
"0.5884646",
"0.58760804",
"0.58516675",
"0.58512115",
"0.58506656",
"0.58493465",
"0.5833101",
"0.58137035",
"0.58098733",
"0.5787897",
"0.5781249",
"0.57774234",
"0.57520074",
"0.575183",
"0.57481396",
"0.57336533",
"0.57270724",
"0.57194626",
"0.57138836",
"0.5706853",
"0.57064694",
"0.57036465",
"0.57006973",
"0.56992865",
"0.5698386",
"0.56711006",
"0.5664666",
"0.56605846",
"0.5660095",
"0.56572133",
"0.56533754",
"0.56519604",
"0.56431425",
"0.56033975",
"0.5600296",
"0.5594716",
"0.55882794",
"0.5587367",
"0.5571827",
"0.5571701",
"0.55700517",
"0.5547167",
"0.5545799",
"0.5518792",
"0.5517434",
"0.5513076",
"0.5490281",
"0.5472927",
"0.54510474",
"0.5449678",
"0.54469824",
"0.5439265",
"0.54377526",
"0.54377526",
"0.54351526",
"0.54316425",
"0.5425955",
"0.54191774",
"0.5419099",
"0.5419099",
"0.54189163",
"0.54142964",
"0.54025984",
"0.5384029",
"0.5376418",
"0.537058",
"0.5370051",
"0.5370051",
"0.5367842",
"0.5367842",
"0.53654295",
"0.53378457"
] |
0.88591933
|
1
|
Insert the character on the line positioned at the given index.
|
def insert_character(character, index = nil)
return self unless character
Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert
.into(collection, character, index, size))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def insert_character(character, index = nil)\n return self unless character\n\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert\n .into(line, character, index, size))\n end",
"def insert_character(character)\n return self if character.is_a?(Symbol)\n\n @lines = lines.insert_character(character, y, x)\n\n right\n\n refresh\n end",
"def line_from_char(index = -1)\n send_message(:LINEFROMCHAR, index.to_i)\n end",
"def insert_text(line, col, text) \n\t\tindex = index_of_position(line, col)\n\t\t@text.insert(index, text)\n\t\ti = 0\n\t\ti += 1 while i < @line_indices.length and @line_indices[i] < index\n\t\t(0...text.length).each do |c|\n\t\t\tif text[c,1] == \"\\n\"\n\t\t\t\t@line_indices.insert(i, index + c)\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\t\t(i ... @line_indices.length).each { |i| @line_indices[i] += text.length }\n\tend",
"def insert_character(char)\n @background_grid[@state.row][@state.column] = Character.new(char, @state.style.dup)\n @state.column += 1\n end",
"def set_char at , char\n raise \"char not fixnum #{char}\" unless char.kind_of? Fixnum\n index = range_correct_index(at)\n internal_object_set( index + 1 , char )\n end",
"def insert_text(row, column, text, style = CharacterStyle.default)\n text.each_char do |char|\n self[row][column] = Character.new(char, style)\n column += 1\n end\n self\n end",
"def line_at(start_x, str)\n x = start_x\n move_to_x(start_x) if start_x > 1\n str.length.times do |i|\n $stdout.putc str[i] if x > 0 && x < @width\n x += 1\n end\n $stdout.putc \"\\n\"\n end",
"def insert(text, at: caret)\n editable? and @native.insert_text(at.to_i, text.to_s, text.to_s.length)\n end",
"def <<(char)\n @text << char\n @cursor += 1\n end",
"def <<(char)\n @text << char\n @cursor += 1\n end",
"def []=(i, chars)\n edit_mode\n\n if i.is_a?(Range)\n @text[i] = chars\n @cursor += chars.length\n return\n end\n\n if i <= 0\n before_text = \"\"\n after_text = @text.dup\n elsif i > @text.length - 1 # insert outside of line input\n before_text = @text.dup\n after_text = ?\\s * (i - @text.length)\n @cursor += after_text.length\n else\n before_text = @text[0..i-1].dup\n after_text = @text[i..-1].dup\n end\n\n if i > @text.length - 1\n @text = before_text + after_text + chars\n else\n @text = before_text + chars + after_text\n end\n\n @cursor = i + chars.length\n end",
"def move(index, character)\n @board[index] = character\n end",
"def put_to_new_next_line(txt)\n l = current_line_range()\n insert_txt_at(txt, l.end + 1)\n set_pos(l.end + 1)\n end",
"def insert_at(index)\n at(index)\n temp = @current_node.next\n blankNode = Node.new('Inserted Node')\n @current_node.next = blankNode\n blankNode.next = temp\n end",
"def character(index = nil)\n return '' if line && line.empty?\n return line[-1] unless index\n\n Vedeu::Editor::Item.by_index(line, index)\n end",
"def shift_character_by(char, index)\n new_ord = (char.ord + index)\n if new_ord > LAST_CHARACTER_ORD\n new_ord -= ALPHABET_SIZE\n elsif new_ord < FIRST_CHARACTER_ORD\n new_ord += ALPHABET_SIZE\n end\n new_ord.chr\n end",
"def draw_line(index)\n rect = Rect.new(0, 0, 0, 0)\n rect.x += 4\n rect.y += index * WLH\n rect.width = contents.width - 8\n rect.height = WLH\n self.contents.clear_rect(rect)\n self.contents.font.color = normal_color\n self.contents.draw_text(rect, @lines[index])\n end",
"def insert_at(index, e)\n push e if index > @length - 1\n node = get_node index\n insert_node_between node.prev, node, ListNode.new(e)\n end",
"def insert(k)\n\t\t\tif k == Ruvim::API::CR then\n\t\t\t\tcr\n\t\t\telse\n\t\t\t\t@buffer.insert k\n\t\t\t\tforward\n\t\t\t\tredraw_line\n\t\t\tend\n\t\t\tself\n\t\tend",
"def insert(text)\n normal \"i#{text}\"\n end",
"def insert_at(element, index)\n return insert_at_trailer(element) if index == size\n raise(StandardError, 'IndexError') if invalid_index?(index)\n return insert_at_header(element) if normalize_index(index).zero?\n\n node = find_node_by_index(index)\n do_insert_between_nodes(element, node.prev, node)\n end",
"def move(board, index, char = \"X\")\n board[index.to_i] = char\nend",
"def insert_line lineno=@current_index\n prompt = \"Insert: \"\n maxlen = 80\n #config={}; \n #config[:default] = line\n #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)\n ret, str = input_string prompt\n #ret, str = rb_getstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)\n $log.debug \" rb_getstr returned #{ret} , #{str} \"\n return if ret != 0\n\n # pad based expect @content not list\n # remove list after a while FIXME\n @list ||= @content\n @list.insert lineno, str\n ## added handler on 2010-05-23 11:46 - undo works - tested in testlistbox.rb\n fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)\n fire_dimension_changed\n end",
"def addchar(c)\n\t\tif @marked == false\n\t\t\tinsertchar(@row,@col,c.chr)\n\t\telse\n\t\t\tmark_row,row = ordered_mark_rows\n\t\t\tfor r in mark_row..row\n\t\t\t\tif (@text[r].length==0)&&((c==?\\s)||(c==?\\t)||(c==$ctrl_i)||(c==$space))\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif @colmode\n\t\t\t\t\tsc = bc2sc(@row,@col)\n\t\t\t\t\tcc = sc2bc(r,sc)\n\t\t\t\t\tif(cc>@text[r].length) then next end\n\t\t\t\t\tinsertchar(r,cc,c.chr)\n\t\t\t\telse\n\t\t\t\t\tinsertchar(r,0,c.chr)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tcursor_right\n\t\tif @linewrap\n\t\t\tjustify(true)\n\t\tend\n\tend",
"def insert_at(value, index)\n if index == 0\n prepend(value)\n elsif index >= self.size\n append(value)\n else\n prev = nil\n cur = head\n i = 0\n until i == index\n prev = cur\n cur = cur.next_node\n i += 1\n end\n prev.next_node = Node.new(value, cur)\n end\n end",
"def insert_at(data, index)\n\t\t@current_node = at(index)\n\t\t@insert_node = Node.new(data, @current_node)\n\n\t\t#Handeling the case that user inserts a node at head position (even though prepend exists for that)\n\t\tif @current_node != @head\n\t\t\t@old_link_node = at(index - 1)\n\t\t\t@old_link_node.next_node = @insert_node\n\t\telse\n\t\t\t@head = @insert_node\n\t\tend\n\tend",
"def insert(index, string)\n execute_only(:insert, index, string)\n end",
"def insert_at(data, index)\n return nil if index < 0 || index > @size \n new_node = Node.new(data, at(index))\n at(index - 1).next_node = new_node\n @size += 1\n end",
"def change_line(line_num, text) \n\t\traise \"no newlines here yet please\" if text =~ /\\n/\n\t\n\t\tix1, ix2 = line_index(line_num) + 1, line_index(line_num + 1)\n\t\t@text[ix1...ix2] = text\n\t\t(line_num...@line_indices.length).each { |i| @line_indices[i] += text.length - (ix2 - ix1) }\n\tend",
"def insert(value, index)\n end",
"def line_space(index=@buffer.line.end)\n\t\t\ts = 0\n\t\t\t@buffer[@buffer.line.start ... index].each_char do |k|\n\t\t\t\ts += char_space(k, s)\n\t\t\tend\n\t\t\t\n\t\t\ts\n\t\tend",
"def insert(chars)\n self[@cursor] = chars\n end",
"def insert(chars)\n self[@cursor] = chars\n end",
"def insert_text_at_cursor(text) \n\t\tinsert_text(@cursor_row, @cursor_col, text)\n\t\n\t\tif text.include?(\"\\n\")\n\t\t\t#todo what about multiple \\n's\n\t\t\t@cursor_row += 1\n\t\t\t@cursor_col = 0\n\t\t\t#resize_contents(500, line_num_to_coord(@text.num_lines + 1))\n\t\t\temit_changed(@cursor_row - 1)\n\t\telse\n\t\t\t@cursor_col += text.length\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def move(board, index, character = \"X\")\n board[index] = character\nend",
"def move(board, index, character = \"X\")\n board[index] = character\nend",
"def delete_character(index = nil)\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete\n .from(line, index, size))\n end",
"def delete_character(index = nil)\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete\n .from(line, index, size))\n end",
"def move(board, index, char = \"X\")\n board[index] = char\nend",
"def add(piece, index)\n @board.each_with_index do |row, position|\n if (row[index] != \"\\u26b3\") || (position == 5)\n row[index] == \"\\u26b3\" ? row[index] = piece : @board[position-1][index] = piece\n break\n end\n end\n end",
"def _rl_insert_char(count, c)\r\n return 0 if (count <= 0)\r\n\r\n incoming = ''\r\n\r\n if @rl_byte_oriented\r\n incoming << c\r\n incoming_length = 1\r\n else\r\n @pending_bytes << c\r\n if _rl_get_char_len(@pending_bytes) == -2\r\n return 1\r\n else\r\n incoming = @pending_bytes\r\n @pending_bytes = ''\r\n incoming_length = incoming.length\r\n end\r\n end\r\n\r\n if(count>1)\r\n string = incoming * count\r\n rl_insert_text(string)\r\n string = nil\r\n return 0\r\n end\r\n\r\n if @rl_byte_oriented\r\n # We are inserting a single character.\r\n #If there is pending input, then make a string of all of the\r\n #pending characters that are bound to rl_insert, and insert\r\n #them all.\r\n if (_rl_any_typein())\r\n _rl_insert_typein(c)\r\n else\r\n rl_insert_text(c)\r\n end\r\n else\r\n rl_insert_text(incoming)\r\n end\r\n\r\n return 0\r\n end",
"def insert_after\r\n @lines.insert(@line_num, TextLineBuffer.new(\"\"))\r\n @line_num = @line_num + 1\r\n end",
"def insert_at(value, index, current_index = 0, node = @head)\n return 'Not a valid index' if index > size || index.negative?\n return append(value) if index == size\n return prepend(value) if index.zero?\n\n if current_index + 1 == index\n new_node = Node.new(value)\n new_node.next_node = node.next_node\n node.next_node = new_node\n return\n end\n insert_at(value, index, current_index + 1, node.next_node)\n end",
"def insert_some_chars(string, count, col)\r\n if @hConsoleHandle\r\n _rl_output_some_chars(string,0,count)\r\n else\r\n # DEBUGGING\r\n if (@rl_byte_oriented)\r\n if (count != col)\r\n $stderr.write(\"readline: debug: insert_some_chars: count (#{count}) != col (#{col})\\n\");\r\n end\r\n end\r\n # If IC is defined, then we do not have to \"enter\" insert mode.\r\n #if (@_rl_term_IC)\r\n # buffer = tgoto(@_rl_term_IC, 0, col)\r\n # @_rl_out_stream.write(buffer)\r\n # _rl_output_some_chars(string,0,count)\r\n #else\r\n # If we have to turn on insert-mode, then do so.\r\n if (@_rl_term_im)\r\n @_rl_out_stream.write(@_rl_term_im)\r\n end\r\n # If there is a special command for inserting characters, then\r\n # use that first to open up the space.\r\n if (@_rl_term_ic)\r\n @_rl_out_stream.write(@_rl_term_ic * count)\r\n end\r\n\r\n # Print the text.\r\n _rl_output_some_chars(string,0, count)\r\n\r\n # If there is a string to turn off insert mode, we had best use\r\n # it now.\r\n if (@_rl_term_ei)\r\n @_rl_out_stream.write(@_rl_term_ei)\r\n end\r\n #end\r\n end\r\n end",
"def insert(index, path)\n\t\t@sequence[index, 0] = path.sequence\n\tend",
"def move(board, index, character)\n board[index] = character\nend",
"def rb_mvaddch row, col, char\n mvaddch row, col, char\n end",
"def move(board, index, char)\n board[index] = char\nend",
"def insert_at(node, index)\n target = self.at(index)\n target_prev = target.prev\n set_next_and_prev(target_prev, node)\n set_next_and_prev(node, target)\n self.size += 1\n end",
"def rb_mvaddch row, col, char\n super(row-@top, col-@left, char)\n end",
"def insert_at(value, index)\n prev = self.at(index - 1)\n next_node = prev.next_node\n prev.next_node = Node.new(value, next_node)\n end",
"def move (board, index, character = \"X\")\n board[index] = character\nend",
"def push_literal_at(index)\n add :push_literal, index\n return index\n end",
"def []=(i, chars)\n if i.is_a?(Range)\n @text[i] = chars\n @cursor += chars.length\n return\n end\n\n if i <= 0\n before_text = ''\n after_text = @text.dup\n elsif i == @text.length - 1\n before_text = @text.dup\n after_text = ''\n elsif i > @text.length - 1\n before_text = @text.dup\n after_text = ?\\s * (i - @text.length)\n @cursor += after_text.length\n else\n before_text = @text[0..i-1].dup\n after_text = @text[i..-1].dup\n end\n\n if i > @text.length - 1\n @text = before_text + after_text + chars\n else\n @text = before_text + chars + after_text\n end\n\n @cursor = i + chars.length\n end",
"def nextChar\n if getChar == \"\\n\"\n @line += 1\n @column = @lastLineSize\n end\n @index += 1\n @column += 1\n end",
"def add_letter(word, index, let)\n word.split(\"\").insert(index,let).join\nend",
"def move(board, index, character)\n character = \"X\"\nend",
"def insert(index, choice)\n insert_idx = find_index_by { |i| index < @indexes[i] }\n insert_idx ||= -1\n @indexes.insert(insert_idx, index)\n @selected.insert(insert_idx, choice)\n @size += 1\n self\n end",
"def insert_at(value, index)\n current = @head\n (index - 1).times do\n current = current.next_node\n end\n\n current.next_node = Node.new(value, current.next_node)\n \n end",
"def char_at(column)\n line[column, 1]\n end",
"def insert(word, inside, ind)\n first = 0\n first = ind unless ind == 0\n word[0..first-1] << inside << word[first..-1]\nend",
"def move(position, char)\n @board[position] = char\n end",
"def winsertln\n Ncurses.winsertln(pointer)\n end",
"def insert_string(str, pos)\n StringInserter.new(self, str, pos).insert_string\n end",
"def insert_element_at_given_index(array, index, element)\n array.insert(index, element)\nend",
"def move(line, column=0)\n \"\\e[#{line.to_i};#{column.to_i}H\"\n end",
"def add_line(line_index, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, dx: 0)\n sprite_stack.add_line(line_index, str, align, outlinesize, type: type, color: color, dx: dx)\n end",
"def insert_at(inode, index)\n return nil if index < 1 || index > size\n\n prev_node = get_prev_node(index) unless index == 1\n\n if index > 1\n inode.next = prev_node.next\n\n prev_node.next = inode\n\n self.size += 1\n else\n prepend(inode)\n end\n\n inode\n end",
"def move(index, character)\n @board[index] = character\n return @board\n end",
"def putch char\n @current_index ||= 0\n if @editable \n super\n return 0\n else\n match = next_match(char)\n set_buffer match unless match.nil?\n fire_handler :ENTER_ROW, self\n end\n @modified = true\n fire_handler :CHANGE, self # 2008-12-09 14:51 ???\n 0\n end",
"def insert(index, object)\n # raises IndexOutOfBoundsException if index is out of bounds [0, @length)\n # TODO\n end",
"def insert_row(row, index=@rows.length)\n @rows.insert(index, row)\n end",
"def insert_at(data, index)\n current = @head\n index.times do\n current = current.next\n end\n save = current.next.clone\n current.next = nil\n append(data)\n current.next.next = save\n end",
"def move(board, input_to_index, character = \"X\")\n board[input_to_index] = character\nend",
"def insert_text_at_line_number(source, target_file, line_number)\n if line_number > 0\n line_number -= 1\n file = IO.readlines(target_file)\n file.insert((line_number), check_source_type(source))\n File.open(target_file, \"w\") do |x|\n x.puts file\n end\n else\n raise ArgumentError, \"Line number must be 1 or higher.\".red\n end\n end",
"def handle_text_insertion pos, text\n add_command InsertionCommand.new(pos, text)\n end",
"def update_array_at_with (array, i, char)\n array[i] = X\nend",
"def move(board, input_to_index, character)\n board[input_to_index] = character\nend",
"def insert_row filename, lineno, text\n d = _read filename\n d.insert(lineno, text)\n _write filename, d\n 0\n end",
"def NextChar\r\n\t\t@Line.slice!(0, 1)\r\n\tend",
"def move(board, index, char = \"X\")\n board[index] = char\n return board\nend",
"def transaction_set_line_number(index)\n ['LX', index.to_s.rjust(4, '0')].join(@element_seperator)\n end",
"def insert(idx, *args)\n return self if args.__size == 0\n idx = Maglev::Type.coerce_to(idx, Fixnum, :to_int)\n idx += (size + 1) if idx < 0\n raise IndexError, \"#{idx} out of bounds\" if idx < 0\n self[idx, 0] = args\n self\n end",
"def insert_text(position, pattern, new_text)\n index = case pattern\n when Regexp\n if match = @body.match(pattern)\n match.offset(0)[position == :before ? 0 : 1]\n else\n @body.size\n end\n else\n pattern\n end\n @body.insert index, new_text\n end",
"def insert(str, offset, fragment)\n str.replace(str.unpack(\"U*\").insert(offset, fragment.unpack(\"U*\")).flatten.pack(\"U*\"))\n end",
"def line_char_to_offset(text, line, character); end",
"def [](index)\n line[index]\n end",
"def insert_at(index)\n if index < 0 || index >= @size\n return nil\n end\n\n next_to_last = nil\n new_node = nil\n if index == 0\n return prepend\n elsif index == @size-1\n return append\n else\n search_index = @head\n index.times {|i|\n if i == index - 1\n next_to_last = search_index\n end\n search_index = search_index.next_node\n }\n new_node = Node.new\n next_to_last.next_node = new_node\n new_node.next_node = search_index\n end\n @size += 1\n new_node\n end",
"def update(index, value)\n index = input_to_index(index)\n @cells[index] = value.token\n end",
"def move(board, index, char=\"X\")\n update_array_at_with(board, index, char)\nend",
"def move (board,index,character=\"X\")\n board[index]=character\nend",
"def putch char\n @current_index ||= 0\n if @editable \n raise \"how is it editable here in combo\"\n super\n return 0\n else\n match = next_match(char)\n text match unless match.nil?\n fire_handler :ENTER_ROW, self\n end\n @modified = true\n fire_handler :CHANGE, self # 2008-12-09 14:51 ???\n 0\n end",
"def insert(index, element)\n oob_throw(index)\n if index == 0\n @array = [element] + @array[index + 1..-1]\n else\n @array = @array[0..index-1] + [element] + @array[index..-1]\n end\n end",
"def insert_at(index,data)\n return nil if @head.nil? || index > self.size - 1\n if index == 0\n self.prepend(data)\n elsif index == self.size - 1\n self.append(data)\n else\n new_node = Node.new(data)\n current_node = @head\n prev_node = nil\n index.times do\n prev_node,current_node = current_node,current_node.next\n end\n end\n new_node.next,prev.next = current_node,new_node \n end",
"def move_to_column(x); puts \"\\e[#{x}F\" end",
"def push_literal_at(idx)\n add :push_literal, idx\n return idx\n end",
"def move(index, token = \"X\")\n @board[index] = token\n end",
"def insert_line\n down\n\n @lines = lines.insert_line(Vedeu::Editor::Line.new, y)\n\n bol\n\n refresh\n end",
"def insert(index, element)\n if index == 0\n insert_first(element)\n else\n node_before_index = get(index - 1)\n node_at_index = get(index)\n node_before_index.next_node = element\n element.next_node = node_at_index\n @size += 1\n end\n end"
] |
[
"0.81417227",
"0.68893707",
"0.68169624",
"0.6811781",
"0.6556482",
"0.64879465",
"0.6456418",
"0.64364827",
"0.6368418",
"0.627979",
"0.627979",
"0.62780356",
"0.62682813",
"0.6233469",
"0.622108",
"0.6200869",
"0.61653554",
"0.61573774",
"0.61566377",
"0.61483425",
"0.6109464",
"0.602218",
"0.5984503",
"0.5983036",
"0.59778124",
"0.59703815",
"0.59404653",
"0.5938691",
"0.59383947",
"0.59151757",
"0.5909048",
"0.5905224",
"0.5868026",
"0.5868026",
"0.5839192",
"0.583493",
"0.583493",
"0.5825563",
"0.5825563",
"0.5820846",
"0.5816938",
"0.5807266",
"0.5791822",
"0.57894224",
"0.57834125",
"0.57812816",
"0.57805264",
"0.5776092",
"0.57682055",
"0.576111",
"0.5760136",
"0.57521415",
"0.5741279",
"0.5738472",
"0.5732156",
"0.5729001",
"0.5716247",
"0.5715412",
"0.57089186",
"0.569191",
"0.56903195",
"0.56866854",
"0.5686555",
"0.5677484",
"0.5675642",
"0.56579787",
"0.56559634",
"0.56402063",
"0.5627608",
"0.5617426",
"0.56160784",
"0.559998",
"0.55927837",
"0.5587287",
"0.5584567",
"0.55835044",
"0.5582818",
"0.5580474",
"0.5579633",
"0.55758935",
"0.5569796",
"0.55536103",
"0.55531454",
"0.55524844",
"0.55371594",
"0.5532555",
"0.5532099",
"0.5528919",
"0.55234927",
"0.5521688",
"0.55205274",
"0.5513001",
"0.55052024",
"0.55037004",
"0.55027956",
"0.55006295",
"0.55003387",
"0.5495605",
"0.54908663",
"0.54849744"
] |
0.79030144
|
1
|
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
|
def add_two_numbers(l1, l2)
curr = try = ListNode.new()
sum = 0
while l1 || l2 || sum > 0
# puts l1.val
if l1
sum += l1.val
l1 = l1.next
end
if l2
sum += l2.val
l2 = l2.next
end
curr.next = ListNode.new(sum % 10)
curr = curr.next
sum /= 10
end
try.next
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove_common_digit( a, b )\n\txa = a.divmod( 10 )\n\txb = b.divmod( 10 )\n\n\treturn -1,-1 if xa[ 1 ] == xb[ 1 ] && xa[ 1 ] == 0\n\n\treturn xa[ 1 ],xb[ 1 ] if xa[ 0 ] == xb[ 0 ]\n\treturn xa[ 1 ],xb[ 0 ] if xa[ 0 ] == xb[ 1 ]\n\treturn xa[ 0 ],xb[ 1 ] if xa[ 1 ] == xb[ 0 ]\n\treturn xa[ 0 ],xb[ 0 ] if xa[ 1 ] == xb[ 1 ]\n\treturn -1,-1\nend",
"def num(x,y)\n if x > 0 && y > 0\n return x.digits.first == y.digits.first\n else\n puts \"invalid\"\n end\nend",
"def drop_trailing_zero(num)\n i, f = num.to_i, num.to_f\n i == f ? i : f\n end",
"def drop_trailing_zero(num)\n i, f = num.to_i, num.to_f\n i == f ? i : f\n end",
"def TripleDouble(num1,num2)\n arr_num1 = num1.to_s.split(//).map(&:to_i)\n arr_num2 = num2.to_s.split(//).map(&:to_i)\n first_number_valid?(arr_num1) && second_number_valid?(arr_num2) ? 1 : 0\nend",
"def test_leading_zeros\n [ \n ['02161711150', '21-61711150'],\n ['002161711150', '21-61711150'],\n ['0002161711150', '21-61711150'],\n ].each do |test, expected |\n x = CnPhoneNumber.new test\n assert_equal expected, x.to_pretty_s, \"failed on #{test}\"\n end\n end",
"def triple_double(num1, num2)\n str1 = num1.to_s\n str2 = num2.to_s\n str1.match?(/(.)\\1\\1/) && str2.match?(/(.)\\1/) ? 1 : 0\nend",
"def no_boring_zeros(num)\nreturn 0 if num == 0\n\n new_num = num.to_s\n if new_num[-1] == \"0\"\n no_boring_zeros(new_num[0..-2])\n else\n return new_num.to_i\n end\nend",
"def string_numbers_same_format?(n1, n2)\n logger.info {\"VALIDANDO NUMEROS #{n1}, #{n2}\"}\n\n if n1.size == n2.size # 0010 y 0200\n return n1.size\n elsif n1[0] != \"0\" and n2[0] != \"0\" # 10 y 200\n return 0\n else\n return false\n end\nend",
"def one_followed_by_zeros?(number)\n digits = number.to_s.split(\"\")\n first_digit = digits.shift\n first_digit.to_i == 1 && digits.size > 0 && digits.map(&:to_i).all?(&:zero?)\n end",
"def triple_double(num1,num2)\n numbers = num1.to_s.scan(/(\\d)\\1\\1/)\n return 0 if numbers.empty?\n numbers.flatten!.map! { |i| num2.to_s.scan(/#{i}{2}/) }\n numbers.flatten.empty? ? 0 : 1\nend",
"def digit_match(number1, number2)\n matches = 0\n while number1 && number2 && (number1 > 0) && (number2 > 0)\n matches += 1 if ((number1 % 10) == (number2 % 10))\n number1 /= 10\n number2 /= 10\n end\n return matches\nend",
"def triple_double(num1, num2)\n num1, num2 = num1.to_s, num2.to_s\n num1.each_char.with_index do |digit, idx|\n next if idx >= num1.size - 2\n if num1[idx + 1] == digit && num1[idx + 2] == digit\n num2.each_char.with_index do |digit2, idx2|\n next if idx >= num1.size - 1 || digit2 != digit\n return 1 if num2[idx2 + 1] == digit\n end\n end\n end\n 0\nend",
"def strip_common_digits(num, den)\n # Rejct the trivial examples\n return nil, nil if num % 10 == 0 || den % 10 == 0\n\n a = num.to_s.split('').sort\n b = den.to_s.split('').sort\n\n # Case of 49/94 is a no go\n return nil, nil if a == b\n\n common = a & b\n unless common.length == 0\n a.reject!{|x| x == common.first}\n b.reject!{|x| x == common.first}\n\n # Case that one of the numbers is like 99 and both values were rejected\n return nil, nil if a.length == 0 || b.length == 0\n\n return a.first.to_f, b.first.to_f\n end\nend",
"def triple_double(num1,num2)\n n = num1.digits.each_cons(3).select { |i| p i[0] == i[1] && i[0] == i[2] }\n n.any? && num2.to_s.include?(n[0][1..-1].join) ? 1 : 0\nend",
"def num_check(num_one,num_two)\n num_one.to_i.to_s == num_one &&num_two.to_i.to_s == num_two || num_one.to_f.to_s == num_one &&num_two.to_f.to_s == num_two\nend",
"def non_zero_digit; end",
"def remove_leading_zero(arg)\n arg.to_s.sub(\"0\", \"\")\n end",
"def gb_remove_trailing_zero (value)\n (value == value.to_i) ? value.to_i : value\n end",
"def same_digits?(a, b)\n return a != b &&\n a.to_s.split(/(?=.)/).sort == b.to_s.split(/(?=.)/).sort\nend",
"def no_boring_zeros(num)\n num_str = num.to_s\n x = -1\n\n while x > 0 do \n if num_str[x] != '0'\n break\n end\n x -= 1\n end\n num_str[0...x].to_i\nend",
"def has_leading_zeros?(value)\n if value.to_s.match(/\\./) # float value\n value.to_s.to_f.to_s.length != value.to_s.length\n else # integer value\n value.to_s.to_i.to_s.length != value.to_s.length\n end\n end",
"def vampire_test(a,b)\n if a <= 0 and b <= 0\n false\n elsif \n \n else\n arr = (a*b).to_s.chars.map(&:to_i)\n [arr.include?(a), arr.include?(b), (arr.last != 0)].include?(false)\n end\nend",
"def twoZeroForleft(valor)\n\t\ttam = valor.size\n\n\t\treturn case tam\n\t\t\twhen 1..9 then \"00#{tam}\"\n\t\t\twhen 10..99 then \"0#{tam}\"\n\t\t\twhen 100..999 then \"#{tam}\"\n\t\tend\n\n\tend",
"def twice(num)\n left_side = num.to_s.chars\n right_side = left_side.pop(left_side.length/2)\n\n left_side == right_side ? num : num * 2\nend",
"def interesting_number(number)\n return false if number.to_s.split(\"\").length < 3 \n number.to_s.split(\"\").sort[0] == \"0\" ? number.to_s.split(\"\").delete_at(0) && number.to_s.split(\"\").push(\"0\") : x = x\n return number.to_s.split(\"\")[0] < number.to_s.split(\"\")[-1] ? number.to_s.split(\"\").sort == number.to_s.split(\"\") || false : number.to_s.split(\"\").sort.reverse == number.to_s.split(\"\") || false\nend",
"def validate_num(number)\n number.to_i.to_s == number && number.to_i > 0\nend",
"def keep_leading_zeros(val = true)\n @leading_zeros = val\n end",
"def not_zero(number)\n if number == 0\n return \"-\"\n else\n return number\n end\n end",
"def test_last_digit(a, b)\n return (a % 10 == b % 10);\n end",
"def valid_number?(n_s)\n n_s.to_i.to_s == n_s && n_s.to_i != 0\nend",
"def leading_zero_on_single_digits(number)\n number > 9 ? number : \"0#{number}\"\n end",
"def ensurezero(prefix)\n prefix < 10 ? prefix.to_s.rjust(2, \"0\") : prefix\n end",
"def bitwise_exclusive(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif (val == '1' && b[index] == '0') || (val == '0' && b[index] == '1')\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend",
"def test_both_are_zero\n\t\tp = Print.new\n\t\trefute(p.one_type_is_zero?([0,0]))\n\tend",
"def zero_insert(n)\n result = ''\n index, n = 0, n.to_s\n while index < n.length - 1\n a, b = n[index].to_i, n[index + 1].to_i\n result += a.to_s\n result += '0' if a == b || (a + b) % 10 == 0\n index += 1\n end\n result += n[index]\n result\nend",
"def non_start(value_a, value_b)\n # value_a[1..-1] + value_b[1..-1]\n value_a[1...value_a.length + 1] + value_b[1..-1]\n end",
"def BitwiseOne(strArr)\n first = strArr[0]\n second = strArr[1]\n third = \"\"\n \n i = 0 \n while i < first.length\n # When i change this line to first[i] == \"0\" &&\n # second[i] == \"0\"\n # all tests passes. Why????????????????????????\n if first[i] == second[i]\n \t third << \"0\"\n else\n \t third << \"1\"\n end\n \n i += 1\n end\n third \nend",
"def same_sign?(number, number2)\n return (number * number2 > 0 or (number >= 0 and number2 >= 0))\nend",
"def number_or_zero(s)\n i= s.to_i\n i.to_s == s ? i : 0\n end",
"def twice num\n num_size = num.to_s.size\n return num * 2 if num_size.odd?\n center = num_size / 2\n left = num.to_s[0, center]\n right = num.to_s[center, num_size]\n left == right ? num : num * 2\nend",
"def twice(number)\n string_number = number.to_s\n center = string_number.size / 2\n left_side = center.zero? ? '': string_number[0..center - 1]\n right_side = string_number[center..-1]\n\n return number if left_side == right_side\n return number * 2\nend",
"def leading_zero_number(digits: T.unsafe(nil)); end",
"def twice(number)\n string_number = number.to_s\n center = string_number.size / 2\n left_side = center.zero? ? '' : string_number[0..center - 1]\n right_side = string_number[center..-1]\n\n return number if left_side == right_side\n return number * 2\nend",
"def part_two(pass)\n triples = pass.scan(/(.)\\1\\1/)\n doubles = pass.scan(/(.)\\1/)\n triples.empty? ||\n (triples.any? && (doubles - triples).any? && (triples - doubles).empty?)\nend",
"def twice(num)\n number = num.to_s\n length = number.length\n\n case\n when length.odd?\n return num * 2\n when length.even?\n left = number.slice(0, number.length / 2)\n right = number.slice((number.length / 2)..-1)\n left == right ? num : num * 2\n end\nend",
"def twice(num)\n middle_idx = num.to_s.length / 2\n if num.to_s[0, middle_idx] == num.to_s[middle_idx..-1]\n num\n else\n num * 2\n end\nend",
"def self_dividing_numbers(left, right)\n (left..right).select{|x| x.digits.all?{|y| y!=0 && x%y == 0}}\nend",
"def remove_double_zero\n @number[2..-1]\n end",
"def spaceship_problem_number(x,y)\n u = split_problem_number_into_letter_and_number(x)\n v = split_problem_number_into_letter_and_number(y)\n if u[0]!=v[0] then return u[0]<=>v[0] else return u[1]<=>v[1] end\nend",
"def check_highway_number highway_number\n if !highway_number.blank?\n i = 0\n\n while highway_number.at(i) == \"0\"\n highway_number = highway_number.from(i+1)\n end\n\n return highway_number\n\n else\n return highway_number\n end\n\n end",
"def number_is_valid_2?(number)\n str = number.to_s\n str.scan(/(\\d)\\1+/).length - str.scan(/(\\d)\\1\\1+/).length > 0\nend",
"def all_digits_odd?\n self.to_s.split('').inject(0) { |memo, s| memo + ( s.to_i%2==0 ? 1 : 0 ) } == 0\n end",
"def leading_zero_number(digits: 10)\n \"0#{(2..digits).collect { digit }.join}\"\n end",
"def bad_zero?(letters, values, non_zero)\n (0...letters.length).any? do |index|\n values[index].zero? && non_zero.include?(letters[index])\n end\n end",
"def nozero(num)\n num > 0 ? -num : num \nend",
"def twice(num)\n length = num.to_s.size\n center = length / 2\n if length.odd?\n num *= 2\n else\n num.to_s[0, center] == num.to_s[center..-1] ? num : num *= 2\n end\nend",
"def check_array(a, b)\n sum = (a[0]+a[1]+a[2])-(b[0]+b[1]+b[2])\n\tif(sum >= 0)\n\t\treturn a\n\tend\n\treturn b\nend",
"def twice(int)\n int_string_arr = int.to_s.chars()\n return int * 2 if int_string_arr.length % 2 != 0\n left_side = int_string_arr[0, int_string_arr.length/2].join.to_i\n right_side = int_string_arr[int_string_arr.length/2, int_string_arr.length/2].join.to_i\n left_side == right_side ? int : int * 2\n \nend",
"def ana4(str1, str2)\n return false unless str1.length == str2.length\n letters = Hash.new(0)\n i = 0\n while i < str1.length\n letters[str1[i]] += 1\n letters[str2[i]] -= 1\n i += 1\n end\n letters.values.all? { |value| value == 0 }\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string.to_i != 0\nend",
"def leading_zeroes(max_num_length)\n 101.times do |i|\n num_of_zeroes = max_num_length - i.digits.length\n puts \"0\" * num_of_zeroes + i.to_s\n end\nend",
"def twice(num)\n num_str = num.to_s\n if num_str.length.even?\n midpoint = num_str.length / 2\n return num if num_str[0, midpoint] == num_str[midpoint, midpoint]\n end\n num * 2\nend",
"def add_two_positive_numbers(num1,num2)\r\n if (num1 < 0) \r\n 0\r\n elsif (num2 < 0) \r\n 0\r\n else \r\n num1 + num2\r\n end\r\nend",
"def str_zero(n)\n n.to_s.sub(/\\.?0+$/, '')\nend",
"def BitwiseOne(strArr)\n result = \"\"\n first = strArr[0]\n second = strArr[1]\n idx = 0\n\n while idx < strArr[0].length\n if first[idx] == \"0\" && second[idx] == \"0\"\n result << \"0\"\n else\n result << \"1\"\n end\n idx += 1\n end\n\n result\nend",
"def unused_digits(*args)\n numbers = *args.join.split(\"\")\n digits = (0..9).to_a.map(&:to_s)\n \n (digits - numbers).join\n \nend",
"def non_integer_string?(x_value, y_value)\n x_value.is_a?(String) && x_value.scan(/\\d/).empty? || \\\n y_value.is_a?(String) && y_value.scan(/\\d/).empty?\n end",
"def twice(int)\n int = int.to_s\n half_int = int[0, int.length/2]\n return int.to_i if half_int + half_int == int\n return int.to_i * 2 if half_int + half_int != int\nend",
"def stringnum_comparison(str1, str2)\n extract_digits(str1) <=> extract_digits(str2)\n end",
"def numerify(number_string, leading_zero: T.unsafe(nil)); end",
"def bitwise_xor(num1, num2)\n bnum1 = num1.to_s(2)\n bnum2 = num2.to_s(2)\n band = (num1 | num2).to_s(2)\n puts \"num1 = \" + ( ' ' * bnum2.length ) + num1.to_s(2)\n puts \"num2 = \" + ( ' ' * bnum1.length ) + num2.to_s(2)\n puts \"b|& = \" + ( ' ' * ([bnum1.length, bnum2.length].min ) + band)\nend",
"def digit_match(n, m)\n return 1 if n == 0 && m == 0\n return 0 if n == 0 || m == 0\n return 1 if n.to_s[-1] == m.to_s[-1]\nend",
"def less_than_or_equal_to_zero(num)\n\treturn num <= 0 ? true : false\nend",
"def two_digits_number(x)\n x < 10 ? \"0#{x}\" : x.to_s\n end",
"def compare_version(v1, v2)\r\n v1 = v1.split('.')\r\n v2 = v2.split('.')\r\n longest = v1.length > v2.length ? v1 : v2\r\n (0...(longest.length)).each do |idx|\r\n one = v1[idx] || '0'\r\n two = v2[idx] || '0'\r\n return -1 if two.to_i > one.to_i\r\n return 1 if one.to_i > two.to_i\r\n end\r\n 0\r\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string != 0\nend",
"def valid_number?(number_string)\n number_string.to_i.to_s == number_string && number_string != 0\nend",
"def double?(num)\n num_str = num.to_s\n midpoint = num_str.length / 2\n num_str[0...midpoint] == num_str[midpoint..-1]\nend",
"def adjust_ones_count(base_two_num, ones_count) #'10100100', 4\n base_ten_num = base_tenify(base_two_num)\n if base_two_num.count('1') < ones_count\n add_ones(base_two_num, ones_count)\n elsif base_two_num.count('1') > ones_count\n subtract_ones(base_two_num, ones_count)\n end\nend",
"def test_rec_number_negative\n @numbers.each do |value, expected|\n # add auto negative values\n value = value.is_a?(String) ? '-' + value : value * -1\n expected = expected == '0' ? expected : '-' + expected\n\n assert_equal expected, @TS_Rec.format(value)\n end\n end",
"def min_int(in_first, in_second)\n\tcheck_pre(((in_first.int?) and (in_second.int?)))\n\t(in_first > in_second ? in_second : in_first)\nend",
"def alternate_1(a, b)\n return false if a.size != b.size\n return true if a == b\n\n # Get the ASCII char set with initial zeroed count\n counts = (?!..?~).map { |c| [c, 0] }.to_h\n\n a.each_char { |c| counts[c] += 1 }\n\n b.each_char.with_object(true) do |c|\n counts[c] -= 1\n return false if counts[c].negative?\n end\n end",
"def zero?(x, y=nil)\n x.zero? || x.abs < value(y || x)\n end",
"def double_num?(int)\n # digits is even && left half = right half\n len = int.to_s.length\n arr = int.digits.reverse\n len.even? && arr.take(len / 2) == arr.drop(len / 2)\nend",
"def one_away(first, second)\n short, long = [first, second].sort_by(&:size)\n short.each_char { |el| long.slice! long.index(el) if long.index(el) }\n long.size <= 1\nend"
] |
[
"0.72131515",
"0.715317",
"0.67107934",
"0.67107934",
"0.6662345",
"0.6639326",
"0.6507969",
"0.64560723",
"0.64537716",
"0.64105594",
"0.63988405",
"0.6396204",
"0.6384871",
"0.6380399",
"0.63803834",
"0.63660574",
"0.63544565",
"0.63032746",
"0.62759125",
"0.6265676",
"0.6213144",
"0.62056243",
"0.6121104",
"0.61183393",
"0.60646313",
"0.606029",
"0.6045613",
"0.6032414",
"0.6023114",
"0.5999443",
"0.59901386",
"0.59407234",
"0.5926295",
"0.591081",
"0.5910519",
"0.58943397",
"0.5890747",
"0.5886117",
"0.5881233",
"0.58799815",
"0.58795863",
"0.5872128",
"0.58591497",
"0.5855844",
"0.5825538",
"0.58054185",
"0.58020455",
"0.5791346",
"0.57839257",
"0.5766642",
"0.5761479",
"0.57589924",
"0.57459825",
"0.574021",
"0.57332414",
"0.573172",
"0.57202804",
"0.5711076",
"0.5699653",
"0.5691602",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56820583",
"0.56728625",
"0.5667379",
"0.566495",
"0.5658869",
"0.5658174",
"0.5644165",
"0.5639533",
"0.5639129",
"0.5623457",
"0.5593421",
"0.55867976",
"0.55742675",
"0.55698246",
"0.55684584",
"0.5566602",
"0.5558273",
"0.5558273",
"0.5555004",
"0.5549237",
"0.5547485",
"0.55450815",
"0.55319214",
"0.5523987",
"0.55177253",
"0.55134255"
] |
0.0
|
-1
|
string to integer (atoi)
|
def my_atoi(s)
new_string = ""
nums = "+-01234567890."
s.each_char do |char|
if !nums.include?(char) && char != " " && new_string == ""
return 0
elsif !nums.include?(char) && char !=" "
break
else nums.include?(char)
new_string << char
end
end
if new_string.to_i < -2**31
return -2**31
elsif new_string.to_i > 2**31 - 1
return 2**31 - 1
else
return new_string.to_i
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_integer(string)\n string.to_i\n rescue\n 0\n end",
"def string_to_integer(str)\n str.to_i\nend",
"def string_to_integer(str)\n return str.to_i\nend",
"def string_to_integer(string)\nend",
"def string_to_integer(string)\n digits = string.chars.map { |digit| MATCH[digit] }\n\n value = 0\n digits.each { |digit| value = 10 * value + digit }\n value\nend",
"def atoi(s)\n\t\tnum = 0\n\t\tacc = 0\n\t\ts.length.downto(0) { |i|\n\t\t\tif s[i] == '0'\n\t\t\t\tnum = 0\n\t\t\telsif s[i] == '1'\n\t\t\t\tnum = 1\n\t\t\telsif s[i] == '2'\n\t\t\t\tnum = 2\n\t\t\telsif s[i] == '3'\n\t\t\t\tnum = 3\n\t\t\telsif s[i] == '4'\n\t\t\t\tnum = 4\n\t\t\telsif s[i] == '5'\n\t\t\t\tnum = 5\n\t\t\telsif s[i] == '6'\n\t\t\t\tnum = 6\n\t\t\telsif s[i] == '7'\n\t\t\t\tnum = 7\n\t\t\telsif s[i] == '8'\n\t\t\t\tnum = 8\n\t\t\telsif s[i] == '9'\n\t\t\t\tnum = 9\n\t\t\telsif s[i] == '-' && i == 0\n\t\t\t\tnum = 0\n\t\t\t\t\tacc *= -1\n\t\t\t\telsif s[i] == nil || (s[i] == '+' && i == 0)\n\t\t\t\tnum = 0\n\t\t\telse\n\t\t\t\tabort(\"No se ingreso un número válido.\")\n\t\t\tend\n\t\t\tif num > 0\n\t\t\t\tacc += num * 10** (s.length-1-i)\n\t\t\tend\n\t\t}\n\t\tacc\n\tend",
"def string_to_integer(string)\n digits = string.chars.map(&:to_i)\n value = 0\n digits.each do |digit|\n value = 10 * value + digit\n end\n value\nend",
"def string_to_integer2(string)\n digits = string.chars.map { |char| HASH[char] }\n\n value = 0\n digits.each { |digit| value = 10 * value + digit }\n value\nend",
"def string_to_integer(str)\n str.chars.map { |chr| chr.ord - 48 }.reduce { |a, e| (a * 10) + e }\nend",
"def to_number(string)\n Integer(string || '')\n rescue ArgumentError\n 0\n end",
"def string_to_integer(string)\n \n digit_array = string.chars.map do |digit|\n digit = DIGITS[digit]\n end\n \n converted_string = 0\n \n digit_array.each do |digit|\n converted_string = converted_string * 10 + digit\n end\n \n converted_string\nend",
"def parse_integer(int_string)\n Integer(int_string)\n end",
"def string_to_integer(string)\n char_to_int = {\n '1'=> 1,\n '2'=> 2,\n '3'=> 3,\n '4'=> 4,\n '5'=> 5,\n '6'=> 6,\n '7'=> 7,\n '8'=> 8,\n '9'=> 9,\n '0'=> 0,\n }\n \n if string[0] == '-' then\n string[1..string.length].chars.reduce(0) { |int, char| int * 10 + char_to_int[char]} * -1\n elsif string[0] == '+' then\n string[1..string.length].chars.reduce(0) { |int, char| int * 10 + char_to_int[char]}\n else\n string.chars.reduce(0) { |int, char| int * 10 + char_to_int[char]}\n end\nend",
"def as_integer(string)\n string.gsub(/[\\n ]+/, \"\").to_i\n end",
"def my_atoi(s)\n # Alternatively, return Float::NAN instead of 0 when string is invalid\n return 0 if !s || s.length == 0\n\n i, result, sign = 0, 0, 1\n max, min = (2**31) - 1, -(2**31)\n \n i += 1 while i < s.length && s[i] == \" \"\n return 0 if i == s.length\n\n if s[i] == \"-\"\n sign = -1\n i += 1\n elsif s[i] == \"+\"\n i += 1\n end\n\n return 0 if i == s.length\n\n while i < s.length && s[i].match?(/\\d/)\n result = result * 10 + s[i].ord - \"0\".ord\n i += 1\n end\n\n result = result * sign\n\n return max if result > max\n return min if result < min\n return result\n\nend",
"def string_to_integer(string)\n integer = 0\n idx = 0\n while idx < string.length\n integer = integer * 10\n integer += string[idx].to_i\n idx += 1\n end\n\n integer\nend",
"def string_to_integer(string)\n\n\tnumbers = {'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5,\n\t\t\t\t'6' => 6, '7' => 7, '8' => 8, '9' => 9 }\n\n\tarray = string.chars.map do |n|\n\t\tnumbers[n]\n\tend\n\n\tarray.inject(0){ |total, num| total * 10 + num}\n\nend",
"def string_to_integer(string)\n\n\tnumbers = {'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5,\n\t\t\t\t'6' => 6, '7' => 7, '8' => 8, '9' => 9 }\n\n\tarray = string.chars.map do |n|\n\t\tnumbers[n]\n\tend\n\n\tarray.inject(0){ |total, num| total * 10 + num}\n\nend",
"def string_to_integer(str)\n place_idx = (str.length - 1)\n \n num = 0\n while place_idx >= 0\n digit = str[place_idx].ord - '0'.ord\n num = num + digit * (10 ** (str.length - 1 - place_idx))\n place_idx -= 1\n end\n\n num\nend",
"def to_i( str )\n return str if !str.is_a?( String )\n\n if str.match( /\\d+/ ).to_s.size == str.size\n return str.to_i\n else\n return str\n end\n end",
"def atoi(string_int)\n sum = 0\n string_int.each_byte do |char|\n sum = (sum * 10) + (char - ZERO_ASCII_CODE)\n end\n\n return sum\nend",
"def to_int(string)\n Integer(string)\nrescue ArgumentError\n nil\nend",
"def string_to_number(s)\n s.to_i\nend",
"def string_to_number(s)\n s.to_i\nend",
"def convert_string_to_number(str); end",
"def string_to_signed_int(string)\n\tcase string[0]\n\twhen '-' then -string_to_int(string[1..-1])\n\twhen '+' then string_to_int(string[1..-1])\n\telse\tstring_to_int(string)\n\tend\nend",
"def string_to_number(string)\n string.to_i\nend",
"def convert_string_input_to_integer(str)\n is_string_a_valid_integer?(str) ? str.to_i : nil\nend",
"def locNumToInt(str)\n\tnum = 0\n\tstr.split('').each {|c|\n\t\tnum += 2**(c.ord - 97)\n\t}\n\tnum\nend",
"def Atoi(args)\n\t\tparse(args)\n\t\t\t.verify\n\t\t\t.atoi\n\tend",
"def string_to_integer(str)\n arr = []\n str.each_char { |char| arr << char if STR_TO_INT.key?(char) }\n\n sum = 0\n arr.reverse.each.with_index do |num, index|\n sum += STR_TO_INT[num] * 10**index\n end\n sum\nend",
"def convert_number_string_to_integer(number_string)\n Integer(number_string.gsub(\" \", \"\"))\nend",
"def string_to_signed_integer(str)\n case str[0]\n when '-' then -string_to_integer(str.slice(1, str.length))\n when '+' then string_to_integer(str.slice(1, str.length))\n else string_to_integer(str)\n end\nend",
"def myAtoi( str)\n value = 0\n size = str.length\n i = 0\n while (i < size)\n value = (value << 3) + (value << 1) + (str[i].ord - '0'.ord)\n i += 1\n end\n return value\nend",
"def string_to_integer(str)\n convert_hash = {\n '0' => 0,\n '1' => 1,\n '2' => 2,\n '3' => 3,\n '4' => 4,\n '5' => 5,\n '6' => 6,\n '7' => 7,\n '8' => 8,\n '9' => 9,\n }\n sum = 0\n value = 0\n str_arr = str.chars\n str_arr.each do |num|\n value = convert_hash[num]\n sum += value * (10 ** (str_arr.length - (str_arr.index(num) + 1)))\n end\n sum\nend",
"def string_to_integer(str)\n str_size = str.size\n num_str = '0123456789'\n curr_size = 1\n str_size.times{curr_size *= 10}\n result = 0\n pos = 0\n\n arr = str.split('')\n\n arr.each do |a|\n pos = num_str.index(a)\n add_up = pos * curr_size\n result += add_up\n curr_size /= 10\n end\n result /= 10\nend",
"def string_to_signed_integer(str)\n case str[0]\n when '-' then -string_to_integer(str[1..-1])\n when '+' then string_to_integer(str[1..-1])\n else string_to_integer(str)\n end\nend",
"def str_to_int(str_num)\n arr_num = str_to_array_of_num(str_num)\n new_num = 0\n while arr_num.length > 0\n n = arr_num.length\n i = arr_num.shift\n new_num += i * 10**(n-1)\n end\n new_num\nend",
"def string_to_integer(string)\n base_dict = { 1 => 1, 2 => 10, 3 => 100, 4 => 1000, 5 => 10000, 6 => 100000}\n keys = base_dict.keys\n store = []; count = 0 ; result = []; \n string.each_byte {|dec| store.push(dec - 48)}\n base = keys[0,store.length].reverse\n loop do \n result.push(base_dict[base[count]] * store[count])\n count += 1\n break if count == store.length\n end\n result = result.inject(0) {|x, i| x + i}\n puts result\n end",
"def convert_To_Int( string_of_ints )\n string_of_ints.split(\" \").map { |s| s.to_i }\nend",
"def string_to_signed_integer(string)\n case string[0]\n when '-' then -string_to_integer(string[1..-1])\n when '+' then string_to_integer(string[1..-1])\n else string_to_integer(string)\n end\nend",
"def atoi(s)\n offset = '0'.ord\n neg = false\n sum = 0\n\n begin\n s.each_byte do |i|\n if i == 45 # the number is negative\n neg = true\n next\n elsif i == 46 # Number is a float, disregard mantissa\n break \n elsif (i < 48 || i > 57) # Not a valid number\n raise InvalidNumberException, \"Error: Invalid Number\"\n end\n\n # Get value of char as int and add to current sum\n tmp = i - offset\n sum = (sum * 10) + tmp\n end \n\n # Make number negative if it was originally negative\n return neg ? -sum : sum\n\n rescue InvalidNumberException => e\n abort(e.message) # inform user about error\n end\nend",
"def string_to_signed_integer(string)\n case string[0]\n when '-' then -string_to_integer(string[1..-1])\n when '+' then string_to_integer(string[1..-1])\n else string_to_integer(string)\n end\nend",
"def string_to_signed_integer(string)\n case string[0]\n when '-' then -string_to_integer(string[1..-1])\n when '+' then string_to_integer(string[1..-1])\n else string_to_integer(string)\n end\nend",
"def string_to_signed_integer(string)\n case string[0]\n when '-' then -string_to_integer(string[1..-1])\n when '+' then string_to_integer(string[1..-1])\n else string_to_integer(string)\n end\nend",
"def str_to_ints(str)\n str.chars.map{|c| c == ' ' ? c : c.ord - 64 }\nend",
"def to_i(str)\n i = 0\n b = 1\n str.each_byte { |c| i += b*c; b *= 256 }\n return i\n end",
"def binary_string_to_number(string)\n string = string.clone.force_encoding(Encoding::ASCII_8BIT)\n string.bytes.inject(0) do |number, byte|\n number * 256 + byte.ord\n end\n end",
"def string_to_signed_integer(str)\n str = '+' + str if DIGITS.keys.include?(str[0])\n case str[0]\n when '-'\n -string_to_integer(str[1..-1])\n when '+'\n string_to_integer(str[1..-1])\n end\nend",
"def string_to_integer(string)\n integer_hash = {\n '0' => 0,\n '1' => 1,\n '2' => 2,\n '3' => 3,\n '4' => 4,\n '5' => 5,\n '6' => 6,\n '7' => 7,\n '8' => 8,\n '9' => 9\n }\n\n output_array = []\n\n string.chars.reverse.each_with_index { |val, i| output_array << integer_hash[val] * 10 ** i }\n\n output_array.reduce(:+)\nend",
"def to_integer(input); end",
"def convert_to_integer(string)\n unless /^-?\\d+$/ =~ string\n raise \"'#{string}' is not an integer.\" #(1)\n end\n string.to_i\nend",
"def string_to_int(param, default = 0)\n param.nil? ? default : Integer(param)\n end",
"def s_to_i(string)\n string.chars.reduce(0) do |output, char|\n output * charset.length + char_to_codepoint(char)\n end\n end",
"def string_to_integer(string_num)\n hash = {\n '0'=>0, '1'=>1, '2'=>2, '3'=>3, '4'=>4,\n '5'=>5, '6'=>6, '7'=>7, '8'=>8, '9'=>9\n }\n int_array = string_num.chars.map { |num| hash[num] }\n tens = 1\n integer = 0\n int_array.size.times do\n integer += int_array.pop * tens\n tens *= 10\n end\n integer\nend",
"def atoi\n\t\t _int = []; _sum = 0\n\t\t\n\t\t@ascii_string.each do |value| \n\t\t\t_int.push(NILTO9[value])\n\t\tend\n\t\t\n\t\te = _int.length \t\t\n\t\n\t\t_int.each do |value|\n\t\t\t_sum = _sum + ((value/BASE)/(1/(BASE**e))).floor\n\t\t\te -= 1\n\t\tend\t\n\n\t \t_sum\n\tend",
"def hex_to_integer(str)\n values = str.chars.map.with_index do |char, index|\n CHAR_TO_DIGIT[char] * (16 ** (index - 3).abs)\n end\n\n values.reduce(:+)\nend",
"def s_to_i(s)\n if s[0..1] == \"0x\"\n return s.to_i(16)\n else\n return s.to_i(10)\n end\nend",
"def str2int1(str)\n n = str.to_uint1\n return n && n > 127 ? 128-n : n\n end",
"def get_integer(string)\n case string\n when \"one\" then 1\n when \"two\" then 2\n when \"three\" then 3\n when \"four\" then 4\n when \"five\" then 5\n when \"six\" then 6\n when \"seven\" then 7\n when \"eight\" then 8\n when \"nine\" then 9\n when \"zero\" then 0\n else string.to_i\n end\nend",
"def string_to_signed_integer(str)\n string_to_pass = (str[0] == '+') || (str[0] == '-') ? str[1..-1] : str\n value = string_to_integer(string_to_pass)\n str[0] == '-' ? -value : value\nend",
"def string_to_signed_integer(str)\n unsigned = str.start_with?('+', '-') ? str[1..-1] : str\n number = string_to_integer(unsigned)\n str[0] == '-' ? -number : number\nend",
"def string_to_signed_integer(string)\n number = string.chars.inject(0) { |sum, char| 10 * sum + ('1'..char).count }\n string[0] == '-' ? -number : number\nend",
"def string_to_integer(string, numbers)\n str_nums = string.chars.reverse\n number = 0\n str_nums.each_with_index do |num, index|\n number += numbers[num] * 10**(index)\n end\n number\nend",
"def string_to_integer(num_string)\n digits = { '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4,\n '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9 }\n\n num_string.chars.reverse.map.with_index { |char, idx| digits[char] * (10 ** idx) }.sum\nend",
"def string_to_signed_integer(string)\n convert = %w(0 1 2 3 4 5 6 7 8 9)\n number = 0\n sign = 1\n\n sign = -1 if string[0] == '-'\n string[0] = '' if string[0] == '+' || string[0] == '-'\n\n digits = string.chars.map { |char| convert.index(char) }\n digits.length.times { |i| number += digits.reverse[i] * (10**i) }\n\n number * sign\nend",
"def string_to_signed_integer(string)\n if string.start_with?('-', '+')\n string.start_with?('-') ? 0 - string_to_integer(string[1..-1]) : string_to_integer(string[1..-1])\n else\n string_to_integer(string)\n end\nend",
"def string_to_signed_integer_2 str\n sign = 1\n case\n when str[0] == '-' || str[0] == '+'\n sign = -1 if str[0] == '-'\n substr = str[1..-1]\n else\n substr = str\n end\n sign * string_to_integer(substr)\nend",
"def ascii_value(string)\r\n integer = 0\r\n string.each_char { |chr| integer += chr.ord }\r\n integer\r\nend",
"def to_num(string)\n string.gsub!(' ', '')\n string.each_char.map { |char| \"#{convert[char]} \" }.join.chop\n end",
"def string_to_signed_integer(string)\n sign = string[0] if string[0] == \"-\" || string[0] == \"+\"\n string = string.delete(sign) if sign\n integer = string_to_integer(string)\n integer = sign == \"-\" ? -integer : integer \nend",
"def convert_to_i(input)\n input.to_i\n end",
"def string_to_signed_integer2(string)\n case string[0]\n when '-' then -string_to_integer(string[1..-1]) # Apparently below you can prefix the minus symbol to the method.\n when '+' then string_to_integer(string[1..-1])\n else string_to_integer(string)\n end\nend",
"def string_to_signed_integer(str)\n if %w(- +).include?(str[0])\n sign = str[0]\n str = str[1..-1]\n end\n\n return -string_to_integer(str) if sign == '-'\n string_to_integer(str)\nend",
"def string_to_signed_integer(string)\n signed = 1\n if string.include? '-'\n signed = -1\n string.delete!('-')\n elsif string.include? '+'\n string.delete!('+')\n end\n\n string_to_integer(string) * signed\nend",
"def string_to_signed_integer_refactored(str)\n /[0-9]/.match(str[0]) ? num = str : num = str[1..-1]\n str[0] == '-' ? -string_to_integer(num) : string_to_integer(num)\nend",
"def getNum (string)\n\tif string.to_i == 0\n\t\tif string.eql?('0')\n\t\t\treturn 0\n\t\telse\n\t\t\treturn 10\n\t\tend\n\tend\n\treturn string.to_i\nend",
"def string_to_integer(str)\n num_hsh = {'1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9,'0'=>0,}\n arr = str.chars.reverse\n total = 0\n new_arr = []\n arr.each do |str|\n new_arr << num_hsh[str]\n end\n new_arr.each_with_index do |num, i|\n total += num * 10**i\n end\n total\nend",
"def get_number_from_string(s)\n s.scan(/\\d/).map(&:to_i).join.to_i\nend",
"def to_int() end",
"def to_int() end",
"def string_to_signed_integer(str)\n\n\tlookup_table = {'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, \n\t\t\t\t\t'5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9,}\n\t\t\t\t\t\n\tcharacters_in_str = str.chars\n\t\n\ttotal = 0\n\n\tmultiplier = (characters_in_str[0] == '-') ? -1 : 1\n\t\t\n\tcharacters_in_str.shift if (characters_in_str[0] == '+') || (characters_in_str[0] == '-') \n\n\tarray_of_numbers = characters_in_str.map { |char| lookup_table[char] }\n\tarray_of_numbers.reverse.each_with_index do |number, index|\n\ttotal += (number)*(10**index)\n\tend\n\n\ttotal*multiplier\n\nend",
"def convert_string_id_to_integer(string_id)\n string_id.bytes.join.to_i\nend",
"def int_version(str)\n\t\tint = 0\n\t\tbegin # Okay, if you're not exactly what I expect, just return 0\n\t\t\treturn 0 unless str =~ /^[0-9]+\\x2e[0-9]+/\n\t\t\tdigits = str.split(\".\")[0,3].map {|x| x.to_i}\n\t\t\tdigits[2] ||= 0 # Nil protection\n\t\t\tint = (digits[0] << 16)\n\t\t\tint += (digits[1] << 8)\n\t\t\tint += digits[2]\n\t\trescue\n\t\t\treturn int\n\t\tend\n\tend",
"def str_to_number(s)\r\n\t\tval_str = s.to_s()\r\n\t\tif INT_REGEX.match(val_str)\r\n\t\t\treturn val_str.to_i()\r\n\t\telsif FLOAT_REGEX.match(val_str)\r\n\t\t\treturn val_str.to_f()\r\n\t\telse\r\n\t\t\traise ArgumentError, \"can't understand numeric format '#{s}'\"\r\n\t\tend\r\n\tend",
"def convert_to_integer\n @valid = false\n DIGIT_DATA.each do |integer,data|\n if string == data['string']\n @integer = integer\n @valid = true\n end\n end\n end",
"def ints\n strs.map(&:to_i)\n end",
"def string_to_signed_integer(str)\n arr = %w[0 1 2 3 4 5 6 7 8 9]\n sign = str.slice!(0) unless arr.include?(str[0])\n multiplier = sign == '-' && sign ? -1 : 1\n\n str.chars.reverse.map.with_index { |char, i| arr.index(char) * 10**i }.reduce(&:+) * multiplier\nend",
"def string_to_signed_integer(string)\n keys_array = string.chars\n neg = 1\n if keys_array.include?(\"-\")\n neg = -1\n keys_array.delete(\"-\")\n end\n \n if keys_array.include?(\"+\")\n keys_array.delete(\"+\")\n end\n \n accumulator = 0\n keys_array.each { |character| accumulator = 10 * accumulator + DIGITS[character] }\n accumulator * neg\nend",
"def convert_to_integer(value)\n if value == \"0\"\n value = 0\n elsif value.to_i == 0\n # Set to -1 as we are dealing with range 0-255 so -1 will raise error\n value = -1\n else\n value = value.to_i\n end\n return value\nend",
"def churn_line_to_int(line)\n #/\\((\\d+)\\)/.match(line)[1].to_i\n match=/\\((\\d+) /.match(line)\n match==nil ? 0 : match[1].to_i\nend",
"def string_to_signed_integer(string)\n no_sign_integer = string_to_integer(string.delete('-+'))\n string[0] == '-' ? -no_sign_integer : no_sign_integer\nend",
"def cast_to_int(s, max_num_size = DEFAULT_MAX_NUM_SIZE)\n data = s.htb\n raise '\"script number overflow\"' if data.bytesize > max_num_size\n if require_minimal && data.bytesize > 0\n if data.bytes[-1] & 0x7f == 0 && (data.bytesize <= 1 || data.bytes[data.bytesize - 2] & 0x80 == 0)\n raise 'non-minimally encoded script number'\n end\n end\n Script.decode_number(s)\n end",
"def hex2int(hex_string)\n hex_string.split(/([a-fA-F0-9][a-fA-F0-9])/i).reject(&:blank?).map {|h| h.to_i(16)}.map(&:chr).join\n end",
"def cast_to_num(str)\n Integer(str)\n rescue ArgumentError\n Float(str)\n rescue ArgumentError\n nil\n end",
"def convert_string_to_number(str)\n matches = RE_NUMBER_STR.match(str)\n\n s = matches[:sign] == '-' ? -1 : 1\n i = matches[:integer].to_i\n f = matches[:fractional].to_i\n d = matches[:fractional] ? matches[:fractional].length : 0\n t = matches[:exponent_sign] == '-' ? -1 : 1\n e = matches[:exponent].to_i\n\n # I know this looks nutty, but it's exactly what's defined in the spec,\n # and it works.\n s * (i + f * 10**-d) * 10**(t * e)\n end",
"def BinaryConverter(str)\r\n return str.to_i(2)\r\nend",
"def value_to_integer(value)\n if @slop.strict?\n begin\n Integer(value.to_s, 10)\n rescue ArgumentError\n raise InvalidArgumentError, \"#{value} could not be coerced into Integer\"\n end\n else\n value.to_s.to_i\n end\n end",
"def cat_number(string)\n return string.split('-',5)[1].to_i\n end",
"def roman_to_integer str\r\n result = 0\r\n idx = 0\r\n\r\n # thousands\r\n while true\r\n if str[idx, 1].downcase != 'm'\r\n break\r\n end\r\n result += 1000\r\n idx += 1 \r\n end\r\n\r\n # 900 or 400 or 500\r\n if str[idx, 2].downcase == 'cm'\r\n result += 900\r\n idx += 2\r\n elsif str[idx, 2].downcase == 'cd'\r\n result += 400\r\n idx += 2\r\n elsif str[idx, 1].downcase == 'd'\r\n result += 500\r\n idx += 1\r\n end\r\n\r\n # hundreds\r\n while true\r\n if str[idx, 1].downcase != 'c'\r\n break\r\n end\r\n result += 100\r\n idx += 1\r\n end\r\n\r\n # 90 or 50 or 40\r\n if str[idx, 2].downcase == 'xc'\r\n result += 90\r\n idx += 2\r\n elsif str[idx, 2].downcase == 'xl'\r\n result += 40\r\n idx += 2\r\n elsif str[idx, 1].downcase == 'l'\r\n result += 50\r\n idx += 1\r\n end\r\n\r\n # tens\r\n while true\r\n if str[idx, 1].downcase != 'x'\r\n break\r\n end\r\n result += 10\r\n idx += 1 \r\n end\r\n\r\n # 9 or 4 or 5\r\n if str[idx, 2].downcase == 'ix'\r\n result += 9\r\n idx += 2\r\n elsif str[idx, 2].downcase == 'iv'\r\n result += 4\r\n idx += 2\r\n elsif str[idx, 1].downcase == 'v'\r\n result += 5\r\n idx += 1\r\n end\r\n\r\n # ones\r\n while true\r\n if str[idx, 1].downcase != 'i'\r\n break\r\n end\r\n result += 1\r\n idx += 1\r\n end\r\n\r\n if idx == str.length\r\n return result\r\n else\r\n puts \"#{str} is not a valid roman number\"\r\n end\r\nend"
] |
[
"0.79941136",
"0.78129214",
"0.7729582",
"0.7619611",
"0.7537958",
"0.75151134",
"0.7495805",
"0.7455603",
"0.74422896",
"0.7402852",
"0.7380027",
"0.73634326",
"0.7362075",
"0.73266894",
"0.73225176",
"0.73144335",
"0.7278621",
"0.7278621",
"0.72784317",
"0.72445947",
"0.72208965",
"0.72042876",
"0.7154783",
"0.7154783",
"0.7008425",
"0.69977707",
"0.69809026",
"0.6980897",
"0.6976409",
"0.6935633",
"0.6931809",
"0.69307816",
"0.6929368",
"0.692081",
"0.685888",
"0.6852017",
"0.6840448",
"0.6769997",
"0.67561144",
"0.6749846",
"0.6720423",
"0.6719548",
"0.6717653",
"0.6717653",
"0.6717653",
"0.6713061",
"0.6696533",
"0.66870433",
"0.6684448",
"0.66797024",
"0.6666016",
"0.66608363",
"0.6630869",
"0.6629851",
"0.6617821",
"0.6610529",
"0.65950274",
"0.65829444",
"0.6573795",
"0.6554702",
"0.65495396",
"0.6538057",
"0.6502945",
"0.6501121",
"0.6483119",
"0.6467423",
"0.64649796",
"0.64486355",
"0.644072",
"0.64334923",
"0.6404509",
"0.64029837",
"0.6390846",
"0.63770956",
"0.6345414",
"0.6339057",
"0.6317284",
"0.63169533",
"0.6316518",
"0.630979",
"0.630979",
"0.6304712",
"0.6297639",
"0.62934244",
"0.6285165",
"0.6234135",
"0.62229437",
"0.62201995",
"0.620962",
"0.61914057",
"0.60996526",
"0.6087737",
"0.6086379",
"0.6083412",
"0.6063374",
"0.6043977",
"0.60327953",
"0.6020531",
"0.60094064",
"0.59928083"
] |
0.67212194
|
40
|
container with most water
|
def max_area(height)
max_area = 0
left = 0
right = height.length - 1
while right > left
min_height = [height[left], height[right]].min
area = find_area(min_height, left, right)
if area > max_area
max_area = area
end
if height[left] >= height[right]
right -= 1
else
left += 1
end
end
max_area
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def container\n tube || well\n end",
"def container_with_most_water(height)\n max_area = 0\n left = 0\n right = height.length - 1\n \n until right - left == 0 do \n length = height[left] < height[right] ? height[left] : height[right]\n width = right - left\n area = length * width\n max_area = area if max_area < area\n \n if height[left] <= height[right]\n left += 1\n else\n right -= 1\n end\n end\n \n max_area\nend",
"def nebula; end",
"def get_drawable_objects()\n @ary = []\n @ary += @monsters\n @ary += @towers.values\n @ary += @bullets\n @ary << @placed_tower if @placed_tower\n @ary\n end",
"def read_containers\n []\n end",
"def ignore_container\n depth = 1\n\n increase_depth_on = [ StartObject.empty, StartArray.empty ]\n decrease_depth_on = [ EndObject.empty, EndArray.empty ]\n\n while depth > 0\n event = next_event\n\n if increase_depth_on.include?(event)\n depth += 1\n elsif decrease_depth_on.include?(event)\n depth -= 1\n end\n end\n end",
"def containers\n return @containers\n end",
"def container\n # TODO before/after filters\n # pie_clearfix\n \n mixin({\n margin: 'auto',\n width: column_width.em,\n max_width: 100.percent\n })\n end",
"def water\n @size += 1\n end",
"def docking(bike_collection)\n\n # If it is just a bike, no need to run through an array.\n if bike_collection.is_a?(Bike)\n if full? then storage.push(bike_collection) else raise 'no space' end\n\n # If array, loop through it and add\n elsif bike_collection.is_a?(Array)\n bike_collection.each do |bike|\n if full? then storage.push(bike) else raise 'no space' end\n end\n end\n\n end",
"def index\n @container_row = nil\n @container_rows = @container ? ContainerRow.where(container_id: @container.id).order(\"position asc\") : Container.where(site_id: @site.id)\n end",
"def container\n [[container_parent, container_element(\"box\"), container_element(\"folder\")].compact.join(\", \")]\n end",
"def container\n return @container\n end",
"def containers\n containers_exited(days_old: 1)\n containers_running(days_old: 1)\n end",
"def container(flag=nil)\n\t\talso_foreign = (flag==:also_foreign)\t\t\n\t\tif also_foreign && self.foreign_container\n\t\t\treturn self.foreign_container\n\t\telse\n\t\t\treturn self.eContainer\n\t\tend\n\tend",
"def children() []; end",
"def each_container(&block)\n collection.each_value(&block)\n end",
"def content_collection_for(storable)\n subcontainer_positions if Container === storable\n end",
"def unpack!\n @container = @container.container\n end",
"def unpack!\n @container = @container.container\n end",
"def elements; end",
"def elements; end",
"def elements; end",
"def arm_container\n @container ||= ActiveRecord::Magic::Event::Container.new\n end",
"def make_dock\n\n lowest = @map.first\n @map.each do |tile|\n if more_south(tile, lowest)\n lowest = tile\n end\n end\n\n @map.push(Dock.create(:x => lowest.x, :y => (lowest.y + 1*@height) ))\n end",
"def build_blocks\n new_blocks = []\n current_rotated_blocks.each do |block|\n block_actor = @stage.create_actor :block,\n x: block[0] * BLOCK_SIZE + @falling_piece.x,\n y: block[1] * BLOCK_SIZE + @falling_piece.y,\n grid_offset_x: block[0],\n grid_offset_y: block[1],\n image: @falling_piece.image\n\n new_blocks << block_actor\n end\n # Destroy ourselves, leaving only the blocks behind\n @falling_piece.remove\n\n new_blocks\n end",
"def outer; end",
"def words_container\n @@container || @@default_container\n end",
"def build\n physical_holdings_block\n end",
"def create_wrappers\n return if @elements_have_been_wrapped\n\n elements = fragment.children\n\n # The different groups of elements\n mapping = []\n\n # The current bucket of elements that is being\n # collected, will get reset whenever it runs into\n # an element that is a greater heading rank\n bucket = []\n\n current_level = Util.level(elements.first)\n\n elements.each_cons(2) do |element, next_element|\n bucket << element\n\n # We will have run into a greater header, so close up the bucket\n # and put it into the mapping\n if Util.is_header?(next_element) && Util.level(next_element) >= current_level\n mapping.push([current_level, bucket])\n bucket = []\n end\n\n if Util.is_header?(element)\n current_level = Util.level(element)\n end\n end\n\n # we never ended up reaching a header, so close up and move on\n if !mapping.include?(bucket)\n mapping.push([current_level, bucket])\n end\n\n base_fragment = Nokogiri::HTML.fragment(\"<div class='brief top level' />\")\n\n mapping.map! do |item|\n level, group = item\n group.reject! { |i| i.text == \"\\n\" }\n\n #puts \"Mapping! #{ level } group length: #{ group.length }\"\n\n if level == 0\n #puts \"== Condition A\"\n base_fragment = fragment = Nokogiri::HTML.fragment(\"<div class='brief top level'>#{ group.map(&:to_html).join('') }</div>\")\n elsif level <= lowest_level\n #puts \"== Condition B\"\n fragment = Nokogiri::HTML.fragment(\"<section>#{ group.map(&:to_html).join('') }</section>\")\n elsif level > lowest_level\n #puts \"== Condition C\"\n # should be able to look at the document section mappings and\n # apply custom css classes to these based on the name of the section\n fragment = Nokogiri::HTML.fragment(\"<article>#{ group.map(&:to_html).join('') }</article>\")\n end\n\n [level, [fragment]]\n end\n\n begin\n self.fragment = Brief::Document::Section::Builder.run(mapping, low: lowest_level, high: highest_level)\n rescue Brief::Document::Section::BuilderError\n ##puts \"== Error, returning default fragment: #{ $! }\"\n @fragment\n end\n end",
"def children\n (items + collections)\n end",
"def nesting() end",
"def container\n lambda do |state|\n Variable.new state\n end\n end",
"def after_container\r\n\t\t\t''\r\n\t\tend",
"def part_1\n nodes = Set.new([SHINY_GOLD])\n growing = true\n size = nodes.size\n\n while growing\n @bag_rules.each do |key, bags|\n nodes.add(key) if bags.keys.to_set.intersect?(nodes)\n end\n growing = size != nodes.size\n size = nodes.size\n end\n\n nodes.size - 1\n end",
"def containers\n return @containers unless @containers.nil?\n container_codes = []\n codes = code.split('|')\n container_codes << (codes = codes[0..-2]).join('|') while codes.size > 1\n # first is country code\n @containers = [country]\n # second, third can be parent administrative division if not nil\n # NOTE container codes is like: [\"ES|58|PO\", \"ES|58\", \"ES\"] (country is last)\n @containers += Division.find_all_by_code container_codes[0..-2], :order => :level if container_codes.size > 1\n return @containers\n end",
"def outer_box\n inner_box.map { |d| o(d) }\n end",
"def room_items(r)\n (r.z1..r.z2).each { |z|\n ((r.x1 & -16)..r.x2).step(16) { |x|\n ((r.y1 & -16)..r.y2).step(16) { |y|\n df.map_tile_at(x, y, z).mapblock.items_tg.each { |i|\n yield i if i.flags.on_ground and i.pos.x >= r.x1 and i.pos.x <= r.x2 and i.pos.y >= r.y1 and i.pos.y <= r.y2 and i.pos.z == z\n }\n }\n }\n }\n end",
"def room_items(r)\n (r.z1..r.z2).each { |z|\n ((r.x1 & -16)..r.x2).step(16) { |x|\n ((r.y1 & -16)..r.y2).step(16) { |y|\n df.map_tile_at(x, y, z).mapblock.items_tg.each { |i|\n yield i if i.flags.on_ground and i.pos.x >= r.x1 and i.pos.x <= r.x2 and i.pos.y >= r.y1 and i.pos.y <= r.y2 and i.pos.z == z\n }\n }\n }\n }\n end",
"def init_containers\n return @init_containers\n end",
"def container(inner_html)\r\n\t\t\thtml = ''\r\n\t\t\thtml << before_container\r\n\t\t\thtml << template.tag('div', container_attributes, true) + \"\\n\"\r\n\t\t\thtml << inner_html\r\n\t\t\thtml << \"</div>\\n\"\r\n\t\t\thtml << after_container\r\n\t\t\treturn html.html_safe\r\n\t\tend",
"def container\n namespace + '_container'\n end",
"def generate_initial_solution\n aux_groups = @groups.groups_deep_clone\n x=@white_space_x\n y=@white_space_y\n \n aux_groups.each do |g|\n g.allocate_this(x,y)\n y+=g.height\n end\n \n if values_bits[Constants::V_Type_of_BG] <= 4.5 #Image as background\n aux_groups << @interest_box\n end\n \n return aux_groups\n end",
"def get_front()\n \n end",
"def children; []; end",
"def collection; end",
"def collection; end",
"def init(container)\n end",
"def get_containers\n init_folder unless @init # have I been initialized?\n return @containers \n end",
"def container\n @container ||= Dry::Container.new\n end",
"def get_container_class( current_piece )\n css_classes = current_piece.effects.join(' ') # current_piece.piece_selector + ' ' + current_piece.as_child_selector + ' ' +\n # how many columns are there?\n # handling data iteration?\n # Rails.logger.debug \"current_piece=#{current_piece.id},#{current_piece.title}, current_piece.is_container?=#{current_piece.is_container?}, current_piece.template.running_data_sources.present?=#{current_piece.template.running_data_sources.present?}\"\n if current_piece.is_container?\n running_data_item = current_piece.template.running_data_item\n if running_data_item.present?\n current_page = current_piece.template.page_generator.current_page_tag\n column_count = current_piece.template.running_data_source_sction_piece.column_count\n i = current_piece.template.running_data_item_index\n #Rails.logger.debug \"i=#{i}, column_count=#{column_count}, current_piece.template.running_data_source_sction_piece=#{current_piece.template.running_data_source_sction_piece.id}\"\n css_classes << ' data_first' if column_count>0 && i==0\n css_classes << ' data_last' if column_count>0 && ((i+1)%column_count==0)\n css_classes << \" data_#{i+1}\"\n\n case running_data_item.model\n when Spree::Taxon\n css_classes << ' data_current' if running_data_item.current?\n css_classes << ' data_current_ancestor' if current_page.ancestor_ids.include?(running_data_item.id)\n when Spree::Product\n when Spree::Post\n end\n\n end\n end\n if current_piece.parent.effects.present?\n css_classes << \" child_#{current_piece.nth_of_siblings}\"\n end\n\n css_classes\n end",
"def inner_box\n [width, height, depth]\n end",
"def containers\n t = Liquid::Template.parse(template)\n t.root.nodelist.select{ |t| t.kind_of? LiquidTags::ContainsBlock }.collect{ |c| c.container_name }\n end",
"def build\n return @entries.first.elements if @entries.length == 1\n @entries.each(&:restrict)\n\n @entries.flat_map do |entry|\n entry.restricted_elements.map do |element|\n next if (level_ids_in_grain - element.grain_level_ids).present?\n element.grain_hash\n end.compact\n end.uniq.map do |grain_hash|\n elm = VirtualElement.new grain_hash, @memory_slice, @entries.map(&:element_locator)\n elm.rollup(*@virtual_metrics)\n end\n end",
"def container\n return super if super.parent_item\n\n stored_file.container\n end",
"def initialize\n @docked_bikes = []\n end",
"def collections; end",
"def layout_children\n \n end",
"def snat_pool\n super\n end",
"def collect_child_elements(memo = [])\n memo\n end",
"def collect_child_elements(memo = [])\n memo\n end",
"def collect_child_elements(memo = [])\n memo\n end",
"def find_minimum_volume(order)\n array = []\n order.items.each do |item|\n array << { dimensions: item.dimensions }\n end\n EasyBoxPacker.find_smallest_container(items: array)\nend",
"def layout\n for box in @boxes\n if !box.inPosition\n findSpot(box)\n end\n end\n end",
"def containers\n obj = parse_object(1)\n return nil unless obj && obj.m_Container && obj.m_Container.array?\n obj.m_Container.value.map do |e|\n {:name => e.first.value, :preload_index => e.second.preloadIndex.value, :path_id => e.second.asset.m_PathID.value}\n end\n end",
"def ephemeral_containers\n return @ephemeral_containers\n end",
"def container\n @container ||= find_or_create_container\n end",
"def print_layout_water_content_list_items\n [{ code: :naturally_occurring, lookup: true },\n { code: :naturally_occurring_percentage, when: :naturally_occurring?, is: [true] },\n { code: :waste_percentage },\n { code: :added_water_percentage }]\n end",
"def eclosure(t)\n stack = Array(t)\n seen = {}\n children = []\n\n until stack.empty?\n s = stack.pop\n next if seen[s]\n\n seen[s] = true\n children << s\n\n stack.concat(inverted[s][nil])\n end\n\n children.uniq\n end",
"def container\n container_class\n end",
"def container\n Dry::Types.container\n end",
"def sub_allocate array,attribute,compared_to,container,&block\r\nsub_array = pick_items(array,attribute,compared_to)\r\n\t\t\t\t# select the first empty element from Booking Items matching condition\r\n\t\t\t\tif !sub_array.empty? \r\n\t\t\t\tsub_array.each do |it|\r\n\t\t\t\t\t\tif it.first_empty_unit \r\n\t\t\t\t\t\tit.first_empty_unit.box = container\r\n\t\t\t\t\t\treturn \r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\telsif block_given?\r\n\t\t\t\tnew_array = yield array\r\n\t\t\t\t\tif !new_array.empty?\r\n\t\t\t\t\t\tnew_array.each do |bi|\r\n\t\t\t\t\t\t\t\tif bi.first_empty_unit \r\n\t\t\t\t\t\t\t\tbi.first_empty_unit.box = container\r\n\t\t\t\t\t\t\t\treturn \r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\t\t# select the first empty element from any Booking Item\r\n\t\t\t\t\t\tarray.each do |bi|\r\n\t\t\t\t\t\t\tif bi.first_empty_unit \r\n\t\t\t\t\t\t\tbi.first_empty_unit.box = container\r\n\t\t\t\t\t\t\treturn \r\n\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend\r\n\t\t\t\t#SURPLUS CONTAINER\t\r\n\t\t\t\terrors << \"Surplus Container #{container.instance_variable_get(:@container)}\" \r\n\t\t\t\telse\r\n\t\t\t\t# select the first empty element from any Booking Item\r\n\t\t\t\t\t\tarray.each do |bi|\r\n\t\t\t\t\t\t\tif bi.first_empty_unit \r\n\t\t\t\t\t\t\tbi.first_empty_unit.box = container\r\n\t\t\t\t\t\t\treturn \r\n\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tend\r\n\t\t\t\t#SURPLUS CONTAINER\t\r\n\t\t\t\terrors << \"Surplus Container #{container.instance_variable_get(:@container)}\" \r\n\t\t\t\tend\r\nend",
"def eAllContents(&block)\r\n if block\r\n if @_contained_elements\r\n @_contained_elements.each do |e|\r\n res = block.call(e)\r\n e.eAllContents(&block) if res != :prune\r\n end\r\n end\r\n nil\r\n else\r\n result = []\r\n if @_contained_elements\r\n @_contained_elements.each do |e|\r\n result << e\r\n result.concat(e.eAllContents)\r\n end\r\n end\r\n result\r\n end\r\n end",
"def pool; end",
"def pool; end",
"def lay_out\n layout = []\n @move_list.each do |move|\n end_point = layout.empty? ? ORIGIN : layout.last.end_point\n layout << Vector.new(end_point, end_point.extend(move))\n end\n layout\n end",
"def get_containers\n assert_not_nil @rdigg.info.get_containers\n end",
"def stack; end",
"def stack; end",
"def tiles\n @tiles\n end",
"def elements\r\n return @elements if @elements\r\n @elements = []\r\n @root_elements.each do |e|\r\n @elements << e\r\n @elements.concat(e.eAllContents)\r\n end\r\n @elements\r\n end",
"def countClouds(skyMap)\n marker = 0\n \n row = 0\n queue = []\n while row < skyMap.size\n col = 0\n \n while col < skyMap[row].size\n \n if skyMap[row][col] && skyMap[row][col] == \"1\"\n marker += 1\n skyMap[row][col] = marker\n queue << [row, col] \n end\n \n until queue.empty?\n coord = queue.shift\n \n left_child = [coord[0], coord[1] - 1] if coord[1] - 1 >= 0\n right_child = [coord[0], coord[1] + 1] if coord[1] + 1 < skyMap[row].size\n top_child = [coord[0] - 1, coord[1]] if coord[0] - 1 >= 0\n bottom_child = [coord[0] + 1, coord[1]] if coord[0] + 1 < skyMap.size\n \n if left_child && skyMap[left_child[0]][left_child[1]] == \"1\"\n queue << left_child\n skyMap[left_child[0]][left_child[1]] = marker\n end\n if right_child && skyMap[right_child[0]][right_child[1]] == \"1\"\n queue << right_child \n skyMap[right_child[0]][right_child[1]] = marker\n end\n \n if top_child && skyMap[top_child[0]][top_child[1]] == \"1\"\n queue << top_child \n skyMap[top_child[0]][top_child[1]] = marker\n end\n \n if bottom_child && skyMap[bottom_child[0]][bottom_child[1]] == \"1\"\n queue << bottom_child \n skyMap[bottom_child[0]][bottom_child[1]] = marker\n end\n end\n col += 1\n end\n row += 1\n end\n \n marker\nend",
"def equalize_water\r\n # get groups\r\n\tgroups = @positions.map {|x| x.group }\r\n\tgroups.uniq!\r\n\t\r\n\t# calculate sum of water content for each group\r\n groups.each do |group|\r\n\t sum = 0\r\n\t count = 0\r\n\t @positions.each do |p|\r\n\t if p.type.class.to_s == \"Water\" && p.group == group\r\n\t sum += p.water_content\r\n\t\t count += 1\r\n\t end\r\n\t end\r\n\t if count > 1\r\n\t left_over = sum % count\r\n\t amount_for_each = sum / count\r\n\t # distribute the water to postions\r\n\t @positions.each do |p|\r\n\t if p.type.class.to_s == \"Water\" && p.group == group\r\n\t p.water_content = amount_for_each\t\t\r\n\t end\r\n\t end\r\n\t\r\n\t # need to assign the left over to the first position in the the group\r\n\t @positions.each_with_index do |p,index|\r\n\t if p.type.class.to_s == \"Water\" && p.group == group\r\n\t p.water_content += left_over if left_over > 0\r\n\t\t break\r\n end\r\n end\r\n\t #@positions[0].water_content += left_over if left_over > 0\r\n\t end\r\n\tend\r\n\t\r\n\tif @log == true\r\n\t @logger.write \"water equalized\"\r\n\tend\r\n end",
"def dock(bike)\n# the method will 'raise' an exception stating no capacity, if\n# the @rack array is at capacity\n raise \"Dock at Capacity\" if @rack.length >= 20 \n# the bike variable created via our Bike class is pushed to be stored\n# in the @rack array ### more info needed\n @rack << bike\n end",
"def physical_holdings_block\n markup = ''\n children = physical_holdings\n markup = self.class.content_tag(:tbody, children.html_safe) unless children.empty?\n markup\n end",
"def unit\n\t\t\tpush [pop]\n\t\tend",
"def layer\n end",
"def before_container\r\n\t\t\t''\r\n\t\tend",
"def hits_containers\n return @hits_containers\n end",
"def elements\n\n # We'll build up an array of co-ordinates\n pieces = []\n\n # And work through the current bricks\n @bricks[@rotation].each do |brick|\n\n # Apply the current grid position to this bricks\n pieces.append( [ @grid_row + brick[0], @grid_col + brick[1] ] )\n\n end\n\n return pieces\n\n end",
"def build_containers_tree\n TreeBuilderContainers.new(\"containers_tree\", \"containers\", @sb)\n end",
"def address_containers(ident_only=false, &block)\n []\n end",
"def dock(bike)\n fail 'Capacity full' if full?\n @bikes << bike\n end",
"def boxes\n wayfinder.decorated_ephemera_boxes\n end",
"def containers\n TestLab::Container.all\n end",
"def content\n @bgs, @gbs = [], []\n img = image(\"#{HH::STATIC}/hhhello.png\")\n img.move 305, 42\n @bgs << img\n @bgs << rect(38, 0, width-38, 35, fill: \"#CDC\")\n @bgs << rect(38, 0, width-38, 38, fill: black.push(0.05)..black.push(0.2))\n @tabs, @tables = [], HH::DB.tables\n @scripts = HH.scripts\n\n hometab \"Programs\", true, 50, 13 do\n @slot.append do\n @homepane.clear{home_scripts}\n flush\n end\n end\n hometab \"Samples\", false, 168, 13 do\n @slot.append do\n @homepane.clear{sample_scripts}\n flush\n end\n end\n @bgs << rect(38, 38, 300, 4, fill: rgb(233, 239, 224))\n\n @slot.append do\n stack(height: 40){}\n @homepane = flow(margin_top: 10){home_scripts}\n flush\n end\n\n=begin\n stack :margin_left => 12 do\n background rgb(233, 239, 224, 0.85)..rgb(233, 239, 224, 0.0)\n image 10, 70\n end\n @bulletin_stack = stack do\n end\n=end\n end",
"def outer_box_with_kerf\n inner_box.map { |d| o(d, add_kerf: true) }\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end"
] |
[
"0.6220147",
"0.5935769",
"0.57515",
"0.5582832",
"0.55748445",
"0.5573974",
"0.55023944",
"0.5490273",
"0.54340255",
"0.54275185",
"0.5422245",
"0.538203",
"0.53254056",
"0.53235185",
"0.52970606",
"0.5217733",
"0.5167465",
"0.51440424",
"0.50773543",
"0.50773543",
"0.5077115",
"0.5077115",
"0.5077115",
"0.50750613",
"0.50689465",
"0.5062844",
"0.50526726",
"0.5051657",
"0.5042358",
"0.50296485",
"0.5025696",
"0.5023922",
"0.5000568",
"0.49828815",
"0.4976905",
"0.49761695",
"0.49745566",
"0.49707025",
"0.49707025",
"0.49609575",
"0.49538735",
"0.49469775",
"0.49460194",
"0.49411413",
"0.49342287",
"0.49335846",
"0.49335846",
"0.49333766",
"0.49326432",
"0.492779",
"0.4927703",
"0.49273407",
"0.49246615",
"0.49227798",
"0.49224567",
"0.49192956",
"0.49191773",
"0.49167794",
"0.49084032",
"0.4907061",
"0.4907061",
"0.4907061",
"0.4904287",
"0.4903817",
"0.4902221",
"0.490162",
"0.48897114",
"0.4886025",
"0.48821253",
"0.48778003",
"0.48720568",
"0.48674646",
"0.48642507",
"0.48615664",
"0.48615664",
"0.4849937",
"0.4849149",
"0.4848928",
"0.4848928",
"0.48407263",
"0.4839721",
"0.48359397",
"0.48299512",
"0.48283333",
"0.48268896",
"0.48237407",
"0.4815103",
"0.4809202",
"0.48030812",
"0.4799646",
"0.47938442",
"0.4790437",
"0.4789382",
"0.47884876",
"0.47883922",
"0.4788204",
"0.47870705",
"0.47755677",
"0.47755677",
"0.47755677",
"0.47755677"
] |
0.0
|
-1
|
Given a string containing digits from 29 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
|
def letter_combinations(digits)
map = "- - abc def ghi jkl mno pqrs tuv wxyz".split
charsets = digits.chars.map { |d| map[d.to_i].chars }
digits == "" ? [] : [''].product(*charsets).map(&:join)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def letter_combinations(digits)\n dictionary = {\n '1' => [],\n '2' => ['a', 'b', 'c'],\n '3' => ['d', 'e', 'f'],\n '4' => ['g', 'h', 'i'],\n '5' => ['j', 'k', 'l'],\n '6' => ['m', 'n', 'o'],\n '7' => ['p', 'q', 'r', 's'],\n '8' => ['t', 'u', 'v'],\n '9' => ['w', 'x', 'y', 'z']\n }\n\n res = [[]]\n digits.split(\"\").each do |num|\n ltrs = dictionary[num]\n res = permute(res, ltrs)\n end\n\n new_res = []\n res.each { |bucket| new_res << bucket.join(\"\") }\n new_res \nend",
"def to_letters(num_string)\n num_string.split.map { |num| convert.key(num) }.join\n .scan(/...../).join(' ')\n end",
"def numbers_to_letters(string)\n convertion_table = ('A'..'Z').to_a\n words = string.split('+')\n words.map do |word|\n word.scan(/\\d+/).map{|letter| convertion_table[letter.to_i - 1]}.join\n end.join(' ')\nend",
"def letter_combinations(digits)\n\n DIGIT_HASH = {\n '2' => ['a', 'b', 'c'],\n '3' => ['d', 'e', 'f'],\n '4' => ['g', 'h', 'i'],\n '5' => ['j', 'k', 'l'],\n '6' => ['m', 'n', 'o'],\n '7' => ['p', 'q', 'r', 's'],\n '8' => ['t', 'u', 'v'],\n '9' => ['w', 'x', 'y', 'z']\n }\n\n res = []\n\n digits.each do |digit|\n \n if res.empty?\n res = DIGIT_HASH[digit]\n else\n temp_array = []\n res.each do |stored|\n DIGIT_HASH[digit].each do |new_letter|\n temp_array.push(stored + new_letter)\n end\n end\n res = temp_array\n end\n\n end\n\n res\nend",
"def phone_letter_combinations(digits)\n\nend",
"def get_pandigitals\n return (0..9).to_a.permutation.map(&:join)\nend",
"def number_to_letter(n)\n letters = +''\n while n > 0\n index = (n - 1) % 26\n letters.prepend(LETTERS[index])\n n = (n - index - 1) / 26\n end\n letters\n end",
"def get_phone_alpha_mappings()\n phone_mappings = {\n 'a' => 2,\n 'b' => 2,\n 'c' => 2,\n 'd' => 3,\n 'e' => 3,\n 'f' => 3,\n 'g' => 4,\n 'h' => 4,\n 'i' => 4,\n 'j' => 5,\n 'k' => 5,\n 'l' => 5,\n 'm' => 6,\n 'n' => 6,\n 'o' => 6,\n 'p' => 7,\n 'q' => 7,\n 'r' => 7,\n 's' => 7,\n 't' => 8,\n 'u' => 8,\n 'v' => 8,\n 'w' => 9,\n 'x' => 9,\n 'y' => 9,\n 'z' => 9\n }\n phone_mappings\nend",
"def solution(number)\n accumulator =\n number.to_s.reverse.each_char.with_index.map do |letter, index|\n character_map(letter.to_i, *@roman_symbols[index * 2, 3])\n end\n accumulator.reverse.join \nend",
"def to_strings\n digits.inject(['']) do |results, digit|\n combinations(results, digit)\n end\n end",
"def get_alpha(num)\n alpha26 = ('A'...'AA').to_a\n return \"\" if num < 1\n string = \"\"\n loop do\n num, r = (num-1).divmod(26)\n string.prepend(alpha26[r])\n break if num.zero?\n end\n string\n end",
"def get_alphabets_every_by(num)\n ('A'..'Z').select.with_index(1) do |_alpha, index|\n (index % num).zero?\n end\nend",
"def solve_cipher(string, n)\n\n#Split each element of the string to get and array and return an array where each element is x (to operate with each element)\n string.split('').map do |x|\n#Create a new variable that will be the new index for each element.\n new_index = x.ord + n\n \n#Define the new index value with if conditional statements.\n\n#The value for whitespace is its value -26 as it is not included in the alphanumerical rules defined above\nif x == ' '\n new_index = ' '.ord - 26\nend\n\n\n#Declare the values of the index where it is above z's\nif new_index > 'z'.ord\n new_index = 'a'.ord + new_index - 'z'.ord - 1\nend\n\n#Declare the values of the index where it is beyond a's\nif new_index < 'a'.ord\n new_index = 'z'.ord - ('a'.ord - new_index) + 1\nend\n \n #Make the function return the list of numbers converted into letters \n new_index.chr\n\nend.join\n\nend",
"def number_decoder( input )\n output = \"\"\n \n # build number to letter hash\n translator = Hash.new\n letters = ('A'..'Z').to_a\n letters.each_index{|i| translator [(i+1).to_s] = letters[i] }\n \n input.each(' ') do |nibble|\n\n \n num = nibble.strip.to_i\n if (num == 0 or num.nil?) then output << \" \"\n else\n case (num-1)/26\n when 0 then output << translator[num.to_s]# + ' '\n when 1 then output << translator[(num - 26).to_s]\n end\n end\n end\n \n output\nend",
"def number_encoder( input )\n output = \"\"\n \n # build letter to number hash\n translator = Hash.new\n letters = ('A'..'Z').to_a\n letters.each_index{|i| translator[ letters[i] ] = i+1 }\n\n \n # seperates into chunks\n input.each(' ') do |chunk|\n chunk.each_char() { |char| output << translator[char].to_s + ' ' }\n end\n output.rstrip!\n output \nend",
"def distinct_subseq_ii(s)\n alphabets = ('a'..'z').to_a\n dict = Array.new(27, 0)\n mod = 10 ** 9 + 7\n total = 1\n s.chars.each do |char|\n index = alphabets.index(char) + 1\n combo = total * 2 - dict[index]\n dict[index] = total # if 'c' ever appears again, it will clash with the current combos.\n total = combo < 0 ? 0 + mod : combo % mod\n end\n total - 1 # subtract empty string\nend",
"def generate_letter(cnt)\n letters = (\"0\"..\"9\").to_a + (\"a\"..\"f\").to_a\n word = \"\"\n cnt.times do\n word << letters.sample\n end\n word\nend",
"def solve(text)\n alpha = ('a'..'z').to_a\n answer = ''\n text.each_char do |char|\n new_idx = (alpha.length - 1) - alpha.index(char)\n answer += alpha[new_idx]\n end\n return answer\nend",
"def generate_code(number)\n charset = Array('A'..'Z') + Array('a'..'z')\n Array.new(number) { charset.sample }.join\nend",
"def play_pass(str, n)\n str.chars.map.with_index do |ltr, idx|\n if ltr =~ /[a-zA-Z]/\n if ltr.ord + n > 90 || ltr.ord + n > 122\n ltr = (ltr.ord - 26 + n).chr\n else\n ltr = (ltr.ord + n).chr\n end\n \n if idx.odd?\n ltr = ltr.downcase\n else\n ltr = ltr.upcase\n end\n \n elsif ltr =~ /\\d/\n ltr = 9 - ltr.to_i\n else\n ltr\n end\n end.join.reverse\nend",
"def number_letters(number)\n\nsingles = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\n\nteens = ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n\ntens = ['ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\nnumber_word = nil\n if number == 1000\n return 'one thousand'\n elsif number >= 100 && number < 1000\n hundreds_digit = number / 100\n remainder = number % 100\n if remainder == 0\n number_word = singles[hundreds_digit - 1] + ' hundred'\n else\n number_word = singles[hundreds_digit - 1] + ' hundred and ' + \"#{number_letters(remainder)}\"\n end\n elsif number >= 20 && number <= 99\n tens_digit = number / 10\n remainder = number % 10\n if remainder == 0\n number_word = tens[tens_digit - 1]\n else\n number_word = tens[tens_digit - 1] + '-' + singles[remainder - 1]\n end\n elsif number >= 11 && number <= 19\n remainder = number % 10\n number_word = teens[remainder - 1]\n elsif number == 10\n return 'ten'\n else\n number_word = singles[number - 1]\n end\nnumber_word\nend",
"def calculate_alphabet(str)\nend",
"def letters_and_digits\n self.to_s.scan(/\\w/).join\n end",
"def get_poss_characters()\n alpha = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n poss = []\n for i in (0..alpha.length-1)\n poss.push(alpha[i])\n end\n return poss\nend",
"def generate_code(number)\n charset = Array('A'..'Z') + Array(0..9)\n Array.new(number) { charset.sample }.join\n end",
"def split_problem_number_into_letter_and_number(x)\n if x.to_i>0 then return ['',x.to_i] end # for efficiency\n if x=~/([a-z]*)([0-9]+)/ then\n return [$1,$2.to_i]\n else\n fatal_error(\"illegal problem number, #{x}\")\n end\nend",
"def number_encoding(str)\n result = ''\n str.downcase.each_char do |char|\n if char =~ /[a-z]/\n result << (char.ord - 96).to_s\n else\n result << char\n end\n end\n result\nend",
"def form_words(number = \"6686787825\")\n # Once we have the sequences, we would want to convert them to a Cartesian product\n # to achieve the desired result\n matrix = split_into_sequences(number).map do |a, b|\n words_for_a = @word_list & Set.new(combination(a.chars))\n words_for_b = @word_list & Set.new(combination(b.chars))\n words_for_a.to_a.product words_for_b.to_a\n end.reject(&:empty?)\n\n combination_word_list = []\n\n # Take two elements from the array and form a combination\n matrix.flatten.each_slice(2) { |comb| combination_word_list.push(comb) }\n\n # Lookup dictionary if we can find an exact match for the given number\n final_word = (@word_list & Set.new(combination(number.chars))).first\n\n # Join each combination to see if it matches the exact word that\n # the give number forms, if yes then we replace the word combination array\n # with the full word.\n combination_word_list.map! do |array|\n if array.join(\"\") == final_word\n final_word\n else\n array\n end\n end\n\n puts combination_word_list.inspect\n combination_word_list\n end",
"def string_expansion(str)\n result = []\n multiple = 1\n str.each_char do |char|\n if (char.to_i == 0) && (char != \"0\")\n result << (char * multiple)\n else multiple = char.to_i\n end\n end\n result.join\nend",
"def generate_code(number)\n charset = Array('A'..'Z') + Array('a'..'z')\n Array.new(number) { charset.sample }.join\n end",
"def letters\n @letters ||= {\n \"2\" => ['a','b','c'],\n \"3\" => ['d','e','f'],\n \"4\" => ['g','h','i'],\n \"5\" => ['j','k','l'],\n \"6\" => ['m','n','o'],\n \"7\" => ['p','q','r','s'],\n \"8\" => ['t','u','v'],\n \"9\" => ['w','x','y','z']\n }\n end",
"def solution(string)\n\talphabet = (\"A\"..\"Z\").to_a\n\n\tarr = []\n\tstring.chars.each do |letter|\n\t\tif alphabet.include?(letter)\n\t\t\tarr << \" \"\n\t\t\tarr << letter\n\t\telse\n\t\t\tarr << letter\n\t\tend\n\tend\narr.join\nend",
"def number_letters_count\n ones = { \n 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five',\n 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten',\n 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen',\n 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen',\n 19 => 'nineteen' \n }\n \n tens = { \n 20 => 'twenty', 30 => 'thirty', 40 => 'forty', 50 => 'fifty', 60 => 'sixty', \n 70 => 'seventy', 80 => 'eighty', 90 => 'ninety' \n }\n\n (1..1000).to_a.map do |num|\n digits = num.to_s.chars.map(&:to_i)\n if num < 20\n num = ones[num]\n elsif num >= 20 && num < 100\n if digits[1] == 0\n num = tens[digits[0] * 10]\n else \n num = tens[digits[0] * 10] + ' ' + ones[digits[1]]\n end\n elsif num >= 100 && num < 1000\n if digits[1] == 0 && digits[2] == 0\n num = ones[digits[0]] + ' hundred'\n elsif digits[1] == 0 && digits[2] != 0\n num = ones[digits[0]] + ' hundred' + ' and ' + ones[digits[2]]\n elsif ones.include? digits[1..2].join.to_i\n num = ones[digits[0]] + ' hundred' + ' and ' + ones[digits[1..2].join.to_i]\n elsif digits[1] != 0 && digits[2] == 0\n num = ones[digits[0]] + ' hundred' + ' and ' + tens[digits[1] * 10]\n elsif digits[1] != 0 && digits[2] != 0\n num = ones[digits[0]] + ' hundred' + ' and ' + tens[digits[1] * 10] + ' ' + ones[digits[2]]\n end\n elsif num == 1000\n num = 'one thousand'\n end\n end.map { |word| word.gsub(' ', '') }.join.length\nend",
"def atoi(word)\n results = []\n word.chars.each do |char|\n letter = change_letter(char)\n results << letter\n end\n results.each do |integer|\n print integer\n end\n puts \"\"\nend",
"def rampant_repeats(str, hash)\n (str.split(\"\").map do |char| \n if hash.keys.include?(char)\n # if hash.has_key?(char)\n char * hash[char] \n else\n char\n end\n end).join(\"\")\nend",
"def rampant_repeats(str, hash)\n (str.split(\"\").map do |char| \n if hash.keys.include?(char)\n char * hash[char] \n else\n char\n end\n end).join(\"\")\nend",
"def helper(str)\n return 1 if str.size == 0\n\n result = helper str[1..]\n result += helper(str[2..]) if str.size >= 2 && str[0...2].to_i <= 26\n\n result\nend",
"def string_expansion(str)\n \n return str if str.eql?('') || str.chars.all? {|letter| letter.match?(/[a-z,A-Z]/)} \n \n results = '' \n \n characters = str.chars\n \n current_number = 0\n \n characters.each_with_index do |letter, index|\n if index.eql?(0) && letter.match?(/[a-z,A-Z]/)\n results << letter\n elsif letter.match? (/[0-9]/)\n current_number = letter\n elsif letter.match? (/[a-z,A-Z]/)\n results << letter * current_number.to_i\n end\n end\n \n results\n \nend",
"def lexical_combinations(strings)\n l = []\n if strings.length == 1\n l.add(strings)\n else\n strings.each do |letter|\n others = strings.except(letter)\n lexical_combinations(others).each do |subcombo|\n l.add([letter] + subcombo)\n l.add([letter + subcombo.first] + subcombo.butfirst)\n end\n end\n end\n l\nend",
"def play_pass(str, n)\n alphabet = (\"A\"..\"Z\").to_a\n shifted_alphabet = alphabet.rotate(n)\n ary = str.chars\n \n ary.each_with_index do |item, index|\n if item == item.to_i.to_s\n ary[index] = (9 - item.to_i).to_s\n elsif alphabet.include?(item)\n ind = alphabet.index(item)\n ary[index] = shifted_alphabet[ind]\n end\n end\n ary.map!.with_index { |item, index| index.odd? ? ary[index].downcase : ary[index].upcase }\n \n ary.join('').reverse\nend",
"def brutus_cipher(string)\n\tresult = \"\"\n\tis_letter = /[a-zA-Z]/\n\tfor x in 0...string.length do\n\t\tputs \"For loop iterating...\"\n\t\tif is_letter.match(string[x])\n\t\t\tif string[x].ord.between?(88, 91) || string[x].ord > 119\n\t\t\t\tresult += (string[x].ord - 23).chr\n\t\t\telse\n\t\t\t\tresult += (string[x].ord + 3).chr\n\t\t\tend\n\t\telse\n\t\t\tresult += string[x]\n\t\tend\n\tend\n\treturn result\nend",
"def encode_digit(d)\n d + 22 + 75 * (d < 26 ? 1 : 0)\n # 0..25 map to ASCII a..z or A..Z \n # 26..35 map to ASCII 0..9\n end",
"def countletters(number)\n\n numerical = number.to_s\n\n dictionary = {\n 1 => \"one\", 2 => \"two\", 3 => \"three\", 4 => \"four\", 5 => \"five\",\n 6 => \"six\", 7 => \"seven\", 8 => \"eight\", 9 => \"nine\", 10 => \"ten\",\n 11 => \"eleven\", 12 => \"twelve\", 13 => \"thirteen\", 14 => \"fourteen\",\n 15 => \"fifteen\", 16 => \"sixteen\", 17 => \"seventeen\", 18 => \"eighteen\",\n 19 => \"nineteen\", 20 => \"twenty\", 30 => \"thirty\", 40 => \"fourty\", 50 => \"fifty\",\n 60 => \"sixty\", 70 => \"seventy\", 80 => \"eighty\", 90 => \"ninety\", 100 => \"hundred\",\n 1000 => \"thousand\", 1000000 => \"million\", 1000000000 => \"billion\"\n }\n\n if numerical.length == 2\n if numerical[0]\n p \"#{dictionary[20]}#{dictionary[number-20]}\"\n end\n end\n\nend",
"def solve(s)\n alphabet = ('a'..'z').to_a\n s.gsub(/[aeiou]/, ' ').split.map { |l| l.chars.map { |i| alphabet.index(i) + 1 }.sum }.max\nend",
"def combinations(num_digits)\n combos = []\n (1..num_digits).each do |len|\n combos += (0...num_digits).to_a.combination(len).to_a\n end\n combos\nend",
"def digit_list(number)\n number.to_s.chars.map { |char| char.to_i }\nend",
"def dealphabetize(\n alphabet = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n )\n str = to_s\n alphabet = alphabet.to_s\n len = alphabet.length\n str.chars.inject(0) do |num, char|\n i = alphabet.index(char)\n raise(\"Character not in alphabet: '#{char}'\") if i.nil?\n\n num * len + i\n end\n end",
"def frequent_letters(string)\n hash = Hash.new(0)\n results = []\n\n string.each_char do |char|\n hash[char] += 1\n end\n\n hash.each do |k, v|\n if v > 2\n results << k\n end\n end\n\n return results\nend",
"def letter_counts(limit)\r\n\t# Define word for cooresponding number\r\n\tnumbers_to_words = {one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8, nine: 9, ten: 10,\r\n\t\t\t\t\t\t\t\t\t\t eleven: 11, twelve: 12, thirteen: 13, fourteen: 14, fifteen: 15, sixteen: 16, seventeen: 17, eighteen: 18,\r\n\t\t\t\t\t\t\t\t\t\t nineteen: 19, twenty: 20, thirty: 30, forty: 40, fifty: 50, sixty: 60, seventy: 70, eighty: 80, ninety: 90}\r\n\r\n\t#Variable to count total length\r\n\tcount = 0\r\n\t# Iterate through every number up to limit\r\n\t(1..limit).each do |num|\r\n\t\t# word variable will store word string for current number\r\n\t\tword = \"\"\r\n\t\t# Convert number to array so it is easier to manipulate\r\n\t\tnum_array = num.to_s.split(\"\")\r\n\r\n\t\t# If only one digit long, simply assign key to word\r\n\t\tif num_array.length == 1\r\n\t\t\tx = num_array.join.to_i\r\n\t\t\tword << numbers_to_words.key(x).to_s\r\n\t\tend\r\n\r\n\t\t# If four digits long, add \"one thousand\" to number\r\n\t\tif num_array.length == 4\r\n\t\t\tnum_array.shift\r\n\t\t\tword << \"onethousand\"\r\n\r\n\t\t# If at least three digits, add relevant 1 through 9 key with \"hundred\"\r\n\t\telsif num_array.length >= 3\r\n\t\t\tx = num_array.shift.to_i\r\n\t\t\tword << numbers_to_words.key(x).to_s\r\n\t\t\tword << \"hundred\"\r\n\t\t\t# If number continues after third digit, include \"and\"\r\n\t\t\tword << \"and\" unless num_array == [\"0\",\"0\"]\r\n\t\tend\r\n\r\n\t\t# If at least a two digit number,\r\n\t\tif num_array.length >= 2\r\n\t\t\t# If higher than 20, add relevant 'multiple of ten' key before single key\r\n\t\t\tif num_array.join.to_i > 20\r\n\t\t\t\tx = num_array.shift.to_i * 10\r\n\t\t\t\tword << numbers_to_words.key(x).to_s\r\n\t\t\t\tx = num_array.join.to_i\r\n\t\t\t\tword << numbers_to_words.key(x).to_s\r\n\t\t\t# If less than 20, simply assign key to word\r\n\t\t\telse\r\n\t\t\t\tx = num_array.join.to_i\r\n\t\t\t\tword << numbers_to_words.key(x).to_s\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\t# Output entire word and increase count by word length\r\n\t\tputs word\r\n\t\tcount += word.length\r\n\tend\r\n\tputs count\r\nend",
"def repeater(string)\r\n result = \"\"\r\n string.chars.each do |letter|\r\n result << letter * 2\r\n end\r\n result\r\nend",
"def encode_digit(d)\n d + 22 + 75 * (d < 26 ? 1 : 0)\n # 0..25 map to ASCII a..z\n # 26..35 map to ASCII 0..9\n end",
"def the3(number)\n english = ''\n digits = {'0' => '', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five',\n '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine'}\n for i in 0..2\n case i\n when 0 then english += digits[number[i]] + (number[i] == '0' ? '' : ' hundred ')\n when 1 then english += number[i] == '0' ? '' : the2(number[1..2])\n when 2 then english += number[i - 1] == '1' ? '' : digits[number[i]]\n end\n end\n return english\nend",
"def stringToPerms(rotor)\n outPerms = Array.new\n numsUsed = Array.new\n subPerms = Array.new\n i = 0\n\n while numsUsed.length < 26 do\n if (!numsUsed.include?(i)) then\n numsUsed.push(i)\n subPerms.push(i)\n i = charToNum(rotor[i])\n \n if(numsUsed.length >= 26) then\n outPerms.push(subPerms)\n end\n else\n outPerms.push(subPerms)\n subPerms = Array.new\n for n in 0...26 do\n if(!numsUsed.include?(n)) then\n i = n\n break\n end\n end\n end\n end\n\n return outPerms\nend",
"def alternate string, num\n range = ('a'..'z').to_a.rotate(num)\n working = string.split(//)\n working.map! do |x|\n x = range[('a'..'z').to_a.index(x)]\n end.join\n \n \n\nend",
"def solve_cipher(input)\n\n\tputs \"\\n\\nCAESAR'S CYPHER -- ITERATION 1\\n\"\n\t \n\t#Char -> convert string to characters \n\t#map() -> convert all the items \n\t#ord -> Return the Integer ordinal of a one-character string\n\n\tinput_ascii = input.chars.map(&:ord)\n\toutput_ascii = []\n\t\n\tinput_ascii.each do |item|\n\n\t\tif (item >= 97 and item <= 122)\n\t\t\tlowercase = item - 97\n\t\t\toutput_ascii << 97 + (lowercase - 1) % 26\n\n\t\telsif (item >= 65 and item <= 90)\n\t\t\tuppercase = item - 65\n\t\t\toutput_ascii << 65 + (uppercase - 1) % 26\n\t \tend\n\tend\n\n\tcypher = output_ascii.map(&:chr)\n\tresult = cypher.join\n\n\treturn result\nend",
"def randz(num)\n (0...num).map{ ('a'..'z').to_a[rand(26)] }.join\nend",
"def randz(num)\n (0...num).map{ ('a'..'z').to_a[rand(26)] }.join\nend",
"def rampant_repeats(str, hash)\n n_str = ''\n str.each_char do |char|\n if hash.has_key?(char) \n n_str += char * hash[char]\n else\n n_str += char\n end\n end\n n_str\nend",
"def generate_alphabet\n (\"a\"..\"z\").to_a\nend",
"def rampant_repeats(string, hash)\n new_str = ''\n\n string.each_char do |char|\n if hash.has_key?(char)\n new_str += (char*hash[char])\n else\n new_str += char\n end\n end\n new_str\nend",
"def compress(chars)\n return 1 if chars.size == 1\n hash = {}\n\n chars.each do |char|\n if hash[char]\n hash[char] += 1\n else\n hash[char] = 1\n end\n end\n\n answer = []\n hash.each do |key, value|\n if value == 1\n answer << key\n else\n if value > 9\n answer << key\n value.to_s.each_char do |char|\n answer << char\n end\n else\n answer << key\n answer << value.to_s\n end\n end\n end\n\n answer.size\nend",
"def rampant_repeats(str, hash)\n new_str = ''\n str.each_char do |char|\n if hash.has_key?(char)\n hash[char].times do\n new_str << char\n end\n else\n new_str << char\n end\n end\n new_str\nend",
"def letter_to_place(str)\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n arr = []\n str.each_char {|letter| arr << alphabet.index(letter) + 1}\n arr\nend",
"def caesar_cipher(str, num)\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n cipher = ''\n\n (0...str.length).each do |i|\n char = str[i]\n index = alphabet.index(char) + num\n cipher += alphabet[index % 26]\n end\n return cipher\nend",
"def caesar_cipher(str, num)\r\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\r\n cypher = alphabet.split(\"\").map.with_index do |char, i|\r\n if !(alphabet.split(\"\").index(char) + num >= alphabet.split(\"\").length)\r\n alphabet.split(\"\")[alphabet.split(\"\").index(char) + num]\r\n else\r\n alphabet.split(\"\")[alphabet.split(\"\").index(char) + num - alphabet.split(\"\").length]\r\n end\r\n end\r\n cryptography = ''\r\n str.each_char do |char|\r\n cryptography += cypher[alphabet.index(char)]\r\n end\r\n return cryptography\r\nend",
"def translate_string_to_number(input)\n\n #take the input\n #break it up into individual letters\n #map the letters to a dictionary (a = 1) or\n #map the input to a placement in an array\n\nend",
"def change a\n a = a.downcase\n end_string = ''\n ('a'..'z').each { |let| a.include?(let) ? end_string << '1' : end_string << '0' }\n end_string\nend",
"def digits_explode(str)\n digits = str.chars\n results = digits.map do |num_str|\n new_str = ''\n num_str.to_i.times do\n new_str += num_str\n end\n new_str\n end\n results.join\nend",
"def caesar_cipher(string=\"What a string!\",num=5)\n newstring=''\n string.scan(/./) do |x|\n asc=x.ord\n if (97..122).include?(asc)\n if asc>122-num\n asc=96+(num-(122-asc))\n else\n asc += num\n end\n elsif (65..90).include?(asc)\n if asc>90-num\n asc=64+(num-(90-asc))\n else\n asc += num\n end\n else\n asc=asc\n end\n new_character=asc.chr\n newstring=newstring + new_character\n end\n puts newstring\nend",
"def encode(string)\n\ta = (\"a\"..\"z\").to_a\n\tb = a.rotate(13)\n\t@result = string.split(\"\")\n\n\t@result.map! do |l|\n\t\tindex = a.index(l)\n\n\t\tb[index]\n\tend\n\n\t@result.join\nend",
"def grouped_anagrams(strings)\n return [] if strings.empty?\n numbered_letters = {}\n ('a'..'z').each_with_index { |l, i| numbered_letters[l] = i}\n\n possible_anagrams = {}\n\n strings.each do |string|\n value = 0\n string.each_char do |char|\n value += numbered_letters[char]\n end\n if possible_anagrams[value]\n possible_anagrams[value] << string \n else\n possible_anagrams[value] = [string]\n end\n end\n\n return possible_anagrams.values\nend",
"def rampant_repeats(str, hash)\n repeated = \"\"\n # iterate through str chars, if chars is in hash.keys, add to output chars * key.value\n str.each_char do |letter|\n if hash.keys.include?(letter)\n repeated += letter * hash[letter]\n else\n repeated += letter\n end\n end\n\n repeated\nend",
"def guess_several_letters(object, string)\n string.each { |letter| guess(letter) }\n end",
"def rampant_repeats(str, hash)\n str.chars.map { |c| hash.key?(c) ? c * hash[c] : c }.join\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char|\n if hash.key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char \n end\n end\n new_str\nend",
"def combination(chars_array)\n array_of_letters = chars_array.map { |digit| @letters[digit] }\n combination = array_of_letters.shift.product(*array_of_letters).map(&:join)\n end",
"def solution(number)\n roman_numeral = { 1 => 'I', 4 => 'IV', 5=> 'V', 6 => 'VI', 10=> 'X', 50=> 'L', 100=> 'C', 500=> 'D', 1000=> 'M' }\n numbers = number.digits.map.with_index{ |int, idx| int * 10**idx }\n numbers.map{ |number| roman_numeral[number] }.reverse.join\nend",
"def rampant_repeats(str, hash)\n new_str = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def generate_chars(num, chars)\n return_chars = ''\n num.times { return_chars += chars.sample.to_s }\n return_chars\nend",
"def string_expansion(str)\n result = ''\n last_num = nil\n str.each_char do |char|\n if char.match?(/[a-z]/i) # if it's a letter\n result << char if last_num == nil # append to result string if no number precedes\n result << (char * last_num) if last_num != nil # multiply letter by preceding number then append\n else\n last_num = char.to_i\n end\n end\n result\nend",
"def mnemonic_pin(word)\n word.each_char.map { |char| mnemonic_digit(char) }.join\nend",
"def repeater(str)\n temp_arr = []\n str.chars do |letter|\n temp_arr << letter * 2\n end\n \n temp_arr.join('')\nend",
"def get_number_from_word(source_text)\n source_letters = source_text.split (\"\")\n result = \"\"\n \n source_letters.each do |next_letter|\n if [\"a\", \"b\", \"c\"].include?(next_letter)\n next_processed_letter = \"2\"\n \n end\n \n \n result = \"#{result}#{next_processed_letter}\"\n \n end\n \n \n return result\n \nend",
"def caesarCipher(s, k)\n s.chars.map do |c|\n if 65 <= c.ord && c.ord <= 90\n # A-Z\n code_point = ((c.ord - 65 + k) % 26) + 65\n code_point.chr\n elsif 97 <= c.ord && c.ord <= 122\n # a-z\n code_point = ((c.ord - 97 + k) % 26) + 97\n code_point.chr\n else\n c\n end\n end.join\nend",
"def reformat(s)\n return s if s.size == 1\n \n num_arrays = ('0'..'9').to_a\n alphabetical_array = ('a'..'z').to_a\n \n numbers_array = []\n alpha_array = []\n \n char_hash = Hash.new(0)\n \n s.each_char do |char|\n numbers_array << char if num_arrays.include?(char)\n alpha_array << char if alphabetical_array.include?(char)\n end\n \n str = ''\n \n while !numbers_array.empty? && !alpha_array.empty?\n str << numbers_array.pop\n str << alpha_array.pop\n end\n \n if alpha_array.size > 0\n if num_arrays.include?(str[str.size - 1])\n str << alpha_array.pop\n elsif num_arrays.include?(str[0])\n str.prepend(alpha_array.pop)\n end\n elsif numbers_array.size > 0\n if alphabetical_array.include?(str[str.size - 1])\n str << numbers_array.pop\n elsif alphabetical_array.include?(str[0])\n str.prepend(numbers_array.pop)\n end\n end\n \n str\nend",
"def letters\n the_letters = []\n letter_regex = /[a-z]/i\n chars.each do |character|\n the_letters << character if character.match(letter_regex)\n end\n the_letters.join\n end",
"def LetterCountI(str)\n\n str = str.split\n repeating_letters = []\n str.each do |word| \n word = word.split(\"\")\n letters = Hash.new(0)\n word.each { |letter| letters[letter] += 1 }\n selected_letters = letters.select { |key, value| value > 1 }\n repeating_letters << selected_letters.keys.length\n end\n if (repeating_letters.select {|l| l >= 1}).empty?\n return -1\n else\n max = repeating_letters.max\n return str[repeating_letters.index(max)]\n end\nend",
"def order(words)\n # your code...\n warr = words.split(' ')\n length = (warr.length) - 1\n nums = (0..9).to_a\n ans = (0..length).to_a\n warr.each do |x|\n x.each_char do |y|\n ans[(y.to_i) - 1] = x if nums.include?(y.to_i)\n end\n end\n ans = ans.join(' ')\n return ans\nend",
"def all_anagrams(string)\n return [string] if string.length <= 1\n\n options = all_anagrams(string[1..-1])\n\n result = []\n\n options.each do |sub|\n string.length.times do |i|\n result << sub[0...i] + string[0] + sub[i..-1]\n end\n end\n\n result\nend",
"def randstr\n (0...50).map{ ('a'..'z').to_a[rand(26)] }.join\nend",
"def encode_repeating(my_string)\r\n i = 0\r\n j = 0\r\n letter = my_string[i]\r\n while i < my_string.length\r\n j += 1 while my_string[j + 1] == letter\r\n if j - i >= 2\r\n my_string[(i + 1)..j] = (j - i + 1).to_s\r\n end\r\n additional = 0\r\n additional = 1 if j > i\r\n i += 1 + additional\r\n j = i\r\n letter = my_string[i]\r\n end\r\n return my_string\r\nend",
"def get_all_strings(numbers, prefix = '', strings = [])\n if numbers.empty?\n strings << prefix\n return\n end\n\n number = numbers.first.to_i\n letters = self.keyboard_layout.get_letters(number)\n letters.each { |l| get_all_strings(numbers[1..-1], prefix + l, strings) }\n\n strings\n end",
"def generate_code\n charset = Array('A'..'Z') + Array('a'..'z')\n Array.new(8) { charset.sample }.join\nend",
"def make_hundred\n arr = [\"+\", \"-\", \"\"].repeated_permutation(8).to_a.map do |operators|\n ((1..9).to_a).zip(operators).flatten.compact\n end.map(&:join).select {|x| eval(x) == 100}\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char| \n if hash[char]\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def digitize_1(n)\n list = []\n puts n.to_s\n \n n.to_s.each_char do |char| \n list << char.to_i\n end\n\n return list.reverse\nend",
"def num_decodings(s)\n return 0 if !s || s == '0'\n return 1 if s.size == 1\n dp = [0] * (s.size + 1)\n dp[0] = 1\n dp[1] = s[0] == '0' ? 0 : 1\n\n for i in 2..s.size do \n char = s[i - 1].to_i\n chars = s[(i - 2)..(i - 1)].to_i\n\n if char >= 1 && char <= 9\n dp[i] += dp[i - 1]\n end\n\n if chars >= 10 && chars <= 26\n dp[i] += dp[i - 2]\n end\n end\n\n dp.last\nend",
"def caesar_cipher(string,num)\n alpha = (\"a\"..\"z\").to_a \n string_array = \"\"\n string.each_char do |char|\n if alpha.include?(char)\n old_index = alpha.index(char)\n new_index = old_index + num \n string_array += alpha[new_index % 26]\n else\n string_array += char \n end\n\n end\n return string_array\nend",
"def dig_number(number)\n arr_dig = number.to_s.chars\n count = arr_dig.size\n arr_dig.map {|dig| dig.to_i ** count} \nend",
"def rampant_repeats(s, h)\n s.chars.map do |c|\n if h[c]\n c * h[c]\n else\n c\n end\n end.join(\"\")\nend"
] |
[
"0.75101686",
"0.70532066",
"0.6991677",
"0.68580794",
"0.6789314",
"0.66761273",
"0.647862",
"0.63912565",
"0.63720846",
"0.63053834",
"0.63027745",
"0.62978005",
"0.6269583",
"0.62526387",
"0.6237471",
"0.62358636",
"0.6178465",
"0.61221075",
"0.6112744",
"0.60967153",
"0.6053753",
"0.6034651",
"0.6032681",
"0.6032084",
"0.6028662",
"0.60160214",
"0.59966046",
"0.5966811",
"0.59511274",
"0.59489125",
"0.5944647",
"0.5935453",
"0.5925162",
"0.59172153",
"0.5899167",
"0.58531266",
"0.5839277",
"0.58350813",
"0.5834575",
"0.5814458",
"0.581007",
"0.58037925",
"0.57852775",
"0.5772914",
"0.57687116",
"0.5767919",
"0.575821",
"0.57576823",
"0.5750685",
"0.57479256",
"0.5735568",
"0.57336813",
"0.57306165",
"0.5728903",
"0.5728498",
"0.5721189",
"0.5721189",
"0.57132196",
"0.57120454",
"0.57103014",
"0.5706395",
"0.57042754",
"0.5698702",
"0.5696872",
"0.5692944",
"0.56908",
"0.56897396",
"0.56865156",
"0.5683865",
"0.56808347",
"0.5678847",
"0.5675926",
"0.5672113",
"0.566883",
"0.5667735",
"0.5664137",
"0.56624615",
"0.5661177",
"0.5659597",
"0.56527764",
"0.56478846",
"0.5647646",
"0.56464124",
"0.5643256",
"0.56382215",
"0.5636126",
"0.5628639",
"0.5626956",
"0.56209093",
"0.5619806",
"0.5619242",
"0.5612538",
"0.5611383",
"0.5610803",
"0.5606552",
"0.560607",
"0.5604634",
"0.56000286",
"0.5595915",
"0.55950963"
] |
0.7655314
|
0
|
Given an array nums and a value val, remove all instances of that value inplace and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array inplace with O(1) extra memory. The order of elements can be changed. It doesn't matter what you leave beyond the new length. Clarification: Confused why the returned value is an integer but your answer is an array? Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.
|
def remove_element(nums, val)
nums.each_with_index do |num, i|
if num == val
nums[i] = nil
end
end
nums.compact!
nums.length
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove_element(nums, val)\n nums.delete(val)\n nums.length\nend",
"def remove_element(nums, val)\n return 0 if nums.empty? || (nums.size == 1 && nums[0] == val)\n start = 0\n nums.each_with_index do |num, index|\n if num != val\n nums[start] = num\n start += 1\n end\n end\n nums[0..(start - 1)]\nend",
"def remove_element(nums, val)\n return nil if !nums \n # while nums.delete(val)\n # # nums.delete(val)\n # end\n nums.each {|element| nums.delete(element) if val == element}\n return nums.length\nend",
"def remove_element(nums, val)\n instance_val_pointer = 0\n\n for i in (0...nums.size) do\n if nums[i] != val\n nums[instance_val_pointer] = nums[i]\n instance_val_pointer += 1\n end\n end\n \n return instance_val_pointer\nend",
"def remove_element(nums, val)\n n = nums.length\n pointer = 0\n\n while pointer < n\n if nums[pointer] == val\n nums[pointer] = nums[n - 1]\n n -= 1\n else\n pointer += 1\n end\n end\n\n pointer\nend",
"def remove_element(nums, val)\n\n # puts \"array before: #{nums}\"\n # #recognize if there's a match between the val & a value in the array\n # nums.each_with_index {|value, index|\n # #recognize a match (between target value & array's value)\n # if value == val\n # puts \"match\"\n # #delete matching array element\n # nums.delete_at(index)\n # end\n # }\n # puts \"array after: #{nums}\"\n # #return size of the revised array\n # puts \"revised array is of size #{nums.size}\"\n\n array_index = 0\n\n puts \"array before: #{nums}\"\n while array_index < nums.size \n if nums[array_index] == val\n nums.delete_at(array_index) #identify a match, and delete the array element\n else\n array_index += 1 \n end\n end\n puts \"array after: #{nums}\"\n puts \"revised array is of size #{nums.size}\"\n\n # return nums.size\n\n\n\n\n\n\nend",
"def remove_element_in_place(nums, val)\n\nend",
"def removeElement(nums, val)\n if nums.nil? then\n 0\n else\n fast = slow = 0\n while fast < nums.size do\n if not nums[fast]==val then\n nums[slow] = nums[fast]\n slow += 1\n end\n fast += 1\n end\n slow\n end\nend",
"def remove_element(nums, val)\n pointer1 = 0\n nums.each_with_index do |num, pointer2|\n if val != num\n nums[pointer1] = nums[pointer2]\n pointer1 += 1\n end\n end\n pointer1\nend",
"def remove_duplicates(nums)\n counter = 0\n original_length = nums.length\n\n (1...nums.length).each do |i|\n if nums[i-1] == nums[i]\n counter += 1\n else\n nums[i-counter] = nums[i]\n end\n end\n\n return original_length - counter\nend",
"def remove(a, value)\n write_index = 0\n occurences = 0\n 0.upto(a.length-1).each {|i|\n if a[i] == value\n occurences += 1\n else\n a[write_index] = a[i]\n write_index += 1\n end\n }\n\n return a[0, a.length - occurences]\nend",
"def remove_duplicates(nums)\n counter = 0 # Establish a counter variable to keep track of the amount of duplicates\n original_length = nums.length # Hold a reference to the original length of the array because the array without duplicates will have less elements\n\n (1...nums.length).each do |i| # Iterate through the elements; there's no need to go to the end, where we'd end up with nil values since the value of the length of the array is going to hold an index out of bounds\n if nums[i-1] == nums[i] # Check to see if the element behind the current element and the current element are equivalent/duplicates\n counter += 1 # We only need to increment the counter because we've found a duplicate; nothing more and nothing less\n else\n nums[i-counter] = nums[i] # If two numbers are different from each other, push the current element as far back as the position of the last duplicated element; the streak of duplicates has ended and we've found a solo element; remember the arrays are sorted\n end\n end\n\n return original_length - counter # Return the new length by subtracting the amount of duplicates the array contained from the original_length\nend",
"def remove_duplicates(nums)\n return nums.length if nums.length < 2\n i = 1\n length = 1\n\n while !nums[i].nil?\n if nums[i-1] == nums[i]\n nums.delete_at(i)\n i -= 1\n else \n length += 1\n end \n i += 1\n end \n length \nend",
"def remove_duplicates(nums)\n nums.uniq!\n return nums.length\nend",
"def remove_duplicates(nums)\n size, cursor = 0, 0\n while cursor < nums.size # iterating through each number in nums starting from the first number at index 0.\n num = nums[cursor] # as I iterate through each number, I will assign it to a variable called \"num\", i.e \"num\" will be constantly rewritten to the value that I am currently at as I iterate through the numbers.\n cursor += 1 # so that I can iterate.\n while nums[cursor] == num # if the duplicates are next to each other\n cursor += 1 # I iterate to the next number.\n end\n nums[size] = num # use num(which exclude the duplicates) again and assign it to nums[size] (which is the actual number). this step is just a checker so that the next step (size += 1) will be accurate, it is not actually removing the duplicates inline, i.e return nums will not give you the array without duplicates.\n size += 1 # After filtering out the duplicates, increase the counter by 1 every time we move on to another number.\n end\n return size\nend",
"def remove_duplicates(nums)\n return 0 if nums.length === 0\n\n curr_idx = 0\n j = 0\n val = nums[j]\n\n while curr_idx < nums.length\n curr_val = nums[curr_idx]\n if curr_val === val\n curr_idx += 1\n next\n else\n val = curr_val\n j += 1\n nums[j] = curr_val\n end\n end\n\n j + 1\nend",
"def remove_duplicates(nums)\n \n return nums.length if nums.length <= 2\n prevNum = nums[0]\n i = 1\n arrLength = 1\n dupCount = 1\n while i<nums.length do\n if nums[i] == prevNum && dupCount < 2\n dupCount = dupCount + 1\n arrLength = arrLength + 1\n elsif nums[i] != prevNum\n prevNum = nums[i]\n dupCount = 1\n arrLength = arrLength + 1\n end\n i = i + 1\n end\n \n puts(arrLength)\n \nend",
"def remove_duplicates(nums)\n nums_size, cursor = 0, 0\n\n while cursor < nums.size\n num = nums[cursor]\n cursor += 1\n while nums[cursor] == num\n cursor += 1\n end\n\n nums[nums_size] = num; nums_size += 1\n end\n\n nums_size\nend",
"def remove_duplicates(nums)\n \n if nums.size > 0 #make sure the array size > 0\n \n if nums[0] == \"\" # exit if the 1st element is empty\n return\n else\n compare_to = nums[0]\n index = 1\n\n # iterate through the values of the array\n while index < nums.size\n value = nums[index]\n if compare_to == value\n nums.delete_at(index) # delete value (maintain compare_to value)\n # do NOT increment index pointer \n # BC when delete value, the pointer must continue pointing to that same location since the value will update (with deletion)\n puts \"MATCH #{compare_to} compared to value: #{value} at index[#{index}]\"\n else\n puts \"NO match #{compare_to} compared to value: #{value} at index[#{index}]\"\n compare_to = value # re-configuring the value to compare against\n index += 1\n end\n end\n puts \"#{nums}\"\n return nums.length\n end\n else\n return #exit if the array doesn't have any values\n end\n\nend",
"def remove_duplicates(nums)\n return 0 if nums.length == 0\n write = 0\n read = 1\n\n while read < nums.length\n if nums[write] != nums[read]\n write += 1\n nums[write] = nums[read]\n end\n read += 1\n end\n\n write + 1\nend",
"def remove_duplicates(nums)\n #提供的array為已經排序過的array\n #將重複的移除,使陣列中每個元素都不重複\n #右邊元素=左邊元素時,全部往左移\n #將左移過後多出來的元素設為nil\n #刪除nil元素用 陣列.delete(nil)\n #回傳新陣列長度\n \n i = 0\n j = 0\n k = 0\n\n numssize = nums.size\n\n while i < (numssize - j)\n nums[i] = nums[ i + j ]\n if nums[i] == nums[i + j +1]\n j += 1\n while nums[i + j] == nums[i + j +1]\n j += 1\n end\n nums[i + j] = nums[ i + j + 1]\n end\n i += 1\n end\n\n for k in (numssize - j)...numssize\n nums[k] = nil \n end\n\n nums.delete(nil)\n\n newsize = nums.size\nend",
"def delete_all(arr, val)\n # delete all the elements of the array where element = val\n return arr.delete(val) \nend",
"def remove_duplicates(nums)\n\n non_dupe_index = 0\n nums.each do |num|\n if (non_dupe_index == 0 || num > nums[non_dupe_index - 1])\n nums[non_dupe_index] = num\n non_dupe_index += 1\n end\n end\n nums.replace(nums)\n non_dupe_index\n\nend",
"def remove_duplicates(nums)\n puts nums.uniq.length\nend",
"def mutate(arr)\n arr.pop # => 6\nend",
"def pop_from_array(arr)\n l=arr.length\n l.each do\n num=arr.pop\n puts \"#{num} is removed!\"\n end\nend",
"def check_array(nums)\n temp = nums[0];\n\tnums[0] = nums[nums.length-1];\n\tnums[nums.length-1] = temp;\n\treturn nums;\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup\ndel=[]\nsource.each do |item|\n if item.is_a? Integer\n del << item\n next\n elsif item.include?(thing_to_delete)\n next\n else\n del << item\n end\n end\n return source=del\nend",
"def remove_duplicates_two(nums)\n return 0 if nums.empty?\n i = 0\n j = 1\n while j < nums.length\n if nums[i] != nums[j]\n i += 1\n nums[i] = nums[j]\n end\n j += 1\n end\n print nums\n i+1\nend",
"def find_unsorted_subarray(nums)\n sum = 0\n index = 0\n sorted = nums.sort\n while index < nums.length\n if nums[index] == sorted[index]\n sum += 1\n else\n break\n end\n index += 1\n end\n return 0 if sum == nums.length\n index = nums.length - 1\n while index >= 0\n if nums[index] == sorted[index]\n sum += 1\n else\n break\n end\n index -= 1\n end\n nums.length - sum\nend",
"def remove_duplicates(nums)\n beginning_index = nil\n \n nums.each_with_index do |num, index|\n next if index == 0\n \n if num == nums[index - 1] \n nums[index - 1] = nil\n end\n end\n \n nums.compact!\n \n nums.count\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n \n duplicate = source.dup\n\n i = 0\n while i < duplicate.length\n word = duplicate[i]\n if word.is_a?(Fixnum)\n i += 1\n next\n end\n if word.include?(thing_to_delete)\n source.delete(word)\n end\n i += 1\n end \n source\nend",
"def remove_element_from_end_of_array(array)\n return array.pop\nend",
"def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend",
"def remove_duplicates(array)\n array.uniq!.length\nend",
"def remove_evens!(arr)\n cloned_arr = arr.dup\n cloned_arr.each do |num|\n if num % 2 == 0\n arr.delete(num)\n end\n end\n arr\nend",
"def remove_duplicates(nums)\n return 0 if nums.empty?\n cur = nums.first\n primary = 1\n nums.each_with_index do |num, _idx|\n next if num == cur\n nums[primary] = num\n cur = num\n primary += 1\n end\n primary\nend",
"def delete_digit(n)\n nums = []\n array = n.digits.reverse\n array.each_with_index do |int, index|\n copy = array.clone\n copy.delete_at(index)\n nums << copy.join.to_i\n end\n nums.max\nend",
"def remove_evens!(arr)\n cloned_arr = arr.dup\n arr.each do |num|\n if num % 2 == 0\n cloned_arr.delete(num)\n end\n end\n cloned_arr\nend",
"def remove_element_from_end_of_array(array)\n array.pop\nend",
"def remove_element_from_end_of_array(array)\n array.pop\nend",
"def filter(arr, val)\n i = 0\n new_arr = []\n while i < arr.length\n if arr[i] == val\n new_arr << arr[i]\n end\n\n i += 1\n end\n\n return new_arr\nend",
"def no_mutate(arr)\n arr.uniq!\nend",
"def no_mutate(arr)\n arr.uniq!\nend",
"def remove_every_other(arr)\n (1..arr.length).step(1) {|x| arr.slice!(x)}\n arr\nend",
"def no_mutate(arr)\n arr.uniq\nend",
"def no_mutate(arr)\n arr.uniq\nend",
"def no_mutate(arr)\n arr.uniq\nend",
"def mutate(arr)\n arr.uniq!\nend",
"def find_unsorted_subarray2(nums)\n sort_nums = nums.sort\n\n left = nums.length\n right = 0\n\n sort_nums.each_with_index do |num, index|\n if num != nums[index]\n left = [index, left].min\n right = [index, right].max\n end\n end\n\n right >= left ? right - left + 1 : 0\nend",
"def remove_item(array, num_items)\n while array.length > num_items\n array.pop\n end\n array\nend",
"def remove(val)\n if map.key?(val)\n idx = map.delete(val)\n if idx != size - 1\n arr[idx], arr[size - 1] = arr[size - 1], arr[idx]\n map[arr[idx]] = idx\n end\n self.size -= 1\n true\n else\n false\n end\n end",
"def remove_duplicates(nums)\n prev = nil\n count = 0\n nums.each do |num|\n if num == prev\n next\n else\n nums[count] = num\n prev = num\n count+=1\n end\n end\n\n return count\nend",
"def no_mutate(array)\n array.last #returns array with last item removed, no mutation of array\nend",
"def remove_da_posicao(array,alvo)\n new_array = []\n base = 0\n if alvo <= 0 || alvo >= (array.size - 1)\n return array\n else \n for n in (0..array.size-1)\n if alvo == n\n next\n else\n new_array[base] = array[n] \n base = base + 1\n end\n end\n return new_array\n end\n \nend",
"def eliminar(array, num)\n #for i in 0..((array.length) - 1)\n #if array.at(i) < num\n # puts \"debería de funcionar\"\n # #array.delete_at(1)\n #end\n #end\n array.reject!{ |x| x < num }\n puts \"El resultado es #{array}\"\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n\n indexChange = 0\n for x in 0..(source.length - 1)\n sourceString = source[x - indexChange].to_s\n\n if sourceString.include? thing_to_delete\n source[x - indexChange,source.length] = source[x + 1 - indexChange, source.length]\n indexChange = indexChange + 1\n end\n end\n # p source\n return source\nend",
"def length_finder(array)\n num_array = []\n array.each do |i|\n num_array.insert(-1,i.length)\n end\n return num_array\nend",
"def remove_evens!(arr)\n arr.each do |num|\n if num % 2 == 0\n arr.delete(num)\n end\n end\n arr\nend",
"def delete(array, length, value_to_delete)\r\n i = 0;\r\n while i < array.length\r\n if array[i] == value_to_delete\r\n spaces = (array.length - 1) - i;\r\n moved = 0;\r\n until moved == spaces\r\n array[i] = array[i+1];\r\n i++;\r\n moved++;\r\n end\r\n array[array.length - 1] = 'SPECIAL_VALUE';\r\n end\r\n i++;\r\n end\r\nend",
"def mutate(arr)\n arr.pop # (no bang! here) mutates\nend",
"def delete_matches(to_delete, array)\n to_delete = to_delete.reverse # so indexes don't shift down as items are being deleted\n to_delete.each do |num|\n array.delete_at(num)\n end\n array\n end",
"def array_remove_at(array, index)\n if index<0 || index>=array.length\n return array\n end\n return array.slice(0,index) + array.slice(index+1,array.length)\n end",
"def lengths (arr)\n return arr.map!{|word| word.length}\nend",
"def map_to_no_change(source_array)\n \n i = 0\n new_array = []\n \n while i < source_array.length do\n new_array << source_array[i]\n \n i += 1\n end\n \n new_array\nend",
"def replace_elements(arr)\n i = arr.length - 1\n max = arr.last\n while i >= 0\n if i == arr.length - 1 \n arr[i] = -1\n else\n temp = arr[i]\n arr[i] = max\n max = temp if temp > max\n end\n i -= 1\n end\n\n return arr\nend",
"def find_unique_elements(arr)\n# Count how many times each element appears in the array, if an element appears\n# more than once, delete that element and any elements that are equal to it.\n \n arr.each do |i|\n\tif arr.count(i) > 1\n\t\tarr.delete(i)\n\tend\n end\n return arr\nend",
"def reject_arr(arr)\n arr.delete_if{ |a| a%3 == 0 }\nend",
"def my_array_deletion_method!(source, thing_to_delete)\n source.reject! {|word| word.to_s.rindex(thing_to_delete) != nil}\n return source\nend",
"def delete(arr,index)\n # res = arr.clone;\n res = arr[0,index] + arr[index+1,arr.size-(index+1)];\n return res;\nend",
"def filter_out!(arr, &prc)\n i = 0\n while i < arr.length\n if prc.call(arr[i])\n arr.delete_at(i)\n else\n i += 1\n end\n end \n arr\nend",
"def remove(val)\n return false if ! @h[val]\n # Swap in the array last element\n # and elemet to be delted.\n i,j = @h[val], @a.size - 1\n a,b = val,@a[j]\n @h[a],@h[b] = @h[b],@h[a]\n @a[i],@a[j] = @a[j],@a[i]\n @a.pop\n @h[val] = nil\n return true\n end",
"def move_zeroes(nums)\n ndx = 0\n times = 0\n\n while times < nums.size\n if nums[ndx] == 0\n nums.delete_at(ndx)\n nums << 0\n else\n ndx += 1\n end\n\n times += 1\n end\n\n nil\nend",
"def start_arr_delete(arr)\n # delete the element at the beginning of the array and return the deleted element\n return arr.shift\nend",
"def end_arr_delete(arr)\n # delete the element from the end of the array and return the deleted element\n return arr.pop\nend",
"def single_number(nums)\n uniques = []\n nums.each do |num|\n uniques.include?(num) ? uniques.delete(num) : uniques << num\n end\n uniques\nend",
"def less_five_array(numbers)\n\tputs \"The original array is #{numbers}\"\n\tnumbers.delete_if{|num| num < 5}\n\t#numbers.drop_while {|num| num < 10}\n\tputs \"The permanently modified array is #{numbers}\"\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def end_arr_delete(arr)\n # delete the element from the end of the array and return the deleted element\n arr.pop\nend",
"def map_to_no_change(source_array)\n array = []\n index = 0 \n \n while index < source_array.size do \n array.push(source_array[index])\n index += 1 \n end\n return array\nend",
"def mutate(array)\n array.pop \nend",
"def remove_dups(arr)\n\treturn arr.uniq()\nend",
"def pop_from_array(arr)\n arr.size.times do\n puts arr.pop\n end\nend",
"def my_array_deletion_method(source, thing_to_delete)\n source.delete_if{|x| x.to_s.include?(thing_to_delete)}\n return source\nend",
"def my_array_deletion_method(source, thing_to_delete)\n source.delete_if{|x| x.to_s.include?(thing_to_delete)}\n return source\nend",
"def missing_number(nums)\n missing = nums.size\n nums.each_with_index do |num, index|\n missing ^= index ^ num\n end\n missing\nend",
"def remove_odd_numbers_from_array(a)\n return a.delete_if{|x| x % 2 == 1}\nend",
"def eliminar_med_elem_arr(arreglo)\n index = arreglo.length / 2\n index -= 1 if arreglo.length.even?\n eliminar_elem_arr(arreglo, index)\n arreglo\nend",
"def mutate(arr)\n arr.pop\n end",
"def delete_nth(arr, n)\n results = []\n arr.each do |current_num|\n times_it_appears_in_results = results.count(current_num)\n results << current_num if times_it_appears_in_results < n\n end\n results\nend",
"def reverse!(arr)\n arr.size.times do |n|\n arr.unshift(arr.delete_at(n))\n end\n arr\nend"
] |
[
"0.75248563",
"0.7453051",
"0.7308791",
"0.72617537",
"0.71683663",
"0.7139942",
"0.70382595",
"0.70364654",
"0.69365734",
"0.6657233",
"0.64814603",
"0.6362131",
"0.6325264",
"0.63187855",
"0.63075316",
"0.62714183",
"0.62675685",
"0.6225266",
"0.61950064",
"0.61876684",
"0.61052793",
"0.60658437",
"0.60584724",
"0.60379374",
"0.59317577",
"0.5897246",
"0.58947456",
"0.5866062",
"0.5827514",
"0.5769359",
"0.5758033",
"0.5725247",
"0.5713489",
"0.5709",
"0.57046664",
"0.56820416",
"0.5654483",
"0.56227005",
"0.56182665",
"0.5614975",
"0.5614975",
"0.5602584",
"0.55862427",
"0.55862427",
"0.55756",
"0.55701613",
"0.55701613",
"0.55701613",
"0.5569401",
"0.5528435",
"0.55139536",
"0.5509304",
"0.5474925",
"0.5446591",
"0.5438428",
"0.54183227",
"0.5418181",
"0.5416035",
"0.5414921",
"0.5409715",
"0.54076946",
"0.540722",
"0.5401944",
"0.5389118",
"0.53742963",
"0.5363346",
"0.53522706",
"0.5329783",
"0.5326609",
"0.5316389",
"0.531403",
"0.53044593",
"0.5301445",
"0.52885324",
"0.5286081",
"0.5265795",
"0.5263732",
"0.52623236",
"0.52623236",
"0.52623236",
"0.52623236",
"0.52623236",
"0.52623236",
"0.52623236",
"0.52623236",
"0.52623236",
"0.52623236",
"0.5257105",
"0.52467227",
"0.52456456",
"0.52453166",
"0.5243316",
"0.5243239",
"0.5243239",
"0.5227268",
"0.5213856",
"0.5210239",
"0.52097106",
"0.52042323",
"0.52033913"
] |
0.7503756
|
1
|
Override default date and time formats:
|
def update_date_formats!
Date::DATE_FORMATS.update(
:db => '%Y-%m-%d %H:%M:%S',
:ui => '%d.%m.%Y',
:yaml => '%Y-%m-%d', # For Dates
:default => '%d.%m.%Y'
)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_time_formats!\n Time::DATE_FORMATS.update(\n :db => '%Y-%m-%d %H:%M:%S',\n :ui => '%d.%m.%Y %H:%M',\n :yaml => '%Y-%m-%d %H:%M:%S %:z', # For DateTimes\n :default => lambda do |time|\n non_zero_time = time.hour != 0 || time.min != 0 || time.sec != 0\n time.strftime(non_zero_time ? '%d.%m.%Y %H:%M' : '%d.%m.%Y')\n end\n )\n end",
"def datetime_format\n end",
"def datetime_format\n @default_formatter.datetime_format\n end",
"def datetime_format\n @default_formatter.datetime_format\n end",
"def datetime_format=(datetime_format)\n @default_formatter.datetime_format = datetime_format\n end",
"def datetime_format=(format)\n end",
"def default_options_date_format(format)\n format || '%Y-%m-%d - %l:%M:%S%p'\n end",
"def datetime_format=(datetime_format)\n @default_formatter.datetime_format = datetime_format\n end",
"def datetime_format=(format)\n add_datetime_formatter!(format)\n end",
"def default_format\n case input_type\n when :bootstrap_date\n I18n.t('date.formats.default')\n when :bootstrap_date_time\n I18n.t('time.formats.default')\n end\n end",
"def datetime_format\n formatter.datetime_format if formatter.respond_to?(:datetime_format)\n end",
"def set_date_format(format)\n @date_format = format\n end",
"def approach_time_format\n \"%b %e, %Y %l:%M%p\"\n end",
"def date_time_format(date_time, format = :date_time)\n format = FORMATS[format]\n date_time.strftime(format)\n end",
"def preferred_format(date)\n return date if date == \"anytime\"\n date.strftime(PREFERRED_DATE_FORMAT)\n end",
"def date_format tim\n # tim.strftime '%Y/%m/%d %H:%M:%S'\n tim.strftime '%Y/%m/%d %H:%M'\nend",
"def format_datetime(t)\n format DFORMAT, t.day, t.mon, t.year, t.hour, t.min, t.sec, t.zone\n end",
"def datetime_format=(datetime_format)\n formatter.datetime_format = datetime_format if formatter.respond_to?(:datetime_format=)\n end",
"def dt_format\n \"%Y-%m-%d %H:%M\"\n end",
"def default_timestamp_format\n \"{ts '%Y-%m-%d %H:%M:%S%N'}\"\n end",
"def time_format format_type=nil\n\n format =I18n.t(\"time.formats.default_time_only\")\n if format_type==\"jquery_time\" then\n return strftime_format_2_js_format_simple(format)\n elsif format_type==\"strftime\" then\n return format \n else\n return format \n end\n end",
"def set_date_format(format)\n @date_format = format\n end",
"def date_format\n return @date_format\n end",
"def set_format_for_date(datetime)\n return \"\" unless datetime.is_a? Time\n if datetime > 30.days.ago\n time_ago_in_words(datetime)\n else\n datetime.to_date.to_formatted_s(:rfc822)\n end\n end",
"def time_format\n return @time_format\n end",
"def time_format=(value)\n @time_format = value\n end",
"def en_time_format(date)\n date.strftime(\"%m.%d.%y - %H:%M\")\n end",
"def initialize\n @datetime_format = '%Y%m%d %H:%M:%S'\n end",
"def date_formats\n [\n '%m/%d/%Y', #'mm/dd/yyyy',\n '%m-%d-%Y', #'mm-dd-yyyy',\n '%m-%d-%y', #'mm-dd-yy',\n '%d/%m/%Y', #'dd/mm/yyyy',\n '%d-%m-%Y', #'dd-mm-yyyy',\n '%d-%m-%y', #'dd-mm-yy',\n '%a, %d %b %Y' #strftime, e.g. 'Sat, 10 Nov 2007'\n ]\n end",
"def date_and_time(options = {})\n @time.is_a?(Time) ? \"#{date(options)} at #{time(options)}\" : date(options = {})\n end",
"def datetime_format\n /^\\d{4}-\\d{2}-\\d{2}\\w\\d{2}:\\d{2}:\\d{2}/\n end",
"def date_format=(value)\n @date_format = value\n end",
"def format_date_time(date_time)\n if defined?(ActiveSupport)\n date_time.strftime(DATE_TIME_FORMAT)\n else\n date_time.inspect\n end\n end",
"def use_us_formats\n self.current_date_format = :us\n end",
"def format_date_time( dt )\n dt.strftime( \"%B %e, %Y %I:%M%p\" )\nend",
"def format_datetime\n if @opts[:as] == :select\n values = {}\n if v = @attr[:value]\n v = DateTime.parse(v) unless v.is_a?(Time) || v.is_a?(DateTime)\n values[:year], values[:month], values[:day], values[:hour], values[:minute], values[:second] = v.year, v.month, v.day, v.hour, v.min, v.sec\n end\n _format_date_select(values, @opts[:order] || DEFAULT_DATETIME_ORDER)\n else\n _format_input('datetime-local')\n end\n end",
"def format_date_and_time(date)\n date.day == Time.zone.now.day ? date.to_s(:time) : date_and_time_formatter(date)\n end",
"def bootstrap_datetime_format\n datetime = object.start ? object.start : DateTime.now\n datetime.strftime(\"%m/%d/%Y %l:%M %p\")\n end",
"def time_format(time)\n\t if time\n\t time.strftime(\"%d/%m/%Y %H:%M\")\n\t end\n\tend",
"def german_time_format(date)\n date.strftime(\"%d.%m.%y - %H:%M\")\n end",
"def typus_date_format(attribute = :default)\n options = read_model_config['fields']['options']\n if options && options['date_formats'] && options['date_formats'][attribute.to_s]\n options['date_formats'][attribute.to_s].to_sym\n else\n :default\n end\n end",
"def formatted_date_time date, time\n date_time = merge_date_time date, time\n I18n.localize date_time\n end",
"def use_euro_formats\n self.current_date_format = :euro\n end",
"def time_format=(format)\n @time_format = HOUR_FORMAT_OPTIONS[format]\n end",
"def default_timestamp_format\n \"TIMESTAMP '%Y-%m-%d %H:%M:%S%N %z'\".freeze\n end",
"def format(formatter = DateTimeFormatter::ISO_LOCAL_TIME)\n formatter.format self\n end",
"def show_date_format(time)\n unless time.blank?\n time.strftime(\"%Y年%m月%d日\") rescue '--'\n end\n end",
"def date_format t\n t.strftime \"%Y/%m/%d\"\n end",
"def date_formats_by_unit\n #mysql format is always at first position, only one value if mysql and strftime are equivalent\n return ['%Y-%m-%d %H%i%s', '%Y-%m-%d %H%M%S'] if measured_in?(\"seconds\")\n return ['%Y-%m-%d %H%i', '%Y-%m-%d %H%M'] if measured_in?(\"minutes\")\n return ['%Y-%m-%d %H'] if measured_in?(\"hours\")\n return ['%Y-%m-%d']\n end",
"def show_in_strftime\n @date.strftime(\"%d/%m/%Y -- %H:%M\")\n end",
"def set_date_format(format) \n unless format.nil?\n return format\n else\n return @@db_format\n end\n end",
"def format_date_nicely(date)\nend",
"def fmt_date_time(obj)\r\n if obj.class == Array \r\n return obj.collect {|e| fmt_date(e)}\r\n elsif obj.respond_to?('strftime')\r\n return obj.strftime(\"%m/%d/%Y at %I:%M%p\") \r\n else\r\n return obj\r\n end\r\n end",
"def format_time(time)\n strftime_preset = '%Y-%m-%dT%l:%M:%S%z'\n time.strftime(strftime_preset)\n end",
"def formatDate(date, options={})\n if (options[:dateOnly]==true)\n return date.localtime().strftime(\"%d.%m.%Y\")\n else\n if (options[:showSeconds]==false)\n return date.localtime().strftime(\"%d.%m.%Y %H:%M\")\n else\n return date.localtime().strftime(\"%d.%m.%Y %X\")\n end\n end\n end",
"def date_format_options\n DATE_FORMATS.collect {|f| [\"#{Date.today.strftime(f)} - #{f}\", f]}\n end",
"def custom_time (*arg)\n\tresult = \"\"\n\targ.each do |value|\n\t\tif(value == :day_of_week)\n\t\t\tresult += \"%A, \"\n\t\telsif(value == :month)\n\t\t\tresult += \"%B \"\n\t\telsif(value == :day)\n\t\t\tresult += \"%d, \"\n\t\telsif(value == :year)\n\t\t\tresult += \"%Y \"\n\t\telsif(value == :time)\n\t\t\tresult += \"at %I:%M%p\" \n\t\tend\n\tend\n\tt = Time.now\n\tt.strftime(result)\nend",
"def default_format=(format)\n @default_format = format\n end",
"def format_date_time(value, format)\n if value.nil? then\n \"\"\n else\n value.strftime(format)\n end\n end",
"def format_datetime(date_time)\n unless !logged_in? || current_user.timezone.nil?\n date_time = date_time.in_time_zone(current_user.timezone)\n end\n #SEE Ruby-doc for options\n date_time.strftime(\"%h %d, 20%y at %l:%m%p (%Z)\") #Format: 02/28/14 11:00pm (PST)\n end",
"def change_date_format\n params[:audit][:period_start] = DateTime.strptime(params[:audit][:period_start], \"%m/%d/%Y %H:%M\")\n params[:audit][:period_end] = DateTime.strptime(params[:audit][:period_end], \"%m/%d/%Y %H:%M\")\n end",
"def datetime_format\n @logger.first.datetime_format\n end",
"def format_date\n begin\n self.eob_date = Date.strptime(self.unformatted_eob_date, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_eob_date.blank?\n self.dos = Date.strptime(self.unformatted_dos, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_dos.blank?\n self.check_date = Date.strptime(self.unformatted_check_date, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_check_date.blank?\n rescue\n errors.add :base, \"Invalid Date(s)\"\n end\n end",
"def datetime_format_set\n instance_variable_get(:\"@#{current_date_format}_datetime_format_set\")\n end",
"def formatted_datetime(date_time)\n date_time.strftime(\"%a, %e %b %Y %H:%M\")\n end",
"def date_formats\n now = Time.now\n [:to_date, :to_datetime, :to_time].each do |conv_meth|\n obj = now.send(conv_meth)\n puts obj.class.name\n puts \"=\" * obj.class.name.length\n name_and_fmts = obj.class::DATE_FORMATS.map { |k, v| [k, %Q('#{String === v ? v : '&proc'}')] }\n max_name_size = name_and_fmts.map { |k, _| k.to_s.length }.max + 2\n max_fmt_size = name_and_fmts.map { |_, v| v.length }.max + 1\n name_and_fmts.each do |format_name, format_str|\n puts sprintf(\"%#{max_name_size}s:%-#{max_fmt_size}s %s\", format_name, format_str, obj.to_s(format_name))\n end\n puts\n end\nend",
"def formatted_date datetime\n return '' if datetime.nil?\n\n datetime.strftime '%Y-%m-%d %H:%m'\n end",
"def date_format t\n t.strftime \"%Y/%m/%d\"\nend",
"def date_format t\n t.strftime \"%Y/%m/%d\"\nend",
"def gnupg_date_format(maybe_datetime)\n datetime = case maybe_datetime\n when DateTime then maybe_datetime\n when Time, Date then maybe_datetime.to_datetime\n else raise ArgumentError,\n \"datetime: has to be a DateTime/Time/Date\"\n end\n\n # datetime.utc.iso8601.gsub(/-|:/, '')[0..-6]\n datetime.utc.iso8601.gsub(/-|:/, \"\")[0..-6]\n end",
"def reset_formats\n original_formats = [:db, :time, :short, :date, :long, :long_ordinal, :rfc822]\n formats = @@formats.delete_if{|format, v| !original_formats.include?(format)}\n end",
"def formattimeanddate(unformattedtime)\n unformattedtime.strftime('%I:%M:%S %p - %d %m %Y')\n end",
"def formatted_value\n formatter = @format.downcase.split(' ').map do |part|\n if (parsed_format = parse_date_or_time_format(part))\n parsed_format\n else\n warn 'Unable to parse custom format. Using \"YYYY-mm-dd HH:MM:SS\" format.'\n return @value.strftime('%F %T')\n end\n end.join(' ')\n\n @value.strftime(formatter)\n end",
"def typus_date_format(attribute = :default)\n Typus::Configuration.config[name]['fields']['options']['date_formats'][attribute.to_s].to_sym\n rescue\n :db\n end",
"def FormatTimesDates\n\ttime = Time.new\n\tputs time.to_s\n\tputs time.ctime\n\tputs time.localtime\n\tputs time.strftime(\"%Y-%m-%d %H:%M:%S\")\n\tputs time.strftime(\"%d/%m/%Y\")\nend",
"def out_of_bounds_time_format; end",
"def as_date( d = nil )\n d = (d || self)\n return '' unless [Date, Time, DateTime].include? d.class\n format = d.year == Date.today.year ? 'date_same_year' : 'date_other_year'\n I18n.l d, :format => I18n.t( 'time.formats.' + format )\n end",
"def formatConvertor(inputFormat)\n\n inputFormat.sub! 'DD', '%d'\n inputFormat.sub! 'YYYY', '%Y'\n inputFormat.sub! 'YY', '%Y'\n inputFormat.sub! 'MM', '%m'\n inputFormat.sub! 'hh', '%H'\n inputFormat.sub! 'mm', '%M'\n inputFormat.sub! 'ss', '%S'\n inputFormat.sub! 'HH', '%I' # HH - for hour of the clock (12 hour)\n inputFormat.sub! 'A/P', '%p'\n inputFormat.sub! 'MON', '%b' # Jan/Feb etc\n #inputFormat.sub! 'TZ', '%z' # TimeZone\n\n\nend",
"def datetime_local_field(name, *args)\n options = args.extract_options!.symbolize_keys!\n prepare_options(name, options)\n options[:input_group][:data].merge!({'date-extra-formats' => [BootstrapForm::DATE_FORMAT_JS+\"THH:mm\"+(options[:include_seconds] ? ':ss' : '')]}.merge(options[:data] || {}))\n append_min_max(BootstrapForm::DATE_FORMAT_RUBY+\"T%T\", options)\n args << options\n super\n end",
"def time_format(time)\n time.strftime('%F %r') + \" \" + time.zone\n end",
"def setCreatedTimeFormat(createdTimeFormat)\r\n\t\t\t\t\t@createdTimeFormat = createdTimeFormat\r\n\t\t\t\tend",
"def setCreatedTimeFormat(createdTimeFormat)\r\n\t\t\t\t\t@createdTimeFormat = createdTimeFormat\r\n\t\t\t\tend",
"def format_datetime datetime, fmt=\"%F %H:%M %Z\"\n return unless datetime.present?\n datetime.strftime fmt if datetime\n end",
"def formatted_date(date)\n return '' if date.nil?\n sprintf('%d/%d/%d alle %d:%d', date.day, date.month, date.year,\n date.hour, date.min)\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def datetime_format=(datetime_format)\n @loggers.each do |logger|\n logger.datetime_format = datetime_format\n end\n end",
"def time_format\n return :time12 if new_us_user?\n\n clock_type == '12h' ? :time12 : :time24\n end",
"def date_format_setting_options(locale)\n Setting::DATE_FORMATS.map do |f|\n today = ::I18n.l(User.current.today, :locale => locale, :format => f)\n format = f.delete('%').gsub(/[dmY]/) do\n {'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&]\n end\n [\"#{today} (#{format})\", f]\n end\n end",
"def preferred_human_format(date)\n return date if date == \"anytime\"\n date.strftime(PREFERRED_HUMAN_DATE_FORMAT)\n end",
"def fmt_time(dt) _format_dt dt, H12_M_PM end",
"def format_datetime(obj)\n return unless obj\n\n obj.strftime('%Y-%m-%d %H:%M')\n end",
"def time_display(datetime)\n datetime.strftime(\"%m/%d/%Y, %l:%M %p\")\n end",
"def datetime_format=(datetime_format)\n @loggers.each do |logger|\n logger.datetime_format = datetime_format if logger.respond_to?(:datetime_format=)\n end\n end",
"def default_format(*value)\n set_format(@entry_format_default, *value)\n end",
"def display_datetime(time)\n time.strftime('%e %B, %l:%M%p')\n end",
"def datetimepicker_options(format, value = nil)\n datetimepicker_options = {:value => value.try(:strftime, format), :class => 'ui-timepicker'}\n end",
"def format_datetime(datetime, fmt = '%e %B %Y')\n return datetime unless datetime.is_a? Time\n datetime.strftime(fmt).strip\n end",
"def time_zone\n super\n end",
"def date(input, format); end",
"def format_datetime\n self.start_time = self.start_time.in_time_zone(\"UTC\")\n end"
] |
[
"0.7721267",
"0.7516863",
"0.7392629",
"0.73883057",
"0.7326643",
"0.7323418",
"0.72808945",
"0.7219632",
"0.6911035",
"0.6894927",
"0.6793609",
"0.67824644",
"0.6645458",
"0.66107035",
"0.6572696",
"0.65455264",
"0.65353334",
"0.6512592",
"0.6497654",
"0.64892036",
"0.6468892",
"0.6444491",
"0.6433935",
"0.63757807",
"0.6356742",
"0.63514674",
"0.6333814",
"0.6332462",
"0.6313904",
"0.63120824",
"0.63000125",
"0.6295604",
"0.6277419",
"0.62657386",
"0.6249411",
"0.6243909",
"0.62404764",
"0.6206541",
"0.6205318",
"0.6180028",
"0.6162455",
"0.61607593",
"0.61316025",
"0.6126413",
"0.6112131",
"0.6109566",
"0.6096044",
"0.60760516",
"0.60758525",
"0.60603666",
"0.6057924",
"0.60485125",
"0.60385716",
"0.60274833",
"0.60268545",
"0.60268074",
"0.60253894",
"0.6022513",
"0.6018279",
"0.60044295",
"0.59939736",
"0.5993033",
"0.59913397",
"0.5989549",
"0.597648",
"0.5975646",
"0.59675545",
"0.5951259",
"0.5951259",
"0.5917356",
"0.5915137",
"0.59061074",
"0.58950806",
"0.5890845",
"0.5874477",
"0.5871273",
"0.58702874",
"0.58629614",
"0.585363",
"0.58398694",
"0.5836575",
"0.5836575",
"0.5834692",
"0.5830324",
"0.5823705",
"0.5816941",
"0.5814198",
"0.5800935",
"0.5797322",
"0.5791934",
"0.5791584",
"0.5784094",
"0.57571155",
"0.5754519",
"0.575247",
"0.57425123",
"0.57388437",
"0.5733629",
"0.57180107",
"0.57143766"
] |
0.71987396
|
8
|
Rails 2 loads Oracle dates (with timestamps) as DateTime or Time values (before or after 1970) whereas Rails 1.2 treated them as Date objects. Therefore we have a formatting challenge, which we overcome by hiding the time if it's exactly midnight
|
def update_time_formats!
Time::DATE_FORMATS.update(
:db => '%Y-%m-%d %H:%M:%S',
:ui => '%d.%m.%Y %H:%M',
:yaml => '%Y-%m-%d %H:%M:%S %:z', # For DateTimes
:default => lambda do |time|
non_zero_time = time.hour != 0 || time.min != 0 || time.sec != 0
time.strftime(non_zero_time ? '%d.%m.%Y %H:%M' : '%d.%m.%Y')
end
)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_date()\n #This is a stub, used for indexing\n end",
"def sql_datetime_second_mask\n case session[:database][:locale]\n when \"de\" then \"DD.MM.YYYY HH24:MI:SS\"\n when \"en\" then \"YYYY-MM-DD HH24:MI:SS\"\n else \"DD.MM.YYYY HH24:MI:SS\" # Deutsche Variante als default\n end\n end",
"def to_time()\n #This is a stub, used for indexing\n end",
"def to_datetime()\n #This is a stub, used for indexing\n end",
"def timestamp_to_date(timestamp)\n\t\tTime.at(timestamp/1000).utc #This is a time instance, it should go straight ot ruby\n\tend",
"def fixed_at\r\n model.fixed_at ? model.fixed_at.strftime('%Je')[0] + model.fixed_at.strftime(\"%Jg-%m-%d\") : nil\r\n end",
"def timestamp\n @timestamp ||= Time.parse(@origdate)\n end",
"def convert_db_time(date)\n \treturn date.strftime(\"%m/%d/%Y | %I:%M %P\")\n end",
"def timestamp2date(t)\n Time.at(t.to_i).utc\nend",
"def literal_datetime(v)\n v.strftime(\"TIMESTAMP '%Y-%m-%d %H:%M:%S'\")\n end",
"def time_to_oa_date(time)\n time = time.respond_to?(:to_time) ? time.to_time : time\n # Local dates are stored as UTC by truncating the offset:\n # 1970-01-01 00:00:00 +0200 => 1970-01-01 00:00:00 UTC\n # This is done because SpreadsheetML is not timezone aware.\n (time + time.utc_offset).utc.to_f / 24 / 3600 + 25569\n end",
"def to_time\r\n #MES- From activerecord-1.13.2\\lib\\active_record\\connection_adapters\\abstract\\schema_definitions.rb\r\n # Function was called string_to_time\r\n time_array = ParseDate.parsedate(self)[0..5]\r\n # treat 0000-00-00 00:00:00 as nil\r\n #MES- Next line WAS the following, but we don't have access to Base here\r\n #Time.send(Base.default_timezone, *time_array) rescue nil\r\n Time.utc(*time_array) rescue nil\r\n end",
"def quoted_date(value)\n if value.acts_like?(:time)\n if value.respond_to?(:getutc)\n value = value.getutc\n end\n end\n\n result = value.to_s(:db)\n end",
"def bootstrap_datetime_format\n datetime = object.start ? object.start : DateTime.now\n datetime.strftime(\"%m/%d/%Y %l:%M %p\")\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def datetime_timestamp\n return Date.parse(self.date).to_time\n end",
"def created_at_for_solr\n return FinderHelper.strip(created_at.to_i)\n end",
"def quote_date_with_to_date(value)\n value = value.to_s(:db) if value.acts_like?(:date) || value.acts_like?(:time)\n \"TO_DATE('#{value}','YYYY-MM-DD HH24:MI:SS')\"\n end",
"def test_formatting_time_according_to_precision_coerced\n skip unless @connection # Avoids arunit2 suite run errors.\n @connection.create_table(:foos, force: true) do |t|\n t.time :start, precision: 0\n t.time :finish, precision: 4\n end\n time = ::Time.utc(2000, 1, 1, 12, 30, 0, 999999)\n Foo.create!(start: time, finish: time)\n assert foo = Foo.find_by(start: time)\n assert_equal 1, Foo.where(finish: time).count\n assert_equal time.to_s, foo.start.to_s\n assert_equal time.to_s, foo.finish.to_s\n assert_equal 000000, foo.start.usec\n assert_equal 999000, foo.finish.usec\n end",
"def convert_start_time_to_dateTime (booking)\n \"#{booking.booking_start_day}-#{MONTH_ID_TO_MONTH[booking.booking_start_month]}-#{booking.booking_start_year} at \n #{booking.booking_start_hour}:00\"\n end",
"def to_sql\n self.strftime(\"%Y-%m-%d %H:%M:%S\")\n \tend",
"def formatted_created_at\n self.created_at.to_date.to_s(:long)\nend",
"def decorated_created_at\n created_at.to_date.to_s(:long) \n end",
"def default_timestamp_format\n \"{ts '%Y-%m-%d %H:%M:%S%N'}\"\n end",
"def normalizeTimestamp(timestamp)\n if timestamp == '0000-00-00 00:00:00' || timestamp == '0000-00-00T00:00:00+00:00'\n timestamp = '1983-10-29T03:16:00+00:00'\n end\n timestamp\n end",
"def literal_datetime(v)\n v.strftime(TIMESTAMP_FORMAT)\n end",
"def to_date\n begin\n super\n rescue\n Date.null_date\n end\n end",
"def sql_datetime_minute_mask\n case session[:database][:locale]\n when \"de\" then \"DD.MM.YYYY HH24:MI\"\n when \"en\" then \"YYYY-MM-DD HH24:MI\"\n else \"DD.MM.YYYY HH24:MI\" # Deutsche Variante als default\n end\n end",
"def start_of_time\n Date.jd(0).strftime(\"%Y-%m-%d\")\n end",
"def livia_date_time(d)\n unless d.nil?\n d.to_time.strftime(\"%m/%d/%Y %H:%M\")\n else\n ''\n end\n end",
"def test_datetime2_truncate_usec_on_assigment_precision_0\n time = Time.parse('2018-12-31T23:59:21.341867')\n record = DateTime2Types.new(my_datetime_alt: time)\n\n assert_equal 23, record.my_datetime_alt.hour\n assert_equal 59, record.my_datetime_alt.min\n assert_equal 21, record.my_datetime_alt.sec\n assert_equal 0, record.my_datetime_alt.usec\n assert_equal 0, record.my_datetime_alt.nsec\n end",
"def decorated_created_at\n created_at.to_date.to_s(:long)\n # created_at.strftime \"%d/%m/%Y %H:%M\"\n end",
"def dt_format\n \"%Y-%m-%d %H:%M\"\n end",
"def beginning_of_day\n to_time\n end",
"def quoted_date(value)\n if value.acts_like?(:time)\n zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal\n\n if value.respond_to?(zone_conversion_method)\n value = value.send(zone_conversion_method)\n end\n value.strftime('%Y-%m-%d %H:%M:%S') # Time, DateTime\n else\n value.strftime('%Y-%m-%d') # Date\n end\n end",
"def convert_datetime(date_symbol_or_string)\n attribute = date_symbol_or_string.to_s\n return nil if self[attribute + '(1i)'].nil? || self[attribute + '(2i)'].nil? || self[attribute + '(3i)'].nil? || self[attribute + '(4i)'].nil? || self[attribute + '(5i)'].nil? \n return Time.local(self[attribute + '(1i)'].to_i, self[attribute + '(2i)'].to_i, self[attribute + '(3i)'].to_i, self[attribute + '(4i)'].to_i, self[attribute + '(5i)'].to_i) \n end",
"def normalize_time\n if time.present?\n Time::DATE_FORMATS[:ms] = \"%M:%S\"\n self.time = \"0:#{time.to_formatted_s(:ms)}\".to_time\n end\n end",
"def requires_sql_standard_datetimes?\n true\n end",
"def to_s_for_cap\n to_datetime.to_s_for_cap\n end",
"def test_quoted_datetime_local\n with_timezone_config default: :local do\n t = Time.now.change(usec: 0).to_datetime\n assert_equal t.to_fs(:db), @quoter.quoted_date(t)\n end\n end",
"def to_date\n to_time.to_date\n end",
"def __mongoize_time__\n self\n end",
"def quoted_date(value) #:nodoc:\n if value.acts_like?(:time) && value.respond_to?(:usec)\n \"#{super}.#{sprintf(\"%06d\", value.usec)}\"\n else\n super\n end\n end",
"def dummy_time_for_day day_nr\n if open && close\n hour = open.hour\n min = open.min\n sec = close.hour + close.min / 100.0\n else\n hour = min = sec = 0\n end\n Time.zone.local(1970, 1, day_nr, hour, min, sec, 0)\n end",
"def born_date\n super.to_s(:long)\n end",
"def ruby_value\n ::Date.parse(@date_time_value.strftime(\"%Y%m%d\"))\n end",
"def convert_to_start_at\n\t\tunless @start_date.blank? && @start_time.blank? \n\t\t\tself.start_at = Time.parse(\"#{@start_date} #{@start_time}\") + (1.hours)\n\t\tend\n\tend",
"def decorated_created_at\n\t created_at.to_date.to_s( :long )\n\t end",
"def date_time_to_db_format(date, time)\n finish_date_time = date + \" \" + time\n # format datetime for the database\n postgrestimestamp = DateTime::strptime(finish_date_time, '%d %b %Y %H:%M').to_time\n return postgrestimestamp\n end",
"def get_date(sqlite_date)\n sqlite_date.nil? ? nil : sqlite_date[0..9]\n end",
"def typecast_value_datetime(value)\n Sequel.typecast_to_application_timestamp(value)\n end",
"def date1904() @@date1904; end",
"def format_date_nicely(date)\nend",
"def format_proper_date(key, value)\n return unless key == 'layer_modified_dt'\n\n metadata[key] = Time.parse(value).utc.iso8601\n end",
"def display_time(timestamp)\n return nil if timestamp.blank?\n timestamp.to_s(:date_time_long)\n end",
"def typecast_value_date(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_DATETIME_VALUES\n value\n else\n super\n end\n else\n super\n end\n end",
"def solr_date(date)\n return Time.utc(date.year, date.mon, date.mday).iso8601()\nend",
"def solr_date(date)\n return Time.utc(date.year, date.mon, date.mday).iso8601()\nend",
"def date\n time_table_date || @date\n end",
"def to_sql\n \"timestamp '#{to_s}'\"\n end",
"def format_datetime\n self.start_time = self.start_time.in_time_zone(\"UTC\")\n end",
"def format_datetime\n self.start_time = self.start_time.in_time_zone(\"UTC\")\n end",
"def time_date_hm ; time_date && time_date.strftime(\"%H:%M\") ; end",
"def supports_datetime_with_precision?\n false\n end",
"def supports_datetime_with_precision?\n false\n end",
"def datetime_convert(v)\n case v\n when nil, 0 then nil\n when Numeric then day_convert(v)\n when IsoYear then day_convert(v)\n when IsoDay then day_convert(v)\n when IsoDate then v.to_s\n when START_PATTERN[:complete] then datetime_clean($1)\n when START_PATTERN[:day] then $1\n when START_PATTERN[:year] then day_convert(v)\n else datetime_parse(v)\n end\n end",
"def reset_date_for_time time\n string_as_t time_as_s time\n end",
"def json_date\n start_time.to_i\n end",
"def test_date_time_formatting\n\t\tskip\n\t\tobject = DateTimeStruct.new(DateTime.new(2010, 10, 5))\n\t\tpresenter = Claudia::Presenter.new object\n\t\tputs presenter.start_date\n\t\tputs presenter.start_time\n\tend",
"def decorated_updated_at\n updated_at.to_date.to_s(:long)\n # created_at.strftime \"%d/%m/%Y %H:%M\"\n end",
"def trunc_date(d)\n Time.mktime(d.year, d.month, d.day) unless d.nil?\n end",
"def date\n if (self.datetime_observation) then self.datetime_observation.to_date\n else @date ||= self.observation.date #default\n end\n end",
"def convert_date(date)\r\n if ( date == nil )\r\n return nil\r\n end\r\n string_date = date.to_s\r\n t = string_date.rindex('T')\r\n string_date = string_date.slice(0,t)\r\n string_date \r\nend",
"def datetime(s)\n @db.to_application_timestamp(s)\n end",
"def ruby_value\n to_datetime\n end",
"def __evolve_time__\n __mongoize_time__.utc\n end",
"def to_epoch(dateOrTime)\n return dateOrTime.count('-') > 0 ? Integer(Date.iso8601(dateOrTime).strftime(\"%s\")) : Integer(dateOrTime)\nend",
"def datetime_format\n end",
"def convert_datetimes_intelligently!\n dt_attrs = @converted_headers.select { |obj| obj.match(/_(?:dt?|at|on)\\z/) }\n dt_idxs = dt_attrs.map { |obj| @converted_headers.find_index(obj) }\n\n spreadsheet.map! { |row|\n dt_idxs.each { |idx|\n to_convert = row[idx]\n row[idx] = to_convert.try(:to_datetime) || to_convert\n }\n row }\n end",
"def get_iso_timestamp( data_import_session )\n data_import_session.created_at.strftime(\"%Y%m%d%H%M\")\n end",
"def type_literal_generic_datetime(column)\n :timestamp\n end",
"def to_datetime\n self\n end",
"def timestamp\n _timestamp.as_time\n end",
"def timestamp\n date.strftime(\"%Y%m%d%H%M%S\") \n end",
"def test_quoted_datetime_local\n with_active_record_default_timezone :local do\n t = DateTime.now\n assert_equal t.to_s(:db), @quoter.quoted_date(t)\n end\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date\n find\n end",
"def literal_time(v)\n v.strftime(\"TIMESTAMP '%Y-%m-%d %H:%M:%S'\")\n end",
"def timestamp(row)\n row[0].to_f\nend",
"def easy_date; date; end",
"def local_date_time\n # d = [:year, :mon, :day, :hour, :min, :sec].map{|q| @local_date_time.send(q)}\n # d << (utc_offset/24).to_f\n # #puts d\n # DateTime.new(*d) \n tz0 = utc_offset.to_s.split('.')\n tz = (tz0[0][0]=='-' ? '-' : '+')+('00'+tz0[0].to_i.abs.to_s)[-2,2]+':'\n tz += tz0.count>1 ? ('0'+((('.'+tz0[1]).to_f*100).to_i*0.6).to_i.to_s)[-2,2] : '00'\n @local_date_time.to_datetime.change(:offset => tz) ### \"#{utc_offset}:00\")\n end",
"def default_timestamp_format\n \"TIMESTAMP '%Y-%m-%d %H:%M:%S%N %z'\".freeze\n end",
"def gnupg_date_format(maybe_datetime)\n datetime = case maybe_datetime\n when DateTime then maybe_datetime\n when Time, Date then maybe_datetime.to_datetime\n else raise ArgumentError,\n \"datetime: has to be a DateTime/Time/Date\"\n end\n\n # datetime.utc.iso8601.gsub(/-|:/, '')[0..-6]\n datetime.utc.iso8601.gsub(/-|:/, \"\")[0..-6]\n end",
"def normalize_date(date)\n if zone = active_workspace_configuration[\"TimeZone\"]\n Time.parse(date).in_time_zone(zone).to_date rescue Date.parse(date)\n else\n Date.parse(date)\n end\n end",
"def datetime_clean(value)\n value.to_s.strip.sub(/[+-]00?(:00?)?$/, ZULU).sub(/\\d+\\.\\d+/) do |sec|\n '%02d' % [sec.to_f.round, 59].min\n end\n end",
"def skip_time_zone_conversion_for_attributes\n []\n end",
"def date\n moment.floor\n end"
] |
[
"0.6118587",
"0.6102862",
"0.60548764",
"0.6022073",
"0.5833507",
"0.57795584",
"0.5703911",
"0.5663049",
"0.5656334",
"0.5653293",
"0.56397176",
"0.56332356",
"0.56317246",
"0.5608215",
"0.56046057",
"0.56046057",
"0.56046057",
"0.5591091",
"0.55753785",
"0.5571742",
"0.55708057",
"0.55625427",
"0.5554235",
"0.5548494",
"0.5547097",
"0.5536782",
"0.5525004",
"0.55217844",
"0.5504314",
"0.5495017",
"0.547207",
"0.5469135",
"0.54570884",
"0.54415494",
"0.54414225",
"0.54331946",
"0.5424204",
"0.5423859",
"0.5402534",
"0.5379732",
"0.5376703",
"0.5373255",
"0.5370744",
"0.53691024",
"0.5359933",
"0.53520757",
"0.53504384",
"0.53500533",
"0.53476167",
"0.5346813",
"0.53415763",
"0.53402895",
"0.53292096",
"0.5317701",
"0.53168684",
"0.5315523",
"0.5312779",
"0.5308124",
"0.530613",
"0.530613",
"0.52980036",
"0.52968806",
"0.5296555",
"0.5296555",
"0.52955973",
"0.5295008",
"0.5295008",
"0.5292268",
"0.52815163",
"0.5279697",
"0.52765834",
"0.5274023",
"0.5271936",
"0.5260085",
"0.5253045",
"0.5250379",
"0.5245589",
"0.5237234",
"0.523101",
"0.5229054",
"0.5223943",
"0.5223098",
"0.5222549",
"0.5220973",
"0.5218255",
"0.52153426",
"0.5214947",
"0.520639",
"0.520639",
"0.5205784",
"0.520422",
"0.5202156",
"0.51997876",
"0.51933503",
"0.5192291",
"0.51898324",
"0.5187885",
"0.51790816",
"0.5178398",
"0.5178141"
] |
0.5465254
|
32
|
this should be removed so that we can do better with this open
|
def open()
#note we would want to check for the browser bing open already
#so we don't annoy people
event("Pre")
require 'launchy'
Launchy.open("http://local.general.dev/info.php") #note this should be from setting file
event("Post")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def opening; end",
"def opening; end",
"def opening; end",
"def open_for_read\n end",
"def opened\n end",
"def closed?; end",
"def closed?; end",
"def closed?; end",
"def closed?; end",
"def close() end",
"def close() end",
"def close() end",
"def close() end",
"def close() end",
"def private; end",
"def opened\n raise NotImplementedError\n end",
"def closed?() end",
"def closed?() end",
"def closed?() end",
"def onopen(&blk); super; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def close; end",
"def closing; end",
"def closing; end",
"def open\n raise NotImplementedError\n end",
"def reopen\n end",
"def open_for_write\n end",
"def reopen #rename to differentiate variables\n@open = true\nend",
"def closing?; end",
"def close\n # this method may be left unimplemented if that is applicable\n end",
"def enable_close()\n #This is a stub, used for indexing\n end",
"def close; true; end",
"def close; true; end",
"def close()\n #This is a stub, used for indexing\n end",
"def close_read() end",
"def close_read() end",
"def close_read() end",
"def reopen(*rest) end",
"def reopen(*rest) end",
"def reopen(*rest) end",
"def close\n super\n rescue IOError\n # Already closed\n end",
"def local_closed?; end",
"def open\n Common.contain( self )\n self\n end",
"def initialize\n open\n end",
"def _close\n end",
"def ensure_open\n @opening = false\n @closing = false\n self.openness = 255\n end",
"def closed\n end",
"def closed?() @closed end",
"def open_for_read\n self.eof_flag = false\n open_data_for_read\n end",
"def close\n\t\traise NotImplementedError\n\tend",
"def close\n # this method may be left unimplemented if that is applicable\n end",
"def close_read(*) end",
"def open\n self.closed_at = nil\n end",
"def reader; end",
"def close\n end",
"def close\n end",
"def reopen\n @closed = false\n self\n end",
"def closed_read?() end",
"def open\n refresh\n super\n end",
"def open?\n end",
"def close\n end",
"def close\n end",
"def close\n end",
"def open(i,j)\n end",
"def initialize\n @contents = []\n @open = true\n\n end",
"def close\n # don't need to close\n end",
"def kgio_fastopen(p1, p2)\n #This is a stub, used for indexing\n end",
"def initialize\n\t@contents = []\n\t@open = true\n end",
"def closed\n raise NotImplementedError\n end",
"def handle; end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end",
"def initialize\n @contents = []\n @open = true\n end"
] |
[
"0.7393204",
"0.7393204",
"0.7393204",
"0.6683487",
"0.6411516",
"0.63841563",
"0.63841563",
"0.63841563",
"0.63841563",
"0.6346746",
"0.63443905",
"0.63443905",
"0.63443905",
"0.63443905",
"0.62442607",
"0.6212402",
"0.617273",
"0.617273",
"0.617273",
"0.61665297",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.6156447",
"0.61289185",
"0.61289185",
"0.6074364",
"0.60247785",
"0.59918225",
"0.59333646",
"0.59288865",
"0.5926578",
"0.5921366",
"0.5904287",
"0.5904287",
"0.589995",
"0.5880831",
"0.5880831",
"0.5880831",
"0.5875237",
"0.5875237",
"0.5875237",
"0.58673567",
"0.5827006",
"0.58268106",
"0.5812074",
"0.5800335",
"0.5764657",
"0.57591474",
"0.57324016",
"0.5718261",
"0.5676807",
"0.5669476",
"0.5653273",
"0.56362903",
"0.5631265",
"0.55979776",
"0.55979776",
"0.55881035",
"0.55790335",
"0.55620736",
"0.5558133",
"0.5550053",
"0.5550053",
"0.5550053",
"0.55374223",
"0.5533441",
"0.5529019",
"0.5522036",
"0.55132353",
"0.550437",
"0.54864234",
"0.5485073",
"0.54837155",
"0.54837155",
"0.54837155",
"0.54837155",
"0.54837155",
"0.54837155"
] |
0.0
|
-1
|
qvalues http header parser code taken from webrick
|
def parse_qvalues(value)
tmp = []
if value
parts = value.split(/,\s*/)
parts.each {|part|
if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part)
val = m[1]
q = (m[2] or 1).to_f
tmp.push([val, q])
end
}
tmp = tmp.sort_by{|val, q| -q}
tmp.collect!{|val, q| val}
end
return tmp
rescue
nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cgi_parse_header(line); end",
"def parse_header_contents; end",
"def parseHeaders(request) \n headers = {};\n\n # Loop through headers\n request.lines[1..-1].each do |line|\n # If we are moving to the next line, return what we currently have\n return headers if line == \"\\r\\n\"\n\n # Structure data\n header, value = line.split\n header = header.gsub(\":\", \"\").downcase.to_sym\n headers[header] = value\n end\nend",
"def parse_header(line)\n if (match = line.match(/^(.+?):\\s*(.+)#{@nl}$/))\n key = match[1].downcase\n set_header_special_values(key, match[2])\n parse_normal_header(line, key, match[1], match[2])\n elsif (match = line.match(/^HTTP\\/([\\d\\.]+)\\s+(\\d+)\\s+(.+)$/))\n @response.code = match[2]\n @response.http_version = match[1]\n @http2.on_content_call(@args, line)\n else\n raise \"Could not understand header string: '#{line}'.\"\n end\n end",
"def get_headers\nheader_values = {}\n i = 1\n # while !params[:header][:type_.to_s + \"#{i}\"].nil?\n while !params[:header_values_.to_s + \"#{i}\"].nil?\n\t value = params[:header_values_.to_s + \"#{i}\"].map!{|i| CGI::unescape(i).gsub(\"\\\"\", \"'\")}\n \theader_values[params[:header][:type_.to_s + \"#{i}\"]] = value\n i += 1\n end\n header_values\nend",
"def parse_headers\n headers = {}\n @request.lines[1..-1].each do |line|\n # puts line.inspect\n # puts line.split.inspect\n return headers if line == \"\\r\\n\" # Because HTTP header's last line will be /r/n we return bc we're done\n header, value = line.split\n header = normalize(header)\n headers[header] = value\n end\n \n return headers\n end",
"def _extract_headers(str)\n \n asa = str.split(AMP)\n @headers = {}\n esa = nil\n hv = nil\n asa.each do |hdr|\n esa = hdr.split(EQL)\n hname = SipperUtil.methodize(esa[0])\n if esa[1]\n \n if esa[1] =~ DQ\n hv = esa[1][1...-1]\n else\n hv = esa[1]\n end\n hv = CGI.unescape(hv)\n @headers[hname] = SipperUtil.find_parser_and_parse(hname, hv, true)\n end \n end \n end",
"def parse_headers(headers_hash)\n header_string = \"\"\n for header in headers_hash.select { |k,v| k.match(\"^HTTP.*\") } do\n header_string += header[0]+\":\"+header[1]+\"|\"\n end\n return header_string\n end",
"def parse_headers(raw_headers)\n headers = {}\n raw_headers.each do |h|\n if h =~ /^# *([a-zA-Z_]+) *:(.*)/\n h_key = $1.downcase.intern\n h_value = $2.split(\",\").collect { |v| v.strip }\n if h_value.length > 0 # ignore empty headers\n headers[h_key] = h_value.length > 1 ? h_value : h_value[0]\n end\n end\n end\n \n return headers\n end",
"def raw_headers; end",
"def parse_first_header(line)\n\n # split the line into: METHOD URI PROTOCOL\n # eg: GET / HTTP/1.1\n parsed = line.split(' ')\n\n # a correct request has three parts\n return bad_parsing unless parsed.size == 3\n\n @http_request_method, uri, @http_protocol = parsed\n\n # optional query string\n @http_request_uri, @http_query_string = uri.split('?')\n end",
"def parse_headers raw_headers\n\t\theaders = Hash.new\n\n\t\t# Store values as hash, but don't include duplicate values\n\t\tremove_fws(raw_headers).map do |line|\n\t\t\tkey, value = line.split(\": \", 2)\n\t\t\theaders[key] ||= []\n\t\t\theaders[key] << value unless headers[key].include? value\n\t\tend\n\n\t\t# Pop value from array if there's only one value\n\t\theaders.each{ |key, value| headers[key] = value.pop if value.length == 1 }\n\tend",
"def cgi_parse_header(line)\n parts = _cgi_parseparam(';' + line)\n key = parts.next\n pdict = {}\n\n begin\n while p = parts.next\n i = p.index('=')\n if i\n name = p[0...i].strip.downcase\n value = p[i+1..-1].strip\n if value.length >= 2 && value[0] == '\"' && value[-1] == '\"'\n value = value[1...-1]\n value = value.gsub('\\\\\\\\', '\\\\').gsub('\\\\\"', '\"')\n end\n pdict[name] = value\n end\n end\n rescue StopIteration\n end\n\n [key, pdict]\n end",
"def parse!\n if /^(?<key>.*?):(?<value>.*)/m =~ @raw\n @key = key.strip\n @value = value.strip\n else\n raise \"Unable to parse Header: #{@raw}\"\n end\n end",
"def parse_header(line, opts = {})\n host = opts[:host]\n if host\n line = line.gsub(/^(Host:\\s+).*$/, \"\\\\1#{host}\")\n line = line.gsub(/^(Referer:\\s+https?:\\/\\/)[^\\/]*(.*)$/, \"\\\\1#{host}\\\\2\")\n end\n @headers << line\n line = line.downcase\n if line.start_with? 'content-length: '\n @content_length = line.gsub(/^\\S+\\s+(\\d+)\\s*$/, '\\1').to_i\n elsif line.start_with? 'transfer-encoding: '\n encodings = line.gsub(/^\\S+\\s+(.*)$/, '\\1')\n @transfer_encodings = encodings.split(/\\s*,\\s*/).map {|e| e.strip.to_sym}\n end\n end",
"def parse_setext_header; end",
"def parse_header(raw)\n header = {}\n field = nil\n\n raw.each_line do |line|\n case line\n when /^([A-Za-z0-9!\\#$%&'*+\\-.^_`|~]+):\\s*(.*?)\\s*\\z/om\n field, value = $1, $2\n header[field] = value\n when /^\\s+(.*?)\\s*\\z/om\n value = $1\n fail \"bad header '#{line}'.\" unless field\n\n header[field][-1] << ' ' << value\n else\n fail \"bad header '#{line}'.\"\n end\n end\n\n header.each do |key, value|\n value.strip!\n value.gsub!(/\\s+/, ' ')\n end\n\n header\n end",
"def read_headers!; end",
"def header_raw(str)\n raise \"No HTTP-session attached to this thread.\" if !_httpsession\n raise \"HTTP-session not active.\" if !_httpsession.resp\n Php4r.header(str)\n return nil\n end",
"def headers\n\t\t\thdr = @curb.header_str\n\t\t\tself.class.recode(log?, @curb.content_type, hdr) ?\n\t\t\t\tself.class.parse_headers(hdr) :\n\t\t\t\tself.class.parse_headers(@curb.header_str) # recode failed\n\t\tend",
"def parse_headers(raw_headers)\n # raw headers from net_http have an array for each result. Flatten them out.\n raw_headers.inject({}) do |remainder, (k, v)|\n remainder[k] = [v].flatten.first\n remainder\n end\n end",
"def parse_header(io)\n\t variable_name = nil\n\t parse_pairs io do |code, value|\n\t\tcase code\n\t\t when '0' then next\n\t\t when '9'\n\t\t\tvariable_name = value\n\t\t else\n\t\t\theader[variable_name] = value\n\t\tend\n\t end\n\tend",
"def parse_header(line)\n case line\n when /^#%checkm/\n match = /^#%checkm_(\\d+)\\.(\\d+)/.match line\n @version = \"#{match[1]}.#{match[2]}\" if match\n when /^#%eof/\n @eof = true\n when /^#%fields/\n list = line.split('|')\n list.shift\n @fields = list.map { |v| v.strip.downcase }\n when /^#%prefix/, /^#%profile/\n # do nothing\n end\n end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def parsed_content_type_header; end",
"def parse_http_meta text\n headers = {}\n status = 200\n size = 0\n parts = text.split /^---$/\n if parts.length > 1\n for part in parts.last.split \"\\n\"\n if Oaf::Util.is_http_header? part\n headers.merge! Oaf::Util.get_http_header part\n elsif Oaf::Util.is_http_status? part\n status = Oaf::Util.get_http_status part\n else next\n end\n size += size == 0 ? 2 : 1 # compensate for delimiter\n end\n end\n [headers, status, size]\n end",
"def parse_header_string(header_string)\n status, headers = nil, {}\n return [status, headers] unless header_string\n\n header_string.split(/\\r\\n/).each do |header|\n if header =~ %r|^HTTP/1.[01] \\d\\d\\d (.*)|\n status = $1\n else\n parts = header.split(':', 2)\n unless parts.empty?\n parts[1].strip! unless parts[1].nil?\n if headers.has_key?(parts[0])\n headers[parts[0]] = [headers[parts[0]]] unless headers[parts[0]].kind_of? Array\n headers[parts[0]] << parts[1]\n else\n headers[parts[0]] = parts[1]\n end\n end\n end\n end\n\n [status, headers]\n end",
"def header(buf)\n peek = buf.readbyte(0)\n\n header = {}\n header[:type], type = HEADREP.select do |t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end.first\n\n header[:name] = integer(buf, type[:prefix])\n if header[:type] != :indexed\n header[:name] -= 1\n\n if header[:name] == -1\n header[:name] = string(buf)\n end\n\n if header[:type] == :substitution\n header[:index] = integer(buf, 0)\n end\n\n header[:value] = string(buf)\n end\n\n header\n end",
"def headers(headers); end",
"def encode_header(s); s; end",
"def get_http_header line\n return nil if not is_http_header? line\n parts = line.split(':')\n {parts[0].strip => parts[1].strip}\n end",
"def parse_header( data )\n k,v = data.split(\"\\0\", 2)\n return [k, v.delete(\"\\0\")]\n end",
"def parse_header_line(header_str)\n @headers = header_str.split(',')\n @headers.map! do |h|\n h.gsub!('\"','')\n h.strip!\n h.underscore.to_sym\n end\n @headers\n end",
"def header_to_hash data\n header = {}\n data = data.split(@opts[:delimiter])\n self.req[\"Verb\"], self.req[\"Url\"], self.req[\"Version\"] = data.shift.split(\" \", 3)\n data.each do |line|\n k,v = line.split(\":\", 2)\n if !@opts[:header_bl] || !(HEADER_BLACKLIST.include? k)\n header[k] = v.lstrip\n end\n end\n header\n end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def parse_atx_header; end",
"def parse(text)\n text.split(\"\\n\").each do |line|\n if line =~ /^.*\\:.*$/\n s = line.split(\":\")\n \n key = s[0].strip\n value = s[1].strip\n \n @headers[key] = value\n else\n s = line.split\n \n @http_version = s[0]\n @status = s[1].to_i\n @response_text = s[2]\n end\n end\n end",
"def http_auth_header\n if header['Authorization'].present?\n return header['Authorization'].split(' ').last\n end\n raise(ExceptionHandler::MissingToken, 'Missing_token') #should be refactored into a singleton class man \n end",
"def header(buf)\n peek = buf.getbyte\n buf.seek(-1, IO::SEEK_CUR)\n\n header = {}\n header[:type], type = HEADREP.select do |t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end.first\n\n header[:name] = integer(buf, type[:prefix])\n if header[:type] != :indexed\n header[:name] -= 1\n\n if header[:name] == -1\n header[:name] = string(buf)\n end\n\n if header[:type] == :substitution\n header[:index] = integer(buf, 0)\n end\n\n header[:value] = string(buf)\n end\n\n header\n end",
"def parse_status_and_headers(headers_str)\n status_and_headers = headers_str.split(\"\\r\\n\")\n status_line = status_and_headers.shift\n \n # TODO: there is no support for repeating headers (like Cookie:)\n header_hash = status_and_headers.each_with_object({}) do | header, h|\n split_at = header.index(':')\n key, value = header[0...split_at], header[(split_at + 1)..-1]\n h[key] = value.strip\n end\n raise \"Invalid response status line #{status_line}\" unless status_line =~ STATUS_PAT\n \n http_version, status_code, status = $1, $2, $3\n [status_code.to_i, header_hash]\n end",
"def headers; return {}; end",
"def headers; return {}; end",
"def test_request_signature_get_with_multiple_values_for_header\n uri = URI 'http://localhost/foo/bar'\n req = Net::HTTP::Get.new uri\n req['Date'] = '2015-09-29'\n # Note that Net::HTTPHeader only honors the last header with the same\n # name, discarding earlier values. We can still approximate a cookie\n # with multiple values using the representation below.\n req['Cookie'] = ['foo', 'bar', 'baz=quux']\n req['Gap-Auth'] = 'mbland'\n\n assert_equal(\n ['GET',\n '',\n '',\n '',\n '2015-09-29',\n '',\n '',\n '',\n '',\n 'foo,bar,baz=quux',\n 'mbland',\n '/foo/bar',\n ].join(\"\\n\") + \"\\n\",\n auth.string_to_sign(req))\n\n assert_equal(\n 'sha1 JlRkes1X+qq3Bgc/GcRyLos+4aI=',\n auth.request_signature(req))\n end",
"def parse_request(request_http)\n lines = request_http.split(\"\\n\")\n\n request_line = lines.shift\n method, path, version = request_line.split\n\n headers = {}\n loop do\n line = lines.shift\n break if line =~ /^\\s*$/\n\n key, value = line.split(':', 2)\n headers[key] = value.strip\n end\n\n body = lines.join(\"\\n\")\n\n {\n 'method' => method,\n 'path' => path,\n 'version' => version,\n 'headers' => headers,\n 'body' => body,\n }\n end",
"def parse_header_lines\n if @parsed_values[\"\"].nil? || @parsed_values[\"\"][1].nil?\n @parsed_values[\"\"] = {}\n return\n end\n\n headers = {}\n # Heading lines may have escaped newlines in them\n @parsed_values[\"\"][1].split(/\\\\n/).each do |line|\n next if line.size == 0\n\n if line =~ /(.*?):(.*)/\n key, value = $1, $2\n if headers[key] && headers[key].size > 0\n @errors << [\"Duplicate header line: #{line}\"]\n elsif key =~ /#-#-#-#-#/\n @errors << [\"Marker in header line: #{line}\"]\n else\n headers[key] = value\n end\n else\n @errors << [\"Malformed header #{line}\"]\n end\n end\n\n @parsed_values[\"\"] = headers\n end",
"def parse(content_disposition, header = T.unsafe(nil)); end",
"def parse_Request(request)\n\tinitial_and_headers,body = initialandheaders_Body_Split(request)\n\tinitial,headers = initial_Headers_Split(initial_and_headers)\n\treturn initial,headers,body\n\nend",
"def response_headers_parseable\n response_headers_hash\n rescue HeaderParseError => error\n errors.add :response_headers, \" could not be parsed: #{error.message}\"\n end",
"def header(buf)\n peek = buf.readbyte(0)\n\n header = {}\n header[:type], type = HEADREP.find do |_t, desc|\n mask = (peek >> desc[:prefix]) << desc[:prefix]\n mask == desc[:pattern]\n end\n\n fail CompressionError unless header[:type]\n\n header[:name] = integer(buf, type[:prefix])\n\n case header[:type]\n when :indexed\n fail CompressionError if (header[:name]).zero?\n header[:name] -= 1\n when :changetablesize\n header[:value] = header[:name]\n else\n if (header[:name]).zero?\n header[:name] = string(buf)\n else\n header[:name] -= 1\n end\n header[:value] = string(buf)\n end\n\n header\n end",
"def check_header(header)\n results = Auth.parse_header(header)\n\n assert_equal('auth', results['qop'])\n assert_equal('REALM', results['realm'])\n assert_equal('2006-03-03T17:37:10', results['nonce'])\n assert_equal('', results['opaque'])\n assert_equal('false', results['stale'])\n assert_equal('\\my\\test\\domain', results['domain'])\n end",
"def get_header_and_body\n headers, body = {}, \"\"\n until line = @socket.gets and line.chomp.empty?\n if (kv = line.chomp.split(/:\\s+/,2)).size == 2\n headers.store *kv\n end\n end\n if (content_length = headers[\"Content-Length\"].to_i) > 0\n Log.debug \"content_length is #{content_length}, grabbing from socket\"\n body << @socket.read(content_length)\n end\n headers.merge(\"body\" => body.strip)\n end",
"def header(name)\n rack_header = \"http-#{name}\".upcase!.tr('-', '_')\n\n hdr = @env[rack_header]\n\n # Only return the value if it is not an empty string\n hdr if hdr != ''\n end",
"def str_headers(env, status, headers, res_info, lines, requests, client); end",
"def header(name, value)\n name = name.upcase\n name.tr!('-', '_')\n name = \"HTTP_#{name}\" unless name == 'CONTENT_TYPE' || name == 'CONTENT_LENGTH'\n env(name, value)\n end",
"def parse_header\n header.each do |field, value|\n self.instance_variable_set(\"@#{field}\", value) if HEADER_FIELDS.include? field\n end\n end",
"def request_headers; end",
"def request_headers; end",
"def test_parse_auth_header_with_spacing\n header = 'Digest qop=\"auth\", realm=\"'+ @realm +'\", nonce=\"'+ @nonce +'\", opaque=\"\", stale=\"false\", domain=\"\\my\\test\\domain\"'\n check_header(header)\n end",
"def _extract_params(str)\n @uri_params = SipperUtil.parameterize_header(str)[1] \n end",
"def processed_headers; end",
"def meta\n @meta ||= begin\n arr = @header_str.split(/\\r?\\n/)\n arr.shift\n arr.inject({}) do |hash, hdr|\n key, val = hdr.split(/:\\s+/, 2)\n hash[key.downcase] = val\n hash\n end\n end\n end",
"def test_nasty_pound_header\n parser = HttpParser.new\n nasty_pound_header = \"GET / HTTP/1.1\\r\\nX-SSL-Bullshit: -----BEGIN CERTIFICATE-----\\r\\n\\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\\r\\n\\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\\r\\n\\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\\r\\n\\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\\r\\n\\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\\r\\n\\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\\r\\n\\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\\r\\n\\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\\r\\n\\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\\r\\n\\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\\r\\n\\tu2MSpFyf+9BbC/aXgaZuiCvSR+8Snv3xApQY+fULK/xY8h8Ua51iXoQ5jrgu2SqR\\r\\n\\twgA7BUi3G8LFzMBl8FRCDYGUDy7M6QaHXx1ZWIPWNKsCAwEAAaOCAiQwggIgMAwG\\r\\n\\tA1UdEwEB/wQCMAAwEQYJYIZIAYb4QgEBBAQDAgWgMA4GA1UdDwEB/wQEAwID6DAs\\r\\n\\tBglghkgBhvhCAQ0EHxYdVUsgZS1TY2llbmNlIFVzZXIgQ2VydGlmaWNhdGUwHQYD\\r\\n\\tVR0OBBYEFDTt/sf9PeMaZDHkUIldrDYMNTBZMIGaBgNVHSMEgZIwgY+AFAI4qxGj\\r\\n\\tloCLDdMVKwiljjDastqooXSkcjBwMQswCQYDVQQGEwJVSzERMA8GA1UEChMIZVNj\\r\\n\\taWVuY2UxEjAQBgNVBAsTCUF1dGhvcml0eTELMAkGA1UEAxMCQ0ExLTArBgkqhkiG\\r\\n\\t9w0BCQEWHmNhLW9wZXJhdG9yQGdyaWQtc3VwcG9ydC5hYy51a4IBADApBgNVHRIE\\r\\n\\tIjAggR5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMudWswGQYDVR0gBBIwEDAO\\r\\n\\tBgwrBgEEAdkvAQEBAQYwPQYJYIZIAYb4QgEEBDAWLmh0dHA6Ly9jYS5ncmlkLXN1\\r\\n\\tcHBvcnQuYWMudmT4sopwqlBWsvcHViL2NybC9jYWNybC5jcmwwPQYJYIZIAYb4QgEDBDAWLmh0\\r\\n\\tdHA6Ly9jYS5ncmlkLXN1cHBvcnQuYWMudWsvcHViL2NybC9jYWNybC5jcmwwPwYD\\r\\n\\tVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NhLmdyaWQt5hYy51ay9wdWIv\\r\\n\\tY3JsL2NhY3JsLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAS/U4iiooBENGW/Hwmmd3\\r\\n\\tXCy6Zrt08YjKCzGNjorT98g8uGsqYjSxv/hmi0qlnlHs+k/3Iobc3LjS5AMYr5L8\\r\\n\\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\\r\\n\\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\\r\\n\\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\\r\\n\\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\\r\\n\\tRA==\\r\\n\\t-----END CERTIFICATE-----\\r\\n\\r\\n\"\n req = parser.env\n parser.buf << nasty_pound_header.dup\n\n assert nasty_pound_header =~ /(-----BEGIN .*--END CERTIFICATE-----)/m\n expect = $1.dup\n expect.gsub!(/\\r\\n\\t/, ' ')\n assert_equal req, parser.parse\n assert_equal '', parser.buf\n assert_equal expect, req['HTTP_X_SSL_BULLSHIT']\n end",
"def header(h, buffer = \"\")\n rep = HEADREP[h[:type]]\n\n if h[:type] == :indexed\n buffer << integer(h[:name], rep[:prefix])\n\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name]+1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n if h[:type] == :substitution\n buffer << integer(h[:index], 0)\n end\n\n if h[:value].is_a? Integer\n buffer << integer(h[:value], 0)\n else\n buffer << string(h[:value])\n end\n end\n\n # set header representation pattern on first byte\n fb = buffer[0].unpack(\"C\").first | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def parse_oauth_headers\n # Pull headers and return blank hash if no header variables found\n headers = env['AUTHORIZATION']; result = {};\n return result unless headers && headers[0,5] == 'OAuth'\n # Headers found. Go ahead and match 'em\n headers.split(/,\\n*\\r*/).each do |param|\n phrase, key, value = param.match(/([A-Za-z0-9_\\s]+)=\"([^\"]+)\"/).to_a.map{|v| v.strip}\n result[(key[\"OAuth\"])? :realm : key.to_sym] = value\n end\n result\n end",
"def headers_hash\n @headers_hash ||= Hash[@http_headers.split(\"\\x00\").map{|x| x.split(': ',2)}]\n end",
"def parse_rfc822_header(input)\n headers = Hash.new\n previous = nil\n input.each_line do |line|\n line = line.chomp\n break if line.empty? # Stop at first blank line\n case line\n when /^([^: \\t]+):\\s+(.*)$/\n raise \"Multiple definitions of header '#{$1}'.\" if headers.has_key?($1)\n headers[previous = $1] = $2\n when /^\\s+(.*)$/\n if not previous.nil? and headers.has_key?(previous)\n headers[previous] << \"\\n\" + $1.lstrip\n else\n raise \"Invalid header continuation.\"\n end\n else\n raise \"Invalid header format.\"\n end\n end\n return headers.empty? ? nil : headers\nend",
"def header\n @raw.split(\"--\" + boundary)[0]\n end",
"def build_headers(headers)\n headers.select do |key, value|\n !(key.to_s =~ /cookie/i)\n end.inject([]) do |memo, header|\n memo << {\n :name => header[0].to_s.split('_').map(&:capitalize).join('-'),\n :value => header[1].to_s\n }\n end\nend",
"def parse_header_contents\n text = @src[\"contents\"]\n text.rstrip!\n id_match = HEADER_ID.match(text)\n if id_match\n id = id_match[\"id\"]\n text = text[0...-id_match[0].length]\n text.rstrip!\n end\n [text, id]\n end",
"def verify_header\n # normal header like sample ==> Authorization 'ddd$$%gggrghHFDSS.HHJHTTGGR'\n if headers['Authorization'].present?\n headers['Authorization'].split(' ').last\n else\n errors.add(:token, 'Missing Token')\n nil\n end\n end",
"def parse_header(string)\n {\n # identificação do registro header (conteúdo 0)\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # código da empresa no bradesco\n :codigo_empresa => string[26..45].strip,\n # razão social da empresa\n :razao_social => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => convert_date(string[94..99]),\n # brancos\n #:brancos1 => string[100..107],\n # número aviso bancário\n :numero_aviso_bancario => string[108..112],\n # brancos\n #:brancos2 => string[113..378],\n # data de crédito dos lançamentos\n :data_credito => convert_date(string[379..384]),\n # brancos\n #:brancos3 => string[385..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def header(nheaders,hname)\n\t\t\tnheaders.each_line do |lh|\n\t\t\t\tn,v = lh.split(\": \")\n\t\t\t\tif n == hname\n\t\t\t\t\treturn v\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn hstr\n\t\tend",
"def parse_for_header\n expect(:KW_FOR)\n expect(:L_PARANTH)\n header = parse_for_condition\n expect(:R_PARANTH)\n\n header\n end",
"def decode_captured_headers(string)\n string.split('|', -1).map! { |header| unescape(header) }\n end",
"def decode_captured_headers(string)\n string.split('|', -1).map! { |header| unescape(header) }\n end",
"def headercheck(raw)\n decode(raw)[0...Payload::HEADER.length] == Payload::HEADER\n end",
"def header(str)\n # {{{\n if @output_started\n raise \"HTTP-Headers are already send. You can't change them after output has started!\"\n end\n unless @output_allowed\n raise \"You just can set headers inside of a Rweb::out-block\"\n end\n if str.is_a?Array\n str.each do | value |\n self.header(value)\n end\n\n elsif str.split(/\\n/).length > 1\n str.split(/\\n/).each do | value |\n self.header(value)\n end\n\n elsif str.is_a? String\n str.gsub!(/\\r/, \"\")\n\n if (str =~ /^HTTP\\/1\\.[01] [0-9]{3} ?.*$/) == 0\n pattern = /^HTTP\\/1.[01] ([0-9]{3}) ?(.*)$/\n\n result = pattern.match(str)\n self.setstatus(result[0], result[1])\n elsif (str =~ /^status: [0-9]{3} ?.*$/i) == 0\n pattern = /^status: ([0-9]{3}) ?(.*)$/i\n\n result = pattern.match(str)\n self.setstatus(result[0], result[1])\n else\n a = str.split(/: ?/, 2)\n\n @header[a[0].downcase] = a[1]\n end\n end\n # }}}\n end",
"def fill_header(response); end",
"def header(h, buffer = Buffer.new)\n rep = HEADREP[h[:type]]\n\n if h[:type] == :indexed\n buffer << integer(h[:name], rep[:prefix])\n\n else\n if h[:name].is_a? Integer\n buffer << integer(h[:name]+1, rep[:prefix])\n else\n buffer << integer(0, rep[:prefix])\n buffer << string(h[:name])\n end\n\n if h[:type] == :substitution\n buffer << integer(h[:index], 0)\n end\n\n if h[:value].is_a? Integer\n buffer << integer(h[:value], 0)\n else\n buffer << string(h[:value])\n end\n end\n\n # set header representation pattern on first byte\n fb = buffer[0].unpack(\"C\").first | rep[:pattern]\n buffer.setbyte(0, fb)\n\n buffer\n end",
"def headers=(hash); end",
"def headers=(hash); end",
"def parse_response_headers\n return {} if response_headers.empty?\n\n lines = response_headers.split(\"\\n\")\n\n lines = lines[1..(lines.size - 1)] # Remove Status-Line and trailing whitespace.\n\n # Find only well-behaved HTTP headers.\n lines.map do |line|\n header = line.split(':', 2)\n header.size != 2 ? nil : header\n end.compact.to_h\n end",
"def headerlist; return ['X-MXL-NoteHash', 'X-MXL-Hash', 'X-MX-Bounce']; end",
"def sanitize_header(header, value)\n value\n end",
"def each_response_header(sock)\n key = value = nil\n\n while true\n # read until a newline\n line = sock.readuntil(\"\\n\", true).rstrip\n\n # empty line means we're done with headers\n break if line.empty?\n\n first = line[0]\n line.strip!\n\n # initial whitespace means it's part of the last header\n if first == ?\\s || first == ?\\t && value\n value << ' ' unless value.empty?\n value << line\n else\n yield key, value if key\n key, value = line.split(/\\s*:\\s*/, 2)\n raise HTTPBadResponse, 'wrong header line format' if value.nil?\n end\n end\n\n yield key, value if key\n end",
"def parse(www_authenticate); end",
"def request_headers=(_arg0); end",
"def build_header_auth(uri, version, httpmethod)\n response = get_auth_response(uri)\n @cnonce = Digest::MD5.hexdigest(\"%x\" % (Time.now.to_i + rand(65535)))\n @@nonce_count += 1\n\n response['www-authenticate'] =~ /^(\\w+) (.*)/\n challenge = $2\n params = {}\n challenge.gsub(/(\\w+)=\"(.*?)\"/) { params[$1] = $2 }\n\n a_1 = \"#{@app_id}:#{params['realm']}:#{@app_secret}\" #username, realm and password\n a_2 = \"#{httpmethod}:#{uri}\" #method and path\n request_digest = ''\n request_digest << Digest::MD5.hexdigest(a_1)\n request_digest << ':' << params['nonce']\n request_digest << ':' << ('%08x' % @@nonce_count)\n request_digest << ':' << @cnonce\n request_digest << ':' << params['qop']\n request_digest << ':' << Digest::MD5.hexdigest(a_2)\n\n header = []\n header << \"Digest username=\\\"#{@app_id}\\\"\"\n header << \"realm=\\\"#{params['realm']}\\\"\"\n\n header << \"qop=#{params['qop']}\"\n\n header << \"algorithm=MD5\"\n header << \"uri=\\\"#{uri}\\\"\"\n header << \"nonce=\\\"#{params['nonce']}\\\"\"\n header << \"nc=#{'%08x' % @@nonce_count}\"\n header << \"cnonce=\\\"#{@cnonce}\\\"\"\n header << \"response=\\\"#{Digest::MD5.hexdigest(request_digest)}\\\"\"\n header << \"opaque=\\\"#{params['opaque']}\\\"\"\n\n header_auth_str = header.join(', ')\n @header = {}\n @header[\"Content-Type\"] = \"application/json\"\n if version == API_VERSION_2\n @header[\"Accept\"] = \"application/vnd.com.zipmark.v2+json\"\n else\n @header[\"Accept\"] = \"application/vnd.com.zipmark.v1+json\"\n end\n @header[\"Authorization\"] = header_auth_str\n @header[\"Host\"] = \"curdbee.com\"\n end",
"def headers\n list = @response.header_str.split(/[\\r\\n]+/).map(&:strip)\n Hash[list.flat_map{ |s| s.scan(/^(\\S+): (.+)/) }.map { |pair|\n [pair.first.to_s.camelcase, pair.second]\n }]\n end"
] |
[
"0.7338541",
"0.7102848",
"0.69274634",
"0.6925282",
"0.6776426",
"0.670491",
"0.66628206",
"0.6591524",
"0.65734863",
"0.65713435",
"0.65643156",
"0.6558407",
"0.65351754",
"0.65226936",
"0.64157206",
"0.6406783",
"0.6405212",
"0.63786376",
"0.63459855",
"0.6326906",
"0.6274678",
"0.62738407",
"0.62362415",
"0.6224224",
"0.6224224",
"0.6224224",
"0.6224224",
"0.6212811",
"0.61846626",
"0.6176587",
"0.6169331",
"0.61641705",
"0.61469823",
"0.6129623",
"0.61071986",
"0.60934323",
"0.60854864",
"0.60830265",
"0.60830265",
"0.60830265",
"0.60830265",
"0.60830265",
"0.60830265",
"0.60830265",
"0.60830265",
"0.60830265",
"0.60830265",
"0.6065605",
"0.60634196",
"0.6013584",
"0.6013062",
"0.60065335",
"0.59992146",
"0.59992146",
"0.59853065",
"0.5960159",
"0.59517837",
"0.5945683",
"0.59377146",
"0.5935299",
"0.59143513",
"0.5912367",
"0.58944637",
"0.58905387",
"0.58828735",
"0.5876857",
"0.58522534",
"0.5852176",
"0.5852176",
"0.58352435",
"0.58270013",
"0.5817057",
"0.5817007",
"0.5806291",
"0.57982683",
"0.57923687",
"0.5781878",
"0.5779318",
"0.57778656",
"0.57657737",
"0.5741723",
"0.5734196",
"0.5723323",
"0.57187253",
"0.5710371",
"0.5709067",
"0.5709067",
"0.5707031",
"0.5703886",
"0.5694555",
"0.56835794",
"0.56799287",
"0.56799287",
"0.5667575",
"0.56674856",
"0.5640904",
"0.563444",
"0.5623933",
"0.5616281",
"0.5615936",
"0.559629"
] |
0.0
|
-1
|
Use callbacks to share common setup or constraints between actions.
|
def set_profile
@profile = current_owner.profile
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 profile_params
params.require(:profile).permit(:id, :name, :description, :cpf, :services, :mobile, :zipcode, :address, :number, :complement, :neighborhood, :city, :state, :profile)
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
|
When Car.new is called, this method is run Therefore, for this class, you must pass in 2 variables (make and model) when creating a new instance of it
|
def initialize(make, model)
@make = make
@model = model
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(make, model) #these 2 - make, model - are parameters\n @wheels = 4\n @make = make\n @model = model\n end",
"def initialize (make, model, miles, type, color, year, used)\n\t\t@make = make\n\t\t@model = model\n\t\t@miles = miles\n\t\t@type = type\n\t\t@color = color\n\t\t@year = year\n\t\t@used = used\n\t\tputs \"New car created.\"\n\tend",
"def new\n @car = Car.new\n end",
"def initialize(make, model, year, color, trans, msrp)\n @make = make\n @model = model\n @model_year = year\n @color = color\n @transmission = trans\n @msrp = msrp\n @inventory_id = Car.gen_inventory_id\n end",
"def initialize(make, model, color)\n @make = make\n @model = model\n @color = color\n end",
"def initialize(params)\n setMake(params[:make]);\n setModel(params[:model]);\n setYear(params[:year]);\n commitCar!();\n\n end",
"def initialize(model, make, colour)\r\n @model = model\r\n @make = make\r\n @colour = colour\r\n end",
"def initialize(make, model, classification, owner)\n @make = make\n @model = model\n @classification = classification\n @owner = owner\n @@all << self\n end",
"def create\n @vehicle = Vehicle.new()\n\n \n # Populate the basic information from the form\n @vehicle.make = params[:vehicle][:make]\n @vehicle.model = params[:vehicle][:model]\n @vehicle.miles = params[:vehicle][:miles]\n @vehicle.colour = params[:vehicle][:colour]\n @vehicle.image = params[:vehicle][:image]\n @vehicle.owners = params[:vehicle][:owners]\n @vehicle.reg = params[:vehicle][:reg]\n @vehicle.price = params[:vehicle][:price]\n @vehicle.description = params[:vehicle][:description]\n \n myCar = BasicModelCar.new(@vehicle.make, @vehicle.model, @vehicle.miles, @vehicle.colour, @vehicle.image, @vehicle.owners, @vehicle.reg, @vehicle.price, @vehicle.description)\n crashLogger = CrashLogger.instance\n # Add some additional features to our new car\n # the statements could be written inline: params[:newcar][:fireExt].to_s.length > 0 ? myCar = FireExtinguisher.new(myCar) : null\n if params[:vehicle][:NCT].to_s.length > 0 then\n myCar = NCT.new(myCar)\n end\n if params[:vehicle][:Taxed].to_s.length > 0 then\n myCar = Taxed.new(myCar)\n end\n if params[:vehicle][:ExtendedWarranty].to_s.length > 0 then\n myCar = ExtendedWarranty.new(myCar)\n end\n if params[:vehicle][:Crashed].to_s.length > 0 then\n crashLogger.logCrash(@vehicle.reg.to_s)\n end\n \n ##Populate the cost and description information\n @vehicle.price = myCar.getPrice\n @vehicle.description = myCar.getDescription\n\n respond_to do |format|\n if @vehicle.save\n format.html { redirect_to @vehicle, notice: 'Vehicle was successfully created.' }\n format.json { render json: @vehicle, status: :created, location: @vehicle }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vehicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(make = nil)\n @make = make\n end",
"def setup\n @car = Car.new\n end",
"def create\r\n @car_model = CarModel.new(car_model_params)\r\n\r\n respond_to do |format|\r\n if @car_model.save\r\n format.html { redirect_to @car_model, notice: 'Car model was successfully created.' }\r\n else\r\n format.html { render :new }\r\n end\r\n end\r\n end",
"def init\n\n newCar = Showcar.create(name: \"Reventon\",\n description: \"It was the most expensive Lamborghini road car until the Lamborghini Sesto Elemento was launched, costing two million dollars (~$1.5 million, or ~£840,000). Its top speed was recorded in UAE at 221 miles per hour (355.7 km/h).\",\n photo_link: \"reventon.jpg\")\n newCar.save\n\n newCar = Showcar.create(name: \"Diablo\",\n description: \"The Lamborghini Diablo is a high-performance mid-engined sports car that was built by Italian automaker Lamborghini between 1990 and 2001. It was the first Lamborghini capable of attaining a top speed in excess of 200 miles per hour (320 km/h). After the end of its production run in 2001, the Diablo was replaced by the Lamborghini Murciélago. Diablo means @\\\"devil@\\\" in Spanish.\",\n photo_link: \"diablo.jpg\")\n newCar.save\n\n newCar = Showcar.create(name: \"Veneno\",\n description: \"Lamborthini Veneno is consistently focused on optimum aerodynamics and cornering stability, giving the Veneno the real dynamic experience of a racing prototype, yet it is full homologated for the road.\",\n photo_link: \"veneno.jpg\")\n newCar.save\n\n end",
"def set_make_model\n @make_model = MakeModel.find(params[:id])\n end",
"def set_car_model\r\n @car_model = CarModel.find(params[:id])\r\n end",
"def create\n\t\t\t\tcurrent_driver.create_car(car_params)\n\t\t\tend",
"def make_model_params\n params.require(:make_model).permit(:car_make_id, :model)\n end",
"def set_car_make\n @car_make = CarMake.find(params[:id])\n end",
"def create(model_name,options={})\n # @TODO: this is another path that parallels the ModelFactory\n model_class = Metro::Models.find(model_name)\n mc = model_class.new options\n mc.scene = scene\n mc.window = window\n mc\n end",
"def test_create_my_cars\n assert_equal(@test_car.speed, 0, 'Speed of new car should be 0')\n assert_equal(MyCar.new.model, '')\n assert_equal(MyCar.new.year, 1999)\n assert_equal(MyCar.new.color, 'primer')\n assert_equal(MyCar.new(model:TEST_CAR_MODEL).model, TEST_CAR_MODEL)\n assert_equal(MyCar.new(year:TEST_CAR_YEAR).year, TEST_CAR_YEAR)\n assert_equal(MyCar.new(color:TEST_CAR_COLOR).color, TEST_CAR_COLOR)\n end",
"def validate_model\n raise CarValidationErrors.new(\"Invalid Model\") unless MAKES[make].include?(model)\n end",
"def call(_obj, args, _ctx)\n \toptions = { \n \t\tmake_id: args[:make_id],\n \t\tmake_name: args[:make_name]\n \t}\n\n Make.create(options)\n end",
"def create\n @car = Car.new(params[:car])\n @car.publisher_id = current_user.id\n @car.evaluator_id = User.evaluator.id\n if @car.save\n flash_t :success\n redirect_to case_car_url(@car)\n else\n title_t :new\n render :action => :new_car_accident\n end\n end",
"def initialize(make, model, make_year, origin_price)\n @make = make\n @model = model\n @make_year = make_year\n @origin_price = origin_price\n @current_value = current_value\n @dealer_price = current_value + dealer_markup\n end",
"def make\n fetch('vehicle.makes')\n end",
"def initialize \n @model = \"Generic\"\n @wheels = 2 \n @current_speed = 0\n end",
"def make_and_model; end",
"def initialize(model, year) #metodo constructor permite definir como se contruiran los objetos\n @model = model #guarda lo que sea que tenga en la variable \"model\"\n @year = year\n end",
"def create_car( model, convertible=false)\n # ...\nend",
"def new\n @carrier = Carrier.new\n @carrier.vehicles.build\n end",
"def initialize(model, color, year, origin)\n @model = model\n @color = color\n @year = year\n @origin = origin\n\n @engine_started = false\n @wheels = 4\n end",
"def new\n @recipe = Recipe.new #we do not pass anything to the init..\n end",
"def createVehicle _obj, _args\n \"_obj createVehicle _args;\" \n end",
"def create\n @car = Car.new(params[:car])\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render json: @car, status: :created, location: @car }\n else\n format.html { render action: \"new\" }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(make, color)\n\t\t@make = make #instance variables @make. They are accesible throught the class and your objects\n\t\t@color = color\n\t\tput self.color\n\tend",
"def create\n @car = Car.new(car_params)\n\n if @car.save\n redirect_to @car, notice: 'Car was successfully created.'\n else\n render :new\n end\n end",
"def initialize(model)\n @model = model\n end",
"def initialize(model)\n @model = model\n end",
"def initialize(model)\n @model = model\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n \n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Samochód został utworzony.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n respond_to do |format|\n if @car.save\n format.html { redirect_to cars_path, notice: 'Car (' + @car.name + ') was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render action: 'show', status: :created, location: @car }\n else\n format.html { render action: 'new' }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render action: 'show', status: :created, location: @car }\n else\n format.html { render action: 'new' }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def make_and_model\n m = make\n\n \"#{m} #{model(make_of_model: m)}\"\n end",
"def initialize(make, model, year, color)\n\t\tsuper(make,model,year) #effectively does the below. similar to Parent.call(vars) in js\n\t\t# @make = make \n\t\t# @model = model\n\t\t# @year = year\n\t\t@color = color\n\tend",
"def create\r\n @car = Car.new(car_params)\r\n\r\n respond_to do |format|\r\n if @car.save\r\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\r\n format.json { render :show, status: :created, location: @car }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @car.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def initialize(model, name, owner)\n @model = model\n self.name = name\n self.owner = owner\n self.passengers = []\n self.cargo = []\n end",
"def initialize_model\n # let's create our new empty model\n @model = OpenStudio::Model::Model.new if @model.nil?\n end",
"def initialize(model, template)\n @model = model\n @template = template\n @model_name = @template.controller_name.singularize\n self.class.send(:define_method, @model_name) do\n @model\n end\n end",
"def initialize(model)\n @model = model\n end",
"def setup\n @test_car = MyCar.new(model:TEST_CAR_MODEL,\n year:TEST_CAR_YEAR,\n color:TEST_CAR_COLOR)\n end",
"def car_params\n params.require(:car).permit(:make, :model, :year)\n end",
"def car_params\n params.require(:car).permit(:model, :make, :color, :mileage, :is_for_sale)\n end",
"def make(*args)\n raise NotImplementedError.new('Must override')\n end",
"def car(make, model)\n\tputs make + ' ' + model\nend",
"def car(make, model)\n\tputs make + ' ' + model\nend",
"def make\n if (!params.has_key?(:make) || params[:make].strip.empty? || !params.has_key?(:year) || params[:year].strip.empty?)\n render \"make\"\n else\n @car = Car.new(params[:make], params[:year])\n session[:car] = @car.to_yaml\n redirect_to \"/car/status\"\n end\n end",
"def model_new\n model = Carmodel.new(:title => params[:title], :car_id => params[:car_id])\n if model.save\n txt_append = \"<li class='model_li' model-id='#{model.id}'><input class='subtype_update' value='#{model.title}' size='25' />\"\n txt_append += \"<img alt='Tick' class='model_delete' height='16' src='/assets/refinery/icons/delete.png' width='16' onclick='removemodel(#{model.id})' />\"\n #txt_append += \"refinery_icon_tag('delete.png', :class => 'model_delete')</li>\"\n\n render :text => txt_append\n\n end\n end",
"def new(*args)\n Model.new(*args).tap { |model| yield model if block_given? }\n end",
"def create\n @car = Car.new(car_params)\n if @car.save\n flash[:success] = \"New car added!\"\n redirect_to @car\n else\n render :new\n end\n end",
"def car_make_params\n params.require(:car_make).permit(:name)\n end",
"def initialize\n\t\t@cars = Array.new(2) { |i| Car.new }\n\t\t@cars.each { |car| car.accelerate(rand(1..100)) }\n\tend",
"def car_params\n if(params.has_key?(:car))\n params.require(:car).permit(:make, :model, :year, :color, :vin, :licence, :picture_url, :picture_url_cache,\n :vehicle_type, :body_class, :doors, :gross_vehicle_weight_rating, :transmission_style, :engine_number_of_cylinders, :engine_power, :fuel_type)\n end\n\n end",
"def initialize(make, model, year, msrp)\n # instance variables have instance/object scope\n @make = make\n @model = model\n @year = year\n @msrp = msrp\n @msrp_depr = depr\n end",
"def initialize (model, frame_size, wheels = 2)\n @model = model\n @frame_size = frame_size\n @wheels = wheels\n @speedometer = 0\n end",
"def initialize(model, year, color)\n self.color = color # Call accessor (setter) method.\n @year = year # Only time and way to assign an attr_reader.\n @model = model # Instance variables defined and assigned\n @speed = 0 # here in the initialization method.\n @engine_running = false\n @status = \"Engine switched off and vehicle stationary\"\n end",
"def class Vehicle\r\n attr_accessor :make, :model, :capacity\r\n def initialize(make, model, capacity)\r\n @make = make\r\n @model = model\r\n @fuel_capacity = capacity\r\n @fuel = 50\r\n end\r\n def refuel(litres)\r\n if litres > @fuel_capacity\r\n @fuel = @fuel_capacity\r\n else\r\n @fuel += litres\r\n end\r\n end\r\nend",
"def set_car\n \n @car = Car.find(params[:id])\n end",
"def make; end",
"def car_params\n params.require(:car).permit(:make_id, :description, :model_id, :year, :price, :carType, :transmission, :interior, :miles, :drive, :exterior, :epa, :vin, :image, :published, :featured, :reduced, :pending, :sold )\n end",
"def initialize(year, make)\n @year = year\n @make = make\n end",
"def test_model\n tacoma = Vehicle.new(color: \"Silver\", model_year: 2007, manufacturer: \"Toyota\", model: \"Tacoma\")\n actual = tacoma.model\n assert_equal('Tacoma', actual, \"'Tacoma' as a string should be returned\")\n\n tacoma.model = 'Tundra'\n actual = tacoma.model\n assert_equal('Tundra', actual, \"'Tundra' as a string should be returned\")\n end",
"def create\n @car = Car.find(params[:car_id])\n @driver = @car.drivers.create(params[:driver])\n redirect_to car_path(@car)\n end",
"def car(make, model)\n \"#{make} #{model}\"\nend",
"def car(make, model)\n \"#{make} #{model}\"\nend",
"def car(make, model)\n \"#{make} #{model}\"\nend",
"def create\n @car = current_user.cars.new(car_params)\n #@car = Car.new(car_params)\n\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @car = Car.new(car_params)\n @car.id = Car.count\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render :show, status: :created, location: @car }\n else\n format.html { render :new }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def car_params\n params.require(:car).permit(:make, :model, :year, :car_type, :color, :body_type, :engine_type, \n :transmission, :audio_input, :bluetooth, :heated_seats, :sun_roof, :rearview_camera, :gps, \n :air_conditioner, :electric_doors, :electric_seats, :condition, :video, :description, :latitude, \n :longitude, :price, :address, :city, :state, :driven_wheels, :vehichle_size, :fuel_type, \n :antilock_brake_system, avatars: [])\n end",
"def car_params\n params.require(:car).permit(:make, :model, :color, :price, :year, :condition)\n end",
"def test_car\n new_car = Car.new :make => cars(:new_car).make,\n :model => cars(:new_car).model,\n :Vin => cars(:new_car).Vin,\n :created_at => cars(:new_car).created_at\n assert new_car.save\n\n end",
"def create\n @car = Car.new(params[:car])\n @car.seller_id = @current_seller.id\t\n respond_to do |format|\n if @car.save\n format.html { redirect_to @car, notice: 'Car was successfully created.' }\n format.json { render json: @car, status: :created, location: @car }\n else\n format.html { render action: \"new\" }\n format.json { render json: @car.errors, status: :unprocessable_entity }\n end\n end\n end",
"def newInstance( params={} )\n model.new( params ).extend( InstanceMethods )\n end",
"def reset\n @car = Car.new\n @car.model= random_model \n @car.year=Time.current.year\n end",
"def initialize(model, wheels, frame_size)\n @model = model\n @wheels = wheels\n @frame_size = frame_size\n @bell = \"doesn't rings\"\n @speed = 0\n end",
"def add_make(name)\n unless @makes.has_key?(name)\n camera_make = CameraMake.new(name)\n @makes[name] = camera_make\n else\n camera_make = @makes[name]\n end\n camera_make\n end",
"def make(thing) end",
"def new\n @robot = Robot.new\n end",
"def initialize\n @model = \"BMW\"\n @color = \"Red\"\n @plate = \"#{(\"a\"..\"z\").to_a.sample}-#{rand(1..100)}\"\n @chassis = \"topsecret\"\n end",
"def set_car\n @car = Car.find(params[:id])\n end",
"def set_car\n @car = Car.find(params[:id])\n end",
"def set_car\n @car = Car.find(params[:id])\n end"
] |
[
"0.7462219",
"0.74188995",
"0.7416475",
"0.7096926",
"0.7058828",
"0.699908",
"0.6884808",
"0.68580717",
"0.6783581",
"0.65512407",
"0.6504456",
"0.6503432",
"0.649938",
"0.64527065",
"0.64387816",
"0.64365804",
"0.64203185",
"0.63744015",
"0.6346392",
"0.63099277",
"0.6274346",
"0.6200431",
"0.61700946",
"0.6158224",
"0.61070013",
"0.6091478",
"0.60757583",
"0.6059784",
"0.6053821",
"0.6046224",
"0.6007398",
"0.6001389",
"0.59948564",
"0.5981165",
"0.5965233",
"0.5956844",
"0.5950072",
"0.5950072",
"0.5950072",
"0.5943134",
"0.5943134",
"0.5943134",
"0.5943134",
"0.5943134",
"0.5943134",
"0.5943134",
"0.593762",
"0.59261835",
"0.59160006",
"0.5906469",
"0.5906469",
"0.5891477",
"0.58891207",
"0.5870274",
"0.58674735",
"0.5851784",
"0.58453876",
"0.5843155",
"0.5837423",
"0.5833083",
"0.58309937",
"0.58191043",
"0.5816627",
"0.5816627",
"0.57963717",
"0.5794389",
"0.5789744",
"0.5787556",
"0.5784812",
"0.5782009",
"0.5777026",
"0.57728344",
"0.5771799",
"0.57648563",
"0.57636744",
"0.57566893",
"0.57565325",
"0.5756519",
"0.5736198",
"0.573556",
"0.5734508",
"0.57039046",
"0.57039046",
"0.57039046",
"0.5699743",
"0.56917393",
"0.5683266",
"0.56739205",
"0.5672873",
"0.56711024",
"0.56693274",
"0.56679094",
"0.56619567",
"0.5660844",
"0.56490135",
"0.56465954",
"0.56459165",
"0.56443787",
"0.56443787",
"0.56443787"
] |
0.8067318
|
0
|
Overwriting the sign_out redirect path method
|
def after_sign_out_path_for(resource_or_scope)
user_session_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def after_sign_out_path_for(resource_or_scope)\n '/signed_out'\n end",
"def after_sign_out_path_for(_resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope); end",
"def signout_url\n {:controller => 'auth', :action => 'signout'}\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/users/sign_in'\n end",
"def after_sign_out_path_for(resource_or_scope)\n \"/app/users/sign_in\"\n end",
"def after_sign_out_path_for(resource_or_scope)\n Faraday.get(logout_path) if logout_path.present?\n super(resource_or_scope)\n end",
"def after_sign_out_path_for(resource)\n '/'\n end",
"def after_sign_out_path_for(user)\n '/'\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def sign_out_and_redirect(resource_or_scope); end",
"def after_sign_out_path_for(resource_or_scope)\n # caught by apache to trigger pubcookie logout\n '/logout'\n end",
"def after_sign_out_path_for(resource_or_scope)\n flash[:logout] = true\n root_path\n end",
"def sign_out_and_redirect!(return_to = \"/\")\n sign_out_user\n redirect_to sign_out_url(return_to)\n end",
"def after_sign_out_path_for(resource)\n \tnew_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for user\n reset_session\n\n # for hijacking\n # cookies.delete :secure_user_id\n\n new_user_session_path\n # root_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n # require 'pry'\n # binding.pry\n # Note: at this time: flash[:notice] => \"Signed out successfully.\"\n # current_user is nil.\n new_user_session_path # signIn page\n end",
"def after_sign_out_path_for(resource_or_scope)\n # path before sign out request\n \"#{URI(request.referer).path}?logged_out=1\"\n end",
"def destroy\n super\n after_sign_out_path_for(resource)\n end",
"def sign_out\n\n # mark them as signed out.\n # (this is a helper method of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n # \n # \n #session_sign_out <---- NEED TO CHANGE TO CUSTOM USER SIGN OUT\n\n # send them back to the homepage.\n redirect_to root_path\n\n end",
"def after_sign_out_path_for(resource_or_scope)\n if request.params[:type] == \"sso\"\n Rails.configuration.devise[:sign_out_redirect_url]\n else\n super\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\r\n '/'\r\n end",
"def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(_resource)\n root_path\n end",
"def after_sign_out_path_for(_resource)\n root_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n root_path\n # new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n cookies.delete :pa_auth_token\n \n \"#{Civiccommons::PeopleAggregator.URL}/logout.php?redirect=http://#{request.host}#{request.port == \"80\" ? nil : \":#{request.port}\"}\"\n end",
"def after_sign_out_path_for(resource)\n #if current_user_signed_in?\n # redirect_to home_path \n # else\n redirect_to site_index_path \n #end \n end",
"def after_sign_out_path_for(_resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n\t\tnew_user_session_path\n\tend",
"def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path \n end",
"def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tuser_session_path\n end",
"def sign_out\n logout\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n \tend",
"def after_sign_out_path_for(resource_or_scope)\n login_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n home_path(:ref => \"logout\")\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \t\t\troot_path\n \t\t end",
"def after_sign_out_path_for(_resource)\n root_url\n end",
"def after_sign_out_path_for resource_or_scope\n redirect_uri = params[:redirect_uri]\n redirect_uri ? redirect_uri : super\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/members/sign_in'\n end",
"def signout\n self.oaw_signout\n redirect_to root_url\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n login_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n # root_path\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\r\n login_path\r\n end",
"def after_sign_out_path_for(_)\n root_url\n end",
"def after_sign_out_path_for(resource)\r\n app_root + \"/sessions/new\"\r\n end",
"def after_sign_out_path_for(resource)\n root_path\n end",
"def after_sign_out_path_for(resource)\n root_path\n end",
"def after_sign_out_path_for(resource)\n root_path\n end",
"def signed_out_user\n redirect_to root_path unless !user_signed_in?\n end",
"def after_sign_out_path_for(params)\n bienvenida_path\n end",
"def destroy\n redirect_path = after_sign_out_path_for(\"user\")\n signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(\"user\"))\n set_flash_message :notice, :signed_out if signed_out && is_navigational_format?\n super\n end",
"def after_sign_out_path_for(_resource)\n I18n.locale == I18n.default_locale ? '/' : \"/#{I18n.locale}\"\n end",
"def after_sign_out_path_for(_resource_or_scope)\n home_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tnew_user_session_path\n end",
"def after_sign_out_path_for(user)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n home_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end"
] |
[
"0.81015337",
"0.8007688",
"0.7984609",
"0.7931186",
"0.78991383",
"0.789044",
"0.78749716",
"0.78687364",
"0.78584945",
"0.78447676",
"0.78447676",
"0.78447676",
"0.78447676",
"0.7842587",
"0.7821626",
"0.7789524",
"0.7749104",
"0.77391005",
"0.77310187",
"0.77310187",
"0.77310187",
"0.77310187",
"0.77310187",
"0.7727894",
"0.7727894",
"0.77225393",
"0.77180725",
"0.77098113",
"0.77080196",
"0.7703482",
"0.7695525",
"0.7691706",
"0.7684211",
"0.7684211",
"0.7684048",
"0.7684048",
"0.767817",
"0.767817",
"0.7671087",
"0.76655316",
"0.764426",
"0.76433694",
"0.76422864",
"0.763405",
"0.7630473",
"0.7623184",
"0.7623184",
"0.7623184",
"0.7623184",
"0.7621781",
"0.7621576",
"0.7618084",
"0.76165426",
"0.7614471",
"0.7608315",
"0.76033115",
"0.75976104",
"0.7592272",
"0.75910455",
"0.7588943",
"0.7583923",
"0.7574646",
"0.7559483",
"0.7559269",
"0.7551451",
"0.7542232",
"0.75414157",
"0.7534579",
"0.7534579",
"0.7534579",
"0.7527081",
"0.7523551",
"0.7521828",
"0.75175345",
"0.7515081",
"0.7511004",
"0.7506942",
"0.74854285",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844",
"0.74836844"
] |
0.7732675
|
18
|
puppet version to use (env var)
|
def puppet_version
"PUPPET_VERSION=2.7.19"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_puppet_version\n version = nil\n installed = self.is_in_path?('puppet')\n\n if installed\n raw = self.run('puppet --version')\n version = raw.match(/([\\d\\.]*)\\s/) ? $1 : nil\n else\n version = nil\n end\n\n version\n end",
"def puppet_gem_version\n Gem::Version.create(puppet_version.split(' ').first.strip.gsub('-', '.'))\n end",
"def puppet_version\n return @@puppet_version unless @@puppet_version.nil?\n\n begin\n @@puppet_version = Librarian::Posix.run!(%W{puppet --version}).strip\n rescue Errno::ENOENT, Librarian::Posix::CommandFailure => error\n msg = \"Unable to load puppet. Please install it using native packages for your platform (eg .deb, .rpm, .dmg, etc).\"\n msg += \"\\npuppet --version returned #{error.status}\" if error.respond_to? :status\n msg += \"\\n#{error.message}\" unless error.message.nil?\n $stderr.puts msg\n exit 1\n end\n return @@puppet_version\n end",
"def puppet_version\n raise ArgumentError, '\"puppet_binary\" was not passed to OctocatalogDiff::Catalog::Computed' unless @puppet_binary\n @puppet_version ||= OctocatalogDiff::Util::PuppetVersion.puppet_version(@puppet_binary, @options)\n end",
"def current_version\n node['chef_packages']['chef']['version']\nend",
"def current_version\n node['chef_packages']['chef']['version']\nend",
"def pe_version(host)\n if on(host, 'test -f /opt/puppet/pe_version', :acceptable_exit_codes => [0,1]).exit_code == 0\n return on(host, 'cat /opt/puppet/pe_version').stdout.chomp\n elsif on(host, 'test -f /opt/puppetlabs/server/pe_version', :acceptable_exit_codes => [0,1]).exit_code == 0\n return on(host, 'cat /opt/puppetlabs/server/pe_version').stdout.chomp\n else\n return 'version unknown'\n end\n end",
"def puppetserver_version_on(host)\n result = on(host, 'puppetserver --version', accept_all_exit_codes: true)\n if result.exit_code.zero?\n matched = result.stdout.strip.scan(/\\d+\\.\\d+\\.\\d+/)\n return matched.first\n end\n nil\n end",
"def version\n p\n version = File.read(HOSTER_PATH+\"/hoster.version\")\n puts PROGNAME + \" version \" + version\nend",
"def pe_version(master_host)\n if on(master_host, 'test -f /opt/puppet/pe_version', :acceptable_exit_codes => [0,1]).exit_code == 0\n return on(master_host, 'cat /opt/puppet/pe_version').stdout.chomp\n elsif on(master_host, 'test -f /opt/puppetlabs/server/pe_version', :acceptable_exit_codes => [0,1]).exit_code == 0\n return on(master_host, 'cat /opt/puppetlabs/server/pe_version').stdout.chomp\n else\n return 'version unknown'\n end\n end",
"def version\n @version ||= exec('SHOW server_version')[0]['server_version'].split[0]\n end",
"def platform_and_version\n case node['platform']\n when 'debian'\n platform_and_version = \"debian-#{node['platform_version'].to_i}\"\n when 'ubuntu'\n platform_and_version = \"ubuntu-#{node['platform_version']}\"\n end\n platform_and_version\n end",
"def version_number\n self.name =~ /RHEL-([0-9]+)/\n return $1.to_i\n end",
"def installed_version\n capture(\"#{chef_solo} -v || true\") =~ /Chef: (\\d+\\.\\d+\\.\\d+)/ ? $1 : nil\n end",
"def version\n @version ||= config(\"version\", \"0.0.1\")\n end",
"def get_pe_version(master)\n pe_major = on(master, 'facter -p pe_major_version').stdout.rstrip\n pe_minor = on(master, 'facter -p pe_minor_version').stdout.rstrip\n\n return \"#{pe_major}.#{pe_minor}\".to_f\nend",
"def platform_and_version\n return \"debian-#{node['platform_version'].to_i}\" if node['platform'] == 'debian'\n return \"ubuntu-#{node['platform_version']}\" if node['platform'] == 'ubuntu'\n end",
"def current_deployed_version\n 5\n end",
"def puppet_agent_version_on(host)\n result = on(host, facter('aio_agent_version'), accept_all_exit_codes: true)\n return result.stdout.strip if result.exit_code.zero?\n\n nil\n end",
"def version_to_install\n return config[:bootstrap_version] if config[:bootstrap_version]\n\n if config[:channel] == \"stable\"\n Chef::VERSION.split(\".\").first\n else\n \"latest\"\n end\n end",
"def component_version(exec)\n cmd = \"#{exec} --version\"\n po = Puppet::Util::Execution.execute(cmd, combine: false)\n raise \"Exit #{po.exitstatus} running #{cmd.join(' ')}. STDOUT: #{po}\" if po.exitstatus != 0\n\n po.strip\n end",
"def version; env['api.version'] end",
"def puppet_6_or_greater?\n if Puppet.version.to_f >= 6.0 # Puppet 6 required for Bolt task execution\n return true\n end\n false\nend",
"def platform_version_for_package\n if platform == 'rhel'\n platform_version[/([\\d]+)\\..+/, 1]\n else\n platform_version\n end\n end",
"def get_node_version\n run_ssh_command('node --version')\n end",
"def latest_pre_version(pe_family)\n open(\"http://getpe.delivery.puppetlabs.net/latest/#{pe_family}\").read\nend",
"def get_os_version(ssh_session)\n (ssh_session,os_version) = ssh_session_exec(ssh_session,\"uname -r\")\n os_version = os_version.chomp\n if $verbose_mode == true\n puts \"vSphere version: \"+os_version\n end\n return ssh_session,os_version\nend",
"def customize\n # If the PACKAGE_VERSION variable is passed from the command line, then set\n # @package_version equal to what was passed. Else, use the current version\n # of puppet\n if ENV['PACKAGE_VERSION']\n @package_version = ENV['PACKAGE_VERSION']\n else\n @package_version = '2.7.3'\n end\n \n # Puppet-specific Variables\n @title = \"Puppet_Install\"\n @reverse_domain = \"com.puppetlabs\"\n @package_major_version = @package_version.split('.')[0]\n @package_minor_version = @package_version.split('.')[1] + @package_version.split('.')[2]\n @puppet_file = \"puppet-#{@package_version}\"\n @puppet_url = \"http://downloads.puppetlabs.com/puppet/\"\n @puppet_tarfile = \"#{@puppet_file}.tar.gz\"\nend",
"def ubuntu_facts\n {\n :osfamily => 'Debian',\n :operatingsystem => 'Ubuntu',\n :lsbdistid => 'Ubuntu',\n :lsbdistcodename => 'precise',\n :operatingsystemrelease => '12.04',\n :operatingsystemmajrelease => '12.04',\n :concat_basedir => '/tmp', # Concat\n :puppetversion => '4.8.1', # Apt\n :virtualenv_version => '12.0', # Should not matter for spec tests (python dependency)\n }\nend",
"def hdp_version\n case node['hadoop']['distribution_version']\n when '2.2.0.0'\n '2.2.0.0-2041'\n when '2.2.1.0'\n '2.2.1.0-2340'\n when '2.2.4.2'\n '2.2.4.2-2'\n when '2.2.4.4'\n '2.2.4.4-16'\n when '2.2.6.0'\n '2.2.6.0-2800'\n when '2.2.6.3'\n '2.2.6.3-1'\n when '2.2.8.0'\n '2.2.8.0-3150'\n when '2.2.9.0'\n '2.2.9.0-3393'\n when '2.3.0.0'\n '2.3.0.0-2557'\n when '2.3.2.0'\n '2.3.2.0-2950'\n when '2.3.4.0'\n '2.3.4.0-3485'\n when '2.3.4.7'\n '2.3.4.7-4'\n when '2.4.0.0'\n '2.4.0.0-169'\n else\n node['hadoop']['distribution_version']\n end\n end",
"def system_version\n @system_version ||= File.read(Rails.root.join(\"VERSION\")).strip\n end",
"def version\n unless version = shift_argument\n error(\"Usage: heroku config:version VERSION\\nMust specify VERSION.\")\n end\n\n vars = api.get_config_vars(app).body\n _, versions_data = vars.detect {|k,v| k == 'HEROKU_CONFIG_VERSIONS'}\n\n if versions_data\n versions = JSON.parse(Zlib::Inflate.inflate(Base64.decode64(versions_data)))\n\n if version_vars = versions[version]\n styled_header(\"#{app} Config Vars for version #{version}\")\n styled_hash(version_vars)\n else\n display(\"There are any version named #{version}\")\n end\n else\n display(\"#{app} has no versioned config vars.\")\n end\n end",
"def module_version\n return '0.0.1' unless modulefile?\n\n metadata = ::Puppet::ModuleTool::Metadata.new\n ::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)\n\n metadata.version\n end",
"def required_version\n fetch(:chef_version) || nil\n end",
"def chef_version\n v = run_command('sudo chef-solo --version').stdout.split(':')\n v[0].strip == 'Chef' ? v[1].strip : ''\n end",
"def el_version\n if File.exists?('/etc/fedora-release')\n nil\n elsif File.exists?('/etc/redhat-release')\n rpm = Pkg::Util::Tool.find_tool('rpm', :required => true)\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{rpm} -q --qf \\\"%{VERSION}\\\" $(#{rpm} -q --whatprovides /etc/redhat-release )\")\n stdout\n end\n end",
"def yum_releasever\n platform?('amazon') ? '7' : '$releasever'\n end",
"def os_version\n if !@os_version\n if Facter['operatingsystemrelease'] &&\n Facter['operatingsystemrelease'].value &&\n !Facter['operatingsystemrelease'].value.empty?\n @os_version = Facter['operatingsystemrelease'].value\n else\n raise \"Unable to determine proper OS value on this platform\"\n end\n end\n @os_version.dup\n end",
"def pdb_get_os_major_release(facts)\n if facts.is_a?(Hash) && !facts['operatingsystemmajrelease'].nil? && !facts['operatingsystemmajrelease']['value'].nil?\n os_major_release = facts['operatingsystemmajrelease']['value']\n Puppet.info(\"#{log_prefix} puppet os major release for node is: os major release=#{os_major_release}\")\n os_major_release\n else\n \"Unknown\"\n end\n end",
"def old_version?\n case @node['platform']\n when 'ubuntu'\n Chef::VersionConstraint.new(\"< 11.0\").include?(@node['platform_version'])\n when 'debian'\n Chef::VersionConstraint.new(\"< 7.0\").include?(@node['platform_version'])\n end\n end",
"def linux_version\n case ENV['MACHTYPE']\n when \"s390x-suse-linux\"\n :sles_zlnx\n when /^i[356]86/\n if File.exist? \"/etc/fedora-release\"\n :linux_ia32_cell\n else\n :linux_ia32\n end\n else\n if File.exist? \"/etc/rhel-release\"\n :rhel\n elsif File.exist? \"/etc/redhat-release\"\n `awk '/release 5/||/release 4.9/{v=5};/release 4/{v=4}; END {print \"rhel\" v}' /etc/redhad-release`.to_sym\n elsif File.exist? \"/etc/SuSE-release\"\n `awk '$1==\"VERSION\" { v=$3}; END { print \"sles\" v}' /etc/SuSE-release`.to_sym\n elsif File.exist? \"/etc/yellowdog-release\"\n :yhpc\n else\n :rhel\n end\n end\nend",
"def Check_OS_Version()\n\tos_version = `ver`\n\treturn os_version\nend",
"def define_provisioner\n { 'name' => 'chef-zero', 'require_chef_omnibus' => 'latest' }\n end",
"def yum_releasever\n platform?('amazon') ? '6' : '$releasever'\n end",
"def mock_el_ver(mock_config)\n if Pkg::Config.build_pe\n # This uses a regex capture instead of splitting to allow the now defunct PE version component to be optional\n version = mock_config.match(/^pupent-(\\d\\.\\d-)?([a-z]+)([0-9]+)-(.*)$/)[3]\n else\n first, second, third = mock_config.split('-')\n if ['el', 'fedora'].include?(first) || (first == 'pl' && second.match(/^\\d+$/))\n version = second\n else\n version = third\n end\n end\n if [first, second].include?('fedora')\n version = \"f#{version}\"\n end\n version\nend",
"def puppet_provisioner(provisioner, type, version, role)\n # For PE 2015.x agents.\n if provisioner['type'] == 'pe_agent'\n provisioner['master_vm'] ||= \"#{type}-#{version.to_s.gsub('.','')}-master\"\n provisioner['version'] ||= (version.patch == 'nightly' ? 'current' : version.to_s)\n return provisioner\n end\n\n case version.patch\n when 'nightly'\n # FIXME: This part is going to ge complicated. Re-write as a separate\n # method.\n if provisioner['version'].nil?\n provisioner['series'] ||= version.series\n # FIXME: Raise error if either of these is nil.\n provisioner['version_file'] = @debug_kit.fetch('nightlies', {}).fetch('pe', {}).fetch('version_file', nil)\n end\n provisioner['download_root'] ||= @debug_kit.fetch('nightlies', {}).fetch('pe', {}).fetch('download_root', nil)\n else\n # TODO: When /\\d+/. Else, raise error.\n provisioner['version'] ||= version.to_s\n end\n\n provisioner['role'] ||= role.intern\n case provisioner['role']\n when :master\n # Starting with 2015, we use the pe_agent provisioner which handles\n # cert signing.\n provisioner['autosign'] ||= (version.major.to_i < 2015)\n when :agent\n # Set a default master for the agent to talk to.\n provisioner['master'] ||= \"#{type}-#{version.to_s.gsub('.','')}-master.puppetdebug.vlan\"\n end\n\n return provisioner\n end",
"def debian_version\n super ||\n ( version_gte?( ubuntu_version, [18,4] ) && '10' ) ||\n ( version_gte?( ubuntu_version, [15,4] ) && '8' ) ||\n ( version_gte?( ubuntu_version, [14,4] ) && '7' ) ||\n ( version_gte?( ubuntu_version, [12,4] ) && '6' )\n end",
"def os\n Facter.value(:operatingsystem)\n end",
"def variable_define_flags\n flags = Hash.new\n flags['PuppetDescTag'] = describe 'downloads/puppet'\n flags['FacterDescTag'] = describe 'downloads/facter'\n\n # The regular expression with back reference groups for version string\n # parsing. We re-use this against either git-describe on Puppet or on\n # ENV['PE_VERSION_STRING'] which should match the same pattern. NOTE that we\n # can only use numbers in the product version and that product version\n # impacts major upgrades: ProductVersion Property is defined as\n # [0-255].[0-255].[0-65535] See:\n # http://stackoverflow.com/questions/9312221/msi-version-numbers\n # This regular expression focuses on the major numbers and discards things like \"rc1\" in the string\n version_regexps = [\n /(\\d+)[^.]*?\\.(\\d+)[^.]*?\\.(\\d+)[^.]*?-(\\d+)-(.*)/,\n /(\\d+)[^.]*?\\.(\\d+)[^.]*?\\.(\\d+)[^.]*?\\.(\\d+)/,\n /(\\d+)[^.]*?\\.(\\d+)[^.]*?\\.(\\d+)[^.]*?/,\n ]\n\n case ENV['BRANDING']\n when /enterprise/i\n flags['PackageBrand'] = \"enterprise\"\n msg = \"Could not parse PE_VERSION_STRING env variable. Set it with something like PE_VERSION_STRING=2.5.0\"\n # The Package Version components for FOSS\n match_data = nil\n version_regexps.find(lambda { raise ArgumentError, msg }) do |re|\n match_data = ENV['PE_VERSION_STRING'].match re\n end\n flags['MajorVersion'] = match_data[1]\n flags['MinorVersion'] = match_data[2]\n flags['BuildVersion'] = match_data[3]\n flags['Revision'] = match_data[4] || 0\n else\n flags['PackageBrand'] = \"foss\"\n msg = \"Could not parse git-describe annotated tag for Puppet\"\n # The Package Version components for FOSS\n match_data = nil\n version_regexps.find(lambda { raise ArgumentError, msg }) do |re|\n match_data = flags['PuppetDescTag'].match re\n end\n flags['MajorVersion'] = match_data[1]\n flags['MinorVersion'] = match_data[2]\n flags['BuildVersion'] = match_data[3]\n flags['Revision'] = match_data[4] || 0\n end\n\n # Return the string of flags suitable for candle\n flags.inject([]) { |a, (k,v)| a << \"-d#{k}=\\\"#{v}\\\"\" }.join \" \"\nend",
"def server_version; end",
"def server_version\n status['value']['build']['version']\n end",
"def jboss_product\n Facter.value(:jboss_product)\n end",
"def debian_version\n IO.read('/etc/debian_version').strip.split('.')\n end",
"def set_version(version)\n file_sub(GEMSPEC, /(\\.version\\s*=\\s*).*/, \"\\\\1'#{version}'\")\n file_sub(VERSION_RB, /^(\\s*VERSION\\s*=\\s*).*/, \"\\\\1'#{version}'\")\nend",
"def kernel_version\n uname('-v')\n end",
"def hdp_version\n case node['hadoop']['distribution_version']\n when '2.2.0.0'\n '2.2.0.0-2041'\n when '2.2.1.0'\n '2.2.1.0-2340'\n when '2.2.4.2'\n '2.2.4.2-2'\n when '2.2.4.4'\n '2.2.4.4-16'\n when '2.2.6.0'\n '2.2.6.0-2800'\n when '2.2.6.3'\n '2.2.6.3-1'\n when '2.2.8.0'\n '2.2.8.0-3150'\n when '2.2.9.0'\n '2.2.9.0-3393'\n when '2.3.0.0'\n '2.3.0.0-2557'\n when '2.3.2.0'\n '2.3.2.0-2950'\n when '2.3.4.0'\n '2.3.4.0-3485'\n when '2.3.4.7'\n '2.3.4.7-4'\n when '2.3.6.0'\n '2.3.6.0-3796'\n when '2.4.0.0'\n '2.4.0.0-169'\n when '2.4.2.0'\n '2.4.2.0-258'\n when '2.4.3.0'\n '2.4.3.0-227'\n when '2.5.0.0'\n '2.5.0.0-1245'\n when '2.5.3.0'\n '2.5.3.0-37'\n when '2.5.5.0'\n '2.5.5.0-157'\n when '2.5.6.0'\n '2.5.6.0-40'\n when '2.6.0.3'\n '2.6.0.3-8'\n when '2.6.1.0'\n '2.6.1.0-129'\n when '2.6.2.0'\n '2.6.2.0-205'\n when '2.6.3.0'\n '2.6.3.0-235'\n when '2.6.4.0'\n '2.6.4.0-91'\n else\n # fetch build number from HDP public repository\n build_number = hdp_build_number(node['hadoop']['distribution_version'])\n [node['hadoop']['distribution_version'], build_number].compact.join('-')\n end\n end",
"def version\n version_file = File.join(RAILS_ROOT, \"config\", \"version.ini\")\n current_version = if File.exists? version_file\n File.read(version_file)\n else\n \"0.0.1\"\n end\n current_version.strip\n end",
"def nginx_version\n return nil unless node.key?('nginx')\n node['nginx']['version']\n end",
"def puppet4?\n Puppet.version.to_f >= 4.0\n end",
"def target_version\n config[:target_version] || Chef::VERSION\n end",
"def puppet_conditional_install_precise\n fail(\"Invalid hostname ('#{@box.hostname}' doesn't match /#{VMDeploy[:valid_pool_hostname]}/), refusing to try and install Puppet\") unless @box.hostname.to_s.match(VMDeploy[:valid_pool_hostname])\n @puppet_version = puppet_get_version\n if @puppet_version.nil?\n log.info 'Puppet is not installed - installing it'\n\n ret = @box.sudo 'wget', '--no-verbose', 'http://apt.puppetlabs.com/puppetlabs-release-precise.deb'\n log.info '\"puppet-release\" repo package downloaded'\n\n ret = @box.sudo 'dpkg', '-i', 'puppetlabs-release-precise.deb'\n log.info '\"puppet-release\" repo package installed'\n\n ret = @box.sudo 'apt-get', 'update', '-q'\n ret = @box.sudo 'apt-get', 'install', '-y', '-q', 'puppet'\n @puppet_version = puppet_get_version\n fail('\"apt-get install puppet\" doesn\\'t seem to have installed Puppet') if @puppet_version.nil?\n fail('unknown Puppet version') if @puppet_version == 'unknown'\n log.info \"Installed Puppet version #{@puppet_version}\"\n else\n log.info \"Puppet already installed - version #{@puppet_version}\"\n end\n @puppet_version\n rescue Exception => e\n log.error e.message\n raise\n end",
"def chef_version\n # SPEC_BLOCK_CI is used to force non-locking behavior inside tests.\n @chef_version ||= ENV['CHEF_VERSION'] || if ENV['POISE_MASTER_BUILD']\n # We're going to install the latest nightly via Omnitruck later on.\n nil\n elsif ENV['SPEC_BLOCK_CI'] != 'true'\n # If there isn't a specific override, lock TK to use the same version of Chef as the Gemfile.\n require 'chef/version'\n Chef::VERSION.to_s\n end\n end",
"def version\n version_property ? version_property.ruby_value : nil\n end",
"def ruby_version; '2.6.3' end",
"def distro_ruby_versions\n case distribution_class\n when :ubuntu\n if is_distribution?(\"<= artful\")\n [\"2.3\"]\n elsif is_distribution?(\"<= eoan\")\n [\"2.5\"]\n elsif is_distribution?(\"<= impish\")\n [\"2.7\"]\n elsif is_distribution?(\"<= kinetic\")\n [\"3.0\"]\n else\n [\"3.1\"]\n end\n when :debian\n if is_distribution?(\"<= jessie\")\n [\"2.1\"]\n elsif is_distribution?(\"<= stretch\")\n [\"2.3\"]\n elsif is_distribution?(\"<= buster\")\n [\"2.5\"]\n elsif is_distribution?(\"<= bullseye\")\n [\"2.7\"]\n else\n [\"3.1\"]\n end\n else\n raise \"Unknown distribution class\"\n end\nend",
"def default_puppet_env_name\n ENV['PUPPET_ENV'] || Puppet[:environment]\n end",
"def default_puppet_env_name\n ENV['PUPPET_ENV'] || Puppet[:environment]\n end",
"def loaded_config_version; end",
"def loaded_config_version; end",
"def version\n Buildr.application.deprecated 'Use ENV_JAVA[\\'java.version\\'] instead.'\n Java.load\n ENV_JAVA['java.version']\n end",
"def version\n execute_string(\"-version\")\n end",
"def oracle_server_vernum()\n #This is a stub, used for indexing\n end",
"def swversion\n config[\"swversion\"]\n end",
"def version\n output = @filer.invoke(\"system-get-version\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.child_get_string(\"version\")\n end\n end",
"def version_from_ruby_version_file\n shell_return = run_shell(\"cat .ruby-version\")\n shell_return.nil? ? nil : shell_return.stdout\n end",
"def platform_version\n truncate_platform_version(Ohai[\"platform_version\"], platform_shortname)\n end",
"def ruby_version\n\t\treturn RUBY_VERSION.split( /\\./, 3 ).map( &:to_i ).pack( 'n*' )\n\tend",
"def ruby_version(v)\n @ruby_version = v\n end",
"def client_meta_version(version)\n regexp = /^([0-9]+\\.[0-9]+\\.[0-9]+)(\\.?[a-z0-9.-]+)?$/\n match = version.match(regexp)\n return \"#{match[1]}p\" if (match[2])\n\n version\n end",
"def environment_version\n metadata[:environment_version]\n end",
"def read_version\n # The version string is usually in one of the following formats:\n #\n # * 4.1.8r1234\n # * 4.1.8r1234_OSE\n # * 4.1.8_MacPortsr1234\n #\n # Below accounts for all of these:\n execute(\"--version\").split(\"_\")[0].split(\"r\")[0]\n end",
"def choose_version(version)\n if version =~ /(\\d+)\\.(\\d+)\\.(\\d+)/\n major = $1\n minor = $2\n patch = $3\n if config[:major]\n major = major.to_i + 1\n minor = 0\n patch = 0\n end\n if config[:minor]\n minor = minor.to_i + 1\n patch = 0\n end\n patch = patch.to_i + 1 if config[:patch]\n version = \"#{major}.#{minor}.#{patch}\"\n Chef::Log.debug(\"New version is #{version}\")\n else\n Chef::Log.error(\"Version is in a format I cannot auto-update\")\n exit 1\n end\n version\n end",
"def fingerprint(res)\n version = \"Puppetmaster\"\n puppet_ver = \"< 3.3.1-rc3\"\n http_fingerprint({ :response => res })\n\n data = res.headers['X-Puppet-Version']\n if data\n version << \" #{data}\"\n else\n version << \" #{puppet_ver}\"\n end\n\n data = res.headers['Server']\n version << \" running on #{data}\" if data\n return version\n end",
"def version\n str = if detect_product(\"CriOs\")\n crios.version\n else\n chrome.version\n end\n\n Version.new(str)\n end",
"def os_ver\n @values.fetch('osVer') { \n @values['osVer'] = nil\n }\n end",
"def role_puppet_master\n $myxp.get_deployed_nodes('capi5k-init').first\nend",
"def http_version\n @http_version ||= [\n 'HTTP_VERSION',\n 'SERVER_PROTOCOL',\n ].map{ |x| rack_environment[x] }.find.first.to_s.split('/').last\n end",
"def os_ver=(value)\n if value == @defaults['osVer']\n @values.delete 'osVer' if @values.key? 'osVer'\n else\n @values['osVer'] = value\n end\n end",
"def perl_version\n `perl --version 2>&1`.match(/\\(v([\\d\\.]+)\\)/)[1]\n end",
"def ver\n @values.fetch('ver') { \n @values['ver'] = 1\n }\n end",
"def get_version_info\n if defined?(Sensu::Enterprise::VERSION)\n [\"enterprise\", Sensu::Enterprise::VERSION]\n else\n [\"core\", Sensu::VERSION]\n end\n end",
"def pe_family\n if !ENV['PE_VERSION'] || ENV['PE_VERSION'] == 'latest'\n if ENV['PE_FAMILY']\n return ENV['PE_FAMILY']\n elsif !PRE_RELEASE\n return nil\n else\n puts \"You must set the PE_VERSION or PE_FAMILY environment variable to build a pre-release version\"\n exit 1\n end\n else\n ENV[\"PE_VERSION\"].split('.')[0 .. 1].join('.')\n end\nend",
"def platform_version\n version = capabilities['platformVersion']\n version.nil? ? nil : version.to_s\n end",
"def docker_version() ; info[:docker_version] ; end",
"def find_centos_minor_version\n os_minor_version = ''\n kernel_patch_version = find_kernel_patch_version\n\n os_minor_version = '7' if kernel_patch_version >= '1062'\n os_minor_version = '8' if kernel_patch_version >= '1127'\n os_minor_version = '9' if kernel_patch_version >= '1160'\n\n os_minor_version\nend",
"def version(arg = nil)\n if arg\n @version = Chef::Version.new(arg)\n end\n\n @version.to_s\n end",
"def version\n @version ||= begin\n m = /^Terraform v(?<version>[^\\s]+)/.match(`terraform version`)\n m && m[:version]\n end\n rescue Errno::ENOENT\n nil\n end",
"def version\n cmd(COMMANDS[:version], 2)\n end",
"def puppet_installation\n `cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} deploy:prepare_installation:puppet -S phase=node_prepare HOSTS=#{self.hostname}`\n end",
"def version\n @version ||= File.read(path('version.txt')).strip\n end"
] |
[
"0.77366716",
"0.75111145",
"0.7426613",
"0.6920203",
"0.68346065",
"0.68346065",
"0.67788976",
"0.6649844",
"0.66149205",
"0.6544868",
"0.6436166",
"0.64218706",
"0.6409458",
"0.63958323",
"0.6390239",
"0.63891894",
"0.6389179",
"0.6388214",
"0.6361351",
"0.63382107",
"0.6329638",
"0.63228273",
"0.63141143",
"0.6285107",
"0.6256635",
"0.62432474",
"0.62290055",
"0.6214894",
"0.6208548",
"0.6177475",
"0.617535",
"0.6171636",
"0.61495423",
"0.61272067",
"0.61248183",
"0.6117173",
"0.6106689",
"0.61030257",
"0.61016655",
"0.60849994",
"0.60842186",
"0.6072416",
"0.60722774",
"0.60714495",
"0.60649675",
"0.605728",
"0.6046072",
"0.60436034",
"0.60247606",
"0.6018254",
"0.60173154",
"0.6016442",
"0.6002941",
"0.5991564",
"0.5989295",
"0.598516",
"0.59823704",
"0.5981086",
"0.59443456",
"0.59357446",
"0.59333897",
"0.5928556",
"0.59230435",
"0.59224945",
"0.591621",
"0.59149534",
"0.59149534",
"0.5900055",
"0.5900055",
"0.5891335",
"0.5878239",
"0.58752507",
"0.5872854",
"0.5872717",
"0.585773",
"0.5853335",
"0.585194",
"0.58494204",
"0.5848458",
"0.584481",
"0.58347505",
"0.5814677",
"0.5805278",
"0.5798576",
"0.57862574",
"0.5778264",
"0.57694054",
"0.5763801",
"0.5756484",
"0.5756279",
"0.57524014",
"0.57403207",
"0.5739359",
"0.572814",
"0.5727005",
"0.5725724",
"0.5723051",
"0.57190984",
"0.57132834",
"0.5712453"
] |
0.7795586
|
0
|
TODO: Don't mark loans as realised if they have futher recoveries.
|
def realise_loans!
loan_ids = realised_recoveries.map {|recovery| recovery.loan.id }.uniq
Loan.find(loan_ids).each do |loan|
loan.realised_money_date = Date.today
loan.modified_by = creator
loan.update_state!(Loan::Realised, LoanEvent::RealiseMoney, creator)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def lost?\n # Fill this in\n end",
"def lost?\n @life <=0\n end",
"def can_recover?\n self.lapsed? and not self.blacklisted\n end",
"def before_recover\n end",
"def after_recover\n end",
"def handle_completly_uncontested!\n\n # sole party get three seats\n sole_party = @parties.first\n sole_party.award(3)\n\n # TODO: fix this demeter violation\n other_major = sole_party.null_opposing_major\n other_major.award(1)\n @parties << other_major\n\n # one seat to third party\n # TODO: fix this demeter violation\n third_party = sole_party.null_coalition_minor\n third_party.award(1)\n @parties << third_party\n end",
"def revealed? ; false ; end",
"def make_hungry\n if @hungry\n @hungry = false\n else\n @hungry = true\n end\n end",
"def double_check\n if any_damage?\n @used = true\n @missed = false\n @evaded = false\n end\n end",
"def bringToLife\n @dead = false\n end",
"def leeway; end",
"def leeway; end",
"def borked?; @borked; end",
"def inherit_to_next_generation( next_generation )\r\n if msg.sender == @corrupt_elite\r\n @corrupt_elite = next_generation\r\n end\r\n end",
"def recover!\n @session.chanserv.recover(self.name)\n end",
"def can_use_ill?\n !virginia_borrower?\n end",
"def unknow\r\n return false unless unknow?\r\n @unknow.shift\r\n end",
"def inherit_to_next_generation( next_generation )\r\n if msg.sender == @corrupt_elite\r\n @corrupt_elite = @next_generation\r\n end\r\n end",
"def lost_brain\n ZombieMailer.lost_brain\n end",
"def log_denials\n @log_denials = true\n end",
"def defeat\n @losses += 1\n end",
"def after_save\n begin\n # https://redmine.corp.halomonitor.com/issues/3215\n #\n unless user.blank?\n # \n # Wed Feb 9 23:26:29 IST 2011, ramonrails\n # * this is the panic 'timestamp'\n # * we do not want any difference at all between timestamp in panic & user intake\n # \n # Thu Feb 10 23:17:52 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4180\n # * tiemstamp may really not be the recent one. We need Time.now\n _time_now = Time.now\n #\n # buffer for last panic row related to this user\n user.update_attribute( :last_panic_id, id) # no validations\n # * this is only for cucumber purpose\n if user.has_caregivers.any?(&:raises_exception?)\n raise \"Custom exception for BDD tests only\" # WARNING: this will not send emails until exception handling is added here\n end\n #\n # \n # \"Ready to Bill\" state if panic is\n # * after \"Desired Installation Date\"\n # * senior is member of safety care, but in test mode (partial test mode)\n # * only apply \"ready to bill\" state when current state is any of\n # * Ready to Install or Install Overdue\n # * \"Installed\" means, panic button was ok. user was \"Bill\"ed by human action\n _allowed_states = [User::STATUS[:install_pending], User::STATUS[:overdue]]\n if !user.desired_installation_date.blank? && (_time_now > user.desired_installation_date) && _allowed_states.include?( user.status.to_s)\n # \n # Fri Dec 17 21:01:27 IST 2010, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/3891\n if user.order_placed_online?\n # transition the user from \"Ready to Install\" => \"Ready to Bill\"\n # * We need \"bill\" state when order was placed online\n if user.subscription_successful?\n # * already \"billed\". we can simply go to \"Installed\" state\n user.update_attribute( :status, User::STATUS[:installed]) # \"Installed\"\n else\n user.update_attribute( :status, User::STATUS[:bill_pending]) # \"Ready to bill\". no validations\n end\n else\n # * just mark the user \"Installed\", when created directly from user intake\n user.update_attribute( :status, User::STATUS[:installed]) # \"Installed\"\n end\n # # \n # # Tue Nov 23 00:48:30 IST 2010, ramonrails\n # # * Pro rata is charged from the date we received panic button after \n # user.user_intakes.first.update_attribute( :panic_received_at, _time_now) unless user.user_intakes.blank?\n #\n # add triage_audit_log with a message\n _message = \"Automatically transitioned from 'Ready to Insall' to 'Ready to Bill' state at 'Panic button'\"\n\n # \n # Wed Dec 1 03:36:39 IST 2010, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/3786\n # * if subscription was already charged, mark user \"installed\"\n elsif (user.status.to_s == User::STATUS[:bill_pending]) && user.subscription_successful?\n user.update_attribute( :status, User::STATUS[:installed]) # \"Installed\"\n # # \n # # Tue Nov 23 00:48:30 IST 2010, ramonrails\n # # * Pro rata is charged from the date we received panic button after \n # user.user_intakes.first.update_attribute( :panic_received_at, _time_now) unless user.user_intakes.blank?\n #\n # add triage_audit_log with a message\n _message = \"Automatically transitioned from any existing state to 'Installed' state at 'Panic button' because subscription started before panic event.\"\n end\n # \n # Tue Nov 23 00:48:30 IST 2010, ramonrails\n # * Pro rata is charged from the date we received panic button after \n # Fri Dec 17 21:03:40 IST 2010, ramonrails\n # * This is common method call for \"if\" conditions above\n unless user.user_intakes.blank?\n _intake = user.user_intakes.first\n # \n # Fri Feb 11 00:48:03 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4181\n # * we need panic_received_at and installed_at to reflect the actual timestamp\n # * we cannot however switch the status to \"Installed\" as we want a concurrent \"Ready to Bill\" status\n # if panic < desired \n # panic_received_at is not updated and stays blank\n # elsif (panic > desired or desired.blank?)\n if _intake.installation_datetime.blank? || ( _time_now > _intake.installation_datetime )\n # only the first panic updates panic_received_at, ignore subsequent panics\n if _intake.panic_received_at.blank?\n _intake.update_attribute( :panic_received_at, _time_now)\n # send \"<halouser> installed\" email\" \n user.notify_about_installation\n # \n # update User.installed_at\n # Tue May 24 23:08:25 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4486\n # * Installed at should not be updated when panic button is sent before \"Ready for Approval\" state\n # * status.blank? means 'Not Submitted'\n user.update_attribute( :installed_at, _time_now) unless user.status.blank?\n # \n # make all caregivers active\n # Fri Feb 4 01:06:31 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4147\n # all caregivers are active now\n user.has_caregivers.each { |e| e.set_active_for( user, true) }\n # Installed timestamp in the \"Status\" column of Single Row User Intake\n # * updated in _user_intake_row.html.erb\n #\n # Completely disable test mode (User.test_mode = false)\n # \n # Fri Feb 4 22:31:15 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4152\n # * make user out of test mode here\n user.test_mode = false\n user.send( :update_without_callbacks)\n end\n end\n # # \n # # Fri Jan 28 02:15:27 IST 2011, ramonrails\n # # * https://redmine.corp.halomonitor.com/issues/4111#note-7\n # # * update the Panic.after_save, only store the first panic after installation_datetime, not every subsequent panic\n # if _intake.installation_datetime.blank?\n # # Installation date time blank?\n # ## First panic stored\n # ## Subsequent panics do not over-write the first stored one\n # _intake.update_attribute( :panic_received_at, _time_now) if _intake.panic_received_at.blank?\n # \n # elsif _intake.panic_received_at.blank? || (_intake.panic_received_at < _intake.installation_datetime)\n # # Installation date time given?\n # ## First panic after the timestamp, is stored. Overwriting any existing one that might have existed before the timestamp\n # ## Subsequent panics do not overwrite the existing stored one\n # _intake.update_attribute( :panic_received_at, _time_now)\n # end\n end\n\n #\n # add to triage audit log with a message\n if defined?( _message) && !_message.blank?\n #\n # add a row to triage audit log\n # cyclic dependency is not created. update_withut_callbacks is used in triage_audit_log\n attributes = {\n :user => user,\n :is_dismissed => user.last_triage_status,\n :status => user.status,\n :created_by => user.id,\n :updated_by => user.id,\n :description => _message\n }\n TriageAuditLog.create( attributes)\n end\n\n # Wed Nov 3 23:33:00 IST 2010, ramonrails \n # Old logic: \"Installed\" state can only be achieved by manual human action by clicking \"Bill\" in user intake\n # shifted now to user_intake.rb\n # # \n # # Ready for Install > Installed (green) is automatically transitioned\n # # Check for panic button test (must occur after the install date)\n # auto_install = ((user.status == User::STATUS[:install_pending]) && (_time_now > user.desired_installation_date))\n # if auto_install\n # user.status = User::STATUS[:installed]\n # #\n # # explicitly send email to group admins, halouser, caregivers. tables are saved without callbacks\n # [ user,\n # user.user_intakes.collect(&:caregivers),\n # user.user_intakes.collect(&:group).flatten.uniq.collect(&:admins)\n # ].flatten.uniq.each do |_user|\n # UserMailer.deliver_user_installation_alert( _user)\n # end\n # end\n #\n # Wed Nov 3 23:34:26 IST 2010, ramonrails \n # used update_attribute with validation skipping instead\n # user.send(:update_without_callbacks) # quick fix to https://redmine.corp.halomonitor.com/issues/3067\n # \n # Wed Nov 3 23:37:05 IST 2010, ramonrails \n # user is already a member when partial test mode was activated\n # user.is_halouser_of( Group.safety_care!) # user should also be opted in to call center\n end\n #\n # ramonrails: Thu Oct 14 02:05:21 IST 2010\n # return TRUE to continue executing further callbacks, if any\n true\n rescue Exception => e\n # \n # Wed Feb 9 23:16:17 IST 2011, ramonrails\n # * at least send an email about this error\n CriticalMailer.deliver_monitoring_failure( \"Technical exception #{e}\", self)\n true # no matter what, execute critical_device_event_observer.after_save\n end\n end",
"def loser?\n @lives == 0\n end",
"def seal!\n @mutex.synchronize do\n @sealed = true\n end\n materialize!\n end",
"def mermithization_unstrictured_hersed()\n technonomy(wrangler)\n sock_reassociate_supratemporal(jacket_gloomingly, metrometer, urtica_siegecraft)\n end",
"def haveStolen\n @canISteal = false\n\n end",
"def looses_life\n @lives -= 1\n end",
"def villain_lost(villain)\n if villain.hp <= 0\n villain.update(insane_asylum: true)\n end\n end",
"def run_warned; end",
"def announce_loss\n puts 'You lost, better luck next time!'\n end",
"def refill_annual\n leave_times.find_by(leave_type: 'annual').refill\n end",
"def eat\n @hungry = false\n end",
"def eat\n @hungry = false\n end",
"def eat\n @hungry = false\n end",
"def wrong \n @lives -= 1\n end",
"def ensure_account_is_not_pending_recovery\n self.match.is_not_pending_recovery!\n end",
"def loose_fish_when_bear_takes_it()\n @bear.add_to_stomach(@fish1)\n @river.loose_fish(@fish1)\n assert_equal(0,@river.fish_count())\n end",
"def dead?; end",
"def remaining; end",
"def in_law; end",
"def abandon!\n @union.finished\n @name = @original_name\n @keeper = nil\n @logger.debug(\"Abandoned by my keeper! Resuming my diminished life as #{@name}.\")\n end",
"def acked?; all_status?(:ack); end",
"def initialize\n @hungry = true\n end",
"def cause_mayhem(person)\n\t\tif person.caffeine_level > 0\n\t\t\tperson.caffeine_level = 0\n\t\t\tputs \"#{person.name} has had his caffeine level drained to zero! Bummer.\"\n\t\telse\n\t\t\tputs \"#{person.name} already has less than zero caffeine!\"\n\t\tend\n\tend",
"def lives_lost\n @lives -= 1\n pp \"INCORRECT -- YOU HAVE #{@lives} LIVES LEFT\"\n end",
"def already_reported; end",
"def already_reported; end",
"def resolve!(person, reason)\n if person_can_respond?(person) && response_for(person) == false\n self.class.transaction do\n BountyClaimEvent::BackerDisputeResolved.create!(\n bounty_claim: self,\n person: person,\n description: reason\n )\n BountyClaimResponse.find_or_create_by_claim_and_person(self, person, true, reason) and reload\n end\n end\n end",
"def pre_restore_warning\n end",
"def life_lost\n # if we are attacking ourselves, don't give our life back (otherwise it will never end)\n unless current_user == current_user.previous.player\n # Render the status message and push it to all clients\n message = render_to_string :partial => 'messages/gained_a_life', \n :locals => {:user_1 => current_user.previous.player, :user_2 => current_user}\n send_status_message(message) \n \n # Attacker gains the life that their victim lost\n attacker = current_user.previous.player\n life_gained(attacker)\n end\n ensure\n render :nothing => true\n end",
"def factory_reset_blocked\n return @factory_reset_blocked\n end",
"def member_discovered; end",
"def lost? # ruby style/convention says methods that return booleans should end w/ \"?\", so can't just use attr_reader/attr_writer/attr_accessor\n @lost\n end",
"def recoverable?()\n return false\n end",
"def celebration; end",
"def change!\n @alive = !@alive\n end",
"def post_restore_warning\n end",
"def lent_out?\n if @@on_loan.include?(self) == true\n true\n else\n false\n end\n end",
"def uncovered\n return true\n end",
"def lose_life()\r\n @life -= 1\r\n end",
"def lose_life\n @life -= 1\n end",
"def lent_out?\n @@on_loan.include?(self)\n end",
"def celebrate_birthday\n\t\t@age += 1\n\t\tabout(true)\n\tend",
"def link_dead!; @dead = true end",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def after_redeem() end",
"def ridicule_faultfully_prerevision()\n end",
"def loser\n losing_players\n end",
"def dead\n end",
"def become_angry\n update(anger_level: 0, angry_since: Time.now)\n true\n end",
"def lent_out?\n return @@on_loan.include?(self)\n end",
"def return_to_library\n if lent_out? == true\n false\n else\n @@on_loan.delete(self)\n @@on_shelf << self\n @due_date = nil\n true\n end\n\n end",
"def miss_reason; end",
"def lose_life\n @lives -= 1\n end",
"def lose_life\n @lives -= 1\n end",
"def lose_life\n @lives -= 1\n end",
"def lose_life\n @lives -= 1\n end",
"def naive_for_me_0\n self.class.beat their_throw_after_most_recent_max_match\n end",
"def do_hold(last_check)\n if last_check.off?\n # If the status report says the Equipment is offline, try\n # resending the Task. If that doesn't work, fail and punt to the launcher.\n hold_failure! unless send_to_rhizome\n end\n end",
"def defense_use\n use = []\n @type.not_effected_by.each {|type| use << type if !use.include?(type)}\n @type.strong_against.each {|type| use << type if !use.include?(type)}\n \n puts \"\"\n puts \"#{@type.name.upcase} POKEMON ARE RESISTANT TO:\"\n use.each_with_index {|other_type, index| puts \"#{index+1}. #{other_type.name}\"}\n end",
"def nip_it_in_the_bud\n while has_bud?(@sequence) do\n @sequence.shift\n @sequence.each { |entry| entry.level -= 1 }\n end\n end",
"def handlePossibleAccident\n return false unless rand < @driver.accident\n\n @lastSpeed = @nextSpeed = Velocity::Zero\n @fixTime = World.time + RepairTime\n @bodyEnd = @bodyStart - @length\n @totalAccidents += 1\n\n true\n end",
"def is_sunk? \n if @life > 0\n return false\n else\n return true\n end\n end",
"def reduce_life\n if @life > 0 \n @life = @life - (1 * @starvation_rate)\n else\n @status = :dead\n end\n end",
"def unlearned_flagged_in_curr\n log \"Finding unlearned, flagged messages\"\n\n @unlearned_flagged = @imap.search [\n 'FLAGGED',\n 'NOT', 'KEYWORD', LEARN_KEYWORD\n ]\n\n update_db @unlearned_flagged, :add_tasty\n\n @unlearned_flagged.length\n end",
"def missed?; end",
"def pay_interest!(entity)\n owed = interest_owed(entity)\n # This is here so that the log message does not get duplicated.\n if corp_has_new_zealand?(entity) && entity.loans.size.positive?\n @log << \"#{entity.name}'s token in Nieuw Zeeland covers one loan's worth of interest\"\n end\n return super unless owed.negative?\n\n # Negative interest -> corporation has New Zealand\n @log << \"#{entity.name} gets $20 for having a token in Nieuw Zeeland and no loans\"\n entity.spend(owed, bank, check_cash: false, check_positive: false)\n nil\n end",
"def resolve(correct)\n self.resolved = true\n self.correct = correct\n\n if correct\n # Each correct holding is worth 100 lightbulbs (it is now 100% likely to be correct)\n holdings.each { |h| h.user.increment! 'balance', (h.quantity * 100) }\n end\n holdings.each { |h| h.delete } # TODO: Should we save these for data mining?\n\n save\n end",
"def uncertain?\r\n @@maybes\r\n end",
"def lent_out?\n if @@on_loan.include?(self)\n return true\n else\n return false\n end\n end",
"def lose!\n\t\t@bet = 0\n\tend",
"def block_if_on_hold\n raise \"Account is currently on hold. Messaging is disabled.\" if current_account.on_hold?\n end",
"def internship_passed; end",
"def lent_out?\n if @@on_loan.include?(self)\n return true\n else\n return false\n end\nend",
"def wrong\n self.lives -= 1\n end",
"def resurrect!\n alive! if resurrectable?\n end",
"def claim_reward_balance!(permlink); claim_reward_balance(permlink).broadcast!(true); end",
"def claim_reward_balance!(permlink); claim_reward_balance(permlink).broadcast!(true); end",
"def re_up_ready\n rdy(@max_in_flight)\n # assume these messages are coming our way. yes, this might not be the\n # case, but it's much easier to manage our RDY state with the server if\n # we treat things this way.\n @presumed_in_flight = @max_in_flight\n end",
"def add_bobchild_reationships(bobchildren_ids)\n bobchildren_ids.each do |child_id|\n u = User.find(child_id)\n if u.has_bobfather?\n # This is A CONFIRMATION of the bobfatherhood \n if ( (u.bobfather == self) and \n (u.bobfather_rel[:state] == PROPOSED_BY_CHILD) )\n u.bobfather_rel[:state] = CONFIRMED\n end\n # if u.bobfather != self DO NOTHING b/c da child has ownship of \n # WHO IS MY BOBFATHER \n else\n u.bobfather = self \n # do state machine\n u.bobfather_rel[:state] = PROPOSED_BY_FATHER\n end\n u.save\n end\n end"
] |
[
"0.61238754",
"0.586809",
"0.5839576",
"0.57865703",
"0.57289475",
"0.56945395",
"0.56651825",
"0.56275135",
"0.56142366",
"0.5609703",
"0.5602296",
"0.5602296",
"0.5572648",
"0.555517",
"0.55207175",
"0.55205977",
"0.55090857",
"0.54991937",
"0.5486099",
"0.5473138",
"0.54626596",
"0.54624444",
"0.544042",
"0.5437252",
"0.54255366",
"0.5415359",
"0.54058665",
"0.5405839",
"0.5394232",
"0.5383022",
"0.53774756",
"0.5370466",
"0.5370466",
"0.5370466",
"0.5342115",
"0.53374845",
"0.53356814",
"0.53338045",
"0.53205574",
"0.531778",
"0.53079545",
"0.5307823",
"0.53049254",
"0.5293938",
"0.5293214",
"0.5290169",
"0.5290169",
"0.5287179",
"0.52788705",
"0.52703303",
"0.5259373",
"0.5248275",
"0.52313703",
"0.52304184",
"0.5216176",
"0.52140844",
"0.52137965",
"0.52079356",
"0.52049404",
"0.52008265",
"0.51883554",
"0.5183675",
"0.5177004",
"0.5170167",
"0.5169683",
"0.5166299",
"0.5164167",
"0.5159949",
"0.515455",
"0.51463765",
"0.5143612",
"0.51412815",
"0.513305",
"0.51161575",
"0.51161575",
"0.51161575",
"0.51161575",
"0.510885",
"0.5092253",
"0.5087343",
"0.5082217",
"0.5075398",
"0.5074383",
"0.50678766",
"0.5064852",
"0.50648177",
"0.5062785",
"0.50612366",
"0.50493246",
"0.5045723",
"0.50426126",
"0.5038702",
"0.503106",
"0.5015429",
"0.5015406",
"0.5011788",
"0.5010997",
"0.5010997",
"0.5006499",
"0.5002627"
] |
0.6668867
|
0
|
Get's the `expiration_date` as a Time object
|
def expiration_time
Time.at(0, expiration_date, :millisecond)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def expiration_date_time\n return @expiration_date_time\n end",
"def expiration_date_time\n return @expiration_date_time\n end",
"def expiration_date_time\n return @expiration_date_time\n end",
"def expiration_date_time\n return @expiration_date_time\n end",
"def expiration_date_time\n return @expiration_date_time\n end",
"def expiration_date_time\n return @expiration_date_time\n end",
"def expiration_date\n read_datetime_from_string('expiration_date')\n end",
"def expiration_date\n hash[\"ExpirationDate\"]\n end",
"def expiration_date_time=(value)\n @expiration_date_time = value\n end",
"def expiration_date_time=(value)\n @expiration_date_time = value\n end",
"def expiration_date_time=(value)\n @expiration_date_time = value\n end",
"def expiration_date_time=(value)\n @expiration_date_time = value\n end",
"def expiration_date_time=(value)\n @expiration_date_time = value\n end",
"def expiration_date_time=(value)\n @expiration_date_time = value\n end",
"def expiration_date\n return unless Trebuchet.backend.respond_to?(:expiration_date)\n Trebuchet.backend.expiration_date(self.name)\n end",
"def expiration_date\n unless self['expiration_date']\n month_days = [nil,31,28,31,30,31,30,31,31,30,31,30,31]\n begin \n month_days[2] = 29 if Date.leap?(@year)\n self['expiration_date'] = Time.parse(\"#{@month}/#{month_days[@month]}/#{@year} 23:59:59\")\n rescue\n end\n end \n self['expiration_date']\n end",
"def token_expiration_time\n # Check that user has authenticated\n @local_auth_error = local_auth_error\n return Hash[@error => @local_auth_error] if @local_auth_error\n\n # Return valid date if in test mode\n if @test\n m = MockTimeSync.new\n return m.token_expiration_time\n end\n\n # Decode the token, then get the second dict (payload) from the\n # resulting string. The payload contains the expiration time.\n begin\n decoded_payload = Base64.decode64(@token.split('.')[1])\n rescue\n return Hash[@error => 'improperly encoded token']\n end\n\n # literal_eval the string representation of a dict to convert it to a\n # dict, then get the value at 'exp'. The value at 'exp' is epoch time\n # in ms\n exp_int = JSON.load(decoded_payload)['exp'] # not sure about this\n\n # Convert the epoch time from ms to s\n exp_int /= 1000\n\n # Convert and format the epoch time to ruby datetime.\n exp_datetime = Time.at(exp_int)\n\n exp_datetime\n end",
"def expiration_date\n \"#{expiration_month}/#{expiration_year}\"\n end",
"def fecha_expiration\n run_at = self.expiration_date\n end",
"def expiration_date\n end",
"def expire_time\n e_time = @token_manager.token_info[\"expiration\"]\n raise 'CloudTools::IAMAuth Unable to extract the retrieved expiration time.' if e_time.nil?\n raise \"CloudTools::IAMAuth Extracted expiry time #{e_time} is not an expected integer.\" unless e_time.kind_of?(Integer)\n\n e_time\n end",
"def getExpiration; @expires; end",
"def expiry_time\n response_hash[:hard_expiration_time]\n end",
"def expires_at\n Time.at(expiry_time_millis / 1000).utc.to_datetime\n end",
"def expiration\n return @expiration\n end",
"def expiration_date\n return nil unless success?\n @exdate ||= value_for_xpath('//domain:exDate') && Time.parse(value_for_xpath('//domain:exDate'))\n end",
"def expires_at\n @receipts.first.expires_date\n end",
"def expires_at\n read_attribute(:expires_at).try(:to_f)\n end",
"def expires_at\n exp = payload.exp\n return nil unless exp\n\n Time.zone.at(exp)\n end",
"def expires_at\n @receipts.last.expires_date\n end",
"def key_expiration_time(rnp_key)\n Time.at(key_creation_time(rnp_key) + key_validity_seconds(rnp_key))\n end",
"def expires\r\n object.expires.strftime(\"%Y-%m-%d\")\r\n end",
"def expiration_date\n \"#{expiration_month.to_s.rjust(2, '0')} / #{expiration_year}\"\n end",
"def end_time\n return @start_time + @seconds_to_expiry\n end",
"def expire_time\n Convert.timestamp_to_time @grpc.expire_time\n end",
"def expires_date\n read_datetime_from_string('expires_date')\n end",
"def expires_at\n get_expires_at\n end",
"def expiry_time\n ((Time.now.tv_sec + 31556926) * 1000).to_i\n end",
"def expires_at\n @attributes[:expires_at]\n end",
"def expires_at\n @attributes[:expires_at]\n end",
"def expires_at\n @attributes[:expires_at]\n end",
"def format_expiration\n if expiration\n expiration.strftime(\"%A, %B #{expiration.day.ordinalize} %Y\")\n else\n 'never'\n end\n end",
"def membership_expire_date\n memberships_manager.most_recent_membership_last_day(self)\n # payment_expire_date(THIS_PAYMENT_TYPE)\n end",
"def expiry_date\n ExpiryDate.new(@month, @year)\n end",
"def expires_at\n parse_date( super )\n rescue ArgumentError\n nil\n end",
"def expiration=(value)\n @expiration = value\n end",
"def expiration_time\n self.class.timestamp_from_grpc @grpc.expire_time\n end",
"def expires_at\n @expires_at\n end",
"def expire_time(key)\n @store[key].expires_at\n end",
"def expires_on\n case self.current_state\n when :active then (self.last_renewal_on.to_time + self.length_in_issues.months).to_date\n end\n end",
"def initialize(date)\n @expiration_date = date.strftime('%Y-%m-%dT00:00:00Z')\n end",
"def expiry_time_millis\n @subscription_purchase.expiry_time_millis\n end",
"def expiration\n @expiration ||= 60 * 60 * 24 * 30 # 30 days\n end",
"def expires_at\n raise \"Override and return the metric's expiration time\"\n end",
"def to_time\n t = ::Time.at utc_reference\n Time.new t.utc\n end",
"def expires_on\n self.expires_on = Date.strptime(expiration_date,'%m/%Y')+1.month\n end",
"def payment_expiry_time\n payment = self.payments.where(status: :failed).order(:paid_at).first\n unless payment.nil?\n return payment.paid_at + PAYMENT_EXPIRY_DAYS.days\n end\n nil\n end",
"def expiry\n @expiry\n end",
"def parse_expiration_date(gp)\n begin\n if gp[:expiration_time]\n if gp[:expiration_time] == ''\n gp[:expiration_time] = nil\n else\n gp[:expiration_time] = Date.strptime(gp[:expiration_time], \"%m/%d/%Y\")\n print gp[:expiration_time]\n end\n end\n return true\n rescue\n return false\n end\nend",
"def expires\n Time.parse(@options['expires']) if @options['expires']\n end",
"def cache_expiry_time\n Rails.configuration.x.accounts.cache_expiry || 10.minutes\n end",
"def new_expiration_score\n now + 3600\n end",
"def get_date()\n @time\n end",
"def terms_expiration\n return @terms_expiration\n end",
"def get_time\n Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n end",
"def expiry_date\n ActiveMerchant::Billing::CreditCard::ExpiryDate.new(month, year)\n end",
"def to_time\n value\n end",
"def expires_at\n if max_age\n created_at + max_age\n else\n expires\n end\n end",
"def set_expiration_date\n self.expiry_date = Date.today + 365.days\n end",
"def expiration_timestamp\n @lock_expire if @lock_expire && owner_ident == @locked_owner_id\n end",
"def expiration_date\n self.created_at + RunnersBikers::MATCH_DURATION\n end",
"def to_time\n self\n end",
"def expires\n @expires ||= Time.parse(@data['expires'])\n end",
"def request_expires_at\n Time.now - EXPIRATION_INTERVAL\n end",
"def completion_date_to_time\n if completion_date_type == \"completion_day\"\n return completion_date_value.to_i.days.ago\n elsif completion_date_type == \"completion_week\"\n return completion_date_value.to_i.weeks.ago\n elsif completion_date_type == \"completion_month\"\n return completion_date_value.to_i.months.ago\n elsif completion_date_type == \"completion_year\"\n return completion_date_value.to_i.years.ago\n elsif completion_date_type == \"completion_hour\"\n return completion_date_value.to_i.hours.ago\n end\n end",
"def exp_date_for_alma\n alma_date(DateTime.strptime(original_expiry_date, VSU_EXPIRY_DATE_FORMAT).strftime('%Y-%m-%d'))\n end",
"def reminder_date_time\n return @reminder_date_time\n end",
"def expiry(t)\n Time.now.to_i + t\n end",
"def expires_on\n expiry_date = nil\n dates = %x{echo \"#{self.certificate}\" | openssl x509 -noout -dates}\n dates.each_line do |date_line|\n logger.debug(\"DEBUG >> Date line: #{date_line}\")\n if date_line =~ /^notAfter=/\n expiry_date = date_line.gsub('notAfter=', '').to_time\n end\n end\n expiry_date\n end",
"def acquired_date_time\n return @acquired_date_time\n end",
"def expiry_time\n @slice_time * 26 # keep 26 slices around, but we only ever interrogate 24\n end",
"def expiration_date=(date)\n if date.is_a?(Date)\n @expiration_date = date\n else\n # do we have a month/year in here? will accept 01/12 or 1/1 etc\n # must have 1 or 2 digit then forward slash then 1 or 2 digits\n if date =~ /\\A\\d{2}\\/\\d{1,2}\\z/\n # some fun building a date out of that\n date_split = date.split('/')\n month, year = date_split[0].to_i, date_split[1].to_i\n if month.between?(1, 12)\n year > 30 ? year += 1900 : year += 2000\n # now make sure we have the last day of the month\n @expiration_date = Date.new(year, month, -1)\n end\n # create a date from month year\n else\n if date =~ /\\A\\d\\/\\d{1,2}\\z/\n # tut tut tut\n @expiration_date = date\n else\n # try and parse the date\n begin\n @expiration_date = Date.parse(date)\n rescue ArgumentError\n # no date for you!\n @expiration_date = date\n end\n end\n end\n end\n end",
"def to_time()\n #This is a stub, used for indexing\n end",
"def expires_in\n if expires_at\n expires_at - Time.now\n else\n nil\n end\n end",
"def expires_at\n expires_in && created_at + expires_in.seconds\n end",
"def revoke_time\n\t\t((created_at + Donation.revoke_time - Time.now) / 86400).ceil\n\tend",
"def seconds_until_expiration(now=Time.now)\n ((@ends_at - now).abs).round\n end",
"def expiry\n @expiry ||= 60 * 10\n end",
"def expiry\n @expiry ||= 60 * 10\n end",
"def certificate_expires_at\n attributes[:certificate_expires_at]\n end",
"def expiration\n unless @expiration\n conf = Grape::Jwt::Authentication.configuration\n return conf.rsa_public_key_expiration\n end\n @expiration\n end",
"def is_expiration_required\n return @is_expiration_required\n end",
"def internal_due_date_time\n return @internal_due_date_time\n end",
"def expires_at\n Time.now.utc + self[:expires_in_seconds].to_i\n end",
"def returned_date_time\n return @returned_date_time\n end",
"def expires_in\n if @expires_at.nil? || @issued_at.nil?\n nil\n else\n (@expires_at - @issued_at).to_i\n end\n end",
"def hours_until_expiration(now=Time.now)\n distance_in_hours = seconds_until_expiration(now)/SECONDS_IN_A_HOUR\n distance_in_hours.floor\n end",
"def to_time\n raise NotImplementedError\n end",
"def build_expiry(t_expiry)\n self.expiry = \"#{t_expiry.strftime('%Y-%m-%dT%H:%M:%S+08:00')}\"\n end",
"def to_time\n # Thread-safety: It is possible that the value of @time may be \n # calculated multiple times in concurrently executing threads. It is not \n # worth the overhead of locking to ensure that @time is only \n # calculated once.\n \n unless @time\n result = if @timestamp\n Time.at(@timestamp).utc\n else\n Time.utc(year, mon, mday, hour, min, sec, usec)\n end\n\n return result if frozen?\n @time = result\n end\n \n @time \n end"
] |
[
"0.81501484",
"0.81501484",
"0.81501484",
"0.81501484",
"0.81501484",
"0.81501484",
"0.7467819",
"0.74556446",
"0.72345227",
"0.72345227",
"0.72345227",
"0.72345227",
"0.72345227",
"0.72345227",
"0.72009885",
"0.7194464",
"0.7037336",
"0.70314133",
"0.6962809",
"0.6937511",
"0.6931158",
"0.67702585",
"0.67695147",
"0.6741538",
"0.6730042",
"0.66070414",
"0.6532716",
"0.6455414",
"0.6426041",
"0.6398007",
"0.63830376",
"0.63509774",
"0.63413924",
"0.6333892",
"0.6333526",
"0.6324256",
"0.63103956",
"0.6246674",
"0.6230235",
"0.6230235",
"0.6230235",
"0.62042934",
"0.61956674",
"0.6174039",
"0.61661726",
"0.6161866",
"0.6119994",
"0.6083845",
"0.607283",
"0.60683936",
"0.60539186",
"0.6048217",
"0.6031834",
"0.6020022",
"0.60199773",
"0.59779096",
"0.595789",
"0.59545803",
"0.59012884",
"0.58888435",
"0.5839612",
"0.5835902",
"0.5831593",
"0.58307415",
"0.58272946",
"0.58246744",
"0.58108926",
"0.58005685",
"0.57914114",
"0.57897794",
"0.578795",
"0.5767723",
"0.57505816",
"0.573678",
"0.5727323",
"0.5722541",
"0.570988",
"0.570585",
"0.5684587",
"0.56830436",
"0.568149",
"0.56735843",
"0.56603634",
"0.5642375",
"0.5636981",
"0.5629181",
"0.56208205",
"0.5607502",
"0.5607502",
"0.5602399",
"0.5594927",
"0.5593181",
"0.5588993",
"0.55882335",
"0.55853784",
"0.557926",
"0.5578819",
"0.5570249",
"0.5552769",
"0.55400366"
] |
0.8125416
|
6
|
create a before hook that applies the received validator class to input. will abort request with validation error if invalid
|
def validate_input(validator_klass, options = {})
unless validator_klass.include?(ActiveModel::Validations)
raise ArgumentError, "validator class should be an ActiveModel::Validator"
end
before lambda { |_rack_env, env|
validator = validator_klass.new(env[:input])
validator.valid? || twirp_validation_error(validator.errors)
}, **options, name: validator_klass.to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pre_validation\n\n end",
"def _before_validation\n end",
"def pre_validation\n\n\n end",
"def valid_before; end",
"def validate(validator, *args); validation_chain.validate(validator, *args); end",
"def before_validation_callback\n end",
"def validate\n errors.clear\n self.class.validator.invoke self\n end",
"def run_validations!\n run_callbacks(:validation) do\n super\n end\n end",
"def validator; end",
"def validate\n validator_class.new(self).validate\n end",
"def validated_before(method, *args)\n __method = :\"#{method}_without_validations\"\n alias_method __method, method\n \n without = args.extract_options![:without]\n if [*without].include? :exception\n define_method method do |*params|\n if valid? then send! __method else false end\n end\n else\n define_method method do |*params|\n if valid? then send! __method else raise errors.to_exception end\n end\n end\n end",
"def eval_custom_validator_block(state, original_state = nil)\n yield(state, original_state)\n invalid!(state) if state.errors.present?\n state\n end",
"def validate_request(call)\n call.validate_request\n end",
"def with_validator(&block)\n @validators << block\n self\n end",
"def validate(instance)\n validator.invoke instance\n end",
"def validate_me(validator)\n validator.validate self, checks\n end",
"def validate\n validations = self.class.meta_eval { @validations }\n\n validations.each do |v|\n raise \"#{self.class}.#{v[:name]} #{v[:options][:message]}\" unless\n v[:proc].call(send(v[:name]))\n end\n\n self\n end",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def validate\n super \n end",
"def perform\n\n r = validate\n return r unless r.success?\n\n process_hook\n\n end",
"def validator=(_); end",
"def validate\n super\n end",
"def validate\n self.class.validations.each do |(method, args, opts)|\n send(method, *args) if !opts[:if] || instance_exec(&opts[:if])\n end\n end",
"def validate!\n super()\n self\n end",
"def validate\n self._errors = {}\n self.run_hook :validate\n not self.errors?\n end",
"def validate(&block)\n shrine_class.opts[:validate] = block\n end",
"def run_validation(vmode)\n validate(vmode)\n self\n end",
"def validate!\n # pass\n end",
"def validate\n errors.clear\n instance_exec(&validate_block) if validate_block && get\n end",
"def after_validate\n end",
"def validate\n raise NoMethodError, \"must define method 'validate'\"\n end",
"def validated?; end",
"def validate(*args, &block)\n end",
"def validation; end",
"def validation; end",
"def beforeValidation\n\n puts \"-----------beforeValidation------------\"\n\n #selfTest(self)\n\n puts \"-----------beforeValidation------------\"\n\n\n \n end",
"def validate\n fail 'sub class to implement'\n end",
"def should_validate\n validation_trigger\n end",
"def set_automated_validation\n (self.methods - Object.methods).each do |method|\n params_index = method(method).parameters.map{|ar| ar[1]}.index(:params)\n body_index = method(method).parameters.map{|ar| ar[1]}.index(:body)\n\n define_singleton_method(method) do |*args, &block|\n validate Docker::API::InvalidParameter, Docker::API::VALID_PARAMS[\"#{self.class.name}\"][\"#{method}\"], (args[params_index] || {}) if params_index\n validate Docker::API::InvalidRequestBody, Docker::API::VALID_BODY[\"#{self.class.name}\"][\"#{method}\"], (args[body_index] || {}) if body_index\n super(*args,&block)\n end\n end\n end",
"def valid_before=(_arg0); end",
"def perform\n validate_data_from_requests\n end",
"def extend_ar_validations_valid_method(subclass)\n Valle::Manager.add_validators(subclass)\n end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate!\n self.class.validators.each do |validator|\n validator.validate!(self)\n end\n nil\n end",
"def validate\n\n end",
"def validate(spec)\n raise \"undefined method -- `validate'\"\n end",
"def validated; end",
"def validate\n # add errors if not validate\n end",
"def validate!\n validator.validate(data: data, schema: schema, logger: validation_logger)\n end",
"def handle_request( request, &block )\n\t\tself.log.debug \"[:parameters] Wrapping request with parameter validation.\"\n\n\t\tvalidator = self.class.paramvalidator.dup\n\t\tvalidator.validate( request.params )\n\t\trequest.params = validator\n\n\t\tsuper\n\tend",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def validate(&block)\n if block\n @validate = block\n else\n @validate\n end\n end",
"def validate_block\n shrine_class.opts[:validate]\n end",
"def validate\n begin\n validatable_rules.map{ |k, v| self.send(\"validate_\" + k.to_s) }\n rescue Errors::ValidationError => e\n raise decorate_error e\n end\n end",
"def validate(input)\n result = ctx[:contract].new.call(input[:params])\n if result.errors.count.positive?\n Failure(error: ErrorService.bad_request_fail(result.errors.to_h))\n else\n ctx[:params] = result.to_h\n Success(input.merge(params: result.to_h))\n end\n end",
"def override_validator(name, &block)\n validator_strategies[name] = block\n end",
"def subclass_validations ; true ; end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def initialize(params = {})\n super\n self.is_valid = true\n end",
"def validate(param)\n validator.call(param)\n end",
"def validate(param)\n validator.call(param)\n end",
"def extended_validator\n notify_observers(:validate_application)\n end",
"def validate\n @condition = nil\n @error = \"No validation implemented for #{self.class}#validate\"\n end",
"def validate\n end",
"def defer_validation(&block)\n #p [:defer_validation, self.validation_on, @this]\n old_validation = self.validation_on\n self.validation_on = false\n v = nil\n begin\n v = @this.instance_eval(&block)\n ensure\n self.validation_on = old_validation\n end\n @this.validate!(false)\n v\n end",
"def validate\n \n \n end",
"def run_validations!\n super\n include_typecasting_errors\n errors.empty?\n end",
"def validate!\n MiddlewareValidator.new(middleware).validated_provides!\n end",
"def run_validations\n run_callbacks :validation do\n failed_validators.clear\n validation_chain.run(self)\n @validated = true\n end\n end",
"def perform_validation\n raise NotImplementedError\n end",
"def validate\n self.send(\"validate_#{type}\".to_sym)\n end",
"def validate\n raise \"Can only validate request messages\" unless type == :request\n\n raise(NotTargettedAtUs, \"Received message is not targetted to us\") unless PluginManager[\"security_plugin\"].validate_filter?(payload[:filter])\n end",
"def validate_params\n @calls << [:validate_params]\n end",
"def prepare_invoke!\n return if @prepared\n\n super\n\n # Force the spinner to be registered etc.\n spinner\n\n # Prepare child validators\n validator_instances.each(&:prepare_invoke!)\n nil\n end",
"def validate(&block)\n validator = block\n\n unless value.nil?\n error = validator.call(value)\n raise ValidationError, error if error\n end\n\n @validator = block\n end",
"def validate\r\n\r\n end",
"def validator(&block)\n @validator = DSL::Validator.new\n @validator.instance_exec(&block)\n end",
"def validate_and_sanitize\n validate\n end",
"def validate!\n raise InvalidIntrospectorError, \"Introspector is not valid.\" unless valid?\n end",
"def validate!\n validate_redis\n validate_workers\n validate_options\n end",
"def extra_validations\n success\n end",
"def validator(*states)\n @validator ||= if superclass.respond_to? :validator\n superclass.validator.clone\n\n else\n validator_klass =\n if states[0].is_a? Class and states[0] <= NotNaughty::Validator\n states.shift\n else\n NotNaughty::Validator\n end\n \n validator_klass.new(*states)\n end\n end",
"def chain(params = {}, &block); validation_chain.chain(params, &block); end",
"def validate_and_sanitize\n r = super\n return r unless r.success?\n\n success\n end",
"def validate\r\n validate! rescue false\r\n end",
"def validate\n validate_vendor\n end",
"def validate_with(&block)\n validators << block\n end",
"def apply_validations!\n if not_nullable? && (! skip_not_nullable_validation_due_to_type?)\n flex_column_class.validates field_name, :presence => true\n end\n\n if options.has_key?(:enum)\n values = options[:enum]\n unless values.kind_of?(Array)\n raise ArgumentError, \"Must specify an Array of possible values, not: #{options[:enum].inspect}\"\n end\n\n flex_column_class.validates field_name, :inclusion => { :in => values }\n end\n\n if options.has_key?(:limit)\n limit = options[:limit]\n raise ArgumentError, \"Limit must be > 0, not: #{limit.inspect}\" unless limit.kind_of?(Integer) && limit > 0\n\n flex_column_class.validates field_name, :length => { :maximum => limit }\n end\n end",
"def validate\n @validated = validated_statically? unless validated?\n @validated = validated_dynamically? unless validated?\n @validated\n end",
"def validate_event=(_arg0); end",
"def validator(arg = nil)\n set_or_return(\n :validator,\n arg,\n kind_of: [TrueClass, FalseClass]\n )\n end"
] |
[
"0.66816926",
"0.66270715",
"0.6571829",
"0.6496052",
"0.6409451",
"0.63899034",
"0.6354531",
"0.6337416",
"0.6267571",
"0.62459946",
"0.6219813",
"0.60915405",
"0.60897195",
"0.6066178",
"0.6064134",
"0.6025313",
"0.6014526",
"0.5984107",
"0.5984107",
"0.5984107",
"0.59674305",
"0.59665024",
"0.596352",
"0.5961825",
"0.59617174",
"0.5953025",
"0.5931202",
"0.59047043",
"0.58969027",
"0.58869624",
"0.5869822",
"0.5847938",
"0.58461165",
"0.5838673",
"0.583213",
"0.58310467",
"0.58310467",
"0.5813816",
"0.5802734",
"0.5795474",
"0.57885563",
"0.5782211",
"0.5766591",
"0.57599354",
"0.5754543",
"0.5754543",
"0.5754543",
"0.5754543",
"0.5747434",
"0.57431966",
"0.573931",
"0.5716491",
"0.57164454",
"0.57143426",
"0.5711522",
"0.57023317",
"0.57023317",
"0.57023317",
"0.5695069",
"0.5684429",
"0.5675577",
"0.56723106",
"0.5672199",
"0.5670627",
"0.5665527",
"0.5665527",
"0.5665527",
"0.56640273",
"0.5658528",
"0.5658528",
"0.5655341",
"0.5641916",
"0.5641672",
"0.56250024",
"0.5614036",
"0.56033385",
"0.5598256",
"0.5597956",
"0.5587016",
"0.558156",
"0.5578865",
"0.5568845",
"0.5562779",
"0.5552763",
"0.5542524",
"0.5539845",
"0.55252445",
"0.5521808",
"0.5521109",
"0.55065686",
"0.550523",
"0.54895765",
"0.5489349",
"0.54850686",
"0.54793537",
"0.54749537",
"0.5471498",
"0.5470958",
"0.546077",
"0.54584676"
] |
0.7508325
|
0
|
used when constructing service to apply handler's configured service hooks
|
def configure_hooks(hook_type, service)
unless VALID_HOOKS.include?(hook_type)
raise ArgumentError, "unknown twirp hook type received: #{hook_type}"
end
existing_hooks = instance_variable_get("@#{hook_type}_hooks")
return if existing_hooks.nil?
existing_hooks.values.each do |hook|
service.send(hook_type, &hook)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def around_hooks; end",
"def initialize\n RESTRack::CONFIG[:SERVICE_NAME] = self.class.to_s.split('::')[0].to_sym\n @request_hook = RESTRack::Hooks.new if RESTRack.const_defined?(:Hooks)\n end",
"def setup_handler\n end",
"def InitializeHooks\n end",
"def initialize (service_name, application_context)\n super\n end",
"def pre_hook_send(handler); end",
"def service; end",
"def hooks\n # ???\n end",
"def initialize_service_for_create\n @service = service_class.new(hashified_params, service_options)\n end",
"def inject(services_container); end",
"def init_service (service_name, service_class)\n\n if service_name\n #\n # if there is a service previously registered under the same name,\n # make sure to stop before it gets 'overriden' in the\n # application context\n\n s = @application_context[service_name]\n s.stop if s.respond_to?(:stop)\n end\n\n s = service_class.new(service_name, @application_context)\n\n unless service_name\n #\n # making sure to register the service. service#new doesn't\n # register when there is no service_name\n\n s.service_name = \"#{service_class.name}::#{s.object_id}\"\n @application_context[s.service_name.to_s] = s\n end\n\n s\n end",
"def create\n super(@@service)\n end",
"def method_missing(method_sym, *arguments, &block)\n if self.class.service_class(method_sym)\n # load service from cache if available\n service = instance_variable_get(\"@#{method_sym}\")\n return service if service\n\n service = self.class.service(method_sym, @api_client)\n service.service_manager = self\n instance_variable_set(\"@#{method_sym}\", service)\n else\n super\n end\n end",
"def initialize\n @ewallet_services = {}\n build_service_map\n end",
"def initialize(service)\n @service = service\n end",
"def configure(service_name, configurations); end",
"def process_service_config\n @unbound_config = UnboundConfig.new(options[:service])\n end",
"def make_hooks(*args)\r\n make :hook, *args\r\n end",
"def on_db_service(context, service)\n\tend",
"def hook\n self.class.hook\n end",
"def initialize\n @services = {}\n end",
"def across_service_state\n super\n end",
"def enabled_ad_hoc_hooks(hook_context); end",
"def hook_class_name; end",
"def initialize()\n\t\tsuper\n\t\tself.servicekinds = []\n\t\tself.status = ''\n\t\tsetup_known_services\n\t\tload_rc\n\t\tself\n\tend",
"def scheme_handlers=(_arg0); end",
"def setup_handler\n\t\t# Start the HTTP server service on this host/port\n\t\tself.service = Rex::ServiceManager.start(Rex::Proto::Http::Server,\n\t\t\tdatastore['PXPORT'].to_i, datastore['PXHOST'])\n\n\t\t# Add the new resource\n\t\tservice.add_resource(datastore['PXURI'],\n\t\t\t'Proc' => Proc.new { |cli, req|\n\t\t\t\ton_request(cli, req)\n\t\t\t},\n\t\t\t'VirtualDirectory' => true)\n\n\t\tdlog(\"PassiveX listener started on http://#{datastore['PXHOST']}:#{datastore['PXPORT']}#{datastore['PXURI']}\", 'core', LEV_2)\n\n\t\tprint_status(\"PassiveX listener started.\")\n\tend",
"def service; raise NotImplementedError; end",
"def services\n\n end",
"def service_request(service); end",
"def handlers=(_arg0); end",
"def service_object\n EntitiesActionDispatcher.new(consul_scope)\n end",
"def keyword_based_service?; end",
"def on_db_service(service)\n\tend",
"def all_hook_configs; end",
"def start_hook name, attrs = []\n # this should be implemented in sub-classes\n end",
"def hook_name; end",
"def initialize (service_name, application_context)\n\n super()\n\n service_init service_name, application_context\n\n @paused_instances = {}\n\n @observers = {}\n\n @stopped = false\n\n engine_environment_id\n # makes sure it's called now\n end",
"def bind_method(service_ref, controller, method_name, desc)\n method_key = method_name.to_s.underscore.to_sym\n controller_name = controller.name\n service_ref.class_eval do\n if desc.request_response?\n define_method(method_key) do |message, active_call|\n Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|\n c = fresh_controller.new(\n method_key: method_key,\n service: service_ref,\n message: message,\n active_call: active_call,\n rpc_desc: desc\n )\n c.call(method_key)\n end\n end\n elsif desc.client_streamer?\n define_method(method_key) do |active_call|\n Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|\n c = fresh_controller.new(\n method_key: method_key,\n service: service_ref,\n message: proc { |&block| active_call.each_remote_read(&block) },\n active_call: active_call,\n rpc_desc: desc\n )\n c.call(method_key)\n end\n end\n elsif desc.server_streamer?\n define_method(method_key) do |message, active_call, &block|\n Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|\n c = fresh_controller.new(\n method_key: method_key,\n service: service_ref,\n message: message,\n active_call: active_call,\n rpc_desc: desc\n )\n c.call(method_key, &block)\n end\n end\n else # bidi\n define_method(method_key) do |messages, active_call, &block|\n Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|\n c = fresh_controller.new(\n method_key: method_key,\n service: service_ref,\n message: messages,\n active_call: active_call,\n rpc_desc: desc\n )\n c.call(method_key, &block)\n end\n end\n end\n end\n end",
"def install_post_hook\n end",
"def handlers; end",
"def handlers; end",
"def handlers; end",
"def singleton_method_added( sym )\n\t\tsuper\n\n\t\tif sym == :configure\n\t\t\tConfigurability.log.debug \"Re-configuring %p via deferred config hook.\" % [ self ]\n\t\t\tconfig = Configurability.loaded_config\n\t\t\tConfigurability.log.debug \"Propagating config to %p\" % [ self ]\n\t\t\tConfigurability.install_config( config, self )\n\t\tend\n\tend",
"def services\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def initialize(config)\n super(config, SERVICE_INFO)\n end",
"def before_hook(method_name)\n hooks << method_name\n end",
"def bi_service\n end",
"def create_service\n super.tap do |service_template|\n service_template.cookbook('poise-service')\n create_monit_config\n end\n end",
"def load_service(file, source_code)\r\n begin\r\n _info(\"Loading service definitions from #{file}.\")\r\n precompiler = ServicePrecompiler.new(file, source_code)\r\n precompiler.precompile()\r\n clean_source_code = precompiler.get_modified_source_code()\r\n class_def = define_class(classname=\"#{file}ServiceBuilder\", superclazz=ServiceConfigurationBuilder)\r\n class_def.add_method_def(methodname='configure',sourcecode=clean_source_code)\r\n service_builder = class_def.compile()\r\n resolved = service_builder.build(self.context())\r\n services.push(service_builder)\r\n return resolved\r\n rescue Exception => ex\r\n _debug(ex.message, ex)\r\n end\r\n end",
"def post_setup\n end",
"def service_name=(_arg0); end",
"def startup_hook; end",
"def hook1; end",
"def initialize(hook)\n @hook = hook\n end",
"def method_missing(method, *args, &block) #:doc:\n super unless @wsdl.respond_to? method\n\n setup method, &block\n dispatch method\n end",
"def add_handler(opts={})\n end",
"def hook_path; end",
"def initialize(*services)\n @services = services\n end",
"def process_hook\n fail 'sub class to implement'\n end",
"def hijack_setup(e, _)\n end",
"def init_service\n handle_missing_specifications and exit! if missing_specifications_detected\n ['your', 'data']\n end",
"def method_missing(sym,*args, &block)\n if sym.to_s.match(/^(on|before|after)_/)\n register_handler(sym.to_s,args.first,&block)\n else\n super\n end\n end",
"def process(*args)\n init_srv\n super\n end",
"def initialize_hook(hook, payload)\n @initialize_hook.call(hook, payload)\n end",
"def initialize (service_name, application_context)\n\n super()\n service_init(service_name, application_context)\n\n @dm_repository =\n application_context[:expstorage_dm_repository] || :default\n\n DataMapper.repository(@dm_repository) {\n DmExpression.auto_upgrade!\n }\n\n observe_expool\n end",
"def install_pre_hook\n end",
"def define_action_hook; end",
"def method_missing(sym,*args, &block)\n if sym.to_s.match(/^(on|before|after)_/)\n register_handler(sym.to_s,args.first,&block)\n else\n super\n end\n end",
"def initialize(&block)\n @services = {}\n @current_service = nil\n\n instance_eval(&block) if block_given?\n end",
"def service(uri, &block)\n service = ServiceBuilder.new(context())\n service.uri = uri\n __builders.push(service)\n service.instance_eval(&block) if block_given?\n return service\n end",
"def initialize(service, connection, protocol)\n @service = service\n @connection = connection\n @protocol = protocol\n # define RPC proxy methods on this instance\n extract_rpcs(service).each do |rpc|\n define_singleton_method(rpc) { |*rpc_args| post_rpc(rpc, *rpc_args) }\n end\n end"
] |
[
"0.6502253",
"0.6396917",
"0.6394521",
"0.6332797",
"0.63215667",
"0.62992376",
"0.6215813",
"0.62039936",
"0.6109727",
"0.60925716",
"0.6084907",
"0.60590404",
"0.60432065",
"0.60090166",
"0.59969884",
"0.5986942",
"0.59840745",
"0.5965312",
"0.5955509",
"0.5950327",
"0.5939242",
"0.5925145",
"0.5897922",
"0.5876253",
"0.587602",
"0.5832504",
"0.58138883",
"0.57838696",
"0.5775338",
"0.5771031",
"0.57627296",
"0.5759454",
"0.5758482",
"0.575484",
"0.57529676",
"0.57364744",
"0.573535",
"0.5731509",
"0.5730833",
"0.57183146",
"0.57132167",
"0.57132167",
"0.57132167",
"0.56941086",
"0.56792045",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.56745434",
"0.5671192",
"0.5669108",
"0.56647485",
"0.5660541",
"0.564226",
"0.5638498",
"0.5623812",
"0.56191",
"0.56174487",
"0.5617191",
"0.5606912",
"0.5579496",
"0.55668795",
"0.5558558",
"0.5552874",
"0.55526865",
"0.5542384",
"0.55382615",
"0.5537646",
"0.55370647",
"0.5537013",
"0.55266213",
"0.55227804",
"0.551864",
"0.54904854",
"0.5490421"
] |
0.64143836
|
1
|
creates a wrapped lambda for received hook config and registers it to hooks. method can be a Proc or name of instance or class method on the handler. options :if and :unless are respected here.
|
def define_hook(hooks, method, options)
hook_name = options[:name] || method
if hook_name.is_a?(Proc)
raise ArgumentError, "name option required when using proc for method"
end
hooks[hook_name] = lambda do |*args|
env = args.find { |arg| arg.is_a?(Hash) && arg.key?(:input) }
return if CallbackHelpers.skip?(env, options)
instance_exec(&CallbackHelpers.make_execute_lambda(method, env[:handler], *args))
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _hook_before_method(method, hook, opts = {})\n return false if method == hook\n _add_hooked_method(:before, hook, method)\n original = instance_method(method)\n @_defining_hook = true\n define_method(method) do |*args, &block|\n if opts[:send_args] || opts[:send_arg] || opts[:modify_args] || opts[:send_method] || opts[:try_first]\n margs = args\n margs = [method] + args if opts[:send_method]\n margs = args + [opts[:add_args]].flatten(1) if opts[:add_args]\n result = (hook.is_a?(Proc) ? hook : method(hook)).call(*margs)\n return result if result && opts[:try_first]\n args = result if opts[:modify_args]\n else\n hook.is_a?(Proc) ? hook.call : method(hook).call\n end\n original.bind(self).call(*args, &block)\n end\n @_defining_hook = false\n true\n end",
"def method_missing(sym,*args, &block)\n if sym.to_s.match(/^(on|before|after)_/)\n register_handler(sym.to_s,args.first,&block)\n else\n super\n end\n end",
"def apply(context, method, arguments=[])\n value = (@runtime_class.lookup(method) || context.locals[method])\n fail 'Undefined stored lambda. Check your argument values.' unless value\n value.call(self, arguments[0].ruby_value)\n end",
"def before_hook(method_name)\n hooks << method_name\n end",
"def method_missing(sym,*args, &block)\n if sym.to_s.match(/^(on|before|after)_/)\n register_handler(sym.to_s,args.first,&block)\n else\n super\n end\n end",
"def _hook_after_method(method, hook, opts = {})\n return false if method == hook\n _add_hooked_method(:after, hook, method)\n original = instance_method(method)\n @_defining_hook = true\n define_method(method) do |*args, &block|\n rtr = original.bind(self).call(*args, &block)\n if opts[:send_args]\n (hook.is_a?(Proc) ? hook : method(hook)).call(*args)\n elsif opts[:send_return] || opts[:send_value]\n result = (hook.is_a?(Proc) ? hook : method(hook)).call(rtr)\n rtr = result if opts[:modify_value] || opts[:modify_return]\n elsif opts[:send_return_ary] || opts[:send_value_ary]\n result = (hook.is_a?(Proc) ? hook : method(hook)).call(*rtr)\n rtr = result if opts[:modify_value] || opts[:modify_return]\n elsif opts[:send_all]\n result = (hook.is_a?(Proc) ? hook : method(hook)).call(args: args, value: rtr, method: method)\n else\n (hook.is_a?(Proc) ? hook : method(hook)).call\n end\n rtr\n end\n @_defining_hook = false\n true\n end",
"def hook(&block)\n @hook = block if block_given?\n @hook\nend",
"def around_hook(hook)\n define_method hook do |&block|\n add_hook(hook, &block)\n end\n define_method \"run_#{hook}\" do |*args, &block|\n run_around_hook(hook, *args, &block)\n end\n end",
"def before(method_to_hook, method_to_call = nil, options = {}, &block)\n add(:before, method_to_hook, method_to_call, options, &block)\n end",
"def attach_hook(hook, method)\n if @hook_register[hook] != nil\n @hook_register[hook].push method\n else\n @hook_register[hook] = [method]\n end\n end",
"def hook!(method_to_hook)\n hooked_method = hooked_method(method_to_hook)\n original_method = original_method(method_to_hook)\n line = __LINE__; alias_these_hooks = <<-hooks\n alias :#{original_method} :#{method_to_hook}\n def #{hooked_method}(*args)\n Hook.for(self.class).execute_before(:#{method_to_hook}, self)\n result = #{original_method}(*args)\n Hook.for(self.class).execute_after(:#{method_to_hook}, self)\n result\n end\n alias :#{method_to_hook} :#{hooked_method}\n hooks\n klass.class_eval alias_these_hooks, __FILE__, line.succ\n end",
"def install_hook(side, event, callback)\n self.hooks[:\"#{ side }_#{ event }\"].push(callback)\n end",
"def pre_hook_send(handler); end",
"def prepare_hooks(kind, command)\n hooks = callable_hooks(kind, command)\n return hooks unless kind == :around\n\n around_proc = hooks.reverse.reduce(command) do |callable, hook|\n -> { hook.call(callable) }\n end\n [around_proc]\n end",
"def add_hook(name, hook_function_name, callable=nil, &block)\n @hooks[name] ||= {}\n\n if block\n @hooks[name][hook_function_name] = block\n elsif callable\n @hooks[name][hook_function_name] = callable\n else\n raise ArgumentError, \"Must provide a block or callable.\"\n end\n\n self\n end",
"def wrapper\n -> fn { -> { fn } }\n end",
"def define_hook(name, *params)\n fetch_or_create_hooks << make_hook(name, nil, params)\n\n # We must use string evaluation in order to define a method that can\n # receive a block.\n instance_eval(<<-END)\n def #{name}(handle_or_method=nil, &block)\n add_callback(:#{name}, handle_or_method, &block)\n end\n END\n module_eval(<<-END)\n def #{name}(handle=nil, &block)\n add_external_callback(:#{name}, handle, block)\n end\n END\n end",
"def wrapping_block(method_name, **defaults)\n proc do |*args, **values|\n send method_name, *args, **defaults, **values\n end\n end",
"def define_hook(name, *params)\n hooks << make_hook(name, nil, params)\n\n # We must use string evaluation in order to define a method that can\n # receive a block.\n instance_eval(<<-END)\n def #{name}(handle_or_method=nil, &block)\n add_callback(:#{name}, handle_or_method, &block)\n end\n END\n module_eval(<<-END)\n def #{name}(handle=nil, &block)\n add_external_callback(:#{name}, handle, block)\n end\n END\n end",
"def hook(name, &blk)\n @hooks[name.to_sym] ||= []\n @hooks[name.to_sym] << blk\n self\n end",
"def add_method_hooks\n eigen_class = @target.singleton_class\n\n if @options[:class_methods]\n return unless @target.is_a?(Module)\n\n orig_singleton_method_added = @target.method(:singleton_method_added)\n\n eigen_class.send :define_method, :singleton_method_added do |method|\n aspector_singleton_method_added(method)\n orig_singleton_method_added.call(method)\n end\n else\n if @target.is_a? Module\n orig_method_added = @target.method(:method_added)\n else\n orig_method_added = eigen_class.method(:method_added)\n end\n\n eigen_class.send :define_method, :method_added do |method|\n aspector_instance_method_added(method)\n orig_method_added.call(method)\n end\n end\n end",
"def add_hook(event_name, hook_name, callable=nil, &block)\n @hooks[event_name] ||= []\n\n # do not allow duplicates\n raise ArgumentError, \"Hook with name '#{hook_name}' already defined!\" if hook_exists?(event_name, hook_name)\n\n if block\n @hooks[event_name] << [hook_name, block]\n elsif callable\n @hooks[event_name] << [hook_name, callable]\n else\n raise ArgumentError, \"Must provide a block or callable.\"\n end\n\n self\n end",
"def on(*args, &block)\n @options.push args << lambda(&block)\n end",
"def hook(&block)\n @hooks << block\n end",
"def method_added(name)\n\n# if new method is an alias method of some method then no need to alias it again\n if /hook/.match(name.to_s) or method_defined?(\"#{name}_without_hook\") or [\"before_method\",\"after_method\"].include?(name.to_s)\n return\n end \n\n call_bef = find_except(name,:before) #finds function which should be called before/after this fuction\n call_aft = find_except(name,:after)\n if call_bef.length == 0 && call_aft.length == 0 \n return\n end \n\n if call_bef.include?(name.to_s) or call_aft.include?(name.to_s) #To avoid infinite loop\n return\n end\n\n# define new method\n hook = %{\n def #{name}_hook\n call_bef = self.class.find_except(\\\"#{name}\\\",:before)\n call_bef.each{|elem| send elem}\n #{name}_without_hook()\n call_aft = self.class.find_except(\\\"#{name}\\\",:after)\n call_aft.each{|elem| send elem}\n end\n }\n\n self.class_eval(hook)\n a1 = \"alias #{name}_without_hook #{name}\"\n self.class_eval(a1)\n a2 = \"alias #{name} #{name}_hook\"\n self.class_eval(a2)\n\n end",
"def add_method_callback(hook_name, method)\n fetch_or_create_hooks[hook_name].add_method_callback(self, method)\n end",
"def setup_method_handler(method_handler)\n @handler = method_handler\n end",
"def add_hook(event_name, hook_name, callable = nil, &block)\n event_name = event_name.to_s\n\n # do not allow duplicates, but allow multiple `nil` hooks\n # (anonymous hooks)\n raise ArgumentError, \"Hook with name '#{hook_name}' already defined!\" if hook_exists?(event_name, hook_name) && !hook_name.nil?\n\n raise ArgumentError, 'Must provide a block or callable.' if !block && !callable\n\n # ensure we only have one anonymous hook\n @hooks[event_name].delete_if { |h, _k| h.nil? } if hook_name.nil?\n\n if block\n @hooks[event_name] << [hook_name, block]\n elsif callable\n @hooks[event_name] << [hook_name, callable]\n end\n\n self\n end",
"def hook_method(callback, on:, to:, with:)\n hook = Module.new\n hook.send(:define_method, callback) { |child|\n super child\n to.send with, child\n }\n\n on.extend hook\n nil\n end",
"def check_with(&lambda)\n self.evalLambda = lambda\n end",
"def loop_hook(method_name = nil, &block)\n @loop_hook ||= []\n if block_given?\n @loop_hook << block\n elsif method_name\n @loop_hook << Proc.new { |dev| dev.send(method_name, dev) }\n end\n @loop_hook\n end",
"def make_hooks(*args)\r\n make :hook, *args\r\n end",
"def callable_hooks(kind, command)\n hooks[kind].map do |hook|\n case hook\n when Symbol\n command.method(hook)\n when Proc\n ->(*args) { command.instance_exec(*args, &hook) }\n when Method\n hook\n end\n end\n end",
"def intercept(klass, meth_name, type, &block)\n orig_name = \"aop_orig_#{meth_name}\".to_sym\n meth_name = meth_name.to_sym\n @intercepted_methods ||= Hash.new do |h,k| \n # h[class_name] = hash\n h[k] = Hash.new do |h,k|\n # h[class_name][method_name] = hash\n h[k] = Hash.new do |h,k| \n # h[class_name][method_name][interception_type] = array\n h[k] = []\n end\n end\n end\n \n make_interception = !@intercepted_methods[klass].has_key?(meth_name)\n @intercepted_methods[klass][meth_name][type] << block\n method_chain = @intercepted_methods[klass][meth_name]\n \n if make_interception\n klass.class_eval do\n alias_method orig_name, meth_name\n define_method(meth_name) do |*args|\n method_chain[:before].each { |m| m.call(self, args) }\n # The result of the callcc block will either be the last line in the actual\n # ruby block, or it will be whatever is passed as arguments when calling the \n # +abort_continuation+ proc\n callcc do |abort_continuation|\n # First lambda in chain is the call to the original method\n call_lambda = lambda { send(orig_name, *args) }\n method_chain[:around].each do |m|\n # Make a chain of lambdas that calls the previouly defined\n # lambda, thus creating a chain of around blocks that will\n # all finally reach the original method block\n prev_call_lambda = call_lambda\n call_lambda = lambda {\n # If +prev_call_lambda+ is called, the next around block in\n # chain until the last one which corresponds to the original method call\n # if +abort_continuation+ is called, then this loop is aborted and the\n # callcc block returns whatever was passed as an argument to the proc call\n m.call(self, args, prev_call_lambda, abort_continuation)\n }\n end\n result = call_lambda.call\n method_chain[:after].each { |m| m.call(self, result, args) }\n result\n end\n end\n end\n end\n end",
"def add_hook(event, hook = nil, &block)\r\n hook = block if block #block has precedence\r\n raise ArgumentError, 'no hook was passed' unless hook\r\n hook = hook.to_s unless hook.respond_to?(:call)\r\n hooks[event.to_s].unshift(hook)\r\n hook\r\n end",
"def add_hook(name, &block)\n hooks[name.to_sym] ||= []\n hooks[name.to_sym] << block\n end",
"def method_missing method, *args, &block\n temp = @@config_options.send method\n if temp.is_a?(Proc)\n temp.call *args\n else\n temp\n end\n end",
"def add_handler(opts={})\n end",
"def run_hook!(name)\n return unless hooks[name.to_sym]\n hooks[name.to_sym].each { |blk| config.instance_exec(&blk) }\n end",
"def hook_class!(klass, hooked_methods, hooks)\n\n hooked_methods = [hooked_methods] if hooked_methods.is_a? Symbol\n\n validate_hooks(hooks) # Validate hooks\n validate_is_class(klass) # Validate class\n\n hooked_methods.each do |hooked_method| # Validate methods defined\n validate_has_method_defined(klass.metaclass, hooked_method)\n end\n\n hooked_methods.each do |hooked_method|\n CLASS_METHOD_HOOKS[klass] ||= {}\n new_hooked_method_name = \"#{CLASS_HOOK_METHOD_PREFIX}#{hooked_method}\"\n\n if CLASS_METHOD_HOOKS[klass].has_key?(hooked_method)\n raise AlreadyDefinedHookException.new(\"Hook signature present for #{hooked_method} in #{klass.metaclass}\")\n end\n if klass.metaclass.method_defined?(new_hooked_method_name)\n raise AlreadyDefinedHookException.new(\"Method #{new_hooked_method_name} hook already defined for #{hooked_method} in #{klass.metaclass}\")\n end\n\n CLASS_METHOD_HOOKS[klass][hooked_method] = {}\n\n hooks.each do |where, callback|\n CLASS_METHOD_HOOKS[klass][hooked_method][where] = callback\n end\n\n hook_key = klass.name\n before_hook_call = <<-BEFORE_HOOK_CALL\n before_hook_callback = Peeping::Peep.hooked_class_methods_for(#{hook_key})[:\"#{hooked_method}\"][:before]\n before_hook_callback.call(self, *args) if before_hook_callback\n BEFORE_HOOK_CALL\n\n after_hook_call = <<-AFTER_HOOK_CALL\n after_hook_callback = Peeping::Peep.hooked_class_methods_for(#{hook_key})[:\"#{hooked_method}\"][:after]\n after_hook_callback.call(self, proxied_result) if after_hook_callback\n AFTER_HOOK_CALL\n\n class_eval_call = Proc.new do\n eval <<-REDEF\n alias :\"#{new_hooked_method_name}\" :\"#{hooked_method}\"\n def #{hooked_method}(*args, &block)\n #{before_hook_call}\n proxied_result = if block_given?\n __send__(\"#{new_hooked_method_name}\", *args, &block)\n else\n __send__(\"#{new_hooked_method_name}\", *args)\n end\n #{after_hook_call}\n proxied_result\n end\n REDEF\n end\n klass.metaclass.class_eval(&class_eval_call)\n end\n end",
"def before_method(method)\n @@before_methods << method\n @@wrap_exclusions << method.to_sym # This method will not be wrapped.\n end",
"def configure_hooks(hook_type, service)\n unless VALID_HOOKS.include?(hook_type)\n raise ArgumentError, \"unknown twirp hook type received: #{hook_type}\"\n end\n\n existing_hooks = instance_variable_get(\"@#{hook_type}_hooks\")\n return if existing_hooks.nil?\n\n existing_hooks.values.each do |hook|\n service.send(hook_type, &hook)\n end\n end",
"def input_hook(incoming_type, method_name = nil, &block)\n @input_hook ||= {}\n\n if block_given?\n # set the hook.\n @input_hook[incoming_type] = block\n elsif method_name\n @input_hook[incoming_type] = Proc.new { |dev, type, data| dev.send(method_name, dev, type, data) }\n else\n # get the hook\n @input_hook[incoming_type] ||= Proc.new { |dev, type, data| HIDAPI.debug \"no input hook for #{type} message type with #{data.length} bytes of data\" }\n end\n end",
"def handle_method_addition(clazz, method_name)\n # @_ignore_additions allows to temporarily disable the hook\n return if @_ignore_additions || declared_decorators.empty?\n decorator_class, params, blk = declared_decorators.pop\n\n undecorated_method = clazz.instance_method(method_name)\n decorator = METHOD_CALLED_TOO_EARLY_HANDLER\n clazz.send(:define_method, method_name) { |*args, &block| decorator.call(self, *args, &block) }\n decorated_method = clazz.instance_method(method_name)\n @_ignore_additions = true\n decorator = decorator_class.new(clazz, undecorated_method, decorated_method, *params, &blk)\n @_ignore_additions = false\n clazz.send(Decors::Utils.method_visibility(undecorated_method), method_name)\n end",
"def hook_object!(object, hooked_methods, hooks)\n hooked_methods = [hooked_methods] if hooked_methods.is_a? Symbol\n\n validate_hooks(hooks) # Validate hooks\n\n hooked_methods.each do |hooked_method| # Validate methods defined\n validate_has_method_defined(object.metaclass, hooked_method)\n end\n\n hooked_methods.each do |hooked_method|\n SINGLETON_METHOD_HOOKS[object] ||= {}\n hooked_method_name = \"#{SINGLETON_HOOK_METHOD_PREFIX}#{hooked_method}\"\n\n if SINGLETON_METHOD_HOOKS[object].has_key?(hooked_method)\n raise AlreadyDefinedHookException.new(\"Hook signature present for #{hooked_method} in #{object.metaclass}\")\n end\n if object.metaclass.method_defined?(hooked_method_name)\n raise AlreadyDefinedHookException.new(\"Method #{hooked_method_name} hook already defined for #{hooked_method} in #{where_to_eval}\")\n end\n\n SINGLETON_METHOD_HOOKS[object][hooked_method] = {}\n\n hooks.each do |where, callback|\n SINGLETON_METHOD_HOOKS[object][hooked_method][where] = callback\n end\n\n hook_key = 'self'\n before_hook_call = <<-BEFORE_HOOK_CALL\n\n before_hook_callback = ((Peeping::Peep.hooked_singleton_methods_for(#{hook_key})||{})[:\"#{hooked_method}\"] || {})[:before]\n instance_before_hook_callback = ((Peeping::Peep.hooked_instance_methods_for(self.class) || {})[:\"#{hooked_method}\"] || {})[:before]\n\n before_hook_callback ||= instance_before_hook_callback \n before_hook_callback.call(self, *args) if before_hook_callback\n BEFORE_HOOK_CALL\n\n after_hook_call = <<-AFTER_HOOK_CALL\n after_hook_callback = ((Peeping::Peep.hooked_singleton_methods_for(#{hook_key})||{})[:\"#{hooked_method}\"] || {})[:after]\n instance_after_hook_callback = ((Peeping::Peep.hooked_instance_methods_for(self.class) || {})[:\"#{hooked_method}\"] || {})[:after]\n\n after_hook_callback ||= instance_after_hook_callback \n after_hook_callback.call(self, proxied_result) if after_hook_callback\n AFTER_HOOK_CALL\n\n should_override_instance_call = true # TODO: Optionalize\n class_eval_call = Proc.new do\n eval <<-REDEF\n if #{should_override_instance_call} and method_defined?(:\"#{INSTANCE_HOOK_METHOD_PREFIX}#{hooked_method}\")\n alias :\"#{hooked_method_name}\" :\"#{INSTANCE_HOOK_METHOD_PREFIX}#{hooked_method}\"\n else\n alias :\"#{hooked_method_name}\" :\"#{hooked_method}\"\n end\n def #{hooked_method}(*args, &block)\n #{before_hook_call}\n proxied_result = if block_given?\n __send__(\"#{hooked_method_name}\", *args, &block)\n else\n __send__(\"#{hooked_method_name}\", *args)\n end\n #{after_hook_call}\n proxied_result\n end\n REDEF\n end\n object.metaclass.class_eval(&class_eval_call)\n end\n end",
"def add_hook(payload_class, hook_arg = nil, &hook_block)\n hook = block_given? ? hook_block : hook_arg\n if !hook || !hook.is_a?(Proc)\n raise \"Must pass a proc either as an argument or a block\"\n end\n @message_hooks[payload_class] << hook\n end",
"def run_handler=(proc)\n check_definition_state(is_method: true)\n tool_class.class_eval do\n define_method(:run, &proc)\n end\n end",
"def hook_instances!(klass, hooked_methods, hooks)\n hooked_methods = [hooked_methods] if hooked_methods.is_a? Symbol\n\n #=== Validations ===\n validate_hooks(hooks)\n validate_is_class(klass)\n hooked_methods.each { |hooked_method| validate_has_method_defined(klass, hooked_method) }\n\n hooked_methods.each do |hooked_method|\n INSTANCE_METHOD_HOOKS[klass] ||= {}\n hooked_method_name = \"#{INSTANCE_HOOK_METHOD_PREFIX}#{hooked_method}\"\n\n if INSTANCE_METHOD_HOOKS[klass].has_key?(hooked_method)\n raise AlreadyDefinedHookException.new(\"Hook signature present for #{hooked_method} in #{klass}\")\n end\n if klass.method_defined?(hooked_method_name)\n raise AlreadyDefinedHookException.new(\"Method #{hooked_method_name} hook already defined for #{hooked_method} in #{klass}\")\n end\n\n INSTANCE_METHOD_HOOKS[klass][hooked_method] = {}\n\n hooks.each do |where, callback|\n INSTANCE_METHOD_HOOKS[klass][hooked_method][where] = callback\n end\n\n hook_key = klass.name\n before_hook_call = <<-BEFORE_HOOK_CALL\n before_hook_callback = Peeping::Peep.hooked_instance_methods_for(#{hook_key})[:\"#{hooked_method}\"][:before]\n before_hook_callback.call(self, *args) if before_hook_callback\n BEFORE_HOOK_CALL\n\n after_hook_call = <<-AFTER_HOOK_CALL\n after_hook_callback = Peeping::Peep.hooked_instance_methods_for(#{hook_key})[:\"#{hooked_method}\"][:after]\n after_hook_callback.call(self, proxied_result) if after_hook_callback\n AFTER_HOOK_CALL\n\n class_eval_call = Proc.new do\n eval <<-REDEF\n alias :\"#{hooked_method_name}\" :\"#{hooked_method}\"\n def #{hooked_method}(*args, &block)\n #{before_hook_call}\n proxied_result = if block_given?\n __send__(\"#{hooked_method_name}\", *args, &block)\n else\n __send__(\"#{hooked_method_name}\", *args)\n end\n #{after_hook_call}\n proxied_result\n end\n REDEF\n end\n klass.class_eval(&class_eval_call)\n end\n \n end",
"def after_method(method)\n @@after_methods << method\n @@wrap_exclusions << method.to_sym # This method will not be wrapped.\n end",
"def add_callback(hook_name, handle_or_method=nil, &block)\n if block\n add_block_callback(hook_name, handle_or_method, block)\n else\n add_method_callback(hook_name, handle_or_method)\n end\n end",
"def add_callback(hook_name, handle_or_method=nil, &block)\n if block\n add_block_callback(hook_name, handle_or_method, block)\n else\n add_method_callback(hook_name, handle_or_method)\n end\n end",
"def method_missing(method_name, *args, &block)\n if self.class.has_dsl_attribute?(method_name.to_sym)\n @builded_attributes[method_name.to_sym] = if block_given?\n build_hash_from_block(&block)\n else\n args[0]\n end\n else\n raise \"Configuration '#{method_name}' is not allowed for #{self}\"\n end\n end",
"def on(event, &block)\n hooks[event.to_sym] ||= []\n hooks[event.to_sym] << block\n end",
"def hook(type, options = {})\n options = {:for => [:match, :listen_to, :ctcp], :method => :hook}.merge(options)\n __hooks(type) << Hook.new(type, options[:for], options[:method])\n end",
"def hook(type, options = {})\n options = {:for => [:match, :listen_to, :ctcp], :method => :hook}.merge(options)\n __hooks(type) << Hook.new(type, options[:for], options[:method])\n end",
"def method_missing(method, *args, &block)\n if known_methods.include?(method)\n if args.first.is_a?(Hash)\n call_wrap(method, args.first)\n else\n hash_args = args_to_hash(method, *args)\n call_wrap(method, hash_args)\n end\n else\n super\n end\n end",
"def add_method\n <<-CODE\n next_literal;\n t1 = stack_pop();\n t2 = stack_pop();\n cpu_add_method(state, c, t1, _lit, t2);\n stack_push(t2);\n cpu_perform_hook(state, c, t1, global->sym_method_added, _lit);\n CODE\n end",
"def phi_wrap_method(method_name)\n unless respond_to?(method_name)\n PhiAttrs::Logger.warn(\"#{self.class.name} tried to wrap non-existant method (#{method_name})\")\n return\n end\n return if self.class.__phi_methods_wrapped.include? method_name\n\n wrapped_method = :\"__#{method_name}_phi_wrapped\"\n unwrapped_method = :\"__#{method_name}_phi_unwrapped\"\n\n self.class.send(:define_method, wrapped_method) do |*args, **kwargs, &block|\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n unless phi_allowed?\n raise PhiAttrs::Exceptions::PhiAccessException, \"Attempted PHI access for #{self.class.name} #{@__phi_user_id}\"\n end\n\n unless all_phi_context_logged?\n PhiAttrs::Logger.info(\"#{self.class.name} access by [#{all_phi_allowed_by}]. Triggered by method: #{method_name}\")\n set_all_phi_context_logged\n end\n\n send(unwrapped_method, *args, **kwargs, &block)\n end\n end\n\n # method_name => wrapped_method => unwrapped_method\n self.class.send(:alias_method, unwrapped_method, method_name)\n self.class.send(:alias_method, method_name, wrapped_method)\n\n self.class.__phi_methods_wrapped << method_name\n end",
"def after(method_to_hook, method_to_call = nil, options = {}, &block)\n add(:after, method_to_hook, method_to_call, options, &block)\n end",
"def create_handler_for(handler_method)\n @jr_handlers ||= {}\n handler_class = self\n\n @jr_handlers[handler_method] = proc { |*args|\n # instantiate new handler instance\n jr_instance = handler_class.new\n\n # setup scope to include request variables\n instance_variables.each { |iv|\n jr_instance.instance_variable_set(iv, instance_variable_get(iv))\n }\n\n # invoke handler method\n jr_instance.method(handler_method).call *args\n }\n end",
"def method_missing(method, *args, &block)\n\t\t@self_before_instance_eval.send method, *args, &block\n\t end",
"def bound_method(block); end",
"def apply(klass, method)\n if klass.is_a?(String)\n return unless Object.const_defined?(klass)\n\n klass = Object.const_get(klass)\n end\n\n proxy = self\n original_method = \"_tainted_love_original_#{method}\"\n\n klass.class_eval do\n alias_method original_method, method\n\n define_method method do |*args, &given_block|\n proxy.handle(self, original_method, *args, &given_block)\n end\n end\n end",
"def invoke_with(method_name)\n send :define_method, :invoke do\n run_hook :before_invoke\n @response = send method_name\n run_hook :after_invoke\n @response\n end\n end",
"def add_hooks(repo, endpoint)\n hook = api.create_hook(\n repo,\n 'web',\n {\n url: endpoint,\n secret: ENV['GITHUB_SECRET_TOKEN']\n },\n {\n events: %w(push pull_request), active: true,\n }\n )\n\n yield hook.id\n rescue Octokit::UnprocessableEntity => error\n raise unless error.message.include? 'Hook already exists'\n end",
"def enabled_ad_hoc_hooks(hook_context); end",
"def instrument_method(klass,method_name,unbound_orig_method,inst_code) \n lambda do |*args|\n bound_method = unbound_orig_method.bind(self)\n# if ::DRuby::Profile::Interceptor.enabled then\n inst_code.call(bound_method,*args)\n# else\n# bound_method.call(*args)\n# end\n end\n end",
"def handler_method\n # assumed CWD is where serverless.yml is.\n # At some point this might need to be configurable\n serverless_yml = YAML.safe_load(File.read('serverless.yml'))\n handler_config = serverless_yml['functions'][@function_name.to_s]['handler']\n HandlerMethod.new(handler_config)\n # handler name is either a global method or a static method in a class\n # my_method or MyModule::MyClass.my_method\n # handler_method_name, handler_class = handler_name.split('.').reverse\n # handler_class ||= 'Kernel'\n # klass = Object.const_get(handler_class)\n # klass.method(handler_method_name)\n end",
"def provide_lever(lever, method)\n if @lever_register[lever] != nil\n @lever_register[lever].push method\n else\n @lever_register[lever] = [method]\n end\n end",
"def validation_rule(method_name, &block)\n method = MethodValidation.new(method_name)\n block_given? and method.block &block\n @methods_loaded[:\"#{method_name}\"] = method\n end",
"def add_method_callback(hook_name, method)\n hooks[hook_name].add_method_callback(self, method)\n end",
"def method_missing(method_name, *arguments, &block)\n # Check to see if there is a outer_profile_dsl plugin activator hook with the method name\n registry = Inspec::Plugin::V2::Registry.instance\n hook = registry.find_activators(plugin_type: :outer_profile_dsl, activator_name: method_name).first\n if hook\n # OK, load the hook if it hasn't been already. We'll then know a module,\n # which we can then inject into the context\n hook.activate\n # Inject the module's methods into the context\n # implementation_class is the field name, but this is actually a module.\n self.class.include(hook.implementation_class)\n # Now that the module is loaded, it defined one or more methods\n # (presumably the one we were looking for.)\n # We still haven't called it, so do so now.\n send(method_name, *arguments, &block)\n else\n super\n end\n end",
"def method_missing(method_name, *arguments, &block)\n # Check to see if there is a control_dsl plugin activator hook with the method name\n registry = Inspec::Plugin::V2::Registry.instance\n hook = registry.find_activators(plugin_type: :control_dsl, activator_name: method_name).first\n if hook\n # OK, load the hook if it hasn't been already. We'll then know a module,\n # which we can then inject into the context\n hook.activate\n\n # Inject the module's methods into the context.\n # implementation_class is the field name, but this is actually a module.\n self.class.include(hook.implementation_class)\n # Now that the module is loaded, it defined one or more methods\n # (presumably the one we were looking for.)\n # We still haven't called it, so do so now.\n send(method_name, *arguments, &block)\n else\n # If we couldn't find a plugin to match, maybe something up above has it,\n # or maybe it is just a unknown method error.\n super\n end\n end",
"def add_handler(opts={})\n return if not payload_instance\n return if not handler_enabled?\n payload_instance.add_handler(opts)\n end",
"def define_and_call_method(method, &block)\n self.class.send(:define_method, method, block)\n send method\n end",
"def method_missing(method_symbol, *args, &block)\n # Run before hook if needed\n @composite.method_hooks[method_symbol].before if @composite.method_hook?(method_symbol)\n\n subject_return = @subject.send(method_symbol, *args, &block)\n\n # Run after hook if needed\n @composite.method_hooks[method_symbol].after if @composite.method_hook?(method_symbol)\n\n subject_return\n end",
"def add(f)\n @lambdas.push(f)\n end",
"def fire_on_method(method, event_type, &block)\n if method.is_a? Array\n method.map { |sym| fire_on_method(sym, event_type, &block) }\n return\n end\n \n # We alias @parent to parent here, because class_eval can't see outside\n # this scope otherwise.\n parent, old_method = @parent, ('ruby_events_' + method.to_s + '_event_old').to_sym\n if parent && parent.respond_to?(method)\n parent.class.class_eval do\n # If the parent is already responding to the alias method, it means\n # the fire_on_method event was already triggered. Remove the other\n # event and continue if this happens.\n if parent.respond_to?(old_method, true)\n remove_method method\n alias_method method, old_method\n remove_method old_method\n end\n \n alias_method old_method, method\n private old_method\n \n # Make sure the self.send is at the end, or we won't return what we\n # are supposed to.\n define_method method do |*args|\n events.fire(event_type, *args)\n block.call(*args) if block # Calling the block we've been passed\n __send__(old_method, *args)\n end\n end\n else\n raise 'The given object does not respond to method you are trying to intercept calls to.'\n end\n end",
"def define_new_method!\n advised = self\n\n advised.mod_target.instance_eval do\n define_method advised.new_meth do | *args, &block |\n ar = ActivationRecord.new(advised, self, args, block)\n\n # Proc to invoke the old method with :before and :after advise hooks.\n body = Proc.new do\n self.__send__(advised.before_meth, ar)\n begin\n ar.result = self.__send__(advised.old_meth, *ar.args, &ar.block)\n rescue ::Object => err\n ar.error = err\n ensure\n self.__send__(advised.after_meth, ar)\n end\n ar.result\n end\n\n # Invoke the :around advice with the body Proc.\n self.__send__(advised.around_meth, ar, body)\n\n # Reraise Exception, if occured.\n raise ar.error if ar.error\n\n # Return the message result to caller.\n ar.result\n end # define_method\n end # instance_eval\n\n self\n end",
"def base_rack_app_callable(new_api=true)\n if new_api\n lambda{|env| new(env)._roda_handle_main_route}\n else\n block = @rack_app_route_block\n lambda{|env| new(env).call(&block)}\n end\n end",
"def to_lambda(source_proc)\n return source_proc if source_proc.lambda?\n\n unbound_method = Module.new.module_eval do\n instance_method(define_method(:_, &source_proc))\n end\n\n lambda do |*args, &block|\n unbound_method.bind(self).call(*args, &block)\n end\n end",
"def execute_before(method_to_hook, instance)\n execute(:before, method_to_hook, instance)\n end",
"def singleton_method_added(singleton_method_name)\n\n # Skip any methods that are excluded. See @@wrap_exclusions for more information.\n if @@wrap_exclusions.include?(singleton_method_name.to_sym)\n return\n end\n\n # A method that was once wrapped must now be in the excluded list, as well as it's alias.\n # This is to prevent infinite loop.\n @@wrap_exclusions << singleton_method_name.to_sym\n @@wrap_exclusions << \"old_#{singleton_method_name}\".to_sym\n\n # Because I am in a class method here, I need the special self.class_eval\n # in order to add new class methods. Because the names are part of a variable,\n # I use the HEREDOC so I can call alias_method and redefine the same method.\n #\n # * We create an alias so we can call the original method.\n # * We redefine the method by calling before and after callbacks.\n # * The before callbacks are skipped if they are already called without the after.\n # * The after callbacks are skipped if one of the method called a sibbling.\n # We only do the after callbacks when its the original methods that has finished.\n # * Any arguments and return values are perseved\n # * Methods that supports blocks are not supported.\n self.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1\n class << self\n alias_method :old_#{singleton_method_name}, :#{singleton_method_name}\n end\n def self.#{singleton_method_name}(*args)\n if time_to_call_before_methods?\n before_methods.each do |method|\n send(method)\n end\n end\n entering_wrap_method\n result = old_#{singleton_method_name} *args\n leaving_wrap_method\n if time_to_call_after_methods?\n after_methods.each do |method|\n send(method)\n end\n end\n result\n end\n RUBY_EVAL\n\n end",
"def bootstrap_method method\n return proc do\n (class << self; self ; end).send :define_method, method do |*args|\n endpoints = [Vindicia.endpoint]\n\n if Vindicia.environment == 'production'\n endpoints << Vindicia.endpoint('fallback')\n end\n\n endpoints.each do |endpoint|\n response = self.soap_call(method, args.first, endpoint)\n\n if response.nil?\n next\n elsif response.http_error?\n next\n else\n return Vindicia.parse_response(response, method)\n end\n end\n end\n end\n end",
"def add( k, clr = nil, &block )\n key = sk( k )\n clr ||= caller.first\n LOCK.synchronize do\n applied.delete( key )\n hooks[ key ] << [ block, clr.to_s ]\n end\n end",
"def hook(type, options = {})\n options = { for: %i[match listen_to ctcp], method: :hook, group: nil }.merge(options)\n hook = Hook.new(type, options[:for], options[:method], options[:group])\n __hooks(type) << hook\n\n hook\n end",
"def reset_hook(method_name = nil, &block)\n @reset_hook ||= []\n if block_given?\n @reset_hook << block\n elsif method_name\n @reset_hook << Proc.new { |dev| dev.send(method_name, dev) }\n end\n @reset_hook\n end",
"def add(hook)\n @hooks << hook\n self\n end",
"def hooked_methods\n @hooked_methods ||= []\n end",
"def webhook_health\n WebhookWebhookHealthMethodsFactory.new(self)\n end",
"def remove_hook(method_name, hook)\n hooks[method_name].delete(hook)\n end",
"def call_with_hooks(*args)\n self.class.hooks[:before].each do |block|\n instance_exec(*args, &block)\n end\n\n ret = call(*args)\n\n self.class.hooks[:after].each do |block|\n ret = instance_exec(*args, &block)\n end\n\n ret\n end",
"def ensure_hook(key,&block)\n if block_given? then\n @ensure_hooks[key] = block\n else\n @ensure_hooks.delete(key)\n end\n end",
"def add_propagation_handler(options = Hash.new, &block)\n if options.respond_to?(:call) # for backward compatibility\n block, options = options, Hash.new\n end\n\n handler_options, poll_options = Kernel.filter_options options,\n :type => :external_events\n\n check_arity block, 1\n new_handler = PollBlockDefinition.new(\"propagation handler #{block}\", block, poll_options)\n\n if handler_options[:type] == :propagation\n propagation_handlers << new_handler\n elsif handler_options[:type] == :external_events\n if new_handler.late?\n raise ArgumentError, \"only :propagation handlers can be marked as 'late', the external event handlers cannot\"\n end\n external_events_handlers << new_handler\n else\n raise ArgumentError, \"invalid value for the :type option. Expected :propagation or :external_events, got #{handler_options[:type]}\"\n end\n new_handler.id\n end",
"def callback_actions_for(method, type)\n if self.callback_actions[method].nil?\n callback_actions = []\n else\n callback_actions = self.callback_actions[method][type] ||= []\n end\n \n#Removed this because this didn't work\n#callback_actions_for is called four times with every callback method:\n# before, before metaclass, after, after metaclass\n# And a class and metaclass both now the #{type}_#{method} method\n# So it got called twice\n# if self.instance_methods.include?(\"#{type}_#{method}\")\n# if not callback_actions.include? \"#{type}_#{method}\".to_sym\n# callback = self.add_callback_action(type, method, \"#{type}_#{method}\".to_sym)\n# callback_actions << callback\n# end\n# end\n\n #TODO: order by options[:priority]\n return callback_actions \n end",
"def mk_method(proc)\n @klass.send(:define_method, @method_name, proc)\n end",
"def spike_lamb_wrap\n PipeProc.new do |coll|\n coll.map do |tuple|\n tuple[1].map do |test|\n dp = DecoratedProc.new do \n obj = tuple[0].new\n obj.try :set_up\n obj.send test\n obj.try :tear_down\n end\n dp.message = \"#{tuple[0].name}::#{test.to_s}\"\n dp\n end\n end\n end\nend",
"def add_propagation_handler(options = Hash.new, &block)\n if options.respond_to?(:call) # for backward compatibility\n block, options = options, Hash.new\n end\n\n handler_options, poll_options = Kernel.filter_options options,\n :type => :external_events\n\n check_arity block, 1\n new_handler = PollBlockDefinition.new(\"propagation handler #{block}\", block, poll_options)\n\n if handler_options[:type] == :propagation\n propagation_handlers << new_handler\n elsif handler_options[:type] == :external_events\n external_events_handlers << new_handler\n else\n raise ArgumentError, \"invalid value for the :type option. Expected :propagation or :external_events, got #{handler_options[:type]}\"\n end\n new_handler.id\n end",
"def struct_predicate(method)\n instance_eval <<-RUBY\n def #{method}?\n true\n end\n RUBY\n end",
"def define_hook(id, &block)\n\t\t\t\t\th = Hook.new id, &block\n\t\t\t\t\t@hooks[id] = [] unless @hooks[id]\n\t\t\t\t\t@hooks[id] << h\n\t\t\t\tend"
] |
[
"0.5898352",
"0.58222187",
"0.5811574",
"0.5774951",
"0.5753875",
"0.5734096",
"0.5689229",
"0.5668453",
"0.56216305",
"0.5612948",
"0.5568042",
"0.5564686",
"0.55522984",
"0.5540169",
"0.55165267",
"0.54720986",
"0.5443501",
"0.54318047",
"0.5412243",
"0.5387317",
"0.53868717",
"0.5384094",
"0.53697747",
"0.5364714",
"0.53557414",
"0.53550327",
"0.53504795",
"0.5350101",
"0.5332268",
"0.5323874",
"0.5320991",
"0.5300861",
"0.52998626",
"0.52267253",
"0.52159196",
"0.5212528",
"0.51992285",
"0.5197306",
"0.51787806",
"0.5167531",
"0.51430786",
"0.51406693",
"0.5101701",
"0.5099809",
"0.50821555",
"0.50715023",
"0.5054567",
"0.5051955",
"0.5047702",
"0.50352484",
"0.50352484",
"0.5034566",
"0.5028079",
"0.502375",
"0.502375",
"0.5013855",
"0.5009348",
"0.500656",
"0.4996769",
"0.49957055",
"0.4995033",
"0.4991007",
"0.49856773",
"0.49731135",
"0.49672726",
"0.49603578",
"0.4958297",
"0.4941783",
"0.49313167",
"0.4927688",
"0.49257",
"0.4921133",
"0.49137813",
"0.49088442",
"0.4905476",
"0.49011168",
"0.4892579",
"0.4889537",
"0.48867276",
"0.48667088",
"0.48574564",
"0.4855133",
"0.4838771",
"0.48371503",
"0.48338994",
"0.48300087",
"0.48296168",
"0.48271027",
"0.48172218",
"0.4816622",
"0.4806828",
"0.4801632",
"0.47916666",
"0.47912067",
"0.47896588",
"0.47880983",
"0.47838798",
"0.47820634",
"0.47816357",
"0.4777906"
] |
0.7049262
|
0
|
add a set of item_ids to the matrix
|
def add_set(set_id, item_ids)
raise "implemented in subclass"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all_item_ids\n [id] + item_ids\n end",
"def add_dimension_to_items\n new_items = Array.new\n items.each do |i|\n Rails.logger.debug(\"i[:product_id] is #{i[:product_id]}\")\n p = CachedProduct.find_by_product_id(i[:product_id])\n i = i.merge({:height=>p.height, :width=>p.width, :length =>p.length})\n new_items << i\n end\n new_items\n end",
"def add_single(set_id, item_id, other_item_ids)\n raise \"implemented in subclass\"\n end",
"def assignIds(items)\r\n\titems.each_with_index {|item, index| item['id'] = index}\r\nend",
"def add_with_id item\n id = @id_gen.gen\n #here we automatically mix in the IdManaged protocol\n item.extend IdManaged\n item.id_manager = self\n item.pool_id =id\n @arr << item\n end",
"def add_items_to_order\n params[:order][:menu_item_ids]\n \n end",
"def add_rows! *rows\r\n matrix_new = add_rows *rows\r\n @rows = matrix_new.to_a\r\n end",
"def addToQueue(items)\n if( items.is_a? DataSet ) then\n\t@itemList.push( items )\n elsif( items.is_a? Array ) then\n\titems.each { |i| addToQueue(i) }\n end\n end",
"def add_item item\n @items << item\n @@all_items << item\n end",
"def include_ids?(item_ids)\n all_item_ids == item_ids\n end",
"def add_data_ids(id_old, id_new)\n return id_old.map{|id| id.sort} if id_new.nil?\n id_old = Hash.new if id_old.nil?\n id_new.each do |k, val|\n id_old[k] = Array.new if id_old[k].nil?\n val.each{|v| id_old[k] << v if not id_old[k].any?(v)}\n id_old[k].sort!\n end\n return id_old\nend",
"def update(items)\n # clear!\n self.items.each do |i|\n number = items[i.id].blank? ? 1 : items[i.id].to_i <= 0 ? 1 : items[i.id]\n number.to_i < 99 ? i.quantity = number.to_i : i.quantity=99\n end\n # items.each { |id, quantity| add_items(id, quantity) }\n end",
"def join_matrix(m_input, m_id)\n m_result = Array.new\n n_cols = m_input[0].size\n nc_id = m_id[0].size\n for i in 0..nc_id-1\n m_result[i] = Array.new\n m_result[i][0] = m_id[i][0]\n end\n for i in 0..m_input.size-1\n for j in 0..m_input[0].size - 2\n m_result[i][j+1] = m_input[i][j]\n end\n m_result[i][n_cols+nc_id-1] = m_input[i][n_cols-1]\n end\n for i in 0..m_id.size-1\n for j in 1..m_id[0].size - 1\n m_result[i][j+n_cols-1] = m_id[i][j]\n end\n end\n for i in 0..nc_id-1\n\n m_result[i].unshift( i==0? 'Z' : 'X'+ (i+n_cols-1).to_s)\n end\n m_result\n\nend",
"def add_basket_items(items)\n items.each do |i|\n order_lines.build(\n product_id: i.product.id,\n product_sku: i.product.sku,\n product_name: i.product.name,\n product_rrp: i.product.rrp,\n product_price: i.product.price_ex_vat(i.quantity),\n product_weight: i.product.weight,\n vat_amount: i.product.vat_amount(i.quantity) * i.quantity,\n quantity: i.quantity,\n feature_descriptions: i.feature_descriptions\n )\n end\n end",
"def add_item_to_cart(item_id)\n cart << item_id\n end",
"def param_plus(param_id, *args, &block)\n val = super(param_id, *args, &block)\n maesb_sets.compact.inject(val) {|r, item| r += item.params[param_id] }\n end",
"def add_row( group_id, row, number_to_transpose = 0 )\n @groups[group_id - 1] ||= []\n @groups[group_id - 1] << MiltonsMachine::Core::ForteSet.new(row).transpose_mod12(number_to_transpose)\n @max_group_index = @groups.length - 1\n @max_column_index = @groups[0][0].length - 1\n end",
"def quantity_by_item_id(hash)\n hash.each { |item_id, inv_items|\n hash[item_id] = sum(inv_items, :quantity)\n }; return hash\n end",
"def add_each_to_set(adds)\n view.update_many(\"$addToSet\" => collect_each_operations(adds))\n end",
"def add_item_to_basket(item_id)\n @session[:item_basket] << item_id unless @session[:item_basket].include? item_id\n end",
"def add_ingredients(arr_of_ingredient_ids)\n arr_of_ingredient_ids.each do |id|\n RecipeIngredient.find_or_create_by(\n recipe_id: self.id,\n ingredient_id: id\n )\n end\n end",
"def set_discounts_arr\n cart.discounts.where(kind: 'set').map { |set| set[:product_ids].push(set[:id].to_s + 's') }\n end",
"def add_axis_ids(params) # :nodoc:\n if ptrue?(params[:primary_axes])\n @axis_ids += ids\n else\n @axis2_ids += ids\n end\n end",
"def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def add_item(item_id)\n if line_item = line_items.find_by(item_id: item_id)\n line_item.quantity += 1\n else\n line_item = line_items.build(item_id: item_id)\n end\n line_item\n end",
"def update_for_ids\n update_for_items.map(&:package_branch).map(&:id)\n end",
"def add_item(item_id)\n line_item = self.line_items.find_by(item_id: item_id)\n if line_item\n line_item.quantity += 1\n else\n line_item=self.line_items.build(item_id: item_id)\n end\n line_item\n end",
"def add_multiple_food_items(items)\n items.each do |item|\n item['_id'] = FoodItem.create_id item[:api_key], item[:item_id]\n FoodItem.new_item item\n end\n items\n end",
"def ids\n (1..get_item_count).map do |index|\n get_item_identifier index\n end\n end",
"def samp_id_to_item_hash(items)\n samp_id_to_item_hash = Hash.new()\n items.each {|i| samp_id_to_item_hash[Item.find(i).sample_id] = i.id}\n return samp_id_to_item_hash\n end",
"def add(item)\n raise \"Not a MinisearchDocument object\" unless item.kind_of?(Document)\n items << item\n item.id\n end",
"def add_item(id, param, item_ids)\n add_command = \"#{param}_add\".to_sym\n node = @tinkit_class.get(id)\n node.__send__(add_command, item_ids)\n end",
"def atomic_array_add_to_sets\n @atomic_array_add_to_sets ||= {}\n end",
"def add_items(items)\n items = items.is_a?(Array) ? items : [items]\n\n load_uninitialized_groups\n load_aggregate\n\n redis.pipelined do\n @groups.each { |group| redis.zadd(single_group_key(group), to_zset_pairs(items)) }\n redis.zadd(aggregate_key, to_zset_pairs(items))\n end\n\n # TODO: clean this up\n keys = redis.pipelined do\n @groups.map { |g| redis.scan(0, match: format('%s:*%s*:%s', @group_name, g, @association), count: 500) }\n end.map(&:last).flatten.uniq\n\n # only get multi-group keys\n multi_group_keys = keys.select { |k| k.match(/#{@group_name}:.*\\..*:#{@association}/) }\n multi_group_keys.each do |mgk|\n constituent_keys = mgk.match(/#{@group_name}:(.*\\..*):#{@association}/).captures.first.split('.').map { |g| single_group_key(g) }\n redis.zunionstore mgk.gsub(\"#{redis.namespace}:\", ''), constituent_keys, aggregate: :max\n end\n end",
"def add_sellers_items_from_cart(items, seller)\n \t\tsellers_items = items.select {|item| item.product.user_id == seller}\n\t\tsellers_items.each do |item|\n\t\t\titem.cart_id = nil\n\t\t\titems << item\n\t\tend\n\tend",
"def add_items(items)\n add_items!(unknown_items(items))\n end",
"def add_question_items(items) #params is hash of type => value\n\t\tnew_q_items = create_question_items(items)\n\t\tadd_q_items(new_q_items)\n\tend",
"def add(item)\n self[to_identifier(item)] = item\n end",
"def add_items(items,coll)\n items.each {|item| coll.collection_highlight_items << CollectionHighlightItem.create(item_id:\"#{item}\")}\nend",
"def add_rows *rows\r\n matrix_a = self.to_a\r\n\r\n rows.each {|m|\r\n if m.column_size != self.column_size\r\n raise ArgumentError, \"number of columns should be identical\"\r\n end\r\n\r\n matrix_a += m.to_a\r\n }\r\n\r\n Matrix.rows(matrix_a)\r\n end",
"def add_to_receipt(*items)\n items.each {|item| $game_map.add_to_receipt(marw_format_item_array(item)) }\n end",
"def perform\n entries.each do |entry|\n @items << generate_item(entry)\n end\n add_ids\n end",
"def add_item(item)\n @in_batch << item\n @in_count += 1\n @in_size += @size_of_item_proc.call(item)\n end",
"def add_item(array, item)\n\tarray << item\nend",
"def update_ids\n self.task_id = @task_number\n self.order_id = @order_number\n end",
"def same_ids?(item_ids)\n all_item_ids.sort == item_ids.sort\n end",
"def add_item(hash_of_items, item, quantity=1)\n hash_of_items[item] = quantity\n hash_of_items\nend",
"def reserved_items=(reserved_items)\n reserved_items.each do |id, amount|\n item_reservations.build(:item_id => id, :amount => amount)\n end\n end",
"def add_item(item)\r\n \t@arr.push(item)\r\n end",
"def add!(items)\n\t\t\tcart = Cart.perform_request Cart.api_url(\"carts/#{self.id}\", {}), :patch,\n\t\t\t\t{ op: \"add\",\n\t\t\t\t\titems: items.map { |item| { product_id: item[:product_id], quantity: item[:quantity], variant_id: item[:variant_id] }\n\t\t\t\t}}, true\n\n\t\t\tif cart\n\t\t\t\tself.items = cart[\"data\"][\"items\"]\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\tend",
"def assigned_items=(array_hash)\n # Find new items (but no duplicates)\n self.added_items = []\n array_hash.each do |h|\n unless items.detect { |c| c.id.to_s == h[:id] } || self.added_items.detect { |f| f.id.to_s == h[:id] }\n c = !h[:id].blank? ? Item.find(h[:id]) : Item.new({:nav => self}) # FIXME possible to form hack\n c.attributes = h.reject { |k,v| k == :id } # input values, but don't try to overwrite the id\n self.added_items << c unless c.nil?\n end\n end\n # Delete removed items\n items.each do |c|\n if h = array_hash.detect { |h| h[:id] == c.id.to_s }\n c.attributes = h.reject { |k,v| k == :id }\n else\n c.destroy_association = 1\n end\n end\n end",
"def push *items\n @items.concat items\n end",
"def add_items(grocery_list, item, quantity)\n if grocery_list.include? item\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def add_items(grocery_list, item, quantity)\n if grocery_list.include? item\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def add_item(item, qty)\n for ele in @order do\n order_item = ele.keys[0]\n if order_item.name == item.name\n ele[order_item] += qty\n return \n end\n end\n @order.push({item => qty})\n \n end",
"def item_list_adder(list, items, quantity)\n list[items] = quantity\n list\nend",
"def << item\n @items << item\n end",
"def append_all(items)\n items.each { |item| append(item) }\n end",
"def increment_positions_on_all_items\n conditions = scope_condition\n increase_all! in_collection.where(conditions)\n end",
"def add_line_items_from(cart)\n\t\tcart.line_items.each do |item| \n\t\t\titem.cart_id = nil \n\t\t\tline_items << item \n\t\tend\n\tend",
"def add_item(list, item, quantity)\n #list = item.push\n list[item] = quantity.to_i\n list\nend",
"def agregar_alumnos\n @grupo = Grupo.find(params[:id])\n if request.get?\n @alumnos = Alumno.alumnos_sin_grupo(params[:buscar])\n end\n if request.put?\n unless params[:alumno_ids].nil?\n @alumnos = Alumno.find(params[:alumno_ids])\n for a in @alumnos\n @grupo.alumnos << a\n end\n flash[:notice] = \"Se agregaron los alumnos al grupo\" if @grupo.save\n end\n redirect_to grupo_path(@grupo)\n end\n end",
"def add_item(item)\n @get_items << item\n end",
"def associate_cart_line_items(the_cart)\n the_cart.line_items.each do |a_line_item|\n a_line_item.order_id = self.id\n a_line_item.save\n #self.line_items << a_line_item # LineItem row is saved, with our order_id\n end\n the_cart.order_id = self.id\n the_cart.save\n #self.save\n end",
"def add_axis_ids(params) # :nodoc:\n chart_id = 1 + @id\n axis_count = 1 + @axis2_ids.size + @axis_ids.size\n\n id1 = sprintf('5%03d%04d', chart_id, axis_count)\n id2 = sprintf('5%03d%04d', chart_id, axis_count + 1)\n\n if ptrue?(params[:primary_axes])\n @axis_ids << id1 << id2\n else\n @axis2_ids << id1 << id2\n end\n end",
"def map(items)\n self.push(:points => { :point => items})\n end",
"def add_items_from_cart(cart)\n\t\tcart.line_items.each do |item|\n\t\t\titem.cart_id = nil\n\t\t\tline_items << item\n\t\tend\n\tend",
"def add_products(products)\n # remove nil element and save bidimensional array.\n (@cart_products << [products].compact).flatten!\n end",
"def add_item\n #params[item_id]\n end",
"def add_q_items(question_items)\n\t\tself.items = \"\" if self.items.nil? or self.items.empty?\n\t\tquestion_items.each do |item| \n\t\t\tif self.items.empty?\n\t\t\t\tself.items += item.to_db\n\t\t\telse\n\t\t\t\tself.items += \"###\" + item.to_db\n\t\t\tend\n\t\tend\n\t\t# return question_items.inspect\n\t\t#self.save\n\t\treturn self.question_items # return new items to enable chaining\n\tend",
"def refresh_items\n rows.clear\n\n items.each do |item|\n rows << [item]\n end\n end",
"def add_one_vector(*matrices)\n matrices.map { |m|\n \tnum_rows = m.row_size\n \tnum_cols = m.column_size \t\n \tcolumns = [ Array.new(num_rows) { 1.0 } ]\n \tcolumns.push *(m.column_vectors.map { |v| v.to_a })\n \tMatrix.columns(columns)\n }\n end",
"def add_item(list_items, item_name, item_qty)\n if list_items.include?(item_name)\n list_items[item_name] += item_qty\n else\n list_items[item_name] = item_qty\n end\nend",
"def process_item(item_id)\n @item_id = item_id.to_i\n @batch_ids << @item_id unless precheck_clearancing_error\n end",
"def add_item(item, quantity, list)\n\tlist[item] = quantity\n\titem\nend",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n\t item.cart_id = nil\n \t line_items << item\n end\n end",
"def add_row(numbers)\n row = []\n row.push(numbers.split(\" \").map!{|j| j.to_i})\n row.flatten!\n @arr << row \nend",
"def add(item)\n @clxn[key_for(item)] = item\n end",
"def recordInAll id\n\t0.upto(@toRemove.length - 1) { |i|\n\t\t\t@toRemove[i] << id\n\t}\nend",
"def import_array(rows)\n raise ArgumentError, \"Can only work with arrays\" unless rows.is_a?(Array)\n if self.labels.size > 1 and rows.dimensions == 1\n self.add_item(rows)\n else\n # self.items = self.items + rows\n rows.each do |row|\n self.add_item(row)\n end\n end\n end",
"def call(change_set, collection_ids: [])\n change_set.member_of_collection_ids += collection_ids\n\n Success(change_set)\n end",
"def add(item)\n @items << item unless include?(item)\n end",
"def add_line_items_from_cart(cart)\n #for each lineitem added to the cart we remove the cart id and add to the order (loop)\n cart.line_items.each do |item|\n item.cart_id = nil\n line_items << item\n end\n end",
"def add_item(grocery_hash, new_item)\n new_item.each do |i|\n grocery_hash[i] += 1\n end\n grocery_hash\nend",
"def source_matrix_ids\n a = Set.new\n experiments.each { |experiment| a.merge(experiment.source_matrix_ids) }\n a.to_a\n end",
"def add_dataset_ids(taxonomies, tax_hash, dat_counts_seq)\n # puts \"=\" * 8\n # puts \"\\ntax_hash = \" + tax_hash.inspect\n # puts \"\\ndat_counts_seq = \" + dat_counts_seq.inspect\n \n taxonomies.each do |tax_obj|\n # dat_counts_seq_t = get_dat_counts_seq_by_t(tax_obj, dat_counts_seq)\n # puts \"\\ntax_obj = \" + tax_obj.inspect\n \n dat_counts_seq.each do |dat_cnt_seq_t| \n \n if (dat_cnt_seq_t[:taxonomy_id] == tax_obj[:id]) \n # (1..RANKS_AMOUNT).each do |n|\n # puts \"\\ndat_cnt_seq_t = \" + dat_cnt_seq_t.inspect\n # puts \"\\ntax_obj.attributes.values[1, n] = \" + tax_obj.attributes.values[1, RANKS_AMOUNT].inspect\n \n add_dat_id_knt_to_tax_hash(tax_hash, tax_obj.attributes.values[1, RANKS_AMOUNT], dat_cnt_seq_t)\n # end\n end\n end \n end\n return tax_hash\n end",
"def yale_nd_row_as_set i\n require 'set'\n yale_nd_row(i, :array).to_set\n end",
"def update\n @@all_items[@id] = self\n end",
"def add_item(equipment_model, _quantity = nil)\n return if equipment_model.nil?\n key = equipment_model.id\n items[key] = items[key] ? items[key] + 1 : 1\n end",
"def reset\n @item_ids = []\n end",
"def add_id_to_list(article, id_to_add)\n\n # first make sure not already requested\n array_to_check = return_array(article.request_array)\n if array_to_check.include? id_to_add.to_s\n flash[:notice] = \"You cannot request #{article.title} twice\"\n\n else\n new_request_array = article.request_array\n new_request_array << '-' + id_to_add.to_s\n article.update(request_array: new_request_array)\n\n # now check if id is added\n array_to_check = return_array(article.request_array)\n if array_to_check.include? id_to_add.to_s\n flash[:notice] = \"#{article.title} was added to your items requested list\"\n else\n flash[:notice] = \"You cannot request #{article.title}\"\n end\n\n end\n\n end",
"def add_product(item_id,user_id,line_item_type)\n\tcurrent_item = line_items.where(:item_id => item_id,:user_id=>user_id,:line_item_type => line_item_type).first\n item = Item.find(item_id)\n if line_item_type.to_i!=0\n -1\n elsif current_item\n if(item.availability<=current_item.quantity && current_item.line_item_type.to_i==0)\n -1\n else\n current_item.quantity += 1\n current_item\n end\n else\n if(item.availability<=0 && line_item_type.to_i==0)\n -1\n else\n current_item = LineItem.new(:item_id=>item_id,:user_id=>user_id,:line_item_type => line_item_type)\n line_items << current_item\n current_item\n end\n end\n end",
"def add_items_from_cart(cart)\n cart.order_items.all.each do |item|\n #self refers to the individual order\n self.order_items.new(product: item.product, quantity: item.quantity)\n end\n end",
"def add_item(item_id)\n self.add_or_create_line_item(item_id)\n end",
"def items_to_obj\n item_basket = []\n @items.each do |id, nbr|\n nbr.times do |i|\n item_basket << $data_items[id]\n end\n end\n item_basket\n end",
"def add_item(item,quantity,list)\n\tlist[item] = quantity\nend",
"def add_item(item, quantity, groceries_list)\n groceries_list[item] = quantity\nend",
"def addItem(item)\n @items << item\n end",
"def add_item_quantity (list, item, quantity=1)\nif list.include?(item)\nlist [item] += quantity\nelse list [item] = quantity\nend\nlist\nend",
"def add_items(item, quantity=0, grocery_list)\n grocery_list[item] = quantity\nend"
] |
[
"0.7084985",
"0.61166304",
"0.5945865",
"0.58580595",
"0.5762974",
"0.5694951",
"0.56937623",
"0.5691153",
"0.56829137",
"0.5665043",
"0.5558574",
"0.55539",
"0.5519956",
"0.5509171",
"0.55083656",
"0.5493018",
"0.54570323",
"0.5448069",
"0.54439",
"0.54159915",
"0.540044",
"0.5377556",
"0.5363102",
"0.53575957",
"0.53511983",
"0.53511655",
"0.53482497",
"0.5345987",
"0.53447497",
"0.5331999",
"0.5312157",
"0.5306492",
"0.5299713",
"0.52778906",
"0.524756",
"0.523299",
"0.52305865",
"0.5229535",
"0.52203476",
"0.5212734",
"0.5206083",
"0.52060574",
"0.5202291",
"0.51893604",
"0.5178539",
"0.5178424",
"0.5174",
"0.51368964",
"0.51281786",
"0.512656",
"0.51251185",
"0.51226956",
"0.5113274",
"0.5113274",
"0.509943",
"0.50946105",
"0.50939816",
"0.5091524",
"0.5082308",
"0.50673497",
"0.506671",
"0.5066576",
"0.50663483",
"0.5054492",
"0.50531906",
"0.5052659",
"0.5046984",
"0.50452536",
"0.504479",
"0.50407916",
"0.5029094",
"0.50151575",
"0.5011503",
"0.50042045",
"0.4994835",
"0.4994315",
"0.49938214",
"0.49902657",
"0.49866217",
"0.49800366",
"0.49788666",
"0.4978826",
"0.49671024",
"0.49662822",
"0.49651274",
"0.4964647",
"0.49643618",
"0.49616587",
"0.49614125",
"0.49590474",
"0.49585325",
"0.49548012",
"0.4953985",
"0.49513927",
"0.49489346",
"0.49488991",
"0.49440217",
"0.49432507",
"0.4942715",
"0.49419585"
] |
0.61113286
|
2
|
add a single item to a set of item_ids to the matrix
|
def add_single(set_id, item_id, other_item_ids)
raise "implemented in subclass"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_item item\n @items << item\n @@all_items << item\n end",
"def add_item(item_id)\n if line_item = line_items.find_by(item_id: item_id)\n line_item.quantity += 1\n else\n line_item = line_items.build(item_id: item_id)\n end\n line_item\n end",
"def add(item)\n self[to_identifier(item)] = item\n end",
"def add_item(item_id)\n line_item = self.line_items.find_by(item_id: item_id)\n if line_item\n line_item.quantity += 1\n else\n line_item=self.line_items.build(item_id: item_id)\n end\n line_item\n end",
"def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def add(item)\n raise \"Not a MinisearchDocument object\" unless item.kind_of?(Document)\n items << item\n item.id\n end",
"def add_item_to_cart(item_id)\n cart << item_id\n end",
"def add_item_to_basket(item_id)\n @session[:item_basket] << item_id unless @session[:item_basket].include? item_id\n end",
"def add_with_id item\n id = @id_gen.gen\n #here we automatically mix in the IdManaged protocol\n item.extend IdManaged\n item.id_manager = self\n item.pool_id =id\n @arr << item\n end",
"def all_item_ids\n [id] + item_ids\n end",
"def add_item(item)\n @in_batch << item\n @in_count += 1\n @in_size += @size_of_item_proc.call(item)\n end",
"def add_item(item)\n item = Item.find item unless item.is_a? Item\n $logger.debug{\"#{self} add #{item}\"}\n items << item\n inventory << item.id\n item\n end",
"def add(item)\n @clxn[key_for(item)] = item\n end",
"def add_item(hash_of_items, item, quantity=1)\n hash_of_items[item] = quantity\n hash_of_items\nend",
"def add_item(item, amount)\n # Check if the Entity already has that item\n # in the inventory. If so, just increase\n # the amount.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end",
"def add_item(item)\n fail \"An items id should initially be nil, but was #{item.id}\" unless (item.id == nil)\n fail \"An item must have an owner when added to the system.\" if (item.owner == nil)\n item.id = @item_id_count\n @items.store(@item_id_count, item)\n @item_id_count += 1\n end",
"def add_item(array, item)\n\tarray << item\nend",
"def add_item(item)\r\n \t@arr.push(item)\r\n end",
"def add_item(item, qty)\n for ele in @order do\n order_item = ele.keys[0]\n if order_item.name == item.name\n ele[order_item] += qty\n return \n end\n end\n @order.push({item => qty})\n \n end",
"def <<(item)\n item = ensure_type(Item, item)\n\n original_item = find_item(item)\n\n if original_item\n original_item.quantity += (item.quantity || 1)\n else\n store << item\n end\n end",
"def add_item(item_id)\n self.add_or_create_line_item(item_id)\n end",
"def add_item(item, price, quantity=1)\n @total += (price * quantity)\n @items.fill(item, @items.size, quantity)\n @last_transaction = {item => (price * quantity)}\n @last_qty = quantity\n end",
"def add_item(product_id)\n item = line_items.where(product_id: product_id).first\n if item.present?\n item.quantity += 1\n item\n else\n line_items.new(product_id: product_id)\n end\n end",
"def add_item(item, quantity, list)\n\tlist[item] = quantity\n\titem\nend",
"def add_item(item)\n if (@items.has_key?(item.id))\n #raise error here\n end\n @items[item.id] = item\n Event::ItemUpdateEvent.item_created item\n end",
"def addItem(item)\n @items << item\n end",
"def add(item)\n @data[item] = true\n self\n end",
"def add_set(set_id, item_ids)\n raise \"implemented in subclass\"\n end",
"def add_item(item)\n\t\t@items.push(item)\n\tend",
"def update(items)\n # clear!\n self.items.each do |i|\n number = items[i.id].blank? ? 1 : items[i.id].to_i <= 0 ? 1 : items[i.id]\n number.to_i < 99 ? i.quantity = number.to_i : i.quantity=99\n end\n # items.each { |id, quantity| add_items(id, quantity) }\n end",
"def add_item(item, amount = 1)\n\n # Increase the amount if the item already exists in the inventory.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n\n # If not already in the inventory, push a couple.\n @inventory.push(C[item, amount])\n end",
"def add_item(item)\n @get_items << item\n end",
"def add_item(id, param, item_ids)\n add_command = \"#{param}_add\".to_sym\n node = @tinkit_class.get(id)\n node.__send__(add_command, item_ids)\n end",
"def << item\n @items << item\n end",
"def add(item)\n @items << item unless include?(item)\n end",
"def add_item(item, amount = 1)\n\n # Increase the amount if the item already exists in the inventory.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end",
"def\tinsert_item!(previous_item_id, item_id)\n if previous_item_id\n index = self.items_positions.index(previous_item_id.to_i)\n \t self.items_positions.insert(index + 1, item_id)\n else\n self.items_positions.unshift(item_id)\n end\n self.save\n end",
"def <<(item)\n add!(item)\n end",
"def add_to_inventory(item)\n @inventory.push(item)\n update\n end",
"def add_item\n #params[item_id]\n end",
"def add_dimension_to_items\n new_items = Array.new\n items.each do |i|\n Rails.logger.debug(\"i[:product_id] is #{i[:product_id]}\")\n p = CachedProduct.find_by_product_id(i[:product_id])\n i = i.merge({:height=>p.height, :width=>p.width, :length =>p.length})\n new_items << i\n end\n new_items\n end",
"def add_item!(list, item, qty=1)\r\n list[item] = qty\r\n list\r\nend",
"def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end",
"def add_item(array, item)\n\tarray.push(item)\nend",
"def add_item(groccery_items, item)\n groccery_items[item] = 1\n p groccery_items\nend",
"def update\n @@all_items[@id] = self\n end",
"def <<(item)\n @items << item\n end",
"def add_item(list_items, item_name, item_qty)\n if list_items.include?(item_name)\n list_items[item_name] += item_qty\n else\n list_items[item_name] = item_qty\n end\nend",
"def add_item(item, list, quantity)\n list[item] = quantity\nend",
"def add_item(item)\n @cart_items[item] = @cart_items[item].to_i + 1\n end",
"def add_item(d_item, i, j)\n result = @tiles[j][i].add_item(d_item)\n #3 cases:\n #If an item is already in dest box:\n # 1) if they merge completely, change that item (dispose this one)\n # 2) if they do not fully merge, bounce this item back to original i,j\n #If no item already present:\n # 3) move this item to box\n case result\n when 1\n d_item.dispose\n when 2\n #i and j stay the same, restore items\n when 3\n rec = @grid_viewport.rect\n vp = Viewport.new(rec.x, rec.y, rec.width, rec.height)\n vp.z = d_item.z\n d_item.change_viewport(vp)\n #@items[d_item.j*@gw+d_item.i] = d_item.item.to_array\n end\n return result\n end",
"def assignIds(items)\r\n\titems.each_with_index {|item, index| item['id'] = index}\r\nend",
"def <<(item)\n @batch << item\n end",
"def add_item(equipment_model, _quantity = nil)\n return if equipment_model.nil?\n key = equipment_model.id\n items[key] = items[key] ? items[key] + 1 : 1\n end",
"def add_item(list, item, quantity)\n #list = item.push\n list[item] = quantity.to_i\n list\nend",
"def put(item)\n @inv.push(item)\n end",
"def add_to_inventory(item)\n @items << item\n equip(item)\n items_weight\n end",
"def add_item_to_order(id)\n return if @items[id] <= 0\n\n socket = GameData::Item[id].socket\n get_order(socket) << id unless get_order(socket).include?(id)\n end",
"def add_item(list, item, qty)\n list[item] = qty\n list\nend",
"def add_item(id, nb = 1)\n return if @locked\n return remove_item(id, -nb) if nb < 0\n\n id = GameData::Item[id].id\n @items[id] ||= 0\n @items[id] += nb\n add_item_to_order(id)\n $quests.add_item(id)\n end",
"def <<(item)\n add_item(item)\n end",
"def <<(item)\n add(item)\n self\n end",
"def add_to_cart(item, quantity=1)\n i = self.items.index { |x| x.product == item }\n \n end",
"def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n\n order_item = order.items.find_or_create_by(\n product_id: product_id\n )\n\n order_item.price = product.price\n order_item.quantity = 1\n order_item.save\n end",
"def add_item(item,quantity,list)\n\tlist[item] = quantity\nend",
"def add_item(item, quantity = 1)\n order_item = self.order_items.find_by item: item, price: item.price\n if order_item.is_a? OrderItem\n order_item.add quantity\n else\n self.order_items.create item: item, price: item.price, quantity: quantity\n end\n recalculate!\n end",
"def add(input_list, item, quantity)\n input_list[item] = quantity\nend",
"def process_item(item_id)\n @item_id = item_id.to_i\n @batch_ids << @item_id unless precheck_clearancing_error\n end",
"def update_qty(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def add_item (list, item, qty)\n list[item]=qty\nend",
"def add_item(list, item, quantity=0)\n\tlist[item] = quantity\n\tlist\nend",
"def add_item_quantity (list, item, quantity=1)\nif list.include?(item)\nlist [item] += quantity\nelse list [item] = quantity\nend\nlist\nend",
"def add_item(list, item, quantity)\n\n\tlist[item] = quantity\n\tlist\n\nend",
"def add(item)\n save do\n items.push(Item.new(item)).last\n end\n end",
"def update_item_quantity(hash_of_items, item, quantity)\n hash_of_items[item] = quantity\n hash_of_items\nend",
"def update(list, item, qty)\n add_item(list, item, qty)\nend",
"def add_item(new_item)\n item = Item.new(new_item)\n @items.push(item)\n end",
"def add_item(list, new_item, qty=1)\n list[new_item] = qty\nend",
"def add_item(list, item, quantity)\n list[item] = quantity\n list\nend",
"def add_or_create_line_item(item_id)\n if line_item = self.line_items.find_by(item_id: item_id)\n line_item.increment\n line_item\n else\n LineItem.new(cart_id: self.id, item_id: item_id)\n end\n end",
"def add_item(item)\n @items[item.name] ||= []\n @items[item.name] << item\n end",
"def add!(item)\n @ckh[item.class][item] = item\n end",
"def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend",
"def add_item(current_list, item_added, quantity)\n current_list[item_added] = quantity\n current_list\nend",
"def add_or_update_item(list, item, quantity = 1)\n list[item] = quantity\n list\nend",
"def add_item(hash, item, quantity)\r\n\thash.store(item, quantity)\r\n\thash\r\nend",
"def add_items(grocery_list, item, quantity)\n if grocery_list.include? item\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def add_items(grocery_list, item, quantity)\n if grocery_list.include? item\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend",
"def add_item(list, item, quantity)\n list[item] = quantity\nend",
"def add_item(list, item, quantity)\n list[item] = quantity\nend",
"def add_item(item, quantity, list)\n\t# steps: \n\t# if the item is already in the list\n\tif list[item.to_sym] \n\t\t# add to the quantity\n\t\t#list[item.to_sym] = list[item.to_sym] + quantity\n\t\tlist[item.to_sym] += quantity\n\t# otherwise\n\telse\n\t\t# make a new key with the input quantity\n\t\tlist[item.to_sym] = quantity\n\tend\n\t# output:\n\t\t# updated list\n\tlist\nend",
"def add item\n self[index item] = item if check item\n# check item ? super : free key # delete key\n end",
"def add_item(item, price, *quantity)\n q = quantity.join(\"\").to_i\n if q > 1\n q.times do\n @items.push(item)\n end\n else\n @items.push(item)\n end\n if q > 1\n price_with_quantity = q * price\n @last = price_with_quantity\n @total += price_with_quantity\n else\n @last = price\n @total += price\n end\n\n end",
"def add_item(item, quantity, groceries_list)\n groceries_list[item] = quantity\nend",
"def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n order_item = order.items.find_or_initialize_by(\n product_id: product_id,\n price: product.price,\n quantity: quantity\n )\n\n order_item.save!\n end",
"def add_or_update_item(list, item, quantity=1)\n\tlist[item] = quantity\nend",
"def add_value(item)\n array.push(item)\n end",
"def add(item)\n self.items.push(item)\n if self.min_price > item.price.to_i\n self.min_price = item.price.to_i\n end\n self.owners.push(item.owner)\n self.owners = self.owners.uniq\n self.quantity += item.quantity\n self\n end",
"def add_item(list, item, quant)\n list[item] = quant\nend"
] |
[
"0.66346425",
"0.660644",
"0.65769356",
"0.6545511",
"0.63007885",
"0.6297965",
"0.62868166",
"0.62660927",
"0.6261452",
"0.62398696",
"0.621355",
"0.616932",
"0.61385965",
"0.612757",
"0.61253935",
"0.60932016",
"0.60859704",
"0.6074837",
"0.60625565",
"0.606239",
"0.6042797",
"0.6039995",
"0.6021129",
"0.599788",
"0.59950256",
"0.5991521",
"0.59894687",
"0.5985554",
"0.5980036",
"0.59699225",
"0.5968994",
"0.596101",
"0.5956885",
"0.59518784",
"0.5937917",
"0.5934331",
"0.5932641",
"0.5931033",
"0.5930045",
"0.59162664",
"0.5884278",
"0.58790165",
"0.5871524",
"0.586508",
"0.5855041",
"0.5854447",
"0.5844532",
"0.58423275",
"0.5840401",
"0.5837712",
"0.5836296",
"0.58313197",
"0.5823164",
"0.5819451",
"0.5814526",
"0.58142257",
"0.581373",
"0.58062387",
"0.5790076",
"0.57895154",
"0.57886684",
"0.57865006",
"0.5785036",
"0.57799697",
"0.57771784",
"0.57728815",
"0.57716805",
"0.57716304",
"0.5771239",
"0.5755921",
"0.5754508",
"0.5748727",
"0.57463545",
"0.5746153",
"0.5734991",
"0.5734368",
"0.5731292",
"0.57267106",
"0.5719224",
"0.57129467",
"0.5712374",
"0.57104343",
"0.5710341",
"0.5708381",
"0.57076097",
"0.5706658",
"0.5699485",
"0.5699485",
"0.56962985",
"0.56945026",
"0.56945026",
"0.56917846",
"0.56859815",
"0.5682034",
"0.56796134",
"0.5676285",
"0.5672534",
"0.56697625",
"0.566843",
"0.56671613"
] |
0.6693372
|
0
|
calculate the similarity between item1 and item1 (0.01.0)
|
def similarity(item1, item2)
raise "implemented in subclass"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def similarity_by_euclidean_for_items(item1, item2, list)\n common_users = find_common_users(item1, item2, list)\n \n result = 0.0\n return result if common_users.size < 1\n \n common_users.each do |u|\n result += (u.rating_for(item1.id) - u.rating_for(item2.id))**2\n end\n result = 1 / (1 + result)\n # result = 1 / (1 + Math.sqrt(result)) TODO: make tests to see the difference\n end",
"def similarity_for_items(item1, item2, list = nil)\n # cache disabled\n # cached_sim = get_cached_similarity_for item1, item2\n # return cached_sim if cached_sim\n sim = 0.0\n case SIMILARITY_METHOD\n when 'euclidean'\n sim = similarity_by_euclidean_for_items item1, item2, list\n when 'pearson'\n sim = similarity_by_pearson_for_items item1, item2, list\n when 'jaccard'\n sim = similarity_by_jaccard_for_items item1, item2, list\n end\n sim.round(5)\n #set_similarity_cache_for item1, item2, sim\n end",
"def similarity_by_pearson_for_items(item1, item2, list)\n common_users = find_common_users(item1, item2, list)\n size = common_users.size\n \n return 0 if size < 1\n \n i1_sum_ratings = i2_sum_ratings = i1_sum_sq_ratings = i2_sum_sq_ratings = sum_of_products = 0.0\n common_users.each do |user|\n i1_rating = user.rating_for item1.id\n i2_rating = user.rating_for item2.id\n \n # Sum of all ratings by users\n i1_sum_ratings += i1_rating\n i2_sum_ratings += i2_rating\n \n # Sum of all squared ratings by users\n i1_sum_sq_ratings += i1_rating**2\n i2_sum_sq_ratings += i2_rating**2\n \n # Sum of product of the ratings that given to the same item\n sum_of_products += i1_rating * i2_rating\n end\n \n # Long lines of calculations, see http://davidmlane.com/hyperstat/A56626.html for formula.\n numerator = sum_of_products - ((i1_sum_ratings * i2_sum_ratings) / size)\n denominator = Math.sqrt((i1_sum_sq_ratings - (i1_sum_ratings**2) / size) * (i2_sum_sq_ratings - (i2_sum_ratings**2) / size))\n \n result = denominator == 0 ? 0 : (numerator / denominator)\n \n result = -1.0 if result < -1\n result = 1.0 if result > 1\n result\n end",
"def similarities_for(item1)\n # return => [ [\"item23\", 0.6], [\"item42\", 0.23], (...) ]\n raise \"implemented in subclass\"\n end",
"def similarity (user1, user2)\n\t\tuser1= user1.to_s\n\t\tuser2 = user2.to_s\n\t\tuser1_index = @user_rating_index[user1]\n\t\tuser2_index = @user_rating_index[user2]\n\t\ttotal_diff = 0\n\t\tcounter=0\n\n\t\tuser1_index.each_key do |movie|\n\t\t\tif user2_index.has_key? (movie) \n\t\t\t\tdiff = (user1_index[movie].to_i - user2_index[movie].to_i).abs #abs value difference to be summed then divided by total\n\t\t\t\ttotal_diff += diff\n\t\t\t\tcounter+=1\n\t\t\tend\n\t\tend\n\t\tif counter == 0\n\t\t\treturn 5.0\n\t\tend\n\t\treturn (total_diff.to_f/counter) \n\tend",
"def similarity u1, u2\n u1_r = @usr_rating[u1]\n u2_r = @usr_rating[u2]\n common = u1_r.keys & u2_r.keys\n\n mean_diff = 0\n common.each do |mv|\n mean_diff += diff(u1_r[mv], u2_r[mv]).to_f / common.length\n end\n return ((5 - mean_diff)/5).round(2)\n end",
"def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += (5-(simil1.to_i - simil2.to_i).abs)/5.0\n\t\tend\n\t\tbegin \n\t\t\treturn (simil * 1.0/movie_in_common.size)\n\t\trescue\n\t\t\treturn 0.0\n\t\tend\n\tend",
"def similarity(user_a, user_b)\n av_a, av_b = user_average_rating(user_a), user_average_rating(user_b)\n sum_both, sum_a, sum_b = 0, 0, 0\n\n rating_a = Review.where(user_id: user_a.id)\n\n rating_a.each do |rating_a|\n if rating_b = Review.where(user_id: user_b.id, item_id: rating_a.item_id).first\n sum_a = sum_a + ( (rating_a.rating - av_a)**2 )\n sum_b = sum_b + ( (rating_b.rating - av_b)**2 )\n sum_both = sum_both + ( (rating_a.rating - av_a) * (rating_b.rating - av_b) )\n end\n end\n\n sum_both / ( (Math.sqrt(sum_a)) * (Math.sqrt(sum_b)) )\n end",
"def calculate_similarity(movie_in_common)\n simil = 0.0\n movie_in_common.each do |x|\n #find index of the common movie/ratings\n rating1 = cache_1[1][cache_1[0].index(x)]\n rating2 = cache_2[1][cache_2[0].index(x)]\n simil += (5-(rating1.to_i - rating2.to_i).abs)/5.0\n end\n return simil\n end",
"def similarity(user1, user2) \n movie_in_common = find_common_movies(user1,user2)\n\n if movie_in_common.empty?\n return 0.0\n end\n simil = calculate_similarity(movie_in_common)\n return (simil/movie_in_common.size).round(2)\n end",
"def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += 1.0/((simil1.to_i - simil2.to_i).abs + 1) # 1/(rating difference + 1)\n\t\tend\n\t\treturn simil.round(2)\n\tend",
"def similarity(u1,u2)\n\t\tsimilarity=0\n\t\twatched_u1=@db.get_movie_by_user(u1,:base)\n\t\twatched_u2=@db.get_movie_by_user(u2,:base)\n\t\twatched_u1.each do |movie,rate|\n\t\t\tif watched_u2.has_key?(movie)\n\t\t\t\tsimilarity+=5-(watched_u2[movie].to_i-watched_u1[movie].to_i).abs\n\t\t\tend\n\t\tend\n\t\treturn similarity\n\tend",
"def similarity(user1, user2)\n user1_rate = compute_user_rate(user1)\n user2_rate = compute_user_rate(user2)\n dot_product = user1_rate.reduce(0) { |sum, (k, v)| sum + v * user2_rate[k] }\n user1_magnitude = compute_magnitude(user1_rate)\n user2_magnitude = compute_magnitude(user2_rate)\n dot_product / (user1_magnitude * user2_magnitude)\n end",
"def get_cached_similarity_for(item1, item2)\n @cached_similarities[\"#{item1}_#{item2}\"] || @cached_similarities[\"#{item2}_#{item1}\"]\n end",
"def similarity(user1,user2)\n #retrieves the recorded related to user1 and user2\n #then create an array which contains the movie ids which both user have rated them\n u1=@users[user1]\n u2=@users[user2]\n u1_movies=u1.collect{|itm| itm[1]}\n u2_movies=u2.collect{|itm| itm[1]}\n common_movies=u1_movies & u2_movies\n \n if common_movies.empty?\n return 0\n end\n \n #Similarity is defined as the average of (4 - distance between rating of user 1 and 2) for movie id\n #which both usres have rated\n similarity=0.0\n common_movies.each do |movie|\n rating1=u1.rassoc(movie)[2]\n rating2=u2.rassoc(movie)[2]\n similarity+=4-(rating1-rating2).abs\n end\n return similarity/common_movies.size\n end",
"def similarity(user1, user2)\n if @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n sim_rating = 0\n user1ratings = @userdata[user1.to_s.to_sym]\n user2ratings = @userdata[user2.to_s.to_sym]\n user2ids = []\n user2ratings.each{ |id, rating| user2ids.push id }\n user1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n return sim_rating\n else\n puts \"User not found\"\n return nil\n end\n end",
"def similarity(m1, m2)\n if m1.is_a?(SparseVector) && m2.is_a?(SparseVector)\n m1.cosine(m2)\n elsif m2.size == m1.size\n a_dot_b = 0.0\n a_sq_sum = 0.0\n b_sq_sum = 0.0\n m1.each2(m2) do |x1,x2|\n a_dot_b = x1 * x2\n a_sq_sum += x1 * x1\n b_sq_sum += x2 * x2\n end\n a_dot_b / ( Math.sqrt(a_sq_sum) * Math.sqrt(b_sq_sum) )\n else\n 0.0\n end\n end",
"def similarity(user1, user2)\n\t\tif @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n\t\t\tsim_rating = 0\n\t\t\tuser1ratings = @userdata[user1.to_s.to_sym]\n\t\t\tuser2ratings = @userdata[user2.to_s.to_sym]\n\t\t\tuser2ids = []\n\t\t\tuser2ratings.each{ |id, rating| user2ids.push id }\n\t\t\tuser1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n\t\t\t\t\treturn sim_rating\n\t\telse\n\t\t\tputs \"User not found\"\n\t\t\treturn nil\n\t\tend\n\tend",
"def similarity(user1_id, user2_id)\n raise 'At least one user specified does not exist.' unless @movie_database.users_include?(user1_id, user2_id)\n user_common_movies = @movie_database.movies_in_common(user1_id, user2_id)\n\n return 0.0 if user_common_movies.empty? # most common case\n\n rating_sum = user_common_movies.inject(0) { |sum, movie| sum + user_rating_difference(movie, user1_id, user2_id) }\n max_rating_sum = 4 * user_common_movies.length\n 100.0 - (rating_sum.to_f / max_rating_sum.to_f * 100.0).round(1)\n end",
"def distance item\n if !item.is_a? Item\n raise \"Cannot calculate distance to object that is not an item.\"\n end\n\n disance = 0 if self == item\n id = ItemDistance.where({\n :item1_id => self.id,\n :item2_id => item.id,\n }).first\n\n if id.nil?\n id = ItemDistance.new({\n :item1_id => self.id,\n :item2_id => item.id,\n })\n else\n # An hour DB cache\n distance = id.distance if Time.now - id.updated_at < 60*60\n end\n\n if distance.nil?\n # this in reality is supposed to be sum(each dimmension (b-a)^2) but\n # because the values are all one or zero, we can do this\n diff = (self.voters.to_set - item.voters.to_set).count\n distance = Math.sqrt(diff)\n\n id.distance = distance\n id.save\n end\n\n return distance\n end",
"def similarity(another)\n return 0.0 if @type != another.type\n similarity = Resource.compare(before, another.after) * 0.8\n similarity += @name == another.name ? 0.2 : 0\n similarity\n end",
"def similarity(user1, user2, user_rates)\n user1_rate = user_rates[user1]\n user2_rate = user_rates[user2]\n dot_product = user1_rate.reduce(0) { |sum, (k, v)| sum + v * user2_rate[k] }\n user1_magnitude = compute_magnitude(user1_rate)\n user2_magnitude = compute_magnitude(user2_rate)\n dot_product / (user1_magnitude * user2_magnitude)\n end",
"def similarity(user1, user2)\n\t\tall_movie = @userhash[user1].map{|e| e[0]} | @userhash[user2].map{|e| e[0]}\n\t\tshared_movie = @userhash[user1].map{|e| e[0]} & @userhash[user2].map{|e| e[0]}\n\t\tscoretotal = 0\n\t\tshared_movie.each do |movie|\n\t\t\tscoretotal += (@moviehash[movie][user1] - @moviehash[movie][user2]).abs\n\t\tend\n\t\tnumdiff = all_movie.length-shared_movie.length\n\t\tsimilarity = (1-(scoretotal+numdiff*4.0)/all_movie.length/5.0).round(2)\n\tend",
"def pearson_similarity (u1,u2)\n\t\tsimilarity = @train_data[u1].movie_and_rating.keys & @train_data[u2].movie_and_rating.keys\n\t\tif similarity.empty?\n\t\t\treturn 0\n\t\tend\n\t\tsum_1 = 0\n\t\tsum_2 = 0\n\t\tsum_1_sq = 0\n\t\tsum_2_sq = 0\n\t\tproduct = 0\n\n\t\tsimilarity.each do |mov|\n\t\t\tsum_1 += @train_data[u1].return_rating(mov)\n\t\t\tsum_1_sq += @train_data[u1].return_rating(mov)**2\n\t\t\tsum_2 += @train_data[u2].return_rating(mov)\n\t\t\tsum_2_sq += @train_data[u2].return_rating(mov)**2\n\t\t\tproduct += @train_data[u1].return_rating(mov)*@train_data[u2].return_rating(mov)\n\t\tend\n\n\t\tnumerator = product - (sum_1*sum_2/similarity.length)\n\t\tdenom = Math.sqrt((sum_1_sq-(sum_1**2)/similarity.length)*(sum_2_sq-(sum_2**2)/similarity.length))\n\n\t\tif denom == 0 \n\t\t\treturn 0\n\t\tend\n\t\treturn numerator/denom\n\tend",
"def similarity(user1, user2)\n @user_list[user1].similarity(@user_list[user2])\n end",
"def recalculate_similarity\n query_one = Like.select(:user_id).where(product_id: product_one_id).order('user_id asc').to_sql\n query_two = Like.select(:user_id).where(product_id: product_two_id).order('user_id asc').to_sql\n user_ids_one = ActiveRecord::Base.connection.execute(query_one).column_values(0)\n user_ids_two = ActiveRecord::Base.connection.execute(query_two).column_values(0)\n intersection = (user_ids_one & user_ids_two).size\n union = (user_ids_one | user_ids_two).size\n \n if intersection == 0 || union == 0\n self.similarity = 0\n else\n self.similarity = intersection.to_f / union.to_f\n end\n self.save\n end",
"def similarity(user1, user2)\n\n user1 = user1.to_s\n user2 = user2.to_s\n \n weight_num = 0.20\n weight_movies = 0.40\n weight_rating = 0.40\n \n user1_num_movies = @user_database[user1].length\n user2_num_movies = @user_database[user2].length\n score_num_movies = ((user1_num_movies + user2_num_movies).to_f / ([user1_num_movies, user2_num_movies].max * 2)) * 100.0 \n \n #hash consists of movieID(string) => rating(float)\n user1_hash = {}\n user2_hash = {} \n @user_database[user1].each do |movieID, rating, time|\n user1_hash[movieID] = rating.to_f\n end\n @user_database[user2].each do |movieID, rating, time|\n user2_hash[movieID] = rating.to_f\n end \n common_movies = user1_hash.keys & user2_hash.keys\n num_common_movies = common_movies.length\n score_common_movies = (num_common_movies / [user1_hash.keys.length, user2_hash.keys.length].max ) * 100.0\n \n rating_difference = 0\n common_movies.each do |movieID|\n rating_difference += (user1_hash[movieID] - user2_hash[movieID]).abs\n end\n \n #in case of num_common_movies being 0, then penalize the rating score by 100\n if num_common_movies == 0\n avg_rating_diff = 100 \n else\n avg_rating_diff = rating_difference / num_common_movies.to_f\n end\n \n score_rating = 100 - avg_rating_diff\n \n similarity_score = (weight_num * score_num_movies + weight_movies * score_common_movies + weight_rating * score_rating)\n \n return similarity_score\n \n end",
"def similarity(user1, user2)\n count = 0\n similar = 0\n #to make a shorter comparison, we loop on the shorter movie list\n if movies(user1).length > movies(user2).length\n u1 = user2\n u2 = user1\n else\n u1 = user1\n u2 = user2\n end\n\n @usermap[u1].each do |m1, r1|\n #if user1 and user2 have both rated one movie m, we compare the rating they made\n #and the difference bewteen these two ratings indicates their similarity. The smaller\n #the difference is, the more similar these users are.\n if @usermap[u2].has_key?(m1)\n count += 1\n similar += 5 - (r1 - @usermap[u2][m1]).abs\n end\n end\n\n if count == 0\n 0\n else\n #we calculate the average to get a more convincing similarity constant\n similar/count.to_f\n end\n end",
"def calc_similarity(query, doc)\n tokens = Set.new(query.keys + doc.keys)\n\n a = Vector.elements(tokens.map { |n| query[n] || 0 }, false)\n b = Vector.elements(tokens.map { |n| doc[n] || 0 }, false)\n\n return a.inner_product(b) / (a.magnitude * b.magnitude)\n end",
"def similarity(other_user)\n return 0 if common_bands(other_user).empty?\n\n 1 / (1 + cumulative_euclidean_distance(other_user))\n end",
"def find_similarity(user1Hash, user2Hash)\n similarityValue = -1 # If no common movies watched, return -1\n countMovies = 0.0\n user1Hash.each do |movie, rating|\n if user2Hash.has_key?(movie)\n countMovies += 1\n similarityValue += 4 - (rating.to_i - user2Hash[movie].to_i).abs \n end\n end\n similarityValue != -1 ? (similarityValue + 1) / countMovies : similarityValue\n end",
"def similarity_score(word_1, word_2)\n raise NotImplementedError # TODO\nend",
"def similarity(user1,user2)\n\t\tsim = 0\n\t\tfirst_user = @user_set[\"#{user1}\"].sort_by{|k, v| k.to_i}.to_h\n\t\tsecond_user = @user_set[\"#{user2}\"].sort_by{|k, v| k.to_i}.to_h\n\t\tin_common = first_user.keys & second_user.keys\n\t\tin_common.each do |movie|\n\t\t\tif (first_user[movie].to_i.between?(second_user[movie].to_i-1, second_user[movie].to_i+1))\n\t\t\t\tsim += 1\n\t\t\tend\n\t\tend\n\t\treturn sim\n\tend",
"def similarity(user1, user2)\n similar_movies_avg = []\n\n #fill in user1_data and user2_data\n #find similar watched movies, remove differences in both lists\n $unique_user_data[user1.to_i - 1].each_key {|movieId, rating|\n if $unique_user_data[user2.to_i - 1].has_key?(movieId)\n similar_movies_avg.push((rating.to_i - $unique_user_data[user2.to_i - 1][movieId].to_i).abs)\n end\n }\n #find average\n return similar_movies_avg.inject{ |sum, el| sum + el }.to_f / similar_movies_avg.size\n end",
"def similarities u1\n sims = Hash.new()\n (@usr_rating.keys - [u1]).each do |u2|\n sims.store(u2, similarity(u1, u2))\n end\n return sims\n end",
"def compute_sequence_similarity(ref_sequence, other_sequence)\n total = Repositext::Utils::ArrayDiffer.diff(ref_sequence, other_sequence)\n same = total.find_all { |e| '=' == e.action }\n return 1.0 if same.length == total.length\n return 0.0 if 0 == total.length\n same.length / total.length.to_f\n end",
"def similarity (u1, u2)\r\n\t\t# make sure data is loaded first\r\n\t\tif @user_ratings.nil?\r\n\t\t\tputs \"data has not been loaded\"\r\n\t\t\treturn 0\r\n\t\telse\r\n\t\t\t# make sure users exist before calculating similarity\r\n\t\t\tif check(u1, u2)==1\r\n\t\t\t\tu1_rate_hash = @user_ratings[u1]\r\n\t\t\t\tu2_rate_hash = @user_ratings[u2]\r\n\t\t\t\t# merge the two hashes since that produces a set \r\n\t\t\t\t# then can get the length to get # of unique movies the two users have rated (in case users have not ranked all the same movies)\r\n\t\t\t\tnum_total_movies = u1_rate_hash.merge(u2_rate_hash).keys.length\r\n\t\t\t\t# make combination of all movies that both users ahve seen\r\n\t\t\t\tboth_seen = u1_rate_hash.keys & u2_rate_hash.keys\r\n\t\t\t\tsum = 0\r\n\t\t\t\t# loops throught the movies both users have seen and takes the difference between the ratings\r\n\t\t\t\t# this is subtracted from 4 (the max difference) to give an inverse on the difference if they have the same rating then 4 is added to the sum\r\n\t\t\t\tboth_seen.each do |id|\r\n\t\t\t\t\tsum +=4 - (u1_rate_hash[id] - u2_rate_hash[id]).abs\r\n\t\t\t\tend\r\n\t\t\t\t# the formula for similarity\r\n\t\t\t\t# the # movies both have seen /the number of unique movies both have seen\r\n\t\t\t\t# this gives a percentage of similarity between the movies both users have rated\r\n\t\t\t\t# ensures similarity in preference of movies not just ratings\r\n\t\t\t\t# those who have more similar taste in movies ranked will have thier percentage of similarity affected less as it will be close to 1\r\n\t\t\t\t# where those who have disparate tastes in music will be closer to 0 reducing the total score and reflecting their difference in tastes\r\n\t\t\t\t# the sum is divided by 0 to normalize it(if all ranks are the same the sum comes to 4*number of movies both seen \r\n\t\t\t\t# and needs to be removed to get a # below #movies both seen)\r\n\t\t\t\t# divide by total number of movies seen to get a percentage of similarity of ranks\r\n\t\t\t\t# +0.0 TO TURN INTO DECIMALS *100 TO GET THE PERCENT\r\n\t\t\t\tn =((0.0+both_seen.length)/(num_total_movies))*(((0.0+sum)/4)/both_seen.length)*100\r\n\t\t\t\tif n.nan?\r\n\t\t\t\t\tn = 0.0\r\n\t\t\t\tend\r\n\t\t\t\treturn n\r\n\t\t\telse\r\n\t\t\t\treturn 0\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def similarity logger_a, logger_b, force = false\n return unless logger_a.is_logger? || logger_b.is_logger?\n res = Tempora.redis.hget(Tempora::KeyMapper.similarity_key(logger_a), \"#{logger_b.class}::#{logger_b.id}\")\n return res.to_f if res && !force\n diff = get_shared_items logger_a, logger_b\n return -1 if diff.nil? || diff.empty?\n avg_rating_a = average_rating_for logger_a, diff\n avg_rating_b = average_rating_for logger_b, diff\n items_a = get_all_items_for logger_a\n items_b = get_all_items_for logger_b\n items_a = items_a.select{ |k,_| items_b.include? k }\n items_b = items_b.select{ |k,_| items_a.include? k }\n\n if items_a.values.sum.to_f / items_a.length.to_f == avg_rating_a &&\n items_b.values.sum.to_f / items_b.length.to_f == avg_rating_b\n return 1\n end\n\n numerator = 0\n denominator_a = 0\n denominator_b = 0\n items_a.keys.each do |k|\n numerator += (items_a[k].to_f - avg_rating_a) * (items_b[k].to_f - avg_rating_b)\n denominator_a += (items_a[k].to_f - avg_rating_a)**2\n denominator_b += (items_b[k].to_f - avg_rating_b)**2\n end\n return -1 if numerator == 0 && (denominator_a <= 0 || denominator_b <= 0) # or -1. yeah.\n (numerator / (Math.sqrt(denominator_a) * Math.sqrt(denominator_b))).tap do |res|\n Tempora.redis.hset(Tempora::KeyMapper.similarity_key(logger_a), \"#{logger_b.class}::#{logger_b.id}\", res)\n end\n end",
"def rating_for(active_user, item)\n return unless @similarity_matrix\n \n weighted_similar_items = similarity_sum = 0\n\n sim_objs = @similarity_matrix[item.id]\n sim_objs.each do |obj|\n active_user_rating = active_user.rating_for obj[:id]\n next unless active_user_rating\n weighted_similar_items += active_user_rating * obj[:similarity].abs\n similarity_sum += obj[:similarity].abs\n end\n \n return nil if weighted_similar_items == 0 or similarity_sum == 0\n \n rating = weighted_similar_items / similarity_sum\n rating = 5 if rating > 5\n rating = 1 if rating < 1\n rating\n end",
"def rms()\n diffSquare = @list.collect {|item| (item[:prediction] - item[:rating]) ** 2}\n Math.sqrt(sum(diffSquare) / diffSquare.length)\n end",
"def similarity(user1, user2)\n user1Hash = @allUsersHash[user1]\n user2Hash = @allUsersHash[user2]\n return \"ERROR: USER ID #{user1} is not in the database\" if user1Hash.empty?\n return \"ERROR: USER ID #{user2} is not in the database\" if user2Hash.empty?\n find_similarity(user1Hash, user2Hash)\n end",
"def similarity(user, row)\n (user.transpose.dot(row.transpose)) / (row.norm * user.norm)\nend",
"def sim_distance(preferences, person1, person2)\n have_movies_in_common = preferences[person1].detect {|movie, rating| preferences[person2].keys.include?(movie) }\n \n # if they have no ratings in common, return 0 \n return 0 unless have_movies_in_common\n \n # Add up the squares of all the differences \n sum_of_squares = 0\n preferences[person1].each do |movie, rating| \n sum_of_squares += (rating - preferences[person2][movie])**2 if preferences[person2].keys.include?(movie) \n end\n\n return 1/(1 + sum_of_squares)\nend",
"def calculate_similarity(other_doc)\n self.terms.inject(0.0) do |dot_product, term|\n dot_product + (self.tfidf(term.word) * other_doc.tfidf(term.word))\n end\n end",
"def similarity_to(other,options={})\n shared_words = shared_words_with(other,options)\n shared_words.length * 2.0 / (words.length + other.words.length)\n end",
"def set_similarity_cache_for(item1, item2, sim)\n @cached_similarities[\"#{item1}_#{item2}\"] = sim\n end",
"def similarity_matrix\n multiply_self(normalize)\n end",
"def compute_cosine_similarity current_items, next_items\n\t\t# find numerator by finding the number of the intersection of items\n\t\tnumerator = (current_items & next_items).length\n\n\t\t# find denominator by finding the product of the square root of the number of items of each user\n\t\tdenominator = Math.sqrt(current_items.length) * Math.sqrt(next_items.length)\n\n\t\t# return cosine similarity value\n\t\tnumerator / denominator\n\tend",
"def calculate_similarity(questions)\n raise ArgumentError, \"None question specified.\" if questions.empty?\n similarities = questions.map { |question| question_similarity(question) }\n similarities.compact!\n\n return 0 if similarities.empty?\n similarities.avg\n end",
"def recommend_by_item_based(user, top = @default_recommendation_count)\n return unless @similarity_matrix\n \n weighted_similar_items = Hash.new(0.0)\n similarity_sum_per_item = Hash.new(0.0)\n \n user.list.items.each_value do |user_item|\n item = @items[user_item.id]\n \n sim_objs = @similarity_matrix[item.id]\n sim_objs.each do |obj|\n next if user.has_item? obj[:id]\n weighted_similar_items[obj[:id]] += user_item.rating * obj[:similarity].abs\n similarity_sum_per_item[obj[:id]] += obj[:similarity].abs\n end\n end\n \n recommendations = weighted_similar_items.collect do |k, v|\n next if v == 0.0 or similarity_sum_per_item[k] == 0.0\n { :id => k, :est => (v / similarity_sum_per_item[k]) }\n end\n recommendations.compact.sort{ |x, y| y[:est] <=> x[:est] }.first(top || recommendations.size)\n end",
"def distance_metric(product1, product2) (get_value(product1) - get_value(product2)).abs end",
"def similarity_with(user)\n query_result = UserConnectionQuery.new.similarity(\n user_1: self,\n user_2: user\n ).first\n if query_result then query_result.similarity else nil end\n end",
"def cosine_similarity(x1, y1, x2, y2)\n dp = (x1 * x2) + (y1 * y2)\n mag1 = Math.sqrt((x1 ** 2) + (y1 ** 2))\n mag2 = Math.sqrt((x2 ** 2) + (y2 ** 2))\n return 0 if mag1 == 0 || mag2 == 0\n return (dp / (mag1 * mag2))\n end",
"def calculate_similarity(user_search_term = nil)\n assign_category_jaccard_score unless user_categories.empty?\n assign_score_for_relevant_work_links\n assign_levenstein_score(user_search_term)\n end",
"def image_similarity(hash_a, hash_b)\n 1 - image_hamming_distance(hash_a, hash_b) / 64.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 diff_ratio( other )\n return 0.0 if self == other\n return 1.0 if empty? || other.empty?\n\n s_words = self.words( true )\n o_words = other.words( true )\n\n common = (s_words & o_words).size.to_f\n union = (s_words | o_words).size.to_f\n\n (union - common) / union\n end",
"def similarity(user1,user2)\n user1,user2=user2,user1 if user1 > user2\n result=@similarity_cache[[user1,user2]]\n if result.nil?\n result=@similarity_func.call(data,user1,user2)\n @similarity_cache[[user1,user2]]=result\n end\n result\n end",
"def similarity(doc1_id, doc2_id)\n @tfidf ||= calculate\n CosineSimilarity.new.calculate(@tfidf[doc1_id], @tfidf[doc2_id])\n end",
"def most_similar (user1)\n\t\tuser1 = user1.to_s\n\t\tsimilarity_list = Array.new\n\t\t@user_rating_index.each_key do |key|\n\t\t\tunless key == user1 \n\t\t\t\tpair = Array.new()\n\t\t\t\tpair = [similarity(user1, key), key]\n\t\t\t\tsimilarity_list << pair\n\t\t\tend \n\t\tend\n\t\tsimilarity_list= similarity_list.sort\n\t\treturn similarity_list\n\tend",
"def compute_score\n @query.items.map.with_index do |element, index|\n weight(index) * weight(@classification.items.index(element))\n end.sum\n end",
"def similarity_with(rater)\n rater.create_recommended_to_sets\n agreements = common_likes_with(rater, :return_records => false).size\n agreements += common_dislikes_with(rater, :return_records => false).size\n disagreements = disagreements_with(rater, :return_records => false).size\n \n similarity = (agreements - disagreements).to_f / (likes.count + dislikes.count)\n rater.destroy_recommended_to_sets\n \n return similarity\n end",
"def update_similarity_coefficient(inst1, inst2)\n coeff = klass.similarity_for(inst1, inst2)\n \n update_coefficient inst1, inst2, coeff\n \n nil\n end",
"def calculate_similar_items(data, n=10, metric = Pearson.new)\n result = {}\n\n item_prefs = Dm::Similar::transform_pref(data)\n\n c = 0\n item_prefs.each do |item, similar|\n c += 1\n\n # print a counter for progress report (for large database)\n puts \"#{c} / #{item_prefs.size}\" if c%100 == 0\n\n # find score for similar item\n result[item] = top_matches(item_prefs, item, n, metric)\n end\n\n result\n end",
"def prediction(user, item)\n av_user = user_average_rating(user)\n upper_sum, bottom_sum = 0, 0\n neighbours = get_neighbours(user)\n\n neighbours.each_with_index do |neighbour, i|\n if neighbour_rating = Review.where(user_id: neighbour.id, item_id: item.id).first\n upper_sum = upper_sum + ( similarity(user, neighbour) * (neighbour_rating.rating - user_average_rating(neighbour)) )\n bottom_sum = bottom_sum + similarity(user, neighbour)\n end\n\n end\n\n if upper_sum > 0 and bottom_sum > 0\n av_user + (upper_sum / bottom_sum)\n else\n 0\n end\n end",
"def similar_items( item_id )\n items = []\n response = Amazon::Ecs.similarity_lookup( item_id.to_s, :response_group => 'Large,Reviews,Similarities' )\n response.items.each do |item|\n items << Book.new( item )\n end\n return items\n end",
"def similarity\n size1 = pixel_count(@image_path_1)\n size2 = pixel_count(@image_path_2)\n\n if size1 < size2\n big = @image_path_2\n small = @image_path_1\n else\n big = @image_path_1\n small = @image_path_2\n end\n\n min_size = size(small)\n width = min_size[0] * @resize_factor\n height = min_size[1] * @resize_factor\n\n a = \"convert #{Shellwords.escape(small)} #{Shellwords.escape(big)} -resize '#{width}'x'#{height}'\\! MIFF:- | compare -metric AE -fuzz \\\"#{@color_fuzz}%\\\" - null: 2>&1\"\n result = `#{a}`\n\n result.to_i / (width * height)\n end",
"def cosine_similarity(a, b)\n dot_product(a, b) / (magnitude(a) * magnitude(b))\n end",
"def calculate_inter_similarity(cluster1, cluster2)\n sum = 0\n inter_sim = 0.0\n\n occurences1 = DocVector.new(cluster1.occurences.length, 0)\n occurences2 = DocVector.new(cluster1.occurences.length, 0)\n\n cluster1.compute_tree_children_occurences(occurences1)\n score1 = calculate_cluster_score_v1(occurences1, cluster2)\n\n sum = occurences1.inject {|res, x| res + x }\n\n # calculate similarity by normalizing the score\n score1 = ( sum == 0.0 ) ? 0.0 : score1.to_f / sum\n\n cluster2.compute_tree_children_occurences(occurences2)\n score2 = calculate_cluster_score_v1(occurences2, cluster1)\n\n sum = occurences2.inject {|res, x| res + x }\n\n # calculate similarity by normalizing the score\n score2 = ( sum == 0.0 ) ? 0.0 : score2.to_f / sum\n\n # negative inter-similarity?\n both_negative = ( score1 < 0 )\n\n negative = false\n\n if score1 < 0\n score1 *= -1.0\n negative = true\n end\n\n if score2 < 0\n score2 *= -1.0\n negative = true\n end\n\n # geometric mean\n inter_sim = ( score1 * score2 ) ** 0.5\n\n inter_sim *= -1.0 if negative\n inter_sim *= 2.0 if both_negative\n\n return inter_sim\n end",
"def phash_similarity(hash_a, hash_b)\n 1 - phash_distance(hash_a, hash_b) / 64.0\n end",
"def cosine_similarity(a, b)\n dot_product(a, b) / (magnitude(a) * magnitude(b))\n end",
"def y_star(items, already_sorted = false)\n items = sort_items_by_profitability!(items.clone) unless already_sorted\n i1, i2 = items[0], items[1]\n c1, c2, a1, a2 = i1[:p], i2[:p], i1[:w], i2[:w]\n \n (Rational(c1)/(Rational(c1, a1) - Rational(c2, a2))).ceil\nend",
"def match_percentage incorrect, possible\n #Creates character arrays for both words\n incorrect_array = incorrect.split(\"\")\n possible_array = possible.split(\"\")\n\n #Hashes to hold count of each char\n incorrect_hash = Hash.new(0)\n possible_hash = Hash.new(0)\n\n #Counts the characters in each word\n incorrect_array.each do |char|\n incorrect_hash[char] += 1\n end\n possible_array.each do |char|\n possible_hash[char] += 1\n end\n \n ##Compares the two hashes and returns similarity as a decimal\n #The overall percentage and total characters, used to calculate final percentage\n overall_percentage = 0.to_f\n total_chars = [incorrect_hash.keys.length, possible_hash.keys.length].max\n #Iterates over the hash for the possible correction\n possible_hash.each do |chars|\n #Sets char to the actual character\n char = chars[0]\n #Sets value_possible to count in possible hash\n value_possible = chars[1]\n #Sets value_incorrect to count in incorrect hash\n value_incorrect = incorrect_hash[char]\n\n #If neither value is zero calcluates similarity and adds to overall_percentage, otherwise its 0\n if value_possible != 0 && value_incorrect != 0\n min = [value_possible, value_incorrect].min\n max = [value_possible, value_incorrect].max\n overall_percentage += (min.to_f / max.to_f)\n end\n end\n #Calculates similarity percentage and returns\n overall_percentage /= total_chars\n\n return overall_percentage * $lexicon[possible[0]][possible.length][possible]\nend",
"def similarity(other_user)\n similarity_count = 0\n @rating_list.each_value do |rating|\n if other_rating = other_user.rating_list[rating.movie_id] and \\\n other_rating.rating.to_i >= rating.rating.to_i - 1 and \\\n other_rating.rating.to_i <= rating.rating.to_i + 1\n similarity_count += 1\n end\n end\n return similarity_count\n end",
"def similarity(other, *args)\n signature.similarity(other.signature, *args)\n end",
"def similarity(other_user)\n similarity_count = 0\n @rating_list.each_value do |rating|\n if other_rating = other_user.rating_list[rating.movie_id] and other_rating.rating.to_i >= rating.rating.to_i - 1 and other_rating.rating.to_i <= rating.rating.to_i + 1\n similarity_count += 1\n end\n end\n return similarity_count\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 predict_for(user_id, klass, item_id)\n user_id = user_id.to_s\n item_id = item_id.to_s\n\n liked_by_set = Recommendations::Helpers::RedisKeyMapper.liked_by_set_for(klass, item_id)\n similarity_sum = 0.0\n\n # Get sum of similarities of each item in set\n similarity_sum = similarity_total_for(user_id, liked_by_set)\n\n liked_by_count = Recommendations.redis.pipelined do\n Recommendations.redis.scard(liked_by_set)\n end\n prediction = similarity_sum / (liked_count).to_f\n prediction.finite ? prediction : 0.0\n end",
"def calculate_similar_items(preferences, limit = 10)\n result = {} \n # Invert the preference matrix to be item-centric \n item_preferences = transform_preferences(preferences) \n item_preferences.keys.each do |item|\n # Find the most similar items to this one \n scores = top_matches(item_preferences, item, limit) \n result[item] = scores\n end\n return result\nend",
"def similarshelves(n)\n similar(n)\n end",
"def update_similarities_for_(user_id)\n user_id = user_id.to_s # For comparison. Redis returns all set members as strings.\n similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n\n Recommendable.set_shard_key user_id\n\n # Only calculate similarities for users who have rated the items that\n # this user has rated\n relevant_user_ids = Recommendable.config.ratable_classes.inject([]) do |memo, klass|\n liked_set = Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, user_id)\n disliked_set = Recommendable::Helpers::RedisKeyMapper.disliked_set_for(klass, user_id)\n\n item_ids = Recommendable.redis.sunion(liked_set, disliked_set)\n\n unless item_ids.empty?\n sets = item_ids.map do |id|\n liked_by_set = Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(klass, id)\n disliked_by_set = Recommendable::Helpers::RedisKeyMapper.disliked_by_set_for(klass, id)\n\n [liked_by_set, disliked_by_set]\n end\n\n memo | Recommendable.redis.sunion(*sets.flatten)\n else\n memo\n end\n end\n\n similarity_values = relevant_user_ids.map { |id| similarity_between_(user_id, id) }\n Recommendable.redis.pipelined do\n relevant_user_ids.zip(similarity_values).each do |id, similarity_value|\n next if id == user_id # Skip comparing with self.\n Recommendable.redis.zadd(similarity_set, similarity_value, id)\n end\n end\n\n if knn = Recommendable.config.nearest_neighbors\n length = Recommendable.redis.zcard(similarity_set)\n kfn = Recommendable.config.furthest_neighbors || 0\n\n Recommendable.redis.zremrangebyrank(similarity_set, kfn, length - knn - 1)\n end\n\n true\n end",
"def optimize3(weight, cost=0, items = $items)\r\n return cost if weight <= 0 || items.empty?\r\n # puts \"#{weight}\\t#{cost}\\t#{items.collect{|i| i.weight}.join(' ')}\"\r\n same_ratio = items.find_all { |i| i.ratio == items[0].ratio }\r\n global_best = nil\r\n same_ratio.size.times do |x|\r\n if weight % items[x].weight == 0\r\n return items[x].cost * (weight / items[x].weight) + cost\r\n end\r\n \r\n best = (x == 0) ? items[x].cost * (weight / items[x].weight + 1) + cost : nil\r\n \r\n (items - [items[x]]).each do |item|\r\n if x == 0\r\n c = optimize3(weight % items[x].weight, items[x].cost * (weight / items[x].weight) + cost, items - [items[x]])\r\n else\r\n c = optimize3(weight - items[x].weight, items[x].cost + cost, items)\r\n end\r\n best = c if (best.nil? || c < best)\r\n end\r\n global_best = best if best && (global_best.nil? || best < global_best)\r\n end\r\n global_best\r\nend",
"def score(search_term:, item_name:)\n return 99 unless search_term.present? && item_name.present?\n\n Text::Levenshtein.distance(search_term.downcase, item_name.downcase)\n end",
"def most_similar (u1)\n\t\thash_user_similar = Hash.new\n\t\t@train_data.each_key do |d|\n\t\t\thash_user_similar.store(d, pearson_similarity(u1,d))\n\t\tend\n\t\thash_user_similar.delete(u1)\n\t\treturn sort_decrease_order(hash_user_similar)\n\n\tend",
"def similarity_total_for(user_id, set)\n similarity_set = Recommendations::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n ids = Recommendations.redis.smembers(set)\n similarity_values = Recommendations.redis.pipelined do\n ids.each do |id|\n Recommendations.redis.zscore(similarity_set, id)\n end\n end\n similarity_values.map(&:to_f).reduce(&:+).to_f\n end",
"def similarity_limit\n 0.420 # don't ask\n end",
"def update_similarities_for(user_id)\n user_id = user_id.to_s # For comparison. Redis returns all set members as strings.\n similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n\n # Only calculate similarities for users who have rated the items that\n # this user has rated\n relevant_user_ids = Recommendable.config.ratable_classes.inject([]) do |memo, klass|\n gemd_set = Recommendable::Helpers::RedisKeyMapper.gemd_set_for(klass, user_id)\n disgemd_set = Recommendable::Helpers::RedisKeyMapper.disgemd_set_for(klass, user_id)\n\n item_ids = Recommendable.redis.sunion(gemd_set, disgemd_set)\n\n unless item_ids.empty?\n sets = item_ids.map do |id|\n gemd_by_set = Recommendable::Helpers::RedisKeyMapper.gemd_by_set_for(klass, id)\n disgemd_by_set = Recommendable::Helpers::RedisKeyMapper.disgemd_by_set_for(klass, id)\n\n [gemd_by_set, disgemd_by_set]\n end\n\n memo | Recommendable.redis.sunion(*sets.flatten)\n else\n memo\n end\n end\n\n relevant_user_ids.each do |id|\n next if id == user_id # Skip comparing with self.\n Recommendable.redis.zadd(similarity_set, similarity_between(user_id, id), id)\n end\n\n if knn = Recommendable.config.nearest_neighbors\n length = Recommendable.redis.zcard(similarity_set)\n kfn = Recommendable.config.furthest_neighbors || 0\n\n Recommendable.redis.zremrangebyrank(similarity_set, kfn, length - knn - 1)\n end\n\n true\n end",
"def similarly_purchased_item(item = nil)\n if item.present?\n # first we have to determine if this is a stuffed_animal or if this\n # is an accessory\n other_line_items = []\n if item.class.name == \"StuffedAnimal\"\n other_line_items = LineItem.where(stuffed_animal_id: item.id)\n else\n other_line_items = LineItem.where(accessory: item.id)\n end\n\n # extract an array of similar items\n similar_items = self.other_products_purchased item, other_line_items\n\n # take a random sampling of 1 item\n similar_items.sample(1)\n end\n end",
"def averagehash_similarity(hash_a, hash_b)\n 1 - averagehash_distance(hash_a, hash_b) / 64.0\n end",
"def similar user\n #somethig\n #somethig\n out = JSON.parse(%x|java -jar #{File.dirname(__FILE__)}/recommender.jar #{FILE_IN}|)\n\n u = Matrix[*out[1]]\n s = Matrix[*out[0]]\n vt = Matrix[*out[2]]\n\n #pp u.column(0)\n u_collapsed = Matrix.columns([u.column(0),u.column(1)]) # Items\n s_collapsed = Matrix.columns([s.column(0),s.column(1)])\n vt_collapsed = Matrix.columns([vt.column(0),vt.column(1)]) # Users\n\n pp u_collapsed\n pp s_collapsed\n pp vt_collapsed\n\n #user.transpose * Matrix[u.column(0), u.column(1)]\n #p (s * Matrix[s.column(0), s.column(1)])\n\nend",
"def sim_euclidean(prefs, person1, person2)\n #find items in common\n shared = {}\n prefs[person1].each do |k,v|\n if prefs[person2][k] != nil\n shared[k] = 1\n end\n end\n\n #both persons doesn't have anything in common\n if shared.length == 0\n return 0\n end\n\n #calculate sum of squares\n sum_of_squares = 0\n shared.each do |k,v|\n sum_of_squares += (prefs[person1][k] - prefs[person2][k]) ** 2\n end\n\n #return euclidean distance. 1 is added to denominator to avoid divide by zero\n 1/(1 + sqrt(sum_of_squares))\nend",
"def text_similarity(text,other_model)\n other_model.text_commonality(text) / text_commonality(text)\n end",
"def rating_of(category, item)\n ratings_of = ratings.select{ |r| r.beer.send(category) == item }\n ratings_of.map(&:score).inject(&:+) / ratings_of.count.to_f\n end",
"def same?\n similarities.size == 1 && similarities.first.distance.zero? # The same\n end",
"def similarity(word,label)\n if @cosines.include?(word)\n sim = similarity_cluster(word,label)\n elsif word.include?(\"_\")\n word = word.split(\"_\")[0]\n sim = similarity_cluster(word,label)\n else\n STDERR.puts \"\\'#{word}\\' not in list of pre-computed cosines, sim(#{word},#{label}) = 0\" if @debug\n sim = 0.0\n end\n return sim\n end",
"def similarity_to other, threshold = nil\n Babushka::Levenshtein.distance self, other, threshold\n end",
"def get_vct\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n vct = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n vct += (auxNodo1.value.get_val / (auxNodo1.value.proteinas + auxNodo1.value.glucidos + auxNodo1.value.lipidos)) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return vct.round(1)\n end",
"def similarity_matrix\n tfidf_similarity_model.similarity_matrix\n end",
"def score\n track_similarity = shared_count(:tracks) / (((@user1.tracks.uniq.count + @user2.tracks.uniq.count) - shared_count(:tracks)) * 1.0)\n artist_similarity = shared_count(:artists) / (((@user1.artists.uniq.count + @user2.artists.uniq.count) - shared_count(:artists)) * 1.0)\n genre_similarity = shared_count(:genres) / (((@user1.genres.uniq.count + @user2.genres.uniq.count) - shared_count(:genres)) * 1.0)\n\n # Maximum possible raw score is seven (with yourself). Most people are between 0 and 1.\n raw = (track_similarity * 4) + (artist_similarity * 2) + (genre_similarity * 1)\n score = raw * 100\n score.round\n end",
"def score\n track_similarity = shared_count(:tracks) / (((@user1.tracks.uniq.count + @user2.tracks.uniq.count) - shared_count(:tracks)) * 1.0)\n artist_similarity = shared_count(:artists) / (((@user1.artists.uniq.count + @user2.artists.uniq.count) - shared_count(:artists)) * 1.0)\n genre_similarity = shared_count(:genres) / (((@user1.genres.uniq.count + @user2.genres.uniq.count) - shared_count(:genres)) * 1.0)\n\n # Maximum possible raw score is seven (with yourself). Most people are between 0 and 1.\n raw = (track_similarity * 4) + (artist_similarity * 2) + (genre_similarity * 1)\n score = raw * 100\n score.round\n end"
] |
[
"0.80701387",
"0.7937043",
"0.7589208",
"0.75725365",
"0.7359217",
"0.6925787",
"0.6857152",
"0.68302065",
"0.6804935",
"0.67283803",
"0.67250174",
"0.6691393",
"0.6684902",
"0.6674588",
"0.66491437",
"0.66311103",
"0.66295123",
"0.6615349",
"0.66058624",
"0.6531073",
"0.65166116",
"0.6506781",
"0.65057075",
"0.64990276",
"0.648372",
"0.64564574",
"0.6436779",
"0.638273",
"0.6256197",
"0.6253542",
"0.6211791",
"0.61875993",
"0.61808586",
"0.617957",
"0.6147593",
"0.61404115",
"0.6129253",
"0.611185",
"0.60428226",
"0.6033003",
"0.6028669",
"0.60278064",
"0.59743214",
"0.5938808",
"0.59372365",
"0.59068125",
"0.5906758",
"0.5898463",
"0.5895674",
"0.58917487",
"0.5891683",
"0.58824664",
"0.58632624",
"0.58619314",
"0.58606863",
"0.5852945",
"0.58451974",
"0.58443034",
"0.5814669",
"0.57956374",
"0.57911575",
"0.57905483",
"0.5789424",
"0.57781863",
"0.5755981",
"0.5739305",
"0.5714141",
"0.5699121",
"0.56551355",
"0.56427735",
"0.5642226",
"0.56307393",
"0.5630654",
"0.5612265",
"0.559845",
"0.5597963",
"0.5581047",
"0.5551065",
"0.55150265",
"0.54962915",
"0.5493473",
"0.5487767",
"0.54858655",
"0.5483226",
"0.5432705",
"0.5429858",
"0.5425082",
"0.5422429",
"0.54217154",
"0.54212147",
"0.54185534",
"0.54139113",
"0.5409347",
"0.5403937",
"0.54001254",
"0.53933764",
"0.5368327",
"0.53575075",
"0.5354643",
"0.5354643"
] |
0.7576317
|
3
|
calculate all similarities to other items in the matrix for item1
|
def similarities_for(item1)
# return => [ ["item23", 0.6], ["item42", 0.23], (...) ]
raise "implemented in subclass"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def similarity_by_euclidean_for_items(item1, item2, list)\n common_users = find_common_users(item1, item2, list)\n \n result = 0.0\n return result if common_users.size < 1\n \n common_users.each do |u|\n result += (u.rating_for(item1.id) - u.rating_for(item2.id))**2\n end\n result = 1 / (1 + result)\n # result = 1 / (1 + Math.sqrt(result)) TODO: make tests to see the difference\n end",
"def similarity_by_pearson_for_items(item1, item2, list)\n common_users = find_common_users(item1, item2, list)\n size = common_users.size\n \n return 0 if size < 1\n \n i1_sum_ratings = i2_sum_ratings = i1_sum_sq_ratings = i2_sum_sq_ratings = sum_of_products = 0.0\n common_users.each do |user|\n i1_rating = user.rating_for item1.id\n i2_rating = user.rating_for item2.id\n \n # Sum of all ratings by users\n i1_sum_ratings += i1_rating\n i2_sum_ratings += i2_rating\n \n # Sum of all squared ratings by users\n i1_sum_sq_ratings += i1_rating**2\n i2_sum_sq_ratings += i2_rating**2\n \n # Sum of product of the ratings that given to the same item\n sum_of_products += i1_rating * i2_rating\n end\n \n # Long lines of calculations, see http://davidmlane.com/hyperstat/A56626.html for formula.\n numerator = sum_of_products - ((i1_sum_ratings * i2_sum_ratings) / size)\n denominator = Math.sqrt((i1_sum_sq_ratings - (i1_sum_ratings**2) / size) * (i2_sum_sq_ratings - (i2_sum_ratings**2) / size))\n \n result = denominator == 0 ? 0 : (numerator / denominator)\n \n result = -1.0 if result < -1\n result = 1.0 if result > 1\n result\n end",
"def similarity_for_items(item1, item2, list = nil)\n # cache disabled\n # cached_sim = get_cached_similarity_for item1, item2\n # return cached_sim if cached_sim\n sim = 0.0\n case SIMILARITY_METHOD\n when 'euclidean'\n sim = similarity_by_euclidean_for_items item1, item2, list\n when 'pearson'\n sim = similarity_by_pearson_for_items item1, item2, list\n when 'jaccard'\n sim = similarity_by_jaccard_for_items item1, item2, list\n end\n sim.round(5)\n #set_similarity_cache_for item1, item2, sim\n end",
"def similarity(item1, item2)\n raise \"implemented in subclass\"\n end",
"def similarity(user, row)\n (user.transpose.dot(row.transpose)) / (row.norm * user.norm)\nend",
"def similarity_matrix\n multiply_self(normalize)\n end",
"def calculate_similarity(movie_in_common)\n simil = 0.0\n movie_in_common.each do |x|\n #find index of the common movie/ratings\n rating1 = cache_1[1][cache_1[0].index(x)]\n rating2 = cache_2[1][cache_2[0].index(x)]\n simil += (5-(rating1.to_i - rating2.to_i).abs)/5.0\n end\n return simil\n end",
"def similar user\n #somethig\n #somethig\n out = JSON.parse(%x|java -jar #{File.dirname(__FILE__)}/recommender.jar #{FILE_IN}|)\n\n u = Matrix[*out[1]]\n s = Matrix[*out[0]]\n vt = Matrix[*out[2]]\n\n #pp u.column(0)\n u_collapsed = Matrix.columns([u.column(0),u.column(1)]) # Items\n s_collapsed = Matrix.columns([s.column(0),s.column(1)])\n vt_collapsed = Matrix.columns([vt.column(0),vt.column(1)]) # Users\n\n pp u_collapsed\n pp s_collapsed\n pp vt_collapsed\n\n #user.transpose * Matrix[u.column(0), u.column(1)]\n #p (s * Matrix[s.column(0), s.column(1)])\n\nend",
"def calculate_similar_items(data, n=10, metric = Pearson.new)\n result = {}\n\n item_prefs = Dm::Similar::transform_pref(data)\n\n c = 0\n item_prefs.each do |item, similar|\n c += 1\n\n # print a counter for progress report (for large database)\n puts \"#{c} / #{item_prefs.size}\" if c%100 == 0\n\n # find score for similar item\n result[item] = top_matches(item_prefs, item, n, metric)\n end\n\n result\n end",
"def recompute_similarity_matrix\n start_time = Time.now\n puts \"Creation of similarity matrix for items started at: #{start_time}.\"\n @similarity_matrix = {}\n @items.each_value do |item|\n puts \"Started creating similar items for:#{item}\"\n @similarity_matrix[item.id] = find_top_similar_items item, @default_similar_objects_count\n end\n \n puts \"Creation of similarity matrix for items lasted: #{Time.now - start_time} seconds.\"\n end",
"def similarity(m1, m2)\n if m1.is_a?(SparseVector) && m2.is_a?(SparseVector)\n m1.cosine(m2)\n elsif m2.size == m1.size\n a_dot_b = 0.0\n a_sq_sum = 0.0\n b_sq_sum = 0.0\n m1.each2(m2) do |x1,x2|\n a_dot_b = x1 * x2\n a_sq_sum += x1 * x1\n b_sq_sum += x2 * x2\n end\n a_dot_b / ( Math.sqrt(a_sq_sum) * Math.sqrt(b_sq_sum) )\n else\n 0.0\n end\n end",
"def similarity (user1, user2)\n\t\tuser1= user1.to_s\n\t\tuser2 = user2.to_s\n\t\tuser1_index = @user_rating_index[user1]\n\t\tuser2_index = @user_rating_index[user2]\n\t\ttotal_diff = 0\n\t\tcounter=0\n\n\t\tuser1_index.each_key do |movie|\n\t\t\tif user2_index.has_key? (movie) \n\t\t\t\tdiff = (user1_index[movie].to_i - user2_index[movie].to_i).abs #abs value difference to be summed then divided by total\n\t\t\t\ttotal_diff += diff\n\t\t\t\tcounter+=1\n\t\t\tend\n\t\tend\n\t\tif counter == 0\n\t\t\treturn 5.0\n\t\tend\n\t\treturn (total_diff.to_f/counter) \n\tend",
"def similarity(user_a, user_b)\n av_a, av_b = user_average_rating(user_a), user_average_rating(user_b)\n sum_both, sum_a, sum_b = 0, 0, 0\n\n rating_a = Review.where(user_id: user_a.id)\n\n rating_a.each do |rating_a|\n if rating_b = Review.where(user_id: user_b.id, item_id: rating_a.item_id).first\n sum_a = sum_a + ( (rating_a.rating - av_a)**2 )\n sum_b = sum_b + ( (rating_b.rating - av_b)**2 )\n sum_both = sum_both + ( (rating_a.rating - av_a) * (rating_b.rating - av_b) )\n end\n end\n\n sum_both / ( (Math.sqrt(sum_a)) * (Math.sqrt(sum_b)) )\n end",
"def recommend_by_item_based(user, top = @default_recommendation_count)\n return unless @similarity_matrix\n \n weighted_similar_items = Hash.new(0.0)\n similarity_sum_per_item = Hash.new(0.0)\n \n user.list.items.each_value do |user_item|\n item = @items[user_item.id]\n \n sim_objs = @similarity_matrix[item.id]\n sim_objs.each do |obj|\n next if user.has_item? obj[:id]\n weighted_similar_items[obj[:id]] += user_item.rating * obj[:similarity].abs\n similarity_sum_per_item[obj[:id]] += obj[:similarity].abs\n end\n end\n \n recommendations = weighted_similar_items.collect do |k, v|\n next if v == 0.0 or similarity_sum_per_item[k] == 0.0\n { :id => k, :est => (v / similarity_sum_per_item[k]) }\n end\n recommendations.compact.sort{ |x, y| y[:est] <=> x[:est] }.first(top || recommendations.size)\n end",
"def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += (5-(simil1.to_i - simil2.to_i).abs)/5.0\n\t\tend\n\t\tbegin \n\t\t\treturn (simil * 1.0/movie_in_common.size)\n\t\trescue\n\t\t\treturn 0.0\n\t\tend\n\tend",
"def rating_for(active_user, item)\n return unless @similarity_matrix\n \n weighted_similar_items = similarity_sum = 0\n\n sim_objs = @similarity_matrix[item.id]\n sim_objs.each do |obj|\n active_user_rating = active_user.rating_for obj[:id]\n next unless active_user_rating\n weighted_similar_items += active_user_rating * obj[:similarity].abs\n similarity_sum += obj[:similarity].abs\n end\n \n return nil if weighted_similar_items == 0 or similarity_sum == 0\n \n rating = weighted_similar_items / similarity_sum\n rating = 5 if rating > 5\n rating = 1 if rating < 1\n rating\n end",
"def similarities u1\n sims = Hash.new()\n (@usr_rating.keys - [u1]).each do |u2|\n sims.store(u2, similarity(u1, u2))\n end\n return sims\n end",
"def similarshelves(n)\n similar(n)\n end",
"def similarity(user1, user2) \n\t\tsimil = 0;\n\t\tuser1_movie_list = reviews_hash[user1.to_i].transpose\n\t\tuser2_movie_list = reviews_hash[user2.to_i].transpose\n\t\tmovie_in_common = user1_movie_list[0] & user2_movie_list[0]\n\t\tmovie_in_common.each do |x|\n\t\t\t#find index of the common movie/ratings\n\t\t\tindex1 = user1_movie_list[0].index(x)\n\t\t\tindex2 = user2_movie_list[0].index(x)\n\t\t\tsimil1 = user1_movie_list[1][index1]\n\t\t\tsimil2 = user2_movie_list[1][index2]\n\t\t\tsimil += 1.0/((simil1.to_i - simil2.to_i).abs + 1) # 1/(rating difference + 1)\n\t\tend\n\t\treturn simil.round(2)\n\tend",
"def similarity_matrix\n tfidf_similarity_model.similarity_matrix\n end",
"def recalculate_similarity\n query_one = Like.select(:user_id).where(product_id: product_one_id).order('user_id asc').to_sql\n query_two = Like.select(:user_id).where(product_id: product_two_id).order('user_id asc').to_sql\n user_ids_one = ActiveRecord::Base.connection.execute(query_one).column_values(0)\n user_ids_two = ActiveRecord::Base.connection.execute(query_two).column_values(0)\n intersection = (user_ids_one & user_ids_two).size\n union = (user_ids_one | user_ids_two).size\n \n if intersection == 0 || union == 0\n self.similarity = 0\n else\n self.similarity = intersection.to_f / union.to_f\n end\n self.save\n end",
"def similarity(user1,user2)\n #retrieves the recorded related to user1 and user2\n #then create an array which contains the movie ids which both user have rated them\n u1=@users[user1]\n u2=@users[user2]\n u1_movies=u1.collect{|itm| itm[1]}\n u2_movies=u2.collect{|itm| itm[1]}\n common_movies=u1_movies & u2_movies\n \n if common_movies.empty?\n return 0\n end\n \n #Similarity is defined as the average of (4 - distance between rating of user 1 and 2) for movie id\n #which both usres have rated\n similarity=0.0\n common_movies.each do |movie|\n rating1=u1.rassoc(movie)[2]\n rating2=u2.rassoc(movie)[2]\n similarity+=4-(rating1-rating2).abs\n end\n return similarity/common_movies.size\n end",
"def get_cached_similarity_for(item1, item2)\n @cached_similarities[\"#{item1}_#{item2}\"] || @cached_similarities[\"#{item2}_#{item1}\"]\n end",
"def distance item\n if !item.is_a? Item\n raise \"Cannot calculate distance to object that is not an item.\"\n end\n\n disance = 0 if self == item\n id = ItemDistance.where({\n :item1_id => self.id,\n :item2_id => item.id,\n }).first\n\n if id.nil?\n id = ItemDistance.new({\n :item1_id => self.id,\n :item2_id => item.id,\n })\n else\n # An hour DB cache\n distance = id.distance if Time.now - id.updated_at < 60*60\n end\n\n if distance.nil?\n # this in reality is supposed to be sum(each dimmension (b-a)^2) but\n # because the values are all one or zero, we can do this\n diff = (self.voters.to_set - item.voters.to_set).count\n distance = Math.sqrt(diff)\n\n id.distance = distance\n id.save\n end\n\n return distance\n end",
"def similarity u1, u2\n u1_r = @usr_rating[u1]\n u2_r = @usr_rating[u2]\n common = u1_r.keys & u2_r.keys\n\n mean_diff = 0\n common.each do |mv|\n mean_diff += diff(u1_r[mv], u2_r[mv]).to_f / common.length\n end\n return ((5 - mean_diff)/5).round(2)\n end",
"def calculate_similar_items(preferences, limit = 10)\n result = {} \n # Invert the preference matrix to be item-centric \n item_preferences = transform_preferences(preferences) \n item_preferences.keys.each do |item|\n # Find the most similar items to this one \n scores = top_matches(item_preferences, item, limit) \n result[item] = scores\n end\n return result\nend",
"def similarity_matrix\n if documents.empty?\n []\n else\n multiply_self(normalize)\n end\n end",
"def similarity_matrix\n if documents.empty?\n []\n else\n multiply_self(normalize)\n end\n end",
"def calc_similarity(query, doc)\n tokens = Set.new(query.keys + doc.keys)\n\n a = Vector.elements(tokens.map { |n| query[n] || 0 }, false)\n b = Vector.elements(tokens.map { |n| doc[n] || 0 }, false)\n\n return a.inner_product(b) / (a.magnitude * b.magnitude)\n end",
"def similarity(user1, user2)\n if @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n sim_rating = 0\n user1ratings = @userdata[user1.to_s.to_sym]\n user2ratings = @userdata[user2.to_s.to_sym]\n user2ids = []\n user2ratings.each{ |id, rating| user2ids.push id }\n user1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n return sim_rating\n else\n puts \"User not found\"\n return nil\n end\n end",
"def build_cosine_similarity_matrix\n\t\t# build matrix depending on the strategy\n\t\tstrategy_hash = {\"UserBasedRecommender\" => @user_items_array, \"ContentBasedRecommender\" => @item_categories_array}\n\t\tdata = strategy_hash[self.class.name]\n\n\t\tfor i in 0..data.length-2\n\n\t\t\tcurrent_id = nil\n\t\t\tcurrent_items = nil\n\t\t\tdata[i].each do |key, value|\n\t\t\t\tcurrent_id = key\n\t\t\t\tcurrent_items = value\n\t\t\tend\n\n\t\t\tfor j in i+1..data.length-1\n\n\t\t\t\tnext_id = nil\n\t\t\t\tnext_items = nil\n\t\t\t\tdata[j].each do |key, value|\n\t\t\t\t\tnext_id = key\n\t\t\t\t\tnext_items = value\n\t\t\t\tend\n\n\t\t\t\t# if current user key not in hash then create new hash i.e. {user_id: {pair_user_id : cosine_similarity_value, ...}}\n\t\t\t\t@cosine_similarity_matrix[current_id] = ModifiedHash.new if not @cosine_similarity_matrix[current_id]\n\t\t\t\n\t\t\t\t# do to next => current as well\n\t\t\t\t@cosine_similarity_matrix[next_id] = ModifiedHash.new if not @cosine_similarity_matrix[next_id]\n\n\t\t\t\t# add to hash\n\t\t\t\tcosine_similarity_value = compute_cosine_similarity(current_items, next_items)\n\n\t\t\t\tif cosine_similarity_value > 0\n\t\t\t\t\t@cosine_similarity_matrix[current_id][next_id] = cosine_similarity_value\n\t\t\t\t\t@cosine_similarity_matrix[next_id][current_id] = cosine_similarity_value\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def scoreExclusivity(mat)\n covered = 0\n xor = 0\n mat.first.each_index{|i|\n sum = 0\n mat.each{|node|\n sum += node[i].to_i\n }\n if sum == 1\n xor += 1\n covered += 1\n elsif sum > 1\n covered += 1\n end\n }\n \n return xor.to_f/covered.to_f\nend",
"def distance(m1, m2)\n n = m1.size\n sum = 0.0\n n.times do |i|\n n.times do |j|\n dif = m2[i][j] - m1[i][j]\n sum += dif * dif\n end\n end\n sum\nend",
"def analogy(a, b, c, word_to_id, id_to_word, word_matrix, top: 5, answer: nil)\n all_found = true\n [a, b, c].each do |word|\n unless word_to_id.include?(word)\n puts(\"#{word} not found.\")\n all_found = false\n end\n end\n\n return unless all_found\n\n puts(\"\\n[analogy] #{a}:#{b} = #{c}:?\")\n a_vec = word_matrix[word_to_id[a], true]\n b_vec = word_matrix[word_to_id[b], true]\n c_vec = word_matrix[word_to_id[c], true]\n query_vec = b_vec - a_vec + c_vec\n query_vec = normalize(query_vec)\n\n similarity = word_matrix.dot(query_vec).to_a\n\n if answer\n puts(\"===>#{answer}:#{word_matrix[word_to_id[answer]].dot(query_vec)}\")\n end\n\n count = 0\n\n sorted_indexes = similarity.map.with_index.sort.map(&:last).reverse\n\n sorted_indexes.each do |i|\n # TODO: Deal with NaNs\n next if [a, b, c].include?(id_to_word[i])\n\n puts(\" #{id_to_word[i]}: #{similarity[i]}\")\n\n count += 1\n break if count >= top\n end\nend",
"def similarity(user1, user2)\n user1_rate = compute_user_rate(user1)\n user2_rate = compute_user_rate(user2)\n dot_product = user1_rate.reduce(0) { |sum, (k, v)| sum + v * user2_rate[k] }\n user1_magnitude = compute_magnitude(user1_rate)\n user2_magnitude = compute_magnitude(user2_rate)\n dot_product / (user1_magnitude * user2_magnitude)\n end",
"def distance_others(distance_matrix, i, j)\n distances = []\n for k in 1...distance_matrix.length\n next if k == i || k == j\n distances.push((distance_matrix[i][k] + distance_matrix[j][k] - distance_matrix[i][j]) / 2.to_f)\n end\n distances\nend",
"def distance_members(matrix, i, j)\n distances = []\n distances[0] = matrix[i][j] / 2.to_f + (get_sum(matrix, i) - get_sum(matrix, j)) / (2.to_f * ($r - 2))\n distances[1] = matrix[i][j] - distances[0]\n distances\nend",
"def similar\n World.similar(self)\n end",
"def similar\n World.similar(self)\n end",
"def similarity(user1, user2)\n\n user1 = user1.to_s\n user2 = user2.to_s\n \n weight_num = 0.20\n weight_movies = 0.40\n weight_rating = 0.40\n \n user1_num_movies = @user_database[user1].length\n user2_num_movies = @user_database[user2].length\n score_num_movies = ((user1_num_movies + user2_num_movies).to_f / ([user1_num_movies, user2_num_movies].max * 2)) * 100.0 \n \n #hash consists of movieID(string) => rating(float)\n user1_hash = {}\n user2_hash = {} \n @user_database[user1].each do |movieID, rating, time|\n user1_hash[movieID] = rating.to_f\n end\n @user_database[user2].each do |movieID, rating, time|\n user2_hash[movieID] = rating.to_f\n end \n common_movies = user1_hash.keys & user2_hash.keys\n num_common_movies = common_movies.length\n score_common_movies = (num_common_movies / [user1_hash.keys.length, user2_hash.keys.length].max ) * 100.0\n \n rating_difference = 0\n common_movies.each do |movieID|\n rating_difference += (user1_hash[movieID] - user2_hash[movieID]).abs\n end\n \n #in case of num_common_movies being 0, then penalize the rating score by 100\n if num_common_movies == 0\n avg_rating_diff = 100 \n else\n avg_rating_diff = rating_difference / num_common_movies.to_f\n end\n \n score_rating = 100 - avg_rating_diff\n \n similarity_score = (weight_num * score_num_movies + weight_movies * score_common_movies + weight_rating * score_rating)\n \n return similarity_score\n \n end",
"def pearson_similarity (u1,u2)\n\t\tsimilarity = @train_data[u1].movie_and_rating.keys & @train_data[u2].movie_and_rating.keys\n\t\tif similarity.empty?\n\t\t\treturn 0\n\t\tend\n\t\tsum_1 = 0\n\t\tsum_2 = 0\n\t\tsum_1_sq = 0\n\t\tsum_2_sq = 0\n\t\tproduct = 0\n\n\t\tsimilarity.each do |mov|\n\t\t\tsum_1 += @train_data[u1].return_rating(mov)\n\t\t\tsum_1_sq += @train_data[u1].return_rating(mov)**2\n\t\t\tsum_2 += @train_data[u2].return_rating(mov)\n\t\t\tsum_2_sq += @train_data[u2].return_rating(mov)**2\n\t\t\tproduct += @train_data[u1].return_rating(mov)*@train_data[u2].return_rating(mov)\n\t\tend\n\n\t\tnumerator = product - (sum_1*sum_2/similarity.length)\n\t\tdenom = Math.sqrt((sum_1_sq-(sum_1**2)/similarity.length)*(sum_2_sq-(sum_2**2)/similarity.length))\n\n\t\tif denom == 0 \n\t\t\treturn 0\n\t\tend\n\t\treturn numerator/denom\n\tend",
"def similarity(user1, user2, user_rates)\n user1_rate = user_rates[user1]\n user2_rate = user_rates[user2]\n dot_product = user1_rate.reduce(0) { |sum, (k, v)| sum + v * user2_rate[k] }\n user1_magnitude = compute_magnitude(user1_rate)\n user2_magnitude = compute_magnitude(user2_rate)\n dot_product / (user1_magnitude * user2_magnitude)\n end",
"def similarity(user1, user2)\n\t\tall_movie = @userhash[user1].map{|e| e[0]} | @userhash[user2].map{|e| e[0]}\n\t\tshared_movie = @userhash[user1].map{|e| e[0]} & @userhash[user2].map{|e| e[0]}\n\t\tscoretotal = 0\n\t\tshared_movie.each do |movie|\n\t\t\tscoretotal += (@moviehash[movie][user1] - @moviehash[movie][user2]).abs\n\t\tend\n\t\tnumdiff = all_movie.length-shared_movie.length\n\t\tsimilarity = (1-(scoretotal+numdiff*4.0)/all_movie.length/5.0).round(2)\n\tend",
"def compute_score\n @query.items.map.with_index do |element, index|\n weight(index) * weight(@classification.items.index(element))\n end.sum\n end",
"def similar_items( item_id )\n items = []\n response = Amazon::Ecs.similarity_lookup( item_id.to_s, :response_group => 'Large,Reviews,Similarities' )\n response.items.each do |item|\n items << Book.new( item )\n end\n return items\n end",
"def most_similar (user1)\n\t\tuser1 = user1.to_s\n\t\tsimilarity_list = Array.new\n\t\t@user_rating_index.each_key do |key|\n\t\t\tunless key == user1 \n\t\t\t\tpair = Array.new()\n\t\t\t\tpair = [similarity(user1, key), key]\n\t\t\t\tsimilarity_list << pair\n\t\t\tend \n\t\tend\n\t\tsimilarity_list= similarity_list.sort\n\t\treturn similarity_list\n\tend",
"def similarity(user1, user2)\n\t\tif @userdata.has_key? user1.to_s.to_sym and @userdata.has_key? user2.to_s.to_sym\n\n\t\t\tsim_rating = 0\n\t\t\tuser1ratings = @userdata[user1.to_s.to_sym]\n\t\t\tuser2ratings = @userdata[user2.to_s.to_sym]\n\t\t\tuser2ids = []\n\t\t\tuser2ratings.each{ |id, rating| user2ids.push id }\n\t\t\tuser1ratings.each{ |id, rating| sim_rating += 5 - (rating - user2ratings[user2ids.index id][1]).abs if user2ids.include? id}\n\t\t\t\t\treturn sim_rating\n\t\telse\n\t\t\tputs \"User not found\"\n\t\t\treturn nil\n\t\tend\n\tend",
"def 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 sim_distance(preferences, person1, person2)\n have_movies_in_common = preferences[person1].detect {|movie, rating| preferences[person2].keys.include?(movie) }\n \n # if they have no ratings in common, return 0 \n return 0 unless have_movies_in_common\n \n # Add up the squares of all the differences \n sum_of_squares = 0\n preferences[person1].each do |movie, rating| \n sum_of_squares += (rating - preferences[person2][movie])**2 if preferences[person2].keys.include?(movie) \n end\n\n return 1/(1 + sum_of_squares)\nend",
"def update_similarity(matrix, similarity, row_range, column_range)\n row_range.to_a.each do |i|\n column_range.to_a.each do |j|\n matrix[i][j] = similarity if matrix[i][j] < similarity\n end\n end\n end",
"def similarity(user1, user2)\n @user_list[user1].similarity(@user_list[user2])\n end",
"def get_recommended_items(data, item_sim, user)\n user_rating = data[user]\n scores = {}\n total_sim = {}\n\n user_rating.each do |item, rating|\n item_sim[item].each do |similarity, item2|\n if user_rating[item2].nil?\n # weighted sum of rating times similarity\n scores[item2] ||= 0\n scores[item2] += similarity*rating\n\n # sum of all similarities\n total_sim[item2] ||= 0\n total_sim[item2] += similarity\n end\n end\n end\n\n rankings = scores.collect do |item, score|\n [score/total_sim[item], item]\n end\n rankings.sort!\n rankings.reverse! \n end",
"def set_similarity_cache_for(item1, item2, sim)\n @cached_similarities[\"#{item1}_#{item2}\"] = sim\n end",
"def update_similarities_for(user_id)\n user_id = user_id.to_s # For comparison. Redis returns all set members as strings.\n similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n\n # Only calculate similarities for users who have rated the items that\n # this user has rated\n relevant_user_ids = Recommendable.config.ratable_classes.inject([]) do |memo, klass|\n gemd_set = Recommendable::Helpers::RedisKeyMapper.gemd_set_for(klass, user_id)\n disgemd_set = Recommendable::Helpers::RedisKeyMapper.disgemd_set_for(klass, user_id)\n\n item_ids = Recommendable.redis.sunion(gemd_set, disgemd_set)\n\n unless item_ids.empty?\n sets = item_ids.map do |id|\n gemd_by_set = Recommendable::Helpers::RedisKeyMapper.gemd_by_set_for(klass, id)\n disgemd_by_set = Recommendable::Helpers::RedisKeyMapper.disgemd_by_set_for(klass, id)\n\n [gemd_by_set, disgemd_by_set]\n end\n\n memo | Recommendable.redis.sunion(*sets.flatten)\n else\n memo\n end\n end\n\n relevant_user_ids.each do |id|\n next if id == user_id # Skip comparing with self.\n Recommendable.redis.zadd(similarity_set, similarity_between(user_id, id), id)\n end\n\n if knn = Recommendable.config.nearest_neighbors\n length = Recommendable.redis.zcard(similarity_set)\n kfn = Recommendable.config.furthest_neighbors || 0\n\n Recommendable.redis.zremrangebyrank(similarity_set, kfn, length - knn - 1)\n end\n\n true\n end",
"def update_similarities_for_(user_id)\n user_id = user_id.to_s # For comparison. Redis returns all set members as strings.\n similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)\n\n Recommendable.set_shard_key user_id\n\n # Only calculate similarities for users who have rated the items that\n # this user has rated\n relevant_user_ids = Recommendable.config.ratable_classes.inject([]) do |memo, klass|\n liked_set = Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, user_id)\n disliked_set = Recommendable::Helpers::RedisKeyMapper.disliked_set_for(klass, user_id)\n\n item_ids = Recommendable.redis.sunion(liked_set, disliked_set)\n\n unless item_ids.empty?\n sets = item_ids.map do |id|\n liked_by_set = Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(klass, id)\n disliked_by_set = Recommendable::Helpers::RedisKeyMapper.disliked_by_set_for(klass, id)\n\n [liked_by_set, disliked_by_set]\n end\n\n memo | Recommendable.redis.sunion(*sets.flatten)\n else\n memo\n end\n end\n\n similarity_values = relevant_user_ids.map { |id| similarity_between_(user_id, id) }\n Recommendable.redis.pipelined do\n relevant_user_ids.zip(similarity_values).each do |id, similarity_value|\n next if id == user_id # Skip comparing with self.\n Recommendable.redis.zadd(similarity_set, similarity_value, id)\n end\n end\n\n if knn = Recommendable.config.nearest_neighbors\n length = Recommendable.redis.zcard(similarity_set)\n kfn = Recommendable.config.furthest_neighbors || 0\n\n Recommendable.redis.zremrangebyrank(similarity_set, kfn, length - knn - 1)\n end\n\n true\n end",
"def similarity(user1, user2)\n count = 0\n similar = 0\n #to make a shorter comparison, we loop on the shorter movie list\n if movies(user1).length > movies(user2).length\n u1 = user2\n u2 = user1\n else\n u1 = user1\n u2 = user2\n end\n\n @usermap[u1].each do |m1, r1|\n #if user1 and user2 have both rated one movie m, we compare the rating they made\n #and the difference bewteen these two ratings indicates their similarity. The smaller\n #the difference is, the more similar these users are.\n if @usermap[u2].has_key?(m1)\n count += 1\n similar += 5 - (r1 - @usermap[u2][m1]).abs\n end\n end\n\n if count == 0\n 0\n else\n #we calculate the average to get a more convincing similarity constant\n similar/count.to_f\n end\n end",
"def similarity(user1, user2) \n movie_in_common = find_common_movies(user1,user2)\n\n if movie_in_common.empty?\n return 0.0\n end\n simil = calculate_similarity(movie_in_common)\n return (simil/movie_in_common.size).round(2)\n end",
"def calculate_similarity(user_search_term = nil)\n assign_category_jaccard_score unless user_categories.empty?\n assign_score_for_relevant_work_links\n assign_levenstein_score(user_search_term)\n end",
"def optimize3(weight, cost=0, items = $items)\r\n return cost if weight <= 0 || items.empty?\r\n # puts \"#{weight}\\t#{cost}\\t#{items.collect{|i| i.weight}.join(' ')}\"\r\n same_ratio = items.find_all { |i| i.ratio == items[0].ratio }\r\n global_best = nil\r\n same_ratio.size.times do |x|\r\n if weight % items[x].weight == 0\r\n return items[x].cost * (weight / items[x].weight) + cost\r\n end\r\n \r\n best = (x == 0) ? items[x].cost * (weight / items[x].weight + 1) + cost : nil\r\n \r\n (items - [items[x]]).each do |item|\r\n if x == 0\r\n c = optimize3(weight % items[x].weight, items[x].cost * (weight / items[x].weight) + cost, items - [items[x]])\r\n else\r\n c = optimize3(weight - items[x].weight, items[x].cost + cost, items)\r\n end\r\n best = c if (best.nil? || c < best)\r\n end\r\n global_best = best if best && (global_best.nil? || best < global_best)\r\n end\r\n global_best\r\nend",
"def similarity(user1, user2)\n similar_movies_avg = []\n\n #fill in user1_data and user2_data\n #find similar watched movies, remove differences in both lists\n $unique_user_data[user1.to_i - 1].each_key {|movieId, rating|\n if $unique_user_data[user2.to_i - 1].has_key?(movieId)\n similar_movies_avg.push((rating.to_i - $unique_user_data[user2.to_i - 1][movieId].to_i).abs)\n end\n }\n #find average\n return similar_movies_avg.inject{ |sum, el| sum + el }.to_f / similar_movies_avg.size\n end",
"def calculate_similarity(questions)\n raise ArgumentError, \"None question specified.\" if questions.empty?\n similarities = questions.map { |question| question_similarity(question) }\n similarities.compact!\n\n return 0 if similarities.empty?\n similarities.avg\n end",
"def similarity(other_user)\n return 0 if common_bands(other_user).empty?\n\n 1 / (1 + cumulative_euclidean_distance(other_user))\n end",
"def prediction(user, item)\n av_user = user_average_rating(user)\n upper_sum, bottom_sum = 0, 0\n neighbours = get_neighbours(user)\n\n neighbours.each_with_index do |neighbour, i|\n if neighbour_rating = Review.where(user_id: neighbour.id, item_id: item.id).first\n upper_sum = upper_sum + ( similarity(user, neighbour) * (neighbour_rating.rating - user_average_rating(neighbour)) )\n bottom_sum = bottom_sum + similarity(user, neighbour)\n end\n\n end\n\n if upper_sum > 0 and bottom_sum > 0\n av_user + (upper_sum / bottom_sum)\n else\n 0\n end\n end",
"def score_motifs(motifs)\n # motifs is a ruby Matrix\n # To define scoring, consider t DNA sequences, each of length n, and select a k-mer \n # from each sequence to form a collection Motifs, which we represent as a t × k motif matrix.\n # Our goal is to select k-mers resulting in the most “conserved” motif matrix, meaning the matrix with the \n # most upper case letters (and thus the fewest number of lower case letters). Leaving aside the question of\n # how we select such k-mers, we will first focus on how to score the resulting motif matrices,\n # defining Score(Motifs) as the number of unpopular (lower case) letters in the motif matrix Motifs.\n # Our goal is to find a collection of k-mers that minimizes this score.\n\n # Motifs\n # T C G G G G g T T T t t \n # c C G G t G A c T T a C\n # a C G G G G A T T T t C\n # T t G G G G A c T T t t\n # a a G G G G A c T T C C\n # T t G G G G A c T T C C\n # T C G G G G A T T c a t\n # T C G G G G A T T c C t\n # T a G G G G A a c T a C\n # T C G G G t A T a a C C\n\n # Score \n # 3 + 4 + 0 + 0 + 1 + 1 + 1 + 5 + 2 + 3 + 6 + 4 = 30 \n\n # For now lets assume the input 'motifs' contain the upcase and lowercase encoded in it\n # If not we have to implement that in figuring out the score\n score = 0\n\n (0..(motifs.column_count-1)).each do |col_i|\n col_array = motifs.column(col_i)\n dna_freq = { \"A\" => 0, \"C\" => 0, \"G\" => 0, \"T\" => 0}\n col_array.each do |val|\n # score += 1 if val == val.downcase\n dna_freq[val.upcase] += 1\n end\n cnt_arr = dna_freq.values.sort\n count = 0\n cnt_arr.pop\n cnt_arr.each {|val| count += val}\n score += count\n end\n\n return score\n end",
"def damerau_levenshtein(other)\n n, m = self.length, other.length\n return m if n == 0\n return n if m == 0\n matrix = Array.new(n+1) do |i|\n Array.new(m+1) do |j|\n if i == 0 then j\n elsif j == 0 then i\n else 0 end\n end\n end\n (1..n).each do |i|\n (1..m).each do |j|\n cost = (self[i] == other[j]) ? 0 : 1\n delete = matrix[i-1][j] + 1\n insert = matrix[i][j-1] + 1\n substitution = matrix[i-1][j-1] + cost\n matrix[i][j] = [delete, insert, substitution].min\n if (i > 1) && (j > 1) && (self[i] == other[j-1]) && (self[i-1] == other[j])\n matrix[i][j] = [matrix[i][j], matrix[i-2][j-2] + cost].min\n end\n end\n end\n return matrix.last.last\n end",
"def calc_matrix_q(distance_matrix)\n m = Marshal.load(Marshal.dump(distance_matrix))\n sums = Array.new( distance_matrix.length ) { 0 }\n for i in 1...sums.length\n sums[i] = get_sum(distance_matrix, i)\n end \n const = $r - 2\n for i in 1...distance_matrix.length\n for j in i+1...distance_matrix.length\n m[i][j] = const * distance_matrix[i][j] - sums[i] - sums[j]\n m[j][i] = m[i][j]\n end\n end\n m\nend",
"def similarity(user1_id, user2_id)\n raise 'At least one user specified does not exist.' unless @movie_database.users_include?(user1_id, user2_id)\n user_common_movies = @movie_database.movies_in_common(user1_id, user2_id)\n\n return 0.0 if user_common_movies.empty? # most common case\n\n rating_sum = user_common_movies.inject(0) { |sum, movie| sum + user_rating_difference(movie, user1_id, user2_id) }\n max_rating_sum = 4 * user_common_movies.length\n 100.0 - (rating_sum.to_f / max_rating_sum.to_f * 100.0).round(1)\n end",
"def same?\n similarities.size == 1 && similarities.first.distance.zero? # The same\n end",
"def similarity_with(user)\n query_result = UserConnectionQuery.new.similarity(\n user_1: self,\n user_2: user\n ).first\n if query_result then query_result.similarity else nil end\n end",
"def similarity(u1,u2)\n\t\tsimilarity=0\n\t\twatched_u1=@db.get_movie_by_user(u1,:base)\n\t\twatched_u2=@db.get_movie_by_user(u2,:base)\n\t\twatched_u1.each do |movie,rate|\n\t\t\tif watched_u2.has_key?(movie)\n\t\t\t\tsimilarity+=5-(watched_u2[movie].to_i-watched_u1[movie].to_i).abs\n\t\t\tend\n\t\tend\n\t\treturn similarity\n\tend",
"def similarity(user1,user2)\n\t\tsim = 0\n\t\tfirst_user = @user_set[\"#{user1}\"].sort_by{|k, v| k.to_i}.to_h\n\t\tsecond_user = @user_set[\"#{user2}\"].sort_by{|k, v| k.to_i}.to_h\n\t\tin_common = first_user.keys & second_user.keys\n\t\tin_common.each do |movie|\n\t\t\tif (first_user[movie].to_i.between?(second_user[movie].to_i-1, second_user[movie].to_i+1))\n\t\t\t\tsim += 1\n\t\t\tend\n\t\tend\n\t\treturn sim\n\tend",
"def most_similar (u1)\n\t\thash_user_similar = Hash.new\n\t\t@train_data.each_key do |d|\n\t\t\thash_user_similar.store(d, pearson_similarity(u1,d))\n\t\tend\n\t\thash_user_similar.delete(u1)\n\t\treturn sort_decrease_order(hash_user_similar)\n\n\tend",
"def calcAdjustment(matrix,totalGenes)\n #score adjustment for col/row sum\n colAdj = 0\n matrix.colSums.each{|sum|\n colAdj += Math.log2star(sum)\n }\n \n rowAdj = 0\n matrix.rowSums.each{|sum|\n rowAdj += Math.log2star(sum)\n }\n\n # each row gets sorted by its sum \n rowSortAdj = matrix.rowSums.calcUniqPermutationsLog2\n colSortAdj = matrix.colSums.calcUniqPermutationsLog2\n sortAdj = rowSortAdj + colSortAdj\n\n # score adjustment for which set of N genes to use \n # (think \"multiple testing\" via binomial coefficient)\n testAdj = Math.binomCoefficientLog2(totalGenes,matrix.numRows)\n\n return colAdj + rowAdj + testAdj +sortAdj\nend",
"def similarity_with(rater)\n rater.create_recommended_to_sets\n agreements = common_likes_with(rater, :return_records => false).size\n agreements += common_dislikes_with(rater, :return_records => false).size\n disagreements = disagreements_with(rater, :return_records => false).size\n \n similarity = (agreements - disagreements).to_f / (likes.count + dislikes.count)\n rater.destroy_recommended_to_sets\n \n return similarity\n end",
"def similarities_between_users_answers(question)\n answers = select_users_answers(question)\n similarities = []\n\n answers[:user_1].each do |user_1_answer|\n answers[:user_2].each { |user_2_answer|\n similarities << user_1_answer.similarity_with(user_2_answer)\n }\n end\n\n similarities.compact\n end",
"def most_similar(query, word_to_id, id_to_word, word_matrix, top: 5)\n unless word_to_id.include?(query)\n printf(\"%s not found\\n\", query)\n return\n end\n\n puts '[Query] ' + query\n\n query_id = word_to_id[query]\n query_vec = word_matrix[query_id, true]\n\n # similarity = word_matrix.map { |vec| cos_similarity(vec, query_vec) }\n\n similarity = []\n\n word_matrix.shape[0].times do |idx|\n vec = word_matrix[idx, true]\n similarity[idx] = cos_similarity(vec, query_vec)\n end\n\n sorted_indexes = similarity.map.with_index.sort.map(&:last).reverse\n\n count = 0\n sorted_indexes.each do |idx|\n next if idx == query_id\n\n printf(\" %s: %s\\n\", id_to_word[idx], similarity[idx])\n count += 1\n break if count == top\n end\nend",
"def sim_euclidean(prefs, person1, person2)\n #find items in common\n shared = {}\n prefs[person1].each do |k,v|\n if prefs[person2][k] != nil\n shared[k] = 1\n end\n end\n\n #both persons doesn't have anything in common\n if shared.length == 0\n return 0\n end\n\n #calculate sum of squares\n sum_of_squares = 0\n shared.each do |k,v|\n sum_of_squares += (prefs[person1][k] - prefs[person2][k]) ** 2\n end\n\n #return euclidean distance. 1 is added to denominator to avoid divide by zero\n 1/(1 + sqrt(sum_of_squares))\nend",
"def similar(*asins)\n params = asins.last.is_a?(Hash) ? asins.pop : {:SimilarityType => :Random, :ResponseGroup => :Medium}\n response = call(params.merge(:Operation => :SimilarityLookup, :ItemId => asins.join(',')))\n arrayfy(response['SimilarityLookupResponse']['Items']['Item']).map {|item| handle_type(item, :item)}\n end",
"def orderItem()\r\n$globalArr = $globalArr.sort_by { |e| e[2] }\r\nfinalAns = []\r\nfinalAns.push($globalArr.shift)\r\n\twhile $globalArr.size > 0\r\n\t\tcurrentPost = finalAns.last\r\n\t\tcurrentPostRow = currentPost[1][0]\r\n\t\tcurrentPostCol = currentPost[1][1]\r\n\t\tfor r in 0...$globalArr.length\r\n\t\t\tpos = $globalArr[r][1]\r\n\t\t\tdistanceFromPreviousItem = calculateDistance(currentPostRow, currentPostCol, pos[0], pos[1])\r\n\t\t\t$globalArr[r][2] = distanceFromPreviousItem\r\n\t\tend\r\n\t\t$globalArr = $globalArr.sort_by { |e| e[2] }\r\n\t\tfinalAns.push($globalArr.shift)\r\n\tend\r\n\t$BestAns.push(finalAns.collect {|ind| ind[0]})\r\n\t#puts \"Order By Greedy: \" + finalAns.collect {|ind| ind[0]}.to_s\r\nend",
"def fitness\n Sequences.inject(0.0) do |fitness, sequence|\n # count matches\n matches = 0\n 0.upto(size - 1) do |index|\n if(self[index] == sequence[0][index])\n matches += 1\n end\n end\n # more is worse\n fitness - (sequence[1] - matches).abs\n end\n end",
"def get_recommendation(data, key, metric = Pearson.new)\n totals = {}\n sim_sums = {}\n\n others = data.keys - [key]\n others.each do |other|\n sim = metric.distance(data, key, other)\n\n # only check others with similarity > 0\n if sim > 0\n data[other].each do |item, score|\n # only check item not rated by me\n if data[key][item].nil? or data[key][item] == 0\n totals[item] = 0 if totals[item].nil?\n sim_sums[item] = 0 if sim_sums[item].nil?\n\n totals[item] += score * sim\n sim_sums[item] += sim\n end\n end\n end\n end\n\n rankings = totals.collect do |item, score|\n [score/sim_sums[item], item] \n end\n rankings.sort!\n rankings.reverse!\n end",
"def compute_similarities(sign, diagonal=true)\n self.add_similarity(self.brothers, sign * 0.5, diagonal) \n self.add_similarity(self.ancestors, sign * 0.25, diagonal) \n self.category.parent.children.each { |brother_category|\n self.add_similarity(Product.brothers_bis(brother_category.id), sign * 0.1, diagonal) unless brother_category.id == self.category_id\n } if self.category.parent\n end",
"def similarity (u1, u2)\r\n\t\t# make sure data is loaded first\r\n\t\tif @user_ratings.nil?\r\n\t\t\tputs \"data has not been loaded\"\r\n\t\t\treturn 0\r\n\t\telse\r\n\t\t\t# make sure users exist before calculating similarity\r\n\t\t\tif check(u1, u2)==1\r\n\t\t\t\tu1_rate_hash = @user_ratings[u1]\r\n\t\t\t\tu2_rate_hash = @user_ratings[u2]\r\n\t\t\t\t# merge the two hashes since that produces a set \r\n\t\t\t\t# then can get the length to get # of unique movies the two users have rated (in case users have not ranked all the same movies)\r\n\t\t\t\tnum_total_movies = u1_rate_hash.merge(u2_rate_hash).keys.length\r\n\t\t\t\t# make combination of all movies that both users ahve seen\r\n\t\t\t\tboth_seen = u1_rate_hash.keys & u2_rate_hash.keys\r\n\t\t\t\tsum = 0\r\n\t\t\t\t# loops throught the movies both users have seen and takes the difference between the ratings\r\n\t\t\t\t# this is subtracted from 4 (the max difference) to give an inverse on the difference if they have the same rating then 4 is added to the sum\r\n\t\t\t\tboth_seen.each do |id|\r\n\t\t\t\t\tsum +=4 - (u1_rate_hash[id] - u2_rate_hash[id]).abs\r\n\t\t\t\tend\r\n\t\t\t\t# the formula for similarity\r\n\t\t\t\t# the # movies both have seen /the number of unique movies both have seen\r\n\t\t\t\t# this gives a percentage of similarity between the movies both users have rated\r\n\t\t\t\t# ensures similarity in preference of movies not just ratings\r\n\t\t\t\t# those who have more similar taste in movies ranked will have thier percentage of similarity affected less as it will be close to 1\r\n\t\t\t\t# where those who have disparate tastes in music will be closer to 0 reducing the total score and reflecting their difference in tastes\r\n\t\t\t\t# the sum is divided by 0 to normalize it(if all ranks are the same the sum comes to 4*number of movies both seen \r\n\t\t\t\t# and needs to be removed to get a # below #movies both seen)\r\n\t\t\t\t# divide by total number of movies seen to get a percentage of similarity of ranks\r\n\t\t\t\t# +0.0 TO TURN INTO DECIMALS *100 TO GET THE PERCENT\r\n\t\t\t\tn =((0.0+both_seen.length)/(num_total_movies))*(((0.0+sum)/4)/both_seen.length)*100\r\n\t\t\t\tif n.nan?\r\n\t\t\t\t\tn = 0.0\r\n\t\t\t\tend\r\n\t\t\t\treturn n\r\n\t\t\telse\r\n\t\t\t\treturn 0\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def similarly_purchased_item(item = nil)\n if item.present?\n # first we have to determine if this is a stuffed_animal or if this\n # is an accessory\n other_line_items = []\n if item.class.name == \"StuffedAnimal\"\n other_line_items = LineItem.where(stuffed_animal_id: item.id)\n else\n other_line_items = LineItem.where(accessory: item.id)\n end\n\n # extract an array of similar items\n similar_items = self.other_products_purchased item, other_line_items\n\n # take a random sampling of 1 item\n similar_items.sample(1)\n end\n end",
"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 find_similarity(user1Hash, user2Hash)\n similarityValue = -1 # If no common movies watched, return -1\n countMovies = 0.0\n user1Hash.each do |movie, rating|\n if user2Hash.has_key?(movie)\n countMovies += 1\n similarityValue += 4 - (rating.to_i - user2Hash[movie].to_i).abs \n end\n end\n similarityValue != -1 ? (similarityValue + 1) / countMovies : similarityValue\n end",
"def similarity_score(word_1, word_2)\n raise NotImplementedError # TODO\nend",
"def similarity_matrix(comparison, corpora, stats)\n\n cov = []\n corpora.length.times{|i| cov[i] = [] }\n\n corpora.length.times{|i|\n corpora.length.times{|j|\n if not comparison.symmetric? or (i >= j) then\n cov[i][j] = comparison.compare(corpora[i], stats[i], corpora[j], stats[j])\n\n\n # cov[i][j] = covariance(corpora[i], stats[i], corpora[j], stats[j])\n # cor[i][j] = cov[i][j] / (stats[i][:sd] * stats[j][:sd])\n\n # puts \"COV(#{i},#{j}) = #{covariance(corpora[i], stats[i], corpora[j], stats[j])}\"\n # puts \"PMCC(#{i},#{j}) = #{(covariance(corpora[i], stats[i], corpora[j], stats[j])) / (stats[i][:sd] * stats[j][:sd])}\"\n end\n }\n }\n\n return cov\nend",
"def gram_schmidt\n a = clone\n n = column_size\n m = row_size\n q = Matrix.new(m, n){0}\n r = Matrix.zero(n)\n for k in 0...n\n r[k,k] = a[0...m, k].norm\n q[0...m, k] = a[0...m, k] / r[k, k]\n for j in (k+1)...n\n r[k, j] = q[0...m, k].t * a[0...m, j]\n a[0...m, j] -= q[0...m, k] * r[k, j]\n end\n end\n return q, r\n end",
"def processdup_all(c)\n prev_base = nil\n show = false\n c.each do |l|\n base = get_base(l[:file])\n if prev_base && base != prev_base\n show = true\n break\n end\n prev_base = base\n end\n if show\n c.each do |l|\n puts \"#{get_file(l[:file])} similarity #{l[:count]}\"\n end\n puts \"\"\n end\nend",
"def similarity(user1, user2)\n user1Hash = @allUsersHash[user1]\n user2Hash = @allUsersHash[user2]\n return \"ERROR: USER ID #{user1} is not in the database\" if user1Hash.empty?\n return \"ERROR: USER ID #{user2} is not in the database\" if user2Hash.empty?\n find_similarity(user1Hash, user2Hash)\n end",
"def getRecommendations()\n totals=Hash.new(0)\n simSum=Hash.new(0)\n \n \n @prefs.each_pair do |other,ranks|\n \n # next if it's me\n next if other == @person\n \n # check the affinity \n sim = @similarity.compute(other)\n \n # next if no affinity\n next if sim <= 0\n \n # for each unranked element\n ranks.each_pair do |name,rank|\n if !@prefs[@person].include?(name) or @prefs[@person].length == 0\n \n totals[name] += rank * sim\n simSum[name] += sim\n \n end\n end \n end\n \n # Array creation\n totals.to_a.collect do |e|\n [e[1]/simSum[e[0]],e[0]]\n end.sort do |a,b|\n b[0] <=> a[0]\n end\n \n end",
"def top_matches(item_prefs, item, number=5)\n scores = []\n\n item_prefs.keys.each do |other|\n if other != item\n similarity = distance_similarity(item_prefs, item, other)\n\n if similarity > 0\n scores << [similarity, other]\n end\n end\n end\n\n scores = scores.sort_by { |score| -score[0] }\n\n return scores[0, number]\n end",
"def predict_for(user_id, klass, item_id)\n user_id = user_id.to_s\n item_id = item_id.to_s\n\n liked_by_set = Recommendations::Helpers::RedisKeyMapper.liked_by_set_for(klass, item_id)\n similarity_sum = 0.0\n\n # Get sum of similarities of each item in set\n similarity_sum = similarity_total_for(user_id, liked_by_set)\n\n liked_by_count = Recommendations.redis.pipelined do\n Recommendations.redis.scard(liked_by_set)\n end\n prediction = similarity_sum / (liked_count).to_f\n prediction.finite ? prediction : 0.0\n end",
"def calculate\n max_row_index, max_column_index = setup\n\n bordered_image.noise[0..max_row_index].each_with_index do |row, row_index|\n row[0..max_column_index].each_with_index do |_, index|\n row_range, column_range = calculate_window_range(row_index, index, invader)\n radar_window = bordered_image.noise_range(row_range, column_range)\n similarity = window_similarity(invader, radar_window)\n update_similarity(matrix, similarity, row_range, column_range) if similarity\n end\n end\n\n matrix\n end",
"def similarity(user1,user2)\n user1,user2=user2,user1 if user1 > user2\n result=@similarity_cache[[user1,user2]]\n if result.nil?\n result=@similarity_func.call(data,user1,user2)\n @similarity_cache[[user1,user2]]=result\n end\n result\n end",
"def group(array)\n array.map do |item|\n {\n item: item,\n matches: (array - [item]).map do |item_cmp|\n {\n match: item_cmp,\n distance: calculate_distance(item, item_cmp)\n }\n end\n }\n end\n end",
"def item_total_correlation\n vecs = @ds.vectors.to_a\n @itc ||= vecs.inject({}) do |a,v|\n total=@ds.vector_sum(vecs - [v])\n a[v]=Statsample::Bivariate.pearson(@ds[v],total)\n a\n end\n end",
"def similarity(other_user)\n similarity_count = 0\n @rating_list.each_value do |rating|\n if other_rating = other_user.rating_list[rating.movie_id] and other_rating.rating.to_i >= rating.rating.to_i - 1 and other_rating.rating.to_i <= rating.rating.to_i + 1\n similarity_count += 1\n end\n end\n return similarity_count\n end",
"def compute_sequence_similarity(ref_sequence, other_sequence)\n total = Repositext::Utils::ArrayDiffer.diff(ref_sequence, other_sequence)\n same = total.find_all { |e| '=' == e.action }\n return 1.0 if same.length == total.length\n return 0.0 if 0 == total.length\n same.length / total.length.to_f\n end"
] |
[
"0.71388024",
"0.6949338",
"0.6805654",
"0.6531122",
"0.631466",
"0.6265979",
"0.6025418",
"0.5986484",
"0.5955019",
"0.595329",
"0.5891528",
"0.5864645",
"0.58561486",
"0.58153576",
"0.57817435",
"0.5746806",
"0.5706811",
"0.5704644",
"0.5701195",
"0.5653002",
"0.5647565",
"0.5637372",
"0.562145",
"0.56124234",
"0.5589668",
"0.5560565",
"0.5503439",
"0.5503439",
"0.54950106",
"0.5484727",
"0.5469828",
"0.5458978",
"0.54552925",
"0.5436054",
"0.5428676",
"0.54244924",
"0.54108214",
"0.5409254",
"0.5409254",
"0.54001015",
"0.53904945",
"0.5386259",
"0.5385865",
"0.53706056",
"0.5368536",
"0.5366404",
"0.5363581",
"0.5358224",
"0.5357381",
"0.535635",
"0.53513515",
"0.53359675",
"0.53315645",
"0.53311855",
"0.53196746",
"0.53100467",
"0.5299801",
"0.5287335",
"0.52717733",
"0.5268946",
"0.5263586",
"0.52505463",
"0.5217596",
"0.5209601",
"0.51994306",
"0.5191623",
"0.5185541",
"0.5174621",
"0.5164459",
"0.516012",
"0.51184314",
"0.510032",
"0.50898755",
"0.5085791",
"0.5083603",
"0.5082115",
"0.50738037",
"0.50735223",
"0.5069148",
"0.5047749",
"0.50386226",
"0.5037003",
"0.5032614",
"0.502864",
"0.502645",
"0.50163496",
"0.5004548",
"0.5002806",
"0.4957306",
"0.49561855",
"0.49446794",
"0.4938266",
"0.49345025",
"0.4929504",
"0.49180627",
"0.4906579",
"0.48894155",
"0.4883605",
"0.48835096",
"0.48772413"
] |
0.73868406
|
0
|
retrieve all item_ids in the matrix
|
def all_items
# retzrb => [ "item23", "item42", "item17", (...) ]
raise "implemented in subclass"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all_item_ids\n [id] + item_ids\n end",
"def ids\n (1..get_item_count).map do |index|\n get_item_identifier index\n end\n end",
"def items\n if @items.nil?\n ids = tire_response.results.map { |item| item['id'] }\n items = klass.where(:id => ids).group_by(&:id)\n @items = ids.map{ |id| items[id.to_i] }.flatten.compact\n end\n @items\n end",
"def omim_ids\n @table.keys\n end",
"def ids(table)\n res = connection.query(\"SELECT id FROM #{table} GROUP BY id\")\n id_list = []\n res.each { |i| id_list << i[0].to_i }\n return id_list\n end",
"def ids\n pluck(:id)\n end",
"def get_ids(table)\r\n valid_ids = []\r\n table_info = @db.execute(\"SELECT * FROM #{table}\")\r\n table_info.each do |line|\r\n line_info = []\r\n line.each do |name, value|\r\n if name == 'id'\r\n valid_ids << value\r\n end\r\n end\r\n end\r\n valid_ids\r\n end",
"def rows\n @pz.group_by.each_with_index { |val, n| row_id(n) }\n end",
"def kenim_ids\n @kenim_ids = []\n kenim.each do |k|\n @kenim_ids.push( k._id )\n end\n return @kenim_ids\n end",
"def article_ids\n query('SELECT Id FROM KnowledgeArticle').map(&:Id)\n end",
"def collection_to_id_array(col)\n ids = Array.new\n col.each do |i|\n ids << i.id\n end\n ids\n end",
"def all_ids(_context)\n raise NotImplementedError\n end",
"def datastore_ids\n array = Array.new\n\n self.each(\"DATASTORES/ID\") do |id|\n array << id.text.to_i\n end\n\n return array\n end",
"def ids\n @store.transaction do\n @store.roots\n end\n end",
"def extract_ids\n # no-op\n end",
"def all_ids\n db.transaction(true) do |db|\n extract_model_ids(db)\n end\n end",
"def ids\n @nodes.map(&:id)\n end",
"def get_ids_of_all_jobs\r\n result = [id, parent_job_id].compact\r\n result << Job.where([\"parent_job_id in (?)\",result]).select(:id).collect(&:id)\r\n result.flatten.uniq\r\n end",
"def product_ids\n new_record? ? (@products_cache ? @products_cache.map(&:id) : []) : self.products.map(&:id)\n end",
"def student_ids\n ids = []\n scores_table = frm.table(:id=>\"editTotalResults:totalScoreTable\").to_a\n scores_table.delete_at(0)\n scores_table.each { |row| ids << row[1] }\n return ids\n end",
"def all_ids\n @all_ids ||= @ids_fenotypes.keys\n @all_ids\n end",
"def schema_article_ids\n ids = []\n if self.schema.respond_to?(:each_key)\n self.schema.each_key do |item|\n ids += self.schema[item]['ids']\n end\n end\n ids\n end",
"def ids\n root.ids\n end",
"def ids\n @ids ||= []\n end",
"def item_list\n list = Array.new;\n\n if @inv.respond_to?(\"each\")\n @inv.each do |invItem|\n list.push(invItem.first_id)\n end\n end\n \n return list.join(\", \");\n end",
"def id_list(item, **opt)\n id_split(item).map! { |v| id_obj(v, **opt) }.compact\n end",
"def ids\n self.is_leaf? ? [@ids].flatten : self.children.inject([]) {|result, item| result += item.ids}\n end",
"def product_ids\n new_record? ? (@products ? @products.map(&:id) : []) : self.root.products.map(&:id)\n end",
"def items_from_response\n ids = item_ids\n items = klass.where(:id => ids).group_by(&:id)\n ordered_items(ids, items)\n end",
"def invoice_items\n invoice_items = engine.invoice_item_repository.parse\n invoice_items.select {|invoice_item| invoice_item.item_id == id}\n end",
"def record_ids\n @records.keys\n end",
"def _fetch_internal_id_list(opts = {})\n opts = {\n :collection => JASPAR_DFLT_COLLECTION, \n :tf_name => nil, \n :tf_class => nil,\n :tf_family => nil, \n :matrix_id => nil, \n :tax_group => nil, \n :species => nil,\n :pazar_id => nil, \n :data_type => nil, \n :medline => nil, \n :all => false,\n :all_versions => false\n }.merge(opts)\n\n int_ids = []\n\n # Special case 1: fetch ALL motifs. Highest priority.\n # Ignore all other selection arguments.\n if opts[:all]\n cur = @dbh.query(\"SELECT ID FROM MATRIX\")\n cur.each { |r| int_ids << r[\"ID\"] }\n return int_ids\n end\n\n # Special case 2: fetch specific motifs by their JASPAR IDs. This\n # has higher priority than any other except the above 'all' case.\n # Ignore all other selection arguments.\n if opts[:matrix_id]\n # These might be either stable IDs or stable_ID.version.\n # If just stable ID and if all_versions == 1, return all versions,\n # otherwise just the latest\n if opts[:all_versions]\n opts[:matrix_id].each do |id|\n # ignore vesion here, this is a stupidity filter\n base_id, _ = Bio::Jaspar.split_jaspar_id(id)\n cur = @dbh.query(\"SELECT ID FROM MATRIX WHERE BASE_ID='#{base_id}'\")\n cur.each{ |r| int_ids << r[\"ID\"] }\n end\n else\n opts[:matrix_id].each do |id|\n # only the lastest version, or the requested version\n base_id, version = Bio::Jaspar.split_jaspar_id(id)\n\n unless version\n version = _fetch_latest_version(base_id)\n end\n\n int_id = nil\n if version\n int_id = _fetch_internal_id(base_id, version)\n end\n\n if int_id\n int_ids << int_id\n end\n end\n end\n\n return int_ids\n end\n\n tables = [\"MATRIX AS m\"]\n where_clauses = []\n\n # Select by MATRIX.COLLECTION\n if opts[:collection]\n if opts[:collection].is_a? Array\n # Multiple collections passed in as a list\n clause = \"m.COLLECTION IN ('\"\n clause += opts[:collection].join(\"','\")\n clause += \"')\"\n else\n # A single collection - typical usage\n clause = \"m.COLLECTION='#{opts[:collection]}'\"\n end\n where_clauses << clause\n end\n\n # Select by MATRIX.NAME\n if opts[:tf_name]\n if opts[:tf_name].is_a? Array\n # Multiple names passed in as a list\n clause = \"m.NAME IN ('\"\n clause += opts[:tf_name].join(\"','\")\n clause += \"')\" \n else\n # A single name\n clause = \"m.NAME='#{opts[:tf_name]}'\"\n end\n where_clauses << clause\n end\n\n # Select by MATRIX_SPECIES.TAX_ID\n if opts[:species]\n tables << \"MATRIX_SPECIES AS ms\"\n where_clauses << \"m.ID=ms.ID\"\n\n # NOTE: species are numeric taxonomy IDs but stored as varchars\n # in the DB.\n if opts[:species].is_a? Array\n # Multiple tax IDs passed in as a list\n clause = \"ms.TAX_ID IN ('\"\n clause += opts[:species].join(\"','\")\n clause += \"')\" \n\n else\n # A single tax ID \n clause = \"m.TAX_ID='#{opts[:species]}'\"\n end\n\n where_clauses << clause\n end\n\n # Tag based selection from MATRIX_ANNOTATION\n # Differs from perl TFBS module in that the matrix class explicitly\n # has a tag attribute corresponding to the tags in the database. This\n # provides tremendous flexibility in adding new tags to the DB and\n # being able to select based on those tags with out adding new code.\n # In the JASPAR Motif class we have elected to use specific attributes\n # for the most commonly used tags and here correspondingly only allow\n # selection on these attributes.\n\n # The attributes corresponding to the tags for which selection is\n # provided are:\n\n # Attribute Tag\n # tf_class class\n # tf_family family\n # pazar_id pazar_tf_id\n # medline medline\n # data_type type\n # tax_group tax_group\n \n # Select by TF class(es) (MATRIX_ANNOTATION.TAG=\"class\")\n if opts[:tf_class]\n tables << \"MATRIX_ANNOTATION AS ma1\"\n where_clauses << \"m.ID=ma1.ID\"\n\n clause = \"ma1.TAG='class'\"\n if opts[:tf_class].is_a? Array\n # A list of TF classes\n clause += \" AND ma1.VAL IN ('\"\n clause += opts[:tf_class].join(\"','\")\n clause += \"')\"\n else\n # A single TF class\n clause += \" AND ma1.VAL='#{opts[:tf_class]}'\"\n end\n\n where_clauses << clause\n end\n\n # Select by TF families (MATRIX_ANNOTATION.TAG=\"family\")\n if opts[:tf_family]\n tables << \"MATRIX_ANNOTATION AS ma2\"\n where_clauses << \"m.ID=ma2.ID\"\n\n clause = \"ma2.TAG='family'\"\n if opts[:tf_family].is_a? Array\n # A list of TF families\n clause += \" AND ma2.VAL IN ('\"\n clause += opts[:tf_family].join(\"','\")\n clause += \"')\"\n else\n # A single TF family\n clause += \" AND ma2.VAL='#{opts[:tf_family]}'\"\n end\n\n where_clauses << clause \n end\n\n # Select by PAZAR TF ID(s) (MATRIX_ANNOTATION.TAG=\"pazar_tf_id\")\n if opts[:pazar_id]\n tables << \"MATRIX_ANNOTATION AS ma3\"\n where_clauses << \"m.ID=ma3.ID\"\n\n clause = \"ma3.TAG='pazar_tf_id'\"\n if opts[:pazar_id].is_a? Array\n # A list of PAZAR IDs\n clause += \" AND ma3.VAL IN ('\"\n clause += opts[:pazar_id].join(\"','\")\n clause += \"')\"\n else\n # A single PAZAR ID\n clause += \" AND ma3.VAL='#{opts[:pazar_id]}'\"\n end\n\n where_clauses << clause \n end\n\n # Select by PubMed ID(s) (MATRIX_ANNOTATION.TAG=\"medline\")\n if opts[:medline]\n tables << \"MATRIX_ANNOTATION AS ma4\"\n where_clauses << \"m.ID=ma4.ID\"\n\n clause = \"ma4.TAG='medline'\"\n if opts[:medline].is_a? Array\n # A list of PubMed IDs\n clause += \" AND ma4.VAL IN ('\"\n clause += opts[:medline].join(\"','\")\n clause += \"')\"\n else\n # A single PubMed ID\n clause += \" AND ma4.VAL='#{opts[:medline]}'\"\n end\n\n where_clauses << clause \n end\n\n # Select by data type(s) used to compile the matrix\n # (MATRIX_ANNOTATION.TAG=\"type\")\n if opts[:data_type]\n tables << \"MATRIX_ANNOTATION AS ma5\"\n where_clauses << \"m.ID=ma5.ID\"\n\n clause = \"ma5.TAG='type'\"\n if opts[:data_type].is_a? Array\n # A list of data types\n clause += \" AND ma5.VAL IN ('\"\n clause += opts[:data_type].join(\"','\")\n clause += \"')\"\n else\n # A single data type\n clause += \" AND ma5.VAL='#{opts[:data_type]}'\"\n end\n\n where_clauses << clause \n end\n\n # Select by taxonomic supergroup(s) (MATRIX_ANNOTATION.TAG=\"tax_group\")\n if opts[:tax_group]\n tables << \"MATRIX_ANNOTATION AS ma6\"\n where_clauses << \"m.ID=ma6.ID\"\n\n clause = \"ma6.TAG='tax_group'\"\n if opts[:tax_group].is_a? Array\n # A list of tax IDs\n clause += \" AND ma6.VAL IN ('\"\n clause += opts[:tax_group].join(\"','\")\n clause += \"')\"\n else\n # A single tax ID\n clause += \" AND ma6.VAL='#{opts[:tax_group]}'\"\n end\n\n where_clauses << clause\n end\n\n sql = \"SELECT DISTINCT(m.ID) FROM \" + tables.join(\", \")\n\n if where_clauses\n sql += \" WHERE \" + where_clauses.join(\" AND \")\n end\n\n cur = @dbh.query(sql)\n\n cur.each do |r|\n id = r[\"ID\"]\n if opts[:all_versions]\n int_ids << id\n else\n # is the latest version?\n if _is_latest_version(id)\n int_ids << id\n end\n end\n end\n\n if int_ids.length < 1\n warn(\"Zero motifs returned with current select criteria\")\n end\n\n return int_ids\n end",
"def keys\n\t\t@matrix.keys\n\tend",
"def get_ids(array)\n ids = \"(\"\n array.each do |me|\n ids << me.id.to_s + \",\"\n end\n ids = ids.chomp(\",\")\n ids = ids + \")\"\n return ids\n\n end",
"def source_matrix_ids\n a = Set.new\n experiments.each { |experiment| a.merge(experiment.source_matrix_ids) }\n a.to_a\n end",
"def include_ids?(item_ids)\n all_item_ids == item_ids\n end",
"def image_ids; (images.map(&:id) rescue []); end",
"def image_ids; (images.map(&:id) rescue []); end",
"def get_ids_from(table_name)\n DB::Queries.get_ids_from(table: table_name)\nend",
"def item_inputs\n @operation.inputs.select(&:child_item_id)\n end",
"def items_to_obj\n item_basket = []\n @items.each do |id, nbr|\n nbr.times do |i|\n item_basket << $data_items[id]\n end\n end\n item_basket\n end",
"def all_ids\n json = JSON.parse(http_client.get(\"mobiledevices\"))\n json[\"mobile_devices\"].map { |c| c[\"id\"] }\n end",
"def user_ids\n array = Array.new\n\n self.each(\"USERS/ID\") do |id|\n array << id.text.to_i\n end\n\n return array\n end",
"def invoice_items\n SalesEngine::InvoiceItem.find_all_by_item_id(self.id)\n end",
"def ids\n @keys ||= []\n end",
"def samp_id_to_item_hash(items)\n samp_id_to_item_hash = Hash.new()\n items.each {|i| samp_id_to_item_hash[Item.find(i).sample_id] = i.id}\n return samp_id_to_item_hash\n end",
"def group_ids\n groups.pluck(:id)\n end",
"def active_glm_id_list\n self.active_group_loan_memberships.map{|x| x.id }\n end",
"def user_ids\n users.collect(&:id)\n end",
"def columns\n # This function assumes that each item has the same columns.\n return @items.first.keys\n end",
"def same_ids?(item_ids)\n all_item_ids.sort == item_ids.sort\n end",
"def index \n \t@items = Item.paginate(page: params[:page])\n\n @user_items = current_user.user_items.pluck(:id).uniq\n @all_user_items = UserItem.where(id: @user_items)\n end",
"def unique_metric_ids\n Answer.select(:metric_id).where(company_id: left.id).uniq.pluck :metric_id\n # pluck seems dumb here, but .all isn't working (returns *all card)\nend",
"def to_a\n fetch(ids)\n end",
"def to_a\n fetch(ids)\n end",
"def yale_nd_row_as_set i\n require 'set'\n yale_nd_row(i, :array).to_set\n end",
"def data_matrix_all(coll, data_matrix)\n pas = coll.part_associations\n part_ids = pas.collect(&:part_id)\n das = DataAssociation.where(parent_class: 'Item', parent_id: part_ids)\n pas.each do |pa|\n data_matrix[pa.row][pa.column] = {}\n das.select { |da| da.parent_id == pa.part_id }.each do |da|\n data_matrix[pa.row][pa.column][da.key] = da.value\n end\n end\n data_matrix\n end",
"def ids\n primary_key_array = Array(primary_key)\n\n if loaded?\n result = records.map do |record|\n if primary_key_array.one?\n record._read_attribute(primary_key_array.first)\n else\n primary_key_array.map { |column| record._read_attribute(column) }\n end\n end\n return @async ? Promise::Complete.new(result) : result\n end\n\n if has_include?(primary_key)\n relation = apply_join_dependency.group(*primary_key_array)\n return relation.ids\n end\n\n columns = arel_columns(primary_key_array)\n relation = spawn\n relation.select_values = columns\n\n result = if relation.where_clause.contradiction?\n ActiveRecord::Result.empty\n else\n skip_query_cache_if_necessary do\n klass.connection.select_all(relation, \"#{klass.name} Ids\", async: @async)\n end\n end\n\n result.then { |result| type_cast_pluck_values(result, columns) }\n end",
"def user_ids\n users.pluck(:id)\n end",
"def all_items\n all_items = []\n collections.each do |c|\n c.items.each do |i|\n all_items.push i\n end\n end\n all_items\n end",
"def get_two_items_from(item_class)\n array = []\n id_array = (0..(item_class.count-1)).to_a\n first_id = id_array.sample\n id_array.delete(first_id)\n second_id = id_array.sample\n\n array << item_class[first_id].id\n array << item_class[second_id].id\n array\n end",
"def input_item_id_array(input_names:, op:)\n input_names.map { |n| op.input(n).child_item_id }\n end",
"def update_for_ids\n update_for_items.map(&:package_branch).map(&:id)\n end",
"def get_all_child_collections_ids()\r\n ids = @db_interface.get_all_hash_values(@certain_coll_key)\r\n ids ||= []\r\n return ids\r\n end",
"def key_ids\n @keys.keys\n end",
"def datarows\n return [] if self[:datarows].blank?\n self[:datarows].split(\",\").map(&:to_i)\n end",
"def multi_ids\n params[multi_id_key].split(',')\n end",
"def list_stored_user_ids_ar\n Credential.all.map {|credential| credential.user_id}\nend",
"def user_ids\n self.class.where(id: id).user_ids\n end",
"def user_ids\n @attributes[:user_ids]\n end",
"def user_ids\n @attributes[:user_ids]\n end",
"def user_ids\n @attributes[:user_ids]\n end",
"def get_ids (model_objects)\n ids = []\n if !model_objects.nil?\n \n for model_object in model_objects\n ids.push(model_object.id)\n end\n end\n return ids\n\n end",
"def find_many(array)\n results = CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id IN (#{array.join(\",\")})\")\n \n results_as_objects(results)\n end",
"def player_ids\n\t\tmy_ids = []\n\t\tplayers.each { |player|\n\t\t\tmy_ids << player.id\n\t\t}\n\t\treturn my_ids\n\tend",
"def get_all_postid_for_user(userid)\n postids = Array.new\n postids = Post.where(:user_id => userid).pluck(:id)\n return postids\n end",
"def reset\n @item_ids = []\n end",
"def get_items(user,ex_items)\r\n\t\trv = []\r\n\t\tdb.each { |x,y|\r\n\t\t\trv << y if(x==user)\r\n\t\t\t}\r\n\t\trv - ex_items\r\n\tend",
"def all_maybe_item_id_marker_fields\n maybe_column.buttons(:name => \"itemId[]\")\n end",
"def invoice_items_grouped_by_item(invoice_items)\n FinderClass.group_by(invoice_items, :item_id)\n end",
"def multiple_select_ids(arr) # :doc:\n arr = [arr] unless arr.is_a?(Array)\n arr.collect{|x| x.to_i}.delete_if{|x| x == 0}\n end",
"def items\n result = []\n each_item { |item| result.push(item) }\n result\n end",
"def all\n db.transaction(true) do\n ids = extract_model_ids(db)\n ids.map { |key| db[key] }\n end\n end",
"def all_category_ids\n end",
"def eligible_inventory_item_ids\n where_hash = {\n vendor: promotion.vendor_ids,\n service_id: preferred_service_id,\n item_id: preferred_item_id,\n item_type_id: preferences[:item_type_id]\n }\n @eligible_inventory_item_ids ||= InventoryItem.where(where_hash).ids\n end",
"def child_ids\n ids = [self.id]\n self.children.each do |child|\n ids += child.child_ids\n end\n ids\n end",
"def test_that_it_can_return_all_instances_of_item_by_invoice_id\n engine = SalesEngine.new(\"./data\")\n engine.startup\n assert_equal [539, 528, 523, 535, 529, 541, 530, 534], engine.find_all_items_by_invoice_id(1).map{|item| item.id}\n end",
"def ids\n if Array === key\n Stal.solve(redis, key)\n else\n key.call(\"SMEMBERS\")\n end\n end",
"def all_ids(opts={}, &block)\n user_id = options.delete(:user_id) || User.me.id\n\n opts = options.merge opts\n\n from = \"/users/#{user_id}#{collection_path}/search\"\n\n has_results = true\n ids = []\n\n while has_results && opts[:pages] != opts[:page] do\n params = { limit: opts[:limit],\n offset: opts[:offset] }\n\n path = \"#{from}#{query_string(params)}\"\n data = format.decode(connection.get(path, headers).body) || []\n\n\n results = data[\"results\"]\n has_results = (results.any? and results.count == opts[:limit])\n\n opts[:page ] += 1\n opts[:offset ] += opts[:limit]\n\n yield(results, data, options) if block_given?\n\n ids.concat results\n end\n\n ids\n end",
"def rows\n @array\n end",
"def book_ids(requests)\n return if requests.nil?\n\n arr = []\n requests.each do |r|\n arr << r.book_id\n end\n arr\n end",
"def all_items\r\n list = Array.new\r\n items.each{ |item| list.push(item)}\r\n list\r\n end",
"def get_items\r\n @arr.to_a\r\n end",
"def rows\r\n @all_rows\r\n end",
"def items\n to_return = []\n @items.each do |item_data|\n item_data[:quantity].times do\n to_return << item_data[:title]\n end\n end\n return to_return\n end",
"def identifiers\n request[:ids]\n end",
"def group_ids\n groups.map{|g| g.id}\n end",
"def selected_rows\n @selected_indices\n end",
"def grid_row_items\n # noinspection RubyMismatchedReturnType\n row_items\n end",
"def grid_row_items\n # noinspection RubyMismatchedReturnType\n row_items\n end",
"def ids(things)\n things.map(&:id).join(\",\")\n end"
] |
[
"0.76522875",
"0.7413147",
"0.65557754",
"0.65359426",
"0.62320036",
"0.6201694",
"0.612729",
"0.6087922",
"0.60771424",
"0.60563326",
"0.60553193",
"0.5964694",
"0.5957733",
"0.595444",
"0.5951751",
"0.59078413",
"0.5905141",
"0.5885309",
"0.58731663",
"0.58594424",
"0.58578205",
"0.585008",
"0.5819585",
"0.57952935",
"0.57908434",
"0.57628495",
"0.5752177",
"0.575004",
"0.5748738",
"0.57292134",
"0.5712105",
"0.5709378",
"0.56985646",
"0.5671948",
"0.5663157",
"0.56605965",
"0.5633344",
"0.5633344",
"0.5630788",
"0.56102556",
"0.55842185",
"0.55824417",
"0.55764234",
"0.55659324",
"0.5554172",
"0.5542076",
"0.5539748",
"0.552653",
"0.5508985",
"0.55061966",
"0.5493546",
"0.5492934",
"0.54728967",
"0.54669106",
"0.54669106",
"0.5461058",
"0.5458371",
"0.5454194",
"0.54446125",
"0.5439103",
"0.54277825",
"0.542439",
"0.5422832",
"0.54180604",
"0.54099774",
"0.5408148",
"0.5403913",
"0.5403763",
"0.5396814",
"0.53903025",
"0.53903025",
"0.53903025",
"0.5385382",
"0.53811955",
"0.5375318",
"0.537295",
"0.5370839",
"0.53701466",
"0.5346282",
"0.5345703",
"0.5340906",
"0.5337621",
"0.53358394",
"0.53328645",
"0.53264415",
"0.53259784",
"0.53238565",
"0.532385",
"0.5321027",
"0.53206027",
"0.53085196",
"0.530585",
"0.53039885",
"0.530136",
"0.52984893",
"0.5295556",
"0.5288436",
"0.52876896",
"0.52694356",
"0.52694356",
"0.5266908"
] |
0.0
|
-1
|
delete item_id from the matrix
|
def delete_item(item_id)
raise "implemented in subclass"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n @@all_items.delete(@id)\n end",
"def delete_item(item)\n @get_items.delete(item)\n end",
"def delete_product(item)\r\n\t\tif item.is_a? Enumerable\r\n\t\t\titem.each { |i| @items.delete i }\r\n\t\telse\r\n\t\t\t@items.delete(item)\r\n\t\tend\r\n\tend",
"def remove_item(item_id)\n @items.delete_if { |item| item.id.to_i == item_id.to_i}\n end",
"def remove_item(id)\n @items.delete_at(id)\n end",
"def delete\n\t\t@cart.delete(:item_id)\n end",
"def delete_item(item)\r\n @list.delete(item)\r\n end",
"def delete(item)\n !!@data.delete(item)\n end",
"def delete_item(item)\n @chores.delete(item)\n end",
"def delete_item(unwanted)\r\n @arr.delete(unwanted)\r\n end",
"def remove_row(i)\n rows_ary = to_a\n rows_ary.delete_at(i)\n Matrix.new(*rows_ary)\n end",
"def delete\n association.delete association[element.dataset[:index].to_i]\n end",
"def remove(item)\r\n loc = location_of(item)\r\n loc.remove(item)\r\n end",
"def delete(item)\n item_hash = item.hash\n\n index = item_hash & @mask\n return true if delete_entry @table, index, item_hash, item\n\n index = item_hash.hash & @mask\n return true if delete_entry @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 delete_entry @spill, i.index, item_hash, item\n end\n\n false\n end",
"def deleteItems\n self.items.each do |item|\n item.delete\n end\n end",
"def remove_item (item)\n item_hash[item].delete\nend",
"def remove_item\n\n end",
"def delete_item(hash, item)\n\thash.delete(item)\n\treturn hash \nend",
"def remove_item(item)\n @items.delete(item)\n end",
"def remove item #(item: pointer)\n freeitem item\n delete item\n end",
"def remove_item(item_to_be_removed)\n $groceryhash.delete(item_to_be_removed)\nend",
"def delete_item(iid)\n params = {'pio_iid' => iid}.merge(default_params)\n @connection.delete(:items, iid, params).body\n end",
"def delete_line_item(table)\r\n if table_exists?(table)\r\n print_table(table)\r\n puts \"please choose the id number of the line you'd like to delete.\"\r\n id = get_valid_id(table)\r\n delete = (\"DELETE FROM #{table} WHERE id = #{id}\")\r\n @db.execute(delete)\r\n end\r\n end",
"def remove(item)\r\n @contents.delete(item)\r\n end",
"def delete(item, count = 0)\n conn.lrem key, count, item\n end",
"def remove_item(hash_of_items, item)\n hash_of_items.delete(item)\n hash_of_items\nend",
"def delete_item(list,item)\n\tlist.delete(item)\nend",
"def remove_item(item_list, item)\r\n item_list.delete(item)\r\n item_list\r\nend",
"def delete row_ind\n key, row = @row_refs.at row_ind\n return unless key\n\n if key.atom?\n if @row_refs.delete row_ind\n row.send :remove!\n self\n end\n else\n if row.send :reduce_repeated\n @row_refs.taper row_ind\n self\n end\n end\n end",
"def remove_item(g_hash,item)\n g_hash.delete(item)\nend",
"def remove_item(g_hash,item)\n g_hash.delete(item)\nend",
"def delete(item)\n if @items.include?(item)\n @items.delete_at(item.id)\n true\n else\n false\n end\n end",
"def remove_item(groccery_items, key)\n groccery_items.delete(key)\n p groccery_items\nend",
"def delete_item(list,item)\n list.delete(item)\nend",
"def delete_item(list,item)\n list.delete(item)\nend",
"def remove_item(id:)\n order.items.destroy(id)\n end",
"def remove_item(item_id)\n fail \"There are no items\" if @items.size == 0\n fail \"No such item with id #{item_id}\" unless @items.member?(item_id)\n @items.delete_if { |id, item| item.id == item_id }\n end",
"def delete_item(list,item)\n list.delete(item)\n list\nend",
"def delete_item(list,item)\n list.delete(item)\n list\nend",
"def del_item(list, item_to_del)\n list.delete(item_to_del)\nend",
"def remove_item(list,item)\r\n\r\n list.delete(item)\r\n list\r\nend",
"def delete_row lb # {{{\n index = lb.current_index\n id = lb.list[lb.current_index].first\n lb.list().delete_at(index)\n lb.touch\n ret = @db.execute(\"UPDATE #{@tablename} SET status = ? WHERE rowid = ?\", [ \"x\", id ])\nend",
"def delete_item(glist, item)\n\tglist.delete(item)\n\treturn glist\nend",
"def remove(item)\n cart_items.where(item_id: item.id).first.try(:destroy)\n end",
"def delete_item(list, item)\n\tlist.delete(item)\n\tlist\nend",
"def remove\n rows = self.open_import_file\n field = rows.first\n rows.each do |row|\n item_identifier = row['item_identifier'].to_s.strip\n if item = Item.where(:item_identifier => item_identifier).first\n item.destroy\n end\n end\n end",
"def delete_item(list, item)\n list.delete(item)\nend",
"def remove_item(item)\n order_item = self.order_items.where(item: item).order('price asc').first\n if order_item.is_a? OrderItem\n order_item.remove 1\n recalculate!\n end\n end",
"def remove_item(hash, item)\r\n\thash.delete(item)\r\n\thash\r\nend",
"def delete()\n sql = \"DELETE FROM stock_items WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\n end",
"def update_avail_q_matrix_column(column_index, q_id)\n @avail_q_matrix.column(column_index).each do |item|\n item.delete(q_id)\n end\n # @avail_q_matrix.each_with_index do |elem, row, col|\n # if col == column_index && !(elem&[q_id]).empty?\n # @avail_q_matrix[row, col] -= [q_id]\n # end\n # end\n end",
"def delete_item(list, item)\n list.delete(item)\n list\nend",
"def delete_item(list, item)\n list.delete(item)\n list\nend",
"def remove_item(item)\n return unless @items.key? item\n\n @items.delete item\n @version += 1\n end",
"def delitem(list, item)\n# input: list and key\n list.delete(item)\n# steps: delete a given key item\nend",
"def delete_item(list, item)\n\tdel_list = list.delete(item)\nend",
"def delete_item\n\nend",
"def delete_at(p0) end",
"def delete_item(list,item)\n list.delete(item)\n return list\nend",
"def delete(key)\n result = @rarray.get(key)\n if result\n @rarray.delete(result)\n store\n else\n raise ArgumentError,'Cannot delete - no matching id', caller \n end\n end",
"def remove_item (list, item)\n list.delete(item)\nend",
"def remove_item(list, item)\n list.delete(item)\n list\nend",
"def remove_item(item, hash)\n hash.delete(item)\n return hash\nend",
"def remove_item(hash, item)\n hash.delete(item)\nend",
"def remove_item(list, item)\r\n list.delete(item)\r\n list\r\nend",
"def remove_item(list,item)\n\tlist.delete(item)\nend",
"def delete_item(grocery_list, item)\ngrocery_list.delete(item)\np grocery_list\n\nend",
"def remove\n if @item.quantity == 1\n @item.destroy!\n else\n @item.decrement(:quantity)\n @item.save!\n end\n\n refresh\n end",
"def remove_item(item, grocery_bag)\n grocery_bag.delete(item)\n p grocery_bag\nend",
"def delete_item(list_item)\n @list.delete(list_item)\n @list\n end",
"def remove_item(grocery_list, item)\r\n grocery_list.delete(item) \r\n \r\nend",
"def delete_row(row_id); rest_delete(\"#{link('rows')}/#{row_id}\"); nil; end",
"def remove_item(list, item)\r\n list.delete(item)\r\n p list\r\nend",
"def delete_program_by_id(item_id)\n item = get_program_by_id(item_id)\n item.destroy\n end",
"def remove_item(item)\r\n items.delete(item)\r\n item.owner = nil\r\n end",
"def removeRow\n\t\tnumToRemove = @vars[\"row_to_remove\"].to_i - 1\n\t\t@arrayOfRows.delete_at(numToRemove)\n\tend",
"def remove_item(hash, item)\n hash.delete(item)\n hash\nend",
"def remove_item(hash, item)\n hash.delete(item)\n hash\nend",
"def remove(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n @a[row].delete_at(column)\n end\n end",
"def delete_item(list, item)\n\tlist.delete(item)\n\treturn list\nend",
"def deleted(item)\n end",
"def delete element\n self.delete_at index_of(element) \n end",
"def delete element\n self.delete_at index_of(element) \n end",
"def remove_item(hash, item_name)\r\n hash.delete(item_name)\r\n hash\r\nend",
"def remove_item(input_hash, item)\n# input: list, item name, and optional quantity\n# steps: use input item to delete key\n input_hash.delete(item)\n# output: hash data structure of key/value pairs\nreturn input_hash\nend",
"def remove_item(list,item)\n list.delete(item)\n p list\nend",
"def remove_item (item,list)\nlist.delete(item)\nlist\nend",
"def delete(item, list)\n\tlist.delete(item)\nend",
"def delete_item(message_id)\n resp = @dynamoDB.delete_item({\n table_name: \"Messages\", # required\n key: { # required\n \"message_id\" => message_id, # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>\n }\n })\nend",
"def remove_item(item, list)\n list.delete(item)\nend",
"def remove_item(list, item)\n list.delete(item)\nend",
"def delete_all_line_items_for_inventory_item_id inventory_item_id\n line_items.destroy(line_items.select{|li| (!li.inventory_item.nil? && li.inventory_item.id == inventory_item_id)})\n end",
"def delete_item(idx, list)\n list.reject! { |item| item[:idx] == idx }\n end",
"def remove_item(grocery_list,item_name)\r\n\t \r\n\t grocery_list.delete(item_name)\r\n\r\nend",
"def delete(item)\n fingerprint = fingerprint(item)\n first_index = hash(item)\n second_index = alt_index(first_index, fingerprint)\n\n if @buckets[first_index].remove(fingerprint) || @buckets[second_index].remove(fingerprint)\n decrement_filled_count\n return true\n end\n\n false\n end",
"def remove_item_from_order(id)\n return unless @items[id] <= 0\n\n get_order(GameData::Item[id].socket).delete(id)\n end",
"def remove_item(id)\n return nil if self.class.mode == :sandbox\n\n query = { \"type\" => \"delete\", \"id\" => id.to_s, \"version\" => Time.now.to_i }\n doc_request query\n end",
"def remove_item(item, list)\r\n list.delete(item)\r\n p list\r\n list\r\nend",
"def remove_item(list,item)\n\tlist.delete(item)\n\tp list\nend",
"def remove_item(list, item)\n list.delete(item)\nend"
] |
[
"0.67961454",
"0.6774477",
"0.6673525",
"0.66483307",
"0.66076255",
"0.65512747",
"0.65446544",
"0.6541384",
"0.6528784",
"0.6473194",
"0.6450048",
"0.6429415",
"0.64117146",
"0.635632",
"0.6346991",
"0.6342022",
"0.63412625",
"0.6313359",
"0.63089734",
"0.6305249",
"0.62947077",
"0.62851185",
"0.62802595",
"0.62794226",
"0.6277466",
"0.6269178",
"0.6268982",
"0.62680453",
"0.6265457",
"0.62649024",
"0.62649024",
"0.62481415",
"0.6239633",
"0.6222305",
"0.6222305",
"0.62026846",
"0.6199716",
"0.6189309",
"0.6189309",
"0.6184709",
"0.6173987",
"0.6169645",
"0.61525744",
"0.6126733",
"0.61122286",
"0.6107652",
"0.6097554",
"0.6095723",
"0.60948044",
"0.60881674",
"0.60851127",
"0.6075925",
"0.6075925",
"0.606971",
"0.6066284",
"0.60651493",
"0.6062575",
"0.6059785",
"0.6057999",
"0.60444933",
"0.6043156",
"0.604215",
"0.6040962",
"0.60315883",
"0.60254353",
"0.601563",
"0.6008921",
"0.6005254",
"0.59986395",
"0.59972763",
"0.5993233",
"0.5990713",
"0.5988345",
"0.5986282",
"0.5984164",
"0.5983374",
"0.59817654",
"0.59817654",
"0.5980989",
"0.59804267",
"0.5979395",
"0.59778786",
"0.59778786",
"0.5974549",
"0.596508",
"0.5962402",
"0.5960564",
"0.5954935",
"0.5952196",
"0.5947256",
"0.59447235",
"0.5933896",
"0.5931107",
"0.5930825",
"0.59178346",
"0.59099275",
"0.5907731",
"0.59050244",
"0.5904985",
"0.5904925"
] |
0.6479153
|
9
|
Use callbacks to share common setup or constraints between actions.
|
def set_probe_type
@probe_type = ProbeType.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
|
Only allow a trusted parameter "white list" through.
|
def probe_type_params
params.require(:probe_type).permit(:name, :description, :communication_channel_id, :value1_type_id, :value2_type_id, :value3_type_id, :value4_type_id, :value5_type_id, :value6_type_id, :value7_type_id, :value8_type_id, :value9_type_id, :value10_type_id, :value11_type_id, :value12_type_id, :value13_type_id, :value14_type_id, :value15_type_id, :value16_type_id)
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
|
Verify if current_user is logged_in
|
def logged_in?
redirect_to(root_path, notice: 'Unauthorized access!') unless current_user
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n if current_user\n true\n else\n false\n end\n end",
"def logged_in\n current_user != nil\n end",
"def logged_in?\n\t\t !!current_user\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n current_user.present?\n end",
"def logged_in?\n !current_user.blank?\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n\t !current_user.nil?\n\t end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n if current_user\n true\n else \n false\n end\n end",
"def logged_in?\n current_user != nil\n end",
"def logged_in?\n current_user != nil\n end",
"def logged_in?\n current_user != nil\n end",
"def logged_in?\n \t\t!current_user.nil?\n \tend",
"def logged_in\n\t \t!current_user.nil?\n\t end",
"def logged_in?\r\n\t\t!current_user.nil?\r\n\tend",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n current_user\n end",
"def logged_in?\n current_user\n end",
"def logged_in?\n current_user.present? # True neu user login\n end",
"def logged_in?\n current_user != nil ? true : false\n end",
"def logged_in?\n\t\t!current_user.nil?\n \tend",
"def logged_in?\n\t\tcurrent_user.present?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!logged_user\n end",
"def logged_in?\n return !current_user.nil?\n end",
"def logged_in?\n return !current_user.nil?\n end",
"def logged_in?\n \t# use current_user method to check if current_user is nil - if nil, not logged in\n \t!current_user.nil?\n end",
"def logged_in?\n !@current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end"
] |
[
"0.87036675",
"0.87036675",
"0.8697598",
"0.8667308",
"0.86539376",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8652277",
"0.8644681",
"0.8644254",
"0.8642083",
"0.8642083",
"0.8636677",
"0.86285436",
"0.86285436",
"0.86285436",
"0.86285436",
"0.86285436",
"0.86285436",
"0.86285436",
"0.86285436",
"0.86285436",
"0.8623463",
"0.86202425",
"0.861873",
"0.861873",
"0.861873",
"0.86109024",
"0.86036134",
"0.8597722",
"0.8595777",
"0.8588809",
"0.8588809",
"0.85874766",
"0.8585556",
"0.8584061",
"0.8574045",
"0.8573721",
"0.85737175",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.8573155",
"0.85670495",
"0.8566052",
"0.8566052",
"0.8566052",
"0.8566052",
"0.85625905",
"0.85548776",
"0.85548776",
"0.85524625",
"0.85359997",
"0.8531363",
"0.8531363",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305",
"0.85305"
] |
0.0
|
-1
|
I _should_ be able to use the built in Ruby csv to parse this, but it doesn't work for me :(
|
def each
parsed_line = ""
@lines.each do |line|
parsed_line += line
if parsed_line.count('"') % 2 == 0
yield create_row(parsed_line)
parsed_line = ""
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/,\\\"\\\"/,'')\n # for some reason the iRacing CSV file is buggy.\n unless parsed_line == \"\\n\"\n if i == 5 or i == 6\n parsed_line = parsed_line.gsub(/\\n/,\"\\r\\n\")\n end\n self.parsed_csv_string << parsed_line\n end\n end\n unparsed_file.close\n end",
"def parse(args={})\n csv_args = {:skip_blanks=>true,:col_sep=>\",\"}\n csv_args[:col_sep] = args[:col_sep] if args[:col_sep]\n args[:value_filter] ||= Csv2sql.method :default_value_filter\n i = 0\n CSV.foreach(@filename,csv_args) do |row|\n values = row\n #values_filter is for whole row\n #value_filter is for single value\n values = args[:values_filter].call(row, i) if args[:values_filter]\n if values\n if args[:value_filter]\n j = -1\n values = row.map do |value|\n j += 1\n args[:value_filter].call(value,i,j)\n end\n end\n yield values if values\n end\n i += 1\n end\n end",
"def parse_csv\n i=0\n output_matrix = []\n trim_return_carriage(fulltext).each_line do |line|\n 5.times { |i| avoid_commas_in_special_strings(line) }\n output_matrix << trim_line_ends(line).split(delimiter) unless i == 0\n i+=1\n end\n output_matrix.each do |rec|\n temp_hsh = {}\n (0..rec.size-1).each do |i|\n temp_hsh.merge! object_attributes[i] => rec[i]\n end\n @output_table_object << temp_hsh\n end\n\n output_table_object\n end",
"def parse_csv(file)\n\t\tdata = []\n\t\t# Break open CSV and go through rows\n\t\tbegin\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'UTF-8')\n\t\trescue\n\t\t\t# Convert to UTF-8 if necessary\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'Windows-1252:UTF-8')\n\t\tend\n\t\tdata\n\tend",
"def parse_csv(csv_file)\n\n # Loop through all entries in CSV file\n CSV.foreach(csv_file, :quote_char => \"\\\"\") do |row|\n next if row[0] == \"From\" && row[1] == \"To\"\n next if row[0].nil?\n\n # [0, 1] refers to the 2 addresses in the csv file\n [0, 1].each do |i|\n add_location(row[i])\n end\n\n add_journey(row)\n end\nend",
"def parse_csv(csv_file)\r\n\t\t\t# Fixed errors due to a Byte-Order-Mark (BOM) at the very beginning of some CSV files\r\n\t\t\t# http://stackoverflow.com/questions/23011713/illegal-quoting-error-with-ruby-csv-parsing\r\n\t\t\tparsed_csv = []\r\n\t\t\tbegin\r\n\t\t \t\tparsed_csv = CSV.read(csv_file, :encoding => 'bom|utf-8')\r\n\t\t\trescue ArgumentError\r\n\t\t \t\tbegin\r\n\t\t \t\tparsed_csv = CSV.read(csv_file, :encoding => 'bom|utf-8:ISO-8859-1')\r\n\t\t \t\trescue ArgumentError\r\n\t\t \t\traise ParserError, \"There was an error in reading the CSV encoding.\"\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\treturn parsed_csv\r\n\t\tend",
"def import_csv_smart\n \n end",
"def parse_csv\n if self.csv_file.present?\n csv_text = Paperclip.io_adapters.for(self.csv_file).read\n csv = CSV.parse(csv_text, :headers => false)\n\n csv_columns = ['l', 'r', 'units']\n\n csv_to_save = {}\n\n csv.each_with_index do |row, i|\n if i == 0\n csv_to_save['weight'] = row[1].split(':')[1] # string is like Weight:201, only want the number\n csv_to_save['shoe_size'] = row[2].split(':')[1] # string is like Shoe Size:9\n elsif i >= 3\n row.each_with_index do |field, j|\n if j >= 1 and !field.blank?\n csv_to_save[generate_csv_row_key(csv_columns, row, i, j)] = field\n end\n end\n end\n end\n\n # Check to see if any of the fields are nil, then we must have not received the correct file\n is_clean = true\n csv_to_save.each do |key, val|\n if val.nil?\n is_clean = false\n break\n end\n end\n\n CsvFile.create!(csv_to_save) if is_clean\n end\n end",
"def parse_csv_line(text_line)\n # Split the text_line by comma\n columns = text_line.split(\",\")\n # But some of the values are padded with spaces\n # And add the cleaned up values to the new array (called values)\n # strip --> predefined string function which trims spaces\n values = []\n columns.each {|x| values << x.strip}\n return values\n\nend",
"def parse_csv_line(text_line)\n\tcolumns = text_line.split(\",\")\n\tvalues = []\n\tcolumns.each { |x| values << x.strip}\n\treturn values\nend",
"def csv_parsed\n transform_to_hash(@csv_array, @header)\n end",
"def csvReader(file, headers)\n begin\n csvTable = CSV.read(file, {col_sep:\"\\t\", quote_char:\"\\0\", headers:headers})\n rescue ArgumentError\n puts \"Error: Unsupported encoding, tabulated/CSV file must be in UTF-8 format.\"\n abort\n end\n parsedObj = OpenStruct.new()\n parsedObj.rowArray = []\n parsedObj.belArray = []\n csvTable.each do |row|\n unless row.length == 0\n current = OpenStruct.new()\n current.bel_id = row[0]\n current.bel_id.slice! \"BEL:\"\n current.bel = row[1]\n current.sentence = row[2]\n current.sentence_id = row[3]\n current.sentence_id.slice! \"SEN:\"\n current.pmid = row[4]\n parsedObj.rowArray << current\n parsedObj.belArray << row[1]\n end\n end\n parsedObj.linecount = csvTable.length\n return parsedObj\nend",
"def parse_csv\n raise InvalidStateError, \"#{state.inspect} is not a valid Data state for method 'to_csv'\" unless state == :raw\n\n file_options = @options[:file_options]\n parse_options = @options[:parse_options]\n\n begin\n csv = CSVWrapper.parse(@content, parse_options)\n csv = csv.drop(1) if file_options[:has_headers] == true # drop the first row if it is a header\n rescue => e\n Logger.new(@options).print(@path, :parse, e)\n end\n\n @state = :parsed\n Data.new(@path, csv, @state, @options)\n end",
"def test_s_parseAndCreate\n colSize = 8\n csvStr = \"foo,!!!foo!!!,!foo,bar!,!!!!!!,!!,,!\\r!,!\\r\\n!\\nNaHi,!!!Na!!!,!Na,Hi!,!\\r.\\n!,!\\r\\n\\n!,!!!!,!\\n!,!\\r\\n!\".gsub!('!', '\"')\n csvStrTerminated = csvStr + \"\\n\"\n\n myStr = csvStr.dup\n res1 = []; res2 = []\n idx = 0\n col, idx = CSV::parse_row(myStr, 0, res1)\n col, idx = CSV::parse_row(myStr, idx, res2)\n\n buf = ''\n col = CSV::generate_row(res1, colSize, buf)\n col = CSV::generate_row(res2, colSize, buf)\n assert_equal(csvStrTerminated, buf)\n\n parsed = []\n CSV::Reader.parse(csvStrTerminated) do |row|\n parsed << row\n end\n\n buf = ''\n CSV::Writer.generate(buf) do |writer|\n parsed.each do |row|\n\twriter.add_row(row)\n end\n end\n assert_equal(csvStrTerminated, buf)\n\n buf = ''\n CSV::Writer.generate(buf) do |writer|\n parsed.each do |row|\n\twriter << row\n end\n end\n assert_equal(csvStrTerminated, buf)\n end",
"def parse_csv(b, a, b_a, l, p)\n keys = [\"books\", \"authors\", \"books_authors\", \"languages\", \"publishers\"]\n x = 0\n CSV.foreach(BOOKS_FILE, encoding: \"UTF-8\") do |col|\n if \"====== \" + keys[x].to_s + \" ======\" == col[0]\n x += 1\n end\n\n case x\n when 1 then\n b.push(col)\n when 2 then\n a.push(col)\n when 3 then\n b_a.push(col)\n when 4 then\n l.push(col)\n when 5 then\n p.push(col)\n end\n end\n return b, a, b_a, l, p\nend",
"def csv_to_array(csv); end",
"def csv?(csv)\n valid = csv.include?(';')\n valid |= csv.include?(',')\n valid &= csv.include?(\"\\n\")\n valid\n end",
"def parse_csv(csvstr)\n\treturn CSV.parse(csvstr)\nend",
"def parsed_data\n @parsed_data ||= begin\n CSV.read(full_filename, col_sep: col_sep, quote_char: quote_char, encoding: encoding)\n rescue => e #CSV::MalformedCSVError => er\n @parse_error = e.to_s\n rows = []\n #one more attempt. If BOM is present in the file.\n begin\n f = File.open(full_filename, \"rb:bom|utf-8\")\n rows = CSV.parse(f.read.force_encoding(\"ISO-8859-1\"))\n ensure\n return rows\n end\n end\n end",
"def parseCSV(csvfile)\n begin\n if csvfile != nil\n file_ext = File.extname(csvfile.original_filename)\n if file_ext == \".csv\"\n content = File.read(csvfile.tempfile)\n arr_of_arrs = CSV.parse(content)\n return arr_of_arrs, 0\n else\n return nil, 4\n end\n else\n return nil, 1\n end\n rescue ArgumentError\n return nil, 2\n rescue CSV::MalformedCSVError\n return nil, 3\n end\n end",
"def parseCSV(csvfile)\n begin\n if csvfile != nil && csvfile != \"\"\n file_ext = File.extname(csvfile.original_filename)\n if file_ext == \".csv\"\n content = File.read(csvfile.tempfile)\n arr_of_arrs = CSV.parse(content)\n return arr_of_arrs, 0\n else\n return nil, 4\n end\n else\n return nil, 1\n end\n rescue ArgumentError\n return nil, 2\n rescue CSV::MalformedCSVError\n return nil, 3\n end\n end",
"def parse_csv(filename)\n @file=CSV.read(filename)\n # Read order of headers\n headers = @file.shift\n @file.each do |line|\n next if line.length==0 || (line.length==1 && line[0]==nil)\n # Read fields from line based on headers\n value=ReturnValue.new( line[headers.index('label')],\n line[headers.index('name') || headers.index('label')],\n line[headers.index('type')],\n line[headers.index('unit')],\n line[headers.index('per_unit')],\n line[headers.index('default')] )\n @values.push value\n end\n validate\n end",
"def parse_csv_line_ruby(line, options, header_size = nil)\n return [] if line.nil?\n\n line_size = line.size\n col_sep = options[:col_sep]\n col_sep_size = col_sep.size\n quote = options[:quote_char]\n quote_count = 0\n elements = []\n start = 0\n i = 0\n\n previous_char = ''\n while i < line_size\n if line[i...i+col_sep_size] == col_sep && quote_count.even?\n break if !header_size.nil? && elements.size >= header_size\n\n elements << cleanup_quotes(line[start...i], quote)\n previous_char = line[i]\n i += col_sep.size\n start = i\n else\n quote_count += 1 if line[i] == quote && previous_char != '\\\\'\n previous_char = line[i]\n i += 1\n end\n end\n elements << cleanup_quotes(line[start..-1], quote) if header_size.nil? || elements.size < header_size\n [elements, elements.size]\n end",
"def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend",
"def parse_csv(csv_name, schema)\n CSV.read(csv_name).map {|row| map_row_to_entity(row, schema) }\nend",
"def pbGetCsvRecord(rec,lineno,schema)\r\n record = []\r\n repeat = false\r\n start = 0\r\n if schema[1][0,1]==\"*\"\r\n repeat = true\r\n start = 1\r\n end\r\n begin\r\n for i in start...schema[1].length\r\n chr = schema[1][i,1]\r\n case chr\r\n when \"i\" # Integer\r\n record.push(csvInt!(rec,lineno))\r\n when \"I\" # Optional integer\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^\\-?\\d+$/]\r\n raise _INTL(\"Field {1} is not an integer\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.to_i)\r\n end\r\n when \"u\" # Positive integer or zero\r\n record.push(csvPosInt!(rec,lineno))\r\n when \"U\" # Optional positive integer or zero\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^\\d+$/]\r\n raise _INTL(\"Field '{1}' must be 0 or greater\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.to_i)\r\n end\r\n when \"v\" # Positive integer\r\n field = csvPosInt!(rec,lineno)\r\n raise _INTL(\"Field '{1}' must be greater than 0\\r\\n{2}\",field,FileLineData.linereport) if field==0\r\n record.push(field)\r\n when \"V\" # Optional positive integer\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^\\d+$/]\r\n raise _INTL(\"Field '{1}' must be greater than 0\\r\\n{2}\",field,FileLineData.linereport)\r\n elsif field.to_i==0\r\n raise _INTL(\"Field '{1}' must be greater than 0\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.to_i)\r\n end\r\n when \"x\" # Hexadecimal number\r\n field = csvfield!(rec)\r\n if !field[/^[A-Fa-f0-9]+$/]\r\n raise _INTL(\"Field '{1}' is not a hexadecimal number\\r\\n{2}\",field,FileLineData.linereport)\r\n end\r\n record.push(field.hex)\r\n when \"X\" # Optional hexadecimal number\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^[A-Fa-f0-9]+$/]\r\n raise _INTL(\"Field '{1}' is not a hexadecimal number\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.hex)\r\n end\r\n when \"f\" # Floating point number\r\n record.push(csvFloat!(rec,lineno))\r\n when \"F\" # Optional floating point number\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^\\-?^\\d*\\.?\\d*$/]\r\n raise _INTL(\"Field {1} is not a floating point number\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field.to_f)\r\n end\r\n when \"b\" # Boolean\r\n record.push(csvBoolean!(rec,lineno))\r\n when \"B\" # Optional Boolean\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif field[/^1|[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]|[Tt]|[Yy]$/]\r\n record.push(true)\r\n else\r\n record.push(false)\r\n end\r\n when \"n\" # Name\r\n field = csvfield!(rec)\r\n if !field[/^(?![0-9])\\w+$/]\r\n raise _INTL(\"Field '{1}' must contain only letters, digits, and\\r\\nunderscores and can't begin with a number.\\r\\n{2}\",field,FileLineData.linereport)\r\n end\r\n record.push(field)\r\n when \"N\" # Optional name\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif !field[/^(?![0-9])\\w+$/]\r\n raise _INTL(\"Field '{1}' must contain only letters, digits, and\\r\\nunderscores and can't begin with a number.\\r\\n{2}\",field,FileLineData.linereport)\r\n else\r\n record.push(field)\r\n end\r\n when \"s\" # String\r\n record.push(csvfield!(rec))\r\n when \"S\" # Optional string\r\n field = csvfield!(rec)\r\n record.push((nil_or_empty?(field)) ? nil : field)\r\n when \"q\" # Unformatted text\r\n record.push(rec)\r\n rec = \"\"\r\n when \"Q\" # Optional unformatted text\r\n if nil_or_empty?(rec)\r\n record.push(nil)\r\n else\r\n record.push(rec)\r\n rec = \"\"\r\n end\r\n when \"e\" # Enumerable\r\n record.push(csvEnumField!(rec,schema[2+i-start],\"\",FileLineData.linereport))\r\n when \"E\" # Optional enumerable\r\n field = csvfield!(rec)\r\n record.push(checkEnumFieldOrNil(field,schema[2+i-start]))\r\n when \"y\" # Enumerable or integer\r\n field = csvfield!(rec)\r\n record.push(csvEnumFieldOrInt!(field,schema[2+i-start],\"\",FileLineData.linereport))\r\n when \"Y\" # Optional enumerable or integer\r\n field = csvfield!(rec)\r\n if nil_or_empty?(field)\r\n record.push(nil)\r\n elsif field[/^\\-?\\d+$/]\r\n record.push(field.to_i)\r\n else\r\n record.push(checkEnumFieldOrNil(field,schema[2+i-start]))\r\n end\r\n end\r\n end\r\n break if repeat && nil_or_empty?(rec)\r\n end while repeat\r\n return (schema[1].length==1) ? record[0] : record\r\n end",
"def parse_csv\n CSV.parse(File.read(\"DeleteMe.csv\")) do |row|\n puts row.class\n #project = @rally.find(RallyAPI::RallyQuery.new({:type => :project, :query_string => \"(Name = #{row[\"Name\"]})\"}))\n project = @rally.find(RallyAPI::RallyQuery.new({:type => :project, :query_string => \"(Name = \\\"#{row.first}\\\")\"}))\n puts project\n project = project.first\n fields = {}\n fields[:state] = 'Closed'\n fields[:notes] = close_reason(project)\n project.update(fields)\n end\n # File.open(\"DeleteMe.csv\", \"r\") do |f|\n # f.each_line do |line|\n # puts line\n # end\n # end\n end",
"def csv_from_row(op, row)\n res = \"\"\n until row.empty?\n entry = row.shift.to_s\n if /[,\"]/ =~ entry\n entry = entry.gsub(/\"/, '\"\"')\n res << '\"' << entry << '\"'\n else\n res << entry\n end\n res << \",\" unless row.empty?\n end\n op << res << CRLF\nend",
"def parse_csv(csv, &row_block)\n CSV.parse(Encoding.to_utf_8(File.read(\"#{install_path}/Edit Scripts/#{csv}.csv\", mode: 'rb'))).each(&row_block)\n end",
"def read_csv(io)\n quoted = false\n str = ''\n io.each_char do |ch|\n case\n when (ch == COMMA && !quoted) || ch == LF || ch == CR || ch.nil?\n break\n when ch == quote\n quoted = !quoted\n else\n str << ch\n end\n end\n str.empty? ? nil : value_from_s(str)\n end",
"def parse_csv(file_path)\n record_list = []\n header = []\n is_header = true\n \n CSV.foreach(file_path) do |row|\n if (is_header)\n\theader = row\n\tis_header = false\n else\n\trecord = Record.new\n\trecord.create(header, row)\n\trecord_list.push(record)\n end\n end\n return record_list\n end",
"def import_csv_full\n \n end",
"def parse_csv(path)\n require 'csv'\n\n str = Nitro::Template.new.render(File.read(path))\n\n reader = CSV::Reader.create(str)\n header = reader.shift\n\n reader.each_with_index do |row, i|\n data = {}\n row.each_with_index do |cell, j|\n data[header[j].to_s.strip] = cell.to_s.strip\n end\n self[\"#{@name}_#{i+1}\"] = obj = instantiate(data)\n @objects << obj\n end\n end",
"def get_csv_data(csv_file)\n\t\tcsv_file = File.read(csv_file)\n\t\tcsv = CSV.parse(csv_file, :headers => true)\t\n\t\tcsv\n\tend",
"def parse_csv_legacy(file)\n\trows = []\n\tlines = File.read(file).split(\"\\n\").map(&:strip).reject { |l| l.empty? }\n\trows = lines.map { |r| r.split(\",\").map(&:strip) }\n\n\theader = rows.shift\n\n\trows.map do |row|\n\t\ti = 0\n\t\trow_hash = {}\n\t\theader.each do |h|\n\t\t\trow_hash[h] = row[i]\n\t\t\ti += 1\n\t\tend\n\t\trow_hash\n\tend\nend",
"def get_csv_data(csv_data)\r\n csv_file = nil\r\n\r\n #Get the path and name of the CSV file\r\n if csv_data.to_s.include? '.csv'\r\n csv_file = File.join(File.dirname(__FILE__), \"../venture/config/csv_data/#{csv_data}\")\r\n elsif (\r\n csv_file = File.join(File.dirname(__FILE__), \"../venture/config/csv_data/#{csv_data}.csv\")\r\n )\r\n end\r\n\r\n csv_arr = CSV.read( csv_file, {:headers => true, :header_converters => :symbol, :encoding => 'UTF-8'} )\r\n keys = csv_arr.headers.to_a\r\n # read attribute example => csv[index][:column1]\r\n return csv_arr.to_a.map {|row| Hash[ keys.zip(row) ] }\r\nend",
"def\tparse_file\n CSV.foreach(@file) do |row|\n begin\n rid, price, item = row[0].strip.to_i, row[1].strip.to_f, row[2..-1].map(&:strip).join('-').downcase\n validate(rid, price, item) ? load(rid, price, item) : puts(\"Escaping invalid row: #{row}\")\n rescue StandardError \n puts \"Escaping incorrect row: #{row}\"\n end\n end\n end",
"def parse_csv(decoded_data)\n csv = CSV.parse(decoded_data)\n headers = csv.shift\n csv.to_a.map! { |row| Hash[headers.zip(row)] }\n end",
"def parse_csv(csv)\n objects = CSV.parse(csv)\n headers = objects.shift\n objects.to_a.map! { |row| Hash[headers.zip(row)] }\n end",
"def csv_parse(arg, no_raise: true, no_empty: true, utf8: true, **opt)\n return if arg.nil? || arg.is_a?(Puma::NullIO)\n CSV.parse(arg, **CSV_DEFAULTS, **opt).map { |row|\n row = row.to_h\n next if no_empty && row.values.all?(&:nil?)\n utf8 ? row.transform_values! { |v| force_utf8(v) } : row\n }.compact\n rescue => error\n Log.info { \"#{__method__}: #{error.class}: #{error.message}\" }\n re_raise_if_internal_exception(error)\n raise error unless no_raise\n end",
"def create_item_rows_from_csv \n item_rows = []\n CSV.foreach('./data/items.csv', headers: true, header_converters: :symbol) do |row|\n item_rows << row\n end \n return item_rows\n end",
"def parse_csv content, sep\n CSV.parse(content, :col_sep => sep,\n :converters => [:numeric],\n :headers => true,\n :skip_blanks => true).\n map{ |row| row.to_hash }\n end",
"def read(string)\n lines = string.split(\"\\n\")\n header = lines[0]\n attributes = header.split(',').map! { |v| v.to_sym }\n # Struct.new('CSVEntry', *attributes)\n ret = []\n lines.drop(1).each do |line|\n values = line.split(',')\n opts = {}\n values.each_with_index do |val, idx|\n opts[attributes[idx]] = val\n end\n ret << Struct::CSVEntry.new(opts)\n end\n\n ret\n end",
"def parse_csv_file\n csv_data = CSV.read(\"../artists_for_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash\n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n \n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painter_num => painter_row_arr[6]\n }\n painter_object_array.push(painter_object)\n end\n painter_object_array.flatten\nend",
"def parse_csv_row(csv_row)\n {\n s_no: csv_row['Sr. No'],\n ticket_no: csv_row['Ticket No'],\n email: csv_row['Email'],\n name: csv_row['Name'],\n new_eth_address: csv_row['New Ethereum Add']\n }\n end",
"def parse_csv(csv_string)\n csv_data = FasterCSV.parse(csv_string)\n header = csv_data.shift\n [csv_data.map{|row| Hash[*header.zip(row).flatten] }, header]\n end",
"def parse\n csv_emails.split(/,?\\s/).uniq\n end",
"def test_parse_headers\n tmpdbfile = Tempfile.new('tmp.db')\n args = [\"--header\", \n \"--source\", \"header_test.csv\", \n \"--save-to\", tmpdbfile.path, \n \"--ifs=\" \",\",\n \"--table-name\",\"header_test\"]\n Csvql.run(args)\n\n db = SQLite3::Database.new tmpdbfile.path\n headers_from_db = db.execute2('select * from header_test;')[0]\n headers_from_file = File.open('header_test.csv').each_line.first.gsub(/\\n/,'').split(',')\n\n #binding.pry\n assert_equal headers_from_db, headers_from_file\n end",
"def csv_row\n #empty by default\n []\n end",
"def csv_row\n #empty by default\n []\n end",
"def csvread (filename)\n File.readlines(filename).each do |line|\n if line && !empty?(line)\n num, code, kind, desc, contenten, contentme = line.split(\"\\t\")\n\n num = num\n code = clean(code)\n kind = clean(kind)\n contenten = clean(contenten)\n contentme = clean(contentme)\n\n yield num, code, kind, desc, contenten, contentme\n end\n end\nend",
"def loadStructure(file)\n csv_text = File.read(file)\n return CSV.parse(csv_text, :headers => true)\n \nend",
"def parse\n\t\tresults = []\n\t\tif !self.csv_file_file_name.blank? &&\n\t\t\t\tFile.exists?(self.csv_file.path)\n\t\t\t(f=FasterCSV.open( self.csv_file.path, 'rb',{\n\t\t\t\t:headers => true })).each do |line|\n\n#\t\"Masterid\",\"Motherid\",\"Record_Owner\",\"Datereceived\",\"Lastatt\",\"Lastdisp\",\"Currphone\",\"Vacauthrecd\",\"Recollect\",\"Needpreincentive\",\"Active_Phone\",\"Recordsentformatching\",\"Recordreceivedfrommatching\",\"Sentpreincentive\",\"Releasedtocati\",\"Confirmedcaticontact\",\"Refused\",\"Deceasednotification\",\"Eligible\",\"Confirmationpacketsent\",\"Catiprotocolexhausted\",\"Newphonenumreleasedtocati\",\"Pleanotificationsent\",\"Casereturnedtoberkeleyfornewinf\",\"Casereturnedfromberkeley\",\"Caticomplete\",\"Kitmothersent\",\"Kitinfantsent\",\"Kitchildsent\",\"Kitadolescentsent\",\"Kitmotherrefusedcode\",\"Kitchildrefusedcode\",\"Noresponsetoplea\",\"Responsereceivedfromplea\",\"Senttoinpersonfollowup\",\"Kitmotherrecd\",\"Kitchildrecvd\",\"Thankyousent\",\"Physrequestsent\",\"Physresponsereceived\"\n\n#\n#\tThe IcfMasterTracker will include an after_save or something that will\n#\tdetermine what has changed and update appropriately. It may also\n#\tcreate OperationalEvents to document the data changes. As it is\n#\ttheoretically possible that the Masterid does not exist in the identifiers\n#\ttable, perhaps add a successfully_updated_models flag which could\n#\tbe used?\n#\n\t\t\t\ticf_master_tracker = IcfMasterTracker.find_or_create_by_Masterid(line['Masterid'])\n\t\t\t\t#\tNO BANG. Don't want to raise any errors.\n\t\t\t\tsuccessfully_updated = icf_master_tracker.update_attributes(line.to_hash)\n#\n#\terrors = icf_master_tracker.errors.full_messages.to_sentence\n#\tThese won't be validation errors as there shouldn't be any.\n#\tPerhaps \"no column by that name\" errors if csv file changes?\n#\n#\tAdd successfully_updated value?\n#\t\ticf_master_tracker.update_attribute(:sucessfully_updated, successfully_updated)\n#\twill the above include the line's attributes?\n#\n#\tAdd update_errors column?\n#\t\ticf_master_tracker.update_attribute(:update_errors, errors)\n#\n\n\t\t\t\tresults.push(icf_master_tracker)\n\n\t\t\tend\t#\t(f=FasterCSV.open( self.csv_file.path, 'rb',{ :headers => true })).each\n\t\tend\t#\tif !self.csv_file_file_name.blank? && File.exists?(self.csv_file.path)\n\t\tresults\t#\tTODO why am I returning anything? will I use this later?\n\tend",
"def get_csv(myfile, tabbed = false)\n\n raise \"Unable to read from file '#{myfile}'\" if !File.readable?(myfile) \n\n if tabbed\n recs = CSV::parse(File.open(myfile, 'r'){|f| f.read}, :col_sep => \"\\t\") # this doesn't work on Tab seperated quote delimited\n else\n recs = CSV::parse(File.open(myfile, 'r'){|f| f.read})\n end \n recs ||= []\n recs\n end",
"def import_csv\n @records = CSV.read(@filename, :headers => true, :row_sep => :auto)\n unless @records.blank?\n @linenum = 0\n if @filename.index('att') || @filename.index('Att')\n @school_year = Time.parse(@records[0][\"AbsenceDate\"]).year\n end\n @records.each { |rec |\n @linenum += 1\n @record = rec\n next unless check_record(@record)\n seed_record(@record)\n process_record(@record, rec2attrs(@record)) if rec2attrs(@record) != false\n }\n end \n end",
"def shift\n #########################################################################\n ### This method is purposefully kept a bit long as simple conditional ###\n ### checks are faster than numerous (expensive) method calls. ###\n #########################################################################\n\n # handle headers not based on document content\n if header_row? and @return_headers and\n [Array, String].include? @use_headers.class\n if @unconverted_fields\n return add_unconverted_fields(parse_headers, Array.new)\n else\n return parse_headers\n end\n end\n\n #\n # it can take multiple calls to <tt>@io.gets()</tt> to get a full line,\n # because of \\r and/or \\n characters embedded in quoted fields\n #\n in_extended_col = false\n csv = Array.new\n\n loop do\n # add another read to the line\n unless parse = @io.gets(@row_sep)\n return nil\n end\n\n if in_extended_col\n @line.concat(parse)\n else\n @line = parse.clone\n end\n\n begin\n parse.sub!(@parsers[:line_end], \"\")\n rescue ArgumentError\n unless parse.valid_encoding?\n message = \"Invalid byte sequence in #{parse.encoding}\"\n raise MalformedCSVError.new(message, lineno + 1)\n end\n raise\n end\n\n if csv.empty?\n #\n # I believe a blank line should be an <tt>Array.new</tt>, not Ruby 1.8\n # HBCSV's <tt>[nil]</tt>\n #\n if parse.empty?\n @lineno += 1\n if @skip_blanks\n next\n elsif @unconverted_fields\n return add_unconverted_fields(Array.new, Array.new)\n elsif @use_headers\n return self.class::Row.new(@headers, Array.new)\n else\n return Array.new\n end\n end\n end\n\n next if @skip_lines and @skip_lines.match parse\n\n parts = parse.split(@col_sep_split_separator, -1)\n if parts.empty?\n if in_extended_col\n csv[-1] << @col_sep # will be replaced with a @row_sep after the parts.each loop\n else\n csv << nil\n end\n end\n\n # This loop is the hot path of csv parsing. Some things may be non-dry\n # for a reason. Make sure to benchmark when refactoring.\n parts.each do |part|\n if in_extended_col\n # If we are continuing a previous column\n if part.end_with?(@quote_char) && part.count(@quote_char) % 2 != 0\n # extended column ends\n csv.last << part[0..-2]\n if csv.last.match?(@parsers[:stray_quote])\n raise MalformedCSVError.new(\"Missing or stray quote\",\n lineno + 1)\n end\n csv.last.gsub!(@double_quote_char, @quote_char)\n in_extended_col = false\n else\n csv.last << part << @col_sep\n end\n elsif part.start_with?(@quote_char)\n # If we are starting a new quoted column\n if part.count(@quote_char) % 2 != 0\n # start an extended column\n csv << (part[1..-1] << @col_sep)\n in_extended_col = true\n elsif part.end_with?(@quote_char)\n # regular quoted column\n csv << part[1..-2]\n if csv.last.match?(@parsers[:stray_quote])\n raise MalformedCSVError.new(\"Missing or stray quote\",\n lineno + 1)\n end\n csv.last.gsub!(@double_quote_char, @quote_char)\n elsif @liberal_parsing\n csv << part\n else\n raise MalformedCSVError.new(\"Missing or stray quote\",\n lineno + 1)\n end\n elsif part.match?(@parsers[:quote_or_nl])\n # Unquoted field with bad characters.\n if part.match?(@parsers[:nl_or_lf])\n message = \"Unquoted fields do not allow \\\\r or \\\\n\"\n raise MalformedCSVError.new(message, lineno + 1)\n else\n if @liberal_parsing\n csv << part\n else\n raise MalformedCSVError.new(\"Illegal quoting\", lineno + 1)\n end\n end\n else\n # Regular ole unquoted field.\n csv << (part.empty? ? nil : part)\n end\n end\n\n # Replace tacked on @col_sep with @row_sep if we are still in an extended\n # column.\n csv[-1][-1] = @row_sep if in_extended_col\n\n if in_extended_col\n # if we're at eof?(), a quoted field wasn't closed...\n if @io.eof?\n raise MalformedCSVError.new(\"Unclosed quoted field\",\n lineno + 1)\n elsif @field_size_limit and csv.last.size >= @field_size_limit\n raise MalformedCSVError.new(\"Field size exceeded\",\n lineno + 1)\n end\n # otherwise, we need to loop and pull some more data to complete the row\n else\n @lineno += 1\n\n # save fields unconverted fields, if needed...\n unconverted = csv.dup if @unconverted_fields\n\n if @use_headers\n # parse out header rows and handle HBCSV::Row conversions...\n csv = parse_headers(csv)\n else\n # convert fields, if needed...\n csv = convert_fields(csv)\n end\n\n # inject unconverted fields and accessor, if requested...\n if @unconverted_fields and not csv.respond_to? :unconverted_fields\n add_unconverted_fields(csv, unconverted)\n end\n\n # return the results\n break csv\n end\n end\n end",
"def parse_painter_csv_file\n csv_data = CSV.read(\"db/painter_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash \n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painting_num => painter_row_arr[6],\n :portrait => painter_row_arr[7]\n }\n painter_object_array.push(painter_object) \n end\n painter_object_array.flatten\nend",
"def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each, then convert to Entry using 'add_entry' method\r\n csv.each do |row|\r\n row_hash = row.to_hash\r\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\r\n end #end csv.each loop\r\n end",
"def parse(csv_row)\n @transformer ? parse_transform(csv_row) : raw_value(csv_row)\n end",
"def csv_convert(file)\n data_rows = []\n f = File.open(file, 'r')\n f.each_line do |line|\n data_rows.push line.chomp.split(',')\n end\n f.close\n return data_rows\nend",
"def csv_attributes\n [\n \"Nimi\" => \"name\",\n \"Järjestys\" => \"numbering_order\",\n \"Lyhenne\" => \"shorten\",\n \"Ehdokkaita\" => :candidate_count,\n \"Vaalirengas\" => :coalition_name\n ]\n end",
"def parse\n data = CSV.parse(@input_data)\n data.shift # remove header row\n headers = [:player_key, :year, :team_id, :game, :at_bats, :runs, :hits, :doubles, :triples, :home_runs, :runs_batted_in, :stolen_bases, :caught_stealing]\n data.map {|row| Hash[ *(headers.zip(row).flatten) ] }\n end",
"def parse\n results = []\n\n CSV.parse(read_data).each do |row|\n row = parse_row(row)\n keep = block_given? ? yield(row) == true : true\n results << row if keep\n end\n\n results\n end",
"def read_csv_data file\n rows = []\n readerIn = CSV.open(file, 'r')\n row = readerIn.shift\n while row!= nil && !row.empty?\n rows << row\n row = readerIn.shift\n end\n readerIn.close\n \n return rows\nend",
"def parse_rows(data)\n csv_options = DEFAULT_OPTIONS.merge(:col_sep => inferred_separator)\n CSV.parse(data, csv_options).map(&:to_hash)\n end",
"def parse(data)\n docs = []\n rows = CSV::parse(data)\n if rows.length > 4\n # TODO/FIXME: get Tor Ivan to make a proper csv header\n header = rows[1]\n\n rows[4, rows.length].each do |row|\n doc = Hash[header.zip(row)]\n\n doc.each do |key, val|\n\n # try for int, if that fails, go for float, else string\n begin\n doc[key] = Integer(val)\n rescue ArgumentError\n begin\n doc[key] = Float(val)\n rescue ArgumentError\n end\n end\n\n end\n\n # make the timestamp ours\n toks = doc.delete(\"TIMESTAMP\").split()\n doc[\"measured\"] = toks[0]+\"T\"+toks[1]+\"Z\"\n\n # generate the sha256 digest based on the measurement time and use it as\n # a namespaced UUID seed to prevent duplicate data from entering the database.\n seed = Digest::SHA256.hexdigest doc[\"measured\"]\n doc[\"id\"] = seed[0,8] + \"-\" + seed[8,4] + \"-\" + seed[12,4] + \"-\" + seed[16,4] + \"-\" + seed[20,12]\n\n # point to our schema\n doc[\"schema\"] = \"http://api.npolar.no/schema/weather-bouvet-1.0-rc1\"\n docs << doc\n end\n end\n\n docs\n end",
"def reprocess_csv(file)\n raw = open(file).read.force_encoding(\"UTF-8\")\n csv = CSV.parse(raw, headers: true, header_converters: :symbol)\n csv.each do |row|\n data = row.to_hash.each { |k, v| v = v.to_s.gsub(/[[:space:]]+/, ' ').strip }\n data[:area_id] = data[:area].downcase\n data[:gender] = data[:gender].downcase\n data[:term] = '2013'\n %i(num).each { |i| data.delete i }\n ScraperWiki.save_sqlite([:name, :name, :term], data)\n end\nend",
"def parse\n data = CSV.parse(@input_data)\n data.shift # remove header row\n headers = [:player_key, :birth_year, :first_name, :last_name]\n data.map {|row| Hash[ *(headers.zip(row).flatten) ] }\n end",
"def read_parameters_from_csv(csv)\r\n\t\tbegin\r\n\t\t\ttemp = CSV.read(csv)\r\n\t\trescue Exception\r\n\t\t\traise ArgumentError, \"It wasn't possible to read from #{csv} file.\"\r\n\t\tend\r\n\t\ttemp.each_with_index do |row,index|\r\n\t\t\t@actual_parameters[index] = row[0].split(';')\r\n\t\tend\r\n\tend",
"def strip_csv_quotes(src_path, dest_path)\n\n require 'csv'\n open('LoginHistory-comma-delim.csv', 'w') do |f|\n first_line = true\n CSV.foreach('LoginHistory.csv') do |row|\n if first_line\n first_line = false\n else\n f.puts( row.join(',') )\n end\n \n end\n end\n\nend",
"def load_csv (csv_file)\n\tret = []\n\tFile.open(csv_file, \"r\") do |f|\n\t\tf.each_line do |line|\n\t\t\t#puts line\n\t\t\tret << line.split(';')\n\t\tend\n\tend\n\treturn ret\nend",
"def csvfield!(str)\r\n ret = \"\"\r\n str.sub!(/^\\s*/,\"\")\r\n if str[0,1]==\"\\\"\"\r\n str[0,1] = \"\"\r\n escaped = false\r\n fieldbytes = 0\r\n str.scan(/./) do |s|\r\n fieldbytes += s.length\r\n break if s==\"\\\"\" && !escaped\r\n if s==\"\\\\\" && !escaped\r\n escaped = true\r\n else\r\n ret += s\r\n escaped = false\r\n end\r\n end\r\n str[0,fieldbytes] = \"\"\r\n if !str[/^\\s*,/] && !str[/^\\s*$/]\r\n raise _INTL(\"Invalid quoted field (in: {1})\\r\\n{2}\",str,FileLineData.linereport)\r\n end\r\n str[0,str.length] = $~.post_match\r\n else\r\n if str[/,/]\r\n str[0,str.length] = $~.post_match\r\n ret = $~.pre_match\r\n else\r\n ret = str.clone\r\n str[0,str.length] = \"\"\r\n end\r\n ret.gsub!(/\\s+$/,\"\")\r\n end\r\n return ret\r\n end",
"def parse_to_load_file(csv)\n csv.each_with_index do |student, index|\n student = {month: csv[index][0] , name: csv[index][1], city: csv[index][2], hobby: csv[index][3]}\n @students << student\n end\nend",
"def readTSVline(l, sep=nil)\n\n sep = detectSeperator if sep.nil?\n\n #row = CSV.parse_line(l, :col_sep => seperator).collect{|x|\n row = l.split(sep).collect{|x|\n if ! x.nil?\n x.strip;\n end\n }\n\n ### Pick specify elements of that table\n #name, id, lastVisitDate, lastAttendedDate, meetupsAttended, profileURL, lastDonationAmount, lastDonationDate = readTSVline(seperator)\n [0, 3, 6, 7, 12, 18, 19, 21].map {|i| row[i]}\nend",
"def format_data(csv_row)\n\t\tklass = @import_type.classify.constantize\n\t\tklass_object = klass.new({original_row: csv_row})\n\t\tformatted_data = klass_object.get_data\n\t\tformatted_data\n\tend",
"def process(csv_data)\n unless csv_data.headers == SOA_CSV_STRUCTURE\n LOGGER.error(\"Structure of #{csv_filename} does not match:\\nExpected: #{SOA_CSV_STRUCTURE.inspect}.\\nActual: #{csv_data.headers.inspect}.\\nContent: #{csv_file}\")\n abort('ABORTED!')\n end\n\n index = 0\n csv_data.delete_if do |row|\n index += 1\n retval = row[:buchungstag].nil? || row[:wertstellung].nil? || row[:umsatzart].nil?\n LOGGER.info(\"- Record nbr. #{index} not processed due to empty field(s): #{row.inspect}\") if retval\n retval\n end\n\n csv_data.sort_by { |row| DateTime.parse(row[:buchungstag]) }\n end",
"def format_csv\n data.match(TIDE_REGEX)[1].gsub('<br>', \"\\n\").gsub(';', ',')\n end",
"def preprocess_csv\n concatenate_arrays(replace_blanks(parsed_csv))\n end",
"def parse_csv_file(delim, file_name) \n \n temp_array = Array.new #Create an array\n file = File.open(file_name, \"r\") #Open a file for reading\n \n \n #Iterate file, parse strings and store\n file.each_line do |line|\n temp_array.push(parse_line(delim, line))\n end\n\n #Close resource\n file.close\n \n return temp_array\nend",
"def parse(line, options, header_size = nil)\n # puts \"SmarterCSV.parse OPTIONS: #{options[:acceleration]}\" if options[:verbose]\n\n if options[:acceleration] && has_acceleration?\n # :nocov:\n has_quotes = line =~ /#{options[:quote_char]}/\n elements = parse_csv_line_c(line, options[:col_sep], options[:quote_char], header_size)\n elements.map!{|x| cleanup_quotes(x, options[:quote_char])} if has_quotes\n return [elements, elements.size]\n # :nocov:\n else\n # puts \"WARNING: SmarterCSV is using un-accelerated parsing of lines. Check options[:acceleration]\"\n return parse_csv_line_ruby(line, options, header_size)\n end\n end",
"def rows\n csv.rows.map { |row_array|\n Row.new(header: header, row_array: row_array).to_a\n }\n end",
"def process line\n return unless line.gsub!(/^INSERT INTO `\\w+` VALUES \\(/,\"\")\n warn \"bad ending\" unless line.gsub!(/\\);?$/, '')\n line.split(/\\),\\(/).each do |tuple|\n begin\n QUOTED_QUOTE_RE.gsub!(tuple, \"''\")\n emit FasterCSV.parse_line(tuple, :quote_char => \"'\")\n rescue FasterCSV::MalformedCSVError => e\n warn \"#{e}: #{tuple}\"\n end\n \n end\n end",
"def prepare_data\n data = CSV.read('input.csv', { col_sep: SEPARATOR })\n\n CSV.open('output.csv','wb') do |csv|\n data.each do |row|\n csv << prepare_row(row)\n end\n end\n\n rescue Errno::ENOENT\n puts 'No valid input.csv file present'\n end",
"def parse(path, source)\n self.contacts = []\n self.success = true\n reader = CSV.open(path, 'r')\n header_row = reader.shift\n return unless find_column_indexes(header_row)\n \n reader.each do |columns| \n c = Contact.new\n p columns\n phone_number = columns[ self.field_indexes[:phone_number] ] \n self.skipped_rows += 1\n next if phone_number == '' or phone_number == nil\n c.phone_number = phone_number.gsub( /\\D/, '')\n c.first_name = columns[ self.field_indexes[:first_name] ]\n c.last_name = columns[ self.field_indexes[:last_name] ] \n c.source_id = columns[ self.field_indexes[:source_id] ]\n c.email = columns [ self.field_indexes[:email] ]\n c.source = source\n self.contacts.push(c)\n end\n\n reader.close\n return contacts\n end",
"def parse\r\n\t\tCSV.foreach(self.filepath) {|row| @list << row}\r\n\t\t@list.flatten!\r\n\tend",
"def is_valid_csv?(part)\n part =~ /#{Mergeit::Config::CSV_FORMAT[:regex]}/\n end",
"def csv_value(it, _user=nil)\n raw_value(it)\n end",
"def parse\n\t\tresults = []\n\t\tif !self.csv_file_file_name.blank? &&\n\t\t\t\tFile.exists?(self.csv_file.path)\n\t\t\t(f=CSV.open( self.csv_file.path, 'rb',{\n\t\t\t\t:headers => true })).each do |line|\n\n\t\t\t\ticf_master_tracker = IcfMasterTracker.find_or_create_by_master_id(\n\t\t\t\t\tline['master_id'],\n\t\t\t\t\t:master_tracker_date => self.master_tracker_date )\n\n\t\t\t\tsuccessfully_updated = icf_master_tracker.update_attributes!(\n\t\t\t\t\tline.to_hash.delete_keys!(\n\t\t\t\t\t\t'master_id').merge(\n\t\t\t\t\t\t:master_tracker_date => self.master_tracker_date) )\n\n\t\t\t\tresults.push(icf_master_tracker)\n\t\t\tend\t#\t(f=CSV.open( self.csv_file.path, 'rb',{ :headers => true })).each\n\t\tend\t#\tif !self.csv_file_file_name.blank? && File.exists?(self.csv_file.path)\n\t\tresults\t#\tTODO why am I returning anything? will I use this later?\n\tend",
"def convert_csv(path, table_name)\n \n # csv file has a header row\n header_row = true\n\n # delimiter for csv file\n delimiter = ','\n\n # variable used to skip header row\n skip_row = true\n\n\n CSV.open(path, 'r', delimiter ) do |row|\n\n row.each_with_index do |col,index|\n if col==nil then \n row[index]='NULL'\n else\n \n col.gsub!(\"'\",\"`\")\n row[index] = \"'#{ col }'\"\n end\n end\n\n # Are we reading the header row of the csv file?\n if header_row\n row.each_with_index do |col,index|\n row[index] = \"\\\"#{ col.gsub(\"'\",'').gsub(/\\s+/,'') }\\\"\"\n end\n header_row = false\n print \"INSERT INTO #{table_name} (#{row.join delimiter }) VALUES\"\n next\n end\n\n # Only skip the first (header) row\n if skip_row == true\n # dont skip further rows\n skip_row = false\n else\n # Print end of line insert delimeter\n puts delimiter\n end\n \n # Print to stdout\n print \"(#{row.join delimiter})\"\n \n end\nend",
"def csvAccountDataParsing\n\taccounts = {}\n\n\tCSV.foreach(\"accounts.csv\", {headers: true, return_headers: false}) do |row|\n\t\taccountName = row[\"Account\"].chomp.capitalize\n\t\taccounts = set_initial_values(accounts, accountName, row)\n\t\taccounts[accountName].addData(row)\n\tend\n\n\taccounts.each_value do |value|\n\t\tvalue.calculateFinalAmounts\n\tend\n\n\treturn accounts\nend",
"def filter_data_columns_csv(iterator)\n retval = []\n\n if iterator == nil\n return []\n end\n\n csv = CSV.parse(iterator, :headers => true, :skip_blanks => true)\n \n headers = csv.headers() \n #check for duplicate field names\n #dup_head = headers.detect {|e| headers.rindex(e) != headers.index(e)}\n dup_head = headers.detect do |e|\n if (!e.empty?) #For empty (e == \"\") header fields\n headers.rindex(e) != headers.index(e)\n end\n end\n \n if (headers.empty?)\n message = \"#### Error: header filtering failed.\\n\"\n return [message, nil]\n end\n \n if (dup_head != nil)\n message = \"### Error: document may contain duplicate column names.\\n\"\n message << \"# Source: \" << dup_head << \"\\n\"\n return [message, nil]\n end\n \n csv.each do |row|\n row_hash = (row.to_hash)\n retval << row_hash\n end\n\n return [message, retval]\n end",
"def parse\n output = File.open out_file, 'w'\n File.open(inp_file).each do |line|\n # CSV parse returns an array of rows - we need only the first\n parsed_line = CSV.parse(line.chomp, col_sep: \"\\t\", liberal_parsing: true).first\n value_map = csv_row_to_map(parsed_line)\n puts value_map[:details]['name'] if verbose\n output.puts value_map.to_json\n end\n output.close\n end",
"def initialize(csv_in_filename, era_year_handle, rmid_from_era_year_handles_string)\n @in_file = csv_in_filename\n verify_in_file\n\n @db_conn = PG::Connection.connect(DB_CONNECT_INFO)\t# Connect to the DB\n @era_year_handle = era_year_handle\n verify_era_year_handle\n\n @rmid_from_era_year_handles_string = rmid_from_era_year_handles_string\n if @rmid_from_era_year_handles_string == 'any'\n @rmid_from_era_year_handles = nil\n @rmid_from_era_year_handles_regex = nil\n else\n @rmid_from_era_year_handles = rmid_from_era_year_handles_string.split(',')\n @rmid_from_era_year_handles_regex = \"^(#{@rmid_from_era_year_handles.join('|')})$\"\n end\n verify_rmid_from_era_year_handles\n\n @csv_out_headers = nil\n @csv_out_data = nil\n @handles_by_prefix = {}\t\t# Cache for collection-handles\n convert\n @db_conn.close if @db_conn\n end",
"def parse(line)\n @io.rewind\n @io.truncate(0)\n @io << line\n @io.rewind\n @csv.shift\n end",
"def csv_data\n case\n when google_key || url then Curl::Easy.perform(uri).body_str\n when file then File.open(uri).read\n end\n end",
"def csv(csv_file)\n Slacker.get_csv(csv_file)\n end",
"def load_csv(csv_filepath)\n gifts = []\n CSV.foreach(csv_filepath) do |row|\n gifts << row[0] # Nosso csv só tem uma coluna\n end\n return gifts\nend",
"def read_csv(file_name)\n CSV.foreach(file_name, headers: true) do |row|\n print row['Year'.gsub('*', ' ')], ' '\n qbr(row['Cmp'].to_f, row['Att'].to_f, row['TD'].to_f, row['Int'].to_f,\n row['Yds'].to_f)\n end\nend",
"def process_csv(path)\n res = {}\n CSV.foreach(path) do |row|\n (tag_str, _, dest_str, val_str) = row\n next unless $tags.has_key? tag_str\n tag, dest, val = $tags[tag_str], dest_str.to_i, val_str.to_i\n res[dest] = {} unless res.has_key?(dest)\n res[dest][tag] = 0 unless res[dest].has_key?(tag)\n res[dest][tag] += val\n end\n res\nend",
"def parse(file_path)\n begin\n rows = CSV.read(file_path, headers: true, header_converters: :symbol, converters: [:all, :blank_to_nil])\n rescue CSV::MalformedCSVError => e\n raise \"Could not parse CSV file. Original error: #{e.message}\"\n rescue StandardError => e\n raise \"Could not load CSV file. Make sure the file has CSV headers. Original error: #{e.message}\"\n end\n @contracts = rows.collect {|row| row.to_hash }\n end",
"def load_csv(file)\n metadata = File.open(file, 'r')\n metadata_parsed = CSV.new(metadata, :headers => true, :header_converters => :symbol)\n return metadata_parsed\n end"
] |
[
"0.71557415",
"0.70016444",
"0.6993744",
"0.6969925",
"0.69469714",
"0.68631893",
"0.6844068",
"0.67699975",
"0.67562205",
"0.67546135",
"0.6695829",
"0.66855246",
"0.6676476",
"0.6661149",
"0.665229",
"0.66471875",
"0.66189283",
"0.6612319",
"0.6600012",
"0.6539154",
"0.6536424",
"0.65319365",
"0.65180373",
"0.6514811",
"0.6486581",
"0.6437814",
"0.6421007",
"0.6410469",
"0.64022523",
"0.63970566",
"0.6390986",
"0.63878536",
"0.6375831",
"0.6360623",
"0.63499016",
"0.6343834",
"0.6308484",
"0.63045293",
"0.62940997",
"0.62825704",
"0.6279472",
"0.6259188",
"0.6256603",
"0.6245998",
"0.6244532",
"0.6230353",
"0.6224676",
"0.6222735",
"0.62110645",
"0.62110645",
"0.62095416",
"0.61950517",
"0.6192453",
"0.6165669",
"0.6154728",
"0.61487275",
"0.6140329",
"0.61386627",
"0.6136349",
"0.6123387",
"0.6104339",
"0.6101445",
"0.6099443",
"0.6089308",
"0.6086485",
"0.60862803",
"0.6060765",
"0.605557",
"0.6054777",
"0.60475045",
"0.6043545",
"0.6043238",
"0.6027849",
"0.60015094",
"0.59825164",
"0.5982295",
"0.5971591",
"0.5950883",
"0.59505343",
"0.5950494",
"0.59459907",
"0.59444475",
"0.5943925",
"0.5938766",
"0.5936217",
"0.59357953",
"0.59229153",
"0.5918804",
"0.5906157",
"0.5897288",
"0.58954346",
"0.58880454",
"0.58830833",
"0.58804053",
"0.5874536",
"0.5866293",
"0.5864233",
"0.5860303",
"0.58537114",
"0.58529466",
"0.5851778"
] |
0.0
|
-1
|
embed gist, accepts: | luikore/737238 gist.github.com/luikore/737238
|
def parse_gist
src = content.strip
if src =~ /\A\w+(\-\w+)*\/\d+/
src = "https://gist.github.com/#{src}"
else
src.sub! /\A(?=gist\.github\.com)/, 'https://'
end
src.sub!(/((?<!\.js)|\.git)$/, '.js')
%Q|<script src="#{src}"></script>|
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def gist( gist_id )\n\tgist_snippet_url = \"http://gist.github.com/#{gist_id}\"\n\treturn (<<-EOS).chomp\n<div class=\"gist_plugin\"><script src=\"#{gist_snippet_url}.js\"></script>\n<noscript><a href=\"#{gist_snippet_url}\">gist:#{gist_id}</a></noscript></div>\n\tEOS\nend",
"def run_gist\n `open http://gist.github.com/#{gist_id}` if gist_id\n end",
"def make_gist\n @gist = Gist.new(:description => \"TODO Gist\",\n :public => false)\n @gist[\"list.json\"] = \"[]\"\n @gists.save @gist\n end",
"def gist_url\n \"#{api_url}/gists/%s\"\n end",
"def set_gist_data\n gist.description = generated_gist_description\n gist.files.keys.each { |filename| gist.files[filename] = nil }\n code_examples.each do |example|\n gist.files[example.filename] = { :content => example }\n end\n gist.files\n end",
"def execute(*args)\n private_gist = defaults[\"private\"]\n gist_filename = nil\n gist_extension = defaults[\"extension\"]\n browse_enabled = defaults[\"browse\"]\n\n opts = OptionParser.new do |opts|\n opts.banner = \"Usage: gist [options] [filename or stdin]\"\n\n opts.on('-p', '--[no-]private', 'Make the gist private') do |priv|\n private_gist = priv\n end\n\n t_desc = 'Set syntax highlighting of the Gist by file extension'\n opts.on('-t', '--type [EXTENSION]', t_desc) do |extension|\n gist_extension = '.' + extension\n end\n\n opts.on('-o','--[no-]open', 'Open gist in browser') do |o|\n browse_enabled = o\n end\n\n opts.on('-m', '--man', 'Print manual') do\n Gist::Manpage.display(\"gist\")\n end\n\n opts.on('-v', '--version', 'Print version') do\n puts Gist::Version\n exit\n end\n\n opts.on('-h', '--help', 'Display this screen') do\n puts opts\n exit\n end\n end\n\n opts.parse!(args)\n\n begin\n if $stdin.tty?\n # Run without stdin.\n\n # No args, print help.\n if args.empty?\n puts opts\n exit\n end\n\n # Check if arg is a file. If so, grab the content.\n if File.exists?(file = args[0])\n input = File.read(file)\n gist_filename = file\n gist_extension = File.extname(file) if file.include?('.')\n else\n abort \"Can't find #{file}\"\n end\n else\n # Read from standard input.\n input = $stdin.read\n end\n\n url = write(input, private_gist, gist_extension, gist_filename)\n browse(url) if browse_enabled\n puts copy(url)\n rescue => e\n warn e\n puts opts\n end\n end",
"def load_from_gist(url, version_id)\n\nend",
"def render_gist(gist, file, data)\n json = JSON.parse(data)\n\n # get the list of gist files\n files = json[\"files\"]\n\n # our output buffer\n output = \"\"\n\n files.each do |name,info|\n\n # if a file name was provided, only display that file\n if !file.empty? && file != name\n next\n end\n\n # raw gist content\n data = info[\"content\"]\n\n # render markdown ourselves\n if info[\"language\"] == \"Markdown\"\n output << data\n output << \"\\n\\n\"\n else\n script_url = script_url_for(gist, name)\n code = CGI.escapeHTML data\n output << \"<div><script src='#{script_url}'></script>\"\n output << \"<noscript><pre><code>#{code}</code></pre></noscript></div>\"\n end\n end\n CGI.unescapeHTML(output)\n end",
"def render_gist(gist, file, data)\n script_url = script_url_for gist, file\n html_output_for script_url, data\n end",
"def get_gist_url_for(gist, file)\n \"https://raw.github.com/gist/#{gist}/#{file}\"\n end",
"def get_gist_url_for(gist, file)\n \"https://api.github.com/gists/#{gist}\"\n end",
"def new_embed\n definitions = files.map do |f|\n path = f[0].split(\"/\")[8..-1].join(\"/\")\n line = f[1]\n \"[`#{path}#L#{line}`](#{GITHUB_URL}/tree/#{GIT_VERSION}/lib/#{path}#L#{line})\"\n end.join(\"\\n\")\n\n Discordrb::Webhooks::Embed.new(\n color: 0xff0000,\n url: github_pages_url,\n title: \"[View on Git Docs]\",\n description: definitions,\n footer: {text: \"discordrb v#{Discordrb::VERSION}@#{GIT_VERSION}\", icon_url: RUBY_TACO},\n ).tap { |e| yield e if block_given? }\n end",
"def embed(src, mime_type, label)\nend",
"def gist_string(string)\n gist(:string=>string, :private=>true)\n end",
"def execute(*args)\n set_config('gist.api-url', DEFAULT_GITHUB_API_BASE_URL) if !config('gist.api-url')\n set_config('gist.default-url', DEFAULT_GITHUB_API_BASE_URL) if !config('gist.default-url')\n\n begin\n option_parser.parse!(args)\n\n if $stdin.tty? && options.setup_credentials\n api_url # make sure API URL selection happens, if need be\n setup_credentials\n exit 1\n end\n\n if $stdin.tty? && args[0] != '-'\n # Run without stdin.\n usage if args.empty?\n\n files = args.inject([]) { |list, file|\n # Check if arg is a file. If so, grab the content.\n abort \"Can't find #{file}\" unless File.exists?(file)\n\n list.push({\n :input => File.read(file),\n :filename => file,\n :extension => file.include?('.') ? File.extname(file) : options.gist_extension\n })\n }\n else\n # Read from standard input.\n input = $stdin.read\n files = [{:input => input, :extension => options.gist_extension}]\n end\n\n url = write(files, options.private_gist, options.description)\n browse(url) if options.browse_enabled\n $stdout.puts copy(to_embed(url)) if options.embed_enabled\n $stdout.puts copy(url) unless options.embed_enabled\n rescue Interrupt\n $stderr.puts \"\\nQuit.\"\n exit 1\n rescue OptionParser::InvalidOption => e\n warn e; puts\n usage\n exit 1\n rescue StandardError => e\n options.debug ? warn(e) : raise(e)\n end\n end",
"def gist(id)\n get \"/gists/#{id}\"\n end",
"def gist_params\n params.require(:gist).permit(:description, :file_name, :code, :secret, :user_id)\n end",
"def gist_params\n params.require(:gist).permit(:snippet, :lang, :description)\n end",
"def find_gist\n matches = @gists.get_all.select {|g| g[:description] == \"TODO Gist\"}\n if matches.length > 0 then\n @gists.get_gist(matches[0][:id])\n else\n nil\n end\n end",
"def sync_from_gist! octoclient\n name, file = octoclient.gist(gist_id).files.first\n self.body = file.content\n self.title = name.to_s.gsub(/\\.md$/, '').gsub('_', ' ').capitalize\n rescue Octokit::NotFound => e\n self.body = nil\n end",
"def gist_id(id)\n Hardmode.get(\"/gists/#{id}\", :headers => @auth)\n end",
"def create\n @gist = Gist.new(params[:gist])\n current_user.gists << @gist\n \n respond_to do |format|\n if @gist.save\n format.html { redirect_to @gist, notice: 'Gist was successfully created.' }\n format.json { render json: @gist, status: :created, location: @gist }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @gist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def script_url_for(gist_id, filename)\n \"https://gist.github.com/#{gist_id}.js?file=#{filename}\"\n end",
"def create\n @gist = Gist.new(gist_params)\n\n respond_to do |format|\n if @gist.save\n format.html { redirect_to @gist, notice: 'Gist was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gist }\n else\n format.html { render action: 'new' }\n format.json { render json: @gist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @gist = Gist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gist }\n end\n end",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\n end\nend",
"def load_gists(user = USER)\n require 'bundler'\n Bundler.setup :api\n require 'github_api'\n GISTS.replace Github.new.gists.list user: user\n end",
"def new\n @gist = Gist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gist }\n end\n end",
"def edit_gist(id, files={}, options={:public => true})\n options.merge!(files)\n patch \"/gists/#{id}\", :body => options\n end",
"def set_gist\n @gist = Gist.find(params[:id])\n end",
"def post_new_gist content \n\t\t\t\turl = GITHUB_API_GIST_LINK \n\t\t\t\tresponse = https_open_for ({url: url, mthd:\"post\", content: content})\n \t\t\t\tJSON.parse response.body\n\t\t\tend",
"def _embed_source(workdir)\n FileUtils.mkdir_p _source_dir(workdir)\n File.open(_path_to_source(workdir), 'wb') do |f|\n f.write manuscript_contents\n end\n end",
"def embed_image(src, label)\n id = \"img_#{@img_id}\"\n @img_id += 1\n if @io.respond_to?(:path) and File.file?(src)\n out_dir = Pathname.new(File.dirname(File.absolute_path(@io.path)))\n src = Pathname.new(File.absolute_path(src)).relative_path_from(out_dir)\n end\n # removing home dir\n src = URI::encode(src.gsub(\"#{Dir.home}\", ''))\n @builder.span(:class => 'embed') do |pre|\n pre << %{<a href=\"\" onclick=\"img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false\">#{label}</a><br> \n <img id=\"#{id}\" style=\"display: none\" src=\"#{src}\"/>}\n end\n end",
"def read(gist_id)\n open(GIST_URL % gist_id).read\n end",
"def githubize\n # method goes here\n end",
"def edit_gist(filepath, opts = {})\n begin\n id, name = select_gist_id(\"edit\")\n edit_opts = generate_options(filepath, opts)[0]\n options = {:body => edit_opts.to_json}\n resp = self.class.patch(\"/gists/#{id}\", options)\n response_handling(resp, 200, name, \"edited\")\n rescue SocketError => e\n puts \"\\ncould not connect to Github, heres the error - SocketError - #{e}\\n\"\n puts \"your probably not connected to the internetz, dumbo\"\n end\n end",
"def fork_gist(id)\n boolean_request :post, \"/gists/#{id}/fork\"\n end",
"def project_hook(project)\n # STUB\n end",
"def boxen(name, *args)\n args << {} unless Hash === args.last\n args.last[:github_tarball] ||= \"boxen/puppet-#{name}\"\n mod name, *args\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github\n @github ||= (\n require 'detroit'\n require 'detroit-github'\n Detroit::GitHub.new(\n :folder => 'website'\n #:sitemap => {\n # 'index.html' => 'index.html',\n # 'doc.json' => 'doc.json',\n # 'assets' => 'assets'\n #}\n )\n ) \nend",
"def update_gist\n @gist[\"list.json\"] = JSON.pretty_generate @things\n @gists.save @gist\n end",
"def set_gist\n @gist = Gist.find(params[:id])\n end",
"def set_gist\n @gist = Gist.find(params[:id])\n end",
"def create_gist(filepath, opts={})\n begin\n create_opts, name = generate_options(filepath, opts)\n options = {:body => create_opts.to_json}\n resp = self.class.post(\"/gists\", options)\n response_handling(resp, 201, name, \"created\")\n rescue SocketError => e\n puts \"\\ncould not connect to Github, heres the error - SocketError - #{e}\\n\"\n puts \"your probably not connected to the internetz, dumbo\"\n end\n end",
"def gist_comment(id, comment_id)\n get \"/gists/#{id}/comments/#{comment_id}\"\n end",
"def to_embed(url)\n %Q[<script src=\"#{url}.js\"></script>]\n end",
"def github(name: T.unsafe(nil), email: T.unsafe(nil), uid: T.unsafe(nil)); end",
"def get_gist_from_web(gist, file)\n gist_url = get_gist_url_for gist, file\n raw_uri = URI.parse gist_url\n proxy = ENV['http_proxy']\n if proxy\n proxy_uri = URI.parse(proxy)\n https = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new raw_uri.host, raw_uri.port\n else\n https = Net::HTTP.new raw_uri.host, raw_uri.port\n end\n https.use_ssl = true\n https.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new raw_uri.request_uri\n data = https.request request\n data = data.body\n cache gist, file, data unless @cache_disabled\n data\n end",
"def create_gists(file, options={})\n opts = {:files => {File.basename(file) => { 'content' => File.read(file) }}}\n options.merge!(opts)\n result = self.class.post(\"/gists\", :body => options.to_json, :headers => @headers)\n if result.code == 201\n puts \"You have successfully created a new gist!\"\n end\n end",
"def stanford(name, ref = 'master')\n gitrepo \"code.stanford.edu\", name, ref\nend",
"def update\n @gist = Gist.find(params[:id])\n\n respond_to do |format|\n if @gist.update_attributes(params[:gist])\n format.html { redirect_to @gist, notice: 'Gist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def private_gem(name)\n gem name, '0.3.0', git: \"https://#{ENV['GITHUB_TOKEN']}:x-oauth-basic@github.com/mharris717/#{name}.git\", branch: :master\nend",
"def parse_lj_embed_tags(html, entry)\n # raise EntryWithoutAccountException if entry.account.blank?\n # raise EntryWithoutBlogEntryException if entry.blogentry.blank?\n return '' if html.blank?\n tag_regex =/(<lj-embed\\ {1,}id\\ {0,1}=\\ {0,}[\\\"\\'](.+?)[\\\"\\']\\ {0,}?[\\/]?>)/ism\n html.scan(tag_regex).each do |x|\n id = x[1]\n url = \"#{entry.account.url}#{entry.blogentry.filename}\" rescue '#'\n str = \"This post contains embedded media, click here to view.\".t\n html.gsub!(x[0], \"<a href=\\\"#{url}\\\">#{str}</a>\")\n end\n html\n end",
"def paste_text(text, title = \"rake test\")\n uri = URI.parse('http://gist.github.com/api/v1/xml/new')\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data({ \"files[Fancy: #{title} @ #{get_revision}]\" => text })\n res = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }\n if(res.code == '200')\n 'http://gist.github.com/' + res.body.match(/repo>(\\d+)</)[1]\n else\n false\n end\n end",
"def render_document(content, extension, repo_loc = \"\", version = \"\")\n doc = begin\n if %w(md mdown markdown).include?(extension.downcase)\n render_markdown(content)\n else\n content\n end\n end.gsub(/src=\"(?!http)(.+)\"/, %(src=\"https://github.com/#{repo_loc}/raw/#{version}/\\\\1\")).html_safe\n end",
"def get_gist_contents(gist_id)\n gister = Homework.get(\"/gists/#{gist_id}\", :headers => @auth)\n #binding.pry\n gister['files'].each do |file|\n file.each do |x|\n x['content']\n end\n end\n end",
"def embed\n @missing = true\n\n pars = embed_params\n\n sid = pars[:id]\n type = pars[:type]\n is_static = type == \"static\"\n gon.tp = pars[:c]\n\n if sid.present?\n shr = ShortUri.by_sid(sid, is_static ? :embed_static : :explore)\n if shr.present? && shr.other.present? && (shr.other == 0 || shr.other == 1)\n gon.is_donation = shr.other == 0\n if (gon.is_donation ? [\"a\", \"b\"] : [\"a\"]).index(gon.tp).present?\n gon.data = is_static ? shr.pars : ((gon.is_donation ? Donor : Dataset).explore(shr.pars, \"co\" + gon.tp, true))\n @missing = false\n end\n end\n end\n\n respond_to do |format|\n format.html { render :layout => 'embed' }\n end\n end",
"def git_sources=(_arg0); end",
"def git_sources=(_arg0); end",
"def push(thing)\n @things.unshift thing\n update_gist\n end",
"def gem_git(name, options) # :nodoc:\n if gist = options.delete(:gist)\n options[:git] = \"https://gist.github.com/#{gist}.git\"\n end\n\n return unless repository = options.delete(:git)\n\n pin_gem_source name, :git, repository\n\n reference = gem_git_reference options\n\n submodules = options.delete :submodules\n\n @git_set.add_git_gem name, repository, reference, submodules\n\n true\n end",
"def gist_comments(id)\n get \"/gists/#{id}/comments\"\n end",
"def garnish(html)\n template{ html }\n end",
"def embed(fname, hash=nil)\n if not @root_dir.nil?\n fname = File.join(@root_dir, fname)\n end\n File.open(fname) do |f|\n tmpl = f.read()\n process_string(tmpl, fname, hash)\n end\n end",
"def github(name, ref = 'master')\n gitrepo \"github.com\", name, ref\nend",
"def embed_code(options={})\n \"<img src=\\\"#{@url}\\\" width=\\\"#{embed_width}\\\"/>\"\n end",
"def get_tumblr_embed_link_title(work)\n title = work.title + \" (#{work.word_count} #{ts('words')})\".html_safe\n if work.anonymous?\n pseud = ts(\"Anonymous\")\n else\n pseud = work.pseuds.map {|pseud| (pseud.name)}.join(', ').html_safe\n end\n title + ts(\" by \") + pseud + ts(\" [#{ArchiveConfig.APP_SHORT_NAME}]\")\n end",
"def github_url\n GITHUB_ARTICLES_URL + file_name\n end",
"def patches\n \"https://gist.github.com/fredrikw/5858168/raw\"\n end",
"def parse_gist_id(link_url)\n gist_id = \n if link_url.match? '</script>' \n link_url.sub(/.js\"><\\/script>/, '') \n elsif link_url.match? '.git' \n link_url.sub(/.git$/, '') \n else \n link_url \n end \n File.basename(gist_id)\n end",
"def add_to_doc idea\n GDFile.update_from_string(\n append_idea(IdeaTemplate % [idea[:user],\n idea[:message],\n idea[:link]] ))\nend",
"def gist_comment(comment_id, params={})\n _normalize_params_keys(params)\n _merge_mime_type(:gist_comment, params)\n\n get(\"/gists/comments/#{comment_id}\", params)\n end",
"def github_url\n \"http://github.com/280north/cappuccino/commit/#{sha1}\"\n end",
"def github_url(ruby_doc)\n version, file, line = ruby_doc.source_location.split(\":\")\n\n if version == MASTER\n path = File.join version, file\n else\n github_version = version.tr(\".\", \"_\")\n path = File.join \"v#{github_version}\", file\n end\n\n URI.join(GITHUB_REPO, path, \"#L#{line}\").to_s\n end",
"def use_github?\n !journal_biohackrxiv?\n end",
"def git\n\tend",
"def path_to_file_on_github\n \"https://github.com/#{@repo.name}/blob/master/#{@file}#L#{@todo.line_number}\"\n end"
] |
[
"0.7336357",
"0.6581036",
"0.65539694",
"0.6379984",
"0.63251203",
"0.6317538",
"0.6216875",
"0.61995375",
"0.613781",
"0.6091878",
"0.6082169",
"0.60490996",
"0.5932171",
"0.58436644",
"0.5817473",
"0.57898843",
"0.57616067",
"0.57411134",
"0.5689497",
"0.565051",
"0.5636411",
"0.5608697",
"0.5601677",
"0.55409",
"0.5512082",
"0.55100226",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.54149866",
"0.5414563",
"0.54144317",
"0.5413328",
"0.5412829",
"0.5409474",
"0.5399471",
"0.5390523",
"0.5378922",
"0.53551954",
"0.5337291",
"0.53301406",
"0.531797",
"0.53125393",
"0.53078055",
"0.5293887",
"0.5293887",
"0.5293887",
"0.5293887",
"0.5293887",
"0.5293887",
"0.5293887",
"0.5293887",
"0.5293887",
"0.5293887",
"0.5233332",
"0.52225083",
"0.51863015",
"0.51863015",
"0.518596",
"0.51762295",
"0.5173825",
"0.51688665",
"0.51521665",
"0.51204866",
"0.5090384",
"0.50539684",
"0.50486773",
"0.5045005",
"0.50358",
"0.49902856",
"0.49829096",
"0.49768385",
"0.49728942",
"0.49728942",
"0.49611342",
"0.49544954",
"0.4950936",
"0.4927709",
"0.49276415",
"0.4923082",
"0.49040493",
"0.49036825",
"0.49017072",
"0.48968753",
"0.48710805",
"0.48592946",
"0.48451266",
"0.48343444",
"0.48116383",
"0.48005947",
"0.47998372",
"0.47962934"
] |
0.63015604
|
6
|
embed video, calculates embed iframe by urls from various simple formats, but not accept iframe code
|
def parse_video
# standard
unless /\A\s*(?<width>\d+)x(?<height>\d+)\s+(?<url>.+)\z/ =~ content
env.warn 'can not parse \video content, should be "#{WIDTH}x#{HEIGHT} #{URL}"'
return
end
case url
when /youtu\.?be/
# NOTE merging them into one regexp fails (because longest match?)
unless id = url[/(?<=watch\?v=)\w+/] || url[/(?<=embed\/)\w+/] || url[/(?<=youtu\.be\/)\w+/]
env.warn 'can not parse youtube id'
return
end
%Q|<iframe width="#{width}" height="#{height}" src="https://www.youtube-nocookie.com/embed/#{id}?rel=0" frameborder="0" allowfullscreen></iframe>|
when /vimeo/
unless id = url[/(?<=vimeo\.com\/)\w+/]
env.warn 'can not parse vimeo id, should use link like this "http://vimeo.com/#{DIGITS}"'
return
end
%Q|<iframe width="#{width}" height="#{height}" src="https://player.vimeo.com/video/#{id}" frameborder="0" allowFullScreen></iframe>|
when /sm/
unless id = url[/\bsm\d+/]
env.warn 'can not find "sm#{DIGITS}" from link'
return
end
%Q|<script src="https://ext.nicovideo.jp/thumb_watch/#{id}?w=#{width}&h=#{height}"></script>"|
else
env.warn 'failed to parse video link, currently only youtube, vimeo and niconico are supported'
return
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def embed_video\r\n\tvid_host = self.video_url.sub(/^https?\\:\\/\\//, '').sub(/^www./,'').split('/')[0]\r\n\tif vid_host == 'youtube.com' or vid_host == 'youtu.be'\r\n\t\tyoutube_embed(self.video_url)\r\n\telsif vid_host == 'player.vimeo.com' or vid_host == 'vimeo.com'\r\n\t\tvimeo_embed(self.video_url)\r\n\tend\r\n end",
"def grab_url_embeddable(url)\n video_info = get_video_info(url)\n video_params = extract_video_parameters(video_info)\n\n unless video_params[:embeddable]\n Youtube.notify(\"VIDEO IS NOT EMBEDDABLE\")\n return false\n end\n\n urls_formats = extract_urls_formats(video_info)\n selected_format = choose_format(urls_formats)\n title = video_params[:title]\n file_name = PluginBase.make_filename_safe(title) + \".\" + VIDEO_FORMATS[selected_format][:extension]\n\n {:url => urls_formats[selected_format], :name => file_name}\n end",
"def embedded_video_url\n self.video_url.sub 'watch?v=', 'embed/'\n end",
"def embed_code(width = 500, height = 315)\n if self.vimeod?\n '<iframe src=\"http://player.vimeo.com/video/' + self.vimeo_id.to_s + '?api=1&player_id=video_' + self.id.to_s + '&title=0&byline=0&portrait=0\" id=\"video_' + self.id.to_s + '\" width=\"' + width.to_s + '\" height=\"' + height.to_s + '\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'\n else\n self.embed_code_html(width, height)\n end\n end",
"def iframes; end",
"def get_video_iframe(boulder, width = \"560px\", height = \"315px\")\n if find_vimeo_id(boulder.link)\n get_vimeo_iframe(boulder, width, height)\n elsif find_youtube_id(boulder.link)\n get_youtube_iframe(boulder, width, height)\n end\n end",
"def vimeo_embed(vimeo_url)\r\n\tif vimeo_url[/vimeo\\.com\\/([^\\?]*)/]\r\n\t\tvimeo_id = $1\r\n\telse \r\n\t\tvimeo_url[/^.*((v\\/)|(embed\\/)|(watch\\?))\\??v=?([^\\&\\?]*).*/]\r\n\t\tvimeo_id = $5\r\n\tend\r\n\t#Hate using Iframes but might get that kink out in a few drafts of the website\r\n\t%Q{<iframe title=\"Vimeo video player\" width=\"600px\" height=\"450px\" height=\"auto\" src=\"\\/\\/player.vimeo.com\\?#{ vimeo_id }\" frameborder=\"0\" allowfullscreen></iframe>}\r\n end",
"def video_embed_tag(youtube_url, width = '500', height = '315')\n embed_url = Youtube.embed_url(youtube_url)\n return '' if embed_url.blank?\n tag(:iframe, {:width => width, :height => height, :src => embed_url, :frameborder => 0, :allowfullscreen => true})\n end",
"def vimeo_tag(url, opts = {})\n # extract vimeo_id thing\n# m = url.match(/(?<=\\/)\\d{2,}(?=$|\\/)/)\n# vimeo_id = m.present? ? m[0] : url\n vimeo_id = 36820781\n # \"https://player.vimeo.com/video/999999\"\n embed_url = \"//player.vimeo.com/video/#{vimeo_id}\"\n\n content_tag(:iframe, \"\", :src => embed_url,\n :frameborder => opts[:frameborder],\n :allowfullscreen => true,\n :width => opts[:width] || \"600\",\n :height => opts[:height] || \"480\"\n )\nend",
"def youtube_embed_code(size)\n width, height = video_embed_size(size)\n \"<iframe id='embedded_video' width='#{width}' height='#{height}' src='http://www.youtube.com/embed/#{self.params['v'][0]}?autohide=1&hd=1&border=1&showinfo=0' frameborder='0' allowfullscreen></iframe>\".html_safe\n end",
"def detect_host\n if self.link =~ /(youtube)/\n \"<iframe width='560' height='315' src='https://www.youtube.com/embed/#{youtube_code}' frameborder='0' allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe>\"\n else\n \"<iframe src='https://player.vimeo.com/video/#{vimeo_code}?color=ffffff' width='640' height='360' frameborder='0' allow='autoplay; fullscreen' allowfullscreen></iframe>\"\n end\n end",
"def to_html\n w = 400\n h = 300\n id = @url.match(REGEX)[1]\n embed_image = \"#{BASE_URL}/embed.html?mid=#{id}&width=#{w}&height=#{h}&etp=im\"\n embed_3d = \"#{BASE_URL}/embed.html?mid=#{id}&width=#{w}&height=#{h}\"\n <<HTML\n<div class=\"onebox-3dwh\" id=\"#{id}\">\n <iframe src=\"#{embed_image}\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" width=\"#{w}\" height=\"#{h}\" allowfullscreen></iframe>\n <div class=\"onebox-3dwh-circle\" onclick=\"$('##{id} iframe').attr('src', '#{embed_3d}'); $(this).remove()\" />\n</div>\nHTML\n end",
"def show\n @iframe = @video.iFrame_Source.html_safe\n end",
"def youtube_embed_url\n VideoInfo.new(self.video_url).embed_url if self.video_url?\n end",
"def convert_to_youtube_embed_link\n self.video_url.gsub!(/(youtube.com\\/)(.)*v=([\\w\\-_]+)(.)*$/, '\\1embed/\\3')\n end",
"def embed(src, mime_type, label)\nend",
"def youtube_movie_embed\n str1 = \"http://www.youtube.com/v/\" \n str2 = movie_home_url.split('v=',2).last unless movie_home_url.nil?\n str3 = \"&hl=en_US&fs=1&\"\n return [str1,str2,str3].join \n end",
"def embedyoutube(videonumber)\n %{\n <body style=\"margin:0;\">\n <object height=\"100%\" width=\"100%\"><param name=\"movie\" value=\"http://www.youtube.com/v/#{videonumber}&autoplay=1\" /><embed height=\"100%\" src=\"http://www.youtube.com/v/#{videonumber}&autoplay=1\" type=\"application/x-shockwave-flash\" width=\"100%\"></embed></object>\n </body>\n }\n end",
"def render_resolve_url_personal(work, show_youtube_iframe=false)\n url = work.attach_url\n obj = get_resolved_url_obj(url)\n case obj[:type]\n when \"image\"\n tag :img, src: \"#{url}\", onload: \"onImageLoad(this)\"\n when \"audio\" #compare to 2\n tag :audio, controls: \"controls\", src: \"#{url}\", style: \"width:100%;\"\n when \"video\"\n tag :video, controls: \"controls\", src: \"#{url}\", width: \"100%\", height: \"100%\"\n when \"youtube\"\n matches = obj[:match_object]\n if show_youtube_iframe\n queryobj = {}\n queryobj[\"rel\"] = 0\n hashes = \"\"\n overrides = Rack::Utils.parse_query(URI.parse(matches[0]).query)\n overrides.delete(\"v\")\n queryobj = queryobj.merge(overrides)\n if matches[4] != nil\n splits = matches[4].split('#')\n if splits.length > 1\n hashes += \"#\" + splits[1]\n end\n end\n queryobj[\"enablejsapi\"] = 1;\n if queryobj[\"t\"].present?\n timeRe = /((?<min>\\d+)[m])?((?<sec>\\d+)[s])?/\n time = queryobj[\"t\"].scan(timeRe)[0]\n queryobj[\"start\"] = (time[0] ? time[0].to_i : 0) * 60 + (time[1] ? time[1].to_i : 0)\n end\n querystr = Rack::Utils.build_query(queryobj)\n content_tag :iframe, '', src: \"https://www.youtube.com/embed/#{matches[2]}?#{querystr}#{hashes}\", width: '100%', frameborder: '0', height: '100%'\n else\n tag :img, src: \"https://i.ytimg.com/vi/#{matches[2]}/hqdefault.jpg\", onload: \"onImageLoad(this)\"\n end\n else\n # content_tag :div, :data => { :remote_url => url }, class: \"remote-preview\" do\n # content_tag(:div,'', style: 'background-image:url(' + work.remote_image_url + ')', class: 'preview-image') +\n # content_tag(:p, work.remote_description, class: 'preview-description')\n # end\n tag :img, src: \"#{work.remote_image_url}\", onload: \"onImageLoad(this)\"\n end\n end",
"def embed_code_html(width = 500, height = 315)\n '[video saved - will display when done]'\n end",
"def embeddable_url\n\t\turl.sub('watch?v=', 'embed/')\n\tend",
"def render_video_directly options={}\n # render video player\n content_tag(:div) do\n options[:value].collect do |video_md5|\n l1 = video_md5[0..1]\n l2 = video_md5[2..3]\n content_tag(:video,\n content_tag(:source, \"I'm sorry; your browser doesn't support HTML5 video in MP4 with H.264.\",\n src: \"https://cspace-prod-02.ist.berkeley.edu/#TENANT#_nuxeo/data/#{l1}/#{l2}/#{video_md5}\",\n id: 'video_md5',\n type: 'video/mp4'),\n controls: 'controls',\n style: 'width: 640px;')\n end.join.html_safe\n end\n end",
"def embed\n if youtube_url then youtube_embed\n # Uploads don't get put in the embed field on Kitsu\n elsif upload_url then nil\n elsif image then image_embed\n elsif link then link\n end\n end",
"def youtube_embed video, *style\n result = content_tag :iframe, 'youtube', src: video.yt_embed_link\n if style\n result = content_tag :iframe, 'youtube', src: video.yt_embed_link, style: style\n end\n return result\n end",
"def embed(youtube_url)\n youtube_id = youtube_url.split('=').last\n content_tag(:iframe, nil, src: \"//www.youtube.com/embed/#{youtube_id}\")\n end",
"def embed\n \"#{video.__embed__}#{tracker(true)}\"\n end",
"def youtubify(url)\n if youtube?(url)\n \"<iframe width='400' height='300' \" +\n \"src='#{url.sub(/watch\\?v=/, \"embed/\")}' \" +\n \"frameborder='0' allowfullscreen>\" +\n \"</iframe>\"\n else\n \"<a href='#{url}'>Resources ...</a>\"\n end\n end",
"def source_url\n \"https://www.facebook.com/facebook/videos/#{@element.embed_id}\"\n end",
"def youtube_tag(url, opts = {})\n # extract youtube thing\n m = url.match(/(?<=v=)[A-z0-9\\-]+/)\n youtube_id = m.present? ? m[0] : url\n embed_url = \"//www.youtube.com/embed/#{youtube_id}\"\n\n content_tag(:iframe, \"\", :src => embed_url,\n :frameborder => opts[:frameborder],\n :allowfullscreen => true,\n :width => opts[:width] || \"600\",\n :height => opts[:height] || \"480\"\n )\nend",
"def embed(youtube_url)\n youtube_id = youtube_url.split(\"=\").last\n content_tag(:iframe, nil, src: \"//www.youtube.com/embed/#{youtube_id}\")\n end",
"def video_url(source, options = T.unsafe(nil)); end",
"def create_video_object(obj)\n return content_tag(:div, content_tag(:iframe, \"\", :src => obj.link, :width => \"100%\"), :style => \"position:absolute; top: #{obj.y}px; left: #{obj.x}px;\")\n end",
"def get_video_embed_code(args = {})\n receive_video_id? args\n args = receive_should_validate? args\n\n get('redtube.Videos.getVideoEmbedCode', args,\n [:video_id], args[:should_validate])\n end",
"def oembed_url\n \"https://graph.facebook.com/v9.0/oembed_video?url=#{source_url}\" \\\n \"&access_token=#{access_token}\"\n end",
"def embed_code(url, options={})\n begin\n EmbedLinkFactory.get_embed_link(url).embed_code(options)\n rescue\n begin\n DefaultLink.new(url).embed_code(options)\n rescue\n url\n end\n end\n end",
"def iframe_wrap(src_url, options = {})\n buff = ActiveSupport::SafeBuffer.new\n height = options.delete(:height) || 600\n txt = content_tag :div, :class => \"iframe_wrap\" do\n buff.safe_concat %Q{\n <iframe width=\"100%\" height=\"#{height}\"\n src=\"#{src_url}\"\n frameborder=\"0\"\n allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen>\n </iframe>}\n buff\n end\n concat txt\n end",
"def get_vimeo_iframe boulder, width, height\n vimeo_id = find_vimeo_id boulder.link\n timestamp = \"#t=#{boulder.position_min}m#{boulder.position_sec}s\"\n\n result = %(<iframe src=\"https://player.vimeo.com/video/#{vimeo_id}#{timestamp}\" width=\"640\" height=\"360\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>)\n result.html_safe\n end",
"def video_source(str)\n if str.include? 'www.youtube.com'\n return youtube_embed(str)\n elsif str.include? 'youtu.be'\n return youtube_embed(str)\n else\n return nil\n end\n end",
"def iframe_content_return_url(url, width, height, title = nil)\n url = CGI::escape(url)\n width = CGI::escape(width.to_s)\n height = CGI::escape(height.to_s)\n\n return_url = \"#{content_return_url}?return_type=iframe&url=#{url}&width=#{width}&height=#{height}\"\n return_url = \"#{return_url}&title=#{CGI::escape(title)}\" if title\n\n return return_url\n end",
"def youtube_embed(youtube_url)\r\n\tif youtube_url[/youtu\\.be\\/([^\\?*)/]\r\n\t\tyoutube_id = $1\r\n\telse \r\n\t# Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367\r\n\t\tyoutube_url[/^.*((v\\/)|(embed\\/)|(watch\\?))\\??v?=?([^\\&\\?]*).*/]\r\n\t\tyoutube_id = $5 \r\n\tend\r\n\t#Look into a different method for this \r\n\t%Q{<iframe title=\"YouTube video player\" width=\"600px\" height=450px\" src=\"http://www.youtube.com/embed/#{ youtube_id }\" frameborder=\"0\" allowfullscreen></iframe>}\r\n end",
"def test_generate\n code1 = EmbedCode.generate( \"200px\", \"400px\", \"Yes\", \"\\#F00\", \"5px\", \"default\", 1, 1)\n assert_response :success\n assert_equal( code1, \"<iframe src=\\\"https://thinq.tv/embed\\\" title=\\\"ThinQ.tv: Join in with tech industry tips!\\\" height=200px width=400px style=\\\"position: default; border: 5px solid \\#F00;\\\"></iframe>\" )\n\n # Because \"position\" is default, generate should produce the same output regardless of location values.\n code2 = EmbedCode.generate( \"200px\", \"400px\", \"Yes\", \"\\#F00\", \"5px\", \"default\", -2, -2)\n assert_equal( code1, code2 )\n\n code2 = EmbedCode.generate( \"400px\", \"800px\", \"Yes\", \"\\#F00\", \"1px\", \"absolute\", 0, 1) \n assert_equal( code2, \"<iframe src=\\\"https://thinq.tv/embed\\\" title=\\\"ThinQ.tv: Join in with tech industry tips!\\\" height=400px width=800px style=\\\"position: absolute; z-index:99; bottom: 0; right: 1; border: 1px solid \\#F00;\\\"></iframe>\" )\n\n code2 = EmbedCode.generate( \"400px\", \"800px\", \"no\", \"\\#F00\", \"1px\", \"absolute\", 0, 1) \n assert_equal( code2, \"<iframe src=\\\"https://thinq.tv/embed\\\" title=\\\"ThinQ.tv: Join in with tech industry tips!\\\" height=400px width=800px style=\\\"position: absolute; z-index:99; bottom: 0; right: 1;\\\"></iframe>\" )\n end",
"def youtube_embed(youtube_url)\n VideoPlayer::player(youtube_url,\"640\", \"390\", true)\n end",
"def youtube_embed(youtube_url)\n if youtube_url[/youtu\\.be\\/([^\\?]*)/]\n youtube_id = $1\n else\n # Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367\n youtube_url[/^.*((v\\/)|(embed\\/)|(watch\\?))\\??v?=?([^\\&\\?]*).*/]\n youtube_id = $5\n end\n %Q{<iframe title=\"YouTube video player\" width=\"640\" height=\"390\" src=\"http://www.youtube.com/embed/#{ youtube_id }\" frameborder=\"0\" allowfullscreen></iframe>}\n end",
"def youtube_embed(youtube_url)\n if youtube_url[/youtu\\.be\\/([^\\?]*)/]\n youtube_id = $1\n else\n # Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367\n youtube_url[/^.*((v\\/)|(embed\\/)|(watch\\?))\\??v?=?([^\\&\\?]*).*/]\n youtube_id = $5\n end\n %Q{<iframe title=\"YouTube video player\" width=\"640\" height=\"390\" src=\"http://www.youtube.com/embed/#{ youtube_id }\" frameborder=\"0\" allowfullscreen></iframe>}\n end",
"def embed_media( options = {} )\n width = options[:width] || 633\n height = options[:height] || 475\n\n if options[:link] && options[:uploaded_image_url]\n raise ArgumentError, \"embed_media cannot have both \\\"link\\\" and\n \\\"uploaded_image_url\\\" arguments\"\n end\n\n if options[:link]\n return embed_video(link: options[:link], \n width: width, \n height: height,\n class: options[:class])\n\n elsif options[:uploaded_image_url]\n return \"<img src=\\\"#{options[:uploaded_image_url]}\\\" class=\\\"#{options[:class]}\\\">\".html_safe\n\n elsif !options[:uploaded_image_url] && !options[:link]\n return broken_image_tag(height, width, options[:class])\n end\n\n end",
"def youtube_embed(youtube_url)\n\t # Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367\n\t youtube_url.to_s[/^.*((v\\/)|(embed\\/)|(watch\\?))\\??v?=?([^\\&\\?]*).*/]\n\t youtube_id = $5\n\t youtube_id\n\tend",
"def url_to_video(source, options = T.unsafe(nil)); end",
"def youtube_embed(youtube_url)\n if youtube_url[/youtu\\.be\\/([^\\?]*)/]\n youtube_id = $1\n else\n # Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367\n youtube_url[/^.*((v\\/)|(embed\\/)|(watch\\?))\\??v?=?([^\\&\\?]*).*/]\n youtube_id = $5\n end\n\n %Q{<iframe id=\"player\" type=\"text/html\" width=\"640\" height=\"390\"\n src=\"//www.youtube.com/embed/#{youtube_id}?enablejsapi=1&origin=*\" frameborder=\"0\"></iframe>}\n end",
"def markdown_extention_youtube_links(html)\n html = html.gsub /<a\\shref=\"http:\\/\\/www\\.youtube\\.com\\/watch\\?v=(.*).*\".*>.*<\\/a>/o, \n \"<p><iframe class=\\\"youtube-player\\\" src=\\\"http://www.youtube.com/embed/\\\\1\\\"></iframe></p>\"\n return html\n end",
"def get_youtube_iframe boulder, width, height\n youtube_id = find_youtube_id boulder.link\n seconds = ((boulder.position_min.to_i*60)+ boulder.position_sec.to_i).to_s\n timestamp = \"?start=#{seconds}\"\n #timestamp = \"t=#{boulder.position_min}m#{boulder.position_sec}s\"\n result = %(<iframe title=\"YouTube video player\" width=\"#{width}\"\n height=\"#{height}\" src=\"//www.youtube.com/embed/#{youtube_id}#{timestamp}\"\n frameborder=\"0\" allowfullscreen></iframe>)\n result.html_safe\n end",
"def embed_link\n return nil if self.youtube_link.nil?\n\n id_regex = /(?:http:\\/\\/)?(?:www\\.)?(?:youtube\\.com|youtu\\.be)\\/(?:watch\\?v=)?(.+)/\n youtube_id = self.youtube_link.match(id_regex)\n return nil if youtube_id.nil?\n\n return YOUTUBE_EMBED_PREFIX + youtube_id[1] + \"?rel=0\"\n end",
"def embed width, height\n string = <<EOF\n<object type=\"application/x-shockwave-flash\" width=#{width} height=#{height} data=\"http://www.vimeo.com/moogaloop.swf?clip_id=#{@id}&server=www.vimeo.com&fullscreen=0&show_title=0'&show_byline=0&showportrait=0&color=00ADEF\">\n<param name=\"quality\" value=\"best\" />\n<param name=\"allowfullscreen\" value=\"false\" />\n<param name=\"scale\" value=\"showAll\" />\n<param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=#{@id}&server=www.vimeo.com&fullscreen=0&show_title=0&show_byline=0&showportrait=0&color=00ADEF\" /></object>\nEOF\n string.gsub(\"\\n\", \"\")\n end",
"def iframe(options = {})\n concat(content_tag(:iframe, class: options[:class], src: options[:src], width: options[:width], height: options[:height]) do\n end).html_safe\n end",
"def swf_embed(id, url, width, height, bgcolor, click_tag, alt = '')\n url = h(url)\n click_tag = h(click_tag)\n\n result = <<HTML\n <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"#{width}\" height=\"#{height}\" id=\"#{id}\">\n <param name=\"movie\" value=\"#{url}\" />\n <param name=\"bgcolor\" value=\"#{bgcolor}\" />\n <param name=\"wmode\" value=\"opaque\" />\n <param name=\"allowfullscreen\" value=\"false\" />\n <param name=\"allowscriptaccess\" value=\"never\" />\n <param name=\"quality\" value=\"autohigh\" />\n <param name=\"flashvars\" value=\"clickTAG=#{click_tag}\" />\n\n <!--[if !IE]>-->\n <object type=\"application/x-shockwave-flash\" data=\"#{url}\" width=\"#{width}\" height=\"#{height}\">\n <param name=\"bgcolor\" value=\"#{bgcolor}\" />\n <param name=\"wmode\" value=\"opaque\" />\n <param name=\"allowfullscreen\" value=\"false\" />\n <param name=\"allowscriptaccess\" value=\"never\" />\n <param name=\"quality\" value=\"autohigh\" />\n <param name=\"flashvars\" value=\"clickTAG=#{click_tag}\" />\n <!--<![endif]-->\n\n #{alt}\n\n <!--[if !IE]>-->\n </object>\n <!--<![endif]-->\n </object>\n <script type=\"text/javascript\">\n try { swfobject.registerObject(\"#{id}\", \"9.0.0\"); } catch(e) {}\n\t\t </script>\nHTML\n result.html_safe\n end",
"def youtube( video_id, size = [425,350] )\n\tif @conf.mobile_agent? or feed? then\n\t\t%Q|<div class=\"youtube\"><a href=\"http://www.youtube.com/watch?v=#{video_id}\">YouTube (#{video_id})</a></div>|\n\telsif defined?( :smartphone? ) and @conf.smartphone?\n\t\tsize = [240, 194]\n\t\t<<-TAG\n\t\t<iframe class=\"youtube-player\" type=\"text/html\" width=\"#{size[0]}\" height=\"#{size[1]}\" src=\"http://www.youtube.com/embed/#{video_id}\" frameborder=\"0\">\n\t\t</iframe>\n\t\t<div class=\"youtube\"><a href=\"http://www.youtube.com/watch?v=#{video_id}\">YouTube (#{video_id})</a></div>\n\t\tTAG\n\telse\n\t\t<<-TAG\n\t\t<iframe class=\"youtube-player\" type=\"text/html\" width=\"#{size[0]}\" height=\"#{size[1]}\" src=\"http://www.youtube.com/embed/#{video_id}\" frameborder=\"0\">\n\t\t</iframe>\n\t\tTAG\n\tend\nend",
"def fetch_video\n \t @video=UnvlogIt.new(url)\n \t self.embed_url=@video.embed_html(300, 169)\n \t self.thumb_url=@video.thumbnail\n end",
"def support_embed_content!\n self.content_intended_use = 'embed'\n self.content_return_types = 'oembed,lti_launch_url,url,image_url,iframe'\n end",
"def video_link\n if video_type? && !body.nil?\n vimeo_video(body) || youtube_video(body)\n end\n end",
"def embed_link\n self.embed = detect_host\n end",
"def embed(path,width=\"400\",height=\"250\")\n width = width.to_i-10\n height= height.to_i-40\n \"<OBJECT CLASSID=\\\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\\\" \n \t\t\t width=\\\"#{width}\\\" CODEBASE=\\\"http://www.apple.com/qtactivex/qtplugin.cab\\\" \n \t\t\t height=\\\"#{height}\\\">\n \t\t\t <PARAM name=\\\"SRC\\\" value=\\\"#{path}\\\">\n \t\t\t <PARAM name=\\\"CONTROLLER\\\" value=\\\"true\\\">\n \t\t\t <PARAM name=\\\"scale\\\" value=\\\"Aspect\\\">\n \t\t\t <PARAM name=\\\"AUTOPLAY\\\" value=\\\"true\\\">\n \t\t\t <PARAM name=\\\"border\\\" value=\\\"1\\\">\n \t\t\t <PARAM name=\\\"target\\\" value=\\\"webbrowser\\\">\n \t\t\t <PARAM name=\\\"href\\\">\n \t\t\t <EMBED src=\\\"#{path}?filename=#{filename}\\\" border=\\\"0\\\" \n \t\t\t width=\\\"#{width}\\\" autoplay=\\\"true\\\" scale=\\\"Aspect\\\" \n \t\t\t pluginspage=\\\"http://www.apple.com/quicktime/download/\\\" \n \t\t\t height=\\\"#{height}\\\" target=\\\"webbrowser\\\" \n \t\t\t controller=\\\"true\\\" bgcolor=\\\"FFFFCC\\\">\n \t\t\t </EMBED>\n \t\t\t </OBJECT>\"\n end",
"def oembed_url\n 'https://www.slideshare.net/api/oembed/2?format=json&url='\\\n \"#{source_url}\"\n end",
"def iframe\r\n return '' if @page.if_url.blank?\r\n\r\n html = \"\\n<iframe\"\r\n html << \" id=\\\"#{@page.if_id}\\\"\" if @page.if_id.present?\r\n html << \" class=\\\"#{@page.if_class}\\\"\" if @page.if_class.present?\r\n html << \" border=\\\"#{@page.if_border}\\\"\" \r\n html << \" height=\\\"#{@page.if_height}\\\"\" if @page.if_height.present?\r\n html << \" width=\\\"#{@page.if_width}\\\"\" if @page.if_width.blank?\r\n html << \" scrolling=\\\"#{@page.if_scroll}\\\"\"\r\n # Parameters\r\n parameters = @page.if_url.match(/\\?/) ? '' : '?' \r\n params = YAML.load(@page.if_params) rescue {}\r\n params = {} unless params.class == Hash\r\n params.each do |key, value|\r\n val = @parent.dc_internal_var(value['object'], value['method'])\r\n parameters << \"&#{key}=#{val}\" if val # only when not nil\r\n end\r\n url = @page.if_url + (parameters.blank? ? '' : parameters)\r\n html << \"src=\\\"#{url}\\\" ></iframe>\\n\"\r\n html\r\nend",
"def create\n @embedded_attachment = EmbeddedAttachment.new(embedded_attachment_params)\n\n respond_to do |format|\n if @embedded_attachment.save\n @url = @embedded_attachment.embed_code\n format.html { redirect_to @embedded_attachment, notice: 'Video was successfully created.' }\n format.js\n else\n format.html { render :new }\n format.json { render json: @embedded_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def iframe\n end",
"def video_url_regexp\n /\\Ahttps?:\\/\\/www\\.youtube\\.com|\\Ahttps?:\\/\\/youtu\\.be|www\\.youtube.com\\/embed|\\Ahttps?:\\/\\/vimeo\\.com|player\\.vimeo\\.com\\/video/\n end",
"def youtube_embed(youtube_url)\n if youtube_url[/youtu\\.be\\/([^\\?]*)/]\n youtube_id = $1\n else\n # Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367\n youtube_url[/^.*((v\\/)|(embed\\/)|(watch\\?))\\??v?=?([^\\&\\?]*).*/]\n youtube_id = $5\n end\n end",
"def youtube_video(url)\n render :partial => 'shared/video', :locals => { :url => url }\n end",
"def embedding_tweet(content)\n embedded_content = content\n content.scan(/(https?:\\/\\/twitter\\.com\\/[a-zA-Z0-9_]+\\/status\\/([0-9]+)\\/?)/).each do |url, id|\n tweet_json = open(\"https://api.twitter.com/1/statuses/oembed.json?id=#{id}\").read\n tweet_html = JSON.parse(tweet_json, { :symbolize_names => true })[:html]\n embedded_content = embedded_content.gsub(/#{url}/, tweet_html)\n end\n embedded_content\nend",
"def embedding_tweet(content)\n embedded_content = content\n content.scan(/(https?:\\/\\/twitter\\.com\\/[a-zA-Z0-9_]+\\/status\\/([0-9]+)\\/?)/).each do |url, id|\n tweet_json = open(\"https://api.twitter.com/1/statuses/oembed.json?id=#{id}\").read\n tweet_html = JSON.parse(tweet_json, { :symbolize_names => true })[:html]\n embedded_content = embedded_content.gsub(/#{url}/, tweet_html)\n end\n embedded_content\nend",
"def test_youtube_different_formats\r\n result = `ruby bin/viddl-rb http://www.youtube.com/watch?v=Zj3tYO9co44 --url-only --quality 640:360:mp4`\r\n assert_equal $?, 0\r\n can_download_test(result)\r\n assert result.include?(\"itag=18\")\r\n\r\n result2 = `ruby bin/viddl-rb http://www.youtube.com/watch?v=Zj3tYO9co44 --url-only --quality *:720:*`\r\n assert_equal $?, 0\r\n can_download_test(result2)\r\n assert result2.include?(\"itag=22\")\r\n end",
"def render_video_csid options={}\n # render video player\n content_tag(:div) do\n options[:value].collect do |video_csid|\n content_tag(:video,\n content_tag(:source, \"I'm sorry; your browser doesn't support HTML5 video in MP4 with H.264.\",\n src: \"https://webapps.cspace.berkeley.edu/#TENANT#/imageserver/blobs/#{video_csid}/content\",\n id: 'video_csid',\n type: 'video/mp4'),\n controls: 'controls',\n style: 'width: 640px;')\n end.join.html_safe\n end\n end",
"def embed_code(options={})\n \"<img src=\\\"#{@url}\\\" width=\\\"#{embed_width}\\\"/>\"\n end",
"def extract_vimeo_source(vimeo_embed_code)\n vimeo_embed_code.match(/src=\\\"(.*?)\\\"/)[1].to_s\n end",
"def youtube_embed(video_id)\n return content_tag(:div, class: %w(row)) do\n content_tag(:div, class: %w(col-md-6 col-sm-8 offset-md-3 offset-sm-2)) do\n content_tag(:div, class: %w(embed-responsive embed-responsive-4by3)) do\n content_tag(:iframe, nil, width: \"420\", height: \"315\", src: \"https://www.youtube.com/embed/#{video_id}\", frameborder: 0, allowfullscreen: true)\n end\n end\n end\n end",
"def define_youtube_player_tag(c,data)\n c.define_tag 'player' do |tag|\n width=(tag.attr['width']||(data[:video].width.to_i > 0 ? data[:video].width.to_i : nil)||400).to_i\n height=(tag.attr['height']||(data[:video].height.to_i > 0 ? data[:video].height.to_i : nil)||300).to_i\n color=tag.attr['bg'] || \"#FFFFFF\"\n if !editor?\n if data[:video].thumbnail_file_id && !tag.attr['no_thumb']\n thumbnail_file = DomainFile.find_by_id(data[:video].thumbnail_file_id)\n img_src = \"<a href='javascript:void(0);' onclick='writeVideoPlayer#{paragraph.id}();'><img src='#{thumbnail_file.url}' width='#{width}' height='#{height}'/></a>\"\n autoplay='1'\n else\n autoplay='0'\n end\n autoplay='1' if data[:video].autoplay\n \n <<-PLAYER_CODE\n <div id='video_player_#{paragraph.id}' style='width:#{width}px;height:#{height}px;'>#{img_src}</div>\n <script type=\"text/javascript\">\n function writeVideoPlayer#{paragraph.id}() {\n swfobject.embedSWF(\"http#{\"s\" if request.ssl?}://www.youtube.com/v/#{data[:video].video_id}&rel=0&autoplay=#{autoplay}\",\"video_player_#{paragraph.id}\",\"#{width}\",\"#{height}\",\"8\",\"\",\n { playerMode: \"embedded\" },\n { wmode: \"transparent\", bgcolor: \"#{color}\" });\n }\n #{\"writeVideoPlayer#{paragraph.id}();\" if tag.attr['no_thumb'] || !thumbnail_file}\n </script>\n PLAYER_CODE\n else\n \"<div id='video_player_#{paragraph.id}' style='width:#{width}px;height:#{height}px;'></div>\"\n end\n end \n end",
"def parse_lj_embed_tags(html, entry)\n # raise EntryWithoutAccountException if entry.account.blank?\n # raise EntryWithoutBlogEntryException if entry.blogentry.blank?\n return '' if html.blank?\n tag_regex =/(<lj-embed\\ {1,}id\\ {0,1}=\\ {0,}[\\\"\\'](.+?)[\\\"\\']\\ {0,}?[\\/]?>)/ism\n html.scan(tag_regex).each do |x|\n id = x[1]\n url = \"#{entry.account.url}#{entry.blogentry.filename}\" rescue '#'\n str = \"This post contains embedded media, click here to view.\".t\n html.gsub!(x[0], \"<a href=\\\"#{url}\\\">#{str}</a>\")\n end\n html\n end",
"def vimeo_video_id\n self.vid = link.split('/').last\n end",
"def to_embed(url)\n %Q[<script src=\"#{url}.js\"></script>]\n end",
"def audio_embed_code_css\n # note that we're allowing for the nested \"responsive\" divs here, enabling embed code consistency even though...\n # they serve no purpose for the audio player\n <<~END\n #fulcrum-embed-outer-#{id} {\n }\n #fulcrum-embed-inner-#{id} {\n }\n iframe#fulcrum-embed-iframe-#{id} {\n page-break-inside:avoid;\n -webkit-column-break-inside:avoid;\n break-inside:avoid;\n display:block;\n overflow:hidden;\n border-width:0;\n width:98%;\n max-width:98%;\n height:#{audio_embed_height}px;\n margin:auto;\n }\n END\n end",
"def iframes=(x); @iframes = x; end",
"def check_embedding!\n if embedded?\n response.headers.except! 'X-Frame-Options'\n end\n end",
"def get_datas\n tnurl=\"/images/no-image.jpg\"\n if self.source_url.match(/(youtube.com*)/)\n vid=self.source_url.match(/=([A-Za-z0-9]*)/) ? self.source_url.match(/=([A-Za-z0-9\\d_\\-]*)/)[0].gsub(/=/,'') : self.source_url\n unless vid.blank?\n \n client=YouTubeIt::Client.new(:dev_key => YOUTUBE_API_KEY)\n \n \n begin\n youtube_data=client.video_by(vid)\n rescue\n youtube_data=nil\n self.errors.add(:source_url, \"Invalid video url, removed from youtube\")\n self.source_url=nil\n end \n \n \n unless youtube_data.nil? \n self.title= self.title.blank? ? youtube_data.title : self.title\n self.description= self.description.blank? ? youtube_data.description : self.description\n tnurl=youtube_data.thumbnails[0].url\n self.media_content_url=youtube_data.media_content[0].url\n end\n end\n self.provider=\"youtube\"\n elsif self.source_url.match(/(vimeo.com*)/)\n tnurl='/images/video/vimeo.png' \n vid=self.source_url.match(/vimeo.com\\/([^&]+)/)[1]\n unless vid.blank?\n vimeo_data=Vimeo::Simple::Video.info(vid)\n if vimeo_data && vimeo_data.size>0\n tnurl=vimeo_data[0][\"thumbnail_medium\"]\n self.title= self.title.blank? ? vimeo_data[0][\"title\"] : self.title\n self.description= self.description.blank? ? vimeo_data[0][\"description\"] : self.description\n end\n end\n\n #self.media_content_url=\"/videos/#{self.id}\"\n\n\n self.media_content_url=\"http://www.vimeo.com/moogaloop.swf?clip_id=#{vid}&server=www.vimeo.com&fullscreen=1&show_title=1&show_byline=1&show_portrait=0&color=\"\n self.provider=\"vimeo\"\n elsif self.source_url.match(/(dailymotion.com*)/)\n self.provider=\"dailymotion\" \n tnurl='/images/video/dailymotion.png' \n elsif self.source_url.match(/(myspace.com*)/)\n self.provider=\"myspace\" \n tnurl='/images/video/myspace.png' \n end\n\n self.thumbnail_url=tnurl\n\n\n end",
"def cdn_video_tag(url, opts = {})\n if opts[:size]\n width, height = opts[:size].split('x')\n else\n width, height = opts[:width], opts[:height]\n end\n\n return video_tag(url, opts) # if Rails.env.development?\n\n # url = \"http:#{url}\" if url.present? && url[0..1] == \"//\"\n # cloudfront backed vide\n # video_tag(\"http://d2xfsikitl0nz3.cloudfront.net/#{CGI.escape(url)}\", opts)\n end",
"def youtube_code\n code = self.link.match(/v=(.*)/)\n code.captures.first\n end",
"def vimeo_tag vimeo_data, **args\n if vimeo_data.is_a?(Hash) && vimeo_data[:sources].present?\n tag.iframe class: args[:class], data: { src: vimeo_data[:embed_url] }, width: '100%', height: '100%', frameborder: '0', allow: 'autoplay; fullscreen', webkitallowfullscreen: true, mozallowfullscreen: true, allowfullscreen: true\n elsif supports_afterglow_player?(vimeo_data)\n klass = args[:class].is_a?(Array) ? args[:class] : [args[:class]]\n klass << 'afterglow'\n klass << 'afterglow--ios' if browser.platform.ios?\n\n skin = args[:skin] == :light ? 'light' : 'dark'\n source = tag.source type: 'video/mp4', src: vimeo_data[:download_url]\n content_tag :video, {\n class: klass,\n width: vimeo_data[:width],\n height: vimeo_data[:height],\n poster: vimeo_data[:thumbnail],\n data: { skin: skin },\n } do\n vimeo_data[:sources].each do |source|\n next if source[:quality] == 'hls'\n\n concat tag.source({\n type: source[:type],\n src: source[:link],\n data: { quality: ('hd' if source[:quality] != 'sd') },\n })\n end\n end\n else\n # Fallback to a simple vimeo iframe, if the afterglow player is not supported.\n url = \"https://player.vimeo.com/video/#{vimeo_data}\"\n tag.iframe class: klass, data: { src: url }, width: '100%', height: '100%', frameborder: '0', allow: 'autoplay; fullscreen', webkitallowfullscreen: true, mozallowfullscreen: true, allowfullscreen: true\n end\n end",
"def set_VideoEmbeddable(value)\n set_input(\"VideoEmbeddable\", value)\n end",
"def fileset_embed_markup(file_name)\n fileset = fileset(file_name)\n #emb_markup = fileset[\"embed_code\"] unless fileset[\"noid\"].empty?\n noid = fileset[\"noid\"]\n embed_markup = \"\"\n unless noid.empty?\n # Found fileset. Determine the embed link from the\n # \"Embed Code\" property. This will give the correct host.\n # If fileset has no property, then it can't be embedded.\n external_res = fileset['external_resource_url']\n fmarkup = fileset['embed_code']\n unless fmarkup.nil? or fmarkup.empty?\n if external_res.nil? or external_res.strip.empty?\n embed_doc = Nokogiri::XML::DocumentFragment.parse(fmarkup)\n iframe_node = embed_doc.xpath(\"descendant-or-self::*[local-name()='iframe']\").first\n embed_link = iframe_node['src']\n ititle = iframe_node['title']\n title = HTMLEntities.new.encode(ititle)\n\n href = fileset['link'][12..-3]\n #title = fileset['title'].nil? ? \"\" : fileset['title']\n\n link_uri = URI(embed_link)\n link_scheme_host = link_uri.scheme + \"://\" + link_uri.host\n\n embed_markup = sprintf(RESOURCE_EMBED_MARKUP, link_scheme_host, noid, noid, noid, noid, embed_link, title)\n else\n embed_markup = fmarkup\n end\n end\n end\n return embed_markup\n end",
"def show\n\n\n @video = Video.find(params[:id])\n \n @vid = params[:id]\n #@video = Video.where(:id=>@vid, :is_active=>'1').take\n #@video = Video.where(\"id = ? AND is_active = ?\", @vid, 1)\n \n @video_id = (/([\\w-]{11})/.match(@video.video_link)).to_s\n @embed_code = %Q{<iframe title=\"YouTube video player\" style=\" margin-top: 24px;\" width=\"640\" height=\"390\" src=\"http://www.youtube.com/embed/#{ @video_id}\" frameborder=\"0\" allowfullscreen></iframe>}\n \n \n @commentable = @video\n @comments = @commentable.comments\n @comment = Comment.new\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @video }\n end\n end",
"def embed_screen(params = {})\n @iframe_src = screen_uri(params)\n render \"iframe\"\n end",
"def video_url\n \"http://video.ted.com/#{videoID}\"\n end",
"def iframe(criteria = T.unsafe(nil)); end",
"def oembed_options\n { :maxwidth => \"560\", :maxheight => \"315\" }.merge(options[:oembed]||{})\n end",
"def valid_videos\n self.videos.select{ |video|\n video.exist? && video.embed? && video.auto_play?\n }\n end",
"def parse_video_url(url)\n url_video = case url.downcase\n when /^http:\\/\\/(www\\.)?youtube\\.com/\n parse_youtube(url)\n # when /tudou/\n # parse_tudou(url)\n when /^http:\\/\\/(www\\.)?dailymotion\\.com/\n parse_dailymotion(url)\n # when /metacafe/\n # parse_metacafe(url)\n else\n url\n end\n url_video\n end",
"def addWebCam()\n pathToWebcam = \"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/video/webcams.webm\"\n pathToIntermediates= \"#{$PATHTOGENERATEINTERMEDIATES}/#{@meetingData.meetingId}\"\n\n # resize the webcam video\n puts \" Resizing webcam recording \"\n system \"ffmpeg -i #{pathToWebcam} -vcodec libx264 -vf scale=200:-1 #{pathToIntermediates}/webcamResized.mp4 -loglevel quiet\"\n \n # create a directory to store the final video(inside the published)\n pathToCompleteRecording=\"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/completeVideo\"\n createDirectoryIfNotExists(pathToCompleteRecording)\n\n puts \"Adding webcam into final video\"\n #merge it with the presentation+deskshare video\n system \"ffmpeg -i #{pathToIntermediates}/output.mp4 -i #{pathToIntermediates}/webcamResized.mp4 -filter_complex \\' overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10 \\' #{pathToCompleteRecording}/finalcut.mp4 -loglevel quiet\"\n end",
"def embed_code_css\n if video? || image? || interactive_map?\n responsive_embed_code_css\n elsif audio?\n audio_embed_code_css\n end\n end",
"def sanitize_video_url\n if self.video_url\n self.video_url = self.video_url.split('/').last \n if self.video_url.include? \"watch?v=\"\n self.video_url = self.video_url.split('=').last\n end\n end\n end",
"def responsive_embed_code_css\n <<~END\n #fulcrum-embed-outer-#{id} {\n width:auto;\n page-break-inside:avoid;\n -webkit-column-break-inside:avoid;\n break-inside:avoid;\n max-width:#{embed_width}px;\n margin:auto;\n background-color:#000;\n }\n #fulcrum-embed-inner-#{id} {\n overflow:hidden;\n padding-bottom:#{padding_bottom}%;\n position:relative; height:0;\n }\n iframe#fulcrum-embed-iframe-#{id} {\n overflow:hidden;\n border-width:0;\n left:0; top:0;\n width:100%;\n height:100%;\n position:absolute;\n }\n END\n end",
"def streaming_video_url\n # TODO figure out how to remove the need for this stupid hack\n # paperclip adds the cache buster to the URL automatically, I need\n # it to go away, probably a really easy paperclip option, but not\n # finding it at the moment.\n unless streaming_video.nil?\n streaming_video.data.url.split(\"?\")[0]\n else\n nil\n end\n end",
"def youtube_id\n rexp = /v=(.*)/ or /embed\\/(.*)/\n rexp.match(url).captures.first\n end"
] |
[
"0.7036487",
"0.68915516",
"0.6817374",
"0.6730852",
"0.67027116",
"0.66616917",
"0.664561",
"0.6611145",
"0.66080594",
"0.65695906",
"0.6552747",
"0.65445626",
"0.64981824",
"0.6455144",
"0.6370712",
"0.6362068",
"0.6353784",
"0.63133764",
"0.6311673",
"0.6299641",
"0.6298825",
"0.6284353",
"0.6274026",
"0.6253676",
"0.62470824",
"0.6213656",
"0.6193683",
"0.618726",
"0.61703515",
"0.61620563",
"0.6150798",
"0.61251825",
"0.61104774",
"0.6104833",
"0.6091572",
"0.60871816",
"0.60833746",
"0.60765785",
"0.6053219",
"0.6052441",
"0.6018192",
"0.6008458",
"0.5999363",
"0.5999363",
"0.599029",
"0.5977209",
"0.5961799",
"0.59551424",
"0.59404886",
"0.5903128",
"0.59009916",
"0.58902913",
"0.5885759",
"0.5884769",
"0.5870792",
"0.5865369",
"0.5843544",
"0.5824791",
"0.5822151",
"0.58216864",
"0.5763201",
"0.5755503",
"0.5753018",
"0.57440907",
"0.57343876",
"0.57240015",
"0.570134",
"0.56975937",
"0.56975937",
"0.5693902",
"0.5677065",
"0.5661646",
"0.5661044",
"0.5656556",
"0.5623202",
"0.56193024",
"0.5611686",
"0.56042093",
"0.55804783",
"0.5577795",
"0.5577623",
"0.5572383",
"0.5531101",
"0.5514515",
"0.5511645",
"0.5505119",
"0.55033106",
"0.5501583",
"0.5498256",
"0.54947186",
"0.54931647",
"0.5481865",
"0.546937",
"0.54680246",
"0.5459384",
"0.54584295",
"0.5457152",
"0.54556197",
"0.5445876",
"0.5426229"
] |
0.691994
|
1
|
Define a single reference into _pool_ from _data_ beginning at _start_
|
def initialize(pool, data, start, name=nil)
super(name)
@tag = data.u1(start)
@enclosing_pool = pool
@first_index = data.u2(start+1)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pool; end",
"def pool; end",
"def initialize(pool, data, start, name=nil)\r\n super(pool, data, start, name)\r\n @size = 5\r\n\r\n @second_index = data.u2(start+3)\r\n end",
"def pool\n @pool.dup\n end",
"def pool \n @pool\n end",
"def redis_pool=(_arg0); end",
"def pool\n @pool\n end",
"def pool(node)\n MUTEX.synchronize do\n pools[node.address.resolved] ||=\n Pool.new(node.address.ip, node.address.port, node.options)\n end\n end",
"def pool(node)\n MUTEX.synchronize do\n pools[node.address.resolved] ||= create_pool(node)\n end\n end",
"def pool=(new_value)\n @pool = new_value\n @pool << self if @pool\n end",
"def work_pool; end",
"def initialize(data, start, constant_pool)\r\n creator = AttributesCreator.new(data, start, constant_pool)\r\n creator.create!\r\n @attributes = creator.attributes\r\n @size = creator.size\r\n end",
"def start\n raise \"Already started.\" if @pool and !@pool.empty?\n \n @pool = Array.new(@args[:threads]) do |i|\n Thread.new do\n begin\n Thread.current[:tpool] = {:i => i}\n \n loop do\n block = @queue.pop\n Thread.current[:tpool][:block] = block\n \n block.run\n Thread.current[:tpool].delete(:block)\n end\n rescue Exception => e\n $stderr.puts e.inspect\n $stderr.puts e.backtrace\n end\n end\n end\n end",
"def pool\n @pool ||= Pool.new(SequenceServer.config[:num_threads])\n end",
"def clone_pool\n super\n end",
"def avail\n updatePool\n @pool\n end",
"def reload!\n LOG.debug \"Attempting to reload #{self}.\"\n @lock.synchronize do\n expected = @pool_initializer.call \n actual = @pool\n # remove old destinations\n (actual - expected).each{|d| @pool.delete(d) }\n # append new ones \n @pool += (expected - actual)\n end\n LOG.debug \"Successfully to reloaded #{self}.\"\n end",
"def fill! num=@pool-@count\n raise CreatorError, NO_CONSTRUCTOR_MSG if @create.nil?\n \n return 0 if full?\n num = @pool-num.abs if num < 0\n return 0 if num <= 0\n \n objs = num.times.map(&@create.method(:call))\n expr_addition = objs.zip([Time.now]*num)\n \n threadsafe do\n @expr_hash.merge(expr_addition)\n @stack.push *objs\n @count += num\n end\n \n start_purging!\n\t\t\n\t\tnum\n\tend",
"def _pool\n @pool._dump\n end",
"def set_pool\n @pool = Pool.find(params[:id])\n end",
"def set_pool\n @pool = Pool.find(params[:id])\n end",
"def set_pool\n @pool = Pool.find(params[:id])\n end",
"def start\n service.pool_action uuid, :create\n end",
"def snat_pool\n super\n end",
"def return_pool(**name_args, &block) # yields:\n @object_pool.put(self, **name_args, &block)\n nil\n end",
"def across_pool_state\n super\n end",
"def initialize(data, start, constant_pool)\r\n count = data.u2(start)\r\n @size = 2\r\n\r\n (1..count).each do |i|\r\n # TODO Implement parsing of fields into Field class\r\n\r\n # access_flags = data.u2(start + @size) # later ... FieldAccessFlag.new(data, start + @size)\r\n # @size += 2\r\n # name_index = data.u2(start + @size) # later ... get from ConstantPool\r\n # @size += 2\r\n # descriptor_index = data.u2(start + @size) # later ... get from ConstantPool\r\n # @size += 2\r\n @size += 6\r\n\r\n attributes = Attributes::Attributes.new(data, start + @size, constant_pool)\r\n @size += attributes.size\r\n end\r\n end",
"def add_to_pool\n return if closed? || outdated?\n conn_id = [@address, @port, @use_ssl,\n proxy_address, proxy_port, proxy_user]\n\n POOL_MUTEX[conn_id].synchronize do\n CONN_POOL[conn_id] << self\n end\n end",
"def load_vm_pool\n @log.debug(\"Loading vm pool from id: #{start_vm_id}.\")\n from = @start_vm_id\n how_many = @batch_size\n to = from + how_many - 1\n\n # if in compatibility mode, whole virtual machine pool has to be loaded for the first time\n if @compatibility\n unless @compatibility_vm_pool\n vm_pool = OpenNebula::VirtualMachinePool.new(@client)\n rc = vm_pool.info(OpenNebula::Pool::INFO_ALL, -1, -1, OpenNebula::VirtualMachinePool::INFO_ALL_VM)\n check_retval(rc, Errors::ResourceRetrievalError)\n @compatibility_vm_pool = vm_pool.to_a\n end\n\n pool = @compatibility_vm_pool[from..to] || []\n @start_vm_id = pool.last.id + 1 unless pool.empty?\n\n return pool\n else\n vm_pool = OpenNebula::VirtualMachinePool.new(@client)\n rc = vm_pool.info(OpenNebula::Pool::INFO_ALL, from, -how_many, OpenNebula::VirtualMachinePool::INFO_ALL_VM)\n check_retval(rc, Errors::ResourceRetrievalError)\n\n @start_vm_id = vm_pool.entries.last.id + 1 unless vm_pool.count == 0\n\n return vm_pool\n end\n end",
"def create_pool(node)\n ConnectionPool.new(\n size: node.options[:pool_size] || POOL_SIZE,\n timeout: node.options[:pool_timeout] || TIMEOUT\n ) do\n Connection.new(\n node.address.ip,\n node.address.port,\n node.options[:timeout] || Connection::TIMEOUT,\n node.options\n )\n end\n end",
"def pool\n pool_connection = ConnectionPool.new(size: 10, timeout: 5) do \n Redis.new :db=> redis_db_index, :password=> redis_instance.password, :host=> redis_instance.host, :port=> redis_instance.port\n end \n return pool_connection \n end",
"def initialize(network_range)\n @network_range = network_range\n generate_pool\n end",
"def fresh_start\n @start_time = nil\n @time_now = nil\n @last_meets_process_time = nil\n @meet_pool = MeetPool.new\n @pooled_mposts = Hash.new\n end",
"def pooling(oaf_data_ref, instances)\n\t\t\t\t\t\tobj_states = oaf_data_ref[:object_states].deep_dup\n\t\t\t\t\t\t#STDERR.puts __LINE__\n\t\t\t\t\t\t#STDERR.puts oaf_data_ref[:class_list]\n\t\t\t\t\t\tfor instance in instances do\n\t\t\t\t\t\t\tlikelihood = instance[:class_likelihood]\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tlog_error \"different length of class_likelihood and class_list\" unless likelihood.size == oaf_data_ref[:class_list].size\n\t\t\t\t\t\t\tprob_diff = instance[:action][:grabbed].to_f - instance[:action][:released].to_f\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor i in 0...likelihood.size do\n\t\t\t\t\t\t\t\tclass_id = oaf_data_ref[:class_list][i]\n\t\t\t\t\t\t\t\tl = likelihood[i]\n\t\t\t\t\t\t\t\tprob_in_hand = obj_states[class_id]\n\t\t\t\t\t\t\t\tSTDERR.puts __LINE__\n\t\t\t\t\t\t\t\tSTDERR.puts class_id\n\t\t\t\t\t\t\t\tSTDERR.puts l\n\t\t\t\t\t\t\t\tSTDERR.puts prob_diff\n\t\t\t\t\t\t\t\tSTDERR.puts prob_in_hand\n\t\t\t\t\t\t\t\t# P(prob_in_hand^t_c)=P(c|blob)P(prob_in_hand^{t-1}_blob)\n\t\t\t\t\t\t\t\t# YOU NEED TO DESIGN AN APPROPRIATE POOLING FUNCTION!!!\n\t\t\t\t\t\t\t\tobj_states[class_id] = prob_in_hand + (l*prob_diff)\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tSTDERR.puts obj_states\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\t\t# prob_in_hand must be in [0,1]\n\t\t\t\t\t\tfor id, prob in obj_states do\n\t\t\t\t\t\t\tobj_states[id] = [[1,prob].min,0].max\n\t\t\t\t\t\tend\t\t\t\t\t\n\n\t\t\t\t\t\treturn obj_states\n\t\t\t\tend",
"def redis_pool; end",
"def worker_pool; end",
"def worker_pool; end",
"def pools\n @pools ||= {}\n end",
"def pools\n @pools ||= {}\n end",
"def pool(create_if_missing=false)\n result = Jetpants.topology.pool(collins_pool || self)\n if !result\n if master\n result = master.pool(create_if_missing)\n elsif create_if_missing\n result = Pool.new('anon_pool_' + ip.tr('.', ''), self)\n def result.sync_configuration; end\n end\n end\n result\n end",
"def worker_pool_size=(_arg0); end",
"def bound_data(data, initial)\n data\n end",
"def set_pooling\n @pooling = Pooling.find(params[:id])\n end",
"def pool_capacity; end",
"def alloc_temp\n if @temp_deallocated.any?\n addr = @temp_deallocated.first\n @temp_deallocated.shift\n else\n addr = @temp_counter\n @temp_counter += 1\n end\n entry = Entry.new is_temp: true\n entry.set_addr addr\n @temp_memory[addr - Limits::TEMP_START_ADDR] = entry\n entry\n end",
"def get\n if @pool.empty?\n b = @klass.new(*@args)\n b.instance_exec(self) { |origin| @_origin = origin }\n b\n else\n @pool.pop\n end\n end",
"def request!\n PoolNode.create_or_get(@id, node)\n end",
"def from_data(data)\n id = allocate\n id.send(:data=, data)\n id\n end",
"def start(max = 8)\n max.times do\n @pool << @wire.connection\n end\n @log.debug(\"PostgreSQL pool started with #{max} connections\")\n self\n end",
"def initialize(interval, pool)\n @interval = interval\n @pool = pool\n end",
"def initialize(size = 2)\n raise ArgumentError if size < 1\n @pool = size\n end",
"def public_ipv_4_pool\n data[:public_ipv_4_pool]\n end",
"def initialize_pools(members)\n members.each do |member|\n @hosts << member.host_string\n\n if member.primary?\n @primary = member.host_port\n @primary_pool = Pool.new(self.connection, member.host, member.port,\n :size => self.connection.pool_size,\n :timeout => self.connection.connect_timeout,\n :node => member)\n elsif member.secondary? && !@secondaries.include?(member.host_port)\n @secondaries << member.host_port\n @secondary_pools << Pool.new(self.connection, member.host, member.port,\n :size => self.connection.pool_size,\n :timeout => self.connection.connect_timeout,\n :node => member)\n end\n end\n\n @max_bson_size = members.first.config['maxBsonObjectSize'] ||\n Mongo::DEFAULT_MAX_BSON_SIZE\n @arbiters = members.first.arbiters\n choose_read_pool\n end",
"def free\n @pool.shutdown(&:free)\n end",
"def mkpool(digits, stops)\n ((\"0\"*digits)..(\"9\"*digits)).inject([]) do |ary,e|\n ary << PoolStr.new(\"#{e}#{stops[rand(stops.length)] if stops}\", nil)\n end\nend",
"def setup\n return unless connection_pool_enabled?\n\n @connection_pool = ::Queue.new\n\n start_pool_size.times { @connection_pool.push(new_client) }\n\n @created_connections = start_pool_size\n end",
"def pre_cycle\n copy_value_fetch_from_memory\n initialize_memory_instruction_registers\n move_instruction_pointer_to_a_next_address\n end",
"def mem=(p0) end",
"def test_nil_time\n fp = FakePool.new\n assert_not fp.reaped\n reaper = ConnectionPool::Reaper.new(fp, nil)\n reaper.run\n assert_not fp.reaped\n ensure\n fp.discard!\n end",
"def last_hop_pool\n super\n end",
"def set_entries\n @pool = Pool.find(params[:pool_id])\n end",
"def choose_read_pool\n if @secondary_pools.empty?\n @read_pool = @primary_pool\n elsif @secondary_pools.size == 1\n @read_pool = @secondary_pools[0]\n else\n ping_ranges = Array.new(3) { |i| Array.new }\n @secondary_pools.each do |pool|\n case pool.ping_time\n when 0..150\n ping_ranges[0] << pool\n when 150..1000\n ping_ranges[1] << pool\n else\n ping_ranges[2] << pool\n end\n end\n\n for list in ping_ranges do\n break if !list.empty?\n end\n\n @read_pool = list[rand(list.length)]\n end\n end",
"def borrow_object\n @mutex.synchronize {\n if !@idle_list.empty?\n result = @idle_list.shift\n \n elsif @active_list.size < @config.max_active\n result = create_with_timestamp\n \n elsif @active_list.size >= @config.max_active\n raise CommonPoolError, \"Max number of %d active objects reached.\" % @config.max_active\n \n else\n begin\n timeout(@config.timeout){ @cond.wait(@mutex) }\n rescue TimeoutError\n raise TimeoutError, \"#{@config.timeout} seconds request timeout reached.\"\n end\n result = @idle_list.shift\n end\n @active_list.store(result[1].__id__, result)\n \n logger.debug(\"* Get #{result[1]}\") if logger\n result[1]\n }\n end",
"def preconnect(concurrent = nil)\n hold{}\n end",
"def connection\n #@pool ||= {}\n #@pool[Thread.current] ||= Mongoc::Client.new(host, port, :pool_size=>@pool_size)\n #Mongoc::Client.new(host, port, {})\n Thread.current[:_mongo] ||= Mongoc::Client.new(host, port, {})\n end",
"def acquire(*a)\n conn = nil\n\n 1.times do\n if (conn = super) &&\n (timer = sync{@connection_timestamps.delete(conn)}) &&\n Sequel.elapsed_seconds_since(timer) > @connection_validation_timeout &&\n !db.valid_connection?(conn)\n\n case pool_type\n when :sharded_threaded, :sharded_timed_queue\n sync{@allocated[a.last].delete(Sequel.current)}\n else\n sync{@allocated.delete(Sequel.current)}\n end\n\n disconnect_connection(conn)\n redo\n end\n end\n\n conn\n end",
"def populate(instance)\n instance.proxy_for = resource.proxy_for\n instance.proxy_in = resource.proxy_in\n instance.next_uri = resource.next\n instance.prev_uri = resource.prev\n end",
"def request_static\n # reserve\n return AddressPool.create_or_get(self.network, subnet: self.subnet, iprange: self.iprange)\n end",
"def pool_options(options); end",
"def start\n Thread.new(interval, pool) do |i, p|\n while (true)\n sleep(i)\n p.reap\n end\n end\n end",
"def add_work(&bl)\n pool.post &bl\n end",
"def start!\n @time = now\n @cpu_time_start = now_cpu\n @allocation_count_start = now_allocations\n end",
"def assign_start_list\n @start_list = nil\n end",
"def initialize_threadpool\n EM.threadpool_size = @poolsize\n end",
"def initialize(db, opts = OPTS)\n super\n @max_size = Integer(opts[:max_connections] || 4)\n raise(Sequel::Error, ':max_connections must be positive') if @max_size < 1\n @mutex = Mutex.new \n # Size inside array so this still works while the pool is frozen.\n @size = [0]\n @allocated = {}\n @allocated.compare_by_identity\n @timeout = Float(opts[:pool_timeout] || 5)\n @queue = Queue.new\n end",
"def with &block\n @redis ||= ConnectionPool.new(POOL_CONF){ new_redis }\n @redis.with &block\n end",
"def prepareForReuse; end",
"def book_execution(fill)\n# allocate(fill)\n end",
"def create_pools\n @old_store = store.dup\n pools.map do |key, value|\n # convert the requests to vm names\n pools[key]['requests'] = value['requests'].find_all do |req|\n puts \"Checking request: #{req}\"\n r = req_obj(req)\n if r.completed?\n puts \"The request #{req} has completed, getting hostname\"\n hostnames = resolve_vm_name(r)\n # remove request from pool file by not returning anything\n # if hostname does not exist but request completed don't update pool\n if ! hostnames\n puts \"Provisioning seemed to have failed for #{req}\"\n puts \"Removing request #{req} from pool #{key}\"\n false\n else\n pools[key]['pool_instances'] = value['pool_instances'] + hostnames\n false\n end\n else \n # has not completed\n # keep the request, since it is not finished\n puts \"The request #{req} is still running\"\n req\n end\n end\n\n # return the alive instances and save to the pool\n pools[key]['pool_instances'] = pools[key]['pool_instances'].find_all {|h| is_alive?(h) }\n\n # delete any old instances from used pool\n pools[key]['used_instances'] = pools[key]['used_instances'].find_all {|h| is_alive?(h) }\n\n # create the pool, and save the request in the requests\n # do not create if the number of systems and requests are more than the requested amount\n current_total = value['pool_instances'].count + pools[key]['requests'].count\n unless current_total >= value['size']\n reqs = create_pool(value)\n pools[key]['requests'] = reqs\n end\n end\n # prevents updates from occuring when they are not required\n store.save if store_changed?(@old_store, store)\nend",
"def initialize(data=nil)\n @first = QueueNode.new data unless data.nil?\n @first ||= nil\n @last = @first\n end",
"def create_single_node_pool\n host = @hosts\n if host.is_a?(Array)\n if host.length > 1\n raise ArgumentError, \"Can only create single node pool for single host\"\n end\n\n # Flatten the configured host so that we can easily add it to the\n # client pool.\n host = host.first\n end\n\n @pool.add_node!(host, [(0..Configuration::HASH_SLOTS)])\n\n unless @logger.nil?\n @logger.info(\"redis_cluster: Initialized single node pool: #{host}\")\n end\n end",
"def create_single_node_pool\n host = @hosts\n if host.is_a?(Array)\n if host.length > 1\n raise ArgumentError, \"Can only create single node pool for single host\"\n end\n\n # Flatten the configured host so that we can easily add it to the\n # client pool.\n host = host.first\n end\n\n @pool.add_node!(host, [(0..Configuration::HASH_SLOTS)])\n\n unless @logger.nil?\n @logger.info(\"redis_cluster: Initialized single node pool: #{host}\")\n end\n end",
"def initialize(options = {}, &data_source_block)\n @threads = []\n @wrapper_template = {}\n @current_upstream = {}\n @send_queue = Queue.new\n @sockets = Hamster::Set.new\n @broadcast_worker_delay = (options[:broadcast_worker_delay] ||\n options[:websocket_worker_delay] ||\n DEFAULT_DELAY)\n @read_worker_delay = (options[:read_worker_delay] ||\n options[:incoming_monitor_delay] ||\n DEFAULT_DELAY)\n @no_wrap = options[:no_wrap] || false\n @running = false\n @data_source_block = data_source_block\n start unless options[:start] == false\n end",
"def connection_pool_ramp_increment\n super\n end",
"def pool\n @pool=@vserver_hash.properties.basic.pool\n end",
"def refinit\n return if defined?(@_references)\n\n @_references = 1\n @_references_mutex = Mutex.new\n\n self\n end",
"def recycle()\n @@pool_mutex.synchronize do\n if (@@pool_size < MAX_POOL_SIZE)\n clear_for_recycle()\n @next = @@pool;\n @@pool = this\n @@message_pool_size += 1\n end\n end\n end",
"def initialize\n @start = nil\n end",
"def pool(session)\n read_task('rvpe.host.pool', session) do\n call_one_xmlrpc('one.hostpool.info', session)\n end\n end",
"def before_fork\n return unless (defined? ::DataObjects::Pooling)\n return if ::DataMapper.repository.adapter.to_s =~ /Sqlite3Adapter/\n ::DataMapper.logger.debug \"+-+-+-+-+ Cleaning up connection pool (#{::DataObjects::Pooling.pools.length}) +-+-+-+-+\"\n ::DataObjects::Pooling.pools.each {|p| p.dispose} \n end",
"def data() @data ||= Data.new( self ); end",
"def reap!\n HotTub.logger.info \"[HotTub] Reaping pool #{@name}!\" if HotTub.log_trace?\n while !@shutdown\n reaped = nil\n @mutex.synchronize do\n begin\n if _reap?\n if _dead_clients?\n reaped = @_out.select { |clnt, thrd| !thrd.alive? }.keys\n @_out.delete_if { |k,v| reaped.include? k }\n else\n reaped = [@_pool.shift]\n end\n else\n reaped = nil\n end\n ensure\n @cond.signal\n end\n end\n if reaped\n reaped.each do |clnt|\n close_client(clnt)\n end\n else\n break\n end\n end\n nil\n end",
"def run\n super\n r = Rex::Socket::RangeWalker.new @object.range\n r.each do|address|\n create_object(Host, {:ip_address => address})\n end\nend",
"def create_item\n object = @spawn_object.call\n\n object.pool_create if object.respond_to? :pool_create\n\n item = PoolItem.new(object)\n\n @item_stack.push(item)\n\n item\n end",
"def allocate_handles()\n #This is a stub, used for indexing\n end",
"def initialize(pool=nil, &block)\n if pool\n raise ArgumentError if !pool.respond_to?(:roll)\n end\n @pool = pool\n @possibilities = []\n @die_sides = nil\n @static_modifier = 0\n @roll_modifier = 0\n @result_set = false\n instance_eval(&block)\n unless @result_set\n set_result(:sum)\n end\n end",
"def pool\n unless @pool\n self.pool_size ||=2\n threads = [self.pool_size, 2, Concurrent.processor_count].max\n @pool = Concurrent::ThreadPoolExecutor.new(\n min_threads: 2,\n max_threads: threads,\n max_queue: 10*threads,\n fallback_policy: :caller_runs\n )\n end\n @pool\n end",
"def initialize\n @head = nil\n end",
"def set_pool \n @pool = Pool.find(params[:id])\n unless @logged_in.update_site?\n @pool.readonly!\n end\n end",
"def build\n service.pool_action uuid, :build\n end"
] |
[
"0.65071964",
"0.65071964",
"0.63829106",
"0.63288057",
"0.6131492",
"0.6096813",
"0.59680426",
"0.5910591",
"0.58648056",
"0.58329535",
"0.57922256",
"0.5724876",
"0.56921107",
"0.5683031",
"0.56414473",
"0.5563892",
"0.5551784",
"0.5540265",
"0.55348533",
"0.5520624",
"0.5520624",
"0.5520624",
"0.54716796",
"0.5469208",
"0.54573023",
"0.54414696",
"0.5410804",
"0.54054326",
"0.5392034",
"0.53395337",
"0.53048635",
"0.5247415",
"0.52410656",
"0.52245516",
"0.52185464",
"0.5212912",
"0.5212912",
"0.51882935",
"0.51882935",
"0.5158421",
"0.51381",
"0.51322126",
"0.51140124",
"0.5101642",
"0.50902486",
"0.50807655",
"0.50754005",
"0.50633377",
"0.5040864",
"0.5040607",
"0.5038262",
"0.5037008",
"0.5030035",
"0.50299525",
"0.50140184",
"0.49962902",
"0.49808508",
"0.49732947",
"0.49642006",
"0.49606922",
"0.49585766",
"0.4957709",
"0.49362478",
"0.4928976",
"0.4917804",
"0.49125525",
"0.49054924",
"0.49003822",
"0.4887157",
"0.48858374",
"0.48759598",
"0.48697492",
"0.48688877",
"0.48683032",
"0.48563763",
"0.48500425",
"0.48310578",
"0.48265612",
"0.4816342",
"0.48159665",
"0.48132247",
"0.48132247",
"0.48130602",
"0.4798136",
"0.47980937",
"0.4789244",
"0.47864217",
"0.4784951",
"0.47815472",
"0.47809705",
"0.47713503",
"0.47641742",
"0.47504982",
"0.47484955",
"0.4740251",
"0.47399157",
"0.47340405",
"0.47239763",
"0.47193485",
"0.47143978"
] |
0.71042734
|
0
|
Return the value, which is the referenced value from the pool.
|
def first_value
get(@first_index)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get(ref)\r\n @enclosing_pool[ref].to_s\r\n end",
"def value\n mutex.lock\n execute_task_once\n apply_deref_options(@value)\n ensure\n mutex.unlock\n end",
"def [](key)\n @lock.synchronize do\n ref = @references[key]\n value = ref.object if ref\n value\n end\n end",
"def fetch\n @value\n end",
"def get\n @mutex.synchronize { @value }\n end",
"def value\n @value ||= @block.call\n end",
"def value(block_num = nil)\n \tv, _ = value_with_addr(block_num)\n \tv\n end",
"def weak_ref_value(o)\n if o && o.weakref_alive?\n o\n end\n end",
"def value\n # double-checked locking is safe because we only update once\n return @value if @fulfilled\n\n @mutex.synchronize do\n unless @fulfilled\n begin\n @value = @task.call\n rescue\n @value = @default\n ensure\n @fulfilled = true\n end\n end\n return @value\n end\n end",
"def value\n fetch(0, 0)\n end",
"def value\n return @value unless @value.nil?\n return nil if skip?\n set(resolve)\n @value\n end",
"def instance\n local.value\n end",
"def value\n return @updater.call(*@sources.map { |var| var.value }) if @updater\n return @value if @value\n raise \"No value or updating block set\"\n end",
"def value()\n \t\t@stack.last\n end",
"def pool \n @pool\n end",
"def orchestrate_ref_value\n __ref_value__\n end",
"def orchestrate_ref_value\n __ref_value__\n end",
"def pool\n @pool.dup\n end",
"def fetch\n @fetched_value\n end",
"def get\n val = @source.get\n return nil if val.nil?\n processed_val = process(val)\n if processed_val.nil?\n get\n else\n return processed_val\n end\n\n end",
"def value\n return @val\n end",
"def get\n @cached_value ||= RedisModel::Base.connection.get(key_label)\n end",
"def value\n if @value\n @value\n else\n @value = resolve( :value )\n end\n end",
"def fetch_value(key)\n val = fetch_nested(key)\n return val if self[:no_pruning].include?(key)\n Prunable::VALUES.include?(val) ? Prunable::Value : val\n end",
"def lookup_uncached(val); end",
"def lookup_uncached(val); end",
"def value(timeout = nil)\n return @result if @result\n \n poll_for_result\n \n if notify && pool # listen for task completion notification if the task is set up to do that\n listen_for_result_notification(timeout)\n elsif result_uri.nil? # wait for a result if we don't already have one\n wait_for_result(timeout)\n end\n \n @result\n end",
"def get\n if @pool.empty?\n b = @klass.new(*@args)\n b.instance_exec(self) { |origin| @_origin = origin }\n b\n else\n @pool.pop\n end\n end",
"def value\n Gitlab::Redis::SharedState.with do |redis|\n (redis.get(key) || 0).to_i\n end\n end",
"def get(key)\n if @map.include?(key)\n node = @map[key]\n update_node!(node)\n update_map!(key)\n else\n eject! if count >= @max\n val = calc!(key)\n add_node(key, val)\n update_map!(key)\n end\n\n # Return the value (value of key run through proc)\n val\n end",
"def pool\n @pool\n end",
"def value\n @value ||= extract_value\n end",
"def value\n @value || __eval\n end",
"def value\n @lock.synchronize do\n\n while ! @ready do\n @cond.wait @lock\n end\n\n raise @exception if @exception\n\n @value\n end\n end",
"def get\n @value\n end",
"def value\n \t@calc_stack[-1]\n end",
"def get_value (key)\r\n @redis.get key\r\n end",
"def return_pool(**name_args, &block) # yields:\n @object_pool.put(self, **name_args, &block)\n nil\n end",
"def value\n Reac.value(self)\n end",
"def resolve(fetcher)\n @lock.synchronize do\n unless @seen\n @value = @block.call(fetcher.call)\n @seen = true\n end\n\n @value\n end\n end",
"def value\n v = connection.get(key)\n rescue Memcached::NotFound\n if block\n value = block.call\n value\n end\n end",
"def value\n data[ address ]\n end",
"def pool=(new_value)\n @pool = new_value\n @pool << self if @pool\n end",
"def result\n if not_already_loaded? && any_to_load?\n lazy_results.merge!(block_results)\n lazy_values.clear\n end\n lazy_results[value]\n end",
"def get(key)\n @semaphore.synchronize do\n return @hashed_storage[key]&.value\n end\n end",
"def raw_value\n @raw_value ||= @@ts.take([self.object_id, nil])[1]\n end",
"def value\n return @value if defined? @value\n\n result = @future_result.result\n @value = if @block\n @block.call(result)\n else\n result\n end\n end",
"def get\n val\n end",
"def get\n val\n end",
"def get_value\n if linked?\n return @link.to.get_value\n end\n return false\n end",
"def rule_get_value(ref)\n if val = rule_table.get_value(self, setup_package_id(ref))\n return val\n else\n (raise UnboundError.new(ref))\n end\n end",
"def get_value(env, ref)\n unless ref.package_id\n raise ArgumentError.new(\"package id is invalid: %s\" % ref.inspect)\n end\n\n # when it is known reference\n if expr = @table[ref.package_id][ref.name]\n return expr\n end\n\n if bound?(ref.package_id, ref.name)\n # get value from parent table\n return @parent.get_value(env, ref) if @parent\n else\n # otherwise, find by parent package id\n env.find_ancestor_ids(ref.package_id).each do |ancestor_id|\n if val = get_value(env, ref.set(package_id: ancestor_id))\n return val\n end\n end\n end\n\n return nil\n end",
"def value\n return @value\n end",
"def value\n return @value\n end",
"def value\n return @value\n end",
"def value\n self\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n return @value if done?\n raise LightIO::Error, 'already used' if @light_fiber\n @light_fiber = LightFiber.current\n @ioloop.transfer\n @value\n end",
"def value\n\t\t@operands[-1]\n\tend",
"def value\n\t\traise @exception if exception?\n\n\t\treturn @value if delivered?\n\n\t\tmutex.synchronize {\n\t\t\tcond.wait(mutex)\n\t\t}\n\n\t\tif exception?\n\t\t\traise @exception\n\t\telse\n\t\t\t@value\n\t\tend\n\tend",
"def get_value\n @value\n end",
"def pop\n if @data == nil\n return @data\n else\n get_value = @data.value\n @data = @data.next_node #give me the value stored in next node\n return get_value #give me the value stored in variable\n end\n end",
"def getvalue\n @variable.get_value @name\n end",
"def value(); self.data.value; end",
"def value(key)\n return @memoized[key] if @memoized.include?(key)\n\n @memoized[key] = if respond_to?(key)\n value = __send__(key)\n\n if parts?(key)\n parts_for(key)\n else\n value\n end\n else\n @object[key]\n end\n end",
"def current_value\n @value\n end",
"def fetch_value(value); end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bound? ? state.symbol : @value\n end",
"def value\n variable.value\n end",
"def value\n val = @thread.value\n unset_thread_task\n val\n end",
"def pop\n # I RETURN A VALUE\n if @data != nil\n value = @data.value\n @data = @data.next_node\n return value\n end\n end",
"def value\n @base_object\n end",
"def value\n @base_object\n end",
"def get_value\n @value \n end",
"def ref_node(this_db = self.started_db)\n return Thread.current[:local_ref_node] if Thread.current[:local_ref_node]\n default_ref_node(this_db)\n end",
"def value\n bindings[:object].send(name)\n end",
"def value\n bindings[:object].send(name)\n end",
"def borrow_object\n @mutex.synchronize {\n if !@idle_list.empty?\n result = @idle_list.shift\n \n elsif @active_list.size < @config.max_active\n result = create_with_timestamp\n \n elsif @active_list.size >= @config.max_active\n raise CommonPoolError, \"Max number of %d active objects reached.\" % @config.max_active\n \n else\n begin\n timeout(@config.timeout){ @cond.wait(@mutex) }\n rescue TimeoutError\n raise TimeoutError, \"#{@config.timeout} seconds request timeout reached.\"\n end\n result = @idle_list.shift\n end\n @active_list.store(result[1].__id__, result)\n \n logger.debug(\"* Get #{result[1]}\") if logger\n result[1]\n }\n end",
"def get(key)\n v = Nvmkv::kv_get(@kv_id, @pool_id, key)\n return (v != nil ? NVMKVValue.new(v) : nil)\n end",
"def memo\n derived_values.last\n end",
"def assignment_value\n return @assignment_value\n end",
"def value_cache\n C.value_cache\n end",
"def [](key)\n @lock.synchronize do\n rkey = ref_key(key)\n @values[rkey] if rkey\n end\n end",
"def deref\n @used_references += 1\n end",
"def get_value name\n get name\n end",
"def op_fetch(puid = nil)\n push vm.fetch(puid || pop)\n end",
"def get_variable\n var = @variable\n # workaround: check weakref_alive?, because weakref sometimes delegates references by GC\n return var.__getobj__ if !var.nil? && var.weakref_alive?\n\n var = Chainer::Variable.new(@data, name: @name, requires_grad: @requires_grad)\n var.node = self\n var\n end",
"def value()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.RunMetadataVariable_value(@handle.ptr)\n result\n end",
"def get_value name=nil\n @value\n end",
"def get_value\n now = Time.now\n if now > (@last_retrieved_ts + @interval)\n begin\n @retrievals += 1\n @value = self.retrieve\n @last_retrieved_ts = now\n rescue Exception => e\n puts \"Error in #{self.name}#retrieve : #{e.inspect}\"\n ErrorHandler.report_error(e)\n @value = -1\n end\n end\n return @value\n end",
"def top()\n return @head ? @head.val : nil\n end",
"def value\r\n @value\r\n end",
"def value (timeout = nil)\n\t\t@mutex.synchronize {\n\t\t\tif @old\n\t\t\t\tcond.wait(@mutex, *timeout)\n\t\t\tend\n\n\t\t\t@old = true\n\n\t\t\tif @exception\n\t\t\t\traise @exception\n\t\t\telse\n\t\t\t\t@value\n\t\t\tend\n\t\t}\n\tend",
"def get(ref)\n @map[ref]\n end",
"def return_value\n @return_value.object\n end",
"def prim_val\n self[self.class.primary_key]\n end"
] |
[
"0.7010257",
"0.66636807",
"0.6399516",
"0.6394772",
"0.63068724",
"0.6253776",
"0.6170082",
"0.6144192",
"0.6141153",
"0.6129286",
"0.6048917",
"0.6029394",
"0.59468925",
"0.5945332",
"0.59435093",
"0.593604",
"0.593604",
"0.5894637",
"0.58885837",
"0.5872364",
"0.58580196",
"0.58166873",
"0.58154935",
"0.5806659",
"0.5795565",
"0.5795565",
"0.57939446",
"0.5787203",
"0.57820725",
"0.5761317",
"0.5752941",
"0.573375",
"0.5723284",
"0.5714415",
"0.57075334",
"0.57043886",
"0.5695393",
"0.5690023",
"0.56870854",
"0.5684937",
"0.5682336",
"0.56711334",
"0.56648695",
"0.5632241",
"0.56259197",
"0.5623654",
"0.5616318",
"0.55926466",
"0.55926466",
"0.5588038",
"0.5587826",
"0.5582214",
"0.55686635",
"0.55686635",
"0.55686635",
"0.5566409",
"0.5559689",
"0.5559689",
"0.5557935",
"0.5534434",
"0.552992",
"0.55190784",
"0.55121857",
"0.5509585",
"0.5501877",
"0.5500922",
"0.54974425",
"0.5481737",
"0.54755676",
"0.54755676",
"0.54755676",
"0.54755676",
"0.54745334",
"0.5468718",
"0.5467296",
"0.5465939",
"0.5462253",
"0.5462253",
"0.54562515",
"0.5454339",
"0.54460263",
"0.54460263",
"0.54458773",
"0.5445038",
"0.5442184",
"0.5440991",
"0.54356694",
"0.5434684",
"0.5431428",
"0.5427099",
"0.5423126",
"0.5417197",
"0.5415589",
"0.54137415",
"0.54069483",
"0.54016244",
"0.5386796",
"0.5382715",
"0.5379563",
"0.5377177",
"0.5366238"
] |
0.0
|
-1
|
Return part of debug output.
|
def dump
super + "##{@first_index};\t// #{to_s}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_debug_string\n s = \"3D Camera: [ #{@x.round(2)}, #{@y.round(2)}, #{@z.round(2)} ]\\n\"\n s += \" T[ #{@tx.round(2)}, #{@ty.round(2)}, #{@tz.round(2)} ]\\n\"\n s += \"Fov: #{@fov.round(2)} View: #{@near.round(2)} -> #{@far.round(2)}\\n\\t\"\n s += \"Gosu::Window FPS (#{Gosu.fps})\\n\\t\"\n s += \"Map Objects: (#{$program.active_state.map_objects.size})\"\n return s\n end",
"def build_debug_msg\n message = []\n stds = { @stdout => \"Standard output: \", @stderr => \"Standard error: \" }\n stds.each do |std, name|\n message << tabify(name) << tabify(std) unless std.blank?\n end\n message.join(\"\\n\")\n # Return nil if empty\n end",
"def get_debug_string\n string = \"Object(#{@obj_filename})\\nfaces(#{@face_count}) texture:\\n \\\"#{@texture_file}\\\"\"\n return string\n end",
"def debug_msg( str )\n puts str if @debug == true\n end",
"def debug1(text) debug text, 1 end",
"def debug(text)\n\t\t\tputs text\n\t\t\tnil\n\t\tend",
"def debug(message)\n puts \"#{Time.now.strftime(\"%H:%M:%S.%L\")} - \\t#{message}\" if DEBUG\nend",
"def debug_out()\n return JSON.pretty_generate(self).gsub(\"\\\": \", \"\\\" => \").gsub(\" => null\", \" => nil\")\n end",
"def debug string\n puts string if $DEBUG\nend",
"def debug(s) if $DEBUG then $stderr.print(\"#{s}\\n\") end end",
"def detail\n \"#{line}\\n#{' ' * line_offset}^\"\n end",
"def debug_string\n str = \"\"\n klass.fields.each do |f|\n if f.is_padding?\n str << \"#{f.name}: \\n\"\n else\n str << \"#{f.name}: #{send(f.name.to_sym)}\\n\"\n end\n end\n\n str\n end",
"def debug_msg msg\n puts msg if @options[:debug]\n end",
"def debug(s)\n\t#puts \"DEBUG: #{s}\"\nend",
"def output_debug(string)\n if Command.ui\n Command.ui.debug string\n else\n $stderr.puts \"DEBUG: #{string}\"\n end\n end",
"def debug\n \"origin: #{@unit_origin} | value: #{@value} | destiny: #{@unit_destiny}\"\n end",
"def debug(info)\n puts(info) if @debug\n end",
"def debug_output=(arg); end",
"def debug; end",
"def debug; end",
"def debug; end",
"def debug; end",
"def debug_str(inspect_method = :inspect)\n \"Current Date: #{self.input_date.readable}\\nCurrent Time: #{self.input_time.readable}\\n\\nQuery: #{self.query}\\nStandardized Query: #{self.nlp_query}\\nQuery changed in: #{self.nlp_query.changed_in.inspect}\\n\\nConstructs Found: #{s = \"\\n\"; self.construct_finder.constructs.each{|x| s << x.send(inspect_method) + \"\\n\"}; s}\\n\\n@construct_interpreter: #{self.construct_interpreter.send(inspect_method)}\"\n end",
"def debug(stuff)\n puts \"DEBUG: #{stuff}\"\nend",
"def debug(depth = 0)\n if debug?\n debug_info = yield\n debug_info = debug_info.inspect unless debug_info.is_a?(String)\n debug_info = debug_info.split(\"\\n\").map { |s| \":#{depth.to_s.rjust 4}: #{s}\" }\n output.puts debug_info\n end\n end",
"def dprint(s)\n print s if $DEBUG\nend",
"def debug_print(output, debug)\n\tif debug\n\t\tputs \"[*] #{output}\".red\n\tend\nend",
"def debug_time\n t = Time.now\n return \" RUPI DEBUG \" + t.strftime(\"%H:%M:%S, %L -- : \").to_s\nend",
"def print_debug_info\n puts \"Programmer #{name}:\"\n puts \"\\tSpeed: #{speed}\"\n puts \"\\tDaily wage: #{daily_wage}\"\n puts \"\\tProject: #{project_name}\"\n end",
"def debug(msg)\n #puts msg\n end",
"def debug( msg )\n puts Time.now.strftime(\"- %I:%M%p: \") + msg if @debug\nend",
"def to_debug_s\n \"#{to_criteria_debug_s}\\n#{to_policy_debug_s}\\n(line #{line})\"\n end",
"def debug msg\n if debug?\n return debug_writer.write msg if debug_writer.respond_to? :write\n return debug_writer.call(msg) if debug_writer.respond_to? :call\n raise \"No debug_writer set!\"\n end\n end",
"def print\n return self.content if self.content.end_with?('?') || self.content.end_with?('!')\n return \"#{self.content}.\"\n end",
"def debug_print(returnedData, debug=\"false\")\n if debug == \"true\" then\n puts \"\\r\\n[DEBUG]\\r\\n\"\n pp(returnedData) \n end\nend",
"def debug(object)\n puts \"<pre>\"\n puts object.pretty_inspect.gsub('<', '<').gsub('>', '>')\n puts \"</pre>\"\nend",
"def debug?; end",
"def debug?; end",
"def debug(msg, &block)\n result = yield\n puts \"-- #{msg} #{'-' * (74 - msg.length)}\" if $debug\n result\n end",
"def debug(*info)\n puts(info) if debug_mode?\n end",
"def show\n \"\\t#{@line}: #{first_line}\"\n end",
"def dprint(str)\n if ANSIBLE_DEBUG\n print str\n end\nend",
"def debug(msg) log(DEBUG, \"DEBUG \" << format(msg) << \", \" << caller[0][caller[0].rindex(\"/\").nil? ? 0 : caller[0].rindex(\"/\") + 1 .. -1]); end",
"def debug(message)\n puts message if debug?\n end",
"def print_debug(s)\n config = BeEF::Core::Configuration.instance\n if config.get('beef.debug') || BeEF::Core::Console::CommandLine.parse[:verbose]\n puts Time.now.localtime.strftime(\"[%k:%M:%S]\")+'[>]'.yellow+' '+s.to_s\n end\nend",
"def log_debug(message)\n return message\n end",
"def dumpDebugState\n\t\tif(@hasMore)\n\t\t\tputs 'Has more solutions\\n'\n\t\telse\n\t\t\tputs 'No more solutions\\n'\n\t\tend\n\n\t\tputs \"availProofs #{@availProofs}\\n\"\n\t\tputs \"pengine #{@p.getID}\"\n\tend",
"def debug(current_resolver_depth)\n # debug info will be returned if you call yield here, but it seems to be\n # broken in current Molinillo\n nil\n end",
"def print_debug\n\t\tprint_divider\n\t\tputs \"Root Node: \\n\" + root.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Current Node: \\n\" + @current_node.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Attributes: \\n\" + attributes.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Children: \\n\" + children.to_xml\n\t\tprint_divider\n\tend",
"def debug message; write DEBUG, message, caller[0] unless level > @level end",
"def debug(str)\n $stderr.puts(str) if @debug\n end",
"def debug(str, ret = false)\r\n puts str if @debug\r\n return ret\r\n end",
"def out(msg)\n puts \"#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")} #{msg}\" if DEBUG_OUTPUT\nend",
"def puts_debug(msg)\r\n if (self.debug) \r\n puts msg\r\n end # end debug\r\n end",
"def puts_debug(msg)\r\n if (self.debug) \r\n puts msg\r\n end # end debug\r\n end",
"def debug(msg)\n return unless Fizzy::CFG.debug\n caller_info = caller\n .map { |c| c[/`.*'/][1..-2].split(\" \").first }\n .uniq[0..2]\n .join(\" → \")\n tell \"{m{⚫}}#{✏ caller_info, %w({b{<}} {b{>}})}{w{: #{msg}}}\"\n end",
"def debug( msg )\n puts Time.now.strftime(\"- %I:%M%p: \") + msg\nend",
"def debug_print(thing, title = nil, print_path = false)\n return if !%w[test development].include?(Rails.env)\n\n divider = \"#{\"-\" * 80}\"\n\n puts divider\n if title.present?\n puts %Q(#{title} (#{thing.class.name}))\n else\n puts thing.class.name\n end\n pp thing\n\n if print_path\n puts caller.first[0..caller.first.index(\":in\") - 1]\n end\n\n puts divider\n\n puts\n end",
"def print_debug_info\n puts \"Project #{name}:\"\n puts \"\\tState: #{state}\"\n puts \"\\tMan-days total: #{man_days}\"\n puts \"\\tMan-days done: #{man_days_done}\"\n puts \"\\tPrice: #{price}\"\n end",
"def debug_print(str)\n return unless Rails.env.development? && @debug\n str = str.inspect unless str.instance_of? String\n @debugscr.move(@cur_debug_line, 0)\n @debugscr.clrtoeol\n @debugscr.mvaddstr(@cur_debug_line, 0, str)\n @cur_debug_line = (@cur_debug_line + 1) % @lines\n @debugscr.refresh\n end",
"def set_debug_output(arg); end",
"def print_debug(msg)\n puts msg if (@debug) \n STDOUT.flush\n end",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def debug(message)\n $stderr.puts(message) if @options[:debug]\nend",
"def debug_msg(msg)\n if(@options[:debug])\n @log.puts(msg)\n puts msg\n end\nend",
"def log(s)\n puts \"[Debug]: #{s}\"\nend",
"def log(s)\n puts \"[Debug]: #{s}\"\nend",
"def debug(msg)\n STDERR.puts msg if @debug\n end",
"def output_debug(params)\n Rails.logger.debug(\"\\n\\n\\n\\n------------------------------------------------\\n\")\n Rails.logger.debug(params.inspect)\n Rails.logger.debug(\"\\n------------------------------------------------\\n\\n\\n\\n\")\n end",
"def inspect\n\t\treturn \"#<%p:%#016x formatter: %s, level: %s, output: %s, affecting %s log hosts>\" % [\n\t\t\tself.class,\n\t\t\tself.object_id * 2,\n\t\t\tself.settings[:formatter] || '-',\n\t\t\tself.settings[:level] || '-',\n\t\t\tself.settings[:logdev] ? self.settings[:logdev].class : '-',\n\t\t\tself.log_hosts ? self.log_hosts.length.to_s : \"all\",\n\t\t]\n\tend",
"def debug(*args); end",
"def debug(*args); end",
"def debug(*args); end",
"def debug!\n @client.debug_dev = STDOUT\n end",
"def print_out_line\n name = @run_name\n name += \" (res: #@restart_id)\" if @restart_id\n name += \" real_id: #@real_id\" if @real_id\n beginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s) %3s%1s\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, \"%\")\n if ctd\n #beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n end\n beginning += \" ---#{@comment}\" if @comment\n beginning\n end",
"def debug_message(string)\n caller_method = caller_locations(1..1).first.label\n $stdout.puts(Time.now.strftime('%Y-%m-%d %H:%M:%S: ').concat(\"#{caller_method}: \").concat(string))\nend",
"def debug(thing, tag = 'pre')\n %Q{<#{tag}>#{thing.to_yaml}</#{tag}>}\n end",
"def debug_output(x, y)\n\t\t\tputs \"left eye #{@left_eye_width}\"\n\t\t\tputs \"glabella #{@glabella_width}\"\n\t\t\tputs \"right eye #{@right_eye_width}\"\n\t\t\tputs \"mouth #{x}, #{y}\"\n\t\tend",
"def debug(msg)\n STDERR.puts msg if options.key? :debug\n end",
"def debug(msg) log(7, msg); end",
"def log str \n if $vips_debug\n puts str\n end\nend",
"def debug(msg, thread = nil)\n return nil unless $opt[:debug]\n function = (thread ? \"#{thread}.\" : '') + \\\n (caller[0][/`.*'/] ? caller[0][/`.*'/][1..-2].split(' ').last : 'core');\n puts \"#{function}#{(function.split(/\\.([^.]*)$/).last == 'core' ? '' : '()')}: #{msg}\".white\nend",
"def debug(text)\n puts \"#{text}\".foreground(:yellow)\n end",
"def debug(msg)\n end",
"def inspect\n \"\"\n end",
"def log\n @log_output.string\n end",
"def log_to_console\n location = @location[1..-1] # remove file_descriptor\n details = @details.first(2) # remove additional details\n [\n ' ',\n location.join(', ').ljust(33),\n details.join(': ')\n ].join\n end",
"def debug_message message\n if @quiet\n # noop\n \":\"\n else\n \">&2 echo #{DEBUG_HEADER} #{message}\"\n end\n end",
"def debug_final_report\n\t\t\tsuper\n\t\t\tif @debug_level > 0\n\t puts \"Lowest OLD: \\t#{@lowest_old[0].to_a}\"\n\t puts \"Angle: \\t\\t#{@get_angle.(@current_point, @start_vector)}\"\n\t\t\tend\n\t\tend",
"def debug_output str='abunai', level=1\n str = str.to_s\n str << ' | ' + `ps -o rss -p #{$$}`.strip.split.last.gsub(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/, \"\\\\1,\") + ' Kb'\n\n if @debug_output_level >= level\n puts \"[#{str}]\".black\n return true\n end\n return false\n end",
"def debug(message)\n ostream.puts message if $DEBUG\n end",
"def inspect\n \"#<#{self.class.name}:0x#{(self.__id__ * 2).to_s(16)} \" +\n \"@host=#{host.to_s}, \" +\n \"@log_level=#{log_level}, \" +\n \"@log_location=#{log_location.inspect}>\"\n end",
"def dump_compiled code\n\t\t\tbuf = do_compile code,false\n\t\t\tprint buf,\"\\n\"\n\t\tend",
"def debug\n @words.each_key do |ltr|\n printf \"%c: %5d\\n\", ltr.upcase, @words[ltr].length\n end\n end",
"def debug_final_report\n case\n when @debug_level > 0\n puts \"\\nSuccess at: \\t#{@current_point.to_a}\"\n ptus \"Cost: \\t\\t#{@current_cost}\"\n end\n end",
"def debug_msg(msg=\"\")\n if(@config.debug)\n puts(\"Debug: #{msg}\")\n @file.puts(\"Debug: #{msg}\")\n end\n end",
"def debug_str(pos = nil, row = 0, col = 0)\n if pos.nil?\n pos = @head_pos or @pos\n end\n\n t = ''\n if col >= 80\n t << @codes[(pos-80)..(pos+80)].pack(\"U*\")\n col = 81\n else\n t << line(pos)\n end\n\n if col and col >= 1\n col = col - 1;\n end\n t << \"\\n\"\n t << (' ' * col) + \"^\"\n t\n end",
"def inspect\n\t\treturn \"#<%p:%#016x formatter: %s, level: %s, output: %s>\" % [\n\t\t\tself.class,\n\t\t\tself.object_id * 2,\n\t\t\tself.settings[:formatter] || '-',\n\t\t\tself.settings[:level] || '-',\n\t\t\tself.settings[:logdev] ? self.settings[:logdev].class : '-',\n\t\t]\n\tend",
"def render\n if @location.line == @location.last_line || @location.is?(\"\\n\")\n [\"#{@location}: #{@level}: #{message}\"] + render_line(@location)\n else\n # multi-line diagnostic\n first_line = first_line_only(@location)\n last_line = last_line_only(@location)\n num_lines = (@location.last_line - @location.line) + 1\n buffer = @location.source_buffer\n\n last_lineno, last_column = buffer.decompose_position(@location.end_pos)\n [\"#{@location}-#{last_lineno}:#{last_column}: #{@level}: #{message}\"] +\n render_line(first_line, num_lines > 2, false) +\n render_line(last_line, false, true)\n end\n end"
] |
[
"0.69366837",
"0.69291043",
"0.69069993",
"0.6879002",
"0.6878159",
"0.6730113",
"0.67059743",
"0.66907835",
"0.66851145",
"0.66389287",
"0.6568203",
"0.65560573",
"0.65443265",
"0.6541664",
"0.65178704",
"0.6486761",
"0.6470802",
"0.6467053",
"0.6449916",
"0.6449916",
"0.6449916",
"0.6449916",
"0.64087766",
"0.6399644",
"0.6399275",
"0.6398292",
"0.6397797",
"0.6394759",
"0.6392988",
"0.63900995",
"0.6373447",
"0.6348038",
"0.63374895",
"0.6310612",
"0.6307782",
"0.6296781",
"0.6272725",
"0.6272725",
"0.626071",
"0.62600666",
"0.62557644",
"0.6244681",
"0.6239558",
"0.62389165",
"0.62377495",
"0.6234609",
"0.62103647",
"0.61863434",
"0.61772203",
"0.61719185",
"0.61716664",
"0.61613864",
"0.6157152",
"0.6154674",
"0.6154674",
"0.6137384",
"0.6099078",
"0.6092869",
"0.6086534",
"0.6080942",
"0.60726386",
"0.6064705",
"0.6062049",
"0.6062049",
"0.6062049",
"0.60607713",
"0.6054791",
"0.60506856",
"0.60506856",
"0.60489875",
"0.60476625",
"0.60423905",
"0.6040644",
"0.6040644",
"0.6040644",
"0.6035101",
"0.6032183",
"0.60239947",
"0.60186994",
"0.60041165",
"0.5996434",
"0.5995574",
"0.59940666",
"0.5993158",
"0.5992347",
"0.59662014",
"0.5958785",
"0.59520364",
"0.5941884",
"0.5938476",
"0.5937938",
"0.5930735",
"0.59267825",
"0.59184486",
"0.5916655",
"0.59140307",
"0.59139955",
"0.5913861",
"0.59008765",
"0.5894585",
"0.58906454"
] |
0.0
|
-1
|
Get a reference _ref_ from the +enclosing_pool+
|
def get(ref)
@enclosing_pool[ref].to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pool\n @pool.dup\n end",
"def weak_ref_value(o)\n if o && o.weakref_alive?\n o\n end\n end",
"def pool \n @pool\n end",
"def pool\n @pool\n end",
"def ref\n return self if @closed\n ::Libuv::Ext.ref(handle)\n self\n end",
"def rpc_get_ref(name)\n ::ApplicationRecord.connection_pool.with_connection {\n db_check\n self.framework.db.get_ref(name)\n }\n end",
"def get\n if @pool.empty?\n b = @klass.new(*@args)\n b.instance_exec(self) { |origin| @_origin = origin }\n b\n else\n @pool.pop\n end\n end",
"def ref\n @_references_mutex.synchronize {\n @_references += 1\n }\n\n self\n end",
"def return_pool(**name_args, &block) # yields:\n @object_pool.put(self, **name_args, &block)\n nil\n end",
"def object\n obj = nil\n begin\n if referenced_object_id == @@referenced_object_ids[self.object_id]\n obj = ObjectSpace._id2ref(referenced_object_id)\n obj = nil unless verify_backreferences(obj)\n end\n rescue RangeError\n # Object has been garbage collected.\n end\n obj\n end",
"def ref; end",
"def ref_node(this_db = self.started_db)\n return Thread.current[:local_ref_node] if Thread.current[:local_ref_node]\n default_ref_node(this_db)\n end",
"def deref\n @used_references += 1\n end",
"def close\n pool.checkin self\n end",
"def close\n pool.checkin self\n end",
"def reference\n @refs ||= strip(:reference)\n end",
"def for_references\n self.class.new(shared_context: shared_context)\n end",
"def ref\n @ref ||= maybe_ref || api.master_ref.ref\n end",
"def _pool\n @pool._dump\n end",
"def get_task_ref(task)\n Chef::Log.debug \"Waiting on task #{task}\"\n wait_on_task(task)\n status_ = xapi.task.get_status(task)\n\n case status_\n when 'success'\n puts \"#{h.color \"#{status_}\", :green }\"\n # xapi task record returns result as <value>OpaqueRef:....</value>\n # we want the ref. this way it will work if they fix it to return jsut the ref\n ref = xapi.task.get_result(task).match(/OpaqueRef:[^<]+/).to_s\n\n # cleanup our task\n xapi.task.destroy(task)\n return ref\n else\n ui.msg(\"#{h.color \"#{status_}\", :red } \")\n ui.msg(\"#{h.color 'ERROR:', :red } #{xapi.task.get_error_info(task)}\")\n end\n end",
"def n_ref(ref)\n `#{@native}.refs[#{ref}]`\n end",
"def __drbref\n @ref\n end",
"def ref\n\t\t@_references_mutex.synchronize {\n\t\t\t@_references += 1\n\t\t}\n\n\t\tself\n\tend",
"def get_task_ref(task)\n wait_on_task(task)\n case xapi.task.get_status(task) \n when \"success\"\n # xapi task record returns result as <value>OpaqueRef:....</value> \n # we want the ref. this way it will work if they fix it to return jsut the ref\n ref = xapi.task.get_result(task).match(/OpaqueRef:[^<]+/).to_s\n #cleanup our task\n xapi.task.destroy(task)\n return ref\n else \n ui.msg( \"#{h.color 'ERROR:', :red } Task returned: #{xapi.task.get_result(task)}\" )\n return nil\n end\n end",
"def ref\n UV.ref(@handle)\n end",
"def ref(reference)\n Ref.new(reference)\n end",
"def ref\n if reactor_thread? && reactor_running?\n @process_queue.ref if @ref_count == 0\n @ref_count += 1\n end\n end",
"def pool(node)\n MUTEX.synchronize do\n pools[node.address.resolved] ||= create_pool(node)\n end\n end",
"def connection\n @connection_pool\n end",
"def resolve_reference; end",
"def pool(node)\n MUTEX.synchronize do\n pools[node.address.resolved] ||=\n Pool.new(node.address.ip, node.address.port, node.options)\n end\n end",
"def stack_load_ref(ref)\n\n Lib.lua_rawgeti(@pointer, LUA_REGISTRYINDEX, @ref)\n end",
"def refs\n @refs ||= load_refs\n end",
"def reference\n @reference\n end",
"def connection\n connection_id = current_connection_id\n unless conn = @reserved_connections.fetch(connection_id, nil)\n synchronize do\n conn = ( @reserved_connections[connection_id] ||= checkout )\n end\n end\n conn\n end",
"def creditor_reference(ref: T.unsafe(nil)); end",
"def ref\n @ref ||= self.node.attributes.to_h[\"ref\"]\n end",
"def pool=(new_value)\n @pool = new_value\n @pool << self if @pool\n end",
"def close\n @pool.close\n end",
"def weak_ref(o)\n if is_object_weak_ref?(o)\n o\n else\n WeakRef.new(o)\n end\n end",
"def refs\n @refs\n end",
"def acquire(fiber)\n # A special case for rails when doing ActiveRecord stuff when not yet\n # running in the context of a request (fiber) like in the case of AR\n # queries in environment.rb (Root Fiber)\n return @connections.first unless fiber[:callbacks]\n \n fiber[:current_pool_key] = connection_pool_key\n return fiber[connection_pool_key] if fiber[connection_pool_key]\n conn = if !@connections.empty?\n @connections.shift\n elsif (@connections.length + @busy_connections.length) < @size\n @connection_proc.call\n else\n Fiber.yield @queue << fiber\n end\n \n # They're called in reverse order i.e. release then process_queue\n fiber[:callbacks] << self.method(:process_queue)\n fiber[:callbacks] << self.method(:release)\n \n @busy_connections[fiber] = conn\n fiber[connection_pool_key] = conn\n end",
"def pool(session)\n read_task('rvpe.host.pool', session) do\n call_one_xmlrpc('one.hostpool.info', session)\n end\n end",
"def find_pool(owner_id, sub_id, activeon=nil)\n pools = @cp.list_pools({:owner => owner_id, :activeon => activeon})\n pools.each do |pool|\n if pool['subscriptionId'] == sub_id\n return pool\n end\n end\n return nil\n end",
"def checkout\n start_time = Time.now\n connection = nil\n reserved_connection_placeholder = Thread.current\n begin\n @mutex.synchronize do\n raise \"Can't perform checkout, #{@name} has been closed\" if @pool_size == 0\n until connection do\n if @checked_out.size < @connections.size\n connection = (@connections - @checked_out).first\n @checked_out << connection\n elsif @connections.size < @pool_size\n # Perform the actual connection outside the mutex\n connection = reserved_connection_placeholder\n @connections << connection\n @checked_out << connection\n @logger.debug {\"#{@name}: Created connection ##{@connections.size} #{connection}(#{connection.object_id}) for #{name}\"}\n else\n @logger.info \"#{@name}: Waiting for an available connection, all #{@pool_size} connections are checked out.\"\n wait_mutex(start_time)\n end\n end\n end\n ensure\n delta = Time.now - start_time\n if delta > @warn_timeout\n @logger.warn \"#{@name}: It took #{delta} seconds to obtain a connection. Consider raising the pool size which is \" +\n \"currently set to #{@pool_size}.\"\n end\n end\n if connection == reserved_connection_placeholder\n connection = renew(reserved_connection_placeholder)\n elsif @idle_timeout && (Time.now - connection._last_used) >= @idle_timeout\n connection = renew(connection)\n end\n\n @logger.debug {\"#{@name}: Checkout connection #{connection}(#{connection.object_id}) self=#{self}\"}\n return connection\n end",
"def borrow_object\n @mutex.synchronize {\n if !@idle_list.empty?\n result = @idle_list.shift\n \n elsif @active_list.size < @config.max_active\n result = create_with_timestamp\n \n elsif @active_list.size >= @config.max_active\n raise CommonPoolError, \"Max number of %d active objects reached.\" % @config.max_active\n \n else\n begin\n timeout(@config.timeout){ @cond.wait(@mutex) }\n rescue TimeoutError\n raise TimeoutError, \"#{@config.timeout} seconds request timeout reached.\"\n end\n result = @idle_list.shift\n end\n @active_list.store(result[1].__id__, result)\n \n logger.debug(\"* Get #{result[1]}\") if logger\n result[1]\n }\n end",
"def connection\n if conn = @reserved_connections[current_connection_id]\n conn\n else\n @reserved_connections[current_connection_id] = checkout\n end\n end",
"def connection\n #@pool ||= {}\n #@pool[Thread.current] ||= Mongoc::Client.new(host, port, :pool_size=>@pool_size)\n #Mongoc::Client.new(host, port, {})\n Thread.current[:_mongo] ||= Mongoc::Client.new(host, port, {})\n end",
"def pool; end",
"def pool; end",
"def pool_name()\n #This is a stub, used for indexing\n end",
"def ref\n UV.ref(@pointer)\n\n self\n end",
"def ref\n UV.ref(@pointer)\n\n self\n end",
"def resolve_object_ref(id)\n end",
"def pool(create_if_missing=false)\n result = Jetpants.topology.pool(collins_pool || self)\n if !result\n if master\n result = master.pool(create_if_missing)\n elsif create_if_missing\n result = Pool.new('anon_pool_' + ip.tr('.', ''), self)\n def result.sync_configuration; end\n end\n end\n result\n end",
"def orchestrate_ref_value\n __ref_value__\n end",
"def orchestrate_ref_value\n __ref_value__\n end",
"def close\n @pool.dispose\n end",
"def weak_ref_to_strong_ref(weak_ref)\n weak_ref.tap{} # This is a hack but it works, is there a better way?\n end",
"def check_out\n @mutex.synchronize do\n begin\n return new_client unless connection_pool_enabled?\n\n client = @connection_pool.pop(true)\n\n client.ping if @options[:reconnect]\n\n client\n rescue ThreadError\n if @created_connections < max_pool_size\n client = new_client\n @created_connections += 1\n return client\n end\n\n MysqlFramework.logger.error { \"[#{self.class}] - Database connection pool depleted.\" }\n\n raise 'Database connection pool depleted.'\n end\n end\n end",
"def unref\n return self if @closed\n ::Libuv::Ext.unref(handle)\n self\n end",
"def release()\n fiber = Fiber.current\n if fiber[connection_pool_key]\n @busy_connections.delete(fiber)\n @connections << fiber[connection_pool_key]\n fiber[connection_pool_key] = nil\n end\n end",
"def find_or_create_ref(opts)\n\t\tret = {}\n\t\tret[:ref] = get_ref(opts[:name])\n\t\treturn ret[:ref] if ret[:ref]\n\n\t\ttask = queue(Proc.new {\n\t\t\tref = Ref.find_or_initialize_by_name(opts[:name])\n\t\t\tif ref and ref.changed?\n\t\t\t\tref.save!\n\t\t\tend\n\t\t\tret[:ref] = ref\n\t\t})\n\t\treturn nil if task.wait() != :done\n\t\treturn ret[:ref]\n\tend",
"def get_easy\n easy_pool.pop || Ethon::Easy.new\n end",
"def get(_ref)\n raise NotImplementedError.new\n end",
"def across_pool_state\n super\n end",
"def get_ref(context, name)\n\t\tref = Ref.find(:first, :conditions => [ \"name = ?\", name])\n\t\tif (not ref)\n\t\t\tref = Ref.create(\n\t\t\t\t:name => name,\n\t\t\t\t:created => Time.now\n\t\t\t)\n\t\t\tref.save\n\t\t\tframework.events.on_db_ref(context, ref)\n\t\tend\n\n\t\treturn ref\n\tend",
"def ref(arg)\n lambda do\n RexPrelude.theorem_like_str[arg] ||\n \"[UNRESOLVED REFERENCE #{arg}]\"\n end # creates suspension!\nend",
"def refinit\n return if defined?(@_references)\n\n @_references = 1\n @_references_mutex = Mutex.new\n\n self\n end",
"def pool\n @pool ||= Pool.new(SequenceServer.config[:num_threads])\n end",
"def refs_at; end",
"def clone_pool\n super\n end",
"def pool\n pool_connection = ConnectionPool.new(size: 10, timeout: 5) do \n Redis.new :db=> redis_db_index, :password=> redis_instance.password, :host=> redis_instance.host, :port=> redis_instance.port\n end \n return pool_connection \n end",
"def acquire(timeout = 0.5)\n deadline = current_time + timeout\n\n @mut.synchronize do\n loop do\n raise(PoolShuttingDownError, \"cannot get connection: pool shutting down\") if @shutdown_block\n return @q.pop() if !@q.empty?()\n\n conn = try_create()\n return conn if conn\n\n wait = deadline - current_time\n raise(TimeoutError, \"cannot get connection: timeout after waited #{timeout} seconds\") if wait <= 0\n @cond.wait(@mut, wait)\n end\n end\n end",
"def current_pool\n return nil if current_user.nil?\n session[:pool_id] ? Pool.where(:short_name=>session[:pool_id]) : current_user.identities.first.pools.first\n end",
"def redis_pool=(_arg0); end",
"def ref\n # memoizing this is worthwhile ~ 3 percent of calls are the \"first time\n # around\" in an average run of Puppet. --daniel 2012-07-17\n @ref ||= \"#{self.class.name.to_s.capitalize}[#{self.title}]\"\n end",
"def reap!\n HotTub.logger.info \"[HotTub] Reaping pool #{@name}!\" if HotTub.log_trace?\n while !@shutdown\n reaped = nil\n @mutex.synchronize do\n begin\n if _reap?\n if _dead_clients?\n reaped = @_out.select { |clnt, thrd| !thrd.alive? }.keys\n @_out.delete_if { |k,v| reaped.include? k }\n else\n reaped = [@_pool.shift]\n end\n else\n reaped = nil\n end\n ensure\n @cond.signal\n end\n end\n if reaped\n reaped.each do |clnt|\n close_client(clnt)\n end\n else\n break\n end\n end\n nil\n end",
"def resolved_ref\n \"resolved-#{ref}\"\n end",
"def push(clnt)\n if clnt\n orphaned = false\n @mutex.synchronize do\n begin\n if !@shutdown && @_out.delete(clnt)\n @_pool << clnt\n else\n orphaned = true\n end\n ensure\n @cond.signal\n end\n end\n close_orphan(clnt) if orphaned\n reap! if @blocking_reap\n end\n nil\n end",
"def connection\n # this is correctly done double-checked locking\n # (ThreadSafe::Cache's lookups have volatile semantics)\n @reserved_connections[current_connection_id] || synchronize do\n @reserved_connections[current_connection_id] ||= checkout\n end\n end",
"def deref\n @_references_mutex.synchronize {\n if ((@_references -= 1) == 0)\n cleanup\n\n true\n else\n false\n end\n }\n end",
"def intern\n self\n end",
"def ref\n Coord.rel( self )\n end",
"def get(object_key, timeout_seconds: ReadWriteLock::DEFAULT_TIMEOUT_SECONDS) # yields:\n object_lock = @pool_lock.synchronize{ @object_lock_map[object_key] }\n object_lock.write_synchronize(timeout_seconds) {\n if (@pool_lock.synchronize{ @pool_map.key? object_key }) then\n ref_count = @pool_lock.synchronize{ @pool_map[object_key] }\n else\n yield if block_given?\n object_holder = @object_factory.call(self, object_key, object_lock)\n ref_count = ReferenceCount.new(0, object_holder)\n @pool_lock.synchronize{ @pool_map[object_key] = ref_count }\n end\n ref_count.count >= 0 or raise 'internal error'\n ref_count.count += 1\n ref_count.object_holder\n }\n end",
"def connection\n @reserved_connections[current_connection_id] ||= checkout\n end",
"def get_linked_swimming_pool( name_method = :get_verbose_name )\n object.get_swimming_pool ? object.get_swimming_pool.decorate.get_linked_name( name_method ) : '?'\n end",
"def get_linked_swimming_pool( name_method = :get_verbose_name )\n object.get_swimming_pool ? object.get_swimming_pool.decorate.get_linked_name( name_method ) : '?'\n end",
"def unref\n UV.unref(@handle)\n end",
"def load_onto_stack\n\n raise RuntimeError.new(\n \"#{self.class} got freed, cannot re-access it directly\"\n ) unless @ref\n\n stack_load_ref(@ref)\n end",
"def reference\n value_for('reference')\n end",
"def reference(ref: T.unsafe(nil)); end",
"def sqref(io)\n cref = io.read(2).unpack('v').first\n\n {\n cref: cref, # cref (2 bytes): An unsigned integer that specifies the number of elements in rgrefs. MUST be less than or equal to 0x2000.\n rgrefs: cref.times.map { ref8u(io.read(8)) } # rgrefs (variable): An array of Ref8 structures. The number of elements in the array MUST be equal to cref.\n }\n end",
"def connection_pool(options = {}, &block)\n options = valid_options.merge(options)\n initialize_connection_pool(options) unless defined?(@connection_pool)\n\n if block_given?\n @connection_pool.with(&block)\n else\n @connection_pool\n end\n end",
"def ref\n @references += 1\n end",
"def [](kernel)\n @pool[kernel]\n end",
"def ref\n @id\n end",
"def connection_pool_maximum_reuse\n super\n end",
"def pid\n @pid ||= pid_for @ref\n end",
"def to_obj(ref)\n if @@ids.include?(ref)\n #ObjectSpace._id2ref(ref)\n @@ids[ref]\n else\n STDERR.puts \"attempted to load an unshared object by object id\"\n raise Exception.new(\"attempted to load an unshared object by object id\")\n end\n end"
] |
[
"0.6327182",
"0.60461324",
"0.6011201",
"0.5982237",
"0.58152574",
"0.5814085",
"0.5759991",
"0.5725847",
"0.5711285",
"0.56558347",
"0.5642864",
"0.5624329",
"0.5615926",
"0.5596941",
"0.5596941",
"0.5551657",
"0.5545457",
"0.55419296",
"0.55370665",
"0.5534037",
"0.55324346",
"0.5501794",
"0.5497835",
"0.5492654",
"0.54545367",
"0.5431949",
"0.5425024",
"0.5423254",
"0.5372524",
"0.5351621",
"0.53112686",
"0.52907676",
"0.52784026",
"0.5259462",
"0.52535176",
"0.52439827",
"0.52361256",
"0.52201426",
"0.5187946",
"0.51863194",
"0.51770186",
"0.5132971",
"0.51317215",
"0.51051164",
"0.5101068",
"0.50938267",
"0.5088867",
"0.5084481",
"0.50808924",
"0.50808924",
"0.5072211",
"0.5062016",
"0.5062016",
"0.5058948",
"0.5050797",
"0.5050663",
"0.5050663",
"0.50374484",
"0.5030314",
"0.5022745",
"0.49974754",
"0.499463",
"0.49912706",
"0.49703357",
"0.49642983",
"0.49571034",
"0.49532324",
"0.4951092",
"0.4933045",
"0.49201787",
"0.49136767",
"0.4912697",
"0.48976606",
"0.48909152",
"0.4890362",
"0.4888696",
"0.48882997",
"0.4885325",
"0.48668924",
"0.48609355",
"0.48609287",
"0.48583674",
"0.48430547",
"0.48326662",
"0.48204207",
"0.48201817",
"0.48170218",
"0.48170218",
"0.48160085",
"0.48120514",
"0.48068532",
"0.4802136",
"0.48019302",
"0.47979566",
"0.4793573",
"0.47847158",
"0.4777908",
"0.4774747",
"0.47718033",
"0.47701183"
] |
0.77133334
|
0
|
GET /recorridos/1 GET /recorridos/1.json
|
def show
recorrido = Recorrido.find(params[:id].to_i)
@polylines = []
@stops = []
# @shapes = Shape.all
secuencias = recorrido.get_secuencias_of_the_hour
secuencias.each_with_index do |s, i|
@polylines[i] = []
Shape.where(:code => s.code).first.points.each_with_index do |p, e|
e == 0 ? @polylines[i] << {:strokeColor => '#000000', :icons => [], :lat => p.lat, :lng => p.lng } : @polylines[i] << {:lat => p.lat, :lng => p.lng }
end
s.stops.each do |stop|
@stops << {:title => stop.code,
:lat => stop.lat,
:lng => stop.lng,
:width => 12,
:height => 14,
:picture => "../images/parada_12.png", :type => 'stop',
:type => 'stop',
:ida => i,
:description => render_to_string(:partial => "/recorridos/stop_infowindow", :locals => { :stop => stop})}
end
end
respond_to do |format|
format.js
format.html
format.json { render json: @recorrido }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def index\n @restoras = Restora.all\n end",
"def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end",
"def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end",
"def show\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relogio }\n end\n end",
"def show\n @remito = Remito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remito }\n end\n end",
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def show\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recurso }\n end\n end",
"def index\n @regos = Rego.all\n end",
"def show\n @reconocimiento = Reconocimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @reconocimiento }\n end\n end",
"def listar()\n @client.get(Route.new([ROTA_DID]))\n end",
"def show\n @recoleccion = Recoleccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recoleccion }\n end\n end",
"def index\n @regrapontos = Regraponto.all\n end",
"def index\n @frais_repas = FraisRepa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_repas }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def index\n @recoleccions = Recoleccion.all\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def index\n @ruas = Rua.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ruas }\n end\n end",
"def ocRecibir\n id = params[:id]\n ocClass = Oc.new\n result = ocClass.recibirOC(id) \n render :json => {:aceptado => result, :idoc => id} \n\n end",
"def set_resto\n @resto = Resto.find(params[:id])\n end",
"def index\n @corridas = Corrida.all\n end",
"def set_recorrido\n @recorrido = Recorrido.find(params[:id])\n end",
"def index\n seleccionarMenu(:rondas)\n @rondas = Ronda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rondas }\n end\n end",
"def index\n @redacaos = Redacao.all\n end",
"def show\n @reparacion = Reparacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reparacion }\n end\n end",
"def index\n @reprogramaciones = Reprogramacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reprogramaciones }\n end\n end",
"def index\n @repondres = Repondre.all\n end",
"def index\n @relatorios = Relatorio.all.page(params[:page]).per(15)\n end",
"def show\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def index\n @receipes = Receipe.all\n end",
"def show\n @repa = Repa.find(params[:id])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def index\n @premios = Premio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @premios }\n end\n end",
"def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end",
"def index\r\n @respuesta = Respuestum.all\r\n end",
"def recolectores\n @personas = Persona.where(:empleados_id => 2).order(\"apellido ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @personas }\n end\n end",
"def index\n @ordenes = Orden.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordenes }\n end\n end",
"def index\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalles = @recibo.renglon_recdetalles.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_recdetalles }\n end\n end",
"def index\n @uchronias = Uchronia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronias }\n end\n end",
"def index\n @recaudacions = Recaudacion.all\n end",
"def show\n @historial = Historial.find(params[:id])\n @receta = Recete.histori(@historial.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial }\n end\n end",
"def index\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebitos = @notadedebito.renglon_notadebitos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_notadebitos }\n end\n end",
"def index\n @current_page = 'recettes'\n @recettes = Recette.includes(:photo_files).all.order('id desc').limit(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recettes }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def show\n @roadcrime = Roadcrime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roadcrime }\n end\n end",
"def index\n @riesgos = Riesgo.all\n end",
"def show\n @reltramovano = Reltramovano.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reltramovano }\n end\n end",
"def index\n @factura = Factura.find(params[:factura_id])\n @renglon_facturas = @factura.renglon_facturas\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @renglon_facturas }\n end\n end",
"def index\n @reclas = Recla.all\n end",
"def index\n @rodadas = Rodada.all\n end",
"def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @repuesto.to_json }\n end\n end",
"def index\n @regras = Regra.all\n end",
"def index\n @socios = Socio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @socios }\n end\n end",
"def index\n @respuestas = Respuesta.all\n end",
"def show\n @receipe = Receipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receipe }\n end\n end",
"def index\n \n respond_to do |format|\n format.html { @radars = Radar.all }\n format.json { @radars = Radar.recent }\n end\n end",
"def show\n @reprogramacion = Reprogramacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reprogramacion }\n end\n end",
"def troca\n @remetente = Sobrevivente.where(id: params[:de]).first\n @destinatario = Sobrevivente.where(id: params[:para]).first\n\n enviar = {agua: 1, comida: 2, medicamento: 3, municao: 4}\n receber = {agua: 0, comida: 2, medicamento: 3, municao: 8}\n\n trocou = @remetente.troca(@destinatario, enviar, receber)\n\n render json: { status: trocou }\n end",
"def index\n @relassociates = Relassociate.all\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end",
"def index\n @reparticoes = Reparticao.all\n end",
"def show\n @pessoa_receber = PessoaReceber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pessoa_receber }\n end\n end",
"def index \n if params[:cuisine]. blank?\n @restos = Resto.includes(:stars).order(created_at: :desc).page params[:page]\n else\n @cuisine_id = Cuisine.find_by(name: params[:cuisine]).id\n @restos = Resto.where(cuisine_id: @cuisine_id).order(\"created_at DESC\").page params[:page]\n end\n end",
"def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end",
"def index\n @repertoires = Repertoire.all\n end",
"def listRestaurants\n _restaurants = Restaurant.all\n render json: _restaurants\n end",
"def index\n @rozmiars = Rozmiar.all\n end",
"def index\n @concursos = Concurso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concursos }\n end\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def index\n #@arquivos = Arquivo.all\n\n residencial = current_user.apartamento.residencial\n @arquivos = Arquivo\n .where(:residencial_id => residencial.id)\n .order(\"created_at\")\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @arquivos }\n end\n end",
"def show\n seleccionarMenu(:rondas)\n @ronda = Ronda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ronda }\n end\n end",
"def index\n @renomears = Renomear.all\n end",
"def index\n @repuestos = Repuesto.all\n end",
"def show\n @rua = Rua.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rua }\n end\n end",
"def show\n @realiza = Realiza.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @realiza }\n end\n end",
"def index\n @ordens = Orden.all\n render json: @ordens\n end",
"def index\n @remuneracoes = Remuneracao.all\n end",
"def index\n @territorios = Territorio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @territorios }\n end\n end",
"def show\n @roof = Roof.find(params[:roof_id])\n @status = @roof.statuses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @status }\n end\n end",
"def show\n @frais_repa = FraisRepa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @frais_repa }\n end\n end",
"def show\n @retroaspecto = Retroaspecto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retroaspecto }\n end\n end",
"def show\n @reel = Reel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reel }\n end\n end",
"def index\n @recrutements = Recrutement.all\n end",
"def show\n @ridol = Ridol.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ridol }\n end\n end",
"def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end",
"def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end",
"def index\n @corges = Corge.all\n end",
"def show\n @orden_cobro = OrdenCobro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @orden_cobro }\n end\n end",
"def show\n @orden_cobro = OrdenCobro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @orden_cobro }\n end\n end",
"def show\n @referee = Referee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @referee }\n end\n end",
"def show\n @razmer_go = RazmerGo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @razmer_go }\n end\n end",
"def index\n @receitas = Receita.all\n @receitas = current_usuario.receitas.page(params[:page])\n end",
"def index\n @preparatoria_o_universidad_de_origens = PreparatoriaOUniversidadDeOrigen.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @preparatoria_o_universidad_de_origens }\n end\n end",
"def index\n @ruolos = Ruolo.all\n end",
"def get_todo_restaurants\n @profile = Profile.find(params[:id])\n @restaurants = @profile.todos\n\n render status: 200, json: @restaurants\n end",
"def get_modelos\n marca = Marca.find(params[:marca_id])\n @modelos = Modelo.of_marca(marca.id)\n\n render json: @modelos\n\n end",
"def index\n @reprodutores = Reprodutor.all\n end",
"def index\n @cartridges = Cartridge.all\n\n respond_to do |format|\n format.html\n format.json { render json: @cartridges }\n end\n end",
"def get\n @cine = Cine.find(params[:cine_id], :select => [\"nombre\",\"id\",\"direccion\",\"localidad\"])\n render :json => [ @cine, :peliculas => @cine.peliculas.select('titulo,horas,pelicula_id') ]\n end",
"def show\n @correo = Correo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @correo }\n end\n end",
"def show\n @correo = Correo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @correo }\n end\n end"
] |
[
"0.6985941",
"0.6835628",
"0.6820885",
"0.6757224",
"0.67209727",
"0.65974635",
"0.6552926",
"0.65426266",
"0.6499552",
"0.64912564",
"0.64472693",
"0.6422123",
"0.6418647",
"0.6386169",
"0.6358261",
"0.6343909",
"0.63431144",
"0.6341139",
"0.6286661",
"0.6285019",
"0.6274853",
"0.6255691",
"0.6253307",
"0.622443",
"0.62236154",
"0.6223477",
"0.62055814",
"0.6204535",
"0.6200008",
"0.61964554",
"0.6194156",
"0.6193",
"0.61902416",
"0.6182072",
"0.6181712",
"0.6170817",
"0.6156964",
"0.61568123",
"0.6150041",
"0.6143574",
"0.61284614",
"0.612564",
"0.6125343",
"0.6101922",
"0.60944635",
"0.60938776",
"0.60898477",
"0.6089347",
"0.6081769",
"0.60720366",
"0.6069908",
"0.604951",
"0.6047195",
"0.6043085",
"0.60410434",
"0.6028742",
"0.6025824",
"0.6024206",
"0.6023051",
"0.6021891",
"0.6021345",
"0.59974164",
"0.5990538",
"0.5987456",
"0.5987205",
"0.5949328",
"0.5943778",
"0.5942429",
"0.59414715",
"0.5940205",
"0.59390414",
"0.59361106",
"0.5931905",
"0.5930973",
"0.59286356",
"0.5926531",
"0.59212756",
"0.5920644",
"0.59184825",
"0.59127045",
"0.5908036",
"0.590678",
"0.5904699",
"0.58940834",
"0.5890601",
"0.5887951",
"0.58866614",
"0.58850354",
"0.58850354",
"0.58793104",
"0.5877078",
"0.5875398",
"0.5872726",
"0.58706266",
"0.5867592",
"0.58669275",
"0.5865641",
"0.5864421",
"0.58601606",
"0.58598244",
"0.5858913"
] |
0.0
|
-1
|
Returns all relationships that are manytoone for this model. Used to find the relationships that require properties in any Repository. Example: class Plur include DataMapper::Resource def self.default_repository_name :plur_db end repository(:plupp_db) do has 1, :plupp end end This resource has a manytoone to the Plupp resource residing in the :plupp_db repository, but the Plur resource needs the plupp_id property no matter what repository itself lives in, ie we need to create that property when we migrate etc. Used in DataMapper::Model.properties_with_subclasses
|
def many_to_one_relationships
relationships unless @relationships # needs to be initialized!
@relationships.values.collect do |rels| rels.values end.flatten.select do |relationship| relationship.child_model == self end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def relationships\n model.relationships(repository.name)\n end",
"def relationships\n @relationships ||= Relationship.from_associations(self, associations)\n end",
"def relationships\n return [] if empty?\n\n map { |pivot_table| Relationship.new(pivot_table, PIVOT_TABLE_R, \"../#{pivot_table.pn}\") }\n end",
"def relationships\n return [] if empty?\n\n map { |table| Relationship.new(table, TABLE_R, \"../#{table.pn}\") }\n end",
"def relationships\n @relationships.each do |k, v|\n if v.respond_to?(:uniq!)\n v.uniq!\n @relationships[k] = v.first if v.length == 1\n end\n end\n @relationships\n end",
"def jsonapi_relationships\n\t\t\t\t\tjsonapi_model_class.reflect_on_all_associations.collect do |association|\n\t\t\t\t\t\t#type = nil\n\n\t\t\t\t\t\ttype = :to_one if [\n\t\t\t\t\t\t\tActiveRecord::Reflection::HasOneReflection, \n\t\t\t\t\t\t\tActiveRecord::Reflection::BelongsToReflection\n\t\t\t\t\t\t].include? association.class\n\n\t\t\t\t\t\ttype = :to_many if [\n\t\t\t\t\t\t\tActiveRecord::Reflection::HasManyReflection, \n\t\t\t\t\t\t\tActiveRecord::Reflection::HasAndBelongsToManyReflection\n\t\t\t\t\t\t].include? association.class\n\n\t\t\t\t\t\tnext unless type\n\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: association.name,\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\treceiver: {\n\t\t\t\t\t\t\t\ttype: association.klass.to_s.underscore.pluralize.to_sym,\n\t\t\t\t\t\t\t\tclass: association.klass.to_s.constantize\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\tend.compact\n\t\t\t\tend",
"def relationships\n r = Relationships.new\n r << Relationship.new(cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, \"../#{cache_definition.pn}\")\n r\n end",
"def relationships\n @relationships ||= {}\n end",
"def relationships\n r = Relationships.new\n @worksheets.each do |sheet|\n r << Relationship.new(sheet, WORKSHEET_R, format(WORKSHEET_PN, r.size + 1))\n end\n pivot_tables.each_with_index do |pivot_table, index|\n r << Relationship.new(pivot_table.cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, format(PIVOT_TABLE_CACHE_DEFINITION_PN, index + 1))\n end\n r << Relationship.new(self, STYLES_R, STYLES_PN)\n if use_shared_strings\n r << Relationship.new(self, SHARED_STRINGS_R, SHARED_STRINGS_PN)\n end\n r\n end",
"def relations\n self.class.relations\n end",
"def get_relations\n # Descobrir as relacoes:\n # Orientados\n # Projetos de Pesquisa\n # Producoes Bibliograficas\n # Consultar o RP de cada uma\n # Somar os RPs e retornar\n orientados = self.get_relations_of_orientados\n projetos = self.get_relations_of_projetos_pesquisa\n producoes = self.get_relations_of_producoes_bibliograficas\n\n relations = (orientados | projetos | producoes).delete self.id\n return relations.to_a\n end",
"def list_relationships\n end",
"def associations\n model.relationships.to_a.collect { |name,rel|\n {\n :name => name.to_s,\n :type => association_type_lookup( rel ), # :has_many, :has_one, or :belongs_to\n :parent_model => rel.parent_model,\n :parent_key => rel.parent_key.collect { |p| p.name },\n :child_model => rel.child_model,\n :child_key => rel.child_key.collect { |p| p.name },\n :remote_rel => rel.options[:remote_relationship_name],\n :near_rel => rel.options[:near_relationship_name]\n }\n }\n end",
"def relationships_for(model) # @private :nodoc:\n relationships_mapping[model] or []\n end",
"def relations\n @relations ||= process_rels\n end",
"def has_many_relations\n remap_relations(relations_by_macro(:has_many))\n end",
"def property_relations\n relations = EntityPropertyRelationship.where(entity_id: self.id)\n relations.sort_by { |r| r[:position] }\n end",
"def model_relationships; end",
"def model_relationships\n hash = ActiveSupport::OrderedHash.new\n reflect_on_all_associations.map { |i| hash[i.name] = i.macro }\n return hash\n end",
"def relations\n _relations\n end",
"def relations\n _relations\n end",
"def repositories\n [ repository ].to_set + @properties.keys.map { |repository_name| DataMapper.repository(repository_name) }\n end",
"def get_relations_from_api(api=Rosemary::API.new)\n api.get_relations_referring_to_object(type, self.id.to_i)\n end",
"def associations\r\n [nil, joins]\r\n end",
"def relationships\n return [] unless has_comments?\n\n comments.relationships\n end",
"def child_ontology_relationships(options = {}) # :yields: Array of OntologyRelationships\n opt = {\n :relationship_type => 'all' # or a ObjectRelationships#id\n }.merge!(options.symbolize_keys)\n\n # TODO: modify to sort by first(top) label\n if opt[:relationship_type] == 'all'\n OntologyRelationship.find(:all, :include => [:ontology_class1, :object_relationship, :ontology_class2], :conditions => ['ontology_class2_id = ?', self.id]) # .sort{|x,y| x.ontology_class1.preferred_label.name <=> y.ontology_class1.preferred_label.name}\n else\n OntologyRelationship.find(:all, :include => [:ontology_class1, :object_relationship, :ontology_class2], :conditions => ['ontology_class2_id = ? AND object_relationship_id = ?', self.id, opt[:relationship_type]]) # .sort{|x,y| x.ontology_class1.preferred_label.name <=> y.ontology_class1.preferred_label.name}\n end\n end",
"def relation\n relation = nodes.reduce(root) do |a, e|\n a.associations[e.name.key].join(:join, a, e)\n end\n schema.(relation)\n end",
"def initialize_relationships\n @mappers.each do |mapper|\n @relationships.merge(mapper.relationships.find_dependent(@model))\n end\n\n @relationships.freeze\n end",
"def all_related_models\n via_assay = related_assays.collect do |assay|\n assay.model_masters\n end.flatten.uniq.compact\n via_assay | related_models\n end",
"def gen_relationships\n @parser.relationships.each do |rel|\n through_str = ''\n lines = []\n if rel[:has_relationship]\n has_relationship = rel[:has_relationship].gsub(':', '..')\n case has_relationship\n when '1'\n rel_str = 'belongs_to'\n when 'n'\n rel_str = \"has n,\"\n else\n rel_str = \"has #{has_relationship},\"\n if rel[:through]\n through_str = \", :through => :#{rel[:through]}\"\n else\n through_str = \", :through => Resource\"\n end\n end\n \n if rel[:through]\n lines << \" has n, :#{rel[:through]}\"\n end\n line = \" #{rel_str} :#{rel[:variable]}#{through_str}\"\n line += \" # #{rel[:comment]}\" unless rel[:comment].empty?\n lines << line\n elsif rel[:relationship]\n lines << ' ' + rel[:relationship]\n end\n editor = ModelEditor.new(rel[:filename].snake_case)\n editor.insert(AFTER_PROPERTIES, lines)\n end\n end",
"def properties\n properties = []\n relations = self.property_relations\n relations.each do |relationship|\n properties.push relationship.property\n end\n properties\n end",
"def related_models\n via_assay = assays.collect(&:models).flatten.uniq.compact\n via_assay | models\n end",
"def get_relations_referring_to_object(type, id)\n api_call_with_type(type, id, \"#{type}/#{id}/relations\")\n end",
"def relations\n @relations ||= {}\n end",
"def all_associations\n @all_associations ||= (\n # field associations\n @fields.collect { |field|\n field.associations.values\n }.flatten +\n # attribute associations\n @attributes.collect { |attrib|\n attrib.associations.values\n }.flatten\n ).uniq.collect { |assoc|\n # get ancestors as well as column-level associations\n assoc.ancestors\n }.flatten.uniq\n end",
"def relationship_get_all_props id\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n }\n get_request 'relationship/' + id + '/properties', headers\n end",
"def rels\n @rels ||= root.data._rels\n end",
"def relationships\n [Relationship.new(self, VML_DRAWING_R, \"../#{vml_drawing.pn}\"),\n Relationship.new(self, COMMENT_R, \"../#{pn}\")]\n end",
"def child_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:children).uniq\n Relationship.filter_by_resource_type(rels, options)\n end",
"def guardian_relationships\n\t\t([self.guardian_relationship] + VALID_GUARDIAN_RELATIONSHIPS ).compact.uniq\n\tend",
"def dangling_relationships\n relationships.select do |relationship|\n relationship.subject.nil? || relationship.objekt.nil?\n end\n end",
"def sibling_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:siblings).uniq\n Relationship.filter_by_resource_type(rels, options)\n end",
"def relations\n return @relations if defined?(@relations)\n\n relations = injected_options.fetch(:relations, nil)\n relations = allowed_options.fetch(:relations, []) if relations.nil?\n\n @relations = Relations.new(relations, includes)\n end",
"def has_one_params\n resource.reflect_on_all_associations(:has_one).map do |one|\n relation_param(one)\n end.compact\n end",
"def relationship(*args)\n options = args.extract_options!\n if options[:raise_on_multiple]\n rels = relationships.take(2)\n raise _(\"Multiple relationships found\") if rels.length > 1\n rels.first\n else\n relationships.first\n end\n end",
"def related_organisms\n organisms = related_assays.collect{|a| a.organisms}.flatten.uniq.compact\n organisms = organisms | related_models.collect{|m| m.organism}.uniq.compact\n organisms\n end",
"def related_resources(resource)\n if resource.respond_to?(:related_resources_recursive)\n return resource.related_resources_recursive\n else\n return []\n end\n end",
"def rels(*rel_types)\n if rel_types.empty?\n AllRelsDsl.new(@_relationships, _java_node)\n else\n storage = _create_or_get_storage(rel_types.first)\n RelsDSL.new(storage)\n end\n end",
"def rels(node)\n @batch_inserter.getRelationships(node)\n end",
"def target_relations\n query = \"at:link[@rel = '#{Rel[repository.cmis_version][:relationships]}']/@href\"\n link = data.xpath(query, NS::COMBINED)\n if link.length == 1\n link = Internal::Utils.append_parameters(link.text, \"relationshipDirection\" => \"target\", \"includeSubRelationshipTypes\" => true)\n Collection.new(repository, link)\n else\n raise \"Expected exactly 1 relationships link for #{key}, got #{link.length}, are you sure this is a document/folder?\"\n end\n end",
"def belongs_to_relations(ar_instance)\n\t\t\tcolumns = ar_instance.class.column_names\n\t\t\tparents = columns.map{ |c| c if c =~ /_id/ }.reject{ |c| c.nil? }\n\t\t\tparents.map!{ |parents| parents.gsub('_id', '') }\n\t\tend",
"def joins\n j = []\n associations.each do |association|\n next if association.conditions.blank?\n association_joins = association.joins\n j << (association_joins.blank? ? association.relationship_name.to_sym : {association.relationship_name.to_sym => association_joins})\n end\n j.blank? ? nil : (j.size == 1 ? j.first : j)\n end",
"def has_associations\n assocs.each_rel.to_a\n end",
"def relationships(*ids)\n perform_request_with_collection(:get, '/api/v1/accounts/relationships',\n array_param(:id, ids),\n Mastodon::Relationship)\n end",
"def relationship_custom_fields\n custom_fields_recipe['rules'].find_all do |rule|\n %w[belongs_to has_many many_to_many].include?(rule['type'])\n end\n end",
"def relationship_data\n data = @objects.try(:map) { |o| o.try(:relationship_data) }\n data.try(:compact!) || data\n end",
"def reciprocal_type\n :one_to_many\n end",
"def rel_props(rel)\n @batch_inserter.get_relationship_properties(rel)\n end",
"def all\n @data_adapter.relations\n end",
"def resolve!\n @relations.map(&:resolve!)\n end",
"def all_organization_relationships(**args)\n params = parameters(args) do\n required_params :org_id\n optional_params :org_id\n end\n request(:get, 'organizationRelationships', params)\n end",
"def related_organisms\n organisms = assays.collect(&:organisms).flatten\n organisms |= models.collect(&:organism).flatten\n organisms.uniq.compact\n end",
"def source_relations\n query = \"at:link[@rel = '#{Rel[repository.cmis_version][:relationships]}']/@href\"\n link = data.xpath(query, NS::COMBINED)\n if link.length == 1\n link = Internal::Utils.append_parameters(link.text, \"relationshipDirection\" => \"source\", \"includeSubRelationshipTypes\" => true)\n Collection.new(repository, link)\n else\n raise \"Expected exactly 1 relationships link for #{key}, got #{link.length}, are you sure this is a document/folder?\"\n end\n end",
"def relation_all(model)\n validate_model(model)\n model.all\n end",
"def map_relations\n self.resource_relations = {}\n model.alchemy_resource_relations.each do |name, options|\n relation_name = name.to_s.gsub(/_id$/, \"\") # ensure that we don't have an id\n association = association_from_relation_name(relation_name)\n foreign_key = association.options[:foreign_key] || \"#{association.name}_id\".to_sym\n collection = options[:collection] || resource_relation_class(association).all\n resource_relations[foreign_key] = options.merge(\n model_association: association,\n name: relation_name,\n collection: collection\n )\n end\n end",
"def visible_relations \n\t\t\tif defined? @visible_relations \n\t\t\t\t@visible_relations\n\t\t\telse\n\t\t\t\tassociation_helper_models = []\n\t\t\t\t# find \n\t\t\t\tself.reflections.keys.each do |key|\n\t\t\t\t\tif self.reflections[key].class == ActiveRecord::Reflection::ThroughReflection\n\t\t\t\t\t\tassociation_helper_models.push self.reflections[key].options[:through]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tkeys = self.reflections.keys.map do |key| key.to_sym end\n keys - association_helper_models\n\t\t\tend\n\t\tend",
"def parent_rels(*args)\n options = args.extract_options!\n pri = parent_rel_ids\n rels = pri.kind_of?(Array) && pri.empty? ? Relationship.none : Relationship.where(:id => pri)\n Relationship.filter_by_resource_type(rels, options)\n end",
"def associations; end",
"def rels\n @traversal_result = :rels\n self\n end",
"def logical_relatives(options = {}) # :yields: {OntologyClass => implied_redundant_relationships ? true : false}\n return [] if !ObjectRelationship.find_by_interaction_and_proj_id('is_a', self.proj_id) || !ObjectRelationship.find_by_interaction_and_proj_id('part_of', self.proj_id)\n\n rel1 = Proj.find(self.proj_id).object_relationships.by_interaction('is_a').first.id\n rel2 = Proj.find(self.proj_id).object_relationships.by_interaction('part_of').first.id\n return [] if !rel1 || !rel2\n\n opt = {\n :direction => :children, # [:parents | :children]\n :rel1 => rel1,\n :rel2 => rel2\n }.merge!(options.symbolize_keys)\n\n return nil if ![:parents, :children].include?(opt[:direction])\n\n first_result = [] # all the part_of\n second_result = [] # part_of through is_a\n\n result = {}\n\n # Find/recurse the isa/part_of tree, this gets us a unique array of pertinent OntologyRelationships\n # that reflect OntologyClass relationships that are related by one of rel1 or rel2 at each inspection.\n rels = self.related_ontology_relationships(opt.merge(:relationship_type => [opt[:rel1], opt[:rel2]]))\n\n return {} if rels == nil\n\n # get all the part_of resuls, anything below and with a part_of, is part_of (since all others are is_a)\n to_nuke = [] # index of rels to delete before next itteration\n rels.each do |r|\n nuke = false # boolean check for delete\n if r.object_relationship_id == opt[:rel2]\n nuke = true\n if opt[:direction] == :parents\n first_result.push(r.ontology_class2)\n else\n first_result.push(r.ontology_class1)\n end\n end\n to_nuke.push(r) if nuke\n end\n\n # !! don't do uniq on first result\n\n # try to invoke some loop speedup by deleting values we don't need to loop through\n rels.delete_if{|r| to_nuke.include?(r)}\n rels.delete_if{|r| !r.object_relationship_id == opt[:rel1]} # we only need to deal with isas of rel1 now\n\n # for all of the part_of results also get the is_a children (or whatever rel2 -> rel1 relationship is)\n\n rels.each do |rel|\n first_result.uniq.each_with_index do |r,i|\n if opt[:direction] == :parents\n second_result.insert(-1, rel.ontology_class2) if (rel.ontology_class1 == r)\n else\n second_result.insert(-1, rel.ontology_class1) if (rel.ontology_class2 == r)\n end\n end\n end\n\n second_result.uniq! # don't imply redundancies from hitting an is_a twice (is this right?! - gives \"correct\" result AFAIKT)\n\n (first_result + second_result).each do |r|\n result.merge!(r => (!result.keys.include?(r) ? false : true))\n end\n\n result\n end",
"def parameterized_relationships\n @parameterized_relationships || OpenStruct.new(representations_for: [],\n documents_for: [],\n attachment_uris: [],\n attachments_for: [],\n constituent_of_uris: [],\n has_constituent_part: [])\n end",
"def all_objects\n objects = []\n each_namespace{|n| objects << n}\n each_namespace{|n| \n n.each_relvar{|r| objects << r}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_candidate_key{|k| objects << k}}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_foreign_key{|k| objects << k}}\n }\n objects\n end",
"def relations \n @roots = Category.roots \n @categories = Category.has_children \n @expense_types = ExpenseType.all\n @payment_methods = PaymentMethod.all\n end",
"def relationship_has_objects(id)\n return @client.raw(\"get\", \"/config/relationships/#{id}/hasObjects\")\n end",
"def has_many(*args)\n require \"og/relation/has_many\"\n relations! << Og::HasMany.new(args, :owner_class => self, :collection => true)\n end",
"def projects\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:proj, RDF.type, Ruta::Class.project],\n [:proj, RDF::FOAF.member, :mir],\n [:mir, Ruta::Property.has_member, uri]\n )\n projs = []\n query.each_solution { |sol| projs.push(sol.proj.as(Organisation)) }\n projs\n end",
"def associations\n association_reflections.keys\n end",
"def scaffold_all_associations\n relationships.values.select { |v|\n v.send(:target_model).respond_to?(:scaffold_name)\n }\n end",
"def get_rels\n @rels = []\n @heads.each_with_index do |h1, i|\n @heads[i+1..-1].each do |h2|\n path = @graph.shortest_path(h1, h2)\n s = path.shift\n o = path.pop\n @rels << [s, path, o] if (path & @heads).empty?\n end\n end\n end",
"def identify_single_through_associations\n return reflect_on_all_associations.select { |a|\n (a.macro == :has_one) && !a.options[:through].blank? }.map { |a|\n a.name.to_s\n }\n end",
"def reciprocal_type\n :many_to_one\n end",
"def relationship_ancestry(*args)\n stringify_options = args.extract_options!\n options = stringify_options.slice!(:field_delimiter, :record_delimiter, :exclude_class, :field_method, :include_self)\n\n include_self = stringify_options.delete(:include_self)\n field_method = stringify_options[:field_method] || :id\n\n meth = include_self ? :path : :ancestors\n meth = :\"#{meth.to_s.singularize}_ids\" if field_method == :id\n rels = send(meth, options)\n\n rels_meth = :\"stringify_#{field_method == :id ? \"resource_pairs\" : \"rels\"}\"\n Relationship.send(rels_meth, rels, stringify_options)\n end",
"def associations\n # is caching ok?\n unless @associations\n @associations = {}\n klass.relations.each{|name,association|\n @associations[name.to_s] = Association.new(association,self)\n }\n end\n @associations\n end",
"def relations_info\n self::RELATIONS_INFO\n end",
"def reciprocal_type\n :many_to_one\n end",
"def reflections_for(main, rel)\n main.class\n .reflect_on_all_associations\n .select { |r| r.macro == rel && r.options[:through].nil? }\n end",
"def parents(*args)\n Relationship.resources(parent_rels(*args))\n end",
"def get_relationships_of_type(type)\n g_command = get_command(type)\n relationships = self.send(g_command.to_sym)\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def distinct_relations(from_cache=false)\n # @@neo = Neography::Rest.new\n begin\n if from_cache\n self_node = self.get_node\n @neo.get_node_properties(node1)\n else\n self_node_id = self.get_node_id\n qur = \"start n=node(\"+self_node_id.to_s+\") match n-[r]->() return distinct(type(r)), count(r), r.magnitude;\"\n response = @@neo.execute_query(qur)\n distinct_relations = response[\"data\"]\n return distinct_relations\n end\n rescue Exception\n return nil\n end\n end",
"def linked_associations\n associations.values.select(&:linked?)\n end",
"def path_rels(*args)\n options = args.extract_options!\n rel = relationship(:raise_on_multiple => true) # TODO: Handle multiple nodes with a way to detect which node you want\n rels = rel.nil? ? [relationship_for_isolated_root] : rel.path\n Relationship.filter_by_resource_type(rels, options)\n end",
"def relationship\n return @relationship\n end",
"def related_data\n @resource.related_identifiers.where(verified: true).where(hidden: false).map do |ri|\n { relation: ri.relation_type_friendly&.camelize(:lower), identifier: ri.related_identifier }\n end || []\n end",
"def properties_via(group)\n properties = []\n property_relations_via(group).each do |relationship|\n property = relationship.property\n properties.push(property)\n end\n properties\n end",
"def non_auto_closeable_relationships\n result = []\n\n rules.each do |rule|\n next unless rule.source_jsonmodel_category == :agent\n\n rule.relationship_types.each do |relationship_type|\n if ['creation', 'succession'].include?(relationship_type)\n result << build_relationship_jsonmodel_name(rule, relationship_type)\n end\n end\n end\n\n result\n end",
"def hm_associations\n hm = []\n associations = self.reflect_on_all_associations\n associations.map {|x| hm << x.name if x.macro.to_s == \"has_many\"}\n return hm.flatten\n end",
"def liaison_relationships\n @liaison_relationships ||= person.liaison_relationships&.split(';')&.map(&:strip)\n end",
"def relationship\n relationship? ? children[1] : nil\n end"
] |
[
"0.7674651",
"0.66676754",
"0.63822305",
"0.63748515",
"0.6187852",
"0.613318",
"0.61046165",
"0.60388786",
"0.58650494",
"0.58530086",
"0.5817168",
"0.577327",
"0.57594293",
"0.57555413",
"0.5707714",
"0.5689091",
"0.5683943",
"0.56767297",
"0.56575596",
"0.56518126",
"0.56518126",
"0.563571",
"0.563445",
"0.55214965",
"0.55090207",
"0.54704964",
"0.5464858",
"0.5415227",
"0.54138523",
"0.54100513",
"0.5395139",
"0.5325303",
"0.5320898",
"0.5317803",
"0.5317359",
"0.5294327",
"0.52842456",
"0.5278111",
"0.5267568",
"0.5257361",
"0.524845",
"0.52144957",
"0.52115566",
"0.52107096",
"0.5204005",
"0.5186325",
"0.5181238",
"0.5168971",
"0.51273334",
"0.51221347",
"0.51173735",
"0.5100029",
"0.5098363",
"0.5097091",
"0.5094681",
"0.5091307",
"0.5076432",
"0.5075043",
"0.5072428",
"0.5069117",
"0.50660646",
"0.50601363",
"0.5055994",
"0.5055246",
"0.5052916",
"0.5044536",
"0.5043776",
"0.5037077",
"0.50183654",
"0.50044507",
"0.4989684",
"0.4967406",
"0.49621975",
"0.49592775",
"0.49584082",
"0.4955561",
"0.49487206",
"0.49483123",
"0.49365726",
"0.4934544",
"0.4924297",
"0.49236727",
"0.49217662",
"0.4919114",
"0.49111336",
"0.48970693",
"0.48957548",
"0.48950928",
"0.48937267",
"0.48937267",
"0.48931703",
"0.48816198",
"0.48759717",
"0.48735932",
"0.4863565",
"0.4861707",
"0.48572388",
"0.48555377",
"0.4846991",
"0.48467168"
] |
0.68165123
|
1
|
A shorthand, clear syntax for defining manytoone resource relationships.
|
def belongs_to(name, options={})
@_valid_relations = false
if options.key?(:class_name) && !options.key?(:child_key)
warn "The inferred child_key will changing to be prefixed with the relationship name #{name}. " \
"When using :class_name in belongs_to specify the :child_key explicitly to avoid problems." \
"#{caller(0)[1]}"
end
relationship = ManyToOne.setup(name, self, options)
# Please leave this in - I will release contextual serialization soon
# which requires this -- guyvdb
# TODO convert this to a hook in the plugin once hooks work on class
# methods
self.init_belongs_relationship_for_serialization(relationship) if self.respond_to?(:init_belongs_relationship_for_serialization)
relationship
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def one_relationship(name)\n end",
"def many_to_one(name, opts=OPTS, &block)\n associate(:many_to_one, name, opts, &block)\n end",
"def has_one(*args)\n require \"og/relation/has_one\"\n relations! << Og::HasOne.new(args, :owner_class => self)\n end",
"def one_to_many_relationship(rel_name, definition)\n @relationships << OneToManyRelationship.new(rel_name, definition)\n end",
"def one_to_one(name, opts=OPTS, &block)\n associate(:one_to_one, name, opts, &block)\n end",
"def has_one(*attrs)\n associate(Associations::HasOne, attrs)\n end",
"def one_to_many(name, opts={})\n singular_name = name.to_s.singularize\n ids_attr = \"#{singular_name}_ids\"\n guids_attr = \"#{singular_name}_guids\"\n\n opts[:reciprocal] ||= self.name.split('::').last.underscore.to_sym\n\n define_to_many_methods(name, singular_name, ids_attr, guids_attr)\n super\n end",
"def has_one(*attrs)\n associate(:has_one, attrs)\n end",
"def def_one_to_one(opts)\n def_one_to_many(opts)\n end",
"def one_to_many(name, opts=OPTS, &block)\n associate(:one_to_many, name, opts, &block)\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def has_one_to_many(collection, options = {})\n item = collection.to_s.singularize.to_sym\n has_many_to_many(\n item.to_s.pluralize.to_sym,\n options.merge(before_add: -> (owner, obj) { raise ActiveRecord::RecordNotUnique.new(\"#{name} can have only one #{obj.class} associated\") if owner.send(item).present? })\n )\n AnyLinks.define_singular_accessors(self, item, collection)\n end",
"def has_one(relation, options = {})\n has :one, relation, options\n end",
"def macro\n :belongs_to_related\n end",
"def model_relationships; end",
"def has_one(name, scope = nil, **options)\n # args = options.except(:null_object)\n\n # Call the real belongs_to so that the association gets defined.\n super(name, scope, **options.except(:null_object))\n\n # Modify the association if need be.\n if options[:null_object]\n add_null_object_support(name, options)\n end\n end",
"def add_relationship(rel_attr); end",
"def def_one_through_one(opts)\n def_many_to_many(opts)\n end",
"def relationship(*args)\n options = args.extract_options!\n if options[:raise_on_multiple]\n rels = relationships.take(2)\n raise _(\"Multiple relationships found\") if rels.length > 1\n rels.first\n else\n relationships.first\n end\n end",
"def belongs_to name, opts={}\n opts.merge! :type => :belongs_to, :from => self\n relation = FAP::Relation.new name, opts\n self.relations << relation\n define_relation_getter relation\n end",
"def many_to_one_relationships\n relationships unless @relationships # needs to be initialized!\n @relationships.values.collect do |rels| rels.values end.flatten.select do |relationship| relationship.child_model == self end\n end",
"def reciprocal_type\n :many_to_one\n end",
"def has_one(entity, options = {})\n entity = entity.to_s\n klass = options[:class_name] || entity.camelize\n key = options[:primary_key] || [self.name.demodulize.underscore, :id].join('_')\n from = options[:from]\n nested = options[:nested]\n as = options[:as]\n # TODO params\n\n _define_association(entity, :has_one, class_name: klass, primary_key: key, from: from, nested: nested, as: as)\n end",
"def reciprocal_type\n :one_to_many\n end",
"def reciprocal_type\n :many_to_one\n end",
"def relationship\n Relationship.new(self, CHART_R, \"../#{pn}\")\n end",
"def make_related(parent, child, resource_config)\n proc = resource_config[:relation][:create]\n proc.call(parent, child) if proc\n child\n end",
"def one_through_one(name, opts=OPTS, &block)\n associate(:one_through_one, name, opts, &block)\n end",
"def relationship\n relationship? ? children[1] : nil\n end",
"def has_one(*associations)\n options = associations.extract_options!\n self.associations += associations.map { |a| Associations::HasOneConfig.new(a, options) }\n define_association_methods(associations)\n end",
"def set_one_to_one_associated_object(opts, o)\n raise(Error, \"object #{inspect} does not have a primary key\") unless pk\n _set_associated_object(opts, o)\n end",
"def set_one_to_one_associated_object(opts, o)\n if opts.dataset_need_primary_key? && new?\n delay_validate_associated_object(opts, o)\n after_create_hook { super(opts, o) }\n o\n else\n super\n end\n end",
"def create_relation(object, metadata)\n type = @attributes[metadata.inverse_type]\n target = metadata.builder(self, object).build(type)\n target ? metadata.relation.new(self, target, metadata) : nil\n end",
"def has_many(name, *args, **opt)\n add_collection_property(name, *args, **opt)\n set_relation_field(name, args.first)\n end",
"def has_one(name, root: name, serializer:, **options)\n add_association(name, write_method: :write_one, root: root, serializer: serializer, **options)\n end",
"def initialize(name, target_model, source_model, options = {})\n klass = options.key?(:through) ? ManyToMany::Relationship : OneToMany::Relationship\n target_model ||= Extlib::Inflection.camelize(name).freeze\n @relationship = klass.new(name, target_model, source_model, options)\n end",
"def relationship_for_isolated_root\n Relationship.new(:resource => self)\n end",
"def new(*args)\n type, from_node, to_node = args\n rel = Neo4j::Relationship.create(type, from_node, to_node)\n wrapped_rel = super()\n Neo4j::IdentityMap.add(rel, wrapped_rel)\n wrapped_rel.init_on_load(rel)\n wrapped_rel.init_on_create(*args)\n wrapped_rel\n end",
"def belongs_to?; false; end",
"def def_one_to_many(opts)\n one_to_one = opts[:type] == :one_to_one\n name = opts[:name]\n key = (opts[:key] ||= opts.default_key)\n km = opts[:key_method] ||= opts[:key]\n cks = opts[:keys] = Array(key)\n opts[:key_methods] = Array(opts[:key_method])\n primary_key = (opts[:primary_key] ||= self.primary_key)\n opts[:eager_loader_key] = primary_key unless opts.has_key?(:eager_loader_key)\n cpks = opts[:primary_keys] = Array(primary_key)\n pkc = opts[:primary_key_column] ||= primary_key\n pkcs = opts[:primary_key_columns] ||= Array(pkc)\n raise(Error, \"mismatched number of keys: #{cks.inspect} vs #{cpks.inspect}\") unless cks.length == cpks.length\n uses_cks = opts[:uses_composite_keys] = cks.length > 1\n opts[:dataset] ||= opts.association_dataset_proc\n opts[:eager_loader] ||= proc do |eo|\n h = eo[:id_map]\n reciprocal = opts.reciprocal\n assign_singular = opts.assign_singular?\n delete_rn = opts.delete_row_number_column\n\n eager_load_results(opts, eo) do |assoc_record|\n assoc_record.values.delete(delete_rn) if delete_rn\n hash_key = uses_cks ? km.map{|k| assoc_record.get_column_value(k)} : assoc_record.get_column_value(km)\n next unless objects = h[hash_key]\n if assign_singular\n objects.each do |object| \n unless object.associations[name]\n object.associations[name] = assoc_record\n assoc_record.associations[reciprocal] = object if reciprocal\n end\n end\n else\n objects.each do |object| \n object.associations[name].push(assoc_record)\n assoc_record.associations[reciprocal] = object if reciprocal\n end\n end\n end\n end\n \n join_type = opts[:graph_join_type]\n select = opts[:graph_select]\n use_only_conditions = opts.include?(:graph_only_conditions)\n only_conditions = opts[:graph_only_conditions]\n conditions = opts[:graph_conditions]\n opts[:cartesian_product_number] ||= one_to_one ? 0 : 1\n graph_block = opts[:graph_block]\n opts[:eager_grapher] ||= proc do |eo|\n ds = eo[:self]\n ds = ds.graph(opts.apply_eager_graph_limit_strategy(eo[:limit_strategy], eager_graph_dataset(opts, eo)), use_only_conditions ? only_conditions : cks.zip(pkcs) + conditions, Hash[eo].merge!(:select=>select, :join_type=>eo[:join_type]||join_type, :qualify=>:deep, :from_self_alias=>eo[:from_self_alias]), &graph_block)\n # We only load reciprocals for one_to_many associations, as other reciprocals don't make sense\n ds.opts[:eager_graph][:reciprocals][eo[:table_alias]] = opts.reciprocal\n ds\n end\n \n return if opts[:read_only]\n\n save_opts = {:validate=>opts[:validate]}\n ck_nil_hash ={}\n cks.each{|k| ck_nil_hash[k] = nil}\n\n if one_to_one\n opts[:setter] ||= proc do |o|\n up_ds = _apply_association_options(opts, opts.associated_dataset.where(cks.zip(cpks.map{|k| get_column_value(k)})))\n if o\n up_ds = up_ds.exclude(o.pk_hash) unless o.new?\n cks.zip(cpks).each{|k, pk| o.set_column_value(:\"#{k}=\", get_column_value(pk))}\n end\n checked_transaction do\n up_ds.skip_limit_check.update(ck_nil_hash)\n o.save(save_opts) || raise(Sequel::Error, \"invalid associated object, cannot save\") if o\n end\n end\n opts[:_setter] = proc{|o| set_one_to_one_associated_object(opts, o)}\n else \n save_opts[:raise_on_failure] = opts[:raise_on_save_failure] != false\n\n opts[:adder] ||= proc do |o|\n cks.zip(cpks).each{|k, pk| o.set_column_value(:\"#{k}=\", get_column_value(pk))}\n o.save(save_opts)\n end\n \n opts[:remover] ||= proc do |o|\n cks.each{|k| o.set_column_value(:\"#{k}=\", nil)}\n o.save(save_opts)\n end\n\n opts[:clearer] ||= proc do\n _apply_association_options(opts, opts.associated_dataset.where(cks.zip(cpks.map{|k| get_column_value(k)}))).update(ck_nil_hash)\n end\n end\n end",
"def has_one(association, **options, &block)\n create_association(:has_one, association, options, &block)\n end",
"def child_relation; end",
"def belongs_to(*params)\n config = params.extract_options!\n name = \"#{params.join}_id\"\n schemaless_fields <<\n ::Schemaless::Field.new(name, :integer, config)\n super(*params)\n end",
"def belongs_to(relation, options = {})\n add_field relation, :belongs_to, options\n end",
"def add_this_strange_resource mixed\n assert_type('mixed', mixed, ::DataMapper::Resource)\n name_sym = mixed.class.name_sym\n rel = relationships[name_sym]\n case rel.class.shorttype\n when :dm_many_to_one\n unless self.send(name_sym).nil?\n fail(\"won't set property when it already exists: #{name_sym}\")\n end\n self.send(\"#{name_sym}=\", mixed)\n when :dm_many_to_many\n collec = self.send(name_sym)\n collec.push(mixed)\n end\n nil\n end",
"def relate_resource(resource)\n return if resource.nil?\n\n resource.collection = self\n\n unless resource.new_record?\n @cache[resource.key] = resource\n @orphans.delete(resource)\n end\n\n resource\n end",
"def create_with_back_to\n item_class = params[:resource].typus_constantize\n options = { :controller => item_class.to_resource }\n assoc = item_class.relationship_with(@resource).to_s\n send(\"set_#{assoc}_association\", item_class, options)\n end",
"def relationship_constraint(operator, lhs_operand, rhs_operand, options = {}, &block)\n constraint = RelationshipConstraint.new(self, operator, lhs_operand, rhs_operand, options, &block)\n add_unique_to_set(\"relationship\", constraint, @relationship_constraints)\n end",
"def has_many(*args)\n require \"og/relation/has_many\"\n relations! << Og::HasMany.new(args, :owner_class => self, :collection => true)\n end",
"def configure_relation\n end",
"def def_one_through_many(opts)\n def_many_through_many(opts)\n end",
"def has_one(association_name)\n add_association(:has_one, association_name.to_s.titleize, association_name)\n end",
"def relation(*args, &block)\n boot.relation(*args, &block)\n end",
"def belongs_to(relation)\n add_field relation, :belongs_to\n add_field generate_belongs_to_id(relation), :belongs_to_id # a relation is singular.\n end",
"def one(name, options={})\n configure_for_key_correspondence if options[:using] === :key\n create_association(:one, name, options)\n end",
"def <<(resource)\n relate_resource(resource)\n super\n end",
"def initialize(relationship=\"relationship\", *args)\n @relationship = relationship\n super\n end",
"def has_one(goal, options = { })\n goal.belongs_to(self) unless options[:skip_belongs_to]\n self.associate(:has_one, goal, options)\n end",
"def belongs_to?\n not property? and not multiple?\n end",
"def relation(*fields)\n inline_keys = fields.extract_options!\n if api_response?\n fields.each do |column|\n raise ArgumentError, \"You specify relation with `_id` on the end.\" if column.end_with?(\"_id\")\n\n property column, inline_keys do\n key :type, \"object\"\n key :readOnly, true\n property \"id\", type: \"integer\"\n property \"name\", type: \"string\"\n end\n end\n else\n fields.each do |column|\n property \"#{column}_id\", inline_keys do\n key :type, \"integer\"\n end\n end\n end\n end",
"def belongs_to(*attrs)\n define_rid_method = attrs[1].try(:delete, :rid)\n super.tap do\n if define_rid_method != false\n relationship_name = attrs[0]\n rel = reflections[relationship_name] || reflections[relationship_name.to_s]\n\n return if rel.options[:polymorphic] # If we don't know the class, we cannot find the record by rid.\n\n class_name = rel.options[:class_name] || relationship_name.to_s.classify\n related_class = class_name.constantize\n define_rid_accessors(related_class, relationship_name) if related_class.attribute_names.include? \"rid\"\n end\n end\n end",
"def set_one_through_one_associated_object(opts, o)\n raise(Error, \"object #{inspect} does not have a primary key\") unless pk\n raise(Error, \"associated object #{o.inspect} does not have a primary key\") if o && !o.pk\n _set_associated_object(opts, o)\n end",
"def refers_to(*args)\n require \"og/relation/refers_to\"\n relations! << Og::RefersTo.new(args, :owner_class => self)\n end",
"def relationship(rel_class)\n @relationship = rel_class\n self\n end",
"def create_relation(ways_list)\n puts 'Creating relation...'\n relation = Rosemary::Relation.new(visible: 'true')\n ways_list.each do |way_id|\n relation.members << Rosemary::Member.new('way', way_id)\n end\n relation.add_tags(route: 'bus', type: 'route')\n relation\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def one_through_many(name, through, opts=OPTS, &block)\n associate(:one_through_many, name, opts.merge(through.is_a?(Hash) ? through : {:through=>through}), &block)\n end",
"def add_ms_package_relationship(type, target)\n schema = 'http://schemas.microsoft.com/office/2006/relationships'\n @rels.push([schema + type, target])\n end",
"def has_one(name, options={})\n @builder.has_one(name, options)\n end",
"def define_relationship(opts)\n [:name, :contains_references_to_types].each do |p|\n opts[p] or raise \"No #{p} given\"\n end\n\n base = self\n\n ArchivesSpaceService.loaded_hook do\n # We hold off actually setting anything up until all models have been\n # loaded, since our relationships may need to reference a model that\n # hasn't been loaded yet.\n #\n # This is also why the :contains_references_to_types property is a proc\n # instead of a regular array--we don't want to blow up with a NameError\n # if the model hasn't been loaded yet.\n\n\n related_models = opts[:contains_references_to_types].call\n\n clz = Class.new(AbstractRelationship) do\n table = \"#{opts[:name]}_rlshp\".intern\n set_dataset(table)\n set_primary_key(:id)\n\n if !self.db.table_exists?(self.table_name)\n Log.warn(\"Table doesn't exist: #{self.table_name}\")\n end\n\n set_participating_models([base, *related_models].uniq)\n set_json_property(opts[:json_property])\n set_wants_array(opts[:is_array].nil? || opts[:is_array])\n end\n\n opts[:class_callback].call(clz) if opts[:class_callback]\n\n @relationships[opts[:name]] = clz\n\n related_models.each do |model|\n model.include(Relationships)\n model.add_relationship_dependency(opts[:name], base)\n end\n\n # Give the new relationship class a name to help with debugging\n # Example: Relationships::ResourceSubject\n Relationships.const_set(self.name + opts[:name].to_s.camelize, clz)\n\n end\n end",
"def belongs_to(*names)\n options = names.last.is_a?(Hash) ? names.pop : {}\n raise ArgumentError, 'invalid foreign key' if options.key?(:foreign_key)\n\n key_gen = ->(name,l) { :\"#{name.to_s.split('_').map {|part| part[0..l] }.join}_id\" }\n\n names.each do |name|\n key = key_gen.(name, 0)\n key = key_gen.(name, 1) if self.method_defined?(key)\n\n value = :\"#{name}_id\"\n\n Helpers.add_field(self, key, :type => BSON::ObjectId, :as => value)\n super name, options.merge(:foreign_key => key)\n end\n end",
"def association(name, *options); end",
"def has_one_params\n resource.reflect_on_all_associations(:has_one).map do |one|\n relation_param(one)\n end.compact\n end",
"def relation\n relation = nodes.reduce(root) do |a, e|\n a.associations[e.name.key].join(:join, a, e)\n end\n schema.(relation)\n end",
"def relationships\n model.relationships(repository.name)\n end",
"def set_relationship\n #find relationship\n @relationship = Relationship.find_by_id(params[:id])\n end",
"def has_one(rel_type, params = {})\n clazz = self\n module_eval(%Q{def #{rel_type}=(value)\n dsl = #{clazz}.decl_relationships[:'#{rel_type.to_s}']\n r = Neo4j::Relationships::HasN.new(self, dsl)\n r.each {|n| n.del} # delete previous relationships, only one can exist\n r << value\n r\n end}, __FILE__, __LINE__)\n\n module_eval(%Q{def #{rel_type}\n dsl = #{clazz}.decl_relationships[:'#{rel_type.to_s}']\n r = Neo4j::Relationships::HasN.new(self, dsl)\n [*r][0]\n end}, __FILE__, __LINE__)\n\n module_eval(%Q{\n def #{rel_type}_rel\n dsl = #{clazz}.decl_relationships[:'#{rel_type.to_s}']\n r = Neo4j::Relationships::HasN.new(self, dsl).rels\n [*r][0]\n end}, __FILE__, __LINE__)\n\n decl_relationships[rel_type.to_sym] = Neo4j::Relationships::DeclRelationshipDsl.new(rel_type, params)\n end",
"def relationship_related_link(attribute_name); end",
"def relation(related, arguments=[])\n self.send(related.to_sym)\n end",
"def has_one(association_name, options = {})\n database.schema[self].associations << HasManyAssociation.new(self, association_name, options)\n end",
"def def_many_to_one(opts)\n name = opts[:name]\n opts[:key] = opts.default_key unless opts.has_key?(:key)\n key = opts[:key]\n opts[:eager_loader_key] = key unless opts.has_key?(:eager_loader_key)\n cks = opts[:graph_keys] = opts[:keys] = Array(key)\n opts[:key_column] ||= key\n opts[:graph_keys] = opts[:key_columns] = Array(opts[:key_column])\n opts[:qualified_key] = opts.qualify_cur(key)\n if opts[:primary_key]\n cpks = Array(opts[:primary_key])\n raise(Error, \"mismatched number of keys: #{cks.inspect} vs #{cpks.inspect}\") unless cks.length == cpks.length\n end\n uses_cks = opts[:uses_composite_keys] = cks.length > 1\n opts[:cartesian_product_number] ||= 0\n\n if !opts.has_key?(:many_to_one_pk_lookup) &&\n (opts[:dataset] || opts[:conditions] || opts[:block] || opts[:select] ||\n (opts.has_key?(:key) && opts[:key] == nil))\n opts[:many_to_one_pk_lookup] = false\n end\n auto_assocs = @autoreloading_associations\n cks.each do |k|\n (auto_assocs[k] ||= []) << name\n end\n\n opts[:dataset] ||= opts.association_dataset_proc\n opts[:eager_loader] ||= proc do |eo|\n h = eo[:id_map]\n pk_meths = opts.primary_key_methods\n\n eager_load_results(opts, eo) do |assoc_record|\n hash_key = uses_cks ? pk_meths.map{|k| assoc_record.get_column_value(k)} : assoc_record.get_column_value(opts.primary_key_method)\n if objects = h[hash_key]\n objects.each{|object| object.associations[name] = assoc_record}\n end\n end\n end\n \n join_type = opts[:graph_join_type]\n select = opts[:graph_select]\n use_only_conditions = opts.include?(:graph_only_conditions)\n only_conditions = opts[:graph_only_conditions]\n conditions = opts[:graph_conditions]\n graph_block = opts[:graph_block]\n graph_cks = opts[:graph_keys]\n opts[:eager_grapher] ||= proc do |eo|\n ds = eo[:self]\n ds.graph(eager_graph_dataset(opts, eo), use_only_conditions ? only_conditions : opts.primary_keys.zip(graph_cks) + conditions, Hash[eo].merge!(:select=>select, :join_type=>eo[:join_type]||join_type, :qualify=>:deep, :from_self_alias=>eo[:from_self_alias]), &graph_block)\n end\n \n return if opts[:read_only]\n \n opts[:setter] ||= proc{|o| cks.zip(opts.primary_key_methods).each{|k, pk| set_column_value(:\"#{k}=\", (o.get_column_value(pk) if o))}}\n opts[:_setter] = proc{|o| set_associated_object(opts, o)}\n end",
"def belongs_to(parent_resource)\n parent_resource = parent_resource.to_sym\n parent_resources << parent_resource unless parent_resource.in?(parent_resources)\n end",
"def belongs_to(association, **options, &block)\n create_association(:belongs_to, association, options, &block)\n end",
"def has_one(direction, name = nil, options = { type: nil })\n if name.is_a?(Hash)\n options.merge(name)\n name = direction\n direction = nil\n elsif name.is_a?(Proc)\n name = direction\n direction = nil\n elsif name.nil?\n name = direction\n end\n reflections[name] = { direction: direction, type: options[:type], kind: :has_one }\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive a [HyperRecord::Collection] as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do\n @fetch_states[name] = 'i'\n self.class._promise_get(\"#{self.class.resource_base_uri}/#{self.id}/relations/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\").then do |response|\n @relations[name] = self.class._convert_json_hash_to_record(response.json[self.class.to_s.underscore][name])\n @fetch_states[name] = 'f'\n _notify_observers\n @relations[name]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a has_one association, failed to fetch records!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name] get records of the relation\n # @return [HyperRecord::Collection] either a empty one, if the data has not been fetched yet, or the\n # collection with the real data, if it has been fetched already\n define_method(name) do\n _register_observer\n if @fetch_states.has_key?(name) && 'fi'.include?(@fetch_states[name])\n @relations[name]\n elsif self.id\n send(\"promise_#{name}\")\n @relations[name]\n else\n @relations[name]\n end\n end\n # @!method update_[name] mark internal structures so that the relation data is updated once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do\n @fetch_states[name] = 'u'\n nil\n end\n # define_method(\"#{name}=\") do |arg|\n # _register_observer\n # @relations[name] = arg\n # @fetch_states[name] = 'f'\n # @relations[name]\n # end\n end",
"def has_one?; false; end",
"def has_one?; false; end",
"def relationship( name, &block )\n require_identifier!\n return if context.linkage_only?\n\n include_or_mark_partial name do\n builder = RelationshipBuilder.new( context )\n yield builder\n\n relationships = ( output[:relationships] ||= {} )\n relationships[ name.to_sym ] = builder.compile\n end\n end",
"def add_worksheet_relationship(type, target, target_mode = nil)\n @rels.push([Document_schema + type, target, target_mode])\n end",
"def belongs_to?\n true\n end",
"def create_relationship(destiny, label, bidirectional=true, active=false)\n return false if destiny.nil? or destiny == self\n edge_class = ModelFabric.get_class(SocialFramework.edge_class)\n\n edge = edge_class.where([\"(origin_id = :origin_id AND destiny_id = :destiny_id OR \n destiny_id = :origin_id AND origin_id = :destiny_id) AND label = :label\",\n { origin_id: self.id, destiny_id: destiny.id, label: label }]).first\n\n if edge.nil?\n edge = edge_class.create origin: self, destiny: destiny, active: active,\n bidirectional: bidirectional, label: label\n\n return (not edge.nil?)\n end\n\n return false\n end",
"def place(direct, preposition, target, detail = 'default')\n ItemRelationship.create!(\n source: direct,\n target: target,\n detail: detail,\n preposition: preposition\n )\nend"
] |
[
"0.67878896",
"0.67640823",
"0.6398748",
"0.6388814",
"0.6350348",
"0.6291635",
"0.62543625",
"0.6250144",
"0.62111217",
"0.61377215",
"0.6119926",
"0.6119926",
"0.6116929",
"0.6024195",
"0.5931825",
"0.58953804",
"0.58782214",
"0.58689624",
"0.5816415",
"0.5794295",
"0.57506716",
"0.5737397",
"0.57311475",
"0.57278603",
"0.56429154",
"0.56176925",
"0.56161",
"0.56102276",
"0.5595078",
"0.5517342",
"0.5512806",
"0.5502554",
"0.54955614",
"0.54905343",
"0.5487264",
"0.5479659",
"0.5466594",
"0.5412071",
"0.53968996",
"0.5395004",
"0.5375443",
"0.5358262",
"0.5342212",
"0.5333316",
"0.5320377",
"0.5313278",
"0.5311362",
"0.53077763",
"0.53038514",
"0.53030133",
"0.52996415",
"0.5297364",
"0.5281215",
"0.5272877",
"0.5265155",
"0.5257971",
"0.5255413",
"0.52520746",
"0.52338445",
"0.52337396",
"0.52281946",
"0.5220473",
"0.52003056",
"0.5192601",
"0.518557",
"0.5176359",
"0.5163677",
"0.5163677",
"0.5163677",
"0.5163677",
"0.5163677",
"0.5163677",
"0.5163677",
"0.5163677",
"0.5163677",
"0.51567197",
"0.51548886",
"0.51527137",
"0.51498914",
"0.513185",
"0.51229835",
"0.5118222",
"0.51157886",
"0.51112175",
"0.5105603",
"0.5100584",
"0.51000684",
"0.5094328",
"0.50937283",
"0.50929344",
"0.5088793",
"0.507348",
"0.50639117",
"0.5063763",
"0.5063763",
"0.5054929",
"0.5047034",
"0.50410783",
"0.5038825",
"0.5036603"
] |
0.53172755
|
45
|
for cancancan GET /food_products GET /food_products.json
|
def index
@food_products = FoodProduct.where(group_id: @groups)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def products\n request :public, :get, :products\n end",
"def index\n @food_products = FoodProduct.all\n render json: @food_products\n end",
"def show\n render json: @food_product\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 get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"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 # 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 @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 products\n end",
"def products\n run(:get,\"/school_products\", [200])\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 index\n @food_products = FoodProduct.all\n end",
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def show\n render json: @product\n end",
"def show\n respond_to do |format|\n format.html {render \"products/show\"}\n format.json {\n product = Product.where(id: params[:id]).includes(:category).first\n render json: product.as_json(include: [:category, :photo])\n }\n end\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 list_by_category\n category = Category.where(id: params[:category_id])\n if category.any? then\n @products = category.first.products\n if @products.any? then \n render json: @products, status: 200\n else\n render json: { message: \"Não há produtos associados a categoria informada\" }, status: 404\n end\n else\n render json: { message: \"Não foi encontrada a categoria informada\" }, status: 404\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 index\n respond_to do |format|\n format.html\n format.json {\n if params[:filter]\n json_filter = JSON.parse(params[:filter])\n filter = Product.filter json_filter\n\n product_ids = Product.search_for_ids json_filter[\"query\"], :per_page => 10000\n @products = Product.where(id: product_ids).where(filter)\n else\n @products = Product.all\n end\n\n render json: @products.includes(:category).as_json(include: [:category, :photo])\n }\n end\n end",
"def show\n render json: @product, status: 200\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: @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 json_response(params)\n end",
"def index\n \tproducts = Product.all\n \trender json: products\n \tend",
"def index\n @products = Product.all\n render json: @products\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 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 items\n @beverages = Beverage.available\n respond_to do |format|\n format.json { render :json => @beverages.to_json(methods: :image_url)}\n end\n end",
"def show\n @category = Category.find(params[:id])\n @search = @category.products.search(params[:q])\n @products = @search.result.page(params[:page]).per(current_user.list_page_size)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\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 show\n render :json => Producto.find(params[:id])\n end",
"def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end",
"def index\n\t@products = Product.where(:inventory => true).order(:category_id).page(params[:page])\n @donors = Donor.all\n @categories = Category.all\n @products2 = Product.where(:inventory => false).order(:category_id)\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 find_products\n end",
"def show\n json_response(@api_v1_product)\n end",
"def get_products_by_category\n json_response({ message: 'NOT IMPLEMENTED' })\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 @product = Product.find(params[:id])\n\n render json: @product\n end",
"def show\n @items = cart.items\n @products = @items.collect(&:product)\n \n respond_to do |format|\n format.html { render layout: false } \n format.json { render json: @items }\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 index\n render :json => Producto.all\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 index\n json_response(current_restaurant.restaurant_food_items)\n end",
"def index\n b_admin = current_user.admin? rescue false\n @products = Product.filter_by_params(b_admin, params)\n #@products = Product.available\n \n @title = Product.page_description(params)\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 render json: @product_management\n end",
"def items\n \tbegin\n \t@categories = Category.all.includes(items: [:dimensions])\n \t@ingredients = Ingredient.actives\n \trender 'api/v1/home/items', status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def show\n json_response(@food_item)\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 \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 @api_v1_products = Product.all\n json_response(@api_v1_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 index\n @products = Product.order('item_code ASC').page(params[:page]).per(25)\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 FarMar::Product.by_vendor(id)\n end",
"def products\n FarMar::Product.by_vendor(id)\n end",
"def show \n user = current_user.user_info\n product = user.products.find(params[:id]) if !user.admin\n product = Product.find(params[:id]) if user.admin \n # respond_to do |format|\n # format.html # show.html.erb\n # format.json { render json: @product }\n # end\n p = ShopifyAPI::Product.find product.shopify_id\n redirect_to 'http://shopulse.myshopify.com/products/'+p.handle\n end",
"def products\n Product.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 @tipo_products = TipoProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_products }\n end\n end",
"def index\n @products = @co.products\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 = @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 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 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 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 begin\n @products = Product.all\n render json: @products, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end",
"def get_products_by_ids\n products_ids = params[:products_ids]\n products = Array.new\n JSON.parse(products_ids).each do |product_id|\n product = Product.find_by_id(product_id)\n if product\n products.push(product)\n end\n end\n render json: {products: serialized_products(products)}, status: :ok\n end",
"def show\n @product_cat = ProductCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_cat }\n end\n end",
"def product\n request = Request.where(user_id: [params[:user_id]])\n render :json => request.as_json\n end",
"def index\n @products = Product.order('category, priority desc, price')\n @basket_size = count_basket_items\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def search\n if (params[:category] == 'Categories')\n @products = Product.select('products.*, categories.name AS category_name').joins(:category).where(category_id: params[:id])\n else\n @products = Product.select('products.*, categories.name AS category_name').joins(:category).where(id: params[:id])\n end\n render json: @products.as_json(methods: :avatar_url)\n end",
"def show\n @breadcrumb = 'read'\n @product_type = ProductType.find(params[:id])\n @products = @product_type.products.paginate(:page => params[:page], :per_page => per_page).order('product_code')\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_type }\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 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 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 get_authorization_products_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AuthorizationApi.get_authorization_products ...\"\n end\n \n # resource path\n local_var_path = \"/api/v2/authorization/products\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\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 => 'OrganizationProductEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AuthorizationApi#get_authorization_products\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n product = Product.find(params[:id])\n render json: product, include: :category\n rescue ActiveRecord::RecordNotFound\n product = Product.new\n product.errors.add(:id, \"Wrong ID provided\")\n render json: product, status: 404, serializer: ActiveModel::Serializer::ErrorSerializer\n end",
"def index\n @products = Product.all\n render json: {is_success: true, error_code: 200, message: \"Products Found Successfully\", result: @products}, status: 200\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 @products = Spree::Product.not_deleted.includes(:variants).page(params[:page]).per(Spree::Config[:orders_per_page])\n respond_with @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 show\n @users_products_wanted_action = UsersProductsWantedAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users_products_wanted_action }\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 render json: @pizza\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 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 @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopifyproduct }\n end\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 index\n if params[:categoria_producto]\n render json: Producto.find(params[:producto_id]).categorias\n else\n\t\t @categorias = Categoria.all\n render json: @categorias\n end\n\tend",
"def products\n @products = Product.where(florist_id: session[\"found_florist_id\"]).order(\"status\", \"product_type\", \"name\").paginate(:page => params[:page], :per_page => 25) \n @PRODUCT_UPDATE_MUST_HAVE = PRODUCT_UPDATE_MUST_HAVE\n render(:products) and return\n end",
"def show\n #@category = Category.find(params[:id])\n @products = @category.products.all\n @max = @category.products.maximum(:price)\n @colors = @category.products.select(:params).distinct\n respond_to do |format|\n format.json { render :json => {:category => @category,\n :products => @products,\n :colors => @colors,\n :maxprice => @max\n } }\n end\n end",
"def show\n\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\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 index\n @product_cats = ProductCat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_cats }\n end\n end",
"def index\n # TODO: implement search\n if product_params != {}\n @products = filter_products(product_params[:product]) # app/controllers/concerns/filter_products.rb\n else\n @products = Product.all\n end\n\n respond_to do |format|\n format.html\n format.js\n format.json { render json: @products }\n end\n\n end"
] |
[
"0.7486446",
"0.7455785",
"0.73694324",
"0.71438366",
"0.6909205",
"0.6874169",
"0.68394256",
"0.6812788",
"0.6777962",
"0.67466384",
"0.6715071",
"0.671431",
"0.66903335",
"0.66789186",
"0.6673837",
"0.6659579",
"0.6640164",
"0.6638377",
"0.662694",
"0.66268665",
"0.66251516",
"0.66156775",
"0.66001093",
"0.6589391",
"0.6586897",
"0.6574727",
"0.65675515",
"0.6560773",
"0.65574473",
"0.65541387",
"0.65346533",
"0.65221435",
"0.6516545",
"0.6514285",
"0.6494668",
"0.64909554",
"0.6488341",
"0.64770144",
"0.6473018",
"0.6469587",
"0.64672834",
"0.6465335",
"0.6459985",
"0.64581114",
"0.6456285",
"0.64547306",
"0.64515495",
"0.64425546",
"0.6441543",
"0.6429786",
"0.64184725",
"0.64160925",
"0.6404292",
"0.63923925",
"0.63923925",
"0.6384568",
"0.6380682",
"0.63790935",
"0.63768417",
"0.635734",
"0.6351646",
"0.63516456",
"0.63516456",
"0.63516456",
"0.634635",
"0.634375",
"0.6333942",
"0.63335085",
"0.63335085",
"0.63335085",
"0.63335085",
"0.6330474",
"0.632599",
"0.631819",
"0.63166416",
"0.6316379",
"0.63160163",
"0.6305343",
"0.63045794",
"0.6295748",
"0.62937987",
"0.6292436",
"0.6283174",
"0.6281923",
"0.62799466",
"0.62789625",
"0.62753206",
"0.6271911",
"0.6267031",
"0.62597364",
"0.62510675",
"0.6249698",
"0.6246784",
"0.6245636",
"0.6241176",
"0.62337995",
"0.6223196",
"0.6222981",
"0.621212",
"0.62072766",
"0.6205744"
] |
0.0
|
-1
|
GET /food_products/1 GET /food_products/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @food_products = FoodProduct.all\n render json: @food_products\n end",
"def show\n render json: @food_product\n end",
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end",
"def show\n product = Product.find_by_id(params[:id])\n\n render json: product\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 @product = Product.find(params[:id])\n\n render json: @product\n end",
"def show\n @product = Product.find(params[:id])\n json_response(params)\n end",
"def show\n json_response(@api_v1_product)\n end",
"def show\n\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end",
"def show\n render json: @product, status: 200\n end",
"def show\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end",
"def show\n render :json => Producto.find(params[:id])\n end",
"def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \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 render json: @products\n end",
"def index\n @food_products = FoodProduct.all\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 @product = Product.find(params[:id])\n render json: @product, status: :ok\n end",
"def show\n render json: @product\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 \tproducts = Product.all\n \trender json: products\n \tend",
"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 @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(params[:id])\n\n render json: @product\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 food_info(food_id)\n get(\"/foods/#{food_id}.json\")\n end",
"def show\n @fooditem = Fooditem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @fooditem }\n end\n end",
"def rating(food)\n url = 'https://thereportoftheweek-api.herokuapp.com/reports'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n result = JSON.parse(response)\n puts result[7]['product']\n \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 render json: @product\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 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 index\n @products = Product.all\n respond_to do |format|\n format.html\n format.json { render :json => @product }\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 json_response(@food_item)\n end",
"def show\n @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopifyproduct }\n end\n end",
"def index\n render :json => Producto.all\n end",
"def show\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_recipe }\n end\n end",
"def index\n @tipo_products = TipoProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_products }\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 respond_to do |format|\n format.html {render \"products/show\"}\n format.json {\n product = Product.where(id: params[:id]).includes(:category).first\n render json: product.as_json(include: [:category, :photo])\n }\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 show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\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\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 @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 @product_item = ProductItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_item }\n end\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 index\n json_response(current_restaurant.restaurant_food_items)\n end",
"def show\n @favourite_food = FavouriteFood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favourite_food }\n end\n end",
"def show\n @product2 = Product2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product2 }\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 @tipo_product = TipoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_product }\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 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 @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 @star_product = Star::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @star_product }\n end\n end",
"def index\n @product_images = ProductImage.where(product_uuid: params[:product_id])\n render json: @product_images, status: 200\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 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 @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 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_cat = ProductCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_cat }\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 = Product.find(params[:id])\n render json: product, include: :category\n rescue ActiveRecord::RecordNotFound\n product = Product.new\n product.errors.add(:id, \"Wrong ID provided\")\n render json: product, status: 404, serializer: ActiveModel::Serializer::ErrorSerializer\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 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 products = Product.all\n render json: {message: \"ok\", data: products}\n puts \"hello\"\n\n end"
] |
[
"0.77522504",
"0.75690866",
"0.723285",
"0.7161735",
"0.70759034",
"0.70320964",
"0.6994874",
"0.6985488",
"0.6953214",
"0.6909264",
"0.6893125",
"0.68811864",
"0.6875878",
"0.6875856",
"0.6868638",
"0.6848525",
"0.68176115",
"0.67991483",
"0.67706245",
"0.67700666",
"0.6759992",
"0.6753824",
"0.67445844",
"0.67324",
"0.67282885",
"0.6725383",
"0.6725033",
"0.6725033",
"0.6725033",
"0.67246175",
"0.67131066",
"0.6707681",
"0.6704572",
"0.6698785",
"0.6690166",
"0.6690166",
"0.6690166",
"0.6690166",
"0.6688559",
"0.668827",
"0.66794187",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.6678828",
"0.66785866",
"0.66752243",
"0.6657819",
"0.66563916",
"0.66532326",
"0.665105",
"0.6643937",
"0.6643442",
"0.66418797",
"0.6630897",
"0.6630897",
"0.6630897",
"0.66153574",
"0.6605099",
"0.6598336",
"0.65917826",
"0.6578448",
"0.65783215",
"0.6558143",
"0.6546397",
"0.6544557",
"0.65263784",
"0.6525095",
"0.6520075",
"0.6519383",
"0.6504204",
"0.649613",
"0.6490003",
"0.6487734",
"0.6485639",
"0.64824486",
"0.64773774",
"0.64755714",
"0.6466752",
"0.64655715",
"0.6460104",
"0.6452917",
"0.6452445",
"0.6439445",
"0.6435968"
] |
0.0
|
-1
|
POST /food_products POST /food_products.json
|
def create
@food_product = FoodProduct.new(food_product_params)
respond_to do |format|
if @food_product.save
format.html { redirect_to @food_product, notice: 'Food product was successfully created.' }
format.json { render :show, status: :created, location: @food_product }
else
format.html { render :new }
format.json { render json: @food_product.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @food_product = FoodProduct.new(food_product_params)\n\n respond_to do |format|\n if @food_product.save\n format.html { redirect_to @food_product, notice: \"Food product was successfully created.\" }\n format.json { render :show, status: :created, location: @food_product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @food_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @food_product = FoodProduct.new(food_product_params)\n @food_product.save\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_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 @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\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\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 = 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.create!(product_params)\n json_response(@product, :created)\n end",
"def index\n @food_products = FoodProduct.all\n render json: @food_products\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 json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :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 # @order = Order.new() \n total = 0\n \n @order = Order.new()\n for product in params[:_json]\n \n if (product[:quantity].nil? || product[:quantity].to_f < 1 || !isint(product[:quantity]))\n # Handle case when order invalid quantity\n render json: \"\", status: :bad_request\n return\n end\n\n @product = Product.find_by_name_and_size_id(product[:product], product[:size]) \n if @product.nil?\n # Handle case when order invalid products\n render json: \"\", status: :not_found\n return\n end \n total = total + @product.price * product[:quantity].to_f \n @order.orders_products << OrdersProduct.new(:product => @product, :hot => product[:hot], :quantity => product[:quantity]) \n end \n\n @order.total = total\n\n if @order.save\n render json: @order, status: :created, location: @order\n else\n render json: @order.errors, status: :unprocessable_entity\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 = 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 @product = Product.create(product_params)\n if @product.save\n # Respond to html with a redirect and json\n respond_to do |format|\n format.html do\n flash[:notice] = 'Product added'\n redirect_to products_path\n end\n format.json do\n render json: product.to_json\n end\n end\n else\n # Respond to html with a redirect and json\n respond_to do |format|\n format.html do\n flash.now[:error] = 'Error adding product'\n render :new\n end\n format.json do\n render json: { errors: @product.errors.full_messages }, status: 422\n end\n end\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 food_product_params\n params.require(:food_product).permit(:name)\n end",
"def create\n @raw_food = current_merchant.raw_foods.new(raw_food_params)\n\n respond_to do |format|\n if @raw_food.save\n format.html { redirect_to @raw_food, notice: 'Raw food was successfully created.' }\n format.json { render :show, status: :created, location: @raw_food }\n else\n format.html { render :new }\n format.json { render json: @raw_food.errors, status: :unprocessable_entity }\n end\n end\n @raw_food.ordering_method_ids = params[:raw_food][:ordering_method_ids]\n @raw_food.delivery_location_ids = params[:raw_food][:delivery_location_ids]\n @raw_food.online_retail_service_type_ids = params[:raw_food][:online_retail_service_type_ids]\n @raw_food.raw_food_product_category_ids = params[:raw_food][:raw_food_product_category_ids]\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 @recipe_prod = RecipeProd.new(recipe_prod_params)\n\n respond_to do |format|\n if @recipe_prod.save\n format.html { redirect_to @recipe_prod, notice: 'Recipe prod was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_prod }\n else\n format.html { render :new }\n format.json { render json: @recipe_prod.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 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 addProd()\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.new(name: params[:name], price: params[:price].to_f, category_id: params[:cat_id], picture_list: '[]')\n status = p.save\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 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: 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 @food = Food.new(food_params)\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: 'Food was successfully created.' }\n format.json { render :show, status: :created, location: @food }\n else\n format.html { render :new }\n format.json { render json: @food.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 food_params\n params.require(:food).permit(:name, :description, :image_url, :price,\n :category_id, :restaurant_id,\n tag_ids: [])\n end",
"def create\n @fish_product = FishProduct.new(fish_product_params)\n\n respond_to do |format|\n if @fish_product.save\n format.html { redirect_to @fish_product, notice: 'Fish product was successfully created.' }\n format.json { render :show, status: :created, location: @fish_product }\n else\n format.html { render :new }\n format.json { render json: @fish_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 create\n @food = Food.new(params[:food])\n\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: \"Piatto creato correttamente.\" }\n format.json { render json: @food, status: :created, location: @food }\n else\n format.html { render action: \"new\" }\n format.json { render json: @food.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 @fooditem = Fooditem.new(params[:fooditem])\n\n respond_to do |format|\n if @fooditem.save\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully created.' }\n format.json { render :json => @fooditem, :status => :created, :location => @fooditem }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\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 @recipes_food = RecipesFood.new(recipes_food_params)\n\n respond_to do |format|\n if @recipes_food.save\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully created.' }\n format.json { render :show, status: :created, location: @recipes_food }\n else\n format.html { render :new }\n format.json { render json: @recipes_food.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 @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 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 send_product(product)\n request(product, \"product\", :post, {method: \"add\"})\n end",
"def create\n @shopifyproduct = Shopifyproduct.new(params[:shopifyproduct])\n\n respond_to do |format|\n if @shopifyproduct.save\n format.html { redirect_to @shopifyproduct, notice: 'Shopifyproduct was successfully created.' }\n format.json { render json: @shopifyproduct, status: :created, location: @shopifyproduct }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shopifyproduct.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: @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 render json: Beverage.create!(beverage_post_params), status: :created\n end",
"def create\n @product = Product.new(product_params)\n @product.save\n set_products\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 show\n render json: @food_product\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 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,\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",
"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 food_params\n params.require(:food).permit(:title, :description, :image_url, :price, :category_id)\n end",
"def create\n @product = Product.new(params[:product])\n\n if @product.save\n \n respond_with(@product, :location=>products_url)\n else\n respond_with(@product, :head=>:bad_request)\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, status: :unprocessable_entity }\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 = 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 action: 'show', 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 @fast_food = FastFood.new(fast_food_params)\n\n respond_to do |format|\n if @fast_food.save\n format.html { redirect_to @fast_food, notice: 'Fast food was successfully created.' }\n format.json { render :show, status: :created, location: @fast_food }\n else\n format.html { render :new }\n format.json { render json: @fast_food.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 action: 'show', 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 action: 'show', 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"
] |
[
"0.7275234",
"0.7096893",
"0.6948125",
"0.6941118",
"0.6929887",
"0.6896571",
"0.68398184",
"0.68259233",
"0.68062246",
"0.6765456",
"0.67191714",
"0.6716081",
"0.6653273",
"0.6620721",
"0.66092646",
"0.6593801",
"0.65681094",
"0.6561806",
"0.6544878",
"0.65330684",
"0.6502259",
"0.6487585",
"0.6479379",
"0.64731145",
"0.6466937",
"0.6465617",
"0.64453244",
"0.64428437",
"0.64421844",
"0.64421844",
"0.64421844",
"0.64404416",
"0.6437143",
"0.64321166",
"0.6424936",
"0.642323",
"0.641547",
"0.6396859",
"0.6391057",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.6387152",
"0.63832253",
"0.63797617",
"0.637814",
"0.6373337",
"0.6369529",
"0.6366148",
"0.63639385",
"0.63574743",
"0.6345595",
"0.6340284",
"0.63319385",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6328131",
"0.6327648",
"0.63275737",
"0.6326907",
"0.6318176",
"0.63165677",
"0.63113236",
"0.62913704",
"0.62812996",
"0.62759995",
"0.62759995"
] |
0.7284388
|
0
|
PATCH/PUT /food_products/1 PATCH/PUT /food_products/1.json
|
def update
respond_to do |format|
if @food_product.update(food_product_params)
format.html { redirect_to @food_product, notice: 'Food product was successfully updated.' }
format.json { render :show, status: :ok, location: @food_product }
else
format.html { render :edit }
format.json { render json: @food_product.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @food_product.update(food_product_params)\n end",
"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 respond_to do |format|\n if @food_product.update(food_product_params)\n format.html { redirect_to @food_product, notice: \"Food product was successfully updated.\" }\n format.json { render :show, status: :ok, location: @food_product }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @food_product.errors, status: :unprocessable_entity }\n end\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 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 product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end",
"def update\n json_response(@food_item.update!(food_item_params))\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 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 \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 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 ingredient.update(ingredient_params)\n render json: ingredient\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 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 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 @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to foods_path(), notice: 'Food was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # if no checkboxes were checked, set the options to nil\n params[:food][:color_ids] ||= []\n params[:food][:grown_ids] ||= []\n params[:food][:pack_ids] ||= []\n params[:food][:per_case_ids] ||= []\n params[:food][:size_ids] ||= []\n params[:food][:weight_ids] ||= []\n # set the attributes from the submitted form\n @food = Food.find(params[:id])\n if params[:food][:parent_id] == params[:id]\n flash[:notice] = \"Can't set the parent to be the same as this product!\"\n redirect_to food_url(@food)\n else\n respond_to do |format|\n params[:food][:updated_by] = @current_user.email\n if @food.update_attributes(params[:food])\n flash[:notice] = 'Food was successfully updated.'\n format.html { redirect_to food_url(@food) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @food.errors.to_xml }\n end\n end\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 @food.update(food_params)\n respond_with @food, location: -> { kitchen_board_path }\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 @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 @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 @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: 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,\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 @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 @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 @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\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.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 #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 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 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.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\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.update(product_params)\n set_products\n end",
"def update\n @angular = Product.find(params[:id])\n \n @angular.update_attributes(title: params[:products][:title], description: params[:products][:description])\n respond_to do |format|\n if @angular.valid?\n format.html { redirect_to store_index_path, 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: @angular.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 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 @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 respond_to do |format|\n if @recipe_prod.update(recipe_prod_params)\n format.html { redirect_to @recipe_prod, notice: 'Recipe prod was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_prod }\n else\n format.html { render :edit }\n format.json { render json: @recipe_prod.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\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\n @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to @food, notice: \"Piatto aggiornato correttamente.\" }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product1.update(product1_params)\n format.html { redirect_to @product1, notice: \"Product1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @product1.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 respond_to do |format|\n if @recipes_food.update(recipes_food_params)\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipes_food }\n else\n format.html { render :edit }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = TempProduct.find(params[:id])\n @product.qty = params[:qty]\n # save product\n if @product.save\n # success\n render :json => { :success => true }\n else\n # failed\n render :json => { :success => false }\n end\n end",
"def update\n respond_to do |format|\n if @food.update(food_params)\n format.html { redirect_to @food, notice: 'Food was successfully updated.' }\n format.json { render :show, status: :ok, location: @food }\n else\n format.html { render :edit }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @my_product.update(my_product_params)\n render :show, status: :ok\n else\n render json: @my_product.errors, status: :unprocessable_entity\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: '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 update\n respond_to do |format|\n if @fish_product.update(fish_product_params)\n format.html { redirect_to @fish_product, notice: 'Fish product was successfully updated.' }\n format.json { render :show, status: :ok, location: @fish_product }\n else\n format.html { render :edit }\n format.json { render json: @fish_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: @sub_product.errors unless @sub_product.update(sub_product_params)\n end",
"def update\n render json: @sub_product.errors unless @sub_product.update(sub_product_params)\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: t('.message') }\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 @fast_food.update(fast_food_params)\n format.html { redirect_to @fast_food, notice: 'Fast food was successfully updated.' }\n format.json { render :show, status: :ok, location: @fast_food }\n else\n format.html { render :edit }\n format.json { render json: @fast_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @os_product.update(os_product_params)\n format.html { redirect_to @os_product, notice: 'Os product was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_product }\n else\n format.html { render :edit }\n format.json { render json: @os_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 @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 @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 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 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 do\n redirect_to @product, notice: 'Product was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit , status: :unprocessable_entity }\n format.json do\n render json: @product.errors, status: :unprocessable_entity\n end\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 @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: '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.6999992",
"0.6905472",
"0.68577296",
"0.675926",
"0.6714217",
"0.6700601",
"0.6601842",
"0.659857",
"0.6578815",
"0.65099925",
"0.6509841",
"0.6504303",
"0.64839053",
"0.6473083",
"0.64670897",
"0.64427775",
"0.6439398",
"0.64362687",
"0.64219916",
"0.6421374",
"0.64198744",
"0.64177173",
"0.64177173",
"0.64158404",
"0.64158404",
"0.6413109",
"0.64113516",
"0.6410895",
"0.63967955",
"0.6394599",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.63945943",
"0.6390985",
"0.6382178",
"0.6381273",
"0.6381273",
"0.6381273",
"0.6381273",
"0.6381273",
"0.6379738",
"0.63725704",
"0.6371274",
"0.63589334",
"0.63575965",
"0.6357372",
"0.63558656",
"0.635541",
"0.6354047",
"0.6352074",
"0.6343819",
"0.6334322",
"0.63307065",
"0.6327168",
"0.632293",
"0.63069147",
"0.6299413",
"0.6299246",
"0.62801665",
"0.62785256",
"0.62752825",
"0.6274634",
"0.6274634",
"0.62721425",
"0.62711215",
"0.6263364",
"0.626156",
"0.62611735",
"0.6257699",
"0.6257297",
"0.6255875",
"0.6251917",
"0.62508786",
"0.624733",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245",
"0.6246245"
] |
0.6862493
|
2
|
DELETE /food_products/1 DELETE /food_products/1.json
|
def destroy
@food_product.destroy
respond_to do |format|
format.html { redirect_to food_products_url, notice: 'Food product was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @food_product.destroy\n respond_to do |format|\n format.html { redirect_to food_products_url, notice: \"Food product was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end",
"def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\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 delete_product(id)\n @client.raw('delete', \"/ecommerce/products/#{id}\")\n end",
"def destroy\n @product.destroy\n\n render json: @product, status: :ok#, location: @collection\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 @fooditem = Fooditem.find(params[:id])\n @fooditem.destroy\n\n respond_to do |format|\n format.html { redirect_to fooditems_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @product.destroy\n render json: {}\n end",
"def destroy\n @food_product.destroy\n end",
"def destroy\n p @product.destroy!\n render json: { result: 'deleted' }, status: :ok\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 delete\n client.delete(\"/#{id}\")\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 @food_recipe = FoodRecipe.find(params[:id])\n @food_recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to food_recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.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 @food_item.destroy\n respond_to do |format|\n format.html { redirect_to food_items_url, notice: \"Food item was successfully destroyed.\" }\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 @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 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 @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food 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 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 delete(*rest) end",
"def destroy\n product = Product.find(params[:id])\n product.destroy\n render json: {id: product.id}\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 @fast_food.destroy\n respond_to do |format|\n format.html { redirect_to fast_foods_url, notice: 'Fast food 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 @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 :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 @shopifyproduct = Shopifyproduct.find(params[:id])\n @shopifyproduct.destroy\n\n respond_to do |format|\n format.html { redirect_to shopifyproducts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foodlog = Foodlog.find(params[:id])\n @foodlog.destroy\n\n respond_to do |format|\n format.html { redirect_to foodlogs_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 @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 @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.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 @recipes_food.destroy\n respond_to do |format|\n format.html { redirect_to recipes_foods_url, notice: 'Recipes food 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 root_url }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\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 @food.destroy\n respond_to do |format|\n format.html { redirect_to @restaurant, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fooddiary.destroy\n respond_to do |format|\n format.html { redirect_to food_fooddiaries_url(@food.id) }\n format.json { head :no_content }\n end\n end",
"def destroy_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\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 = 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 = 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 @animal_food.destroy\n respond_to do |format|\n format.html { redirect_to animal_foods_url, notice: \"Animal food was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store_detail = StoreDetail.find(params[:store_detail_id])\n @food = Food.find(params[:id])\n @food.destroy\n respond_to do |format|\n format.html { redirect_to store_detail_foods_path(@store_detail), notice: 'Food detail 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 @food_expenditure.destroy\n respond_to do |format|\n format.html { redirect_to food_expenditures_url, notice: 'FoodExpenditure was successfully destroyed.' }\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 @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 @food.destroy\n\n respond_to do |format|\n format.html { redirect_to(foods_url) }\n format.xml { head :ok }\n end\n end",
"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 @raw_food.destroy\n respond_to do |format|\n format.html { redirect_to raw_foods_url, notice: 'Raw food 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 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 products_url, notice: 'Your product was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite_food = FavouriteFood.find(params[:id])\n @favourite_food.destroy\n\n respond_to do |format|\n format.html { redirect_to favourite_foods_url }\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 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 request(:delete)\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully deleted.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.72047395",
"0.72025514",
"0.71572655",
"0.71572655",
"0.7142773",
"0.71215916",
"0.71050525",
"0.70933443",
"0.7082751",
"0.7052677",
"0.7011949",
"0.70056254",
"0.69896096",
"0.6960052",
"0.69495416",
"0.6920785",
"0.6920785",
"0.6920785",
"0.6913939",
"0.69056326",
"0.68919116",
"0.6886919",
"0.6883118",
"0.6881464",
"0.6875399",
"0.6875399",
"0.6875399",
"0.6874204",
"0.6874204",
"0.6874204",
"0.6874204",
"0.6874204",
"0.6874204",
"0.68692875",
"0.68611866",
"0.68595976",
"0.6846668",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845248",
"0.6845239",
"0.6845216",
"0.6845216",
"0.6845216",
"0.68422896",
"0.68389904",
"0.6832184",
"0.68319577",
"0.68307406",
"0.68302363",
"0.6827873",
"0.682725",
"0.68087995",
"0.680784",
"0.68065757",
"0.68045974",
"0.6800729",
"0.6797182",
"0.67969763",
"0.6782869",
"0.6781024",
"0.6773345",
"0.67712224",
"0.67694247",
"0.67669415",
"0.6766921",
"0.676437",
"0.67635715",
"0.6761236",
"0.6760508",
"0.67323047",
"0.67311794",
"0.6729168",
"0.67284566",
"0.6727211",
"0.67249185"
] |
0.7205989
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def set_food_product
@food_product = FoodProduct.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 food_product_params
params.require(:food_product).permit(:group_id, :name, :first_day_num, :second_day_num, :is_cooking, :start)
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
|
attr_reader :threads2frames Hash[thread_id] > top_frame
|
def adjust_frame(frame_num, absolute_pos)
frame, frame_num = get_frame(frame_num, absolute_pos)
if frame
@frame = frame
@frame.index = frame_num
prefix = "--> ##{frame_num} "
unless @settings[:traceprint]
msg("#{prefix}%s" %
@frame.describe(:basename => settings[:basename],
:maxwidth => settings[:maxwidth] - prefix.size,
:callstyle => settings[:callstyle]))
end
@line_no = @frame.line
@frame
else
nil
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def frames; end",
"def frame_teardown\n @top_frame = @frame = @current_thread = nil \n @threads2frames = {}\n end",
"def catchupFrames(fromFrameNo, toFrameNo)\r\n #puts \"#{fromFrameNo} --> #{toFrameNo}\"\r\n for i in fromFrameNo..toFrameNo do\r\n #puts \"Catching up frame #{i}:\";\r\n if @frames.length <= i then\r\n @frames[i] = Frame.new(self);\r\n @frames[i-1].pixmaps.each do |pixmap|\r\n @frames[i].addPixmap(pixmap)\r\n end\r\n end\r\n end\r\n return @frames[toFrameNo];\r\n end",
"def setup_frames\n @frames ||=\n begin\n frames = 10.times.map {|i| Frame.new(i+1,0,0,0,nil)}\n # link frames\n (0...9).each {|i| frames[i].next_frame = frames[i+1]}\n frames\n end\n end",
"def frames\n _nudge[3]\n end",
"def frame?\n current_frame = []\n @scorecard.each do |key, value|\n current_frame << key if value.framescore[:roll_1].nil? || value.framescore[:roll_2].nil?\n end\n current_frame.sort\n # to get the current frame as an integer, use this:\n # p current_frame[0][-1].to_i\n current_frame[0]\n end",
"def get_triage_frames(board_id)\n widgets_url = URI(\"https://api.miro.com/v1/boards/#{board_id}/widgets\")\n result = send_get(widgets_url)\n widgets_collection = JSON.parse(result)\n # puts CIGREEN + \"WIDGETS COLLECTION: \" + CEND + \"#{result}\"\n widgets = widgets_collection[\"data\"]\n tframes = Hash.new\n widgets.each do |widget|\n if is_triage_frame(widget)\n subtitle = get_tframe_subtitle(widget)\n puts CIGREEN + \"TRIAGE FRAME FOUND with subtitle: \" + CEND + \"#{subtitle}\"\n tframes[subtitle] = widget\n end\n end\n return tframes\nend",
"def frame\n (@frame || 1).to_f\n end",
"def frame(id); end",
"def last_frame; frames.last; end",
"def frame; end",
"def top=(val) @img_stack.top = val; end",
"def stack_top\n\n Lib.lua_gettop(@pointer)\n end",
"def initialize\n @top = nil\n end",
"def build_frames\n prev_frame = nil\n 10.times.map do |frame_number|\n prev_frame = Frame.new(10 - frame_number, prev_frame)\n end.reverse!\n end",
"def current_frame\n @callstack.top\n end",
"def frame\n context.frame\n end",
"def calculate_thread_times\r\n # Cache thread times since this is an expensive\r\n # operation with the required sorting \r\n @result.threads.each do |thread_id, methods|\r\n top = methods.sort.last\r\n \r\n thread_time = 0.01\r\n thread_time = top.total_time if top.total_time > 0\r\n\r\n @thread_times[thread_id] = thread_time \r\n end\r\n end",
"def hash\n @hash ||= @trace_id.hash ^ @is_new.hash ^ @span_id.hash ^\n @sampled.hash ^ @capture_stack.hash\n end",
"def last_frame_with_previous_spare\n return false if number < 11\n\n previous_frame.spare\n end",
"def c_frame?; end",
"def get_multithread_data thread_arr, parent_thread = nil\n resultant_fiber = {}\n\n thread_arr.each { |current_thread|\n current_thread.keys.each { |key|\n # if parent_thread is provided then merge data with that thread instead\n if parent_thread\n parent_thread[key] = current_thread[key]\n else\n resultant_fiber[key] = current_thread[key]\n end\n }\n\n # if current thread's status is stopped or anything else than running then remove that thread from list\n thread_arr.reject { |thread|\n thread[:thread_id] == current_thread[:thread_id]\n } if not current_thread.status \n }\n\n resultant_fiber\nend",
"def frames\n @keyframes.last.index + @keyframes.last.duration\n end",
"def show\n @inter_cap = InterCap.get(params[:id])\n @display_array = []\n @max_count = 0\n sequence_array =[@inter_cap.seq1,@inter_cap.seq2]\n puts \"Into The Threads\"\n thread_array=[]\n 2.times do |i|\n thread_array[i] = Thread.new{\n while sequence_array.length > 0 do\n sequence= sequence_array.pop\n alignment_color_array = []\n contact_consensus_array= []\n disorder_consensus_array= []\n inter_array= []\n interflag_array =[]\n interflag_range=[]\n interflagfalse_range=[]\n display_hash = Hash.new\n alignment_color_array = Array.new \n cur_position = 0 \n orig_position = 0\n info_hash = {}\n seq_length = sequence.a_asequences.count\n contacts = sequence.a_asequences.all(:contact_consensus.gte =>0.6)\n disorders = sequence.a_asequences.all(:disorder_consensus.gte =>0.5)\n both = sequence.a_asequences.all(:disorder_consensus.gte =>0.5, :contact_consensus.gte => 0.6)\n info_hash[:abrev_name] = sequence.abrev_name\n info_hash[:cicp_range] = contacts.map{|aa| aa.original_position}.to_range\n info_hash[:cicp_counts] = contacts.count\n info_hash[:disorder_count] = disorders.count\n info_hash[:disorder_range] = disorders.map{|aa| aa.original_position}.to_range\n info_hash[:disorder_percentage] = disorders.count.to_f/seq_length.to_f\n info_hash[:cicp_percentage] = contacts.count.to_f/seq_length.to_f\n info_hash[:both] = both.map{|aa| aa.original_position}.to_range\n info_hash[:both_count] = both.count\n info_hash[:both_percentage] = both.count.to_f/seq_length.to_f\n info_hash[:sequence_length] =seq_length\n \n sequence.a_asequences.all(:order => [:original_position]).each do |amino_acid| \n if InterCap.all(:aasequence1_id => amino_acid.id, :unique=>true, :fields=>[:aasequence1_id, :aasequence2_id]).count > 0 \n intercap = InterCap.all(:aasequence1_id => amino_acid.id, :unique=>true, :fields=>[:aasequence1_id, :aasequence2_id]).count\n interflag = 1\n interflag_range << amino_acid.original_position\n elsif InterCap.all(:aasequence2_id => amino_acid.id, :unique=>true, :fields=>[:aasequence1_id, :aasequence2_id]).count > 0 \n intercap = InterCap.all(:aasequence2_id => amino_acid.id, :unique=>true, :fields=>[:aasequence1_id, :aasequence2_id]).count\n interflag = 1\n interflag_range << amino_acid.original_position\n else\n intercap = 0\n inter_flag = 0\n interflagfalse_range << amino_acid.original_position\n end\n alignment_color_array[amino_acid.original_position] = residue_color(amino_acid.disorder_consensus, amino_acid.contact_consensus, intercap)\n contact_consensus_array[amino_acid.original_position]=amino_acid.contact_consensus\n disorder_consensus_array[amino_acid.original_position]=amino_acid.disorder_consensus\n inter_array[amino_acid.original_position]= intercap\n interflag_array[amino_acid.original_position]= interflag\n end \n puts display_hash[\"name\"] = sequence.abrev_name \n display_hash[\"alignment\"] = alignment_color_array\n display_hash[\"contacts\"] = contact_consensus_array\n display_hash[\"disorders\"] = disorder_consensus_array\n display_hash[\"inter\"] = inter_array\n display_hash[\"interflag\"] = interflag_array\n display_hash[\"info\"] = info_hash\n display_hash[\"inter_range\"] = interflag_range\n display_hash[\"interfalse_range\"] = interflagfalse_range\n @display_array << display_hash\n end\n }\n end\n thread_array.map{|t| t.join}\n # \n # @contact_consensus_array = @contact_consensus_array.map{|a| a.inject(0){|sum,item| sum + item}}\n # @cicp_array = @cicp_array.map{|a| a.inject(0){|sum,item| sum + item}}\n # disorder_array = @contact_consensus_array.map{|dv| dv.to_f/@seq_contact_count}\n # cicp_avgs = @cicp_array.map{|dv| dv.to_f/@cicp_contact_count}\n # aa_array = Array(1..@contact_consensus_array.count)\n # group_data = aa_array.zip(disorder_array, cicp_avgs,@conservation)\n # require 'csv'\n # @filename = \"#{align.alignment_name}_display_data.csv\"\n # CSV.open(\"public/\"+@filename, \"w\") do |csv|\n # csv << [\"Position\",\"Disorder\",\"CICP\",\"Conservation\"]\n # group_data.each do |gd|\n # csv << gd.map{|e| e.nil? ? 0 : e}\n # end\n # end\n #debugger\n cur_position = 0\n tick_counter = 0\n alignment_tick_array = Array.new\n @max_count = @inter_cap.seq1.a_asequences.count > @inter_cap.seq2.a_asequences.count ? @inter_cap.seq1.a_asequences.count : @inter_cap.seq2.a_asequences.count\n \n while cur_position <= @max_count\n cur_position += 1\n tick_counter += 1\n if tick_counter != 25\n alignment_tick_array << \"FFFFFF\"\n else\n alignment_tick_array << \"000000\"\n tick_counter = 0\n end\n end\n display_hash = Hash.new\n display_hash[\"name\"] = \"\"\n display_hash[\"alignment\"] = alignment_tick_array \n @display_array << display_hash\n if params[:aa_length].nil?\n @aa_length = 400\n else\n @aa_length = params[:aa_length].to_i\n end\n @ranges = (@max_count/@aa_length)\n\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @inter_cap }\n end\n end",
"def thread_stack_trace(tid)\r\n with_suspended_thread(tid) do\r\n ctx = thread_context(tid)\r\n if((start = read32(ctx.Ebp)) != 0) \r\n a = start\r\n stack = [[start, read32(start+4)]]\r\n while((a = read32(a)) and a != 0 and not stack.member?(a))\r\n begin\r\n stack << [a, read32(a+4)]\r\n rescue; break; end\r\n end\r\n return stack\r\n end\r\n end\r\n []\r\n end",
"def parse_thread_stacktrace(lines, thread_id, is_crashed_thread)\n # remove the 1st line\n lines.pop\n\n stacktrace = []\n process_matching_lines(lines, BACKTRACE_LINE_REGEX) do |match|\n stacktrace << parse_crashed_thread_stacktrace_line(match, is_crashed_thread)\n end\n\n # sentry wants their stacktrace with the oldest frame first\n stacktrace = stacktrace.reverse\n\n if is_crashed_thread\n @crashed_thread_stacktrace = stacktrace\n @extra[:crashed_thread_id] = thread_id\n else\n @other_threads_stacktraces[thread_id] = stacktrace\n end\n end",
"def id; frame[:id]; end",
"def frame=(pos); 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 current_frame\n @current_frame\n end",
"def sehFrameWalk()\n toKernel32Code = toKernel32()\n data = <<EOS\n push esi\n push ecx\n push ebx\n\n xor ebx,ebx\n not ebx ; ebx = 0xFFFFFFFF\n\n xor ecx, ecx\n mov cl,0x18 ; image size of ntdll.dll image on Windows 7 Ultimate SP1 (ENG), large enough to cover other versions as well\n shl ecx,16\n\n ; walk SEH chain until we find a candidate default SEH frame\n mov esi,esp\n seh_walking: \n lodsd ; load dword from stack\n cmp eax,ebx\n jne seh_walking\n ; Check if the candidate default SEH frame has correct function pointer\n ; [esi-4] now points to 0xFFFFFFFF so if this truly is the last SEH frame, [esi] (SE Handler) should point into ntdll.dll or kernel32.dll and [esi+20] (return into RtlUserThreadStart) too\n mov eax,[esi] ; potential SE Handler\n sub eax,[esi+16] ; potential return address of top stack frame\n cmp eax, ecx ; size limit means function pointer candidates have to reside in same image.\n ja seh_walking ; continue walking\n ; we now have a candidate, esi potentially points to default SE Handler in ntdll.dll\n mov eax,[esi]\n\n ; work through potential image until we find base address (within size limit to reduce potential false positives)\n find_begin:\n ; if we didn't find image base within size limit, give up on this candidate and try next\n test ecx, ecx\n je seh_walking\n dec eax\n xor ax,ax\n cmp word [eax],0x5A4D ; MZ start of PE header\n jnz find_begin\n\n pop ebx\n pop ecx\n pop esi\n\n mov edx, eax\n ; edx points to either ntdll.dll or kernel32.dll base address (depending on windows version)\n\n #{toKernel32Code}\nEOS\n\n data\n end",
"def load_thread thread_id\n results = perform :thread, :args => [thread_id]\n results.map { |m, depth| [MessageSummary.new(m), depth] }\n end",
"def top;end",
"def frames\n value_parts[3]\n end",
"def frames\n value_parts[3]\n end",
"def frame_number\n @frame_number ||= valid? ? frame.size : frame.size - 1\n end",
"def frame_self(frame_postion=0)\n #This is a stub, used for indexing\n end",
"def frame_locals(frame)\n #This is a stub, used for indexing\n end",
"def leader\n white_size = cumulative_stack_size(:white)\n black_size = cumulative_stack_size(:black)\n case white_size <=> black_size\n when 1 then :white\n when 0 then :tie\n when -1 then :black\n end\n end",
"def stack_top\n self # okay maybe I'll implement this\n end",
"def tally_frames(old=0)\n if !tss.empty?\n # puts \"returning hits count #{hits.count}\"\n return hits.count\n else\n result=0\n snd.each do |sn|\n result += hits.count*sn.tally_frames(old)\n end\n # puts \"all in result #{result}\"\n return result\n end\n end",
"def hit_from; @seq2.from; end",
"def next_frame\n #populate our @channels instance vaiable\n create_channel_list\n do_frame_lookup\n\n if File.exist?(\"/home/lee/src/eyebleach/test_images/#{message[:channel_name]}-frame#{message[:frame_no]}.gif\")\n image = Base64.encode64(File.open(\"/home/lee/src/eyebleach/test_images/#{message[:channel_name]}-frame#{message[:frame_no]}.gif\").read)\n frame_message :next_frame, image, message[:frame_no], @channels[message[:channel_name]], message[:channel_name]\n else\n image = Base64.encode64(File.open(\"/home/lee/src/eyebleach/test_images/#{message[:channel_name]}-frame0.gif\").read)\n frame_message :next_frame, image, 0, @channels[message[:channel_name]], message[:channel_name]\n end\n end",
"def to_phpbb(thread, arp)\n\n if thread.is_a?(Hash) && thread['tid']\n tid = thread['tid']\n else\n tid = thread\n end\n\n x = self[tid]\n\n has_attach = !PHPBB.attachments.find_by('topic_id', tid).empty?\n\n first_post = arp.first['sm_posts']\n last_post = arp.last['sm_posts']\n\n h = {\n topic_id: x['tid'],\n forum_id: X2P_FID[x['fid']],\n icon_id: POST_ICONS[x['icon']],\n topic_attachment: has_attach.to_i,\n topic_reported: 0,\n topic_title: x['subject'],\n topic_poster: first_post[:poster_id],\n topic_time: first_post[:post_time],\n topic_time_limit: 0,\n topic_views: x['views'],\n topic_status: 0,\n topic_type: x['topped'],\n topic_first_post_id: first_post[:post_id],\n topic_first_poster_name: first_post[:post_username],\n topic_first_poster_colour: \"\",\n topic_last_post_id: last_post[:post_id],\n topic_last_poster_id: last_post[:poster_id],\n topic_last_poster_name: last_post[:post_username],\n topic_last_poster_colour: \"\",\n topic_last_post_subject: last_post[:post_subject],\n topic_last_post_time: last_post[:post_time],\n topic_last_view_time: last_post[:post_time],\n topic_moved_id: 0,\n topic_bumped: 0,\n topic_bumper: 0,\n poll_title: \"<t></t>\",\n poll_start: 0,\n poll_length: 0,\n poll_max_options: 1,\n poll_last_vote: 0,\n poll_vote_change: 0,\n topic_visibility: 1,\n topic_delete_time: 0,\n topic_delete_reason: \"\",\n topic_delete_user: 0,\n topic_posts_approved: arp.length,\n topic_posts_unapproved: 0,\n topic_posts_softdeleted: 0\n }\n\n\n return {\"sm_topics\" => h}\n end",
"def second_shot_complete? frame\n frame.shot_2 != nil\n end",
"def tenth_frame; end",
"def grabtop5\n # grab 6 cause the top part is a header\n top5 = `ps -eo pcpu,pid,pmem,args | sort -k 1 -r | head -6`\n top5 = top5.split(/\\n/)\n\n top5procs = {}\n\n # pop the first element of the array cause it's a header\n top5.shift\n\n top5.each do |process|\n prochash = {}\n ps = process.split\n \n #### debugging info...\n prochash['cpu'] = ps[0]\n \n prochash['pid'] = ps[1]\n\n prochash['mem'] = ps[2]\n\n prochash['fullname'] = ps[3]\n\n name = ps[3].split(\"/\")\n name = name[name.size-1]\n prochash['name'] = name\n\n top5procs[prochash['name']] = prochash\n end\n\n return top5procs\n end",
"def top\n return @top\n end",
"def top\n return @top\n end",
"def initialize\n super\n now = Thread.list.length\n @@peak = now if now > @@peak\n end",
"def merge_thread_state thread_structure\n thread_structure.flatten.inject(Set.new) do |set, docid|\n set + (docid < 0 ? [] : load_set(\"state/#{docid}\"))\n end\n end",
"def parent_frame; end",
"def threads_match\n threads_text = find('#f-h', text: /\\d+ of \\d+ topics/).text\n threads_text.match(/(?<loaded>\\d+) of (?<total>\\d+) topics/)\n end",
"def top_mac\n top = `top -l 1 | grep -E '(#{@processes})'`\n end",
"def top\n _exchange(true)\n end",
"def assume_top_queue_position\n update_attribute(queue_position_column, 1)\n end",
"def top\n @stack[-1]\n end",
"def color2_top\n @attributes[:color2_top]\n end",
"def dup_top\n <<-CODE\n t1 = stack_top();\n stack_push(t1);\n CODE\n end",
"def show_frames\r\n jssh_command = \"var frameset = #{WINDOW_VAR}.frames;\r\n var elements_frames = new Array();\r\n for(var i = 0; i < frameset.length; i++)\r\n {\r\n var frames = frameset[i].frames;\r\n for(var j = 0; j < frames.length; j++)\r\n {\r\n elements_frames.push(frames[j].frameElement); \r\n }\r\n }\r\n elements_frames.length;\"\r\n \r\n jssh_command.gsub!(\"\\n\", \"\")\r\n $jssh_socket.send(\"#{jssh_command};\\n\", 0)\r\n length = read_socket().to_i \r\n \r\n puts \"There are #{length} frames\"\r\n \r\n frames = Array.new(length)\r\n for i in 0..length - 1 do\r\n frames[i] = Frame.new(self, :jssh_name, \"elements_frames[#{i}]\")\r\n end\r\n \r\n for i in 0..length - 1 do\r\n puts \"frame: name: #{frames[i].name}\"\r\n puts \" index: #{i+1}\"\r\n end\r\n end",
"def top()\n @stack[0]\n end",
"def frame_sequence\r\n return nil unless has_video?\r\n raise(FLVStreamError, 'File has to contain at least 2 video tags to calculate frame sequence') if video_tags.length < 2\r\n\r\n @frame_sequence ||=\r\n begin\r\n sequences = video_tags.collect do |tag| # find all sequences\r\n video_tags[video_tags.index(tag) + 1].timestamp - tag.timestamp unless tag == video_tags.last\r\n end.compact\r\n \r\n uniq_sequences = (sequences.uniq - [0]).sort # remove 0 and try smallest intervall first \r\n \r\n sequence_appearances = uniq_sequences.collect { |sequence| sequences.find_all { |_sequence| sequence == _sequence }.size } # count apperance of each sequence\r\n \r\n uniq_sequences[ sequence_appearances.index( sequence_appearances.max ) ] # return the sequence that appears most\r\n end\r\n end",
"def frame_class(frame_position)\n #This is a stub, used for indexing\n end",
"def cur_image\n @frames.cur_image\n end",
"def get_frame(block_name, frame)\n if frame[:vlocks].has_key?(block_name)\n frame\n elsif frame[:parent_frame]\n get_frame(block_name, frame[:parent_frame])\n end\n end",
"def refresh_frame(run_whereami = T.unsafe(nil)); end",
"def ani_frames\n return @ani_frames\n end",
"def get_frame\n next_frame\n rescue StopIteration => e\n return nil\n end",
"def threads(pid)\r\n h = CALLS[\"kernel32!CreateToolhelp32Snapshot:LL=L\"].call(0x4, pid)\r\n if h != -1\r\n mi = [(7*4),0,0,0,0,0,0].pack(\"LLLLLLL\")\r\n if CALLS[\"kernel32!Thread32First:LP=L\"].call(h, mi) != 0\r\n ti = str2thread_info(mi)\r\n yield str2thread_info(mi) if ti.th32OwnerProcessID == pid\r\n while CALLS[\"kernel32!Thread32Next:LP=L\"].call(h, mi) != 0\r\n ti = str2thread_info(mi)\r\n yield str2thread_info(mi) if ti.th32OwnerProcessID == pid\r\n end\r\n end\r\n else\r\n raise WinX.new(:create_toolhelp32_snapshot)\r\n end\r\n end",
"def frame_test_counters(frame, idx_tx, idx_rx, cnt_tx = 1000000, cnt_rx = cnt_tx, prio = 0)\n tx_frame = frame.create_frame\n if_tx = $dut.if_list[idx_tx] # Host Tx\n if_rx = $dut.if_list[idx_rx] # Host Rx\n port_rx = $dut.port_list[idx_tx] # Switch Rx\n port_tx = $dut.port_list[idx_rx] # Switch Tx\n if_tx.tx_counter = 0\n if_rx.rx_buffer = false\n if_rx.rx_counters_clear\n obj = MesaJson.new(\"port_counters\")\n rx_cnt = obj.get(port_rx)[\"prio\"][prio][\"rx\"]\n tx_cnt = obj.get(port_tx)[\"prio\"][prio][\"tx\"]\n\n # Send frames\n Log.info(\"Sending #{cnt_tx} frames on #{if_tx.ifname}\")\n for i in 1..cnt_tx do\n if ((i % 100000) == 0)\n Log.info(\"Sent #{i} frames\")\n end\n if_tx.tx(tx_frame)\n end\n sleep(1)\n\n # Check counters\n Log.info(\"Checking counters\")\n rx_cnt = (obj.get(port_rx)[\"prio\"][prio][\"rx\"] - rx_cnt)\n tx_cnt = (obj.get(port_tx)[\"prio\"][prio][\"tx\"] - tx_cnt)\n Log.info(\"Tx frames: #{if_tx.tx_counter} on #{if_tx.ifname}\")\n Log.info(\"Rx frames: #{rx_cnt} on port #{port_rx}, priority #{prio}\")\n Log.info(\"Tx frames: #{tx_cnt} on port #{port_tx}, priority #{prio}\")\n rx_cnt = if_rx.rx_counter\n Log.info(\"Rx frames: #{rx_cnt} on #{if_rx.ifname}\")\n if (rx_cnt != cnt_rx)\n # Host counters are not fully reliable, so a warning is given\n Log.warning(\"Rx expected #{cnt_rx} frames, got #{rx_cnt} frames on #{if_rx.ifname}\")\n end\n Log.msg(\"Tx expected #{cnt_rx} frames, got #{tx_cnt} frames on port #{port_tx}, priority #{prio}\", tx_cnt != cnt_rx)\nend",
"def frame_status(pins)\n @frame_complete = !@frame_complete if pins != 10\n end",
"def frame_info(b, verbose = T.unsafe(nil)); end",
"def initialize(frames = 1024)\n $frames = Frame.new(1024)\n $bm = Bitmap.new(1024)\n\n init_segment_table\n end",
"def load_stack\n $LOAD_STACK\n end",
"def showFrames()\n=begin\n \n ff = @ie.document.frames\n\n log \"there are \" + ff.length.to_s + \" frames\" if $debuglevel >=0\n\n for f in 0 .. ff.length-1\n log \"Frame: \" + ff[f.to_s].name.to_s if $debuglevel >=0 \n log \"My parent is: \" + ff[f.to_s].parentWindow.name.to_s if $debuglevel >=0\n end \n\n #frame = @ie.document.frames[ frameName ].document\n \n=end\n end",
"def top\n @stack.last\n end",
"def initialize\n @threads = []\n end",
"def ignore_frame?(frame)\n\t\t\t\tif self.closed?\n\t\t\t\t\t# puts \"ignore_frame? #{frame.stream_id} -> #{valid_remote_stream_id?(frame.stream_id)} > #{@remote_stream_id}\"\n\t\t\t\t\tif valid_remote_stream_id?(frame.stream_id)\n\t\t\t\t\t\treturn frame.stream_id > @remote_stream_id\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def frame_test_counters(frame, idx_tx, idx_rx, cnt_tx, cnt_rx, prio)\n port_rx = $ts.dut.port_list[idx_tx] # Switch Rx\n port_tx = $ts.dut.port_list[idx_rx] # Switch Tx\n $ts.dut.call(\"mesa_port_counters_clear\", port_rx)\n $ts.dut.call(\"mesa_port_counters_clear\", port_tx)\n\n # Send frames\n if_tx = \"#{$ts.pc.p[idx_tx]}\"\n if_rx = \"#{$ts.pc.p[idx_rx]}\"\n t_i(\"Sending #{cnt_tx} frames on #{if_tx} to #{if_rx}\")\n for i in 1..cnt_tx do\n $ts.pc.run(\"sudo ef tx #{if_tx} #{frame}\")\n end\n sleep(1)\n\n # Check counters\n t_i(\"Checking counters\")\n rx_cnt = $ts.dut.call(\"mesa_port_counters_get\", port_rx)[\"prio\"][prio][\"rx\"]\n tx_cnt = $ts.dut.call(\"mesa_port_counters_get\", port_tx)[\"prio\"][prio][\"tx\"]\n msg = \"Rx expected #{cnt_tx} frames, got #{rx_cnt} frames on port #{port_rx}, priority #{prio}\"\n if (rx_cnt == cnt_tx)\n t_i(msg)\n else\n t_e(msg)\n end\n msg = \"Tx expected #{cnt_rx} frames, got #{tx_cnt} frames on port #{port_tx}, priority #{prio}\"\n if (tx_cnt == cnt_rx)\n t_i(msg)\n else\n t_e(msg)\n end\nend",
"def get_captures\n captures = Hash.new\n\n get_all_moves.each do |k, v|\n captures[k] = v.select do |end_pos|\n #debugger\n @board[end_pos].other_color == @color\n end\n end\n\n captures.reject { |_, v| v.empty? }\n end",
"def threads_key?(key); end",
"def thread_status\n @threads_lock.synchronize do\n Hash[@threads.map do |name, thread|\n [name, \"alive\" => thread.alive?, \"status\" => thread.status]\n end]\n end\n end",
"def stack_top\n if @sp.zero?\n nil\n else\n @stack[@sp - 1]\n end\n end",
"def findBuffer bufferid\n buf = nil\n @frames.each do |buffer, frame|\n if bufferid == buffer.id\n buf = buffer\n break\n end\n end\n buf\n end",
"def puts_top\n g.dup\n g.push_self\n g.swap\n g.send :p, 1, true\n g.pop\n end",
"def index frame\n n = -1\n @avi.process_movi do |indices, movi|\n indices.each_with_index do |m, i|\n movi.pos = m[:offset] + 8\n f = Frame.new(movi.read(m[:size]), m[:id], m[:flag]) \n if f == frame\n n = i\n break\n end\n end\n [indices, movi]\n end\n n\n end",
"def readCommonHeader(buf)\n frame = {}\n len_hi, len_lo, type, flags, stream = buf.slice(0,9).unpack(HEADERPACK)\n\n frame[:length] = (len_hi << FRAME_LENGTH_HISHIFT) | len_lo\n frame[:type], _ = FRAME_TYPES.select { |t,pos| type == pos }.first\n frame[:flags] = FRAME_FLAGS[frame[:type]].reduce([]) do |acc, (name, pos)|\n acc << name if (flags & (1 << pos)) > 0\n acc\n end\n\n frame[:stream] = stream & RBIT\n frame\n end",
"def merge_thread_labels thread_structure\n thread_structure.flatten.inject(Set.new) do |set, docid|\n set + (docid < 0 ? [] : load_set(\"mlabels/#{docid}\"))\n end\n end",
"def scrape_thread_list board_url\n threads = {}\n # subject.txt is text/plain(sjis)\n open(board_url+'subject.txt', 'r:Shift_JIS') do |response|\n response.each_line do |line|\n line = line.encode('UTF-8', invalid: :replace, undef: :replace)\n # \"1347844405.dat<>title (int)\\n\"\n /^(\\d+\\.dat)<>(.+) \\(\\d+\\)/ =~ line\n # see unmatching pattern as bourbon house\n raise BourbonHouseException.new(\"at #{board_url}\") unless $1\n dat_url = board_url + 'dat/' + $1\n threads[dat_url] = $2\n end\n end\n threads\n end",
"def current_aggregate_times\n # last_capture = Game.find(self.id).captures.last\n # set update reference time to last capture\n current_time = Time.now #last_capture.created_at #self.captures.last.created_at\n \n team_hash = {} # {1 => 300(s), 2 => 0(s), ...}\n # populating the hash\n self.teams.each{|team| team_hash[team] = team.aggregate_time }\n \n # for each node in current game\n self.nodes.each do |node|\n last_capture = node.last_capture\n if last_capture\n time_to_add = current_time - last_capture.created_at \n # update the aggregate time\n team_hash[last_capture.team] += time_to_add\n end\n end\n \n team_hash\n end",
"def top()\n @stack[-1]\n end",
"def initialize\n @frame = 1\n @first_throw = 0\n @second_throw = 0\n @bonus_roll = 1\n @pins_per_frame = []\n @total_score = 0\n @previous_turn_bonus = []\nend",
"def thread_graph(out, t_id, info)\n total_calls = 0\n run_total = 0.0\n\n data = info[:nodes]\n\n methods = info[:methods]\n\n run_total = info[:runtime].to_f\n\n all_callers = Hash.new { |h,k| h[k] = [] }\n\n data.each do |n_id, n_data|\n n_data[4].each do |sub|\n all_callers[sub] << n_id\n end\n end\n\n indexes = data.keys.sort do |a, b|\n data[b][1] <=> data[a][1]\n end\n\n indexes = indexes.first(SHORT_LINES) unless options[:full_report]\n\n shown_indexes = {}\n\n indexes.each_with_index do |id, index|\n shown_indexes[id] = index + 1\n end\n\n out.puts \"===== Thread #{t_id} =====\"\n out.puts \"Total running time: #{sec(info[:runtime])}s\"\n out.puts \"index % time self children called name\"\n out.puts \"----------------------------------------------------------\"\n\n primary = \"%-7s%6s %8.2f %9.2f %8d %s [%d]\\n\"\n secondary = \" %8.2f %9.2f %8d %s%s\\n\"\n\n indexes.each do |id|\n m_id, total, called, tn, sub_nodes = data[id]\n\n # The idea is to report information about caller as a ratio of the\n # time it called method.\n #\n\n callers = all_callers[id].sort_by do |c_id|\n clr = data[c_id]\n\n clr[total]\n end\n\n callers = callers.first(10) unless options[:full_report]\n\n callers.each do |c_id|\n clr_m_id, clr_total, clr_called, clr_tn, clr_sub = data[c_id]\n\n sub_total = clr_sub.inject(0) { |a,s| a + data[s][1] }\n\n self_total = clr_total - sub_total\n out.printf(secondary, sec(self_total),\n sec(sub_total),\n clr_called,\n methods[clr_m_id][:name],\n graph_method_index(shown_indexes[c_id]))\n end\n\n # Now the primary line.\n\n children = sub_nodes.inject(0) { |a,s| a + data[s][1] }\n # children = method[:cumulative] * (method[:edges_total].to_f / method[:total])\n\n self_total = total - children\n out.printf primary, (\"[%d]\" % shown_indexes[id]),\n percentage(total, run_total, 1, nil),\n sec(self_total),\n sec(children),\n called,\n methods[m_id][:name],\n shown_indexes[id]\n\n # Same as caller, the idea is to report information about callee methods\n # as a ratio of the time it was called from method.\n #\n\n edges = sub_nodes.sort_by do |e_id|\n if edge = data[e_id]\n edge[1]\n else\n 0.0\n end\n end\n\n edges = edges.last(10) unless options[:full_report]\n # method[:edges] = method[:edges].first(10) unless options[:full_report]\n\n edges.reverse_each do |e_id|\n c_m_id, c_total, c_called, c_tn, c_sub_nodes = data[e_id]\n\n grandchildren = c_sub_nodes.inject(0) { |a,s| a + data[s][1] }\n grandchildren = 0 if grandchildren < 0\n\n self_total = c_total - grandchildren\n out.printf secondary, sec(self_total),\n sec(grandchildren),\n c_called,\n methods[c_m_id][:name],\n graph_method_index(shown_indexes[e_id])\n end\n\n out.puts \"-------------------------------------------------------\"\n end\n\n epilogue out, data.size, total_calls\n end",
"def thread_id\n return @thread_id\n end",
"def initialize(response)\n super\n async = response.oob_records(:exec).select do |oob|\n oob.record_class == :stopped &&\n oob.results[:reason] == 'breakpoint-hit'\n end.first\n @bkptno = async.results[:bkptno]\n @thread_id = async.results[:thread_id]\n @frame = async.results[:frame]\n end",
"def thread_id\n check_connection\n @protocol.thread_id\n end",
"def combine_frames(frames)\n frames.first.zip(*frames[1..-1]).map do |pixels|\n combine_pixels pixels\n end\n end",
"def read_stack_cache_traces(analysis_task_elem)\n analysis_task_elem.each_element(\"value_analysis/messages/message/textline\") { |e|\n if e.text =~ /trace.*\\(context\\w*(.*)\\).*\\(\"user_(n_(?:fill|spill))\"\\).=.(\\d+)/\n yield $1,$2,$3\n end\n }\n end",
"def thread_id\n\n\t\t::Pantheios::Core.thread_id\n\tend",
"def threads\n @rufus ? @rufus.threads : nil\n end",
"def chat_retrieve(unique_tags)\n Thread.new {\n tagHash = []\n tempResults = {}\n list = {}\n y = unique_tags.length - 1\n for i in 0..y\n Thread.new(i) { |i2|\n tagHash[i2] = Hash_Func(unique_tags[i2])\n while @chat_retrieveAckWait != nil && (@chat_retrieveAckWait[tagHash[i2]] == 1 || @chat_retrieveAckWait[tagHash[i2]].kind_of?(Array))\n end\n @chat_retrieveAckWait[tagHash[i2]] = 1\n chat_retrieveMsg = {:type => \"CHAT_RETRIEVE\", :tag => unique_tags[i2], :node_id => tagHash[i2], :sender_id => @guid}.to_json\n nh, m, n = nextHop(tagHash[i2])\n @socket.send chat_retrieveMsg, 0, nh.ip, nh.port\n t = Time.now.sec\n t2 = t + 90\n while t < t2 # Waits 30 seconds before checking route\n if @chat_retrieveAckWait[tagHash[i2]].kind_of?(Array)\n tempResults[tagHash[i2]] = @chat_retrieveAckWait[tagHash[i2]]\n break\n end\n t = Time.now.sec\n if t < t2 - 30\n t = t + 60\n end\n end\n if @chat_retrieveAckWait[tagHash[i2]].kind_of?(Array)\n puts \"Get correct chat result\"\n else\n puts \"The chat_retrieve failed to check the route within set time\"\n\n routeChecker(tagHash[i2])\n end\n @chat_retrieveAckWait[tagHash[i2]] = 0\n }\n end\n t3 = Time.now.sec # returns results after 3 seconds\n t4 = t3 + 3\n while t3 < t4\n t3 = Time.now.sec\n if t3 < t4 - 3\n t3 = t3 + 60\n end\n end\n\n list = tempResults[tagHash[0]]\n removeList = []\n for j in 1..tagHash.length-1\n nList = tempResults[tagHash[j]]\n list.each { |h|\n removeFlag = true\n nList.any? { |nH|\n if nH[:text] == h[:text]\n removeFlag = false\n\n end\n }\n if removeFlag\n removeList << h\n end\n }\n for k in removeList\n list.delete(k)\n end\n end\n r = ChatResult.new() # Holds results\n r.tags = unique_tags\n r.resutls = list\n return r\n }\n end"
] |
[
"0.584636",
"0.57474035",
"0.5580766",
"0.55540055",
"0.55254865",
"0.54482716",
"0.5412241",
"0.536749",
"0.53574866",
"0.52836645",
"0.5274136",
"0.518462",
"0.5183925",
"0.5180254",
"0.5170764",
"0.51603466",
"0.5137984",
"0.510208",
"0.5055031",
"0.50243175",
"0.50187874",
"0.50160336",
"0.50033075",
"0.4996553",
"0.49941614",
"0.49931648",
"0.49346095",
"0.49226066",
"0.49057114",
"0.48981398",
"0.48963445",
"0.48790595",
"0.48625657",
"0.48408112",
"0.48408112",
"0.48351288",
"0.48335934",
"0.4831542",
"0.48258993",
"0.48258257",
"0.48232856",
"0.4815373",
"0.48105556",
"0.48065385",
"0.4803034",
"0.48015648",
"0.48007163",
"0.47794542",
"0.47794542",
"0.47702724",
"0.47667807",
"0.47343943",
"0.47184822",
"0.47174633",
"0.47138152",
"0.4705009",
"0.46998358",
"0.4699551",
"0.46994445",
"0.46973363",
"0.4685347",
"0.46791485",
"0.46694338",
"0.46688858",
"0.46659216",
"0.46605247",
"0.4659997",
"0.46575487",
"0.465013",
"0.46399465",
"0.4638923",
"0.46122426",
"0.461156",
"0.46096036",
"0.46069443",
"0.45994478",
"0.4598944",
"0.45875567",
"0.45851165",
"0.45847628",
"0.45773512",
"0.45694065",
"0.45665827",
"0.45631257",
"0.45519722",
"0.4551502",
"0.45463303",
"0.45447895",
"0.4542368",
"0.45343316",
"0.45323235",
"0.45312288",
"0.45252943",
"0.45237306",
"0.4520062",
"0.4519552",
"0.45187715",
"0.45154223",
"0.4498109",
"0.44978663",
"0.44931197"
] |
0.0
|
-1
|
Remove access to thread and frame variables
|
def frame_teardown
@top_frame = @frame = @current_thread = nil
@threads2frames = {}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clean_thread_locals; end",
"def clean_thread_locals(thread)\n thread.keys.each do |key|\n next if key == :celluloid_queue\n\n # Ruby seems to lack an API for deleting thread locals. WTF, Ruby?\n thread[key] = nil\n end\n end",
"def clean_thread_locals=(_arg0); end",
"def clean_thread_locals(which = T.unsafe(nil)); end",
"def remove_internal_frames(bindings); end",
"def clear_request_data\n Thread.current[THREAD_LOCAL_NAME] = nil\n end",
"def remove_disallow_flag!\n @__phi_access_stack.pop\n end",
"def remove_frame(frame)\n end",
"def remove_debugger_frames(bindings); end",
"def thread_cleanup\n # do nothing, i think?\n end",
"def clear_frame_managers(_pry_); end",
"def unfreeze; end",
"def clean\n Thread.current[:__cms_original_content] = nil\n Thread.current[:__cms_active_page] = nil\n Thread.current[:__cms_stack] = nil\n Thread.current[:__content_node_stack] = nil\n Thread.current[:__content_iterator_stack] = nil\n Thread.current[:__content_iterator_stack_key] = nil\n end",
"def delete_frame_managers(_pry_); end",
"def unwatch; end",
"def unwatch; end",
"def teardown\n evicting_thread.kill\n end",
"def pop_frame_manager(_pry_); end",
"def discard\n @args = nil\n @block = nil\n end",
"def pop_trace_execution_flag # THREAD_LOCAL_ACCESS\n Tracer.state.pop_traced\n end",
"def clear!\n Thread.current[LOCAL_KEY] = nil\n end",
"def scrooge_dump_unflag_this\n Thread.current[:scrooge_dumping_objects].delete(object_id)\n end",
"def clean_thread_context(logger: nil, namespace: nil)\n if store(namespace).present?\n if logger.nil?\n puts \"WARNING: ThreadAccessor variables set outside ThreadAccessor context: #{store(namespace).keys.join(\", \")}\"\n else\n logger.warn(\"ThreadAccessor variables set outside ThreadAccessor context: #{store(namespace).keys.join(\", \")}\")\n end\n end\n\n yield\n ensure\n store(namespace).clear\n end",
"def reset!\n instance_variables.each { |var| remove_instance_variable var }\n end",
"def remove_trace_func\n Kernel.clear_trace_func\n end",
"def unuse\n @use = nil\n end",
"def reset!\n Thread.current[THREAD_KEY] = {}\n end",
"def clean_up\n @breakpoints = []\n @breakpoint_count = -1\n @file = nil\n\n Thread.list.each do |th|\n th[:__pry_debug_stepped_file] = nil\n th[:__pry_debug_stepping] = false\n\n th[:__pry_debug_exception_binding] = nil\n th[:__pry_debug_last_exception] = nil\n end\n\n @break_on_raise = false\n @debugging = false\n @will_load = true\n\n @mutex = Mutex.new\n end",
"def unfreeze(&block); end",
"def remove_internal_frames(bindings)\n i = top_internal_frame_index(bindings)\n # DEBUG:\n #bindings.each_with_index do |b, index|\n # puts \"#{index}: #{b.eval(\"self.class\")} #{b.eval(\"__method__\")}\"\n #end\n # puts \"FOUND top internal frame in #{bindings.size} frames: [#{i}] #{bindings[i].ai}\"\n\n bindings.drop i+1\n end",
"def cleanup()\n @threads.each do |name, thread| \n @threads.delete name if thread.state == :dead\n end\n end",
"def clean_up\n self.user_thread = nil\n self.uid = nil\n self.internal_date = nil\n self.raw_eml = nil\n self.envelope = nil\n self.message_id = nil\n self.sha1 = nil\n self.mail_log = nil\n end",
"def remove\n instance_variables.map{|v| instance_variable_get(v) }\n .keep_if{|v| v.respond_to? :remove }\n .each(&:remove)\n end",
"def detach\n set_current_buffer @frame.window.buffer\n @frame.mini_buffer = nil\n @frame = nil\n end",
"def untrace_var(*rest) end",
"def delete\n @thread.__trim_stack_to_level(@index)\n end",
"def remove_dispatch(mod)\n # THREAD CRITICAL BEGIN\n if @dispatch[mod]\n @dispatch[mod] = false\n # $stderr.puts \"Removing dispatch for #{mod.name}##{name}\"\n mod.class_eval(\"remove_method #{name.inspect}\")\n end\n # THREAD CRITICAL END\n end",
"def stop_thread; end",
"def _clear_accessors\n self.__pack = nil\n self._store = nil\n end",
"def reset\n @instance = nil\n @local_env = nil\n end",
"def reset\n @instance = nil\n @local_env = nil\n end",
"def reset\n [:@sitemap_url, :@models, :@delay, :@environments, :@ping_urls, :@background, :@notified_urls].each do |var|\n remove_instance_variable var if instance_variable_defined?(var)\n end\n end",
"def clear_tracking\n ::ObjectSpace.trace_object_allocations_clear\n end",
"def purge_module_threads(mod)\n return if not @modules[mod]\n\n @modules[mod][:threads].delete_if{|t| \n not t.alive?\n } \n end",
"def discard; end",
"def discard; end",
"def unsafely\n tap { Threaded.safety_options = false }\n end",
"def teardown\n #commented this out because it is now unnecessary\n # @api = nil\n #GC.start\n @api.close_api\n # @server.close\n end",
"def clear!\n Thread.current[:__honeybadger_context] = nil\n end",
"def unsafely\n tap { Threaded.safety_options = false }\n end",
"def unwatch()\n merge(unwatch: 'true')\n end",
"def unwatch()\n merge(unwatch: 'true')\n end",
"def unlock_access!; end",
"def trash_current!\n t = Thread.current\n conn = owned_resource(t)\n return unless conn\n\n @delete_proc.call conn if @delete_proc\n sync { @allocated.delete(t) }\n nil\n end",
"def clear\n instance_variables.each do |instance_variable|\n instance_variable_set(instance_variable, nil)\n end\n end",
"def allowing_other_threads; end",
"def frame_reset\n @delta_time = @frame_to_skip = 0\n @ruby_time = @current_time = @last_time = @last_second_time = Time.new\n reset_gc_time\n reset_ruby_time\n @last_frame_count = Graphics.frame_count\n end",
"def backtrace_remove; end",
"def untick; end",
"def disable_clear_and_finalize=(_arg0); end",
"def clear\n context.clear if Thread.current[NAME]\n self\n end",
"def clear\n context.clear if Thread.current[NAME]\n self\n end",
"def teardown\n Thread.list.each do |thr|\n thr.join if (thr.alive? and thr != @mthread and thr != Thread.current)\n end\n end",
"def uncacheable!\n @stack.each { |t| t.cacheable = false }\n end",
"def reset\n # self.instance_variable_names.each do |var_name|\n # self.instance_variable_set var_name, nil\n # end\n instance_variables.each { |name, value|\n instance_variable_set(name, nil)\n }\n end",
"def restore_globals\n # Restore the original $LOAD_PATH to negate any changes made.\n $LOAD_PATH.replace @@load_path_org\n # Could restore the original $LOADED_FEATURES ($\"), but this worker process\n # acculumates many gems and modules over time and it's not practical to\n # reload them every time.\n # So, just deleting those in @sitelibbase or @sourcebase directory.\n $LOADED_FEATURES.reject! {|x| x.start_with?(@sitelibbase, @sourcebase)}\n end",
"def unbind_read_memory\n memory = read_memory\n memory.each do |key, frame|\n API.unbind key, @mash\n end\nend",
"def unrun\n log \"Nothing to do.\"\n end",
"def reset_request\n @params = @headers = @body = nil\n end",
"def clear_conditions\n Thread.current[:geotab_conditions] = {}\n end",
"def disable_clear_and_finalize; end",
"def backtrace_remove=(_arg0); end",
"def reset_context\n @context = nil\n end",
"def cleanup_view_runtime; end",
"def unassign_site\n Site.current = nil\n end",
"def interpreter_reset\r\n @data_stack = Array.new\r\n @ctrl_stack = Array.new\r\n @start_time = Time.now\r\n end",
"def forget_past!\n access :unsafe_forget_past!\n end",
"def clear\n self.request = nil\n end",
"def reset!\n self.instance_variables.each { |variable| instance_variable_set(variable, nil) }\n self\n end",
"def clear_request_token\n @request_token = nil\n end",
"def reset\n @context = nil\n end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def teardown\n @mem.mem_clear\n end",
"def killBuffer buffer\n @frames.delete buffer\n end",
"def clear_current!\n @master_state.current_listener_pid = nil\n end",
"def un_load\n\n NSLog('Whatever hasn\\'t been unloaded and could be better be now!')\n NSLog('We probably don\\'t need this now that we\\'re using RubyMotion and it\\'s awesome!')\n\n end",
"def public\n Rubinius::VariableScope.of_sender.method_visibility = nil\n end",
"def cleanup!; end",
"def cleanup!; end",
"def delete_variable\n super\n end",
"def cancel_frame\n end",
"def clearFrame(frame)\n if frame>=0 && frame<@animation.length\n for i in 0...PBAnimation::MAXSPRITES\n if self.deletable?(i)\n @animation[frame][i]=nil\n else\n pbResetCel(@animation[frame][i])\n end\n @dirty[i]=true if frame==@currentframe \n end\n end\n end",
"def runs_outside_callee_thread\n @in_callee_thread = false\n self\n end",
"def reset!\n instance.instance_variables.each do |instance_variable|\n instance.send(:remove_instance_variable, instance_variable)\n end\n\n true\n end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def do_not_thread; true; end"
] |
[
"0.79764557",
"0.7554669",
"0.7309854",
"0.7042253",
"0.6873595",
"0.6698564",
"0.65046865",
"0.6445234",
"0.64105463",
"0.6400726",
"0.6348991",
"0.63449085",
"0.62832147",
"0.62520415",
"0.6188339",
"0.6188339",
"0.6090207",
"0.6085164",
"0.6055737",
"0.60382485",
"0.6020791",
"0.6004392",
"0.5984296",
"0.59545755",
"0.5944551",
"0.59347",
"0.5929913",
"0.591676",
"0.5911797",
"0.59032947",
"0.5894101",
"0.5848263",
"0.58364004",
"0.5820831",
"0.5816395",
"0.5802996",
"0.57858473",
"0.5727164",
"0.5705129",
"0.5700213",
"0.5700213",
"0.56889534",
"0.56708753",
"0.5669177",
"0.56639284",
"0.56639284",
"0.5642565",
"0.56350905",
"0.5629725",
"0.5620471",
"0.5609411",
"0.5609411",
"0.5579016",
"0.5573101",
"0.5567875",
"0.556563",
"0.55609655",
"0.5560453",
"0.5557851",
"0.5548625",
"0.55468374",
"0.55468374",
"0.55431926",
"0.55348784",
"0.55320096",
"0.5517261",
"0.55160534",
"0.55126804",
"0.5487601",
"0.5442882",
"0.54411995",
"0.54382694",
"0.5436272",
"0.54200226",
"0.541463",
"0.54115534",
"0.5411054",
"0.5409537",
"0.5399043",
"0.5397012",
"0.5389056",
"0.5387935",
"0.5387935",
"0.5387935",
"0.5387935",
"0.5381706",
"0.5379919",
"0.53779894",
"0.5373601",
"0.5371586",
"0.53673404",
"0.53673404",
"0.5366771",
"0.5361027",
"0.53503114",
"0.53463805",
"0.53461695",
"0.5344281",
"0.5344281",
"0.5344281"
] |
0.7426193
|
2
|
def image Rails.application.routes.url_helpers.rails_blob_path(object.image, only_path: true) if object.image.attached? end
|
def initialize(question: nil)
@question = question
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def image_url\n rails_blob_url(object.image)\n # This helper gets the URL from the file we pass to it\n end",
"def image\n return unless object.image.attached?\n\n # object.image.blob.attributes\n # .slice('filename', 'byte_size')\n # .merge(url: image_url)\n # .tap { |attrs| attrs['name'] = attrs.delete('filename') }\n object.image.service_url\n \n end",
"def featured_image\n if object.featured_image.attached?\n {\n url: rails_blob_url(object.featured_image)\n }\n end\n end",
"def photos\n if self.images.attached?\n self.images.collect { |image| [ \"url\", Rails.application.routes.url_helpers.rails_blob_path(image, only_path: true) ] }\n else\n nil\n end\nend",
"def image_url\n return unless image.attached?\n\n url_for(image)\n end",
"def image_url\n return object.image.service_url if object.image.attached?\n nil\n end",
"def image_url\n object.image_url\n end",
"def cover_url\n #rails_blob_path(image, disposition: 'attachment', only_path: true)\n end",
"def avatar_url\n attachment = @object.avatar_attachment\n return if attachment.nil?\n\n Rails.application.routes.url_helpers.rails_blob_url(attachment, only_path: true)\n end",
"def image_url\n image.url\n end",
"def file_url\n if paperclip_attachment_attached?\n object.send(attribute_name).url(image_style)\n elsif activestorage_attachment_attached?\n attachment = object.send(attribute_name)\n\n if attachment.representable?\n attachment.representation(resize: \"400x150>\")\n else\n attachment.service_url\n end\n end\n end",
"def object_image_url(size: :medium)\n image = object_data[:image] if object_available?\n\n if image.respond_to?(:attached?) && image.attached?\n url_helpers.url_for(image.representation(Integral.image_transformation_options.merge!(resize_to_limit: Integral.image_sizes[size])))\n elsif image.present?\n image\n else\n fallback_image_url\n end\n end",
"def image_path(image)\r\n image.rel_path\r\n end",
"def image_url\n product.images.first.try(:attachment).try(:url)\n end",
"def image_url\n self.filename.url \n end",
"def image_url\n model.image_url.presence || h.asset_path('face.jpg')\n end",
"def image_url\n Image.find(image_id).url\n end",
"def image_url\n image_uri\n end",
"def image\n @path\n end",
"def logo_path(ngo)\n if ngo.image.attached?\n Rails.application.routes.url_helpers.rails_blob_path(ngo.image, only_path: true)\n else\n ActionController::Base.helpers.image_path('image_not_found.png')\n end\n end",
"def image_path\n thumbnail_url\n end",
"def photo_url\n defined?(object.photo) ? object.photo.url : ''\n end",
"def image_url\n image.url(:medium)\n end",
"def avatar\n if object.avatar.attached?\n if Rails.env === 'production'\n object.avatar.url\n else\n rails_blob_url(object.avatar)\n end\n end\n end",
"def image_url\n image.present? ? image.url : ''\n end",
"def avatar_url\n self.avatar.attachment.nil? ? '' :\n \"#{Rails.configuration.api_url}#{Rails.application.routes.url_helpers.rails_blob_path(self.avatar, only_path: true)}\"\n end",
"def avatar_url\n self.avatar.attachment.nil? ? '' :\n \"#{Rails.configuration.api_url}#{Rails.application.routes.url_helpers.rails_blob_path(self.avatar, only_path: true)}\"\n end",
"def download_url\n ActiveStorage::Current.host = Rails.application.routes.default_url_options[:host] if ActiveStorage::Current.host.blank?\n file.attached? ? file.blob.url : ''\n end",
"def image_column(record)\n image_tag url_for_file_column(record, 'image') if record.image\nend",
"def file_url\n file.attached? ? url_for(file) : ''\n end",
"def blob\n @blob ||= image.to_blob\n end",
"def image_url\n url_for(object.profile_pic)\n end",
"def medium_image_path\n rails_representation_url(image.variant(resize: '500x500'), only_path: true)\n end",
"def image_path\r\n if self.image.nil? then\r\n return item.image_path\r\n else\r\n return \"/images/items/\" + self.image\r\n end\r\n end",
"def image_url\n is_processed ?\n FileSystem.url(image_path) : \n orig_image_url\n end",
"def image_url\n is_processed ?\n FileSystem.url(image_path) : \n orig_image_url\n end",
"def file_on_disk\n ActiveStorage::Blob.service.send(:path_for, file.key)\n end",
"def get_attachment_url\n return self.attachment.url unless self.attachment.blank?\n end",
"def get_image_url\n image_url = Storage.get_file_url(ENV['AWS_S3_DIR_PAGES'], self.issue_id, self.filename )\n return image_url\n end",
"def thumbnail\n \tobject.file.url(:thumb)\n end",
"def thumbnail_url\n company.image.url(:thumbnail)\n end",
"def attachment_path\n return unless attachment.attached?\n\n attachment.service_url\n end",
"def image_path\n \"/image_store/#{id}.#{extension}\"\n end",
"def medium_image_path\n rails_representation_url(image.variant(resize_to_limit: [500, nil]), only_path: true)\n end",
"def thumb_image_path\n begin\n self.attachment.url(:thumb) ? self.attachment.url(:thumb) : \"/public/no-image.png\"\n rescue\n \"/public/no-image.png\"\n end\n end",
"def image_url\n return @image_url\n end",
"def image_url\n self.data['image_url'] || nil\n end",
"def image_url\n image.url.split('?').first if image\n end",
"def image_url\n image.url.split('?').first if image\n end",
"def attachment_path\n return unless attachment?\n\n case attachment.options[:storage]\n when :filesystem then attachment.path\n else attachment.url\n end\n end",
"def user_img_URL\n self.user.image_url\n end",
"def photo_path\n if doctor_image\n doctor_image.public_filename\n else\n self.doctor.photo_path\n end\n end",
"def avatar_path\n if ENV[\"FALLBACK_ICONS_DEBUG\"]\n return ActionController::Base.helpers.asset_path(self.class.image_files(:robot).sample)\n end\n\n if avatar.attached?\n # ▼Activestorrage service_url missing default_url_options[:host] · Issue #32866 · rails/rails\n # https://github.com/rails/rails/issues/32866\n Rails.application.routes.url_helpers.rails_blob_path(avatar, only_path: true)\n else\n list = self.class.image_files(race_info.key)\n file = list[(id || self.class.count.next).modulo(list.size)]\n ActionController::Base.helpers.asset_path(file) # asset_url にしてもURLにならないのはなぜ?\n end\n end",
"def image_if_present\n image? ? image : nil\n end",
"def imgurl\n picref.imgurl if picref\n end",
"def extract_url(resource)\n rails_blob_path(resource, disposition: 'attachment', only_path: true)\n end",
"def image_path\n \"#{PATH}/#{image_filename}\"\n end",
"def get_email_image(image_path)\n # Return the path as a string\n return image_path\nend",
"def pic_url\n {\n picture: self.object.pic.service_url\n }\n end",
"def upload_url\n return unless @data['image']\n # Isn't actually displayed in-app without this set\n return unless image['property'] == 'image'\n file(@data['image'])\n end",
"def mini_url\n object.attachment.url('mini')\n end",
"def image_link(record)\n if record.uploads.first.present?\n link_to record do\n image_tag record.uploads.first.image.url(:thumb)\n end\n else\n 'No Images'\n end\n end",
"def base_image\n self\n end",
"def image\n object.send(attribute_name.to_sym)\n end",
"def file_path\n base_image ? base_image.base_filename : nil\n end",
"def non_object_image_url(size: :medium)\n if non_object_image.present?\n url_helpers.url_for(non_object_image.representation(Integral.image_transformation_options.merge!(resize_to_limit: Integral.image_sizes[size])))\n else\n fallback_image_url\n end\n end",
"def main_image\n self.images.first.image\n end",
"def file_representation\n if self.is_image?\n self.image.url\n elsif self.is_pdf?\n 'publicities/pdf.png'\n elsif self.is_office?\n 'publicities/office.png'\n elsif self.is_compressed_file?\n 'publicities/zip.png'\n else\n 'publicities/file.png'\n end\n end",
"def original\n \tobject.file.url(:large)\n end",
"def get_og_image_url\n og_image_filename = self.filename.split('.')[0] + \"_open-graph.jpg\"\n og_image_url = Storage.get_file_url(ENV['AWS_S3_DIR_PAGES'], self.issue_id, og_image_filename )\n return og_image_url\n end",
"def image()\n @image__\n end",
"def picture\n if model.picture and File.file?(model.asset_path_for_image)\n model.picture\n else\n model.update_cache\n ''\n end\n end",
"def image\n if attachment?\n attachment.url(:large)\n elsif filename?\n \"/images/slides/#{filename}\"\n else\n \"/images/slides/default.jpg\"\n end\n end",
"def image?\n self.image.file?\n end",
"def image?\n self.image.file?\n end",
"def has_image?\n \t# self.image.file?\n true\n end",
"def has_attached_image(attachment_name, param_name=nil)\n Spritz::ASSET_STYLES.keys.each do |image_name|\n method_name = (param_name.blank? ? '' : \"#{param_name}_\") + \"#{image_name}_path\"\n eval <<-END\n def #{method_name}\n @#{attachment_name}_#{image_name}_path ||= source.#{attachment_name}.file? ? source.#{attachment_name}.url(:#{image_name}) : ''\n end\n END\n end\n end",
"def image_location\n src || ''\n end",
"def show\n @main_image = @camp.images.first&.attachment&.url(:large)\n end",
"def image_read_path\n @image_read_path\n end",
"def thumb_url\n image.url(:thumbnail)\n end",
"def thumb_url\n image.url(:thumbnail)\n end",
"def image_url\n return '' if product_images.empty?\n product_images[0].filename.url\n end",
"def image\n if attachment?\n attachment.url(:large)\n elsif filename?\n \"/images/menu/#{filename}\"\n else\n nil\n end\n end",
"def photo__path\r\nif !@photo_cache.blank? && !@photo_cache[:path].blank?\r\n @photo_cache[:path]\r\nelse\r\n File.join(FILES_DEST_PHOTO, \"#{self.id}_#{self.photo__name}\")\r\nend\r\nend",
"def document_attachment\n \"#{Rails.root}/uploads/#{document.url}\"\n end",
"def image_url\n# Somehow the picture field returns false for 'nil?' regardless of wether it's set or not\n# So we'll have to check if the size of the url is 0 to see if it exists\n# There should be a better way to do this, probably?\nif self.picture.size == 0\n\tself.profile_picture.nil? ? 'image-unknown.jpg' : self.profile_picture\nelse \n\tself.picture.ava\nend\nend",
"def the_image\n if object.is_group_conversation?\n object.image.url\n else\n participant = other_participant\n Rails.logger.info \"Error: #{object.inspect}\" unless participant.present?\n participant.avatar_url(:now)\n end\n end",
"def image\n begin\n #send_file File.join(APP_CONFIG['part_image_path'],@part.id.to_s,@part.image_name.url.split(\"/\").last),:disposition => 'inline'\n if File.exists?(File.join(params[:image]))\n data = open(params[:image])\n send_data data.read, disposition: 'inline', stream: 'true', stream: 'true'\n #send_file File.join(params[:image]),:disposition => 'inline'\n else\n data = open(\"#{Rails.root}/public/image_not_available.jpg\")\n send_data data.read, disposition: 'inline', stream: 'true', stream: 'true'\n end\n\n rescue\n \"No Image Found\"\n end\n end",
"def default_image\n self.attachments.for(\"default_image\")\n end",
"def image\n return unless resource.avatar\n \"#{Seek::Config.site_base_host}/#{resource.class.table_name}\" \\\n \"/#{resource.id}/avatars/#{resource.avatar.id}?size=250\"\n end",
"def relative_url_fragment_to_jpg\n return \"/#{IMAGEDB_FOLDER}/#{self.id}.jpg\"\n end",
"def small_image_url\n self.small_image.convert('-resize 50%').url\n end",
"def avatar_photo (person)\n if person.image.attached?\n image_tag person.image\n else\n image_tag \"static/placeholder.jpg\"\n end\n end",
"def latest_image\n attachments.present? ? attachments.last.document.url(:medium) : \"#{APP_URL}/images/missing.png\"\n end",
"def photo_path\n\"/photo_store/#{id}.#{extension}\"\nend",
"def cl_photo\n if photo?\n photo\n else\n 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSb0kZ2CA6D46RXZVJ3dvJPusC66fBq1uENE8jN3q8golJ73Ayd'\n end\n end",
"def photo_path\n \"/photo_store/#{id}.#{extension}\"\n end",
"def image\n\n end",
"def attachment_url(resource, version = :thumb_64)\n uploader = if resource.respond_to?(:mount_on)\n resource\n else\n extract_uploader(resource)\n end\n\n uploader.present? ? uploader.url(version) : 'no-img-fallback.png'\n end",
"def entity_image_url(entity, size) \n url = entity.image_url(size).nil? ? \"default-#{size}.jpg\" : entity.image_url(size).to_s \n link_to image_tag(url), entity, :border => 0, :id => \"persona-rant-widget-image\"\n end"
] |
[
"0.84489053",
"0.824382",
"0.8120302",
"0.79041463",
"0.77457637",
"0.76969075",
"0.7611494",
"0.7514989",
"0.7447849",
"0.7389016",
"0.7373772",
"0.7322345",
"0.72447383",
"0.7235509",
"0.7225533",
"0.7209284",
"0.7102403",
"0.70918673",
"0.7075643",
"0.70711476",
"0.705313",
"0.7033844",
"0.7008846",
"0.7001902",
"0.7000012",
"0.6886921",
"0.68843776",
"0.68810296",
"0.68803304",
"0.6878775",
"0.68543774",
"0.6808565",
"0.6785959",
"0.6746768",
"0.67290586",
"0.67290586",
"0.6724603",
"0.67151606",
"0.66914225",
"0.6660177",
"0.66584754",
"0.66548973",
"0.66469616",
"0.6639348",
"0.663085",
"0.661076",
"0.6597808",
"0.65701497",
"0.65701497",
"0.65509266",
"0.6537775",
"0.6537685",
"0.6519217",
"0.65192145",
"0.65086067",
"0.6504769",
"0.65044093",
"0.64988697",
"0.64906394",
"0.64847875",
"0.6482358",
"0.6462742",
"0.6456247",
"0.6447131",
"0.6430678",
"0.6414684",
"0.6412009",
"0.64118093",
"0.6407255",
"0.64029306",
"0.63964236",
"0.6392829",
"0.6385731",
"0.6374251",
"0.6374251",
"0.6369516",
"0.63656557",
"0.63650197",
"0.63625675",
"0.63573486",
"0.63341993",
"0.63341993",
"0.631505",
"0.6313387",
"0.62980855",
"0.62917554",
"0.6286677",
"0.62841296",
"0.6260517",
"0.62585634",
"0.62568784",
"0.62504333",
"0.6247246",
"0.622981",
"0.6226635",
"0.6222733",
"0.62220407",
"0.62176734",
"0.6211724",
"0.62099755",
"0.6205893"
] |
0.0
|
-1
|
test the validations inside the model
|
def test_original_source_code_01
original_source_code = OriginalSourceCode.new(:original_file_id => 1,
:line_number => 2,
:line_content => "y1",
:error_line => 45)
assert original_source_code.save
orginal_source_code_copy = OriginalSourceCode.find(original_source_code.id)
assert_equal original_source_code.line_number,orginal_source_code_copy.line_number
assert original_source_code.valid?
assert original_source_code.destroy
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run_validations\n true\n end",
"def validation; end",
"def validation; end",
"def validate\n \n \n end",
"def validate\r\n\r\n end",
"def validate\n test_case.assert_valid @object\n end",
"def model_valid?\n true\n end",
"def model_valid?\n true\n end",
"def validate!\n # pass\n end",
"def validate\n end",
"def validate\n\n end",
"def extra_validations\n success\n end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def is_valid; end",
"def validate\n valid?\n end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def validate\n # add errors if not validate\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate!\n true\n end",
"def validate\n validate_amount\n validate_game\n validate_period\n end",
"def subclass_validations ; true ; end",
"def do_validation \n return true if self.ok\n set_ok\n self.ok\n end",
"def validate\r\n validate! rescue false\r\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def custom_validations\n self.validate_baseline && validate_baseline_date && \n self.validate_trial_days && self.validates_goal_name && self.validation_due_date\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def is_valid?\n end",
"def run_validations(context)\n __run_validations__(context)\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate!\n\t\t\t\treturn true\n\t\t\tend",
"def validator; end",
"def is_valid\n\tend",
"def is_valid\n\tend",
"def validate\r\n @invalid=false\r\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:rule_code => self.rule_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_rule\n\t end\nend",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def test_presence\n item = Item.new\n assert !item.valid?\n assert_equal @@error[:blank], item.errors.on(:user_id)\n assert_equal @@error[:blank], item.errors.on(:date)\n assert_equal @@error[:blank], item.errors.on(:value)\n end",
"def assert_valid(field, *values)\n __model_check__\n values.each do |value|\n o = __setup_model__(field, value)\n if o.valid?\n assert_block { true }\n else\n messages = [o.errors[field]].flatten\n assert_block(\"unexpected invalid field <#{o.class}##{field}>, value: <#{value.inspect}>, errors: <#{o.errors[field].inspect}>.\") { false }\n end\n end\n end",
"def validate\n @invalid=false\n end",
"def validate\n true\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n validate\n end",
"def run_validations!\n run_callbacks(:validation) do\n super\n end\n end",
"def validations\n {}\n end",
"def is_valid\n return true\n end",
"def test_validity\r\n assert @valid_skill.valid?\r\n end",
"def validated; end",
"def test_valid?\n ex = assert_raise( RuntimeError ) { Tui::Model::Integer.new( 'lab1', 'x' ); }\n base = Tui::Model::Integer.new( 'lab1' )\n assert_false base.valid?( 'a' )\n assert_true base.valid?( 1 )\n ex = assert_raise( RuntimeError ) { base.value = 'a'; }\n assert_equal( 'Invalid value for model type Tui::Model::Integer!', ex.message )\n end",
"def should_validate\n validation_trigger\n end",
"def test_invalid_with_empty_rule_name_or_state_or_logic\n owner = people(:valid_person)\n rule = Rule.new(:person_id => owner.id)\n assert !rule.valid?\n # The rule_name field should have validation errors\n assert rule.errors[:rule_name].any?\n # The state field should have validation errors\n assert rule.errors[:state].any?\n # The logic field should have validation errors\n assert rule.errors[:logic].any?\n end",
"def validated?; end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?(context = :default)\n model = respond_to?(:model) ? self.model : self.class\n model.validators.execute(context, self)\n end",
"def valid?\n reset_errors\n valid_date?\n valid_user?\n valid_activity_type?\n self.errors.empty?\n end",
"def validate\n validate_root\n validate_associated\n valid?\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:temperature_device_type_code => self.temperature_device_type_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_temperature_device_type\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:unit_type_code => self.unit_type_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_unit_type\n\t end\nend",
"def valid; end",
"def assert_valid model, msg=nil\n valid = model.valid?\n msg = [\"Expected #{model.class} to be valid but it had these errors:\",\n *model.errors.full_messages.map { |message| \" - #{message}\" }].join(\"\\n\")\n assert valid, msg\n end",
"def pre_validation\n\n\n end",
"def validate \n #\tfirst check whether combo fields have been selected\n is_valid = true\n if is_valid\n is_valid = ModelHelper::Validations.validate_combos([{:qc_test_id => self.qc_test_id}],self) \n end\n # #now check whether fk combos combine to form valid foreign keys\n # if is_valid\n # is_valid = set_qc_test\n # end\n # if is_valid\n # is_valid = ModelHelper::Validations.validate_combos([{:qc_inspection_type_code => self.qc_inspection_type_code}],self) \n # end\n # #now check whether fk combos combine to form valid foreign keys\n # if is_valid\n # is_valid = set_qc_inspection_type\n # end\n end",
"def supports_validations?\n true\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n end",
"def valid?\n end",
"def test_valid?\n base = Tui::Model::Base.new( 'lab1' )\n ex = assert_raise( RuntimeError ) { base.valid?( 1 ); }\n assert_equal( 'Method Tui::Model::Base::valid? not implemented!', ex.message )\n ex = assert_raise( RuntimeError ) { base.value = 1; }\n assert_equal( 'Method Tui::Model::Base::valid? not implemented!', ex.message )\n end",
"def test_validations\n a = Address.new\n a.first_name = 'X'\n a.last_name = 'Y'\n a.address_1 = 'Z'\n a.city = 'C'\n a.postcode = '1'\n assert !a.valid?\n # assert a.errors.invalid?(:first_name)\n # assert a.errors.invalid?(:last_name)\n # assert a.errors.invalid?(:address_1)\n # assert a.errors.invalid?(:city)\n # assert a.errors.invalid?(:postcode)\n # assert a.errors.invalid?(:state)\n # assert a.errors.invalid?(:country)\n a.first_name = 'Xavier'\n a.last_name = 'Yellownose'\n a.address_1 = 'Zero Fool St.'\n a.city = 'Cumberbund'\n a.postcode = '10000'\n a.state = states(:state1)\n a.country = countries(:canada)\n assert a.valid?\n end",
"def validate\n super \n end",
"def test_person_invalidity\n assert !@invalid_person.valid?\n attributes = [:username, :email]\n attributes.each do |attribute|\n assert @invalid_person.errors[attribute].any?\n end\n end",
"def test_invalid_logic\n owner = people(:valid_person)\n rule = Rule.new(:person_id=>owner.id,\n :rule_name=>\"test\",\n :state=>\"active\",\n :logic=>\"aaaaaand\")\n assert !rule.valid?\n # The logic field should have validation errors\n assert rule.errors[:logic].any?\n end",
"def run_validations!\n super\n include_typecasting_errors\n errors.empty?\n end",
"def validate\n is_valid = true\n\n if is_valid\n is_valid = ModelHelper::Validations.validate_combos([{:order_type_id => self.order_type_id}], self)\n end\n if is_valid\n is_valid = ModelHelper::Validations.validate_combos([{:trading_partner_party_role_id => self.trading_partner_party_role_id}], self)\n end\n\n if is_valid\n is_valid = ModelHelper::Validations.validate_combos([{:customer_party_role_id => self.customer_party_role_id}], self)\n end\n end",
"def check\n if valid?\n report_template(:ok)\n else\n report_template(:fail, VALIDATOR_MISSING)\n end\n end",
"def assert_valid\n raise ValidationError, \"no name\" unless name\n raise ValidationError, \"no version\" unless version\n raise ValidationError, \"no summary\" unless summary\n #raise ValidationError, \"no maintainer\" unless maintainer\n #raise ValidationError, \"no homepage\" unless homepage\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:mark_code => self.mark_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_mark\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def test_invalid_with_empty_attributes\r\n fee_schedule = FeeSchedule.new\r\n assert !fee_schedule.valid?, fee_schedule.errors.full_messages\r\n assert fee_schedule.errors.invalid?(:start_date)\r\n assert fee_schedule.errors.invalid?(:end_date)\r\n end",
"def test_invalid_with_empty_attributes\n user = User.new\n assert !user.valid?\n assert user.errors.invalid?(:uniqueid)\n assert user.errors.invalid?(:password)\n assert user.errors.invalid?(:first_name)\n assert user.errors.invalid?(:last_name)\n assert user.errors.invalid?(:email)\n end",
"def test_validate\n naming = Naming.new\n assert_not(naming.save)\n assert_equal(3, naming.errors.count)\n assert_equal(:validate_naming_name_missing.t, naming.errors[:name].first)\n assert_equal(:validate_naming_observation_missing.t,\n naming.errors[:observation].first)\n assert_equal(:validate_naming_user_missing.t, naming.errors[:user].first)\n end",
"def test_invalid_with_empty_attributes\r\n patient = Patient.new\r\n assert !patient.valid?, patient.errors.full_messages\r\n assert patient.errors.invalid?(:first_name)\r\n assert patient.errors.invalid?(:last_name)\r\n assert patient.errors.invalid?(:dob)\r\n assert patient.errors.invalid?(:ssn)\r\n assert patient.errors.invalid?(:address)\r\n assert patient.errors.invalid?(:city)\r\n assert patient.errors.invalid?(:state)\r\n assert patient.errors.invalid?(:zipcode)\r\n assert patient.errors.invalid?(:sex)\r\n end",
"def test_spec_invalidity\n assert !@invalid_spec.valid?\n attributes = [:gender, :zip_code]\n attributes.each do |attr|\n assert @invalid_spec.errors.invalid?(attr)\n end\n end",
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:target_market_name => self.target_market_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_target_market\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend",
"def test_invalid_with_empty_attributes\n batch = Batch.new\n assert !batch.valid?\n assert batch.errors.invalid?(:batchid)\n assert batch.errors.invalid?(:facility)\n end",
"def test_invalid_with_blank_attributes\n offer = Offer.new\n assert !offer.valid?\n assert !offer.errors.invalid?(:saleman_id)\n assert offer.errors.invalid?(:name)\n assert !offer.errors.invalid?(:name_normalized)\n assert offer.errors.invalid?(:amount)\n assert offer.errors.invalid?(:deal_date)\n assert offer.errors.invalid?(:customer_id)\n assert !offer.errors.invalid?(:description)\n assert offer.errors.invalid?(:status_id)\n assert !offer.errors.invalid?(:weight)\n assert !offer.errors.invalid?(:description_normalized)\n assert !offer.errors.invalid?(:delta)\n end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def valid?; end",
"def test_valid_with_attributes\r\n patient = Patient.new\r\n patient.first_name = @patient.first_name\r\n patient.last_name = @patient.last_name\r\n patient.dob = @patient.dob\r\n patient.ssn = @patient.ssn\r\n patient.address = @patient.address\r\n patient.apt_suite = @patient.apt_suite\r\n patient.address_line1 = @patient.address_line1\r\n patient.city = @patient.city\r\n patient.state = @patient.state\r\n patient.zipcode = @patient.zipcode\r\n patient.sex = @patient.sex\r\n assert patient.valid?, patient.errors.full_messages \r\n end"
] |
[
"0.7818588",
"0.7491052",
"0.7491052",
"0.7379029",
"0.73310715",
"0.7300106",
"0.72885185",
"0.72885185",
"0.72578937",
"0.7235839",
"0.72202706",
"0.7211639",
"0.71838045",
"0.71838045",
"0.71838045",
"0.71838045",
"0.715374",
"0.715374",
"0.715374",
"0.7083311",
"0.70791095",
"0.707469",
"0.707469",
"0.707469",
"0.70545757",
"0.70545757",
"0.70545757",
"0.703749",
"0.70052683",
"0.69966364",
"0.69956553",
"0.6976127",
"0.69667745",
"0.6955596",
"0.6950742",
"0.69229496",
"0.6898003",
"0.68865603",
"0.68686646",
"0.68570364",
"0.6851922",
"0.6847532",
"0.68392324",
"0.68392324",
"0.6826594",
"0.6815058",
"0.67909056",
"0.67909056",
"0.6770113",
"0.6759211",
"0.6758266",
"0.67455673",
"0.6744501",
"0.67410696",
"0.67355275",
"0.6729715",
"0.67296505",
"0.67266023",
"0.67231005",
"0.66946477",
"0.66854286",
"0.6676347",
"0.6657523",
"0.66531634",
"0.66376936",
"0.6632574",
"0.66264033",
"0.6619467",
"0.6598804",
"0.6598531",
"0.65967757",
"0.6590336",
"0.6584123",
"0.6582964",
"0.6582964",
"0.6582964",
"0.6582964",
"0.6576969",
"0.65701336",
"0.6566165",
"0.6538943",
"0.6534685",
"0.6532427",
"0.653016",
"0.65286815",
"0.6524116",
"0.65118206",
"0.65109944",
"0.6508825",
"0.6507052",
"0.6506349",
"0.65011793",
"0.6500112",
"0.64875484",
"0.64759123",
"0.6471115",
"0.6471115",
"0.6471115",
"0.6471115",
"0.6471115",
"0.64678323"
] |
0.0
|
-1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.